(file) Return to IndicationService.cpp CVS log (file) (dir) Up to [Pegasus] / pegasus / src / Pegasus / IndicationService

   1 kumpf 1.1 //%/////////////////////////////////////////////////////////////////////////////
   2           //
   3 kumpf 1.47 // Copyright (c) 2000, 2001, 2002 BMC Software, Hewlett-Packard Company, IBM,
   4 kumpf 1.1  // The Open Group, Tivoli Systems
   5            //
   6            // Permission is hereby granted, free of charge, to any person obtaining a copy
   7 kumpf 1.47 // of this software and associated documentation files (the "Software"), to
   8            // deal in the Software without restriction, including without limitation the
   9            // rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
  10 kumpf 1.1  // sell copies of the Software, and to permit persons to whom the Software is
  11            // furnished to do so, subject to the following conditions:
  12 kumpf 1.27 // 
  13 kumpf 1.47 // THE ABOVE COPYRIGHT NOTICE AND THIS PERMISSION NOTICE SHALL BE INCLUDED IN
  14 kumpf 1.1  // ALL COPIES OR SUBSTANTIAL PORTIONS OF THE SOFTWARE. THE SOFTWARE IS PROVIDED
  15            // "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT
  16 kumpf 1.47 // LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
  17            // PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
  18            // HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
  19 kumpf 1.1  // ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
  20            // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
  21            //
  22            //==============================================================================
  23            //
  24            // Author: Nitin Upasani, Hewlett-Packard Company (Nitin_Upasani@hp.com)
  25            //
  26 kumpf 1.27 // Modified By:  Carol Ann Krug Graves, Hewlett-Packard Company 
  27 kumpf 1.1  //               (carolann_graves@hp.com)
  28 kumpf 1.66 // 		 Ben Heilbronn, Hewlett-Packard Company
  29 kumpf 1.1  //               (ben_heilbronn@hp.com)
  30 kumpf 1.66 // 		 Yi Zhou, Hewlett-Packard Company (yi_zhou@hp.com)
  31 david 1.71 //               Dave Rosckes (rosckes@us.ibm.com)
  32 kumpf 1.1  //
  33            //%/////////////////////////////////////////////////////////////////////////////
  34            
  35            #include <Pegasus/Common/Config.h>
  36 kumpf 1.17 #include <Pegasus/Common/Constants.h>
  37 kumpf 1.60 #include <Pegasus/Common/ArrayInternal.h>
  38 kumpf 1.1  #include <Pegasus/Common/CIMDateTime.h>
  39            #include <Pegasus/Common/CIMProperty.h>
  40 kumpf 1.16 #include <Pegasus/Common/HashTable.h>
  41 kumpf 1.1  #include <Pegasus/Common/MessageQueue.h>
  42 kumpf 1.73 #ifdef PEGASUS_INDICATION_PERFINST
  43            #include <Pegasus/Common/Stopwatch.h>
  44            #endif
  45 kumpf 1.1  #include <Pegasus/Common/System.h>
  46            #include <Pegasus/Common/Tracer.h>
  47 kumpf 1.6  #include <Pegasus/Common/XmlWriter.h>
  48 kumpf 1.36 #include <Pegasus/Common/PegasusVersion.h>
  49 mday  1.73.4.1 #include <Pegasus/Common/AcceptLanguages.h> // l10n  
  50                #include <Pegasus/Common/ContentLanguages.h> // l10n
  51 kumpf 1.1      #include <Pegasus/Repository/CIMRepository.h>
  52 kumpf 1.12     #include <Pegasus/Server/ProviderRegistrationManager/ProviderRegistrationManager.h>
  53 kumpf 1.1      #include <Pegasus/WQL/WQLParser.h>
  54                #include <Pegasus/WQL/WQLSelectStatement.h>
  55                
  56                #include "IndicationService.h"
  57                
  58 mday  1.73.4.2 // l10n
  59                #include <Pegasus/Common/MessageLoader.h>
  60                #include <Pegasus/Common/String.h>
  61                
  62 kumpf 1.1      PEGASUS_USING_STD;
  63                
  64                PEGASUS_NAMESPACE_BEGIN
  65                
  66 kumpf 1.55     // ATTN-RK-20020730: Temporary hack to fix Windows build
  67                Boolean ContainsCIMName(const Array<CIMName>& a, const CIMName& x)
  68                {
  69                    Uint32 n = a.size();
  70                
  71                    for (Uint32 i = 0; i < n; i++)
  72                    {
  73                        if (a[i].equal(x))
  74                            return true;
  75                    }
  76                
  77                    return false;
  78                }
  79                
  80 kumpf 1.44     Mutex IndicationService::_mutex;
  81                
  82 kumpf 1.12     IndicationService::IndicationService (
  83                    CIMRepository * repository,
  84 kumpf 1.14         ProviderRegistrationManager * providerRegManager)
  85 kumpf 1.30         : Base (PEGASUS_QUEUENAME_INDICATIONSERVICE, 
  86 kumpf 1.17                 MessageQueue::getNextQueueId ()),
  87 kumpf 1.12              _repository (repository),
  88 kumpf 1.14              _providerRegManager (providerRegManager)
  89 kumpf 1.11     {
  90 kumpf 1.38         try
  91                    {
  92                        //
  93                        //  Initialize
  94                        //
  95                        _initialize ();
  96                    }
  97                    catch (Exception e)
  98                    {
  99                        //
 100                        //  ATTN-CAKG-P3-20020425: Log a message
 101                        //
 102                    }
 103 kumpf 1.11     }
 104 kumpf 1.1      
 105 kumpf 1.11     IndicationService::~IndicationService (void)
 106                {
 107                }
 108 kumpf 1.1      
 109 kumpf 1.11     void IndicationService::_handle_async_request(AsyncRequest *req)
 110                {
 111                    if ( req->getType() == async_messages::CIMSERVICE_STOP )
 112                    {
 113                        req->op->processing();
 114 mday  1.72             handle_CimServiceStop(static_cast<CimServiceStop *>(req));
 115 kumpf 1.73     
 116 kumpf 1.11             //
 117                        //  Call _terminate
 118                        //
 119                        _terminate ();
 120                    }
 121 kumpf 1.43         else if (req->getType () == async_messages::CIMSERVICE_START)
 122 kumpf 1.11         {
 123                        req->op->processing ();
 124 kumpf 1.1      
 125 kumpf 1.11             handle_CimServiceStart (static_cast <CimServiceStart *> (req));
 126                    }
 127                    else if ( req->getType() == async_messages::ASYNC_LEGACY_OP_START )
 128                    {
 129 mday  1.40            try 
 130                       {
 131                	  req->op->processing();
 132                	  Message *legacy = 
 133                	     (static_cast<AsyncLegacyOperationStart *>(req)->get_action());
 134                	  legacy->put_async(req);
 135                	  
 136                	  handleEnqueue(legacy);
 137                       }
 138                       catch(Exception & )
 139                       {
 140                	  PEG_TRACE_STRING(TRC_INDICATION_SERVICE, Tracer::LEVEL3, 
 141                			   "Caught Exception in IndicationService while handling a wrapped legacy  message ");
 142                	  _make_response(req, async_results::CIM_NAK );
 143                       }
 144                       
 145 kumpf 1.11             return;
 146                    }
 147                    else
 148                        Base::_handle_async_request(req);
 149                }
 150 kumpf 1.1      
 151 kumpf 1.11     void IndicationService::handleEnqueue(Message* message)
 152                {
 153 kumpf 1.73     #ifdef PEGASUS_INDICATION_PERFINST
 154                    Stopwatch stopWatch;
 155                #endif
 156 mday  1.40     	  
 157 mday  1.73.4.1 // l10n
 158                   // Set the client's requested language into this service thread.
 159                   // This will allow functions in this service to return messages
 160                   // in the correct language.
 161                   CIMMessage * msg = dynamic_cast<CIMMessage *>(message);
 162                   if (msg != NULL)
 163                   {
 164                	   AcceptLanguages *langs = 
 165                   			new AcceptLanguages(msg->acceptLanguages);	
 166                	   Thread::setLanguages(langs);   		
 167                   } 
 168                   else
 169                   {
 170                   		Thread::clearLanguages();
 171                   }          
 172                
 173 mday  1.40        switch(message->getType())
 174                   {
 175                      case CIM_GET_INSTANCE_REQUEST_MESSAGE:
 176                	 try 
 177                	 {
 178 kumpf 1.11     	    _handleGetInstanceRequest(message);
 179 mday  1.40     	 }
 180                	 catch( ... ) 
 181                	 {
 182                
 183                	  ;
 184                	 }
 185                	 
 186                	 break;
 187                
 188                      case CIM_ENUMERATE_INSTANCES_REQUEST_MESSAGE:
 189                	 try 
 190                	 {
 191 kumpf 1.11     	    _handleEnumerateInstancesRequest(message);
 192 mday  1.40     	 }
 193                	 catch( ... ) 
 194                	 {
 195                
 196                	  ;
 197                	 }
 198                	 
 199                	 break;
 200                
 201                      case CIM_ENUMERATE_INSTANCE_NAMES_REQUEST_MESSAGE:
 202                	 try 
 203                	 {
 204                	    
 205 kumpf 1.11     	    _handleEnumerateInstanceNamesRequest(message);
 206 mday  1.40     	 }
 207                	 catch( ... ) 
 208                	 {
 209                
 210                	  ;
 211                	 }
 212                	 
 213                	 break;
 214                
 215                      case CIM_CREATE_INSTANCE_REQUEST_MESSAGE:
 216                	 try 
 217                	 {
 218                	    
 219 kumpf 1.11     	    _handleCreateInstanceRequest(message);
 220 mday  1.40     	 }
 221                	 catch( ... ) 
 222                	 {
 223                
 224                	  ;
 225                	 }
 226                	 break;
 227                
 228                      case CIM_MODIFY_INSTANCE_REQUEST_MESSAGE:
 229                	 try 
 230                	 {
 231                	    
 232 kumpf 1.11     	    _handleModifyInstanceRequest(message);
 233 mday  1.40     	 }
 234                	 catch( ... ) 
 235                	 {
 236                
 237                	  ;
 238                	 }
 239                	 break;
 240                
 241                      case CIM_DELETE_INSTANCE_REQUEST_MESSAGE:
 242                	 try 
 243                	 {
 244 kumpf 1.11     	    _handleDeleteInstanceRequest(message);
 245 mday  1.40     	 }
 246                	 catch( ... ) 
 247                	 {
 248                
 249                	  ;
 250                	 }
 251                	 break;
 252                
 253                      case CIM_PROCESS_INDICATION_REQUEST_MESSAGE:
 254                	 try 
 255                	 {
 256                	    _handleProcessIndicationRequest(message);
 257                	 }
 258                	 catch( ... ) 
 259                	 {
 260                
 261                	    ;
 262                	 }
 263                	 break;
 264                
 265                      case CIM_NOTIFY_PROVIDER_REGISTRATION_REQUEST_MESSAGE:
 266 mday  1.40     	 try 
 267                	 {
 268 kumpf 1.27     	    _handleNotifyProviderRegistrationRequest(message);    
 269 mday  1.40     	 }
 270                	 catch( ... ) 
 271                	 {
 272                
 273                	  ;
 274                	 }
 275                	 break;
 276                
 277                      case CIM_NOTIFY_PROVIDER_TERMINATION_REQUEST_MESSAGE:
 278                	 try 
 279                	 {
 280 kumpf 1.27     	    _handleNotifyProviderTerminationRequest(message);    
 281 mday  1.40     	 }
 282                	 catch( ... ) 
 283                	 {
 284                
 285                	    ;
 286                	 }
 287                	 break;
 288                	 
 289                      default:
 290                	 //
 291                	 //  A message type not supported by the Indication Service
 292                	 //  Should not reach here
 293                	 //
 294                	 // << Mon Apr 29 16:29:10 2002 mdd >>
 295                	 PEG_TRACE_STRING(TRC_INDICATION_SERVICE, Tracer::LEVEL3, 
 296                			  "IndicationService::handleEnqueue(msg *) rcv'd unsupported msg " 
 297                			  + String(MessageTypeToString(message->getType())));
 298                	 break;
 299                   }
 300 kumpf 1.73     
 301                #ifdef PEGASUS_INDICATION_PERFINST
 302                    double elapsed = stopWatch.getElapsed ();
 303                
 304                    Tracer::trace (TRC_INDICATION_SERVICE_INTERNAL, Tracer::LEVEL2, 
 305                        "%s: %.3f seconds", MessageTypeToString (message->getType ()), elapsed);
 306                #endif
 307 mday  1.40     	  
 308                   delete message;
 309 kumpf 1.11     }
 310 kumpf 1.1      
 311 kumpf 1.11     void IndicationService::handleEnqueue(void)
 312                {
 313                    Message * message = dequeue();
 314 kumpf 1.1      
 315 kumpf 1.11         PEGASUS_ASSERT(message != 0);
 316                    handleEnqueue(message);
 317                }
 318 kumpf 1.1      
 319 kumpf 1.11     void IndicationService::_initialize (void)
 320                {
 321 kumpf 1.73     #ifdef PEGASUS_INDICATION_PERFINST
 322                    Stopwatch stopWatch;
 323                #endif
 324                
 325 kumpf 1.46         Array <CIMInstance> activeSubscriptions;
 326                    Array <CIMInstance> noProviderSubscriptions;
 327 kumpf 1.38         Array <ProviderClassList> enableProviders;
 328 kumpf 1.11         Boolean duplicate;
 329 kumpf 1.1      
 330 kumpf 1.48         PEG_METHOD_ENTER (TRC_INDICATION_SERVICE, "IndicationService::_initialize");
 331 mday  1.40      
 332 kumpf 1.11         //
 333                    //  Find required services
 334 kumpf 1.38         //  NOTE: Indication Service expects to find exactly one Provider Manager
 335                    //  Service and exactly one Handler Manager Service
 336 kumpf 1.11         //
 337                    Array <Uint32> pmservices;
 338 kumpf 1.30         find_services (PEGASUS_QUEUENAME_PROVIDERMANAGER_CPP, 0, 0, &pmservices);
 339 kumpf 1.11         pegasus_yield ();
 340 kumpf 1.37         PEGASUS_ASSERT (pmservices.size () == 1);
 341                    _providerManager = pmservices [0];
 342                
 343 kumpf 1.11         Array <Uint32> hmservices;
 344 kumpf 1.30         find_services (PEGASUS_QUEUENAME_INDHANDLERMANAGER, 0, 0, &hmservices);
 345 kumpf 1.11         pegasus_yield ();
 346 kumpf 1.37         PEGASUS_ASSERT (hmservices.size () == 1);
 347                    _handlerService = hmservices [0];
 348                
 349 kumpf 1.11         //
 350 kumpf 1.27         //  FUTURE: Add code to find repository service, if repository becomes a 
 351 kumpf 1.11         //  service
 352                    //
 353 kumpf 1.1      
 354 kumpf 1.11         //
 355 kumpf 1.32         //  Set arrays of valid property values
 356                    //
 357                    _validStates.append (_STATE_UNKNOWN);
 358                    _validStates.append (_STATE_OTHER);
 359                    _validStates.append (_STATE_ENABLED);
 360                    _validStates.append (_STATE_ENABLEDDEGRADED);
 361                    _validStates.append (_STATE_DISABLED);
 362                    _validRepeatPolicies.append (_POLICY_UNKNOWN);
 363                    _validRepeatPolicies.append (_POLICY_OTHER);
 364                    _validRepeatPolicies.append (_POLICY_NONE);
 365                    _validRepeatPolicies.append (_POLICY_SUPPRESS);
 366                    _validRepeatPolicies.append (_POLICY_DELAY);
 367                    _validErrorPolicies.append (_ERRORPOLICY_OTHER);
 368                    _validErrorPolicies.append (_ERRORPOLICY_IGNORE);
 369                    _validErrorPolicies.append (_ERRORPOLICY_DISABLE);
 370                    _validErrorPolicies.append (_ERRORPOLICY_REMOVE);
 371                    _validPersistenceTypes.append (_PERSISTENCE_OTHER);
 372                    _validPersistenceTypes.append (_PERSISTENCE_PERMANENT);
 373                    _validPersistenceTypes.append (_PERSISTENCE_TRANSIENT);
 374                
 375                    //
 376 kumpf 1.11         //  Get existing active subscriptions from each namespace in the repository
 377                    //
 378 kumpf 1.73         activeSubscriptions = _getActiveSubscriptionsFromRepository ();
 379 kumpf 1.11         noProviderSubscriptions.clear ();
 380 kumpf 1.1      
 381 kumpf 1.11         String condition;
 382                    String queryLanguage;
 383                    CIMPropertyList propertyList;
 384 kumpf 1.16         Array <ProviderClassList> indicationProviders;
 385 kumpf 1.1      
 386 kumpf 1.11         for (Uint8 i = 0; i < activeSubscriptions.size (); i++)
 387                    {
 388                        //
 389                        //  Check for expired subscription
 390                        //
 391 kumpf 1.46             if (_isExpired (activeSubscriptions [i]))
 392 kumpf 1.11             {
 393 kumpf 1.46                 CIMObjectPath path = activeSubscriptions [i].getPath ();
 394                            _deleteExpiredSubscription (path);
 395 kumpf 1.27                     
 396 kumpf 1.11                 continue;
 397                        }
 398 kumpf 1.1      
 399 kumpf 1.63             CIMNamespaceName sourceNameSpace;
 400 kumpf 1.73             Array <CIMName> indicationSubclasses;
 401 kumpf 1.38             _getCreateParams 
 402 kumpf 1.46                 (activeSubscriptions [i].getPath ().getNameSpace (),
 403 kumpf 1.73                 activeSubscriptions [i], indicationSubclasses, indicationProviders,
 404 kumpf 1.27                 propertyList, sourceNameSpace, condition, queryLanguage);
 405 kumpf 1.1      
 406 kumpf 1.11             if (indicationProviders.size () == 0)
 407                        {
 408                            //
 409                            //  There are no providers that can support this subscription
 410 kumpf 1.19                 //  Implement the subscription's On Fatal Error Policy
 411                            //  If subscription is not disabled or removed,
 412 kumpf 1.11                 //  Append this subscription to no provider list
 413                            //
 414 kumpf 1.19                 if (!_handleError (activeSubscriptions [i]))
 415                            {
 416                                noProviderSubscriptions.append (activeSubscriptions [i]);
 417                            }
 418 kumpf 1.11                 continue;
 419                        }
 420 kumpf 1.27         
 421 kumpf 1.11             //
 422 kumpf 1.38             //  Send Create request message to each provider
 423 kumpf 1.39             //  NOTE: These Create requests are not associated with a user request,
 424                        //  so there is no associated authType or userName
 425 kumpf 1.15             //  The Creator from the subscription instance is used for userName,
 426                        //  and authType is not set
 427 kumpf 1.11             //
 428 kumpf 1.46             CIMInstance instance = activeSubscriptions [i];
 429 kumpf 1.15             String creator = instance.getProperty (instance.findProperty
 430 kumpf 1.38                 (PEGASUS_PROPERTYNAME_INDSUB_CREATOR)).getValue ().toString ();
 431 mday  1.73.4.2 
 432                //l10n start            
 433 mday  1.73.4.1 	// Get the language tags that were saved with the subscription instance 
 434 mday  1.73.4.2         String acceptLangs = String::EMPTY;
 435                	Uint32 propIndex = instance.findProperty(PEGASUS_PROPERTYNAME_INDSUB_ACCEPTLANGS);
 436                 	if (propIndex != PEG_NOT_FOUND)
 437                        {  
 438                             instance.getProperty(propIndex).getValue().get(acceptLangs);   
 439                        }         
 440                        String contentLangs = String::EMPTY;
 441                	propIndex = instance.findProperty(PEGASUS_PROPERTYNAME_INDSUB_CONTENTLANGS);
 442                 	if (propIndex != PEG_NOT_FOUND)
 443                        {  
 444                             instance.getProperty(propIndex).getValue().get(contentLangs);   
 445                        }
 446                // l10n end     
 447 mday  1.73.4.1 
 448 kumpf 1.38             if (!_sendCreateRequests (indicationProviders, sourceNameSpace,
 449 kumpf 1.11                 propertyList, condition, queryLanguage,
 450 mday  1.73.4.1             activeSubscriptions [i], 
 451                            AcceptLanguages(acceptLangs), // l10n
 452                            ContentLanguages(contentLangs),  // 110n
 453                	    creator))
 454 kumpf 1.15             {
 455 kumpf 1.19                 //
 456                            //  No providers accepted this subscription
 457                            //  Implement the subscription's On Fatal Error Policy
 458                            //  If subscription is not disabled or removed,
 459                            //  Append this subscription to no provider list
 460                            //
 461                            if (!_handleError (activeSubscriptions [i]))
 462                            {
 463                                noProviderSubscriptions.append (activeSubscriptions [i]);
 464                            }
 465 kumpf 1.15                 continue;
 466                        }
 467 kumpf 1.1      
 468 kumpf 1.11             //
 469 kumpf 1.38             //  Merge provider list into list of unique providers to enable
 470 kumpf 1.11             //
 471                        for (Uint8 j = 0; j < indicationProviders.size (); j++)
 472                        {
 473                            duplicate = false;
 474 kumpf 1.38                 for (Uint8 k = 0; k < enableProviders.size () && !duplicate; k++)
 475 kumpf 1.11                 {
 476 kumpf 1.32                     if ((indicationProviders [j].provider.identical 
 477 kumpf 1.38                         (enableProviders [k].provider)))
 478 kumpf 1.11                     {
 479                                    duplicate = true;
 480                                }
 481                            }
 482 kumpf 1.27         
 483 kumpf 1.11                 if (!duplicate)
 484                            {
 485 kumpf 1.38                     enableProviders.append (indicationProviders [j]);
 486 kumpf 1.11                 }
 487                        }
 488 kumpf 1.73     
 489                        //
 490                        //  NOTE: Once bugzilla #63 is fixed, the list of providers passed to 
 491                        //  this function must be not those attempted to enable, but those who 
 492                        //  were successfully enabled (response received)
 493                        //
 494                        _insertToHashTables (activeSubscriptions [i], enableProviders, 
 495                            indicationSubclasses, sourceNameSpace);
 496 kumpf 1.11         }  // for each active subscription
 497 kumpf 1.1      
 498 kumpf 1.11         //
 499                    //  Send alerts for any subscriptions for which there is no longer any
 500                    //  provider
 501                    //
 502                    if (noProviderSubscriptions.size () > 0)
 503                    {
 504                        //
 505                        //  Send NoProviderAlertIndication to handler instances
 506                        //  ATTN: NoProviderAlertIndication must be defined
 507                        //
 508                        CIMInstance indicationInstance = _createAlertInstance
 509                            (_CLASS_NO_PROVIDER_ALERT, noProviderSubscriptions);
 510 kumpf 1.1      
 511 kumpf 1.73             Tracer::trace (TRC_INDICATION_SERVICE, Tracer::LEVEL4,
 512                            "Sending NoProvider Alert for %d subscriptions",
 513                            noProviderSubscriptions.size ());
 514 kumpf 1.11             _sendAlerts (noProviderSubscriptions, indicationInstance);
 515                    }
 516 kumpf 1.1      
 517 kumpf 1.11         //
 518 kumpf 1.38         //  Send Enable message to each provider
 519 kumpf 1.11         //
 520 kumpf 1.38         for (Uint8 m = 0; m < enableProviders.size (); m++)
 521 kumpf 1.11         {
 522                        //
 523 kumpf 1.38             //  Send Enable message 
 524 kumpf 1.11             //
 525 kumpf 1.38             _sendEnable (enableProviders [m]);
 526 kumpf 1.11         }
 527 kumpf 1.1      
 528 kumpf 1.73     #ifdef PEGASUS_INDICATION_PERFINST
 529                    double elapsed = stopWatch.getElapsed ();
 530                
 531                    Tracer::trace (TRC_INDICATION_SERVICE_INTERNAL, Tracer::LEVEL2,
 532                        "%s: %.3f seconds", "Initialize", elapsed);
 533                #endif
 534                
 535 kumpf 1.48         PEG_METHOD_EXIT ();
 536 kumpf 1.11     }
 537 kumpf 1.1      
 538 kumpf 1.11     void IndicationService::_terminate (void)
 539                {
 540 kumpf 1.46         Array <CIMInstance> activeSubscriptions;
 541 kumpf 1.11         CIMInstance indicationInstance;
 542 kumpf 1.1      
 543 kumpf 1.48         PEG_METHOD_ENTER (TRC_INDICATION_SERVICE, "IndicationService::_terminate");
 544 kumpf 1.1      
 545 kumpf 1.11         //
 546 kumpf 1.73         //  Get existing active subscriptions from hash table
 547 kumpf 1.11         //
 548                    activeSubscriptions = _getActiveSubscriptions ();
 549 kumpf 1.1      
 550 kumpf 1.73         if (activeSubscriptions.size () > 0)
 551                    {
 552                        //
 553                        //  Create CimomShutdownAlertIndication instance
 554                        //  ATTN: CimomShutdownAlertIndication must be defined
 555                        //
 556                        indicationInstance = _createAlertInstance (_CLASS_CIMOM_SHUTDOWN_ALERT,
 557                            activeSubscriptions);
 558                    
 559                        //
 560                        //  Send CimomShutdownAlertIndication to each unique handler instance
 561                        //
 562                        Tracer::trace (TRC_INDICATION_SERVICE, Tracer::LEVEL4,
 563                            "Sending CIMServerShutdown Alert for %d subscriptions",
 564                            activeSubscriptions.size ());
 565                        _sendAlerts (activeSubscriptions, indicationInstance);
 566                    }
 567 kumpf 1.1      
 568 kumpf 1.48         PEG_METHOD_EXIT ();
 569 kumpf 1.11     }
 570 kumpf 1.6      
 571 kumpf 1.11     void IndicationService::_handleCreateInstanceRequest (const Message * message)
 572                {
 573 kumpf 1.48         PEG_METHOD_ENTER (TRC_INDICATION_SERVICE,
 574                                      "IndicationService::_handleCreateInstanceRequest");
 575 kumpf 1.6      
 576 kumpf 1.27         CIMCreateInstanceRequestMessage* request = 
 577 kumpf 1.11             (CIMCreateInstanceRequestMessage*) message;
 578 kumpf 1.6      
 579 kumpf 1.23         CIMException cimException;
 580 kumpf 1.6      
 581 kumpf 1.45         CIMObjectPath instanceRef;
 582 kumpf 1.1      
 583 kumpf 1.11         CIMInstance instance = request->newInstance.clone ();
 584 kumpf 1.1      
 585 kumpf 1.11         try
 586                    {
 587                        if (_canCreate (instance, request->nameSpace))
 588                        {
 589                            //
 590                            //  Add creator property to Instance
 591 kumpf 1.27                 //  NOTE: userName is only set in the request if authentication 
 592 kumpf 1.13                 //  is turned on
 593 kumpf 1.11                 //
 594 kumpf 1.13                 String currentUser = request->userName;
 595 kumpf 1.52                 if (instance.findProperty (PEGASUS_PROPERTYNAME_INDSUB_CREATOR) == 
 596                                PEG_NOT_FOUND)
 597 kumpf 1.13                 {
 598 kumpf 1.27                     instance.addProperty (CIMProperty 
 599 kumpf 1.38                         (PEGASUS_PROPERTYNAME_INDSUB_CREATOR, currentUser));
 600 kumpf 1.13                 }
 601 kumpf 1.38                 else 
 602 kumpf 1.13                 {
 603 kumpf 1.38                     CIMProperty creator = instance.getProperty 
 604                                    (instance.findProperty 
 605                                    (PEGASUS_PROPERTYNAME_INDSUB_CREATOR));
 606                                creator.setValue (CIMValue (currentUser));
 607 kumpf 1.13                 }
 608 kumpf 1.27         
 609 mday  1.73.4.1             // l10n
 610                            // Add the language properties to the Instance
 611                            // Note:  These came from the Accept-Language and Content-Language
 612                            // headers in the HTTP messages, and may be empty.
 613                            AcceptLanguages acceptLangs = request->acceptLanguages;
 614                            if (instance.findProperty (PEGASUS_PROPERTYNAME_INDSUB_ACCEPTLANGS) == 
 615                                PEG_NOT_FOUND)
 616                            {
 617                                instance.addProperty (CIMProperty 
 618                                    (PEGASUS_PROPERTYNAME_INDSUB_ACCEPTLANGS, 
 619                                    acceptLangs.toString()));
 620                            }
 621                            else 
 622                            {
 623                                CIMProperty langs = instance.getProperty 
 624                                    (instance.findProperty 
 625                                    (PEGASUS_PROPERTYNAME_INDSUB_ACCEPTLANGS));
 626                                langs.setValue (CIMValue (acceptLangs.toString()));
 627                            } 
 628                
 629                            ContentLanguages contentLangs = request->contentLanguages;
 630 mday  1.73.4.1             if (instance.findProperty (PEGASUS_PROPERTYNAME_INDSUB_CONTENTLANGS) == 
 631                                PEG_NOT_FOUND)
 632                            {
 633                                instance.addProperty (CIMProperty 
 634                                    (PEGASUS_PROPERTYNAME_INDSUB_CONTENTLANGS, 
 635                                    contentLangs.toString()));
 636                            }
 637                            else 
 638                            {
 639                                CIMProperty langs = instance.getProperty 
 640                                    (instance.findProperty 
 641                                    (PEGASUS_PROPERTYNAME_INDSUB_CONTENTLANGS));
 642                                langs.setValue (CIMValue (contentLangs.toString()));
 643                            }                                   
 644                            // l10n -end
 645                
 646 kumpf 1.11                 //
 647 kumpf 1.67                 //  If the instance is of the PEGASUS_CLASSNAME_INDSUBSCRIPTION 
 648                            //  class and subscription state is enabled, determine if any 
 649                            //  providers can serve the subscription
 650 kumpf 1.11                 //
 651                            Uint16 subscriptionState;
 652                            String condition;
 653                            String queryLanguage;
 654                            CIMPropertyList requiredProperties;
 655 kumpf 1.63                 CIMNamespaceName sourceNameSpace;
 656 kumpf 1.73                 Array <CIMName> indicationSubclasses;
 657 kumpf 1.16                 Array <ProviderClassList> indicationProviders;
 658 kumpf 1.73     
 659 kumpf 1.64                 if (instance.getClassName ().equal 
 660                                (PEGASUS_CLASSNAME_INDSUBSCRIPTION))
 661 kumpf 1.11                 {
 662                                //
 663                                //  Get subscription state
 664                                //
 665                                CIMValue subscriptionStateValue;
 666                                subscriptionStateValue = instance.getProperty
 667                                    (instance.findProperty (_PROPERTY_STATE)).getValue ();
 668                                subscriptionStateValue.get (subscriptionState);
 669 kumpf 1.1      
 670 kumpf 1.11                     if ((subscriptionState == _STATE_ENABLED) ||
 671                                    (subscriptionState == _STATE_ENABLEDDEGRADED))
 672                                {
 673 kumpf 1.38                         _getCreateParams (request->nameSpace, instance,
 674 kumpf 1.73                             indicationSubclasses, indicationProviders, 
 675                                        requiredProperties, sourceNameSpace, condition, 
 676                                        queryLanguage);
 677                
 678 kumpf 1.11                         if (indicationProviders.size () == 0)
 679                                    {
 680                                        //
 681 kumpf 1.27                             //  There are no providers that can support this 
 682 kumpf 1.11                             //  subscription
 683                                        //
 684 kumpf 1.48                             PEG_METHOD_EXIT ();
 685 mday  1.73.4.2 			
 686                			// l10n
 687                
 688                                        // throw PEGASUS_CIM_EXCEPTION (CIM_ERR_NOT_SUPPORTED,
 689                			//  _MSG_NO_PROVIDERS);
 690                
 691                			throw PEGASUS_CIM_EXCEPTION_L (CIM_ERR_NOT_SUPPORTED,
 692                				 MessageLoaderParms(_MSG_NO_PROVIDERS_KEY, _MSG_NO_PROVIDERS));
 693                
 694 kumpf 1.11                         }
 695                                }
 696 kumpf 1.27         
 697 kumpf 1.11                     //
 698                                //  Set Time of Last State Change to current date time
 699                                //
 700 kumpf 1.35                     CIMDateTime currentDateTime = 
 701                                    CIMDateTime::getCurrentDateTime ();
 702 kumpf 1.52                     if (instance.findProperty (_PROPERTY_LASTCHANGE) == 
 703                                    PEG_NOT_FOUND)
 704 kumpf 1.11                     {
 705 kumpf 1.27                         instance.addProperty 
 706 kumpf 1.11                             (CIMProperty (_PROPERTY_LASTCHANGE, currentDateTime));
 707                                }
 708 kumpf 1.27                     else 
 709 kumpf 1.11                     {
 710 kumpf 1.27                         CIMProperty lastChange = instance.getProperty 
 711 kumpf 1.11                             (instance.findProperty (_PROPERTY_LASTCHANGE));
 712                                    lastChange.setValue (CIMValue (currentDateTime));
 713                                }
 714 kumpf 1.27         
 715 kumpf 1.13                     CIMDateTime startDateTime;
 716                                if ((subscriptionState == _STATE_ENABLED) ||
 717                                    (subscriptionState == _STATE_ENABLEDDEGRADED))
 718                                {
 719                                    startDateTime = currentDateTime;
 720                                }
 721                                else
 722                                {
 723                                    //
 724                                    //  If subscription is not enabled, set Subscription
 725                                    //  Start Time to null CIMDateTime value
 726                                    //
 727                                    startDateTime = CIMDateTime ();
 728                                }
 729                
 730 kumpf 1.11                     //
 731 kumpf 1.13                     //  Set Subscription Start Time
 732 kumpf 1.11                     //
 733 kumpf 1.52                     if (instance.findProperty (_PROPERTY_STARTTIME) == 
 734                                    PEG_NOT_FOUND)
 735 kumpf 1.11                     {
 736 kumpf 1.27                         instance.addProperty 
 737 kumpf 1.13                             (CIMProperty (_PROPERTY_STARTTIME, startDateTime));
 738 kumpf 1.11                     }
 739 kumpf 1.27                     else 
 740 kumpf 1.11                     {
 741 kumpf 1.27                         CIMProperty startTime = instance.getProperty 
 742 kumpf 1.11                             (instance.findProperty (_PROPERTY_STARTTIME));
 743 kumpf 1.13                         startTime.setValue (CIMValue (startDateTime));
 744 kumpf 1.11                     }
 745                            }
 746 kumpf 1.27         
 747 kumpf 1.11                 //
 748                            //  Create instance in repository
 749                            //
 750                            _repository->write_lock ();
 751 kumpf 1.27             
 752                            try 
 753 kumpf 1.11                 {
 754 kumpf 1.27                     instanceRef = _repository->createInstance (request->nameSpace, 
 755 kumpf 1.11                         instance);
 756 david 1.71     
 757                		Logger::put(Logger::STANDARD_LOG, System::CIMSERVER, Logger::TRACE,
 758                			    "IndicationService::_handleCreateInstanceRequest - Name Space: $0  Instance name: $1",
 759                			    request->nameSpace.getString(),
 760                			    instance.getClassName().getString());
 761 kumpf 1.11                 }
 762 kumpf 1.23                 catch (CIMException & exception)
 763                            {
 764                                cimException = exception;
 765                            }
 766 kumpf 1.11                 catch (Exception & exception)
 767                            {
 768 kumpf 1.23                     cimException = PEGASUS_CIM_EXCEPTION(CIM_ERR_FAILED,
 769                                                                     exception.getMessage());
 770                            }
 771 kumpf 1.19     
 772 kumpf 1.23                 _repository->write_unlock ();
 773 kumpf 1.27             
 774 kumpf 1.23                 if (cimException.getCode() != CIM_ERR_SUCCESS)
 775                            {
 776 kumpf 1.11                     CIMCreateInstanceResponseMessage* response =
 777                                    new CIMCreateInstanceResponseMessage(
 778                                        request->messageId,
 779 kumpf 1.23                             cimException,
 780 kumpf 1.11                             request->queueIds.copyAndPop(),
 781                                        instanceRef);
 782 kumpf 1.27         
 783 kumpf 1.11                     //
 784                                //  Preserve message key
 785                                //
 786                                response->setKey (request->getKey ());
 787 kumpf 1.27         
 788 kumpf 1.11                     //
 789                                //  Set response destination
 790                                //
 791                                response->dest = request->queueIds.top ();
 792 kumpf 1.27         
 793 kumpf 1.69                     //
 794                                //  Set HTTP method in response from request
 795                                //
 796                                response->setHttpMethod (request->getHttpMethod ());
 797                
 798 kumpf 1.11                     Base::_enqueueResponse (request, response);
 799 kumpf 1.27         
 800 kumpf 1.48                     PEG_METHOD_EXIT ();
 801 kumpf 1.11                     return;
 802                            }
 803 kumpf 1.27             
 804 kumpf 1.11                 //
 805 kumpf 1.67                 //  If the instance is of the PEGASUS_CLASSNAME_INDSUBSCRIPTION 
 806                            //  class and subscription state is enabled, send Create request to 
 807 kumpf 1.11                 //  indication providers
 808                            //
 809 kumpf 1.64                 if (instance.getClassName ().equal 
 810                                (PEGASUS_CLASSNAME_INDSUBSCRIPTION))
 811 kumpf 1.11                 {
 812                                if ((subscriptionState == _STATE_ENABLED) ||
 813                                    (subscriptionState == _STATE_ENABLEDDEGRADED))
 814                                {
 815                                    //
 816 kumpf 1.38                         //  Send Create request message to each provider
 817 kumpf 1.11                         //
 818 kumpf 1.16                         instanceRef.setNameSpace (request->nameSpace);
 819 kumpf 1.46                         instance.setPath (instanceRef);
 820 mday  1.73.4.1 // l10n 
 821 kumpf 1.38                         if (!_sendCreateRequests (indicationProviders, 
 822 kumpf 1.27                             sourceNameSpace, requiredProperties, condition, 
 823 kumpf 1.46                             queryLanguage, instance,
 824 mday  1.73.4.1                         request->acceptLanguages,
 825                                        request->contentLanguages,   
 826 kumpf 1.15                             request->userName, request->authType))
 827                                    {
 828 kumpf 1.48                             PEG_METHOD_EXIT ();
 829 mday  1.73.4.2 
 830                			// l10n
 831                
 832                                        // throw PEGASUS_CIM_EXCEPTION (CIM_ERR_NOT_SUPPORTED,
 833                			// _MSG_NOT_ACCEPTED);
 834                
 835                			throw PEGASUS_CIM_EXCEPTION_L (CIM_ERR_NOT_SUPPORTED,
 836                				 MessageLoaderParms(_MSG_NOT_ACCEPTED_KEY, _MSG_NOT_ACCEPTED));
 837                
 838 kumpf 1.15                         }
 839 kumpf 1.27                 
 840 kumpf 1.11                         //
 841 kumpf 1.38                         //  Send Enable message to each provider
 842 kumpf 1.11                         //
 843                                    for (Uint8 i = 0; i < indicationProviders.size (); i++)
 844                                    {
 845                                        //
 846 kumpf 1.38                             //  Send Enable message 
 847 kumpf 1.11                             //
 848 kumpf 1.38                             _sendEnable (indicationProviders [i]);
 849 kumpf 1.11                         }
 850 kumpf 1.73     
 851                                    //
 852                                    //  NOTE: Once bugzilla #63 is fixed, the list of providers
 853                                    //  passed to this function must be not those attempted to 
 854                                    //  enable, but those who were successfully enabled 
 855                                    //  (response received)
 856                                    //
 857                                    _insertToHashTables (instance, indicationProviders,
 858                                        indicationSubclasses, sourceNameSpace);
 859 kumpf 1.11                     }
 860                            }
 861                        }
 862                    }
 863                    catch (CIMException & exception)
 864                    {
 865 kumpf 1.23             cimException = exception;
 866 kumpf 1.11         }
 867                    catch (Exception & exception)
 868                    {
 869 kumpf 1.23             cimException = PEGASUS_CIM_EXCEPTION(CIM_ERR_FAILED,
 870                                                             exception.getMessage());
 871 kumpf 1.11         }
 872 kumpf 1.1      
 873 kumpf 1.38         //
 874 kumpf 1.39         //  FUTURE: Response should be sent only after Create response
 875 kumpf 1.38         //  has been received
 876                    //
 877 mday  1.73.4.1 // l10n - no Content-Language in response    
 878 kumpf 1.11         CIMCreateInstanceResponseMessage* response =
 879                        new CIMCreateInstanceResponseMessage(
 880                            request->messageId,
 881 kumpf 1.23                 cimException,
 882 kumpf 1.11                 request->queueIds.copyAndPop(),
 883                            instanceRef);
 884 kumpf 1.6      
 885 kumpf 1.11         //
 886                    //  Preserve message key
 887                    //
 888                    response->setKey (request->getKey ());
 889 kumpf 1.27         
 890 kumpf 1.11         //
 891                    //  Set response destination
 892                    //
 893                    response->dest = request->queueIds.top ();
 894 kumpf 1.27         
 895 kumpf 1.69         //
 896                    //  Set HTTP method in response from request
 897                    //
 898                    response->setHttpMethod (request->getHttpMethod ());
 899                
 900 kumpf 1.11         Base::_enqueueResponse (request, response);
 901 kumpf 1.6      
 902 kumpf 1.48         PEG_METHOD_EXIT ();
 903 kumpf 1.11     }
 904 kumpf 1.6      
 905 kumpf 1.11     void IndicationService::_handleGetInstanceRequest (const Message* message)
 906                {
 907 kumpf 1.48         PEG_METHOD_ENTER (TRC_INDICATION_SERVICE,
 908                                      "IndicationService::_handleGetInstanceRequest");
 909 kumpf 1.6      
 910 kumpf 1.27         CIMGetInstanceRequestMessage* request = 
 911 kumpf 1.11             (CIMGetInstanceRequestMessage*) message;
 912 kumpf 1.6      
 913 kumpf 1.23         CIMException cimException;
 914 kumpf 1.11         CIMInstance instance;
 915 mday  1.73.4.1     String contentLangs = String::EMPTY;  // l10n 
 916 kumpf 1.6      
 917 kumpf 1.19         _repository->read_lock ();
 918                
 919 kumpf 1.11         try
 920                    {
 921                        //
 922                        //  Get instance from repository
 923                        //
 924 kumpf 1.27             instance = _repository->getInstance (request->nameSpace, 
 925                            request->instanceName, request->localOnly, 
 926                            request->includeQualifiers, request->includeClassOrigin, 
 927 kumpf 1.11                 request->propertyList);
 928 kumpf 1.1      
 929 kumpf 1.11             //
 930                        //  Remove Creator property from instance before returning
 931                        //
 932 kumpf 1.38             instance.removeProperty (instance.findProperty 
 933                            (PEGASUS_PROPERTYNAME_INDSUB_CREATOR));
 934 kumpf 1.1      
 935 mday  1.73.4.2 
 936 mday  1.73.4.1 // l10n start
 937                        //
 938                        //  Remove the language properties from instance before returning
 939                        //
 940 mday  1.73.4.2 	Uint32 propIndex = instance.findProperty(PEGASUS_PROPERTYNAME_INDSUB_ACCEPTLANGS);      
 941                        if (propIndex != PEG_NOT_FOUND)
 942                        {
 943                             instance.removeProperty (propIndex); 
 944                        }   
 945                
 946                	propIndex = instance.findProperty(PEGASUS_PROPERTYNAME_INDSUB_CONTENTLANGS);      
 947                        if (propIndex != PEG_NOT_FOUND)
 948                        {
 949                             // Get the content languages to be sent in the Content-Language header
 950                             instance.getProperty(propIndex).getValue().get(contentLangs);
 951                             instance.removeProperty (propIndex); 
 952                        }    
 953 mday  1.73.4.1 // l10n end   
 954                
 955 kumpf 1.11             //
 956 kumpf 1.27             //  If a subscription with a duration, calculate subscription time 
 957 kumpf 1.11             //  remaining, and add property to the instance
 958                        //
 959 kumpf 1.64             if (request->instanceName.getClassName ().equal 
 960                            (PEGASUS_CLASSNAME_INDSUBSCRIPTION))
 961 kumpf 1.11             {
 962 kumpf 1.35                 _setTimeRemaining (instance);
 963 kumpf 1.11             }
 964                    }
 965                    catch (CIMException& exception)
 966                    {
 967 kumpf 1.23             cimException = exception;
 968 kumpf 1.11         }
 969                    catch (Exception& exception)
 970                    {
 971 kumpf 1.23             cimException = PEGASUS_CIM_EXCEPTION(CIM_ERR_FAILED,
 972                                                             exception.getMessage());
 973 kumpf 1.11         }
 974 kumpf 1.10     
 975 kumpf 1.19         _repository->read_unlock ();
 976                
 977 mday  1.73.4.1 // l10n
 978                    // Note: setting Content-Language in the response to the contentLanguage
 979                    // in the repository.
 980 kumpf 1.11         CIMGetInstanceResponseMessage* response = new CIMGetInstanceResponseMessage
 981                        (request->messageId,
 982 kumpf 1.23             cimException,
 983 kumpf 1.11             request->queueIds.copyAndPop(),
 984 mday  1.73.4.1         instance,
 985                        ContentLanguages(contentLangs));
 986 kumpf 1.1      
 987                    //
 988 kumpf 1.11         //  Preserve message key
 989 kumpf 1.6          //
 990 kumpf 1.11         response->setKey (request->getKey ());
 991 kumpf 1.27         
 992 kumpf 1.6          //
 993 kumpf 1.11         //  Set response destination
 994 kumpf 1.1          //
 995 kumpf 1.11         response->dest = request->queueIds.top ();
 996 kumpf 1.27         
 997 kumpf 1.69         //
 998                    //  Set HTTP method in response from request
 999                    //
1000                    response->setHttpMethod (request->getHttpMethod ());
1001                
1002 kumpf 1.11         Base::_enqueueResponse (request, response);
1003 kumpf 1.1      
1004 kumpf 1.48         PEG_METHOD_EXIT ();
1005 kumpf 1.1      }
1006                
1007 kumpf 1.11     void IndicationService::_handleEnumerateInstancesRequest(const Message* message)
1008 kumpf 1.1      {
1009 kumpf 1.48         PEG_METHOD_ENTER (TRC_INDICATION_SERVICE,
1010                                      "IndicationService::_handleEnumerateInstancesRequest");
1011 kumpf 1.1      
1012 kumpf 1.27         CIMEnumerateInstancesRequestMessage* request = 
1013 kumpf 1.11             (CIMEnumerateInstancesRequestMessage*) message;
1014 kumpf 1.1      
1015 kumpf 1.46         Array <CIMInstance> enumInstances;
1016 kumpf 1.1      
1017 kumpf 1.23         CIMException cimException;
1018 kumpf 1.11         CIMInstance cimInstance;
1019 mday  1.73.4.1     String aggregatedLangs = String::EMPTY;    // l10n
1020                
1021 kumpf 1.11     
1022 kumpf 1.19         _repository->read_lock ();
1023                
1024 kumpf 1.11         try
1025                    {
1026 kumpf 1.50             enumInstances = _repository->enumerateInstancesForClass
1027                            (request->nameSpace, request->className, 
1028                             request->deepInheritance, request->localOnly, 
1029                             request->includeQualifiers, request->includeClassOrigin, 
1030                             false, request->propertyList);
1031 mday  1.73.4.1 
1032                // l10n
1033                	// Vars used to aggregate the content languages of the subscription
1034                	// instances.
1035                	Boolean langMismatch = false;
1036 mday  1.73.4.2 	Uint32 propIndex;
1037 kumpf 1.27             
1038 kumpf 1.11             //
1039 mday  1.73.4.2         //  Remove Creator and language properties from instances before returning
1040 kumpf 1.11             //
1041                        for (Uint8 i = 0; i < enumInstances.size (); i++)
1042                        {
1043 kumpf 1.46                 enumInstances [i].removeProperty 
1044                                (enumInstances [i].findProperty 
1045 kumpf 1.38                     (PEGASUS_PROPERTYNAME_INDSUB_CREATOR));
1046 kumpf 1.11     
1047 mday  1.73.4.2 
1048 mday  1.73.4.1 // l10n start
1049 mday  1.73.4.2 	    propIndex = enumInstances [i].findProperty(PEGASUS_PROPERTYNAME_INDSUB_CONTENTLANGS);      
1050                            String contentLangs = String::EMPTY;
1051                            if (propIndex != PEG_NOT_FOUND)
1052                            {
1053                 	         enumInstances [i].getProperty(propIndex).getValue().get(contentLangs); 
1054                                 enumInstances [i].removeProperty(propIndex); 
1055                            }
1056 mday  1.73.4.1 
1057 mday  1.73.4.2             propIndex = enumInstances [i].findProperty(PEGASUS_PROPERTYNAME_INDSUB_ACCEPTLANGS);
1058                            if (propIndex != PEG_NOT_FOUND)
1059                            {
1060                                 enumInstances [i].removeProperty(propIndex); 
1061                            }
1062                
1063                            // Determine what to set into the Content-Language header back to the client
1064 mday  1.73.4.1 	    if (!langMismatch)
1065                            {
1066                		if (contentLangs == String::EMPTY)
1067                		{
1068                			langMismatch = true;
1069                			aggregatedLangs = String::EMPTY;	 
1070                		}
1071                		else
1072                		{	
1073                			if (aggregatedLangs == String::EMPTY)
1074                			{
1075                				aggregatedLangs = contentLangs;				
1076                			}
1077                			else if (aggregatedLangs != contentLangs)
1078                			{
1079                				langMismatch = true;
1080                				aggregatedLangs = String::EMPTY;							
1081                			}
1082                		}	
1083                	    }	
1084                // l10n end			
1085 mday  1.73.4.1 
1086 kumpf 1.11                 //
1087 kumpf 1.27                 //  If a subscription with a duration, calculate subscription time 
1088 kumpf 1.11                 //  remaining, and add property to the instance
1089                            //
1090 kumpf 1.64                 if (request->className.equal (PEGASUS_CLASSNAME_INDSUBSCRIPTION))
1091 kumpf 1.11                 {
1092 kumpf 1.46                     _setTimeRemaining (enumInstances [i]);
1093 kumpf 1.11                 }
1094                        }
1095 kumpf 1.1          }
1096 kumpf 1.11         catch (CIMException& exception)
1097 kumpf 1.1          {
1098 kumpf 1.23             cimException = exception;
1099 kumpf 1.1          }
1100 kumpf 1.11         catch (Exception& exception)
1101 kumpf 1.1          {
1102 kumpf 1.23             cimException = PEGASUS_CIM_EXCEPTION(CIM_ERR_FAILED,
1103                                                             exception.getMessage());
1104 kumpf 1.11         }
1105 kumpf 1.1      
1106 kumpf 1.19         _repository->read_unlock ();
1107                
1108 mday  1.73.4.1 // l10n
1109                    // Note: setting Content-Language in the response to the aggregated
1110                    // contentLanguage from the instances in the repository.
1111 kumpf 1.27         CIMEnumerateInstancesResponseMessage* response = 
1112 kumpf 1.11             new CIMEnumerateInstancesResponseMessage(
1113                            request->messageId,
1114 kumpf 1.23                 cimException,
1115 kumpf 1.11                 request->queueIds.copyAndPop(),
1116 mday  1.73.4.1             enumInstances,
1117                            ContentLanguages(aggregatedLangs));
1118 kumpf 1.1      
1119 kumpf 1.11         //
1120                    //  Preserve message key
1121                    //
1122                    response->setKey (request->getKey ());
1123 kumpf 1.27         
1124 kumpf 1.11         //
1125                    //  Set response destination
1126                    //
1127                    response->dest = request->queueIds.top ();
1128 kumpf 1.27         
1129 kumpf 1.69         //
1130                    //  Set HTTP method in response from request
1131                    //
1132                    response->setHttpMethod (request->getHttpMethod ());
1133                
1134 kumpf 1.11         Base::_enqueueResponse (request, response);
1135 kumpf 1.1      
1136 kumpf 1.48         PEG_METHOD_EXIT ();
1137 kumpf 1.11     }
1138 kumpf 1.1      
1139 kumpf 1.11     void IndicationService::_handleEnumerateInstanceNamesRequest
1140                    (const Message* message)
1141                {
1142 kumpf 1.48         PEG_METHOD_ENTER (
1143                        TRC_INDICATION_SERVICE,
1144                        "IndicationService::_handleEnumerateInstancesNamesRequest");
1145 kumpf 1.27        
1146 kumpf 1.11         CIMEnumerateInstanceNamesRequestMessage* request =
1147                        (CIMEnumerateInstanceNamesRequestMessage*) message;
1148 kumpf 1.1      
1149 kumpf 1.45         Array<CIMObjectPath> enumInstanceNames;
1150 kumpf 1.1      
1151 kumpf 1.23         CIMException cimException;
1152 kumpf 1.1      
1153 kumpf 1.19         _repository->read_lock ();
1154                
1155 kumpf 1.11         try
1156                    {
1157 kumpf 1.50             enumInstanceNames = _repository->enumerateInstanceNamesForClass
1158                            (request->nameSpace, request->className, false);
1159 kumpf 1.11         }
1160                    catch (CIMException& exception)
1161                    {
1162 kumpf 1.23             cimException = exception;
1163 kumpf 1.11         }
1164                    catch (Exception& exception)
1165                    {
1166 kumpf 1.23             cimException = PEGASUS_CIM_EXCEPTION(CIM_ERR_FAILED,
1167                                                             exception.getMessage());
1168 kumpf 1.11         }
1169 kumpf 1.1      
1170 kumpf 1.19         _repository->read_unlock ();
1171                
1172 mday  1.73.4.1 // l10n
1173                    // Note: not setting Content-Language in the response
1174 kumpf 1.11         CIMEnumerateInstanceNamesResponseMessage* response =
1175                        new CIMEnumerateInstanceNamesResponseMessage(
1176                            request->messageId,
1177 kumpf 1.23                 cimException,
1178 kumpf 1.11                 request->queueIds.copyAndPop(),
1179                            enumInstanceNames);
1180 kumpf 1.1      
1181 kumpf 1.11         // preserve message key
1182                    response->setKey(request->getKey());
1183 kumpf 1.1      
1184 kumpf 1.27         
1185 kumpf 1.17         //  Set the response destination !!!
1186 kumpf 1.11         response->dest = request->queueIds.top();
1187 kumpf 1.27         
1188 kumpf 1.69         //
1189                    //  Set HTTP method in response from request
1190                    //
1191                    response->setHttpMethod (request->getHttpMethod ());
1192                
1193 kumpf 1.17         // Note: In this particular case you can call either SendForget
1194                    // OR Base::_enqueueResponse
1195                    //    SendForget(response);
1196 kumpf 1.11         Base::_enqueueResponse(request, response);
1197 kumpf 1.1      
1198 kumpf 1.48         PEG_METHOD_EXIT ();
1199 kumpf 1.1      }
1200                
1201 kumpf 1.11     void IndicationService::_handleModifyInstanceRequest (const Message* message)
1202 kumpf 1.1      {
1203 kumpf 1.48         PEG_METHOD_ENTER (TRC_INDICATION_SERVICE,
1204                                      "IndicationService::_handleModifyInstanceRequest");
1205 kumpf 1.1      
1206 kumpf 1.27         CIMModifyInstanceRequestMessage* request = 
1207 kumpf 1.11             (CIMModifyInstanceRequestMessage*) message;
1208 kumpf 1.6      
1209 kumpf 1.23         CIMException cimException;
1210 kumpf 1.27         
1211 kumpf 1.11         try
1212 kumpf 1.6          {
1213                        //
1214 kumpf 1.11             //  Get the instance name
1215 kumpf 1.6              //
1216 kumpf 1.45             CIMObjectPath instanceReference = 
1217 kumpf 1.46                 request->modifiedInstance.getPath ();
1218 kumpf 1.27         
1219 kumpf 1.6              //
1220 kumpf 1.11             //  Get instance from repository
1221 kumpf 1.6              //
1222 kumpf 1.19             _repository->read_lock ();
1223                
1224                        CIMInstance instance;
1225                
1226                        try
1227                        {
1228 kumpf 1.27                 instance = _repository->getInstance (request->nameSpace, 
1229 kumpf 1.19                     instanceReference);
1230 kumpf 1.27             } 
1231 kumpf 1.19             catch (Exception e)
1232                        {
1233                            _repository->read_unlock ();
1234 kumpf 1.48                 PEG_METHOD_EXIT ();
1235 kumpf 1.19                 throw e;
1236                        }
1237                
1238                        _repository->read_unlock ();
1239 kumpf 1.1      
1240 kumpf 1.11             if (_canModify (request, instanceReference, instance))
1241 kumpf 1.1              {
1242 kumpf 1.11                 //
1243                            //  Check for expired subscription
1244                            //
1245 kumpf 1.35                 if (_isExpired (instance))
1246 kumpf 1.1                  {
1247 kumpf 1.11                     //
1248                                //  Delete the subscription instance
1249                                //
1250 kumpf 1.35                     instanceReference.setNameSpace (request->nameSpace);
1251                                _deleteExpiredSubscription (instanceReference);
1252 kumpf 1.27         
1253 kumpf 1.48                     PEG_METHOD_EXIT ();
1254 mday  1.73.4.2 
1255                		// l10n
1256                
1257                                // String exceptionStr = _MSG_EXPIRED;
1258                                // throw PEGASUS_CIM_EXCEPTION (CIM_ERR_FAILED, exceptionStr);
1259                
1260                		throw PEGASUS_CIM_EXCEPTION_L (CIM_ERR_FAILED,
1261                			 MessageLoaderParms(_MSG_EXPIRED_KEY, _MSG_EXPIRED));
1262                
1263 kumpf 1.1                  }
1264 kumpf 1.27         
1265 kumpf 1.15                 //
1266 kumpf 1.27                 //  _canModify, above, already checked that propertyList is not 
1267 kumpf 1.15                 //  null, and that numProperties is 0 or 1
1268                            //
1269 kumpf 1.35                 CIMInstance modifiedInstance = 
1270 kumpf 1.46                     request->modifiedInstance;
1271 kumpf 1.35                 CIMPropertyList propertyList = request->propertyList;
1272 kumpf 1.51                 if (request->propertyList.size () > 0)
1273 kumpf 1.1                  {
1274 kumpf 1.11                     //
1275                                //  Get current state from instance
1276                                //
1277                                CIMValue subscriptionStateValue;
1278                                Uint16 currentState;
1279 kumpf 1.27                     subscriptionStateValue = instance.getProperty 
1280 kumpf 1.11                         (instance.findProperty (_PROPERTY_STATE)).getValue ();
1281                                subscriptionStateValue.get (currentState);
1282 kumpf 1.27             
1283 kumpf 1.11                     //
1284 kumpf 1.27                     //  Get new state 
1285 kumpf 1.11                     //
1286                                Uint16 newState;
1287 kumpf 1.27                     subscriptionStateValue = 
1288 kumpf 1.46                         request->modifiedInstance.getProperty
1289                                    (request->modifiedInstance.findProperty
1290 kumpf 1.11                         (_PROPERTY_STATE)).getValue ();
1291 kumpf 1.27         
1292 kumpf 1.11                     subscriptionStateValue.get (newState);
1293 kumpf 1.27         
1294 kumpf 1.11                     //
1295                                //  If Subscription State has changed,
1296                                //  Set Time of Last State Change to current date time
1297                                //
1298 kumpf 1.35                     CIMDateTime currentDateTime = 
1299                                    CIMDateTime::getCurrentDateTime ();
1300 kumpf 1.11                     if (newState != currentState)
1301                                {
1302 kumpf 1.52                         if (modifiedInstance.findProperty (_PROPERTY_LASTCHANGE) !=
1303                                        PEG_NOT_FOUND)
1304 kumpf 1.35                         {
1305                                        CIMProperty lastChange = modifiedInstance.getProperty
1306                                            (modifiedInstance.findProperty 
1307                                            (_PROPERTY_LASTCHANGE));
1308                                        lastChange.setValue (CIMValue (currentDateTime));
1309                                    }
1310                                    else
1311                                    {
1312                                        modifiedInstance.addProperty (CIMProperty 
1313                                            (_PROPERTY_LASTCHANGE, CIMValue (currentDateTime)));
1314                                    }
1315 kumpf 1.54                         Array <CIMName> properties = 
1316 kumpf 1.35                             propertyList.getPropertyNameArray ();
1317                                    properties.append (_PROPERTY_LASTCHANGE);
1318                                    propertyList.set (properties);
1319 kumpf 1.11                     }
1320 kumpf 1.13     
1321                                //
1322 kumpf 1.27                     //  If Subscription is to be enabled, and this is the first 
1323 kumpf 1.13                     //  time, set Subscription Start Time
1324                                //
1325 kumpf 1.27                     if ((newState == _STATE_ENABLED) || 
1326 kumpf 1.13                         (newState == _STATE_ENABLEDDEGRADED))
1327                                {
1328                                    //
1329                                    //  If Subscription Start Time is null, set value
1330                                    //  to the current date time
1331                                    //
1332                                    CIMDateTime startTime;
1333 kumpf 1.27                         CIMProperty startTimeProperty = instance.getProperty 
1334 kumpf 1.13                             (instance.findProperty (_PROPERTY_STARTTIME));
1335                                    CIMValue startTimeValue = instance.getProperty
1336 kumpf 1.27                             (instance.findProperty 
1337 kumpf 1.13                             (_PROPERTY_STARTTIME)).getValue ();
1338 kumpf 1.35                         Boolean setStart = false;
1339 kumpf 1.13                         if (startTimeValue.isNull ())
1340                                    {
1341 kumpf 1.35                             setStart = true;
1342 kumpf 1.13                         }
1343                                    else
1344                                    {
1345                                        startTimeValue.get (startTime);
1346 kumpf 1.58                             if (startTime.equal 
1347                                            (CIMDateTime (_ZERO_INTERVAL_STRING)))
1348 kumpf 1.13                             {
1349 kumpf 1.35                                 setStart = true;
1350 kumpf 1.13                             }
1351                                    }
1352 kumpf 1.35     
1353                                    if (setStart)
1354                                    {
1355 kumpf 1.52                             if (modifiedInstance.findProperty (_PROPERTY_STARTTIME)
1356                                            != PEG_NOT_FOUND)
1357 kumpf 1.35                             {
1358                                            CIMProperty startTime = modifiedInstance.getProperty
1359                                                (modifiedInstance.findProperty
1360                                                (_PROPERTY_STARTTIME));
1361                                            startTime.setValue (CIMValue (currentDateTime));
1362                                        }
1363                                        else
1364                                        {
1365                                            modifiedInstance.addProperty (CIMProperty 
1366                                                (_PROPERTY_STARTTIME,
1367                                                CIMValue (currentDateTime)));
1368                                        }
1369                
1370 kumpf 1.54                             Array <CIMName> properties = 
1371 kumpf 1.35                                 propertyList.getPropertyNameArray ();
1372                                        properties.append (_PROPERTY_STARTTIME);
1373                                        propertyList.set (properties);
1374                                    }
1375 kumpf 1.13                     }
1376 kumpf 1.19     
1377 mday  1.73.4.2 
1378 mday  1.73.4.1 // l10n
1379                                // Add the language properties to the modified instance.
1380                    	        // Note:  These came from the Accept-Language and Content-Language
1381                       	        // headers in the HTTP messages, and may be empty.
1382                                AcceptLanguages acceptLangs = request->acceptLanguages;
1383                                modifiedInstance.addProperty (CIMProperty 
1384                                    (PEGASUS_PROPERTYNAME_INDSUB_ACCEPTLANGS, 
1385                                    acceptLangs.toString()));
1386                
1387 mday  1.73.4.2 	        ContentLanguages contentLangs = request->contentLanguages;
1388 mday  1.73.4.1                 modifiedInstance.addProperty (CIMProperty 
1389                                    (PEGASUS_PROPERTYNAME_INDSUB_CONTENTLANGS, 
1390                                    contentLangs.toString()));
1391                                    
1392                                Array <CIMName> properties = propertyList.getPropertyNameArray ();
1393                                properties.append (PEGASUS_PROPERTYNAME_INDSUB_ACCEPTLANGS);
1394                                properties.append (PEGASUS_PROPERTYNAME_INDSUB_CONTENTLANGS);                
1395                                propertyList.set (properties);                    
1396                // l10n -end
1397                
1398 kumpf 1.11                     //
1399 kumpf 1.27                     //  If subscription is to be enabled, determine if there are 
1400 kumpf 1.11                     //  any indication providers that can serve the subscription
1401                                //
1402 kumpf 1.16                     Array <ProviderClassList> indicationProviders;
1403 kumpf 1.11                     CIMPropertyList requiredProperties;
1404 kumpf 1.63                     CIMNamespaceName sourceNameSpace;
1405 kumpf 1.11                     String condition;
1406                                String queryLanguage;
1407 kumpf 1.73                     Array <CIMName> indicationSubclasses;
1408 kumpf 1.27             
1409                                if (((newState == _STATE_ENABLED) || 
1410 kumpf 1.11                          (newState == _STATE_ENABLEDDEGRADED))
1411 kumpf 1.27                         && ((currentState != _STATE_ENABLED) && 
1412 kumpf 1.11                             (currentState != _STATE_ENABLEDDEGRADED)))
1413                                {
1414                                    //
1415 kumpf 1.27                         //  Subscription was previously not enabled but is now to 
1416 kumpf 1.11                         //  be enabled
1417                                    //
1418 kumpf 1.38                         _getCreateParams (request->nameSpace, instance,
1419 kumpf 1.73                             indicationSubclasses, indicationProviders, 
1420                                        requiredProperties, sourceNameSpace, condition, 
1421                                        queryLanguage);
1422 kumpf 1.27         
1423 kumpf 1.11                         if (indicationProviders.size () == 0)
1424                                    {
1425                                        //
1426 kumpf 1.27                             //  There are no providers that can support this 
1427 kumpf 1.11                             //  subscription
1428                                        //
1429 kumpf 1.46                             instance.setPath (instanceReference);
1430                                        _handleError (instance);
1431 kumpf 1.48                             PEG_METHOD_EXIT ();
1432 mday  1.73.4.2 
1433                			// l10n
1434                
1435                                        // throw PEGASUS_CIM_EXCEPTION (CIM_ERR_NOT_SUPPORTED,
1436                			//  _MSG_NO_PROVIDERS);
1437                
1438                			throw PEGASUS_CIM_EXCEPTION_L (CIM_ERR_NOT_SUPPORTED,
1439                				 MessageLoaderParms(_MSG_NO_PROVIDERS_KEY, _MSG_NO_PROVIDERS));
1440 kumpf 1.11                         }
1441                                }
1442 kumpf 1.19     
1443 kumpf 1.11                     //
1444                                //  Modify the instance in the repository
1445                                //
1446                                _repository->write_lock ();
1447 kumpf 1.35     
1448 kumpf 1.11                     try
1449                                {
1450 kumpf 1.46                         modifiedInstance.setPath (instanceReference);
1451 kumpf 1.11                         _repository->modifyInstance (request->nameSpace,
1452 kumpf 1.46                             modifiedInstance, 
1453 kumpf 1.35                             request->includeQualifiers, propertyList);
1454 david 1.71     
1455                		    Logger::put(Logger::STANDARD_LOG, System::CIMSERVER, Logger::TRACE,
1456                				"IndicationService::_handleModifyInstanceRequest - Name Space: $0  Instance name: $1",
1457                				request->nameSpace.getString(),
1458                				modifiedInstance.getClassName().getString());
1459                		}
1460 kumpf 1.23                     catch (CIMException & exception)
1461                                {
1462                                    cimException = exception;
1463                                }
1464 kumpf 1.11                     catch (Exception & exception)
1465                                {
1466 kumpf 1.23                         cimException = PEGASUS_CIM_EXCEPTION(CIM_ERR_FAILED,
1467                                                       exception.getMessage());
1468                                }
1469                
1470                               _repository->write_unlock ();
1471 kumpf 1.27         
1472 kumpf 1.23                     if (cimException.getCode() != CIM_ERR_SUCCESS)
1473                                {
1474 kumpf 1.11                         CIMModifyInstanceResponseMessage* response =
1475                                        new CIMModifyInstanceResponseMessage (
1476                                            request->messageId,
1477 kumpf 1.23                                 cimException,
1478                                            request->queueIds.copyAndPop ());
1479 kumpf 1.27             
1480 kumpf 1.11                         //
1481                                    //  Preserve message key
1482                                    //
1483                                    response->setKey (request->getKey ());
1484 kumpf 1.27         
1485 kumpf 1.11                         //
1486                                    //  Set response destination
1487                                    //
1488                                    response->dest = request->queueIds.top ();
1489 kumpf 1.27         
1490 kumpf 1.69                         //
1491                                    //  Set HTTP method in response from request
1492                                    //
1493                                    response->setHttpMethod (request->getHttpMethod ());
1494                
1495 kumpf 1.11                         Base::_enqueueResponse (request, response);
1496 kumpf 1.27             
1497 kumpf 1.48                         PEG_METHOD_EXIT ();
1498 kumpf 1.11                         return;
1499                                }
1500 kumpf 1.27                     
1501 kumpf 1.11                     //
1502 kumpf 1.38                     //  If subscription is newly enabled, send Create requests
1503                                //  and enable providers
1504 kumpf 1.11                     //
1505 kumpf 1.27                     if (((newState == _STATE_ENABLED) || 
1506 kumpf 1.11                          (newState == _STATE_ENABLEDDEGRADED))
1507 kumpf 1.27                         && ((currentState != _STATE_ENABLED) && 
1508 kumpf 1.11                             (currentState != _STATE_ENABLEDDEGRADED)))
1509 kumpf 1.1                      {
1510 kumpf 1.16                         instanceReference.setNameSpace (request->nameSpace);
1511 kumpf 1.46                         instance.setPath (instanceReference);
1512 mday  1.73.4.1 // l10n                    
1513 kumpf 1.38                         if (!_sendCreateRequests (indicationProviders, 
1514 kumpf 1.27                             sourceNameSpace, requiredProperties, condition, 
1515 kumpf 1.14                             queryLanguage,
1516 kumpf 1.46                             instance,
1517 mday  1.73.4.1                         request->acceptLanguages,
1518                                        request->contentLanguages,  
1519 kumpf 1.15                             request->userName, request->authType))
1520                                    {
1521 kumpf 1.48                             PEG_METHOD_EXIT ();
1522 mday  1.73.4.2 
1523                			// l10n
1524                
1525                                        // throw PEGASUS_CIM_EXCEPTION (CIM_ERR_NOT_SUPPORTED,
1526                			// _MSG_NOT_ACCEPTED);
1527                
1528                			throw PEGASUS_CIM_EXCEPTION_L (CIM_ERR_NOT_SUPPORTED,
1529                				 MessageLoaderParms(_MSG_NOT_ACCEPTED_KEY, _MSG_NOT_ACCEPTED));
1530                
1531 kumpf 1.15                         }
1532 kumpf 1.27         
1533 kumpf 1.11                         //
1534 kumpf 1.38                         //  Send Enable message to each provider
1535 kumpf 1.11                         //
1536                                    for (Uint8 i = 0; i < indicationProviders.size (); i++)
1537                                    {
1538                                        //
1539 kumpf 1.38                             //  Send Enable message 
1540 kumpf 1.11                             //
1541 kumpf 1.38                             _sendEnable (indicationProviders [i]);
1542 kumpf 1.11                         }
1543 kumpf 1.73     
1544                                    //
1545                                    //  Insert entries into the subscription hash tables
1546                                    //
1547                                    //
1548                                    //  NOTE: Once bugzilla #63 is fixed, the list of providers
1549                                    //  passed to this function must be not those attempted to 
1550                                    //  enable, but those who were successfully enabled 
1551                                    //  (response received)
1552                                    //
1553                                    _insertToHashTables (instance, indicationProviders,
1554                                        indicationSubclasses, sourceNameSpace);
1555 kumpf 1.1                      }
1556 kumpf 1.11                     else if ((newState == _STATE_DISABLED) &&
1557                                         ((currentState == _STATE_ENABLED) ||
1558                                          (currentState == _STATE_ENABLEDDEGRADED)))
1559                                {
1560                                    //
1561 kumpf 1.27                         //  Subscription was previously enabled but is now to be 
1562 kumpf 1.11                         //  disabled
1563                                    //
1564 kumpf 1.16                         Array <ProviderClassList> indicationProviders;
1565 kumpf 1.73                         indicationProviders = _getDeleteParams (request->nameSpace,
1566                                        instance, indicationSubclasses, sourceNameSpace);
1567 kumpf 1.27         
1568 kumpf 1.11                         //
1569 kumpf 1.38                         //  Send Delete requests
1570 kumpf 1.11                         //
1571 mday  1.73.4.1 //l10n                    	
1572 kumpf 1.73                         instanceReference.setNameSpace (request->nameSpace);
1573                                    instance.setPath (instanceReference);
1574 kumpf 1.11                         if (indicationProviders.size () > 0)
1575                                    {
1576 kumpf 1.38                             _sendDeleteRequests (indicationProviders, 
1577 kumpf 1.14                                 request->nameSpace,
1578 kumpf 1.46                                 instance,
1579 mday  1.73.4.1 	                    request->acceptLanguages,
1580                    		            request->contentLanguages,  
1581 kumpf 1.15                                 request->userName, request->authType);
1582 kumpf 1.11                         }
1583 kumpf 1.73     
1584                                    //
1585                                    //  Remove entries from the subscription hash tables
1586                                    //
1587                                    _removeFromHashTables (instance, indicationSubclasses, 
1588                                        sourceNameSpace);
1589 kumpf 1.11                     }
1590 kumpf 1.1                  }
1591                        }
1592 kumpf 1.11         }
1593                    catch (CIMException& exception)
1594 kumpf 1.1          {
1595 kumpf 1.23             cimException = exception;
1596 kumpf 1.1          }
1597 kumpf 1.11         catch (Exception& exception)
1598 kumpf 1.1          {
1599 kumpf 1.23             cimException = PEGASUS_CIM_EXCEPTION(CIM_ERR_FAILED,
1600                                                             exception.getMessage());
1601 kumpf 1.1          }
1602                
1603 kumpf 1.38         //
1604 kumpf 1.39         //  FUTURE: Response should be sent only after Create or Delete
1605 kumpf 1.38         //  response has been received
1606                    //
1607 mday  1.73.4.1 // l10n
1608                    // Note: don't need to set content-language in the response.
1609 kumpf 1.11         CIMModifyInstanceResponseMessage* response =
1610                        new CIMModifyInstanceResponseMessage(
1611                            request->messageId,
1612 kumpf 1.23                 cimException,
1613 kumpf 1.11                 request->queueIds.copyAndPop());
1614 kumpf 1.1      
1615                    //
1616 kumpf 1.11         //  Preserve message key
1617 kumpf 1.1          //
1618 kumpf 1.11         response->setKey (request->getKey ());
1619 kumpf 1.27         
1620 kumpf 1.1          //
1621 kumpf 1.11         //  Set response destination
1622 kumpf 1.1          //
1623 kumpf 1.11         response->dest = request->queueIds.top ();
1624 kumpf 1.27         
1625 kumpf 1.69         //
1626                    //  Set HTTP method in response from request
1627                    //
1628                    response->setHttpMethod (request->getHttpMethod ());
1629                
1630 kumpf 1.11         Base::_enqueueResponse (request, response);
1631 kumpf 1.1      
1632 kumpf 1.48         PEG_METHOD_EXIT ();
1633 kumpf 1.1      }
1634                
1635 kumpf 1.11     void IndicationService::_handleDeleteInstanceRequest (const Message* message)
1636 kumpf 1.1      {
1637 kumpf 1.48         PEG_METHOD_ENTER (TRC_INDICATION_SERVICE,
1638                                      "IndicationService::_handleDeleteInstanceRequest");
1639 kumpf 1.1      
1640 kumpf 1.27         CIMDeleteInstanceRequestMessage* request = 
1641 kumpf 1.11             (CIMDeleteInstanceRequestMessage*) message;
1642 kumpf 1.1      
1643 kumpf 1.23         CIMException cimException;
1644 kumpf 1.1      
1645                    try
1646                    {
1647 kumpf 1.11             //
1648 kumpf 1.27             //  Check if instance may be deleted -- a filter or handler instance 
1649 kumpf 1.11             //  referenced by a subscription instance may not be deleted
1650                        //
1651 kumpf 1.16             if (_canDelete (request->instanceName, request->nameSpace,
1652                            request->userName))
1653 kumpf 1.11             {
1654 kumpf 1.64                 if (request->instanceName.getClassName ().equal
1655                                (PEGASUS_CLASSNAME_INDSUBSCRIPTION))
1656 kumpf 1.1                  {
1657 kumpf 1.11                     CIMInstance subscriptionInstance;
1658 kumpf 1.16                     Array <ProviderClassList> indicationProviders;
1659 kumpf 1.1      
1660 kumpf 1.19                     _repository->read_lock ();
1661                
1662                                try
1663                                {
1664 kumpf 1.27                     subscriptionInstance = _repository->getInstance 
1665 kumpf 1.11                         (request->nameSpace, request->instanceName);
1666 kumpf 1.19                     }
1667                                catch (Exception e)
1668                                {
1669                                    _repository->read_unlock ();
1670 kumpf 1.48                         PEG_METHOD_EXIT ();
1671 kumpf 1.19                         throw e;
1672                                }
1673                
1674                                _repository->read_unlock ();
1675 kumpf 1.1      
1676 kumpf 1.73                     Array <CIMName> indicationSubclasses;
1677                                CIMNamespaceName sourceNamespaceName;
1678 kumpf 1.38                     indicationProviders = _getDeleteParams 
1679 mday  1.73.4.1                     (request->nameSpace, subscriptionInstance,
1680 kumpf 1.73                         indicationSubclasses, sourceNamespaceName);
1681 kumpf 1.1      
1682                                //
1683 kumpf 1.38                     //  Send Delete requests
1684 kumpf 1.1                      //
1685 mday  1.73.4.1 // l10n                
1686 kumpf 1.45                     CIMObjectPath instanceReference = request->instanceName;
1687 kumpf 1.16                     instanceReference.setNameSpace (request->nameSpace);
1688 kumpf 1.46                     subscriptionInstance.setPath (instanceReference);
1689 kumpf 1.38                     _sendDeleteRequests (indicationProviders,
1690 kumpf 1.46                         request->nameSpace, subscriptionInstance,
1691 mday  1.73.4.1                     request->acceptLanguages,
1692                                    request->contentLanguages,
1693 kumpf 1.15                         request->userName, request->authType);
1694 kumpf 1.73     
1695                                //
1696                                //  Remove entries from subscription hash tables
1697                                //
1698                                _removeFromHashTables (subscriptionInstance, 
1699                                    indicationSubclasses, sourceNamespaceName);
1700 kumpf 1.1                  }
1701                
1702                            //
1703 kumpf 1.11                 //  Delete instance from repository
1704 kumpf 1.1                  //
1705 kumpf 1.11                 _repository->write_lock ();
1706                
1707                            try
1708 kumpf 1.1                  {
1709 kumpf 1.27                     _repository->deleteInstance (request->nameSpace, 
1710 kumpf 1.11                         request->instanceName);
1711 david 1.71     		
1712                		Logger::put(Logger::STANDARD_LOG, System::CIMSERVER, Logger::TRACE,
1713                			    "IndicationService::_handleDeleteInstanceRequest - Name Space: $0  Instance name: $1",
1714                			    request->nameSpace.getString(),
1715                			    request->instanceName.getClassName().getString());
1716 kumpf 1.1                  }
1717 kumpf 1.23                 catch (CIMException & exception)
1718                            {
1719                                cimException = exception;
1720                            }
1721 kumpf 1.11                 catch (Exception & exception)
1722 kumpf 1.1                  {
1723 kumpf 1.23                     cimException = PEGASUS_CIM_EXCEPTION(CIM_ERR_FAILED,
1724                                                   exception.getMessage());
1725                            }
1726 kumpf 1.11     
1727 kumpf 1.23                 _repository->write_unlock ();
1728 kumpf 1.1      
1729 kumpf 1.23                 if (cimException.getCode() != CIM_ERR_SUCCESS)
1730                            {
1731 kumpf 1.11                     CIMDeleteInstanceResponseMessage* response =
1732                                    new CIMDeleteInstanceResponseMessage (
1733                                        request->messageId,
1734 kumpf 1.23                             cimException,
1735 kumpf 1.11                             request->queueIds.copyAndPop ());
1736 kumpf 1.1      
1737                                //
1738 kumpf 1.11                     //  Preserve message key
1739 kumpf 1.1                      //
1740 kumpf 1.11                     response->setKey (request->getKey ());
1741 kumpf 1.1      
1742                                //
1743 kumpf 1.11                     //  Set response destination
1744 kumpf 1.1                      //
1745 kumpf 1.11                     response->dest = request->queueIds.top ();
1746 kumpf 1.1      
1747 kumpf 1.69                     //
1748                                //  Set HTTP method in response from request
1749                                //
1750                                response->setHttpMethod (request->getHttpMethod ());
1751                
1752 kumpf 1.11                     Base::_enqueueResponse (request, response);
1753 kumpf 1.1      
1754 kumpf 1.48                     PEG_METHOD_EXIT ();
1755 kumpf 1.11                     return;
1756 kumpf 1.1                  }
1757 kumpf 1.11             }
1758                    }
1759                    catch (CIMException& exception)
1760                    {
1761 kumpf 1.23             cimException = exception;
1762 kumpf 1.11         }
1763                    catch (Exception& exception)
1764                    {
1765 kumpf 1.23             cimException = PEGASUS_CIM_EXCEPTION(CIM_ERR_FAILED,
1766                                                             exception.getMessage());
1767 kumpf 1.11         }
1768                
1769 kumpf 1.38         //
1770 kumpf 1.39         //  FUTURE: Response should be sent only after Delete response has 
1771 kumpf 1.38         //  been received
1772                    //
1773 kumpf 1.11         CIMDeleteInstanceResponseMessage* response =
1774                        new CIMDeleteInstanceResponseMessage(
1775                            request->messageId,
1776 kumpf 1.23                 cimException,
1777 kumpf 1.11                 request->queueIds.copyAndPop());
1778                
1779                    //
1780                    //  Preserve message key
1781                    //
1782                    response->setKey (request->getKey ());
1783 kumpf 1.27         
1784 kumpf 1.11         //
1785                    //  Set response destination
1786                    //
1787                    response->dest = request->queueIds.top ();
1788 kumpf 1.27         
1789 kumpf 1.69         //
1790                    //  Set HTTP method in response from request
1791                    //
1792                    response->setHttpMethod (request->getHttpMethod ());
1793                
1794 kumpf 1.11         Base::_enqueueResponse (request, response);
1795                
1796 kumpf 1.48         PEG_METHOD_EXIT ();
1797 kumpf 1.11     }
1798                
1799 mday  1.73.4.1 // l10n TODO - might need to globalize another flow and another consumer interface
1800                // (ie. mdd's) if we can't agree on one export flow and consumer interface
1801                // (see PEP67)
1802                
1803 kumpf 1.11     void IndicationService::_handleProcessIndicationRequest (const Message* message)
1804                {
1805 kumpf 1.73     #ifdef PEGASUS_INDICATION_PERFINST
1806                    Stopwatch stopWatch;
1807                    double elapsed;
1808                #endif
1809                
1810 kumpf 1.48         PEG_METHOD_ENTER (TRC_INDICATION_SERVICE,
1811                                      "IndicationService::_handleProcessIndicationRequest");
1812 kumpf 1.11     
1813                    CIMProcessIndicationRequestMessage* request =
1814                        (CIMProcessIndicationRequestMessage*) message;
1815                
1816 kumpf 1.23         CIMException cimException;
1817 kumpf 1.11     
1818                    CIMProcessIndicationResponseMessage* response =
1819                        new CIMProcessIndicationResponseMessage(
1820                            request->messageId,
1821 kumpf 1.23                 cimException,
1822 kumpf 1.11                 request->queueIds.copyAndPop());
1823                
1824                    String filterQuery;
1825                    Boolean match;
1826                
1827 kumpf 1.46         Array <CIMInstance> matchedSubscriptions;
1828                    CIMInstance handlerNamedInstance;
1829 kumpf 1.11     
1830                    WQLSelectStatement selectStatement;
1831                
1832                    CIMInstance handler;
1833                    CIMInstance indication = request->indicationInstance;
1834 kumpf 1.73     
1835                    PEG_TRACE_STRING (TRC_INDICATION_SERVICE, Tracer::LEVEL4, 
1836                        "Received Indication " + indication.getClassName().getString());
1837                
1838 kumpf 1.11         try
1839                    {
1840 kumpf 1.73             WQLSimplePropertySource propertySource = 
1841                            _getPropertySourceFromInstance (indication);
1842 kumpf 1.11     
1843 kumpf 1.37             //
1844 kumpf 1.39             //  Check if property list contains all properties of class
1845 kumpf 1.37             //  If so, set to null
1846                        //
1847 kumpf 1.67             Array <CIMName> propertyNames;
1848                        CIMPropertyList propertyList;
1849                        for (Uint8 i = 0; i < indication.getPropertyCount(); i++)
1850                            propertyNames.append(indication.getProperty(i).getName());
1851                        propertyList = _checkPropertyList (propertyNames, 
1852                            request->nameSpace, indication.getClassName ());
1853 kumpf 1.37     
1854 kumpf 1.63             Array <CIMNamespaceName> nameSpaces;
1855 kumpf 1.15             nameSpaces.append (request->nameSpace);
1856 kumpf 1.67     
1857 kumpf 1.68             if (request->subscriptionInstanceNames.size() > 0)
1858                        {
1859 kumpf 1.73     #ifdef PEGASUS_INDICATION_PERFINST
1860                            stopWatch.reset ();
1861                #endif
1862                
1863 kumpf 1.68                 for (Uint8 i = 0; i < request->subscriptionInstanceNames.size(); 
1864                                 i++)
1865                            {
1866 kumpf 1.73                     //
1867                                //  Look up the subscription in the active subscriptions table
1868                                //
1869                                String activeSubscriptionsKey = _generateActiveSubscriptionsKey
1870                                    (request->subscriptionInstanceNames [i]);
1871                                ActiveSubscriptionsTableEntry tableValue;
1872                                if (_activeSubscriptionsTable.lookup (activeSubscriptionsKey, 
1873                                    tableValue))
1874                                {
1875                                    matchedSubscriptions.append (tableValue.subscription);
1876                                }
1877 kumpf 1.68                 }
1878 kumpf 1.73     
1879                #ifdef PEGASUS_INDICATION_PERFINST
1880                            elapsed = stopWatch.getElapsed ();
1881                
1882                            Tracer::trace (TRC_INDICATION_SERVICE_INTERNAL, Tracer::LEVEL2, 
1883                                "%s: %.3f seconds", 
1884                                "Look up Subscriptions", elapsed);
1885                #endif
1886 kumpf 1.68             }
1887                        else
1888                        {
1889 kumpf 1.73     #ifdef PEGASUS_INDICATION_PERFINST
1890                            stopWatch.reset ();
1891                #endif
1892                
1893 kumpf 1.68                 matchedSubscriptions = _getMatchingSubscriptions(
1894                                indication.getClassName (), nameSpaces, propertyList);
1895 kumpf 1.73     
1896                #ifdef PEGASUS_INDICATION_PERFINST
1897                            elapsed = stopWatch.getElapsed ();
1898                
1899                            Tracer::trace (TRC_INDICATION_SERVICE_INTERNAL, Tracer::LEVEL2, 
1900                                "%s: %.3f seconds", 
1901                                "Get Matching Subscriptions", elapsed);
1902                #endif
1903 kumpf 1.68             }
1904 kumpf 1.11     
1905                        for (Uint8 i = 0; i < matchedSubscriptions.size(); i++)
1906                        {
1907                            match = true;
1908                
1909 kumpf 1.66     	    //
1910                	    // copy the indication, format it based on the subscription,
1911                	    // and send the formatted indication to the consumer
1912                	    // 
1913                	    CIMInstance formattedIndication = indication.clone();
1914                
1915 kumpf 1.15                 //
1916                            //  Check for expired subscription
1917                            //
1918 kumpf 1.46                 if (_isExpired (matchedSubscriptions [i]))
1919 kumpf 1.15                 {
1920 kumpf 1.46                     CIMObjectPath path = matchedSubscriptions [i].getPath ();
1921                                _deleteExpiredSubscription (path);
1922 kumpf 1.27         
1923 kumpf 1.15                     continue;
1924                            }
1925                
1926 kumpf 1.16                 _getFilterProperties (
1927 kumpf 1.46                     matchedSubscriptions[i],
1928                                matchedSubscriptions[i].getPath ().getNameSpace (),
1929 kumpf 1.16                     filterQuery);
1930 kumpf 1.11     
1931                            selectStatement = _getSelectStatement (filterQuery);
1932                
1933                            if (selectStatement.hasWhereClause())
1934 kumpf 1.1                  {
1935 kumpf 1.73     #ifdef PEGASUS_INDICATION_PERFINST
1936                                stopWatch.reset ();
1937                #endif
1938                
1939 kumpf 1.11                     if (!selectStatement.evaluateWhereClause(&propertySource))
1940 kumpf 1.1                      {
1941 kumpf 1.11                         match = false;
1942 kumpf 1.1                      }
1943 kumpf 1.73     
1944                #ifdef PEGASUS_INDICATION_PERFINST
1945                                elapsed = stopWatch.getElapsed ();
1946                
1947                                Tracer::trace (TRC_INDICATION_SERVICE_INTERNAL, Tracer::LEVEL2, 
1948                                    "%s: %.3f seconds", 
1949                                    "Evaluate WHERE clause", elapsed);
1950                #endif
1951 kumpf 1.1                  }
1952                
1953 kumpf 1.11                 if (match)
1954 kumpf 1.1                  {
1955 kumpf 1.67                     //
1956                                // Format indication
1957                                // Remove properties not listed in SELECT clause from 
1958                                // indication as they are not required to be passed to consumer
1959                                // If SELECT includes all properties ("*"), pass all properties
1960                                // to the consumer
1961                                //
1962                                if (!selectStatement.getAllProperties ())
1963                                {
1964                                    CIMPropertyList selectPropertyList;
1965                                    Array <CIMName> selectPropertyNames;
1966 kumpf 1.34     
1967 kumpf 1.67                         //
1968                                    // Get properties listed in SELECT clause
1969                                    //
1970                                    selectPropertyList = 
1971                                        selectStatement.getSelectPropertyList ();
1972                                    selectPropertyNames = 
1973                                        selectPropertyList.getPropertyNameArray ();
1974 kumpf 1.34     
1975 kumpf 1.67                         //
1976                		    // Remove properties not listed in SELECT clause
1977 kumpf 1.66     		    // from indication
1978                		    //
1979                		    for (Uint32 j = 0; j < propertyNames.size(); j++)
1980                		    {
1981 kumpf 1.67                             if (!ContainsCIMName (selectPropertyNames, 
1982                                                              propertyNames[j]))
1983 kumpf 1.66     			{
1984                			    formattedIndication.removeProperty(
1985                				formattedIndication.findProperty
1986                						      (propertyNames[j])); 
1987                			}
1988                	  	    }
1989 kumpf 1.67     		}
1990 kumpf 1.66     		
1991 kumpf 1.67                     handlerNamedInstance = _getHandler
1992                                    (matchedSubscriptions[i]);
1993 kumpf 1.1      
1994 mday  1.73.4.1 // l10n
1995                // Note: not expecting any language in the response
1996 kumpf 1.67                     CIMRequestMessage * handler_request =
1997                                    new CIMHandleIndicationRequestMessage (
1998                                        XmlWriter::getNextMessageId (),
1999                                        request->nameSpace,
2000                                        handlerNamedInstance,
2001                                        formattedIndication,
2002 mday  1.73.4.1                         QueueIdStack(_handlerService, getQueueId()),
2003                                        String::EMPTY,
2004                                        String::EMPTY,
2005                                        request->contentLanguages);
2006                               
2007 kumpf 1.67                     AsyncOpNode* op = this->get_op();
2008 kumpf 1.11     
2009 kumpf 1.67                     AsyncLegacyOperationStart *async_req = 
2010 kumpf 1.11                         new AsyncLegacyOperationStart(
2011 kumpf 1.67                         get_next_xid(),
2012                                    op,
2013                                    _handlerService,
2014                                    handler_request,
2015                                    _queueId);
2016                
2017                                PEG_TRACE_STRING(TRC_INDICATION_SERVICE, Tracer::LEVEL4, 
2018 kumpf 1.73                         "Sending (SendWait) Indication to " + 
2019 kumpf 1.67                         ((MessageQueue::lookup(_handlerService)) ? 
2020                                    String(((MessageQueue::lookup
2021                                    (_handlerService))->getQueueName())) : 
2022                                    String("BAD queue name")) + 
2023                                    "via CIMHandleIndicationRequestMessage");
2024 mday  1.40     		 		 
2025 kumpf 1.44                     AsyncReply *async_reply = SendWait(async_req);
2026 kumpf 1.1      
2027 kumpf 1.15                     //
2028 kumpf 1.27                     //  ATTN-CAKG-P1-20020326: Check for error - implement 
2029 kumpf 1.15                     //  subscription's OnFatalErrorPolicy
2030                                //
2031                
2032 kumpf 1.67                     response = 
2033                                    reinterpret_cast<CIMProcessIndicationResponseMessage *>
2034                                    ((static_cast<AsyncLegacyOperationResult *>
2035                                    (async_reply))->get_result());
2036 kumpf 1.1      
2037 kumpf 1.37                     //
2038                                //  Recipient deletes request
2039                                //
2040                
2041 kumpf 1.44                     delete async_reply;
2042 kumpf 1.1                  }
2043                        }
2044 kumpf 1.11         }
2045                    catch (CIMException& exception)
2046                    {
2047 kumpf 1.23             response->cimException = exception;
2048 kumpf 1.11         }
2049                    catch (Exception& exception)
2050                    {
2051 kumpf 1.23             response->cimException = PEGASUS_CIM_EXCEPTION(CIM_ERR_FAILED,
2052                                                                       exception.getMessage());
2053 kumpf 1.11         }
2054                
2055                    _enqueueResponse(request, response);
2056                
2057 kumpf 1.48         PEG_METHOD_EXIT ();
2058 kumpf 1.11     
2059                    return;
2060                }
2061                
2062                void IndicationService::_handleNotifyProviderRegistrationRequest
2063                    (const Message* message)
2064                {
2065 kumpf 1.48         PEG_METHOD_ENTER (
2066                        TRC_INDICATION_SERVICE,
2067                        "IndicationService::_handleNotifyProviderRegistrationRequest");
2068 kumpf 1.11     
2069 kumpf 1.27         CIMNotifyProviderRegistrationRequestMessage* request = 
2070 kumpf 1.11             (CIMNotifyProviderRegistrationRequestMessage*) message;
2071                
2072 kumpf 1.23         CIMException cimException;
2073 mday  1.8      
2074 kumpf 1.12         CIMInstance provider = request->provider;
2075 kumpf 1.15         CIMInstance providerModule = request->providerModule;
2076 kumpf 1.63         CIMName className = request->className;
2077                    Array <CIMNamespaceName> newNameSpaces = request->newNamespaces;
2078                    Array <CIMNamespaceName> oldNameSpaces = request->oldNamespaces;
2079 kumpf 1.11         CIMPropertyList newPropertyNames = request->newPropertyNames;
2080                    CIMPropertyList oldPropertyNames = request->oldPropertyNames;
2081 kumpf 1.6      
2082 kumpf 1.46         Array <CIMInstance> newSubscriptions;
2083                    Array <CIMInstance> formerSubscriptions;
2084 kumpf 1.16         Array <ProviderClassList> indicationProviders;
2085                    ProviderClassList indicationProvider;
2086 kumpf 1.6      
2087 kumpf 1.11         newSubscriptions.clear ();
2088                    formerSubscriptions.clear ();
2089 kumpf 1.1      
2090 kumpf 1.11         switch (request->operation)
2091                    {
2092                        case OP_CREATE:
2093                        {
2094 kumpf 1.10                 //
2095 kumpf 1.11                 //  Get matching subscriptions
2096 kumpf 1.10                 //
2097 kumpf 1.27                 newSubscriptions = _getMatchingSubscriptions (className, 
2098 kumpf 1.15                     newNameSpaces, newPropertyNames);
2099 kumpf 1.11     
2100                            break;
2101                        }
2102 kumpf 1.10     
2103 kumpf 1.11             case OP_DELETE:
2104                        {
2105 kumpf 1.10                 //
2106 kumpf 1.11                 //  Get matching subscriptions
2107 kumpf 1.10                 //
2108 kumpf 1.27                 formerSubscriptions = _getMatchingSubscriptions (className, 
2109 kumpf 1.15                     oldNameSpaces, oldPropertyNames);
2110 kumpf 1.11     
2111                            break;
2112 kumpf 1.10             }
2113                
2114 kumpf 1.11             case OP_MODIFY:
2115 kumpf 1.10             {
2116 kumpf 1.11                 //
2117                            //  Get lists of affected subscriptions
2118                            //
2119 kumpf 1.15                 _getModifiedSubscriptions (className, newNameSpaces, oldNameSpaces,
2120 kumpf 1.27                     newPropertyNames, oldPropertyNames, 
2121 kumpf 1.15                     newSubscriptions, formerSubscriptions);
2122 kumpf 1.11     
2123                            break;
2124 kumpf 1.10             }
2125 kumpf 1.11             default:
2126                            //
2127                            //  Error condition: operation not supported
2128                            //
2129 kumpf 1.48                 PEG_METHOD_EXIT ();
2130 kumpf 1.57                 throw PEGASUS_CIM_EXCEPTION(CIM_ERR_NOT_SUPPORTED, String::EMPTY);
2131 kumpf 1.11                 break;
2132                    }  // switch
2133                
2134                    //
2135                    //  Construct provider class list from input provider and class name
2136                    //
2137 kumpf 1.12         indicationProvider.provider = provider;
2138 kumpf 1.15         indicationProvider.providerModule = providerModule;
2139 kumpf 1.11         indicationProvider.classList.append (className);
2140                    indicationProviders.append (indicationProvider);
2141 kumpf 1.10     
2142 kumpf 1.11         if (newSubscriptions.size () > 0)
2143                    {
2144                        CIMPropertyList requiredProperties;
2145                        String condition;
2146                        String queryLanguage;
2147 kumpf 1.10     
2148                        //
2149 kumpf 1.38             //  Send Create or Modify request for each subscription that can newly 
2150 kumpf 1.16             //  be supported
2151 kumpf 1.10             //
2152 kumpf 1.11             for (Uint8 i = 0; i < newSubscriptions.size (); i++)
2153 kumpf 1.10             {
2154 kumpf 1.63                 CIMNamespaceName sourceNameSpace;
2155 kumpf 1.73                 Array <CIMName> indicationSubclasses;
2156 kumpf 1.38                 _getCreateParams 
2157 kumpf 1.46                     (newSubscriptions [i].getPath ().getNameSpace (), 
2158 kumpf 1.73                     newSubscriptions [i], indicationSubclasses,
2159 kumpf 1.27                     requiredProperties, sourceNameSpace, condition, queryLanguage);
2160 kumpf 1.11     
2161                            //
2162 kumpf 1.39                 //  NOTE: These Create or Modify requests are not associated with a
2163                            //  user request, so there is no associated authType or userName
2164 kumpf 1.27                 //  The Creator from the subscription instance is used for 
2165 kumpf 1.16                 //  userName, and authType is not set
2166 kumpf 1.15                 //
2167 kumpf 1.46                 CIMInstance instance = newSubscriptions [i];
2168 kumpf 1.15                 String creator = instance.getProperty (instance.findProperty
2169 kumpf 1.38                     (PEGASUS_PROPERTYNAME_INDSUB_CREATOR)).getValue ().toString ();
2170 kumpf 1.11     
2171 mday  1.73.4.1 
2172 mday  1.73.4.2 // l10n start
2173                            String acceptLangs = String::EMPTY;
2174                            Uint32 propIndex = instance.findProperty(PEGASUS_PROPERTYNAME_INDSUB_ACCEPTLANGS);  			
2175                            if (propIndex != PEG_NOT_FOUND)
2176                            {
2177                                 instance.getProperty(propIndex).getValue().get(acceptLangs);
2178                            }
2179                            String contentLangs = String::EMPTY;
2180                            propIndex = instance.findProperty(PEGASUS_PROPERTYNAME_INDSUB_CONTENTLANGS);  			
2181                            if (propIndex != PEG_NOT_FOUND)
2182                            {
2183                                 instance.getProperty(propIndex).getValue().get(contentLangs);
2184                            }
2185                // l10n end
2186 kumpf 1.11                 //
2187 kumpf 1.73                 //  Look up the subscription in the active subscriptions table
2188 kumpf 1.16                 //
2189 kumpf 1.73                 String activeSubscriptionsKey = _generateActiveSubscriptionsKey
2190                                (newSubscriptions [i].getPath ());
2191                            ActiveSubscriptionsTableEntry tableValue;
2192                            if (_activeSubscriptionsTable.lookup (activeSubscriptionsKey,
2193                                tableValue))
2194 kumpf 1.16                 {
2195 kumpf 1.73                     Boolean update = false;
2196                                ProviderClassList providerClasses;
2197                
2198 kumpf 1.70                     //
2199 kumpf 1.73                     //  If the provider is already in the subscription's list, 
2200                                //  send a Modify request, otherwise send a Create request
2201 kumpf 1.70                     //
2202 kumpf 1.73                     Uint32 providerIndex = _providerInList (provider, tableValue);
2203                                if (providerIndex != PEG_NOT_FOUND)
2204                                {
2205                                    //
2206                                    //  Send Modify requests
2207                                    //
2208 mday  1.73.4.1 // l10n
2209 kumpf 1.73                         _sendModifyRequests (indicationProviders,
2210                                        newSubscriptions [i].getPath ().getNameSpace (), 
2211 mday  1.73.4.1                         requiredProperties, condition, queryLanguage,
2212                                        newSubscriptions [i],
2213                                        AcceptLanguages(acceptLangs),
2214                                        ContentLanguages(contentLangs), 
2215                                        creator);
2216 kumpf 1.73     
2217                                    Uint32 classIndex = _classInList (className,
2218                                        tableValue.providers [providerIndex]);
2219                                    if (classIndex == PEG_NOT_FOUND)
2220                                    {
2221                                        //
2222                                        //  Provider is already serving this subscription, but 
2223                                        //  not for this class 
2224                                        //
2225                                        update = true;
2226                                        tableValue.providers [providerIndex].classList.append 
2227                                            (className);
2228                                    }
2229                                }
2230                                else
2231                                {
2232                                    //
2233                                    //  Provider was not previously serving this subscription
2234                                    //
2235                                    update = true;
2236                                    tableValue.providers.append (indicationProvider);
2237 kumpf 1.73     
2238                                    //
2239                                    //  Send Create requests
2240                                    //
2241 mday  1.73.4.1 // l10n                
2242 kumpf 1.73                         if (!_sendCreateRequests (indicationProviders,
2243                                        sourceNameSpace, requiredProperties, condition, 
2244 mday  1.73.4.1                         queryLanguage, newSubscriptions [i], 
2245                                        AcceptLanguages(acceptLangs), 
2246                                        ContentLanguages(contentLangs),  
2247                                        creator))
2248 kumpf 1.73                         {
2249                                        PEG_METHOD_EXIT ();
2250 mday  1.73.4.2 
2251                			// l10n
2252                
2253                                        // throw PEGASUS_CIM_EXCEPTION (CIM_ERR_NOT_SUPPORTED, 
2254                			// _MSG_NOT_ACCEPTED);
2255                
2256                			throw PEGASUS_CIM_EXCEPTION_L (CIM_ERR_NOT_SUPPORTED,
2257                				 MessageLoaderParms(_MSG_NOT_ACCEPTED_KEY, _MSG_NOT_ACCEPTED));
2258                
2259 kumpf 1.73                         }
2260                        
2261                                    //
2262                                    //  Send Enable message to each provider
2263                                    //
2264                                    for (Uint8 j = 0; j < indicationProviders.size (); j++)
2265                                    {
2266                                        //
2267                                        //  Send Enable message
2268                                        //
2269                                        _sendEnable (indicationProviders [j]);
2270                                    }
2271                                }
2272                
2273 kumpf 1.16                     //
2274 kumpf 1.73                     //  NOTE: Once bugzilla #63 is fixed, the update must only
2275                                //  be done if the provider responds successfully to the
2276                                //  enable request
2277 kumpf 1.16                     //
2278 kumpf 1.73                     if (update)
2279                                {
2280                                    _activeSubscriptionsTable.remove (activeSubscriptionsKey);
2281                #ifdef PEGASUS_INDICATION_HASHTRACE
2282                                    PEG_TRACE_STRING (TRC_INDICATION_SERVICE_INTERNAL, 
2283                                        Tracer::LEVEL3, 
2284                                        "REMOVED _activeSubscriptionsTable entry: " + 
2285                                        activeSubscriptionsKey);
2286                #endif
2287                                    _insertActiveSubscriptionsEntry (tableValue.subscription,
2288                                        tableValue.providers);
2289                                }
2290                            }  // subscription found in table
2291 kumpf 1.16                 else
2292 kumpf 1.10                 {
2293 kumpf 1.16                     //
2294 kumpf 1.73                     //  Subscription not found in Active Subscriptions table
2295 kumpf 1.16                     //
2296 kumpf 1.73     
2297 kumpf 1.1                      //
2298 kumpf 1.73                     //  ATTN-CAKG-P3-20030403: Log a message
2299 kumpf 1.1                      //
2300                            }
2301                        }
2302                    }
2303 kumpf 1.11     
2304                    if (formerSubscriptions.size () > 0)
2305 kumpf 1.1          {
2306 kumpf 1.16             CIMPropertyList requiredProperties;
2307                        String condition;
2308                        String queryLanguage;
2309 kumpf 1.11     
2310                        //
2311 kumpf 1.38             //  Send Delete or Modify request for each subscription that can no 
2312 kumpf 1.16             //  longer be supported
2313 kumpf 1.11             //
2314                        for (Uint8 i = 0; i < formerSubscriptions.size (); i++)
2315                        {
2316 kumpf 1.39                 //  NOTE: These Delete or Modify requests are not associated with a
2317                            //  user request, so there is no associated authType or userName
2318 kumpf 1.16                 //  The Creator from the subscription instance is used for userName,
2319                            //  and authType is not set
2320 kumpf 1.46                 CIMInstance instance = formerSubscriptions [i];
2321 kumpf 1.15                 String creator = instance.getProperty (instance.findProperty
2322 kumpf 1.38                     (PEGASUS_PROPERTYNAME_INDSUB_CREATOR)).getValue ().toString ();
2323 kumpf 1.16     
2324 mday  1.73.4.2 // l10n start
2325                            String acceptLangs = String::EMPTY;
2326                            Uint32 propIndex = instance.findProperty(PEGASUS_PROPERTYNAME_INDSUB_ACCEPTLANGS);  			
2327                            if (propIndex != PEG_NOT_FOUND)
2328                            {
2329                                 instance.getProperty(propIndex).getValue().get(acceptLangs);
2330                            }
2331                            String contentLangs = String::EMPTY;
2332                            propIndex = instance.findProperty(PEGASUS_PROPERTYNAME_INDSUB_CONTENTLANGS);  			
2333                            if (propIndex != PEG_NOT_FOUND)
2334                            {
2335                                 instance.getProperty(propIndex).getValue().get(contentLangs);
2336                            }
2337                // l10n end
2338 mday  1.73.4.1 
2339 kumpf 1.16                 //
2340 kumpf 1.73                 //  Look up the subscription in the active subscriptions table
2341 kumpf 1.37                 //  If class list contains only the class name from the current
2342 kumpf 1.38                 //  operation, send a Delete request
2343                            //  Otherwise, send a Modify request
2344 kumpf 1.16                 //
2345 kumpf 1.73                 String activeSubscriptionsKey = _generateActiveSubscriptionsKey
2346                                (formerSubscriptions [i].getPath ());
2347                            ActiveSubscriptionsTableEntry tableValue;
2348                            if (_activeSubscriptionsTable.lookup (activeSubscriptionsKey,
2349                                tableValue))
2350 kumpf 1.16                 {
2351 kumpf 1.73                     Uint32 providerIndex = _providerInList (provider, tableValue);
2352                                if (providerIndex != PEG_NOT_FOUND)
2353 kumpf 1.37                     {
2354 kumpf 1.73                         //
2355                                    //  If class list contains only the class name from the 
2356                                    //  current delete, send a Delete request
2357                                    //
2358                                    if ((tableValue.providers [providerIndex].classList.size () 
2359                                            == 1) &&
2360                                        (tableValue.providers [providerIndex].classList 
2361                                            [0].equal (className)))
2362                                    {
2363 mday  1.73.4.1 // l10n
2364 kumpf 1.73                             _sendDeleteRequests (indicationProviders,
2365                                            formerSubscriptions [i].getPath ().getNameSpace (), 
2366 mday  1.73.4.1                             formerSubscriptions [i], 
2367                                            AcceptLanguages(acceptLangs),
2368                                            ContentLanguages(contentLangs), 
2369                                            creator);
2370 kumpf 1.16     
2371 kumpf 1.73                             tableValue.providers.remove (providerIndex);
2372                                    }
2373                    
2374 kumpf 1.70                         //
2375 kumpf 1.73                         //  Otherwise, send a Modify request
2376 kumpf 1.70                         //
2377 kumpf 1.73                         else
2378                                    {
2379                                        Uint32 classIndex = _classInList (className, 
2380                                            tableValue.providers [providerIndex]);
2381                                        if (classIndex != PEG_NOT_FOUND)
2382                                        {
2383                                        CIMNamespaceName sourceNameSpace;
2384                                        Array <CIMName> indicationSubclasses;
2385                                        _getCreateParams 
2386                                            (formerSubscriptions [i].getPath ().getNameSpace (),
2387                                            formerSubscriptions [i], indicationSubclasses,
2388                                            requiredProperties, sourceNameSpace, condition, 
2389                                            queryLanguage);
2390                
2391                                        //
2392                                        //  Send Modify requests
2393                                        //
2394 mday  1.73.4.1 // l10n                    
2395 kumpf 1.73                             _sendModifyRequests (indicationProviders,
2396                                            formerSubscriptions [i].getPath ().getNameSpace (), 
2397                                            requiredProperties, condition, queryLanguage, 
2398 mday  1.73.4.1                             formerSubscriptions [i], 
2399                                            AcceptLanguages(acceptLangs),
2400                                            ContentLanguages(contentLangs),    
2401                                            creator);
2402 kumpf 1.37     
2403 kumpf 1.73                             tableValue.providers [providerIndex].classList.remove 
2404                                            (classIndex);
2405                                        }
2406                                        else
2407                                        {
2408                                            //
2409                                            //  ATTN-CAKG-P3-20030403: Log a message
2410                                            //
2411                                        }
2412                                    }
2413                                    _activeSubscriptionsTable.remove (activeSubscriptionsKey);
2414                #ifdef PEGASUS_INDICATION_HASHTRACE
2415                                    PEG_TRACE_STRING (TRC_INDICATION_SERVICE_INTERNAL, 
2416                                        Tracer::LEVEL3, 
2417                                        "REMOVED _activeSubscriptionsTable entry: " + 
2418                                        activeSubscriptionsKey);
2419                #endif
2420                                    _insertActiveSubscriptionsEntry (tableValue.subscription,
2421                                        tableValue.providers);
2422                                }
2423                                else
2424 kumpf 1.73                     {
2425 kumpf 1.37                         //
2426 kumpf 1.73                         //  The subscription was not served by the provider 
2427 kumpf 1.37                         //
2428                                }
2429 kumpf 1.16                 }
2430                            else
2431                            {
2432 kumpf 1.37                     //
2433 kumpf 1.73                     //  ATTN-CAKG-P3-20030403: Log a message
2434 kumpf 1.37                     //
2435 kumpf 1.16                 }
2436 kumpf 1.11             }
2437 kumpf 1.1      
2438 kumpf 1.11             //
2439 kumpf 1.39             //  NOTE: When a provider that was previously serving a subscription 
2440                        //  no longer serves the subscription due to a provider registration 
2441                        //  change, an alert is always sent, even if there are still other 
2442                        //  providers serving the subscription
2443 kumpf 1.11             //
2444 kumpf 1.1      
2445 kumpf 1.11             //
2446                        //  Create NoProviderAlertIndication instance
2447                        //  ATTN: NoProviderAlertIndication must be defined
2448                        //
2449 kumpf 1.27             CIMInstance indicationInstance = _createAlertInstance 
2450 kumpf 1.11                 (_CLASS_NO_PROVIDER_ALERT, formerSubscriptions);
2451 kumpf 1.27         
2452 kumpf 1.11             //
2453                        //  Send NoProviderAlertIndication to each unique handler instance
2454                        //
2455 kumpf 1.73             Tracer::trace (TRC_INDICATION_SERVICE, Tracer::LEVEL4,
2456                            "Sending NoProvider Alert for %d subscriptions",
2457                            formerSubscriptions.size ());
2458 kumpf 1.11             _sendAlerts (formerSubscriptions, indicationInstance);
2459                    }
2460 kumpf 1.1      
2461 kumpf 1.48         PEG_METHOD_EXIT ();
2462 kumpf 1.1      }
2463                
2464 kumpf 1.73     Uint32 IndicationService::_providerInList 
2465                    (const CIMInstance & provider, 
2466                     const ActiveSubscriptionsTableEntry & tableValue)
2467                {
2468                    PEG_METHOD_ENTER (TRC_INDICATION_SERVICE,
2469                                      "IndicationService::_providerInList");
2470                
2471                    //
2472                    //  Look for the provider in the list
2473                    //
2474                    for (Uint8 i = 0; i < tableValue.providers.size (); i++)
2475                    {
2476                        if (tableValue.providers [i].provider.identical (provider))
2477                        {
2478                            return i;
2479                        }
2480                    }
2481                
2482                    return PEG_NOT_FOUND;
2483                
2484                    PEG_METHOD_EXIT ();
2485 kumpf 1.73     }
2486                
2487                Uint32 IndicationService::_classInList 
2488                    (const CIMName & className, 
2489                     const ProviderClassList & providerClasses)
2490                {
2491                    PEG_METHOD_ENTER (TRC_INDICATION_SERVICE,
2492                                      "IndicationService::_classInList");
2493                
2494                    //
2495                    //  Look for the class in the list
2496                    //
2497                    for (Uint8 i = 0; i < providerClasses.classList.size (); i++)
2498                    {
2499                        if (providerClasses.classList [i].equal (className))
2500                        {
2501                            return i;
2502                        }
2503                    }
2504                
2505                    return PEG_NOT_FOUND;
2506 kumpf 1.73     
2507                    PEG_METHOD_EXIT ();
2508                }
2509                
2510 kumpf 1.11     void IndicationService::_handleNotifyProviderTerminationRequest
2511                    (const Message * message)
2512 kumpf 1.1      {
2513 kumpf 1.46         Array <CIMInstance> providerSubscriptions;
2514 kumpf 1.11         CIMInstance indicationInstance;
2515                
2516 kumpf 1.48         PEG_METHOD_ENTER (TRC_INDICATION_SERVICE,
2517                                      "IndicationService::_handleNotifyProviderTermination");
2518 kumpf 1.1      
2519 kumpf 1.27         CIMNotifyProviderTerminationRequestMessage* request = 
2520 kumpf 1.11     	(CIMNotifyProviderTerminationRequestMessage*) message;
2521                
2522 kumpf 1.38         Array <CIMInstance> providers = request->providers;
2523 kumpf 1.11     
2524 kumpf 1.38         for (Uint8 i = 0; i < providers.size (); i++)
2525                    {
2526                        //
2527                        //  Get list of affected subscriptions
2528                        //
2529 kumpf 1.73             //  _getProviderSubscriptions also updates the Active Subscriptions 
2530                        //  hash table, and implements each subscription's On Fatal Error 
2531                        //  policy, if necessary
2532                        //
2533 kumpf 1.38             providerSubscriptions.clear ();
2534                        providerSubscriptions = _getProviderSubscriptions (providers [i]);
2535                    
2536 kumpf 1.73             if (providerSubscriptions.size () > 0)
2537                        {
2538                            //
2539                            //  NOTE: When a provider that was previously serving a subscription
2540                            //  no longer serves the subscription due to a provider termination,
2541                            //  an alert is always sent, even if there are still other providers
2542                            //  serving the subscription
2543                            //
2544                        
2545                            //
2546                            //  Create ProviderTerminatedAlertIndication instance
2547                            //  ATTN: ProviderTerminatedAlertIndication must be defined
2548                            //
2549                            indicationInstance = _createAlertInstance 
2550                                (_CLASS_PROVIDER_TERMINATED_ALERT, providerSubscriptions);
2551                        
2552                            //
2553                            //  Send ProviderTerminatedAlertIndication to each unique handler 
2554                            //  instance
2555                            //
2556                            Tracer::trace (TRC_INDICATION_SERVICE, Tracer::LEVEL4,
2557 kumpf 1.73                     "Sending ProviderDisabled Alert for %d subscriptions",
2558                                providerSubscriptions.size ());
2559                            _sendAlerts (providerSubscriptions, indicationInstance);
2560                        }
2561 kumpf 1.38         }
2562 kumpf 1.11     
2563 kumpf 1.48         PEG_METHOD_EXIT ();
2564 kumpf 1.11     }
2565 kumpf 1.1      
2566 kumpf 1.19     Boolean IndicationService::_handleError (
2567 kumpf 1.46         const CIMInstance subscription)
2568 kumpf 1.19     {
2569 kumpf 1.48         PEG_METHOD_ENTER (TRC_INDICATION_SERVICE,
2570                                      "IndicationService::_handleError");
2571 kumpf 1.19     
2572                    Boolean handleError = false;
2573                
2574                    //
2575                    //  Get the value of the On Fatal Error Policy property
2576                    //
2577                    CIMValue errorPolicyValue;
2578                    Uint16 onFatalErrorPolicy;
2579 kumpf 1.46         errorPolicyValue = subscription.getProperty 
2580                        (subscription.findProperty 
2581 kumpf 1.19             (_PROPERTY_ONFATALERRORPOLICY)).getValue ();
2582                    errorPolicyValue.get (onFatalErrorPolicy);
2583                
2584                    if (errorPolicyValue == _ERRORPOLICY_DISABLE)
2585                    {
2586                        //
2587 kumpf 1.39             //  FUTURE: Failure Trigger Time Interval should be allowed to pass 
2588                        //  before implementing On Fatal Error Policy
2589 kumpf 1.19             //
2590                        //  Set the Subscription State to disabled
2591                        //
2592                        _disableSubscription (subscription);
2593                        handleError = true;
2594                    }
2595                    else if (errorPolicyValue == _ERRORPOLICY_REMOVE)
2596                    {
2597                        //
2598 kumpf 1.39             //  FUTURE: Failure Trigger Time Interval should be allowed to pass 
2599                        //  before implementing On Fatal Error Policy
2600 kumpf 1.19             //
2601                        //  Delete the subscription
2602                        //
2603                        _deleteSubscription (subscription);
2604                        handleError = true;
2605                    }
2606                
2607 kumpf 1.48         PEG_METHOD_EXIT ();
2608 kumpf 1.19         return handleError;
2609                }
2610                
2611                void IndicationService::_disableSubscription (
2612 kumpf 1.46         CIMInstance subscription)
2613 kumpf 1.19     {
2614 kumpf 1.48         PEG_METHOD_ENTER (TRC_INDICATION_SERVICE,
2615                                      "IndicationService::_disableSubscription");
2616 kumpf 1.19     
2617                    //
2618                    //  Create property list
2619                    //
2620                    CIMPropertyList propertyList;
2621 kumpf 1.54         Array <CIMName> properties;
2622 kumpf 1.19         properties.append (_PROPERTY_STATE);
2623                    propertyList = CIMPropertyList (properties);
2624                
2625                    //
2626                    //  Set Time of Last State Change to current date time
2627                    //
2628 kumpf 1.46         CIMInstance instance = subscription;
2629 kumpf 1.35         CIMDateTime currentDateTime = CIMDateTime::getCurrentDateTime ();
2630 kumpf 1.52         if (instance.findProperty (_PROPERTY_LASTCHANGE) == PEG_NOT_FOUND)
2631 kumpf 1.19         {
2632 kumpf 1.27             instance.addProperty 
2633 kumpf 1.19                 (CIMProperty (_PROPERTY_LASTCHANGE, currentDateTime));
2634                    }
2635 kumpf 1.27         else 
2636 kumpf 1.19         {
2637 kumpf 1.27             CIMProperty lastChange = instance.getProperty 
2638 kumpf 1.19                 (instance.findProperty (_PROPERTY_LASTCHANGE));
2639                        lastChange.setValue (CIMValue (currentDateTime));
2640                    }
2641                
2642                    //
2643                    //  Set Subscription State to Disabled
2644                    //
2645 kumpf 1.27         CIMProperty state = instance.getProperty (instance.findProperty 
2646 kumpf 1.19             (_PROPERTY_STATE));
2647                    state.setValue (CIMValue (_STATE_DISABLED));
2648                
2649                    //
2650                    //  Modify the instance in the repository
2651                    //
2652                    _repository->write_lock ();
2653 kumpf 1.27        
2654 kumpf 1.19         try
2655                    {
2656 kumpf 1.27             _repository->modifyInstance 
2657 kumpf 1.46                 (subscription.getPath ().getNameSpace (),
2658 kumpf 1.19                 subscription, false, propertyList);
2659                    }
2660                    catch (Exception & exception)
2661                    {
2662                        //
2663 kumpf 1.38             //  ATTN-CAKG-P3-20020425: Log a message
2664 kumpf 1.19             //
2665                    }
2666                
2667                    _repository->write_unlock ();
2668                
2669 kumpf 1.48         PEG_METHOD_EXIT ();
2670 kumpf 1.19     }
2671                
2672                void IndicationService::_deleteSubscription (
2673 kumpf 1.46         const CIMInstance subscription)
2674 kumpf 1.19     {
2675 kumpf 1.48         PEG_METHOD_ENTER (TRC_INDICATION_SERVICE,
2676                                      "IndicationService::_deleteSubscription");
2677 kumpf 1.19     
2678                    //
2679                    //  Delete referencing subscription instance from repository
2680                    //
2681                    _repository->write_lock ();
2682                
2683                    try
2684                    {
2685 kumpf 1.27             _repository->deleteInstance 
2686 kumpf 1.46                 (subscription.getPath ().getNameSpace (), 
2687                            subscription.getPath ());
2688 kumpf 1.19         }
2689                    catch (Exception & exception)
2690                    {
2691                        //
2692 kumpf 1.38             //  ATTN-CAKG-P3-20020425: Log a message
2693 kumpf 1.19             //
2694                    }
2695                
2696                    _repository->write_unlock ();
2697                
2698 kumpf 1.48         PEG_METHOD_EXIT ();
2699 kumpf 1.19     }
2700                
2701 kumpf 1.11     Boolean IndicationService::_canCreate (
2702                    CIMInstance & instance,
2703 kumpf 1.63         const CIMNamespaceName & nameSpace)
2704 kumpf 1.11     {
2705 kumpf 1.48         PEG_METHOD_ENTER (TRC_INDICATION_SERVICE, "IndicationService::_canCreate");
2706 kumpf 1.4      
2707 kumpf 1.11         // REVIEW: Derived classes of CIM_IndicationSubscription not
2708                    // handled. It is reasonable for a user to derive from this
2709                    // class and add extra properties.
2710 kumpf 1.4      
2711 kumpf 1.11         // REVIEW: how does the provider manager know to forward
2712                    // requests to this service? Is it by class name? If so,
2713                    // shouldn't the provider use an is-a operator on the new
2714                    // class?
2715 kumpf 1.4      
2716 kumpf 1.11         //
2717                    //  Check all required properties exist
2718 kumpf 1.34         //  For a property that has a default value, if it does not exist or is 
2719                    //  null, add or set property with default value
2720                    //  For a property that has a specified set of valid values, validate
2721 kumpf 1.11         //
2722 kumpf 1.64         if (instance.getClassName ().equal (PEGASUS_CLASSNAME_INDSUBSCRIPTION))
2723 kumpf 1.11         {
2724                        //
2725                        //  Filter and Handler are key properties for Subscription
2726                        //  No other properties are required
2727                        //
2728 kumpf 1.34             _checkRequiredProperty (instance, _PROPERTY_FILTER, _MSG_KEY_PROPERTY);
2729                        _checkRequiredProperty (instance, _PROPERTY_HANDLER, _MSG_KEY_PROPERTY);
2730 kumpf 1.1      
2731 kumpf 1.34             //
2732                        //  Subscription State, Repeat Notificastion Policy, and On Fatal Error
2733                        //  Policy properties each has a default value, a corresponding 
2734                        //  Other___ property, and a set of valid values
2735                        //
2736                        _checkPropertyWithOther (instance, _PROPERTY_STATE, 
2737                            _PROPERTY_OTHERSTATE, (Uint16) _STATE_ENABLED, 
2738                            (Uint16) _STATE_OTHER, _validStates);
2739 kumpf 1.22     
2740 kumpf 1.34             _checkPropertyWithOther (instance, _PROPERTY_REPEATNOTIFICATIONPOLICY,
2741 kumpf 1.22                 _PROPERTY_OTHERREPEATNOTIFICATIONPOLICY, (Uint16) _POLICY_NONE,
2742 kumpf 1.32                 (Uint16) _POLICY_OTHER, _validRepeatPolicies);
2743 kumpf 1.22     
2744 kumpf 1.34             _checkPropertyWithOther (instance, _PROPERTY_ONFATALERRORPOLICY, 
2745 kumpf 1.32                 _PROPERTY_OTHERONFATALERRORPOLICY, (Uint16) _ERRORPOLICY_IGNORE, 
2746                            (Uint16) _ERRORPOLICY_OTHER, _validErrorPolicies);
2747 kumpf 1.27         } 
2748 kumpf 1.11         else  // Filter or Handler
2749                    {
2750 kumpf 1.1              //
2751 kumpf 1.11             //  Name, CreationClassName, SystemName, and SystemCreationClassName
2752 kumpf 1.27             //  are key properties for Filter and Handler  
2753 kumpf 1.11             //  CreationClassName and Name must exist
2754                        //  If others do not exist, add and set to default
2755 kumpf 1.1              //
2756 kumpf 1.34             _checkRequiredProperty (instance, _PROPERTY_NAME, _MSG_KEY_PROPERTY);
2757                        _checkRequiredProperty (instance, _PROPERTY_CREATIONCLASSNAME, 
2758                            _MSG_KEY_PROPERTY);
2759 kumpf 1.1      
2760 kumpf 1.34             _checkPropertyWithDefault (instance, _PROPERTY_SYSTEMNAME, 
2761                            System::getFullyQualifiedHostName ());
2762 kumpf 1.1      
2763 kumpf 1.34             _checkPropertyWithDefault (instance, _PROPERTY_SYSTEMCREATIONCLASSNAME, 
2764                            System::getSystemCreationClassName ());
2765 kumpf 1.1      
2766 kumpf 1.64             if (instance.getClassName ().equal (PEGASUS_CLASSNAME_INDFILTER))
2767 kumpf 1.10             {
2768                            //
2769 kumpf 1.11                 //  Query and QueryLanguage properties are required for Filter
2770 kumpf 1.10                 //
2771 kumpf 1.34                 _checkRequiredProperty (instance, _PROPERTY_QUERY, _MSG_PROPERTY);
2772                            _checkRequiredProperty (instance, _PROPERTY_QUERYLANGUAGE, 
2773                                _MSG_PROPERTY);
2774 kumpf 1.1      
2775 kumpf 1.10                 //
2776 kumpf 1.11                 //  Default value for Source Namespace is the namespace of the
2777                            //  Filter registration
2778 kumpf 1.10                 //
2779 kumpf 1.63                 CIMNamespaceName sourceNameSpace = CIMNamespaceName 
2780                                (_checkPropertyWithDefault (instance, _PROPERTY_SOURCENAMESPACE,
2781                                 nameSpace.getString()));
2782 kumpf 1.15     
2783                            //
2784                            //  Validate the query and indication class name
2785                            //  An exception is thrown if the query is invalid or the class
2786                            //  is not an indication class
2787                            //
2788                            String filterQuery = instance.getProperty (instance.findProperty
2789                                (_PROPERTY_QUERY)).getValue ().toString ();
2790 kumpf 1.27                 WQLSelectStatement selectStatement = 
2791 kumpf 1.15                     _getSelectStatement (filterQuery);
2792 kumpf 1.63                 CIMName indicationClassName = _getIndicationClassName 
2793 kumpf 1.15                     (selectStatement, sourceNameSpace);
2794 kumpf 1.11             }
2795 kumpf 1.10     
2796 kumpf 1.11             //
2797 kumpf 1.27             //  Currently only two direct subclasses of Indication handler 
2798                        //  class are supported -- further subclassing is not currently 
2799 kumpf 1.11             //  supported
2800                        //
2801 kumpf 1.64             else if ((instance.getClassName ().equal 
2802                                  (PEGASUS_CLASSNAME_INDHANDLER_CIMXML)) ||
2803                                 (instance.getClassName ().equal
2804                                  (PEGASUS_CLASSNAME_INDHANDLER_SNMP)))
2805 kumpf 1.11             {
2806 kumpf 1.34                 _checkPropertyWithOther (instance, _PROPERTY_PERSISTENCETYPE,
2807 kumpf 1.32                     _PROPERTY_OTHERPERSISTENCETYPE, (Uint16) _PERSISTENCE_PERMANENT,
2808                                (Uint16) _PERSISTENCE_OTHER, _validPersistenceTypes);
2809 kumpf 1.11     
2810 kumpf 1.64                 if (instance.getClassName ().equal 
2811                                (PEGASUS_CLASSNAME_INDHANDLER_CIMXML))
2812 kumpf 1.11                 {
2813 kumpf 1.13                     //
2814 kumpf 1.27                     //  Destination property is required for CIMXML 
2815 kumpf 1.13                     //  Handler subclass
2816                                //
2817 kumpf 1.34                     _checkRequiredProperty (instance, _PROPERTY_DESTINATION, 
2818                                    _MSG_PROPERTY);
2819 kumpf 1.11                 }
2820                
2821 kumpf 1.64                 if (instance.getClassName ().equal 
2822                                (PEGASUS_CLASSNAME_INDHANDLER_SNMP))
2823 kumpf 1.11                 {
2824 mday  1.73.4.1 		//
2825                                //  TargetHost property is required for SNMP
2826                                //  Handler subclass
2827 kumpf 1.11                     //
2828 mday  1.73.4.1                 _checkRequiredProperty (instance, _PROPERTY_TARGETHOST,
2829                                    _MSG_PROPERTY);
2830                
2831                                //
2832                                //  TargetHostFormat property is required for SNMP
2833 kumpf 1.13                     //  Handler subclass
2834                                //
2835 mday  1.73.4.1                 _checkRequiredProperty (instance, _PROPERTY_TARGETHOSTFORMAT,
2836 kumpf 1.34                         _MSG_PROPERTY);
2837 kumpf 1.13     
2838                                //
2839 mday  1.73.4.1                 //  SNMPVersion property is required for SNMP Handler
2840 kumpf 1.11                     //
2841 mday  1.73.4.1                 _checkRequiredProperty (instance, _PROPERTY_SNMPVERSION,
2842 kumpf 1.34                         _MSG_PROPERTY);
2843 kumpf 1.11                 }
2844                        }
2845                
2846                        else
2847                        {
2848                            //
2849                            //  A class not currently served by the Indication Service
2850                            //
2851 kumpf 1.48                 PEG_METHOD_EXIT ();
2852 mday  1.73.4.2 
2853                	    // l10n
2854                
2855                            // throw PEGASUS_CIM_EXCEPTION (CIM_ERR_NOT_SUPPORTED,
2856                	    // _MSG_CLASS_NOT_SERVED);
2857                
2858                	    throw PEGASUS_CIM_EXCEPTION_L (CIM_ERR_NOT_SUPPORTED,
2859                		     MessageLoaderParms(_MSG_CLASS_NOT_SERVED_KEY, _MSG_CLASS_NOT_SERVED));
2860 kumpf 1.11             }
2861 kumpf 1.1          }
2862                
2863 kumpf 1.48         PEG_METHOD_EXIT ();
2864 kumpf 1.11         return true;
2865 kumpf 1.22     }
2866                
2867 kumpf 1.34     void IndicationService::_checkRequiredProperty (
2868                    CIMInstance & instance,
2869 kumpf 1.63         const CIMName & propertyName,
2870 kumpf 1.34         const String & message)
2871                {
2872 kumpf 1.48         PEG_METHOD_ENTER (TRC_INDICATION_SERVICE,
2873                                      "IndicationService::_checkRequiredProperty");
2874 kumpf 1.34     
2875                    Boolean missingProperty = false;
2876                
2877                    //
2878                    //  Required property must exist in instance
2879                    //
2880 kumpf 1.52         if (instance.findProperty (propertyName) == PEG_NOT_FOUND)
2881 kumpf 1.34         {
2882                        missingProperty = true;
2883                    }
2884                    else
2885                    {
2886                        //
2887                        //  Get the property
2888                        //
2889                        CIMProperty theProperty = instance.getProperty
2890                            (instance.findProperty (propertyName));
2891                        CIMValue theValue = theProperty.getValue ();
2892                
2893                        //
2894                        //  Required property must have a non-null value
2895                        //
2896                        if (theValue.isNull ())
2897                        {
2898                            missingProperty = true;
2899                        }
2900                    }
2901                
2902 kumpf 1.34         if (missingProperty)
2903                    {
2904 mday  1.73.4.2 
2905                      // l10n
2906                
2907                      String exceptionStr = _MSG_MISSING_REQUIRED;
2908                      // exceptionStr.append (propertyName.getString());
2909                      exceptionStr.append ("$0");
2910                      exceptionStr.append (message);
2911                
2912                      String message_key;
2913                      if (strcmp(message.getCString(), _MSG_KEY_PROPERTY) == 0) {
2914                	message_key = _MSG_KEY_PROPERTY_KEY;
2915                      } else if (strcmp(message.getCString(), _MSG_PROPERTY) == 0) {
2916                	message_key = _MSG_PROPERTY_KEY;
2917                      } else {
2918                	message_key = String("");
2919                      }
2920                
2921                      PEG_METHOD_EXIT ();
2922                      
2923                      // l10n
2924                
2925 mday  1.73.4.2       // throw PEGASUS_CIM_EXCEPTION (CIM_ERR_INVALID_PARAMETER,
2926                      //		   exceptionStr);
2927                
2928                      throw PEGASUS_CIM_EXCEPTION_L (CIM_ERR_INVALID_PARAMETER,
2929                				     MessageLoaderParms(message_key, 
2930                				     exceptionStr, propertyName.getString()));
2931                
2932 kumpf 1.34         }
2933 kumpf 1.48         PEG_METHOD_EXIT ();
2934 kumpf 1.34     }
2935                
2936                void IndicationService::_checkPropertyWithOther (
2937 kumpf 1.22         CIMInstance & instance,
2938 kumpf 1.63         const CIMName & propertyName,
2939                    const CIMName & otherPropertyName,
2940 kumpf 1.22         const Uint16 defaultValue,
2941 kumpf 1.32         const Uint16 otherValue,
2942                    const Array <Uint16> & validValues)
2943 kumpf 1.22     {
2944                    Uint16 result = defaultValue;
2945                
2946 kumpf 1.48         PEG_METHOD_ENTER (TRC_INDICATION_SERVICE,
2947                                      "IndicationService::_checkPropertyWithOther");
2948 kumpf 1.22     
2949                    //
2950                    //  If the property doesn't exist, add it with the default value
2951                    //
2952 kumpf 1.52         if (instance.findProperty (propertyName) == PEG_NOT_FOUND)
2953 kumpf 1.22         {
2954                        instance.addProperty (CIMProperty (propertyName,
2955                            CIMValue (defaultValue)));
2956                    }
2957                    else
2958                    {
2959                        //
2960                        //  Get the property
2961                        //
2962                        CIMProperty theProperty = instance.getProperty
2963                            (instance.findProperty (propertyName));
2964                        CIMValue theValue = theProperty.getValue ();
2965                
2966                        //
2967                        //  If the value is null, set to the default value
2968                        //
2969                        if (theValue.isNull ())
2970                        {
2971                            theProperty.setValue (CIMValue (defaultValue));
2972                        }
2973                        else
2974 kumpf 1.22             {
2975                            theValue.get (result);
2976                
2977                            //
2978 kumpf 1.35                 //  Validate the value
2979 kumpf 1.22                 //
2980 kumpf 1.32                 if (!Contains (validValues, result))
2981                            {
2982 mday  1.73.4.2 	      // l10n
2983                
2984 kumpf 1.32                     String exceptionStr = _MSG_INVALID_VALUE;
2985 mday  1.73.4.2                 // exceptionStr.append (theValue.toString ());
2986                		exceptionStr.append ("$0");
2987 kumpf 1.32                     exceptionStr.append (_MSG_FOR_PROPERTY);
2988 mday  1.73.4.2                 // exceptionStr.append (propertyName.getString());
2989                		exceptionStr.append ("$1");
2990                
2991 kumpf 1.48                     PEG_METHOD_EXIT ();
2992 mday  1.73.4.2 
2993                                // throw PEGASUS_CIM_EXCEPTION (CIM_ERR_INVALID_PARAMETER,
2994                		//    exceptionStr);
2995                
2996                                throw PEGASUS_CIM_EXCEPTION_L (CIM_ERR_INVALID_PARAMETER,
2997                                    MessageLoaderParms(_MSG_INVALID_VALUE_FOR_PROPERTY_KEY, exceptionStr,
2998                				       theValue.toString(), propertyName.getString()));
2999 kumpf 1.32                 }
3000 kumpf 1.22             }
3001                
3002                        //
3003                        //  If the value is Other, the Other
3004                        //  property must exist and value must not be NULL
3005                        //
3006                        if (result == otherValue)
3007                        {
3008 kumpf 1.52                 if (instance.findProperty (otherPropertyName) == PEG_NOT_FOUND)
3009 kumpf 1.22                 {
3010 mday  1.73.4.2 	      // l10n
3011                
3012                	      String exceptionStr = _MSG_MISSING_REQUIRED;
3013                	      // exceptionStr.append (otherPropertyName.getString());
3014                	      exceptionStr.append ("$0");
3015                	      exceptionStr.append (_MSG_PROPERTY);
3016                
3017                	      PEG_METHOD_EXIT ();
3018                
3019                	      // l10n
3020                                
3021                	      // throw PEGASUS_CIM_EXCEPTION (CIM_ERR_INVALID_PARAMETER,
3022                	      //		   exceptionStr);
3023                
3024                	      throw PEGASUS_CIM_EXCEPTION_L (CIM_ERR_INVALID_PARAMETER,
3025                					     MessageLoaderParms(_MSG_PROPERTY_KEY, 
3026                								exceptionStr,
3027                								otherPropertyName.getString()));
3028                
3029 kumpf 1.22                 }
3030                            else
3031                            {
3032                                CIMProperty otherProperty = instance.getProperty
3033                                    (instance.findProperty (otherPropertyName));
3034                                CIMValue theOtherValue = otherProperty.getValue ();
3035                                if (theOtherValue.isNull ())
3036                                {
3037 mday  1.73.4.2 		  // l10n
3038                
3039 kumpf 1.22                         String exceptionStr = _MSG_MISSING_REQUIRED;
3040 mday  1.73.4.2                     // exceptionStr.append (otherPropertyName.getString());
3041                		    exceptionStr.append ("$0");
3042 kumpf 1.22                         exceptionStr.append (_MSG_PROPERTY);
3043 mday  1.73.4.2 
3044 kumpf 1.48                         PEG_METHOD_EXIT ();
3045 mday  1.73.4.2 
3046                		    // l10n
3047                                    // throw PEGASUS_CIM_EXCEPTION (CIM_ERR_INVALID_PARAMETER,
3048                		    //  exceptionStr);
3049                
3050                		    throw PEGASUS_CIM_EXCEPTION_L (CIM_ERR_INVALID_PARAMETER,
3051                					     MessageLoaderParms(_MSG_PROPERTY_KEY, 
3052                								exceptionStr,
3053                								otherPropertyName.getString()));
3054 kumpf 1.22                     }
3055                            }
3056                        }
3057                
3058                        //
3059                        //  If value is not Other, Other property must not exist
3060                        //  or must be NULL
3061                        //
3062 kumpf 1.52             else if (instance.findProperty (otherPropertyName) != PEG_NOT_FOUND)
3063 kumpf 1.22             {
3064                            CIMProperty otherProperty = instance.getProperty
3065                                (instance.findProperty (otherPropertyName));
3066                            CIMValue theOtherValue = otherProperty.getValue ();
3067                            if (!theOtherValue.isNull ())
3068                            {
3069 mday  1.73.4.2 	      // l10n
3070                
3071                	      // String exceptionStr = otherPropertyName.getString();
3072                	      String exceptionStr ("$0");
3073                	      exceptionStr.append (_MSG_PROPERTY_PRESENT);
3074                	      // exceptionStr.append (propertyName.getString());
3075                	      exceptionStr.append ("$1");
3076                	      exceptionStr.append (_MSG_VALUE_NOT);
3077                	      // exceptionStr.append (CIMValue (otherValue).toString ());
3078                	      exceptionStr.append ("$2");
3079                	      
3080 kumpf 1.48                     PEG_METHOD_EXIT ();
3081 mday  1.73.4.2 
3082                		// l10n
3083                
3084                                // throw PEGASUS_CIM_EXCEPTION (CIM_ERR_INVALID_PARAMETER,
3085                		//  exceptionStr);
3086                
3087                		throw PEGASUS_CIM_EXCEPTION_L (CIM_ERR_INVALID_PARAMETER,
3088                			     MessageLoaderParms(_MSG_PROPERTY_PRESENT_BUT_VALUE_NOT_KEY, 
3089                						exceptionStr,
3090                						otherPropertyName.getString(),
3091                						propertyName.getString(),
3092                						CIMValue (otherValue).toString ()));
3093 kumpf 1.22                 }
3094                        }
3095                    }
3096                
3097 kumpf 1.48         PEG_METHOD_EXIT ();
3098 kumpf 1.1      }
3099                
3100 kumpf 1.34     String IndicationService::_checkPropertyWithDefault (
3101                    CIMInstance & instance,
3102 kumpf 1.63         const CIMName & propertyName,
3103 kumpf 1.34         const String & defaultValue)
3104                {
3105                    String result = defaultValue;
3106                
3107 kumpf 1.48         PEG_METHOD_ENTER (TRC_INDICATION_SERVICE,
3108                                      "IndicationService::_checkPropertyWithDefault");
3109 kumpf 1.34     
3110                    //
3111                    //  If the property doesn't exist, add it with the default value
3112                    //
3113 kumpf 1.52         if (instance.findProperty (propertyName) == PEG_NOT_FOUND)
3114 kumpf 1.34         {
3115                        instance.addProperty (CIMProperty (propertyName,
3116                            CIMValue (defaultValue)));
3117                    }
3118                    else
3119                    {
3120                        //
3121                        //  Get the property
3122                        //
3123                        CIMProperty theProperty = instance.getProperty
3124                            (instance.findProperty (propertyName));
3125                        CIMValue theValue = theProperty.getValue ();
3126                
3127                        //
3128                        //  If the value is null, set to the default value
3129                        //
3130                        if (theValue.isNull ())
3131                        {
3132                            theProperty.setValue (CIMValue (defaultValue));
3133                        }
3134                        else
3135 kumpf 1.34             {
3136                            theValue.get (result);
3137                        }
3138                    }
3139                
3140                    return result;
3141                
3142 kumpf 1.48         PEG_METHOD_EXIT ();
3143 kumpf 1.34     }
3144                
3145 kumpf 1.11     Boolean IndicationService::_canModify (
3146                    const CIMModifyInstanceRequestMessage * request,
3147 kumpf 1.45         const CIMObjectPath & instanceReference,
3148 kumpf 1.32         CIMInstance & instance)
3149 kumpf 1.1      {
3150 kumpf 1.48         PEG_METHOD_ENTER (TRC_INDICATION_SERVICE, "IndicationService::_canModify");
3151 kumpf 1.1      
3152 kumpf 1.11         //
3153 kumpf 1.27         //  Currently, only modification allowed is of Subscription State 
3154 kumpf 1.11         //  property in Subscription class
3155                    //
3156 kumpf 1.64         if (!instanceReference.getClassName ().equal 
3157                        (PEGASUS_CLASSNAME_INDSUBSCRIPTION))
3158 kumpf 1.11         {
3159 kumpf 1.48             PEG_METHOD_EXIT ();
3160 kumpf 1.57             throw PEGASUS_CIM_EXCEPTION(CIM_ERR_NOT_SUPPORTED, String::EMPTY);
3161 kumpf 1.11         }
3162 kumpf 1.1      
3163 kumpf 1.11         if (request->includeQualifiers)
3164 kumpf 1.1          {
3165 kumpf 1.48             PEG_METHOD_EXIT ();
3166 kumpf 1.57             throw PEGASUS_CIM_EXCEPTION(CIM_ERR_NOT_SUPPORTED, String::EMPTY);
3167 kumpf 1.11         }
3168 kumpf 1.1      
3169 kumpf 1.11         //
3170                    //  Request is invalid if property list is null, meaning all properties
3171                    //  are to be updated
3172                    //
3173                    if (request->propertyList.isNull ())
3174                    {
3175 kumpf 1.48             PEG_METHOD_EXIT ();
3176 kumpf 1.57             throw PEGASUS_CIM_EXCEPTION(CIM_ERR_NOT_SUPPORTED, String::EMPTY);
3177 kumpf 1.11         }
3178 kumpf 1.1      
3179 kumpf 1.11         //
3180                    //  Request is invalid if more than one property is specified
3181                    //
3182 kumpf 1.51         else if (request->propertyList.size () > 1)
3183 kumpf 1.1          {
3184 kumpf 1.48             PEG_METHOD_EXIT ();
3185 kumpf 1.57             throw PEGASUS_CIM_EXCEPTION(CIM_ERR_NOT_SUPPORTED, String::EMPTY);
3186 kumpf 1.1          }
3187 kumpf 1.11     
3188                    //
3189                    //  For request to be valid, zero or one property must be specified
3190                    //  If one property specified, it must be Subscription State property
3191                    //
3192 kumpf 1.51         else if ((request->propertyList.size () == 1) &&
3193 kumpf 1.64                  (!request->propertyList[0].equal (_PROPERTY_STATE)))
3194 kumpf 1.1          {
3195 kumpf 1.48             PEG_METHOD_EXIT ();
3196 kumpf 1.57             throw PEGASUS_CIM_EXCEPTION(CIM_ERR_NOT_SUPPORTED, String::EMPTY);
3197 kumpf 1.1          }
3198                
3199 kumpf 1.34         _checkPropertyWithOther (instance, _PROPERTY_STATE, _PROPERTY_OTHERSTATE,
3200 kumpf 1.32             (Uint16) _STATE_ENABLED, (Uint16) _STATE_OTHER, _validStates);
3201                
3202 kumpf 1.11         //
3203                    //  Get creator from instance
3204                    //
3205 kumpf 1.27         String creator = instance.getProperty (instance.findProperty 
3206 kumpf 1.38             (PEGASUS_PROPERTYNAME_INDSUB_CREATOR)).getValue ().toString ();
3207 kumpf 1.1      
3208 kumpf 1.11         //
3209                    //  Current user must be privileged user or instance Creator to modify
3210 kumpf 1.13         //  NOTE: if authentication was not turned on when instance was created,
3211                    //  instance creator will be String::EMPTY
3212 kumpf 1.27         //  If creator is String::EMPTY, anyone may modify or delete the 
3213 kumpf 1.13         //  instance
3214                    //
3215                    String currentUser = request->userName;
3216                    if ((creator != String::EMPTY) &&
3217 kumpf 1.27             (!System::isPrivilegedUser (currentUser)) && 
3218 kumpf 1.11             (currentUser != creator))
3219                    {
3220 kumpf 1.48             PEG_METHOD_EXIT ();
3221 kumpf 1.57             throw PEGASUS_CIM_EXCEPTION(CIM_ERR_ACCESS_DENIED, String::EMPTY);
3222 kumpf 1.11         }
3223 kumpf 1.1      
3224 kumpf 1.11         return true;
3225 kumpf 1.48         PEG_METHOD_EXIT ();
3226 kumpf 1.1      }
3227                
3228 kumpf 1.11     Boolean IndicationService::_canDelete (
3229 kumpf 1.45         const CIMObjectPath & instanceReference,
3230 kumpf 1.63         const CIMNamespaceName & nameSpace,
3231 kumpf 1.16         const String & currentUser)
3232 kumpf 1.1      {
3233 kumpf 1.63         CIMName superClass;
3234                    CIMName propName;
3235 kumpf 1.11     
3236 kumpf 1.48         PEG_METHOD_ENTER (TRC_INDICATION_SERVICE, "IndicationService::_canDelete");
3237 kumpf 1.1      
3238 kumpf 1.11         //
3239 kumpf 1.16         //  Get the instance to be deleted from the respository
3240                    //
3241 kumpf 1.19         CIMInstance instance;
3242                
3243                    _repository->read_lock ();
3244                
3245                    try
3246                    {
3247                        instance = _repository->getInstance (nameSpace, instanceReference);
3248                    }
3249                    catch (Exception e)
3250                    {
3251                        _repository->read_unlock ();
3252 kumpf 1.48             PEG_METHOD_EXIT ();
3253 kumpf 1.19             throw e;
3254                    }
3255                
3256                    _repository->read_unlock ();
3257 kumpf 1.16     
3258                    //
3259                    //  Get creator from instance
3260                    //
3261 kumpf 1.27         String creator = instance.getProperty (instance.findProperty 
3262 kumpf 1.38             (PEGASUS_PROPERTYNAME_INDSUB_CREATOR)).getValue ().toString ();
3263 kumpf 1.16     
3264                    //
3265                    //  Current user must be privileged user or instance Creator to delete
3266                    //  NOTE: if authentication was not turned on when instance was created,
3267                    //  instance creator will be String::EMPTY
3268 kumpf 1.27         //  If creator is String::EMPTY, anyone may modify or delete the 
3269 kumpf 1.16         //  instance
3270                    //
3271                    if ((creator != String::EMPTY) &&
3272                        (!System::isPrivilegedUser (currentUser)) &&
3273                        (currentUser != creator))
3274                    {
3275 kumpf 1.48             PEG_METHOD_EXIT ();
3276 kumpf 1.57             throw PEGASUS_CIM_EXCEPTION(CIM_ERR_ACCESS_DENIED, String::EMPTY);
3277 kumpf 1.16         }
3278                
3279                    //
3280 kumpf 1.11         //  Get the class and superclass of the instance to be deleted
3281                    //
3282 kumpf 1.19         CIMClass refClass;
3283                    _repository->read_lock ();
3284                
3285                    try
3286                    {
3287                        refClass = _repository->getClass (nameSpace,
3288                            instanceReference.getClassName ());
3289                    }
3290                    catch (Exception e)
3291                    {
3292                        _repository->read_unlock ();
3293 kumpf 1.48             PEG_METHOD_EXIT ();
3294 kumpf 1.19             throw e;
3295                    }
3296                
3297                    _repository->read_unlock ();
3298 kumpf 1.1      
3299 kumpf 1.11         superClass = refClass.getSuperClassName();
3300 kumpf 1.1      
3301 kumpf 1.11         //
3302 kumpf 1.27         //  If the class or superclass is Filter or Handler, check for 
3303 kumpf 1.11         //  subscription instances referring to the instance to be deleted
3304                    //
3305 kumpf 1.64         if ((superClass.equal (PEGASUS_CLASSNAME_INDFILTER)) ||
3306                        (superClass.equal (PEGASUS_CLASSNAME_INDHANDLER)) ||
3307                        (instanceReference.getClassName().equal (PEGASUS_CLASSNAME_INDFILTER)) 
3308                     || (instanceReference.getClassName().equal (PEGASUS_CLASSNAME_INDHANDLER)))
3309                    {
3310                        if ((superClass.equal (PEGASUS_CLASSNAME_INDFILTER)) ||
3311                            (instanceReference.getClassName().equal 
3312                            (PEGASUS_CLASSNAME_INDFILTER)))
3313 kumpf 1.11             {
3314                            propName = _PROPERTY_FILTER;
3315                        }
3316 kumpf 1.64             else if (superClass.equal (PEGASUS_CLASSNAME_INDHANDLER))
3317 kumpf 1.1              {
3318 kumpf 1.11                 propName = _PROPERTY_HANDLER;
3319 kumpf 1.1      
3320 kumpf 1.11                 //
3321 kumpf 1.27                 //  If deleting transient handler, first delete any referencing 
3322 kumpf 1.11                 //  subscriptions
3323                            //
3324                            if (_isTransient (nameSpace, instanceReference))
3325 kumpf 1.1                  {
3326 kumpf 1.11                     _deleteReferencingSubscriptions (nameSpace, propName,
3327                                    instanceReference);
3328 kumpf 1.48                     PEG_METHOD_EXIT ();
3329 kumpf 1.11                     return true;
3330 kumpf 1.1                  }
3331 kumpf 1.11             }
3332 kumpf 1.1      
3333 kumpf 1.11             //
3334 kumpf 1.22             //  Get all the subscriptions in the same namespace from the respository
3335 kumpf 1.11             //
3336 kumpf 1.46             Array <CIMInstance> subscriptions = _getSubscriptions (nameSpace);
3337 kumpf 1.1      
3338 kumpf 1.11             CIMValue propValue;
3339 kumpf 1.1      
3340 kumpf 1.11             //
3341 kumpf 1.27             //  Check each subscription for a reference to the instance to be 
3342 kumpf 1.11             //  deleted
3343                        //
3344 kumpf 1.15             for (Uint8 i = 0; i < subscriptions.size(); i++)
3345 kumpf 1.11             {
3346                            //
3347                            //  Get the subscription Filter or Handler property value
3348                            //
3349 kumpf 1.46                 propValue = subscriptions[i].getProperty
3350                                (subscriptions[i].findProperty
3351 kumpf 1.11                     (propName)).getValue();
3352 kumpf 1.27                 
3353 kumpf 1.45                 CIMObjectPath ref;
3354 kumpf 1.11                 propValue.get (ref);
3355 kumpf 1.4      
3356 kumpf 1.11                 //
3357 kumpf 1.27                 //  If the current subscription Filter or Handler is the instance 
3358 kumpf 1.11                 //  to be deleted, it may not be deleted
3359                            //
3360                            // ATTN: Can namespaces in the references cause comparison failure?
3361                            //
3362                            if (instanceReference == ref)
3363                            {
3364 kumpf 1.48                     PEG_METHOD_EXIT ();
3365 mday  1.73.4.2 
3366                		// l10n
3367                
3368                                // String exceptionStr = _MSG_REFERENCED;
3369                                // throw PEGASUS_CIM_EXCEPTION (CIM_ERR_FAILED, exceptionStr);
3370                
3371                		throw PEGASUS_CIM_EXCEPTION_L (CIM_ERR_FAILED,
3372                			 MessageLoaderParms(_MSG_REFERENCED_KEY, _MSG_REFERENCED));
3373 kumpf 1.1                  }
3374                        }
3375                    }
3376                
3377 kumpf 1.48         PEG_METHOD_EXIT ();
3378 kumpf 1.11         return true;
3379                }
3380 kumpf 1.4      
3381 kumpf 1.1      
3382 kumpf 1.73     Array <CIMInstance> 
3383                IndicationService::_getActiveSubscriptionsFromRepository () const
3384 kumpf 1.1      {
3385 kumpf 1.46         Array <CIMInstance> activeSubscriptions;
3386 kumpf 1.63         Array <CIMNamespaceName> nameSpaceNames;
3387 kumpf 1.46         Array <CIMInstance> subscriptions;
3388 kumpf 1.11         CIMValue subscriptionStateValue;
3389                    Uint16 subscriptionState;
3390                
3391 kumpf 1.48         PEG_METHOD_ENTER (TRC_INDICATION_SERVICE,
3392 kumpf 1.73             "IndicationService::_getActiveSubscriptionsFromRepository");
3393 kumpf 1.1      
3394 kumpf 1.11         //
3395                    //  Get list of namespaces in repository
3396                    //
3397 kumpf 1.22         nameSpaceNames = _getNameSpaceNames ();
3398 kumpf 1.1      
3399 kumpf 1.11         //
3400                    //  Get existing subscriptions from each namespace in the repository
3401                    //
3402                    for (Uint8 i = 0; i < nameSpaceNames.size (); i++)
3403 kumpf 1.1          {
3404                
3405 kumpf 1.11             //
3406                        //  Get existing subscriptions in current namespace
3407                        //
3408 kumpf 1.22             subscriptions = _getSubscriptions (nameSpaceNames [i]);
3409 kumpf 1.19     
3410 kumpf 1.1              //
3411 kumpf 1.11             //  Process each subscription
3412 kumpf 1.1              //
3413 kumpf 1.11             for (Uint8 j = 0; j < subscriptions.size (); j++)
3414 kumpf 1.1              {
3415                            //
3416 kumpf 1.11                 //  Get subscription state
3417 kumpf 1.1                  //
3418 kumpf 1.27                 subscriptionStateValue = 
3419 kumpf 1.46                     subscriptions [j].getProperty
3420                                (subscriptions [j].findProperty 
3421 kumpf 1.11                     (_PROPERTY_STATE)).getValue ();
3422                            subscriptionStateValue.get (subscriptionState);
3423 kumpf 1.1      
3424 kumpf 1.27         
3425 kumpf 1.1                  //
3426 kumpf 1.11                 //  Process each enabled subscription
3427 kumpf 1.1                  //
3428 kumpf 1.11                 if ((subscriptionState == _STATE_ENABLED) ||
3429                                (subscriptionState == _STATE_ENABLEDDEGRADED))
3430 kumpf 1.1                  {
3431 kumpf 1.13                     //
3432 kumpf 1.46                     //  CIMInstances returned from repository do not include 
3433 kumpf 1.13                     //  namespace
3434                                //  Set namespace here
3435                                //
3436 kumpf 1.45                     CIMObjectPath instanceName = 
3437 kumpf 1.46                         subscriptions [j].getPath ();
3438 kumpf 1.13                     instanceName.setNameSpace (nameSpaceNames [i]);
3439 kumpf 1.46                     subscriptions [j].setPath (instanceName);
3440                                activeSubscriptions.append (subscriptions [j]);
3441 kumpf 1.11                 }  // if subscription is enabled
3442                        }  // for each subscription
3443                    }  // for each namespace
3444 kumpf 1.1      
3445 kumpf 1.48         PEG_METHOD_EXIT ();
3446 kumpf 1.19         return activeSubscriptions;
3447 kumpf 1.1      }
3448                
3449 kumpf 1.73     Array <CIMInstance> IndicationService::_getActiveSubscriptions () const
3450                {
3451                    Array <CIMInstance> activeSubscriptions;
3452                
3453                    PEG_METHOD_ENTER (TRC_INDICATION_SERVICE,
3454                                      "IndicationService::_getActiveSubscriptions");
3455                              
3456                    //
3457                    //  Iterate through the subscription table
3458                    //
3459                    for (ActiveSubscriptionsTable::Iterator i =
3460                        _activeSubscriptionsTable.start (); i; i++)
3461                    {
3462                        //
3463                        //  Append subscription to the list
3464                        //
3465                        activeSubscriptions.append (i.value ().subscription);
3466                    }
3467                
3468                    PEG_METHOD_EXIT ();
3469                    return activeSubscriptions;
3470 kumpf 1.73     }
3471                
3472 kumpf 1.11     
3473 kumpf 1.46     Array <CIMInstance> IndicationService::_getMatchingSubscriptions (
3474 kumpf 1.63         const CIMName & supportedClass,
3475                    const Array <CIMNamespaceName> nameSpaces,
3476 kumpf 1.27         const CIMPropertyList & supportedProperties) 
3477 kumpf 1.1      {
3478 kumpf 1.46         Array <CIMInstance> matchingSubscriptions;
3479                    Array <CIMInstance> subscriptions;
3480 kumpf 1.1      
3481 kumpf 1.48         PEG_METHOD_ENTER (TRC_INDICATION_SERVICE,
3482                                      "IndicationService::_getMatchingSubscriptions");
3483 kumpf 1.1      
3484 kumpf 1.73         for (Uint8 i = 0; i < nameSpaces.size (); i++)
3485 kumpf 1.11         {
3486                        //
3487 kumpf 1.73             //  Look up the indicationClass-sourceNamespace pair in the 
3488                        //  Subscription Classes table
3489 kumpf 1.11             //
3490 kumpf 1.73             String subscriptionClassesKey = _generateSubscriptionClassesKey 
3491                            (supportedClass, nameSpaces [i]);
3492                        SubscriptionClassesTableEntry tableValue;
3493                        if (_subscriptionClassesTable.lookup (subscriptionClassesKey, 
3494                            tableValue))
3495                        {
3496                            subscriptions = tableValue.subscriptions;
3497                            for (Uint8 j = 0; j < subscriptions.size (); j++)
3498                            {
3499                                Boolean match = true;
3500                
3501                                //
3502                                //  If supported properties is null (all properties)
3503                                //  the subscription can be supported
3504                                //
3505                                if (!supportedProperties.isNull ())
3506                                {
3507                                    String filterQuery;
3508                                    WQLSelectStatement selectStatement;
3509                                    CIMName indicationClassName;
3510                                    CIMNamespaceName sourceNameSpace;
3511 kumpf 1.73                         CIMPropertyList propertyList;
3512 kumpf 1.11     
3513                                    //
3514 kumpf 1.73                         //  Get filter properties
3515                                    //
3516                                    _getFilterProperties (subscriptions [j],
3517                                        nameSpaces [i], filterQuery, sourceNameSpace);
3518                                    selectStatement = _getSelectStatement (filterQuery);
3519                            
3520                                    //
3521                                    //  Get indication class name from filter query
3522                                    //
3523                                    indicationClassName = _getIndicationClassName 
3524                                        (selectStatement, sourceNameSpace);
3525                            
3526                                    //
3527                                    //  Get property list from filter query (FROM and 
3528                                    //  WHERE clauses)
3529                                    //
3530                                    propertyList = _getPropertyList (selectStatement,
3531                                        sourceNameSpace, indicationClassName);
3532                                
3533                                    //
3534                                    //  If the subscription requires all properties,
3535 kumpf 1.73                         //  but supported property list does not include all 
3536                                    //  properties, the subscription cannot be supported
3537 kumpf 1.11                         //
3538 kumpf 1.73                         if (propertyList.isNull ())
3539                                    {
3540                                        match = false;
3541                                    }
3542                                    else 
3543 kumpf 1.11                         {
3544                                        //
3545 kumpf 1.73                             //  Compare subscription property list
3546                                        //  with supported property list
3547 kumpf 1.11                             //
3548 kumpf 1.73                             for (Uint8 k = 0; 
3549                                             k < propertyList.size () && match; 
3550                                             k++)
3551 kumpf 1.11                             {
3552 kumpf 1.73                                 if (!ContainsCIMName
3553                                                (supportedProperties.getPropertyNameArray(),
3554                                                propertyList[k]))
3555 kumpf 1.11                                 {
3556 kumpf 1.73                                     match = false;
3557 kumpf 1.11                                 }
3558                                        }
3559                                    }
3560 kumpf 1.73                     }
3561 kumpf 1.11     
3562 kumpf 1.73                     if (match)
3563                                {
3564 kumpf 1.11                         //
3565 kumpf 1.16                         //  Add current subscription to list
3566 kumpf 1.11                         //
3567 kumpf 1.73                         matchingSubscriptions.append (subscriptions [j]);
3568                                }
3569                            }
3570                        }
3571                    }
3572 kumpf 1.1      
3573 kumpf 1.48         PEG_METHOD_EXIT ();
3574 kumpf 1.19         return matchingSubscriptions;
3575 kumpf 1.1      }
3576                
3577 kumpf 1.11     void IndicationService::_getModifiedSubscriptions (
3578 kumpf 1.63         const CIMName & supportedClass,
3579                    const Array <CIMNamespaceName> & newNameSpaces,
3580                    const Array <CIMNamespaceName> & oldNameSpaces,
3581 kumpf 1.11         const CIMPropertyList & newProperties,
3582                    const CIMPropertyList & oldProperties,
3583 kumpf 1.46         Array <CIMInstance> & newSubscriptions,
3584                    Array <CIMInstance> & formerSubscriptions)
3585 kumpf 1.1      {
3586 kumpf 1.73         Array <CIMInstance> newList;
3587                    Array <CIMInstance> formerList;
3588                    Array <CIMInstance> bothList;
3589 kumpf 1.1      
3590 kumpf 1.48         PEG_METHOD_ENTER (TRC_INDICATION_SERVICE,
3591                                      "IndicationService::_getModifiedSubscriptions");
3592 kumpf 1.1      
3593 kumpf 1.11         newSubscriptions.clear ();
3594                    formerSubscriptions.clear ();
3595                
3596 kumpf 1.1          //
3597 kumpf 1.73         //  For each newly supported namespace, lookup to retrieve list of 
3598                    //  subscriptions for the indication class-source namespace pair
3599                    //
3600                    for (Uint8 i = 0; i < newNameSpaces.size (); i++)
3601                    {
3602                        //
3603                        //  Look up the indicationClass-sourceNamespace pair in the
3604                        //  Subscription Classes table
3605                        //
3606                        String subscriptionClassesKey = _generateSubscriptionClassesKey
3607                            (supportedClass, newNameSpaces [i]);
3608                        SubscriptionClassesTableEntry tableValue;
3609                        if (_subscriptionClassesTable.lookup (subscriptionClassesKey,
3610                            tableValue))
3611                        {
3612                            for (Uint8 j = 0; j < tableValue.subscriptions.size (); j++)
3613                                newList.append (tableValue.subscriptions [j]);
3614                        }
3615                    }
3616                
3617                    //
3618 kumpf 1.73         //  For each formerly supported namespace, lookup to retrieve list of 
3619                    //  subscriptions for the indication class-source namespace pair
3620                    //
3621                    for (Uint8 k = 0; k < oldNameSpaces.size (); k++)
3622                    {
3623                        //
3624                        //  Look up the indicationClass-sourceNamespace pair in the
3625                        //  Subscription Classes table
3626                        //
3627                        String subscriptionClassesKey = _generateSubscriptionClassesKey
3628                            (supportedClass, oldNameSpaces [k]);
3629                        SubscriptionClassesTableEntry tableValue;
3630                        if (_subscriptionClassesTable.lookup (subscriptionClassesKey,
3631                            tableValue))
3632                        {
3633                            for (Uint8 m = 0; m < tableValue.subscriptions.size (); m++)
3634                                formerList.append (tableValue.subscriptions [m]);
3635                        }
3636                    }
3637                
3638                    //
3639 kumpf 1.73         //  Find subscriptions that appear in both lists, and move them to a third 
3640                    //  list
3641 kumpf 1.1          //
3642 kumpf 1.73         Sint8 found;
3643                    for (Uint8 p = 0; p < newList.size (); p++)
3644                    {
3645                        found = -1;
3646                        for (Uint8 q = 0; q < formerList.size (); q++)
3647                        {
3648                            if (newList [p].identical (formerList [q]))
3649                            {
3650                                found = q;
3651                                bothList.append (newList [p]);
3652                                break;
3653                            }
3654                        }
3655                        if (found >= 0)
3656                        {
3657                            newList.remove (p);
3658                            p--;
3659                            formerList.remove (found);
3660                        }
3661                    }
3662 kumpf 1.1      
3663                    //
3664 kumpf 1.73         //  For indicationClassName-sourceNamespace pair that is now supported, but 
3665                    //  previously was not, add to list of newly supported subscriptions if 
3666                    //  required properties are now supported
3667 kumpf 1.1          //
3668 kumpf 1.73         for (Uint8 n = 0; n < newList.size (); n++)
3669 kumpf 1.1          {
3670 kumpf 1.73             String filterQuery;
3671                        WQLSelectStatement selectStatement;
3672                        CIMName indicationClassName;
3673                        CIMNamespaceName sourceNameSpace;
3674                        CIMPropertyList requiredProperties;
3675 kumpf 1.11     
3676                        //
3677 kumpf 1.73             //  Get filter properties
3678                        //
3679                        _getFilterProperties (newList [n],
3680                            newList [n].getPath ().getNameSpace (), filterQuery, 
3681                            sourceNameSpace);
3682                        selectStatement = _getSelectStatement (filterQuery);
3683                    
3684                        //
3685                        //  Get indication class name from filter query (FROM clause)
3686                        //
3687                        indicationClassName = _getIndicationClassName (selectStatement,
3688                            sourceNameSpace);
3689                    
3690                        //
3691                        //  Get property list from filter query (FROM and WHERE 
3692                        //  clauses)
3693 kumpf 1.11             //
3694 kumpf 1.73             requiredProperties = _getPropertyList (selectStatement,
3695                            sourceNameSpace, indicationClassName);
3696 kumpf 1.19     
3697 kumpf 1.1              //
3698 kumpf 1.73             //  Check if required properties are now supported
3699 kumpf 1.1              //
3700 kumpf 1.73             if (_inPropertyList (requiredProperties, newProperties))
3701 kumpf 1.1              {
3702 kumpf 1.73                 newSubscriptions.append (newList [n]);
3703                        }
3704                    }
3705 kumpf 1.13     
3706 kumpf 1.73         //
3707                    //  For indicationClassName-sourceNamespace pair that was previously 
3708                    //  supported, but now is not, add to list of formerly supported 
3709                    //  subscriptions
3710                    //
3711                    for (Uint8 f = 0; f < formerList.size (); f++)
3712                    {
3713                        formerSubscriptions.append (formerList [f]);
3714                    }
3715 kumpf 1.1      
3716 kumpf 1.73         //
3717                    //  For indicationClassName-sourceNamespace pair that is now supported, 
3718                    //  and was also previously supported, add to appropriate list, based on
3719                    //  required properties 
3720                    //
3721                    for (Uint8 b = 0; b < bothList.size (); b++)
3722                    {
3723                        String filterQuery;
3724                        WQLSelectStatement selectStatement;
3725                        CIMName indicationClassName;
3726                        CIMNamespaceName sourceNameSpace;
3727                        CIMPropertyList requiredProperties;
3728                        Boolean newMatch = false;
3729                        Boolean formerMatch = false;
3730 kumpf 1.1      
3731 kumpf 1.73             //
3732                        //  Get filter properties
3733                        //
3734                        _getFilterProperties (bothList [b],
3735                            bothList [b].getPath ().getNameSpace (), filterQuery, 
3736                            sourceNameSpace);
3737                        selectStatement = _getSelectStatement (filterQuery);
3738                    
3739                        //
3740                        //  Get indication class name from filter query (FROM clause)
3741                        //
3742                        indicationClassName = _getIndicationClassName (selectStatement,
3743                            sourceNameSpace);
3744                    
3745                        //
3746                        //  Get property list from filter query (FROM and WHERE 
3747                        //  clauses)
3748                        //
3749                        requiredProperties = _getPropertyList (selectStatement,
3750                            sourceNameSpace, indicationClassName);
3751 kumpf 1.1      
3752 kumpf 1.73             //
3753                        //  Check required properties 
3754                        //
3755                        newMatch = _inPropertyList (requiredProperties, 
3756                            newProperties);
3757                        formerMatch = _inPropertyList (requiredProperties, 
3758                            oldProperties);
3759 kumpf 1.15     
3760 kumpf 1.73             //
3761                        //  Add current subscription to appropriate list
3762                        //
3763                        if (newMatch && !formerMatch)
3764                        {
3765                            newSubscriptions.append (bothList [b]);
3766                        }
3767                        else if (!newMatch && formerMatch)
3768                        {
3769                            formerSubscriptions.append (bothList [b]);
3770                        }
3771                    }
3772 kumpf 1.11     
3773 kumpf 1.48         PEG_METHOD_EXIT ();
3774 kumpf 1.11     }
3775                
3776 kumpf 1.63     Array <CIMNamespaceName> IndicationService::_getNameSpaceNames (void) const
3777 kumpf 1.22     {
3778 kumpf 1.63         Array <CIMNamespaceName> nameSpaceNames;
3779 kumpf 1.22     
3780 kumpf 1.48         PEG_METHOD_ENTER (TRC_INDICATION_SERVICE,
3781 kumpf 1.73                           "IndicationService::_getNameSpaceNames");
3782 kumpf 1.22     
3783                    _repository->read_lock ();
3784                
3785                    try
3786                    {
3787                        nameSpaceNames = _repository->enumerateNameSpaces ();
3788                    }
3789                    catch (Exception e)
3790                    {
3791                        _repository->read_unlock ();
3792 kumpf 1.48             PEG_METHOD_EXIT ();
3793 kumpf 1.22             throw e;
3794                    }
3795                
3796                    _repository->read_unlock ();
3797                
3798 kumpf 1.48         PEG_METHOD_EXIT ();
3799 kumpf 1.22         return nameSpaceNames;
3800                }
3801                
3802 kumpf 1.46     Array <CIMInstance> IndicationService::_getSubscriptions (
3803 kumpf 1.63         const CIMNamespaceName & nameSpaceName) const
3804 kumpf 1.22     {
3805 kumpf 1.46         Array <CIMInstance> subscriptions;
3806 kumpf 1.22     
3807 kumpf 1.48         PEG_METHOD_ENTER (TRC_INDICATION_SERVICE,
3808                                      "IndicationService::_getSubscriptions");
3809 kumpf 1.22     
3810                    //
3811                    //  Get existing subscriptions in current namespace
3812                    //
3813                    _repository->read_lock ();
3814                
3815                    try
3816                    {
3817                        subscriptions = _repository->enumerateInstances
3818                            (nameSpaceName, PEGASUS_CLASSNAME_INDSUBSCRIPTION);
3819                    }
3820                    catch (CIMException e)
3821                    {
3822                        //
3823                        //  Some namespaces may not include the subscription class
3824                        //  In that case, just return no subscriptions
3825                        //  Any other exception is an error
3826                        //
3827                        if (e.getCode () != CIM_ERR_INVALID_CLASS)
3828                        {
3829                            _repository->read_unlock ();
3830 kumpf 1.48                 PEG_METHOD_EXIT ();
3831 kumpf 1.22                 throw e;
3832                        }
3833                    }
3834                
3835                    _repository->read_unlock ();
3836                
3837 kumpf 1.48         PEG_METHOD_EXIT ();
3838 kumpf 1.22         return subscriptions;
3839                }
3840                
3841 kumpf 1.15     Boolean IndicationService::_inPropertyList (
3842                    const CIMPropertyList & requiredProperties,
3843                    const CIMPropertyList & supportedProperties)
3844                {
3845 kumpf 1.48         PEG_METHOD_ENTER (TRC_INDICATION_SERVICE,
3846                                      "IndicationService::_inPropertyList");
3847 kumpf 1.22     
3848 kumpf 1.15         //
3849                    //  If property list is null (all properties)
3850                    //  all the required properties are supported
3851                    //
3852                    if (supportedProperties.isNull ())
3853                    {
3854                        return true;
3855                    }
3856                    else
3857                    {
3858                        //
3859                        //  If the subscription requires all properties,
3860 kumpf 1.27             //  but property list does not include all 
3861 kumpf 1.15             //  properties, the required properties cannot be supported
3862                        //
3863                        if (requiredProperties.isNull ())
3864                        {
3865                            return false;
3866                        }
3867                        else
3868                        {
3869                            //
3870                            //  Compare required property list
3871                            //  with property list
3872                            //
3873 kumpf 1.51                 for (Uint8 i = 0; i < requiredProperties.size (); i++)
3874 kumpf 1.15                 {
3875 kumpf 1.55                     if (!ContainsCIMName (supportedProperties.getPropertyNameArray (), 
3876 kumpf 1.51                         requiredProperties[i]))
3877 kumpf 1.15                     {
3878                                    return false;
3879                                }
3880                            }
3881                        }
3882                    }
3883                
3884 kumpf 1.48         PEG_METHOD_EXIT ();
3885 kumpf 1.15         return true;
3886                }
3887                
3888 kumpf 1.46     Array <CIMInstance> IndicationService::_getProviderSubscriptions (
3889 kumpf 1.16         const CIMInstance & provider)
3890 kumpf 1.1      {
3891 kumpf 1.46         Array <CIMInstance> providerSubscriptions;
3892 kumpf 1.11     
3893 kumpf 1.48         PEG_METHOD_ENTER (TRC_INDICATION_SERVICE,
3894                                      "IndicationService::_getProviderSubscriptions");
3895 kumpf 1.11     
3896                    //
3897 kumpf 1.16         //  Iterate through the subscription table
3898 kumpf 1.11         //
3899 kumpf 1.73         for (ActiveSubscriptionsTable::Iterator i =
3900                        _activeSubscriptionsTable.start (); i; i++)
3901 kumpf 1.16         {
3902                        //
3903                        //  If provider matches, append subscription to the list
3904                        //
3905 kumpf 1.73             for (Uint8 j = 0; j < i.value ().providers.size (); j++)
3906 kumpf 1.16             {
3907 kumpf 1.73                 ActiveSubscriptionsTableEntry tableValue = i.value ();
3908                            if (tableValue.providers [j].provider.identical (provider))
3909                            {
3910                                //
3911                                //  Add the subscription to the list
3912                                //
3913                                providerSubscriptions.append (tableValue.subscription);
3914                
3915                                //
3916                                //  Remove the provider from the list of providers serving the 
3917                                //  subscription
3918                                //
3919                                tableValue.providers.remove (j);
3920                                _activeSubscriptionsTable.remove (i.key ());
3921                #ifdef PEGASUS_INDICATION_HASHTRACE
3922                                PEG_TRACE_STRING (TRC_INDICATION_SERVICE_INTERNAL, 
3923                                    Tracer::LEVEL3, 
3924                                    "REMOVED _activeSubscriptionsTable entry: " + i.key ());
3925                #endif
3926                
3927                                if (tableValue.providers.size () > 0)
3928 kumpf 1.73                     {
3929                                    //
3930                                    //  Insert updated entry into Active Subscriptions table
3931                                    //
3932                                    _insertActiveSubscriptionsEntry (tableValue.subscription,
3933                                        tableValue.providers);
3934                                }
3935                                else
3936                                {
3937                                    //
3938                                    //  If the terminated provider was the only provider serving
3939                                    //  the subscription, implement the subscription's On Fatal 
3940                                    //  Error Policy
3941                                    //
3942                                    _handleError (tableValue.subscription);
3943                                }
3944                            }
3945 kumpf 1.16             }
3946                    }
3947 kumpf 1.11     
3948 kumpf 1.48         PEG_METHOD_EXIT ();
3949 kumpf 1.19         return providerSubscriptions;
3950 kumpf 1.11     }
3951                
3952 kumpf 1.16     void IndicationService::_getFilterProperties (
3953 kumpf 1.11         const CIMInstance & subscription,
3954 kumpf 1.63         const CIMNamespaceName & nameSpaceName, 
3955 kumpf 1.16         String & query,
3956 kumpf 1.63         CIMNamespaceName & sourceNameSpace,
3957 kumpf 1.27         String & queryLanguage) 
3958 kumpf 1.11     {
3959                    CIMValue filterValue;
3960 kumpf 1.45         CIMObjectPath filterReference;
3961 kumpf 1.11         CIMInstance filterInstance;
3962                
3963 kumpf 1.48         PEG_METHOD_ENTER (TRC_INDICATION_SERVICE,
3964                                      "IndicationService::_getFilterProperties");
3965 kumpf 1.11     
3966                    filterValue = subscription.getProperty (subscription.findProperty
3967                        (_PROPERTY_FILTER)).getValue ();
3968                
3969                    filterValue.get (filterReference);
3970                
3971 kumpf 1.19         _repository->read_lock ();
3972                
3973                    try
3974                    {
3975 kumpf 1.27             filterInstance = _repository->getInstance (nameSpaceName, 
3976 kumpf 1.19                 filterReference);
3977                    }
3978                    catch (Exception e)
3979                    {
3980                        _repository->read_unlock ();
3981 kumpf 1.48             PEG_METHOD_EXIT ();
3982 kumpf 1.19             throw e;
3983                    }
3984                
3985                    _repository->read_unlock ();
3986 kumpf 1.11     
3987 kumpf 1.27         query = filterInstance.getProperty (filterInstance.findProperty 
3988 kumpf 1.11             (_PROPERTY_QUERY)).getValue ().toString ();
3989                
3990 kumpf 1.27         sourceNameSpace = filterInstance.getProperty (filterInstance.findProperty 
3991 kumpf 1.16             (_PROPERTY_SOURCENAMESPACE)).getValue ().toString ();
3992                
3993                    queryLanguage = filterInstance.getProperty
3994                        (filterInstance.findProperty (_PROPERTY_QUERYLANGUAGE)).
3995                        getValue ().toString ();
3996                
3997 kumpf 1.48         PEG_METHOD_EXIT ();
3998 kumpf 1.11     }
3999                
4000 kumpf 1.16     void IndicationService::_getFilterProperties (
4001 kumpf 1.14         const CIMInstance & subscription,
4002 kumpf 1.63         const CIMNamespaceName & nameSpaceName, 
4003 kumpf 1.16         String & query,
4004 kumpf 1.63         CIMNamespaceName & sourceNameSpace) 
4005 kumpf 1.14     {
4006                    CIMValue filterValue;
4007 kumpf 1.45         CIMObjectPath filterReference;
4008 kumpf 1.14         CIMInstance filterInstance;
4009                
4010 kumpf 1.48         PEG_METHOD_ENTER (TRC_INDICATION_SERVICE,
4011                                      "IndicationService::_getFilterProperties");
4012 kumpf 1.14     
4013                    filterValue = subscription.getProperty (subscription.findProperty
4014                        (_PROPERTY_FILTER)).getValue ();
4015                
4016                    filterValue.get (filterReference);
4017                
4018 kumpf 1.19         _repository->read_lock ();
4019                
4020                    try
4021                    {
4022 kumpf 1.27             filterInstance = _repository->getInstance (nameSpaceName, 
4023 kumpf 1.19                 filterReference);
4024                    }
4025                    catch (Exception e)
4026                    {
4027                        _repository->read_unlock ();
4028 kumpf 1.48             PEG_METHOD_EXIT ();
4029 kumpf 1.19             throw e;
4030                    }
4031                
4032                    _repository->read_unlock ();
4033 kumpf 1.14     
4034 kumpf 1.27         query = filterInstance.getProperty (filterInstance.findProperty 
4035 kumpf 1.16             (_PROPERTY_QUERY)).getValue ().toString ();
4036                
4037 kumpf 1.27         sourceNameSpace = filterInstance.getProperty (filterInstance.findProperty 
4038 kumpf 1.14             (_PROPERTY_SOURCENAMESPACE)).getValue ().toString ();
4039                
4040 kumpf 1.48         PEG_METHOD_EXIT ();
4041 kumpf 1.14     }
4042                
4043 kumpf 1.16     void IndicationService::_getFilterProperties (
4044 kumpf 1.11         const CIMInstance & subscription,
4045 kumpf 1.63         const CIMNamespaceName & nameSpaceName, 
4046 kumpf 1.27         String & query) 
4047 kumpf 1.11     {
4048                    CIMValue filterValue;
4049 kumpf 1.45         CIMObjectPath filterReference;
4050 kumpf 1.11         CIMInstance filterInstance;
4051                
4052 kumpf 1.48         PEG_METHOD_ENTER (TRC_INDICATION_SERVICE,
4053                                      "IndicationService::_getFilterProperties");
4054 kumpf 1.1      
4055 kumpf 1.11         filterValue = subscription.getProperty (subscription.findProperty
4056                        (_PROPERTY_FILTER)).getValue ();
4057 kumpf 1.1      
4058 kumpf 1.11         filterValue.get (filterReference);
4059 kumpf 1.1      
4060 kumpf 1.19         _repository->read_lock ();
4061                
4062                    try
4063                    {
4064 kumpf 1.27             filterInstance = _repository->getInstance (nameSpaceName, 
4065 kumpf 1.19                 filterReference);
4066                    }
4067                    catch (Exception e)
4068                    {
4069                        _repository->read_unlock ();
4070 kumpf 1.48             PEG_METHOD_EXIT ();
4071 kumpf 1.19             throw e;
4072                    }
4073                
4074                    _repository->read_unlock ();
4075 kumpf 1.1      
4076 kumpf 1.27         query = filterInstance.getProperty (filterInstance.findProperty 
4077 kumpf 1.16             (_PROPERTY_QUERY)).getValue ().toString ();
4078 kumpf 1.1      
4079 kumpf 1.48         PEG_METHOD_EXIT ();
4080 kumpf 1.11     }
4081 kumpf 1.1      
4082 kumpf 1.11     WQLSelectStatement IndicationService::_getSelectStatement (
4083                    const String & filterQuery) const
4084                {
4085                    WQLSelectStatement selectStatement;
4086 kumpf 1.1      
4087 kumpf 1.48         PEG_METHOD_ENTER (TRC_INDICATION_SERVICE,
4088                                      "IndicationService::_getSelectStatement");
4089 kumpf 1.1      
4090 kumpf 1.11         try
4091                    {
4092                        selectStatement.clear ();
4093 kumpf 1.44     
4094                        _mutex.lock(pegasus_thread_self());
4095                
4096 kumpf 1.11             WQLParser::parse (filterQuery, selectStatement);
4097 kumpf 1.44     
4098                        _mutex.unlock();
4099 kumpf 1.11         }
4100                    catch (ParseError & pe)
4101                    {
4102 kumpf 1.15             String exceptionStr = pe.getMessage ();
4103 mday  1.73.4.2         _mutex.unlock();
4104 kumpf 1.48             PEG_METHOD_EXIT ();
4105 kumpf 1.15             throw PEGASUS_CIM_EXCEPTION (CIM_ERR_INVALID_PARAMETER, exceptionStr);
4106 kumpf 1.11         }
4107                    catch (MissingNullTerminator & mnt)
4108                    {
4109 kumpf 1.15             String exceptionStr = mnt.getMessage ();
4110 mday  1.73.4.2         _mutex.unlock();
4111 kumpf 1.48             PEG_METHOD_EXIT ();
4112 kumpf 1.15             throw PEGASUS_CIM_EXCEPTION (CIM_ERR_INVALID_PARAMETER, exceptionStr);
4113 kumpf 1.11         }
4114 kumpf 1.1      
4115 kumpf 1.48         PEG_METHOD_EXIT ();
4116 kumpf 1.11         return selectStatement;
4117 kumpf 1.1      }
4118                
4119 kumpf 1.63     CIMName IndicationService::_getIndicationClassName (
4120 kumpf 1.11         const WQLSelectStatement & selectStatement,
4121 kumpf 1.63         const CIMNamespaceName & nameSpaceName) const
4122 kumpf 1.1      {
4123 kumpf 1.63         CIMName indicationClassName;
4124                    Array <CIMName> indicationSubclasses;
4125 kumpf 1.1      
4126 kumpf 1.48         PEG_METHOD_ENTER (TRC_INDICATION_SERVICE,
4127                                      "IndicationService::_getIndicationClassName");
4128 kumpf 1.1      
4129 kumpf 1.11         indicationClassName = selectStatement.getClassName ();
4130                
4131 kumpf 1.1          //
4132 kumpf 1.15         //  Validate that class is an Indication class
4133                    //  The Indication Qualifier should exist and have the value True
4134 kumpf 1.1          //
4135 kumpf 1.15         Boolean validClass = false;
4136 kumpf 1.19         CIMClass theClass;
4137                    _repository->read_lock ();
4138                
4139                    try
4140                    {
4141                        theClass = _repository->getClass (nameSpaceName, indicationClassName);
4142                    }
4143                    catch (Exception e)
4144                    {
4145                        _repository->read_unlock ();
4146 kumpf 1.48             PEG_METHOD_EXIT ();
4147 kumpf 1.19             throw e;
4148                    }
4149                
4150                    _repository->read_unlock ();
4151                
4152 kumpf 1.52         if (theClass.findQualifier (_QUALIFIER_INDICATION) != PEG_NOT_FOUND)
4153 kumpf 1.15         {
4154 kumpf 1.27             CIMQualifier theQual = theClass.getQualifier (theClass.findQualifier 
4155 kumpf 1.15                 (_QUALIFIER_INDICATION));
4156                        CIMValue theVal = theQual.getValue ();
4157                        if (!theVal.isNull ())
4158                        {
4159                            Boolean indicationClass;
4160                            theVal.get (indicationClass);
4161                            validClass = indicationClass;
4162                        }
4163                    }
4164 kumpf 1.1      
4165 kumpf 1.15         if (!validClass)
4166 kumpf 1.1          {
4167 mday  1.73.4.2       // l10n
4168                
4169                        // String exceptionStr = _MSG_INVALID_CLASSNAME;
4170                      String exceptionStr = String("Invalid $0 class name ");
4171                        // exceptionStr.append (indicationClassName.getString());
4172                        exceptionStr.append ("$1");
4173                        // exceptionStr.append (_MSG_IN_FROM);
4174                        exceptionStr.append (" in $2 clause of ");
4175                        // exceptionStr.append (PEGASUS_CLASSNAME_INDFILTER.getString());
4176                        exceptionStr.append ("$3");
4177 kumpf 1.15             exceptionStr.append (" ");
4178 mday  1.73.4.2         // exceptionStr.append (_PROPERTY_QUERY.getString());
4179                        exceptionStr.append ("$4");
4180 kumpf 1.11             exceptionStr.append (_MSG_PROPERTY);
4181 mday  1.73.4.2 
4182 kumpf 1.48             PEG_METHOD_EXIT ();
4183 mday  1.73.4.2 
4184                	// l10n
4185                
4186                        // throw PEGASUS_CIM_EXCEPTION (CIM_ERR_INVALID_PARAMETER, 
4187                	//  exceptionStr);
4188                
4189                        throw PEGASUS_CIM_EXCEPTION_L (CIM_ERR_INVALID_PARAMETER, 
4190                				       MessageLoaderParms (
4191                				          _MSG_INVALID_CLASSNAME_IN_FROM_PROPERTY_KEY,
4192                				          exceptionStr, 
4193                				          "indication",
4194                				          indicationClassName.getString(), 
4195                				          "FROM",
4196                				          PEGASUS_CLASSNAME_INDFILTER.getString(), 
4197                				          _PROPERTY_QUERY.getString()));
4198 kumpf 1.11         }
4199 kumpf 1.1      
4200 kumpf 1.48         PEG_METHOD_EXIT ();
4201 kumpf 1.19         return indicationClassName;
4202 kumpf 1.1      }
4203                
4204 kumpf 1.63     Array <CIMName> IndicationService::_getIndicationSubclasses (
4205                        const CIMNamespaceName & nameSpace,
4206                        const CIMName & indicationClassName) const
4207 kumpf 1.22     {
4208 kumpf 1.63         Array <CIMName> indicationSubclasses;
4209 kumpf 1.22     
4210                    const char METHOD_NAME [] = "IndicationService::_getIndicationSubclasses";
4211                
4212 kumpf 1.48         PEG_METHOD_ENTER (TRC_INDICATION_SERVICE,
4213                                      "IndicationService::_getIndicationSubclasses");
4214 kumpf 1.22     
4215                    _repository->read_lock ();
4216                
4217                    try
4218                    {
4219                        indicationSubclasses = _repository->enumerateClassNames
4220                            (nameSpace, indicationClassName, true);
4221                    }
4222                    catch (Exception e)
4223                    {
4224                        _repository->read_unlock ();
4225 kumpf 1.48             PEG_METHOD_EXIT ();
4226 kumpf 1.22             throw e;
4227                    }
4228                
4229                    _repository->read_unlock ();
4230                
4231                    indicationSubclasses.append (indicationClassName);
4232                
4233 kumpf 1.48         PEG_METHOD_EXIT ();
4234 kumpf 1.22         return indicationSubclasses;
4235                }
4236                
4237 kumpf 1.27     Array <ProviderClassList> 
4238 kumpf 1.11         IndicationService::_getIndicationProviders (
4239 kumpf 1.63             const CIMNamespaceName & nameSpace,
4240                        const CIMName & indicationClassName,
4241                        const Array <CIMName> & indicationSubclasses,
4242 kumpf 1.11             const CIMPropertyList & requiredPropertyList) const
4243 kumpf 1.1      {
4244 kumpf 1.16         ProviderClassList provider;
4245                    Array <ProviderClassList> indicationProviders;
4246 kumpf 1.12         Array <CIMInstance> providerInstances;
4247                    Array <CIMInstance> providerModuleInstances;
4248                    Boolean duplicate = false;
4249 kumpf 1.1      
4250 kumpf 1.48         PEG_METHOD_ENTER (TRC_INDICATION_SERVICE,
4251                                      "IndicationService::_getIndicationProviders");
4252 kumpf 1.1      
4253 kumpf 1.11         //
4254 kumpf 1.12         //  For each indication subclass, get providers
4255 kumpf 1.1          //
4256 kumpf 1.12         for (Uint8 i = 0; i < indicationSubclasses.size (); i++)
4257 kumpf 1.1          {
4258                        //
4259 kumpf 1.12             //  Get providers that can serve the subscription
4260 kumpf 1.1              //
4261 kumpf 1.12             providerInstances.clear ();
4262                        providerModuleInstances.clear ();
4263                        if (_providerRegManager->getIndicationProviders
4264                                (nameSpace,
4265                                 indicationSubclasses [i],
4266 kumpf 1.14                      requiredPropertyList,
4267 kumpf 1.12                      providerInstances,
4268                                 providerModuleInstances))
4269 kumpf 1.1              {
4270 kumpf 1.27                 PEGASUS_ASSERT (providerInstances.size () == 
4271 kumpf 1.12                                 providerModuleInstances.size ());
4272 kumpf 1.27                 
4273 kumpf 1.1                  //
4274 kumpf 1.27                 //  Merge into list of ProviderClassList structs 
4275 kumpf 1.1                  //
4276 kumpf 1.12                 for (Uint8 j = 0; j < providerInstances.size () && !duplicate; j++)
4277 kumpf 1.1                  {
4278 kumpf 1.12                     provider.classList.clear ();
4279                                duplicate = false;
4280 kumpf 1.1      
4281                                //
4282 kumpf 1.12                     //  See if indication provider is already in list
4283 kumpf 1.1                      //
4284 kumpf 1.27                     for (Uint8 k = 0; 
4285 kumpf 1.12                          k < indicationProviders.size () && !duplicate; k++)
4286 kumpf 1.1                      {
4287 kumpf 1.27                         if ((providerInstances [j].identical 
4288 kumpf 1.12                             (indicationProviders [k].provider)) &&
4289                                        (providerModuleInstances [j].identical
4290                                        (indicationProviders [k].providerModule)))
4291 kumpf 1.1                          {
4292 kumpf 1.12                             //
4293                                        //  Indication provider is already in list
4294                                        //  Add subclass to provider's class list
4295                                        //
4296 kumpf 1.27                             indicationProviders [k].classList.append 
4297 kumpf 1.12                                 (indicationSubclasses [i]);
4298                                        duplicate = true;
4299 kumpf 1.1                          }
4300 kumpf 1.11                     }
4301 kumpf 1.27                 
4302 kumpf 1.12                     if (!duplicate)
4303 kumpf 1.11                     {
4304 kumpf 1.1                          //
4305 kumpf 1.11                         //  Current provider is not yet in list
4306                                    //  Create new list entry
4307 kumpf 1.1                          //
4308 kumpf 1.12                         provider.provider = providerInstances [j];
4309                                    provider.providerModule = providerModuleInstances [j];
4310                                    provider.classList.append (indicationSubclasses [i]);
4311                                    indicationProviders.append (provider);
4312                                }
4313                            }  // for each indication provider instance
4314                        }  // if any providers
4315                    }  // for each indication subclass
4316 kumpf 1.27             
4317 kumpf 1.48         PEG_METHOD_EXIT ();
4318 kumpf 1.19         return indicationProviders;
4319 kumpf 1.1      }
4320                
4321 kumpf 1.27     CIMPropertyList IndicationService::_getPropertyList 
4322 kumpf 1.17         (const WQLSelectStatement & selectStatement,
4323 kumpf 1.63          const CIMNamespaceName & nameSpaceName,
4324                     const CIMName & indicationClassName) const
4325 kumpf 1.1      {
4326 kumpf 1.67         CIMPropertyList propertyList;
4327 kumpf 1.1      
4328 kumpf 1.48         PEG_METHOD_ENTER (TRC_INDICATION_SERVICE,
4329                                      "IndicationService::_getPropertyList");
4330 kumpf 1.1      
4331                    //
4332 kumpf 1.11         //  Get all the properties referenced in the projection list (SELECT clause)
4333 kumpf 1.1          //
4334 kumpf 1.67         propertyList = selectStatement.getSelectPropertyList ();
4335                    if (propertyList.isNull ())
4336 kumpf 1.11         {
4337 kumpf 1.67             //
4338                        //  Return null property list for all properties 
4339                        //
4340                        return propertyList;
4341                    }
4342                    else
4343                    {
4344                        Array <CIMName> propertyArray;
4345                
4346                        //
4347                        //  Get selected property names
4348                        //
4349                        propertyArray = propertyList.getPropertyNameArray ();
4350                
4351                        //
4352                        //  Get all the properties referenced in the condition (WHERE clause)
4353                        //
4354                        if (selectStatement.hasWhereClause ())
4355 kumpf 1.11             {
4356 kumpf 1.67                 CIMPropertyList 
4357                            wherePropertyList = selectStatement.getWherePropertyList ();
4358                    
4359 kumpf 1.11                 //
4360 kumpf 1.67                 //  WHERE property list may not be NULL (may be empty)
4361 kumpf 1.11                 //
4362 kumpf 1.67                 for (Uint32 j = 0; j < wherePropertyList.size(); j++)
4363 kumpf 1.11                 {
4364 kumpf 1.67                     //
4365                                //  Add property name to the list if not already there
4366                                //
4367                                if (!ContainsCIMName (propertyArray, wherePropertyList[j]))
4368 kumpf 1.11                     {
4369 kumpf 1.67                         propertyArray.append (wherePropertyList[j]);
4370 kumpf 1.11                     }
4371 kumpf 1.1                  }
4372                        }
4373 kumpf 1.67     
4374                        return _checkPropertyList (propertyArray, nameSpaceName, 
4375                            indicationClassName);
4376 kumpf 1.11         }
4377 kumpf 1.37     }
4378                
4379                CIMPropertyList IndicationService::_checkPropertyList 
4380 kumpf 1.54         (const Array <CIMName> & propertyList,
4381 kumpf 1.63          const CIMNamespaceName & nameSpaceName,
4382                     const CIMName & indicationClassName) const
4383 kumpf 1.37     {
4384 kumpf 1.48         PEG_METHOD_ENTER (TRC_INDICATION_SERVICE,
4385                                      "IndicationService::_checkPropertyList");
4386 kumpf 1.37     
4387 kumpf 1.14         //
4388 kumpf 1.17         //  Check if list includes all properties in class
4389                    //  If so, must be set to NULL
4390 kumpf 1.14         //
4391 kumpf 1.19         CIMClass indicationClass;
4392                    _repository->read_lock ();
4393                
4394                    try
4395                    {
4396 kumpf 1.27             indicationClass = _repository->getClass (nameSpaceName, 
4397 kumpf 1.19                 indicationClassName);
4398                    }
4399                    catch (Exception e)
4400                    {
4401                        _repository->read_unlock ();
4402 kumpf 1.48             PEG_METHOD_EXIT ();
4403 kumpf 1.19             throw e;
4404                    }
4405                
4406                    _repository->read_unlock ();
4407                
4408 kumpf 1.17         Boolean allProperties = true;
4409 kumpf 1.37         for (Uint32 i = 0; 
4410                         i < indicationClass.getPropertyCount () && allProperties; i++)
4411 kumpf 1.17         {
4412 kumpf 1.55             if (!ContainsCIMName (propertyList, 
4413 kumpf 1.37                 indicationClass.getProperty (i).getName ()))
4414 kumpf 1.17             {
4415                            allProperties = false;
4416                        }
4417                    }
4418 kumpf 1.14     
4419 kumpf 1.17         if (allProperties)
4420                    {
4421                        //
4422                        //  Return NULL CIMPropertyList
4423                        //
4424 kumpf 1.48             PEG_METHOD_EXIT ();
4425 kumpf 1.18             return CIMPropertyList ();
4426 kumpf 1.17         }
4427                    else
4428                    {
4429 kumpf 1.48             PEG_METHOD_EXIT ();
4430 kumpf 1.19             return CIMPropertyList (propertyList);
4431 kumpf 1.17         }
4432 kumpf 1.11     }
4433                
4434 kumpf 1.27     String IndicationService::_getCondition 
4435 kumpf 1.11         (const String & filterQuery) const
4436                {
4437                    String condition = String::EMPTY;
4438                
4439 kumpf 1.48         PEG_METHOD_ENTER (TRC_INDICATION_SERVICE,
4440                                      "IndicationService::_getCondition");
4441 kumpf 1.11     
4442                    //
4443                    //  Get condition substring from filter query
4444                    //
4445                    if (filterQuery.find (_QUERY_WHERE) != PEG_NOT_FOUND)
4446                    {
4447 kumpf 1.27             condition = filterQuery.subString (filterQuery.find 
4448 kumpf 1.11                 (_QUERY_WHERE) + 6);
4449                    }
4450                
4451 kumpf 1.48         PEG_METHOD_EXIT ();
4452 kumpf 1.19         return condition;
4453 kumpf 1.11     }
4454                
4455                
4456 kumpf 1.46     CIMInstance IndicationService::_getHandler (
4457                    const CIMInstance & subscription) const
4458 kumpf 1.11     {
4459                    CIMValue handlerValue;
4460 kumpf 1.45         CIMObjectPath handlerRef;
4461 kumpf 1.11         CIMInstance handlerInstance;
4462                
4463 kumpf 1.48         PEG_METHOD_ENTER (TRC_INDICATION_SERVICE, "IndicationService::_getHandler");
4464 kumpf 1.11     
4465                    //
4466                    //  Get Handler reference from subscription instance
4467                    //
4468 kumpf 1.46         handlerValue = subscription.getProperty 
4469                        (subscription.findProperty
4470 kumpf 1.11             (_PROPERTY_HANDLER)).getValue ();
4471                
4472                    handlerValue.get (handlerRef);
4473                
4474                    //
4475                    //  Get Handler instance from the repository
4476                    //
4477 kumpf 1.19         _repository->read_lock ();
4478                
4479                    try
4480                    {
4481 kumpf 1.27             handlerInstance = _repository->getInstance 
4482 kumpf 1.46                 (subscription.getPath ().getNameSpace (), handlerRef);
4483 kumpf 1.19         }
4484                    catch (Exception e)
4485                    {
4486                        _repository->read_unlock ();
4487 kumpf 1.48             PEG_METHOD_EXIT ();
4488 kumpf 1.19             throw e;
4489                    }
4490                
4491                    _repository->read_unlock ();
4492 kumpf 1.11     
4493 kumpf 1.13         //
4494 kumpf 1.46         //  Set namespace in path in CIMInstance
4495 kumpf 1.13         //
4496 kumpf 1.27         handlerRef.setNameSpace 
4497 kumpf 1.46             (subscription.getPath ().getNameSpace ());
4498                    handlerInstance.setPath (handlerRef);
4499 kumpf 1.11     
4500 kumpf 1.48         PEG_METHOD_EXIT ();
4501 kumpf 1.46         return handlerInstance;
4502 kumpf 1.11     }
4503                
4504                Boolean IndicationService::_isTransient (
4505 kumpf 1.63         const CIMNamespaceName & nameSpace,
4506 kumpf 1.45         const CIMObjectPath & handler) const
4507 kumpf 1.11     {
4508                    CIMValue persistenceValue;
4509                    Uint16 persistenceType;
4510                
4511 kumpf 1.48         PEG_METHOD_ENTER (TRC_INDICATION_SERVICE,
4512                                      "IndicationService::_isTransient");
4513 kumpf 1.11     
4514                    //
4515 kumpf 1.38         //  Get the handler instance from the respository
4516 kumpf 1.11         //
4517 kumpf 1.19         CIMInstance instance;
4518                    _repository->read_lock ();
4519                
4520                    try
4521                    {
4522                        instance = _repository->getInstance (nameSpace, handler);
4523                    }
4524                    catch (Exception e)
4525                    {
4526                        _repository->read_unlock ();
4527 kumpf 1.48             PEG_METHOD_EXIT ();
4528 kumpf 1.19             throw e;
4529                    }
4530                
4531                    _repository->read_unlock ();
4532 kumpf 1.11     
4533                    //
4534                    //  Get Persistence Type
4535                    //
4536                    persistenceValue = instance.getProperty (instance.findProperty
4537                        (_PROPERTY_PERSISTENCETYPE)).getValue ();
4538                    persistenceValue.get (persistenceType);
4539                
4540                    //
4541                    //  If Persistence Type is Other, Other Persistence Type
4542                    //  property must exist
4543                    //
4544                    if (persistenceType == _PERSISTENCE_TRANSIENT)
4545                    {
4546 kumpf 1.48             PEG_METHOD_EXIT ();
4547 kumpf 1.11             return true;
4548                    }
4549                    else
4550                    {
4551 kumpf 1.48             PEG_METHOD_EXIT ();
4552 kumpf 1.11             return false;
4553                    }
4554                }
4555                
4556                void IndicationService::_deleteReferencingSubscriptions (
4557 kumpf 1.63         const CIMNamespaceName & nameSpace,
4558                    const CIMName & referenceProperty,
4559 kumpf 1.45         const CIMObjectPath & handler)
4560 kumpf 1.11     {
4561 kumpf 1.46         Array <CIMInstance> subscriptions;
4562 kumpf 1.11     
4563 kumpf 1.48         PEG_METHOD_ENTER (TRC_INDICATION_SERVICE,
4564                                      "IndicationService::_deleteReferencingSubscriptions");
4565 kumpf 1.11     
4566                    //
4567                    //  Get existing subscriptions in the namespace
4568                    //
4569 kumpf 1.22         subscriptions = _getSubscriptions (nameSpace);
4570 kumpf 1.11     
4571                    //
4572 kumpf 1.27         //  Check each subscription for a reference to the specified instance 
4573 kumpf 1.11         //
4574                    for (Uint8 i = 0; i < subscriptions.size (); i++)
4575                    {
4576 kumpf 1.1              //
4577 kumpf 1.11             //  Get the reference property value from the subscription instance
4578 kumpf 1.1              //
4579 kumpf 1.46             CIMValue propValue = subscriptions [i].getProperty
4580                            (subscriptions [i].findProperty
4581 kumpf 1.11                 (referenceProperty)).getValue ();
4582 kumpf 1.45             CIMObjectPath ref;
4583 kumpf 1.11             propValue.get (ref);
4584 kumpf 1.1      
4585                        //
4586 kumpf 1.11             //  If the current subscription references the specified instance,
4587                        //  delete it
4588 kumpf 1.1              //
4589 kumpf 1.11             if (handler == ref)
4590 kumpf 1.1              {
4591 kumpf 1.16                 Array <ProviderClassList> indicationProviders;
4592 kumpf 1.73                 Array <CIMName> indicationSubclasses;
4593                            CIMNamespaceName sourceNamespaceName;
4594 kumpf 1.38                 indicationProviders = _getDeleteParams (nameSpace, 
4595 kumpf 1.73                     subscriptions [i], indicationSubclasses, sourceNamespaceName);
4596 kumpf 1.12     
4597                            //
4598 kumpf 1.38                 //  Send Delete requests
4599 kumpf 1.12                 //
4600 kumpf 1.46                 CIMInstance instance = subscriptions [i];
4601 kumpf 1.15                 String creator = instance.getProperty (instance.findProperty
4602 kumpf 1.38                     (PEGASUS_PROPERTYNAME_INDSUB_CREATOR)).getValue ().toString ();
4603 mday  1.73.4.1 
4604 mday  1.73.4.2 // l10n start                
4605                            String acceptLangs = String::EMPTY;
4606                            Uint32 propIndex = instance.findProperty(PEGASUS_PROPERTYNAME_INDSUB_ACCEPTLANGS);  			
4607                            if (propIndex != PEG_NOT_FOUND)
4608                            {
4609                                 instance.getProperty(propIndex).getValue().get(acceptLangs);
4610                            }
4611                            String contentLangs = String::EMPTY;
4612                            propIndex = instance.findProperty(PEGASUS_PROPERTYNAME_INDSUB_CONTENTLANGS);  			
4613                            if (propIndex != PEG_NOT_FOUND)
4614                            {
4615                                 instance.getProperty(propIndex).getValue().get(contentLangs);
4616                            }
4617                // l10n end
4618 mday  1.73.4.1 
4619 kumpf 1.45                 CIMObjectPath instanceName = 
4620 kumpf 1.46                     subscriptions [i].getPath ();
4621 kumpf 1.16                 instanceName.setNameSpace (nameSpace);
4622 kumpf 1.46                 subscriptions [i].setPath (instanceName);
4623 mday  1.73.4.1 // l10n  
4624 kumpf 1.38                 _sendDeleteRequests (indicationProviders, nameSpace, 
4625 mday  1.73.4.1                 subscriptions [i], 
4626                                AcceptLanguages(acceptLangs),
4627                                ContentLanguages(contentLangs),
4628                                creator);
4629 kumpf 1.12     
4630 kumpf 1.1                  //
4631 kumpf 1.11                 //  Delete referencing subscription instance from repository
4632 kumpf 1.1                  //
4633 kumpf 1.11                 _repository->write_lock ();
4634                
4635 kumpf 1.1                  try
4636                            {
4637 kumpf 1.50                     //
4638                                //  Namespace and host must not be set in path passed to 
4639                                //  repository
4640                                //
4641 kumpf 1.63                     CIMObjectPath path ("", CIMNamespaceName (),
4642 kumpf 1.50                         subscriptions [i].getPath ().getClassName(),
4643                                    subscriptions [i].getPath ().getKeyBindings());
4644                                _repository->deleteInstance (nameSpace, path);
4645 kumpf 1.1                  }
4646 kumpf 1.11                 catch (Exception & exception)
4647 kumpf 1.1                  {
4648                                //
4649 kumpf 1.38                     //  ATTN-CAKG-P3-20020425: Log a message
4650 kumpf 1.1                      //
4651                            }
4652                
4653 kumpf 1.11                 _repository->write_unlock ();
4654                        }
4655                    }
4656                
4657 kumpf 1.48         PEG_METHOD_EXIT ();
4658 kumpf 1.11     }
4659                
4660                Boolean IndicationService::_isExpired (
4661                    const CIMInstance & instance) const
4662                {
4663 kumpf 1.48         PEG_METHOD_ENTER (TRC_INDICATION_SERVICE, "IndicationService::_isExpired");
4664 kumpf 1.11     
4665 kumpf 1.35         Boolean isExpired = true;
4666                    Uint64 timeRemaining = 0;
4667 kumpf 1.1      
4668 kumpf 1.11         //
4669 kumpf 1.35         //  Get time remaining, if subscription has a duration
4670 kumpf 1.11         //
4671 kumpf 1.35         if (_getTimeRemaining (instance, timeRemaining))
4672 kumpf 1.13         {
4673 kumpf 1.35             if (timeRemaining > 0)
4674                        {
4675                            isExpired = false;
4676                        }
4677 kumpf 1.13         }
4678                    else
4679                    {
4680 kumpf 1.35             //
4681                        //  If there is no duration, the subscription has no expiration date
4682                        //
4683                        isExpired = false;
4684 kumpf 1.13         }
4685 kumpf 1.1      
4686 kumpf 1.48         PEG_METHOD_EXIT ();
4687 kumpf 1.35         return isExpired;
4688 kumpf 1.1      }
4689                
4690 kumpf 1.11     void IndicationService::_deleteExpiredSubscription (
4691 kumpf 1.45         CIMObjectPath & subscription)
4692 kumpf 1.1      {
4693 kumpf 1.48         PEG_METHOD_ENTER (TRC_INDICATION_SERVICE,
4694                                      "IndicationService::_deleteExpiredSubscription");
4695 kumpf 1.1      
4696 kumpf 1.63         CIMNamespaceName nameSpace = subscription.getNameSpace ();
4697                    subscription.setNameSpace (CIMNamespaceName ());
4698 kumpf 1.35     
4699 kumpf 1.11         //
4700                    //  Delete the subscription instance
4701                    //
4702                    _repository->write_lock ();
4703 kumpf 1.1      
4704 kumpf 1.11         try
4705                    {
4706                        _repository->deleteInstance (nameSpace, subscription);
4707                    }
4708                    catch (Exception & exception)
4709                    {
4710                        //
4711 kumpf 1.38             //  ATTN-CAKG-P3-20020425: Log a message
4712 kumpf 1.11             //
4713                    }
4714 kumpf 1.1      
4715 kumpf 1.11         _repository->write_unlock ();
4716 kumpf 1.1      
4717 kumpf 1.48         PEG_METHOD_EXIT ();
4718 kumpf 1.1      }
4719                
4720 kumpf 1.35     Boolean IndicationService::_getTimeRemaining (
4721                    const CIMInstance & instance,
4722                    Uint64 & timeRemaining) const
4723 kumpf 1.1      {
4724 kumpf 1.48         PEG_METHOD_ENTER (TRC_INDICATION_SERVICE,
4725                                      "IndicationService::_getTimeRemaining");
4726 kumpf 1.1      
4727 kumpf 1.35         Boolean hasDuration = true;
4728                    timeRemaining = 0;
4729                
4730 kumpf 1.11         //
4731                    //  Calculate time remaining from subscription
4732                    //  start time, subscription duration, and current date time
4733                    //
4734 kumpf 1.1      
4735 kumpf 1.11         //
4736 kumpf 1.27         //  NOTE: It is assumed that the instance passed to this method is a 
4737 kumpf 1.35         //  subscription instance, and that the Start Time property exists
4738                    //  and has a value
4739 kumpf 1.11         //
4740 kumpf 1.1      
4741 kumpf 1.11         //
4742                    //  Get Subscription Start Time
4743                    //
4744                    CIMValue startTimeValue;
4745                    CIMDateTime startTime;
4746 kumpf 1.27         startTimeValue = instance.getProperty 
4747 kumpf 1.11             (instance.findProperty (_PROPERTY_STARTTIME)).getValue ();
4748                    startTimeValue.get (startTime);
4749 kumpf 1.1      
4750 kumpf 1.11         //
4751                    //  Get Subscription Duration
4752                    //
4753 kumpf 1.52         if (instance.findProperty (_PROPERTY_DURATION) != PEG_NOT_FOUND)
4754 kumpf 1.35         {
4755                        CIMValue durationValue;
4756                        durationValue = instance.getProperty 
4757                            (instance.findProperty (_PROPERTY_DURATION)).getValue ();
4758                        if (durationValue.isNull ())
4759                        {
4760                            hasDuration = false;
4761                        }
4762                        else
4763                        {
4764                            Uint64 duration;
4765                            durationValue.get (duration);
4766 kumpf 1.1      
4767 kumpf 1.35                 //
4768                            //  Get current date time, and calculate Subscription Time Remaining
4769                            //
4770                            CIMDateTime currentDateTime = CIMDateTime::getCurrentDateTime ();
4771 kumpf 1.65                 
4772                            Sint64 difference;
4773                            try 
4774                            {
4775                                difference = CIMDateTime::getDifference
4776                                    (startTime, currentDateTime);
4777                            }
4778                            // Check if the date time is out of range. 
4779                            catch (DateTimeOutOfRangeException& e)
4780                            {
4781                                // ATTN: P4 SF 10/15/2002 May need to handle this error more
4782                                // appropriately.
4783                                PEG_METHOD_EXIT();
4784                                throw e;
4785                            }
4786                
4787 kumpf 1.35                 PEGASUS_ASSERT (difference >= 0);
4788                            if (((Sint64) duration - difference) >= 0)
4789                            {
4790                                timeRemaining = (Sint64) duration - difference;
4791                            }
4792                        }
4793                    }
4794                    else
4795 kumpf 1.1          {
4796 kumpf 1.35             hasDuration = false;
4797 kumpf 1.1          }
4798 kumpf 1.35     
4799 kumpf 1.48         PEG_METHOD_EXIT ();
4800 kumpf 1.35         return hasDuration;
4801                }
4802                
4803                void IndicationService::_setTimeRemaining (
4804                    CIMInstance & instance)
4805                {
4806 kumpf 1.48         PEG_METHOD_ENTER (TRC_INDICATION_SERVICE,
4807                                      "IndicationService::_setTimeRemaining");
4808 kumpf 1.35     
4809                    Uint64 timeRemaining = 0;
4810                    if (_getTimeRemaining (instance, timeRemaining))
4811 kumpf 1.1          {
4812 kumpf 1.35             //
4813                        //  Add or set the value of the property with the calculated value
4814                        //
4815 kumpf 1.52             if (instance.findProperty (_PROPERTY_TIMEREMAINING) == PEG_NOT_FOUND)
4816 kumpf 1.35             {
4817                            instance.addProperty (CIMProperty 
4818                                (_PROPERTY_TIMEREMAINING, timeRemaining));
4819                        }
4820                        else 
4821                        {
4822                            CIMProperty remaining = instance.getProperty 
4823                                (instance.findProperty (_PROPERTY_TIMEREMAINING));
4824                            remaining.setValue (CIMValue (timeRemaining));
4825                        }
4826 kumpf 1.1          }
4827                
4828 kumpf 1.48         PEG_METHOD_EXIT ();
4829 kumpf 1.1      }
4830                
4831 kumpf 1.38     void IndicationService::_getCreateParams (
4832 kumpf 1.63         const CIMNamespaceName & nameSpaceName,
4833 kumpf 1.11         const CIMInstance & subscriptionInstance,
4834 kumpf 1.73         Array <CIMName> & indicationSubclasses,
4835 kumpf 1.16         Array <ProviderClassList> & indicationProviders,
4836 kumpf 1.11         CIMPropertyList & propertyList,
4837 kumpf 1.63         CIMNamespaceName & sourceNameSpace,
4838 kumpf 1.11         String & condition,
4839                    String & queryLanguage)
4840 kumpf 1.1      {
4841 kumpf 1.11         String filterQuery;
4842                    WQLSelectStatement selectStatement;
4843 kumpf 1.63         CIMName indicationClassName;
4844 kumpf 1.11         condition = String::EMPTY;
4845                    queryLanguage = String::EMPTY;
4846 kumpf 1.1      
4847 kumpf 1.48         PEG_METHOD_ENTER (TRC_INDICATION_SERVICE,
4848                                      "IndicationService::_getCreateParams");
4849 kumpf 1.1      
4850 kumpf 1.11         //
4851 kumpf 1.16         //  Get filter properties
4852 kumpf 1.11         //
4853 kumpf 1.27         _getFilterProperties (subscriptionInstance, nameSpaceName, 
4854 kumpf 1.16             filterQuery, sourceNameSpace, queryLanguage);
4855 kumpf 1.11         selectStatement = _getSelectStatement (filterQuery);
4856 kumpf 1.27         
4857 kumpf 1.11         //
4858                    //  Get indication class name from filter query (FROM clause)
4859                    //
4860                    indicationClassName = _getIndicationClassName (selectStatement,
4861 kumpf 1.27             sourceNameSpace);
4862                    
4863 kumpf 1.1          //
4864                    //  Get list of subclass names for indication class
4865                    //
4866 kumpf 1.27         indicationSubclasses = _getIndicationSubclasses (sourceNameSpace,
4867 kumpf 1.22             indicationClassName);
4868 kumpf 1.19     
4869 kumpf 1.11         //
4870 kumpf 1.27         //  Get property list from filter query (FROM and WHERE 
4871 kumpf 1.11         //  clauses)
4872                    //
4873 kumpf 1.70         propertyList = _getPropertyList (selectStatement,
4874                        sourceNameSpace, indicationClassName);
4875 kumpf 1.1      
4876                    //
4877 kumpf 1.11         //  Get indication provider class lists
4878 kumpf 1.1          //
4879 kumpf 1.27         indicationProviders = _getIndicationProviders 
4880                        (sourceNameSpace, indicationClassName, indicationSubclasses, 
4881 kumpf 1.11              propertyList);
4882                
4883                    if (indicationProviders.size () > 0)
4884 kumpf 1.1          {
4885 kumpf 1.11             //
4886                        //  Get condition from filter query (WHERE clause)
4887                        //
4888                        if (selectStatement.hasWhereClause ())
4889                        {
4890                            condition = _getCondition (filterQuery);
4891                        }
4892 kumpf 1.16         }
4893                
4894 kumpf 1.48         PEG_METHOD_EXIT ();
4895 kumpf 1.16     }
4896 kumpf 1.27         
4897 kumpf 1.38     void IndicationService::_getCreateParams (
4898 kumpf 1.63         const CIMNamespaceName & nameSpaceName,
4899 kumpf 1.16         const CIMInstance & subscriptionInstance,
4900 kumpf 1.73         Array <CIMName> & indicationSubclasses,
4901 kumpf 1.16         CIMPropertyList & propertyList,
4902 kumpf 1.63         CIMNamespaceName & sourceNameSpace,
4903 kumpf 1.16         String & condition,
4904                    String & queryLanguage)
4905                {
4906                    String filterQuery;
4907                    WQLSelectStatement selectStatement;
4908                    condition = String::EMPTY;
4909                    queryLanguage = String::EMPTY;
4910                
4911 kumpf 1.48         PEG_METHOD_ENTER (TRC_INDICATION_SERVICE,
4912                                      "IndicationService::_getCreateParams");
4913 kumpf 1.16     
4914                    //
4915                    //  Get filter properties
4916                    //
4917 kumpf 1.27         _getFilterProperties (subscriptionInstance, nameSpaceName, 
4918 kumpf 1.16             filterQuery, sourceNameSpace, queryLanguage);
4919                    selectStatement = _getSelectStatement (filterQuery);
4920 kumpf 1.27         
4921 kumpf 1.16         //
4922 kumpf 1.27         //  Get property list from filter query (FROM and WHERE 
4923 kumpf 1.16         //  clauses)
4924                    //
4925 kumpf 1.70         CIMName indicationClassName = _getIndicationClassName (selectStatement,
4926                        sourceNameSpace);
4927                    propertyList = _getPropertyList (selectStatement,
4928                        sourceNameSpace, indicationClassName);
4929 kumpf 1.11     
4930 kumpf 1.16         //
4931                    //  Get condition from filter query (WHERE clause)
4932                    //
4933                    if (selectStatement.hasWhereClause ())
4934                    {
4935                        condition = _getCondition (filterQuery);
4936 kumpf 1.1          }
4937                
4938 kumpf 1.73         //
4939                    //  Get indication class name from filter query (FROM clause)
4940                    //
4941                    indicationClassName = _getIndicationClassName (selectStatement,
4942                        sourceNameSpace);
4943                    
4944                    //
4945                    //  Get list of subclass names for indication class
4946                    //
4947                    indicationSubclasses = _getIndicationSubclasses (sourceNameSpace,
4948                        indicationClassName);
4949                
4950 kumpf 1.48         PEG_METHOD_EXIT ();
4951 kumpf 1.1      }
4952 kumpf 1.27         
4953 kumpf 1.38     Array <ProviderClassList> IndicationService::_getDeleteParams (
4954 kumpf 1.63         const CIMNamespaceName & nameSpaceName,
4955 kumpf 1.73         const CIMInstance & subscriptionInstance,
4956                    Array <CIMName> & indicationSubclasses,
4957                    CIMNamespaceName & sourceNameSpace)
4958 kumpf 1.1      {
4959 kumpf 1.11         String filterQuery;
4960                    WQLSelectStatement selectStatement;
4961 kumpf 1.63         CIMName indicationClassName;
4962 kumpf 1.11         CIMPropertyList propertyList;
4963 kumpf 1.16         Array <ProviderClassList> indicationProviders;
4964 kumpf 1.6      
4965 kumpf 1.48         PEG_METHOD_ENTER (TRC_INDICATION_SERVICE,
4966                                      "IndicationService::_getDeleteParams");
4967 kumpf 1.1      
4968                    //
4969 kumpf 1.16         //  Get filter properties
4970 kumpf 1.11         //
4971 kumpf 1.27         _getFilterProperties (subscriptionInstance, nameSpaceName, 
4972 kumpf 1.16             filterQuery, sourceNameSpace);
4973 kumpf 1.11         selectStatement = _getSelectStatement (filterQuery);
4974 kumpf 1.27         
4975 kumpf 1.11         //
4976                    //  Get indication class name from filter query (FROM clause)
4977                    //
4978                    indicationClassName = _getIndicationClassName (selectStatement,
4979 kumpf 1.27             sourceNameSpace);
4980                    
4981 kumpf 1.11         //
4982                    //  Get list of subclass names for indication class
4983                    //
4984 kumpf 1.27         indicationSubclasses = _getIndicationSubclasses (sourceNameSpace,
4985 kumpf 1.22             indicationClassName);
4986 kumpf 1.19     
4987 kumpf 1.11         //
4988 kumpf 1.27         //  Get property list from filter query (FROM and WHERE 
4989 kumpf 1.11         //  clauses)
4990 kumpf 1.1          //
4991 kumpf 1.70         propertyList = _getPropertyList (selectStatement,
4992                        sourceNameSpace, indicationClassName);
4993 kumpf 1.1      
4994                    //
4995 kumpf 1.73         //  Get indication provider class lists from Active Subscriptions table
4996 kumpf 1.11         //
4997 kumpf 1.73         String activeSubscriptionsKey = _generateActiveSubscriptionsKey
4998                        (subscriptionInstance.getPath ());
4999                    ActiveSubscriptionsTableEntry tableValue;
5000                    if (_activeSubscriptionsTable.lookup (activeSubscriptionsKey, 
5001                                    tableValue))
5002                    {
5003                        indicationProviders = tableValue.providers;
5004                    }
5005                    else
5006                    {
5007                        //
5008                        //  ATTN-CAKG-P3-20030403: Log a message
5009                        //
5010                    }
5011 kumpf 1.11     
5012 kumpf 1.48         PEG_METHOD_EXIT ();
5013 kumpf 1.11         return indicationProviders;
5014                }
5015 kumpf 1.27         
5016 mday  1.20     
5017 kumpf 1.38     void IndicationService::_sendCreateRequestsCallBack(AsyncOpNode *op, 
5018 kumpf 1.27     						    MessageQueue *q, 
5019 mday  1.20     						    void *parm)
5020                {
5021 kumpf 1.48         PEG_METHOD_ENTER (TRC_INDICATION_SERVICE,
5022                                      "IndicationService::_sendCreateRequestsCallBack");
5023 kumpf 1.31     
5024 kumpf 1.27         IndicationService *service = 
5025 mday  1.20           static_cast<IndicationService *>(q);
5026 kumpf 1.27         struct enableProviderList *epl = 
5027 mday  1.20            reinterpret_cast<struct enableProviderList *>(parm);
5028 kumpf 1.27         
5029 mday  1.20        AsyncRequest *asyncRequest = static_cast<AsyncRequest *>(op->get_request());
5030                   AsyncReply *asyncReply = static_cast<AsyncReply *>(op->get_response());
5031                   CIMRequestMessage *request = reinterpret_cast<CIMRequestMessage *>
5032                      ((static_cast<AsyncLegacyOperationStart *>(asyncRequest))->get_action());
5033                   CIMCreateSubscriptionResponseMessage * response =
5034 kumpf 1.27           reinterpret_cast 
5035 mday  1.20           <CIMCreateSubscriptionResponseMessage *>
5036                      ((static_cast <AsyncLegacyOperationResult *>
5037                	(asyncReply))->get_result());
5038 kumpf 1.27        
5039 mday  1.20        PEGASUS_ASSERT(response != 0);
5040 kumpf 1.23        if (response->cimException.getCode() == CIM_ERR_SUCCESS)
5041 mday  1.20        {
5042 kumpf 1.27           
5043 mday  1.20        }
5044                   else
5045                   {
5046                      //
5047 kumpf 1.38           //  ATTN-CAKG-P3-20020326: Log a message
5048 mday  1.20           //
5049                   }
5050 kumpf 1.27        
5051 mday  1.20        delete epl;
5052                   delete request;
5053                   delete response;
5054                   delete asyncRequest;
5055                   delete asyncReply;
5056                   op->release();
5057                   service->return_op(op);
5058 kumpf 1.31     
5059 kumpf 1.48         PEG_METHOD_EXIT ();
5060 mday  1.20     }
5061                
5062 mday  1.73.4.1 // l10n  
5063 kumpf 1.38     Boolean IndicationService::_sendCreateRequests
5064 kumpf 1.16         (const Array <ProviderClassList> & indicationProviders,
5065 kumpf 1.63          const CIMNamespaceName & nameSpace,
5066 kumpf 1.11          const CIMPropertyList & propertyList,
5067                     const String & condition,
5068                     const String & queryLanguage,
5069 kumpf 1.46          const CIMInstance & subscription,
5070 mday  1.73.4.1      const AcceptLanguages & acceptLangs,
5071                     const ContentLanguages & contentLangs,	 
5072 kumpf 1.15          const String & userName,
5073                     const String & authType)
5074 kumpf 1.11     {
5075                    CIMValue propValue;
5076                    Uint16 repeatNotificationPolicy;
5077                
5078 kumpf 1.48         PEG_METHOD_ENTER (TRC_INDICATION_SERVICE,
5079                                      "IndicationService::_sendCreateRequests");
5080 kumpf 1.1      
5081                    //
5082 kumpf 1.14         //  Get repeat notification policy value from subscription instance
5083 kumpf 1.1          //
5084 kumpf 1.46         propValue = subscription.getProperty 
5085                        (subscription.findProperty 
5086 kumpf 1.11             (_PROPERTY_REPEATNOTIFICATIONPOLICY)).getValue ();
5087                    propValue.get (repeatNotificationPolicy);
5088                
5089                    //
5090 kumpf 1.38         //  Send Create request to each provider
5091 kumpf 1.11         //
5092 mday  1.20     
5093 kumpf 1.11         for (Uint8 i = 0; i < indicationProviders.size (); i++)
5094                    {
5095 kumpf 1.27            
5096                       struct enableProviderList *epl = 
5097 kumpf 1.38                new enableProviderList(indicationProviders[i], 
5098 mday  1.20     				 subscription);
5099 kumpf 1.27            
5100 mday  1.73.4.1 // l10n       
5101 kumpf 1.16             CIMCreateSubscriptionRequestMessage * request =
5102                            new CIMCreateSubscriptionRequestMessage
5103 kumpf 1.11                     (XmlWriter::getNextMessageId (),
5104                                nameSpace,
5105 kumpf 1.46                     subscription,
5106 kumpf 1.27     		 epl->pcl->classList, 
5107                		 epl->pcl->provider, 
5108 mday  1.20     		 epl->pcl->providerModule,
5109                		 propertyList,
5110                		 repeatNotificationPolicy,
5111                		 condition,
5112                		 queryLanguage,
5113                		 QueueIdStack (_providerManager, getQueueId ()),
5114                		 authType,
5115 mday  1.73.4.1 		 userName,
5116                		 contentLangs,
5117                		 acceptLangs);
5118 mday  1.20     	
5119 kumpf 1.27             AsyncOpNode* op = this->get_op(); 
5120 kumpf 1.1      
5121 kumpf 1.11             AsyncLegacyOperationStart * async_req =
5122                            new AsyncLegacyOperationStart
5123                                (get_next_xid (),
5124                                op,
5125                                _providerManager,
5126                                request,
5127                                _queueId);
5128 kumpf 1.1      
5129 kumpf 1.27     	SendAsync(op, 
5130                		  _providerManager, 
5131 kumpf 1.38     		  IndicationService::_sendCreateRequestsCallBack,
5132 kumpf 1.27     		  this, 
5133 mday  1.20     		  (void *)epl);
5134                	
5135                
5136                        // AsyncReply * async_reply = SendWait (async_req);
5137 kumpf 1.1          }
5138                
5139 kumpf 1.15         //
5140 kumpf 1.39         //  FUTURE: Should only return true if at least one provider accepted
5141                    //  the subscription
5142 kumpf 1.15         //
5143                    //Boolean result = (accepted > 0);
5144                    Boolean result = true;
5145                    return result;
5146                
5147 kumpf 1.48         PEG_METHOD_EXIT ();
5148 kumpf 1.1      }
5149                
5150 kumpf 1.37     void IndicationService::_sendModifyRequestsCallBack (
5151                    AsyncOpNode * op,
5152                    MessageQueue * q,
5153                    void * parm)
5154 mday  1.20     {
5155 kumpf 1.48         PEG_METHOD_ENTER (TRC_INDICATION_SERVICE,
5156                                      "IndicationService::_sendModifyRequestsCallBack");
5157 kumpf 1.37     
5158                    IndicationService *service = static_cast <IndicationService *> (q);
5159                    struct enableProviderList * epl = reinterpret_cast
5160                        <struct enableProviderList *> (parm);
5161 kumpf 1.27        
5162 kumpf 1.37         AsyncRequest * asyncRequest = static_cast <AsyncRequest *>
5163                        (op->get_request ());
5164                    AsyncReply * asyncReply = static_cast <AsyncReply *> (op->get_response ());
5165                    CIMRequestMessage * request = reinterpret_cast <CIMRequestMessage *>
5166                        ((static_cast <AsyncLegacyOperationStart *> 
5167                        (asyncRequest))->get_action ());
5168 mday  1.20     
5169 kumpf 1.37         //
5170                    //  ATTN: Check for return value indicating invalid queue ID
5171                    //  If received, need to find Provider Manager Service queue ID
5172                    //  again
5173                    //
5174 kumpf 1.27        
5175 kumpf 1.37         CIMModifySubscriptionResponseMessage * response = reinterpret_cast
5176                        <CIMModifySubscriptionResponseMessage *>
5177                        ((static_cast <AsyncLegacyOperationResult *>
5178                	(asyncReply))->get_result ());
5179 kumpf 1.27        
5180 kumpf 1.37         PEGASUS_ASSERT(response != 0);
5181                    if (response->cimException.getCode () == CIM_ERR_SUCCESS)
5182                    {
5183                    }
5184                    else
5185                    {
5186                        //
5187 kumpf 1.38             //  ATTN-CAKG-P3-20020326: Log a message
5188                        //  Should the table entry be updated anyway?
5189 kumpf 1.37             //
5190                    }
5191                
5192                    delete epl;
5193                    delete request;
5194                    delete response;
5195                    delete asyncRequest;
5196                    delete asyncReply;
5197                    op->release ();
5198                    service->return_op (op);
5199 mday  1.20     }
5200                
5201 mday  1.73.4.1 // l10n
5202 kumpf 1.11     void IndicationService::_sendModifyRequests
5203 kumpf 1.16         (const Array <ProviderClassList> & indicationProviders,
5204 kumpf 1.63          const CIMNamespaceName & nameSpace,
5205 kumpf 1.11          const CIMPropertyList & propertyList,
5206                     const String & condition,
5207                     const String & queryLanguage,
5208 kumpf 1.46          const CIMInstance & subscription,
5209 mday  1.73.4.1      const AcceptLanguages & acceptLangs,
5210                     const ContentLanguages & contentLangs,	 
5211 kumpf 1.15          const String & userName,
5212                     const String & authType)
5213 kumpf 1.1      {
5214 kumpf 1.11         CIMValue propValue;
5215                    Uint16 repeatNotificationPolicy;
5216 kumpf 1.1      
5217 kumpf 1.48         PEG_METHOD_ENTER (TRC_INDICATION_SERVICE,
5218                                      "IndicationService::_sendModifyRequests");
5219 kumpf 1.1      
5220                    //
5221 kumpf 1.14         //  Get repeat notification policy value from subscription instance
5222 kumpf 1.1          //
5223 kumpf 1.46         propValue = subscription.getProperty 
5224                        (subscription.findProperty
5225 kumpf 1.11             (_PROPERTY_REPEATNOTIFICATIONPOLICY)).getValue ();
5226                    propValue.get (repeatNotificationPolicy);
5227 kumpf 1.1      
5228                    //
5229 kumpf 1.38         //  Send Modify request to each provider
5230 kumpf 1.1          //
5231 kumpf 1.11         for (Uint8 i = 0; i < indicationProviders.size (); i++)
5232 kumpf 1.1          {
5233 mday  1.20     
5234 kumpf 1.27            struct enableProviderList *epl = 
5235                	  new enableProviderList(indicationProviders[i], 
5236 mday  1.20     				 subscription);
5237                
5238 mday  1.73.4.1 // l10n
5239 mday  1.21            CIMModifySubscriptionRequestMessage * request =
5240                	  new CIMModifySubscriptionRequestMessage(
5241                	     XmlWriter::getNextMessageId (),
5242                	     nameSpace,
5243 kumpf 1.46     	     subscription,
5244 kumpf 1.27     	     epl->pcl->classList, 
5245                	     epl->pcl->provider, 
5246 mday  1.21     	     epl->pcl->providerModule,
5247                	     propertyList,
5248                	     repeatNotificationPolicy,
5249                	     condition,
5250                	     queryLanguage,
5251                	     QueueIdStack (_providerManager, getQueueId ()),
5252                	     authType,
5253 mday  1.73.4.1 	     userName,
5254                	     contentLangs,
5255                	     acceptLangs);
5256 kumpf 1.1      
5257 kumpf 1.11             AsyncOpNode* op = this->get_op();
5258 kumpf 1.1      
5259 kumpf 1.11             AsyncLegacyOperationStart * async_req =
5260                            new AsyncLegacyOperationStart
5261                                (get_next_xid (),
5262                                op,
5263                                _providerManager,
5264                                request,
5265                                _queueId);
5266 kumpf 1.1      
5267 kumpf 1.27     	SendAsync(op, 
5268                		  _providerManager, 
5269 mday  1.20     		  IndicationService::_sendModifyRequestsCallBack,
5270 kumpf 1.27     		  this, 
5271 mday  1.20     		  (void *)epl);
5272 kumpf 1.1      
5273 kumpf 1.25             // AsyncReply * async_reply = SendWait (async_req);
5274 kumpf 1.11         }
5275 kumpf 1.1      
5276 kumpf 1.48         PEG_METHOD_EXIT ();
5277 kumpf 1.1      }
5278                
5279 mday  1.21     
5280 kumpf 1.38     void IndicationService::_sendDeleteRequestsCallBack (
5281 kumpf 1.37         AsyncOpNode * op, 
5282                    MessageQueue * q, 
5283                    void * parm)
5284 mday  1.21     {
5285 kumpf 1.48         PEG_METHOD_ENTER (TRC_INDICATION_SERVICE,
5286                                      "IndicationService::_sendDeleteRequestsCallBack");
5287 kumpf 1.37     
5288                    IndicationService * service = static_cast <IndicationService *> (q);
5289                    struct enableProviderList * epl = 
5290                        reinterpret_cast <struct enableProviderList *> (parm);
5291 mday  1.21     
5292 kumpf 1.37         AsyncRequest * asyncRequest = static_cast <AsyncRequest *>
5293                        (op->get_request ());
5294                    AsyncReply * asyncReply = static_cast <AsyncReply *> (op->get_response ());
5295                    CIMRequestMessage * request = reinterpret_cast <CIMRequestMessage *>
5296                        ((static_cast <AsyncLegacyOperationStart *> 
5297                        (asyncRequest))->get_action ());
5298 mday  1.21     
5299 kumpf 1.37         CIMDeleteSubscriptionResponseMessage * response =
5300                        reinterpret_cast <CIMDeleteSubscriptionResponseMessage *>
5301                        ((static_cast <AsyncLegacyOperationResult *>
5302 mday  1.21     	(asyncReply))->get_result());
5303 kumpf 1.27        
5304 kumpf 1.37         //
5305                    //  ATTN: Check for return value indicating invalid queue ID
5306                    //  If received, need to find Provider Manager Service queue ID again
5307                    //
5308 kumpf 1.27        
5309 kumpf 1.37         PEGASUS_ASSERT (response != 0);
5310                    if (response->cimException.getCode () == CIM_ERR_SUCCESS)
5311                    {
5312                    }
5313                    else
5314                    {
5315 mday  1.21             //
5316 kumpf 1.38             //  ATTN-CAKG-P3-20020326: Log a message
5317                        //  Should the table entry be removed anyway?
5318 kumpf 1.37             //
5319                    }
5320                
5321                    delete epl;
5322                    delete request;
5323                    delete response;
5324                    delete asyncRequest;
5325                    delete asyncReply;
5326                    op->release ();
5327                    service->return_op (op);
5328 mday  1.21     }
5329                
5330 mday  1.73.4.1 // l10n
5331 kumpf 1.38     void IndicationService::_sendDeleteRequests
5332 kumpf 1.16         (const Array <ProviderClassList> & indicationProviders,
5333 kumpf 1.63          const CIMNamespaceName & nameSpace,
5334 kumpf 1.46          const CIMInstance & subscription,
5335 mday  1.73.4.1      const AcceptLanguages & acceptLangs,
5336                     const ContentLanguages & contentLangs,	  
5337 kumpf 1.15          const String & userName,
5338                     const String & authType)
5339 kumpf 1.10     {
5340 kumpf 1.48         PEG_METHOD_ENTER (TRC_INDICATION_SERVICE,
5341                                      "IndicationService::_sendDeleteRequests");
5342 kumpf 1.10     
5343                    //
5344 kumpf 1.38         //  Send Delete request to each provider
5345 kumpf 1.10         //
5346 kumpf 1.11         for (Uint8 i = 0; i < indicationProviders.size (); i++)
5347 kumpf 1.10         {
5348 mday  1.21     
5349 kumpf 1.27            struct enableProviderList *epl = 
5350                	  new enableProviderList(indicationProviders[i], 
5351 mday  1.21     				 subscription);
5352                
5353 mday  1.73.4.1 // l10n
5354 kumpf 1.16             CIMDeleteSubscriptionRequestMessage * request =
5355                            new CIMDeleteSubscriptionRequestMessage
5356 kumpf 1.11                 (XmlWriter::getNextMessageId (),
5357                            nameSpace,
5358 kumpf 1.46                 subscription,
5359 mday  1.21     	     epl->pcl->classList,
5360 kumpf 1.27     	     epl->pcl->provider, 
5361 mday  1.21     	     epl->pcl->providerModule,
5362                	     QueueIdStack (_providerManager, getQueueId ()),
5363                	     authType,
5364 mday  1.73.4.1 	     userName,
5365                	     contentLangs,
5366                	     acceptLangs);
5367                
5368 kumpf 1.11             AsyncOpNode* op = this->get_op();
5369 kumpf 1.10     
5370 kumpf 1.11             AsyncLegacyOperationStart * async_req =
5371                            new AsyncLegacyOperationStart
5372                                (get_next_xid (),
5373                                op,
5374                                _providerManager,
5375                                request,
5376                                _queueId);
5377 mday  1.21     	
5378 kumpf 1.27     	SendAsync(op, 
5379                		  _providerManager, 
5380 kumpf 1.38     		  IndicationService::_sendDeleteRequestsCallBack,
5381 kumpf 1.27     		  this, 
5382 mday  1.21     		  (void *)epl);
5383 kumpf 1.10     
5384 mday  1.21     	// <<< Fri Apr  5 06:05:55 2002 mdd >>>
5385 kumpf 1.25     	// AsyncReply * async_reply = SendWait (async_req);
5386 kumpf 1.10         }
5387                
5388 kumpf 1.48         PEG_METHOD_EXIT ();
5389 kumpf 1.10     }
5390                
5391 kumpf 1.73     String IndicationService::_generateActiveSubscriptionsKey (
5392                    const CIMObjectPath & subscriptionRef)
5393 kumpf 1.16     {
5394 kumpf 1.73         String activeSubscriptionsKey;
5395 kumpf 1.16     
5396 kumpf 1.48         PEG_METHOD_ENTER (TRC_INDICATION_SERVICE,
5397 kumpf 1.73                           "IndicationService::_generateActiveSubscriptionsKey");
5398 kumpf 1.16     
5399                    //
5400                    //  Append subscription namespace name to key
5401                    //
5402 kumpf 1.73         activeSubscriptionsKey.append 
5403                        (subscriptionRef.getNameSpace ().getString());
5404                
5405                    //
5406                    //  Get filter and handler key bindings from subscription reference
5407                    //
5408                    Array<CIMKeyBinding> subscriptionKB = subscriptionRef.getKeyBindings ();
5409                    Array<CIMKeyBinding> filterKB;
5410                    Array<CIMKeyBinding> handlerKB;
5411                    for (Uint8 i = 0; i < subscriptionKB.size (); i++)
5412                    {
5413                        if ((subscriptionKB [i].getName () == _PROPERTY_FILTER) &&
5414                            (subscriptionKB [i].getType () == CIMKeyBinding::REFERENCE))
5415                        {
5416                            CIMObjectPath filterRef (subscriptionKB [i].getValue ());
5417                            filterKB = filterRef.getKeyBindings ();
5418                        }
5419                        if ((subscriptionKB [i].getName () == _PROPERTY_HANDLER) &&
5420                            (subscriptionKB [i].getType () == CIMKeyBinding::REFERENCE))
5421                        {
5422                            CIMObjectPath handlerRef (subscriptionKB [i].getValue ());
5423 kumpf 1.73                 handlerKB = handlerRef.getKeyBindings ();
5424                        }
5425                    }
5426 kumpf 1.16     
5427                    //
5428                    //  Append subscription filter key values to key
5429                    //
5430 kumpf 1.73         for (Uint8 j = 0; j < filterKB.size (); j++)
5431                    {
5432                        activeSubscriptionsKey.append (filterKB [j].getValue ());
5433                    }
5434                
5435                    //
5436                    //  Append subscription handler key values to key
5437                    //
5438                    for (Uint8 k = 0; k < handlerKB.size (); k++)
5439                    {
5440                        activeSubscriptionsKey.append (handlerKB [k].getValue ());
5441                    }
5442                
5443                    PEG_METHOD_EXIT ();
5444                    return activeSubscriptionsKey;
5445                }
5446                
5447                void IndicationService::_insertActiveSubscriptionsEntry (
5448                    const CIMInstance & subscription,
5449                    const Array <ProviderClassList> & providers)
5450                {
5451 kumpf 1.73         PEG_METHOD_ENTER (TRC_INDICATION_SERVICE,
5452                                      "IndicationService::_insertActiveSubscriptionsEntry");
5453                
5454                    String activeSubscriptionsKey = _generateActiveSubscriptionsKey 
5455                        (subscription.getPath ());
5456                    ActiveSubscriptionsTableEntry entry;
5457                    entry.subscription = subscription;
5458                    entry.providers = providers;
5459                    _activeSubscriptionsTable.insert (activeSubscriptionsKey, entry);
5460 kumpf 1.16     
5461 kumpf 1.73     #ifdef PEGASUS_INDICATION_HASHTRACE
5462                    String traceString;
5463                    traceString.append (activeSubscriptionsKey);
5464                    traceString.append (" Providers: ");
5465                    for (Uint8 i = 0; i < providers.size (); i++)
5466 kumpf 1.16         {
5467 kumpf 1.73             String providerName = providers [i].provider.getProperty 
5468                            (providers [i].provider.findProperty 
5469                            (_PROPERTY_NAME)).getValue ().toString ();
5470                        traceString.append (providerName);
5471                        traceString.append ("  Classes: ");
5472                        for (Uint8 j = 0; j < providers[i].classList.size (); j++)
5473                        {
5474                             traceString.append (providers[i].classList[j].getString());   
5475                             traceString.append ("  ");
5476                        }
5477 kumpf 1.16         }
5478 kumpf 1.73         
5479                    PEG_TRACE_STRING (TRC_INDICATION_SERVICE_INTERNAL, Tracer::LEVEL3, 
5480                        "INSERTED _activeSubscriptionsTable entry: " + traceString);
5481                #endif
5482                
5483                    PEG_METHOD_EXIT ();
5484                }
5485                
5486                String IndicationService::_generateSubscriptionClassesKey (
5487                    const CIMName & indicationClassName,
5488                    const CIMNamespaceName & sourceNamespaceName)
5489                {
5490                    String subscriptionClassesKey;
5491                
5492                    PEG_METHOD_ENTER (TRC_INDICATION_SERVICE,
5493                                      "IndicationService::_generateSubscriptionClassesKey");
5494                
5495                    //
5496                    //  Append indication class name to key
5497                    //
5498                    subscriptionClassesKey.append (indicationClassName.getString ());
5499 kumpf 1.16     
5500                    //
5501 kumpf 1.73         //  Append source namespace name to key
5502 kumpf 1.16         //
5503 kumpf 1.73         subscriptionClassesKey.append (sourceNamespaceName.getString ());
5504                
5505                    PEG_METHOD_EXIT ();
5506                    return subscriptionClassesKey;
5507                }
5508                
5509                void IndicationService::_insertSubscriptionClassesEntry (
5510                    const CIMName & indicationClassName,
5511                    const CIMNamespaceName & sourceNamespaceName,
5512                    const Array <CIMInstance> & subscriptions)
5513                {
5514                    PEG_METHOD_ENTER (TRC_INDICATION_SERVICE,
5515                                      "IndicationService::_insertSubscriptionClassesEntry");
5516 kumpf 1.16     
5517 kumpf 1.73         String subscriptionClassesKey = _generateSubscriptionClassesKey
5518                        (indicationClassName, sourceNamespaceName);
5519                    SubscriptionClassesTableEntry entry;
5520                    entry.indicationClassName = indicationClassName;
5521                    entry.sourceNamespaceName = sourceNamespaceName;
5522                    entry.subscriptions = subscriptions;
5523                    _subscriptionClassesTable.insert (subscriptionClassesKey, entry);
5524                
5525                #ifdef PEGASUS_INDICATION_HASHTRACE
5526                    String traceString;
5527                    traceString.append (subscriptionClassesKey);
5528                    traceString.append (" Subscriptions: ");
5529                    for (Uint8 i = 0; i < subscriptions.size (); i++)
5530 kumpf 1.16         {
5531 kumpf 1.73             traceString.append (subscriptions [i].getPath ().toString());   
5532                        traceString.append ("  ");
5533 kumpf 1.16         }
5534 kumpf 1.73         
5535                    PEG_TRACE_STRING (TRC_INDICATION_SERVICE_INTERNAL, Tracer::LEVEL3, 
5536                        "INSERTED _subscriptionClassesTable entry: " + traceString);
5537                #endif
5538                
5539                    PEG_METHOD_EXIT ();
5540                }
5541                
5542                void IndicationService::_insertToHashTables (
5543                    const CIMInstance & subscription,
5544                    const Array <ProviderClassList> & providers,
5545                    const Array <CIMName> & indicationSubclassNames,
5546                    const CIMNamespaceName & sourceNamespaceName)
5547                {
5548                    PEG_METHOD_ENTER (TRC_INDICATION_SERVICE,
5549                                      "IndicationService::_insertToHashTables");
5550 kumpf 1.16     
5551                    //
5552 kumpf 1.73         //  Insert entry into active subscriptions table 
5553 kumpf 1.16         //
5554 kumpf 1.73         _insertActiveSubscriptionsEntry (subscription, providers);
5555                
5556                    //
5557                    //  Insert or update entries in subscription classes table 
5558                    //
5559                    for (Uint8 i = 0; i < indicationSubclassNames.size (); i++)
5560                    {
5561                        String subscriptionClassesKey = _generateSubscriptionClassesKey
5562                            (indicationSubclassNames [i], sourceNamespaceName);
5563                        SubscriptionClassesTableEntry tableValue;
5564                        if (_subscriptionClassesTable.lookup (subscriptionClassesKey,
5565                            tableValue))
5566                        {
5567                            //
5568                            //  If entry exists for this IndicationClassName-SourceNamespace 
5569                            //  pair, remove old entry and insert new entry
5570                            //
5571                            Array <CIMInstance> subscriptions = tableValue.subscriptions;
5572                            subscriptions.append (subscription);
5573                            _subscriptionClassesTable.remove (subscriptionClassesKey);
5574                #ifdef PEGASUS_INDICATION_HASHTRACE
5575 kumpf 1.73                 PEG_TRACE_STRING (TRC_INDICATION_SERVICE_INTERNAL, Tracer::LEVEL3, 
5576                                "REMOVED _subscriptionClassesTable entry: " + 
5577                                subscriptionClassesKey);
5578                #endif
5579                            _insertSubscriptionClassesEntry (indicationSubclassNames [i],
5580                                sourceNamespaceName, subscriptions);
5581                        }
5582                        else
5583                        {
5584                            //
5585                            //  If no entry exists for this 
5586                            //  IndicationClassName-SourceNamespace pair, insert new entry
5587                            //
5588                            Array <CIMInstance> subscriptions;
5589                            subscriptions.append (subscription);
5590                            _insertSubscriptionClassesEntry (indicationSubclassNames [i],
5591                                sourceNamespaceName, subscriptions);
5592                        }
5593                    }
5594 kumpf 1.16     
5595 kumpf 1.48         PEG_METHOD_EXIT ();
5596 kumpf 1.16     }
5597                
5598 kumpf 1.73     void IndicationService::_removeFromHashTables (
5599 kumpf 1.46         const CIMInstance & subscription,
5600 kumpf 1.73         const Array <CIMName> & indicationSubclassNames,
5601                    const CIMNamespaceName & sourceNamespaceName)
5602 kumpf 1.16     {
5603 kumpf 1.48         PEG_METHOD_ENTER (TRC_INDICATION_SERVICE,
5604 kumpf 1.73                           "IndicationService::_removeFromHashTables");
5605                
5606                    //
5607                    //  Remove entry from active subscriptions table 
5608                    //
5609                    String activeSubscriptionsKey = _generateActiveSubscriptionsKey
5610                        (subscription.getPath ());
5611                    _activeSubscriptionsTable.remove (activeSubscriptionsKey);
5612                
5613                #ifdef PEGASUS_INDICATION_HASHTRACE
5614                    PEG_TRACE_STRING (TRC_INDICATION_SERVICE_INTERNAL, Tracer::LEVEL3, 
5615                        "REMOVED _activeSubscriptionsTable entry: " + 
5616                        activeSubscriptionsKey);
5617                #endif
5618                
5619                    //
5620                    //  Remove or update entries in subscription classes table 
5621                    //
5622                    for (Uint8 i = 0; i < indicationSubclassNames.size (); i++)
5623                    {
5624                        String subscriptionClassesKey = _generateSubscriptionClassesKey
5625 kumpf 1.73                 (indicationSubclassNames [i], sourceNamespaceName);
5626                        SubscriptionClassesTableEntry tableValue;
5627                        if (_subscriptionClassesTable.lookup (subscriptionClassesKey,
5628                            tableValue))
5629                        {
5630                            //
5631                            //  If entry exists for this IndicationClassName-SourceNamespace 
5632                            //  pair, remove subscription from the list
5633                            //
5634                            Array <CIMInstance> subscriptions = tableValue.subscriptions;
5635                            for (Uint8 j = 0; j < subscriptions.size (); j++)
5636                            {
5637                                if (subscriptions [j].getPath().identical 
5638                                   (subscription.getPath()))
5639                                {
5640                                    subscriptions.remove (j);
5641                                }
5642                            }
5643 kumpf 1.16     
5644 kumpf 1.73                 //
5645                            //  Remove the old entry
5646                            //
5647                            _subscriptionClassesTable.remove (subscriptionClassesKey);
5648                #ifdef PEGASUS_INDICATION_HASHTRACE
5649                            PEG_TRACE_STRING (TRC_INDICATION_SERVICE_INTERNAL, Tracer::LEVEL3, 
5650                                "REMOVED _subscriptionClassesTable entry: " + 
5651                                subscriptionClassesKey);
5652                #endif
5653                
5654                            //
5655                            //  If there are still subscriptions in the list, insert the 
5656                            //  new entry
5657                            //
5658                            if (subscriptions.size () > 0)
5659                            {
5660                                _insertSubscriptionClassesEntry (indicationSubclassNames [i],
5661                                    sourceNamespaceName, subscriptions);
5662                            }
5663                        }
5664                        else
5665 kumpf 1.73             {
5666                            //
5667                            //  Entry not found in Subscription Classes table
5668                            //
5669                
5670                            //
5671                            //  ATTN-CAKG-P3-20030403: Log a message
5672                            //
5673                        }
5674                    }
5675 kumpf 1.16     
5676 kumpf 1.48         PEG_METHOD_EXIT ();
5677 kumpf 1.16     }
5678                
5679 kumpf 1.11     CIMInstance IndicationService::_createAlertInstance (
5680 kumpf 1.63         const CIMName & alertClassName,
5681 kumpf 1.46         const Array <CIMInstance> & subscriptions)
5682 kumpf 1.10     {
5683 kumpf 1.48         PEG_METHOD_ENTER (TRC_INDICATION_SERVICE,
5684                                      "IndicationService::_createAlertInstance");
5685 kumpf 1.10     
5686 kumpf 1.11         CIMInstance indicationInstance (alertClassName);
5687 kumpf 1.10     
5688 kumpf 1.27         // 
5689 kumpf 1.11         //  Add property values for all required properties of CIM_AlertIndication
5690 kumpf 1.27         // 
5691                    indicationInstance.addProperty 
5692 kumpf 1.11             (CIMProperty (_PROPERTY_ALERTTYPE, CIMValue ((Uint16) _TYPE_OTHER)));
5693 kumpf 1.10         //
5694 kumpf 1.38         //  ATTN: what should Other Alert Type value be??
5695                    //  Currently using Alert class name
5696 kumpf 1.10         //
5697 kumpf 1.27         indicationInstance.addProperty 
5698 kumpf 1.63             (CIMProperty (_PROPERTY_OTHERALERTTYPE, alertClassName.getString()));
5699 kumpf 1.10     
5700 kumpf 1.27         indicationInstance.addProperty 
5701 kumpf 1.11             (CIMProperty (_PROPERTY_PERCEIVEDSEVERITY,
5702                                      CIMValue ((Uint16) _SEVERITY_WARNING)));
5703 kumpf 1.10         //
5704 kumpf 1.38         //  ATTN: what should Probable Cause value be??
5705                    //  Currently using Unknown
5706 kumpf 1.10         //
5707 kumpf 1.27         indicationInstance.addProperty 
5708 kumpf 1.11             (CIMProperty (_PROPERTY_PROBABLECAUSE,
5709 kumpf 1.27                           CIMValue ((Uint16) _CAUSE_UNKNOWN)));   
5710 kumpf 1.10     
5711 kumpf 1.27         // 
5712 kumpf 1.11         //  Add properties specific to each alert class
5713                    //  ATTN: update once alert classes have been defined
5714                    //  NB: for _CLASS_NO_PROVIDER_ALERT and _CLASS_PROVIDER_TERMINATED_ALERT,
5715                    //  one of the properties will be a list of affected subscriptions
5716 kumpf 1.13         //  It is for that reason that subscriptions is passed in as a parameter
5717 kumpf 1.27         // 
5718 kumpf 1.64         if (alertClassName.equal (_CLASS_CIMOM_SHUTDOWN_ALERT))
5719 kumpf 1.11         {
5720                    }
5721 kumpf 1.64         else if (alertClassName.equal (_CLASS_NO_PROVIDER_ALERT))
5722 kumpf 1.10         {
5723                    }
5724 kumpf 1.64         else if (alertClassName.equal (_CLASS_PROVIDER_TERMINATED_ALERT))
5725 kumpf 1.10         {
5726                    }
5727 kumpf 1.11     
5728 kumpf 1.48         PEG_METHOD_EXIT ();
5729 kumpf 1.19         return indicationInstance;
5730 kumpf 1.10     }
5731                
5732 mday  1.21     
5733 kumpf 1.27     void IndicationService::_sendAlertsCallBack(AsyncOpNode *op, 
5734                					    MessageQueue *q, 
5735 mday  1.21     					    void *parm)
5736                {
5737 kumpf 1.48         PEG_METHOD_ENTER (TRC_INDICATION_SERVICE,
5738                                      "IndicationService::_sendAlertsCallBack");
5739 mday  1.21     
5740 kumpf 1.27        IndicationService *service = 
5741 mday  1.21           static_cast<IndicationService *>(q);
5742 kumpf 1.46        CIMInstance *_handler = 
5743                      reinterpret_cast<CIMInstance *>(parm);
5744 kumpf 1.27        
5745 mday  1.21        AsyncRequest *asyncRequest = static_cast<AsyncRequest *>(op->get_request());
5746                   AsyncReply *asyncReply = static_cast<AsyncReply *>(op->get_response());
5747                   CIMRequestMessage *request = reinterpret_cast<CIMRequestMessage *>
5748                      ((static_cast<AsyncLegacyOperationStart *>(asyncRequest))->get_action());
5749                
5750 kumpf 1.27        CIMHandleIndicationResponseMessage* response = 
5751 mday  1.21           reinterpret_cast<CIMHandleIndicationResponseMessage *>
5752                      ((static_cast<AsyncLegacyOperationResult *>
5753                	(asyncReply))->get_result());
5754                
5755 kumpf 1.37        PEGASUS_ASSERT(response != 0);
5756                   if (response->cimException.getCode() == CIM_ERR_SUCCESS)
5757                   {
5758                   }
5759                   else
5760                   {
5761                   }
5762                   
5763 mday  1.21        //
5764                   //  ATTN: Check for return value indicating invalid queue ID
5765 kumpf 1.37        //  If received, need to find Handler Manager Service queue ID
5766 mday  1.21        //  again
5767                   //
5768                
5769 mday  1.49     // << Mon Jul 15 09:59:16 2002 mdd >> handler is allocated as an element in an array, 
5770                // don't delete here. 
5771                //   delete _handler; 
5772 mday  1.21        delete request;
5773                   delete response;
5774                   delete asyncRequest;
5775                   delete asyncReply;
5776 mday  1.29        op->release();
5777 mday  1.21        service->return_op(op);
5778 kumpf 1.73     
5779                    PEG_METHOD_EXIT ();
5780 mday  1.21     }
5781                
5782                
5783 kumpf 1.11     void IndicationService::_sendAlerts (
5784 kumpf 1.46         const Array <CIMInstance> & subscriptions,
5785 kumpf 1.11         /* const */ CIMInstance & alertInstance)
5786 kumpf 1.10     {
5787 kumpf 1.46         CIMInstance current;
5788 kumpf 1.11         Boolean duplicate;
5789 kumpf 1.46         Array <CIMInstance> handlers; 
5790 kumpf 1.27         
5791 kumpf 1.48         PEG_METHOD_ENTER (TRC_INDICATION_SERVICE, "IndicationService::_sendAlerts");
5792 kumpf 1.10     
5793 kumpf 1.11         handlers.clear ();
5794                
5795 kumpf 1.73         PEG_TRACE_STRING (TRC_INDICATION_SERVICE, Tracer::LEVEL4, 
5796                        "Sending alert: " + alertInstance.getClassName().getString());
5797                
5798 kumpf 1.10         //
5799 kumpf 1.11         //  Get list of unique handler instances for all subscriptions in list
5800 kumpf 1.10         //
5801 kumpf 1.13         for (Uint8 i = 0; i < subscriptions.size (); i++)
5802 kumpf 1.11         {
5803 kumpf 1.73             PEG_TRACE_STRING (TRC_INDICATION_SERVICE, Tracer::LEVEL4, 
5804                            "Alert subscription: " + subscriptions [i].getPath().toString());
5805                
5806 kumpf 1.11             //
5807                        //  Get handler instance
5808                        //
5809 kumpf 1.13             current = _getHandler (subscriptions [i]);
5810 kumpf 1.11     
5811                        //
5812                        //  Merge into list of unique handler instances
5813                        //
5814                        duplicate = false;
5815                        for (Uint8 j = 0; j < handlers.size () && !duplicate; j++)
5816                        {
5817 kumpf 1.56                 if ((current.identical (handlers [j])) &&
5818 kumpf 1.46                     (current.getPath () == handlers [j].getPath ()))
5819 kumpf 1.11                 {
5820                                duplicate = true;
5821                            }
5822                        }
5823                
5824                        if (!duplicate)
5825                        {
5826                            handlers.append (current);
5827                        }
5828                    }
5829 kumpf 1.10     
5830                    //
5831 kumpf 1.11         //  Send handle indication request to each handler
5832 kumpf 1.10         //
5833 kumpf 1.11         for (Uint8 k = 0; k < handlers.size (); k++)
5834                    {
5835                        CIMHandleIndicationRequestMessage * handler_request =
5836                            new CIMHandleIndicationRequestMessage (
5837                                XmlWriter::getNextMessageId (),
5838 kumpf 1.46                     handlers[k].getPath ().getNameSpace (),
5839                                handlers[k],
5840 kumpf 1.11                     alertInstance,
5841                                QueueIdStack (_handlerService, getQueueId ()));
5842                
5843                        AsyncOpNode* op = this->get_op();
5844 kumpf 1.27          
5845                        AsyncLegacyOperationStart *async_req = 
5846 kumpf 1.11                 new AsyncLegacyOperationStart(
5847                                get_next_xid(),
5848                                op,
5849                                _handlerService,
5850                                handler_request,
5851                                _queueId);
5852 kumpf 1.10     
5853 kumpf 1.27     	SendAsync(op, 
5854                		  _handlerService, 
5855 mday  1.21     		  IndicationService::_sendAlertsCallBack,
5856 kumpf 1.27     		  this, 
5857 kumpf 1.46     		  (void *)&handlers[k]);
5858 kumpf 1.10     
5859 kumpf 1.25     	// <<< Fri Apr  5 06:24:14 2002 mdd >>>
5860                	// AsyncReply *async_reply = SendWait(async_req);
5861 kumpf 1.10         }
5862 kumpf 1.24     
5863 kumpf 1.48         PEG_METHOD_EXIT ();
5864 kumpf 1.24     }
5865                
5866 kumpf 1.38     void IndicationService::_sendEnableCallBack(AsyncOpNode *op,
5867 mday  1.28     					   MessageQueue *q,
5868                					   void *parm)
5869                {
5870 kumpf 1.48         PEG_METHOD_ENTER (TRC_INDICATION_SERVICE,
5871                                      "IndicationService::_sendEnableCallBack");
5872 kumpf 1.31     
5873 mday  1.28        IndicationService *service = 
5874                      static_cast<IndicationService *>(q);
5875                   
5876                   AsyncRequest *asyncRequest = static_cast<AsyncRequest *>(op->get_request());
5877                   AsyncReply *asyncReply = static_cast<AsyncReply *>(op->get_response());
5878                   CIMEnableIndicationsRequestMessage *request = 
5879                      static_cast<CIMEnableIndicationsRequestMessage *>
5880                      ((static_cast<AsyncLegacyOperationStart *>(asyncRequest))->get_action());
5881                   
5882 mday  1.40     //    Message *response =  
5883                //       ((static_cast<AsyncLegacyOperationResult *>(asyncReply))->get_result());
5884 kumpf 1.31     
5885                   CIMEnableIndicationsResponseMessage * response =
5886 mday  1.40           reinterpret_cast<CIMEnableIndicationsResponseMessage *>
5887 kumpf 1.31           ((static_cast <AsyncLegacyOperationResult *>
5888                        (asyncReply))->get_result());
5889                
5890                    if (response->cimException.getCode () == CIM_ERR_SUCCESS)
5891                    {
5892                    }
5893                    else
5894                    {
5895                    }
5896 mday  1.28     
5897                   //
5898                   //  ATTN: Check for return value indicating invalid queue ID
5899                   //  If received, need to find Provider Manager Service queue ID
5900                   //  again
5901                   //
5902                
5903                   delete request;
5904                   delete response;
5905                   delete asyncRequest;
5906                   delete asyncReply;
5907 mday  1.29        op->release();
5908 mday  1.28        service->return_op(op);
5909 kumpf 1.31     
5910 kumpf 1.48         PEG_METHOD_EXIT ();
5911 mday  1.28     }
5912                
5913                
5914 kumpf 1.38     void IndicationService::_sendEnable (
5915                    const ProviderClassList & enableProvider)
5916 kumpf 1.24     {
5917 kumpf 1.48         PEG_METHOD_ENTER (TRC_INDICATION_SERVICE, "IndicationService::_sendEnable");
5918 kumpf 1.27      
5919 kumpf 1.24         CIMEnableIndicationsRequestMessage * request =
5920                        new CIMEnableIndicationsRequestMessage
5921                            (XmlWriter::getNextMessageId (),
5922 kumpf 1.38                  enableProvider.provider,
5923                             enableProvider.providerModule,
5924 kumpf 1.24                  QueueIdStack (_providerManager, getQueueId ()));
5925                
5926 kumpf 1.27         AsyncOpNode* op = this->get_op (); 
5927 kumpf 1.24     
5928                    AsyncLegacyOperationStart * async_req =
5929                        new AsyncLegacyOperationStart
5930                            (get_next_xid (),
5931                            op,
5932                            _providerManager,
5933                            request,
5934                            _queueId);
5935                
5936 mday  1.28         SendAsync (op, 
5937                	       _providerManager, 
5938 kumpf 1.38     	       IndicationService::_sendEnableCallBack,
5939 mday  1.28     	       this, 
5940                	       NULL);
5941 kumpf 1.37     
5942 mday  1.40     //    AsyncReply * async_reply = SendWait (async_req);
5943 mday  1.28         // << Wed Apr 10 12:26:16 2002 mdd >>
5944 kumpf 1.10     
5945 kumpf 1.48         PEG_METHOD_EXIT ();
5946 kumpf 1.10     }
5947                
5948 kumpf 1.11     WQLSimplePropertySource IndicationService::_getPropertySourceFromInstance(
5949                    CIMInstance& indicationInstance)
5950 kumpf 1.6      {
5951 kumpf 1.11         Boolean booleanValue;
5952                    WQLSimplePropertySource source;
5953                
5954 kumpf 1.48         PEG_METHOD_ENTER (TRC_INDICATION_SERVICE,
5955                                      "IndicationService::_getPropertySourceFromInstance");
5956 kumpf 1.31     
5957 kumpf 1.11         for (Uint8 i=0; i < indicationInstance.getPropertyCount(); i++)
5958                    {
5959                        CIMProperty property = indicationInstance.getProperty(i);
5960                        CIMValue propertyValue = property.getValue();
5961                        CIMType type = property.getType();
5962 kumpf 1.63             CIMName propertyName = property.getName();
5963 kumpf 1.11     
5964                        switch (type)
5965                        {
5966 kumpf 1.53                 case CIMTYPE_UINT8:
5967 kumpf 1.11                     Uint8 propertyValueUint8;
5968                                propertyValue.get(propertyValueUint8);
5969 kumpf 1.63                     source.addValue(propertyName.getString(),
5970 kumpf 1.11                         WQLOperand(propertyValueUint8, WQL_INTEGER_VALUE_TAG));
5971                                break;
5972                
5973 kumpf 1.53                 case CIMTYPE_UINT16:
5974 kumpf 1.11                     Uint16 propertyValueUint16;
5975                                propertyValue.get(propertyValueUint16);
5976 kumpf 1.63                     source.addValue(propertyName.getString(),
5977 kumpf 1.11                         WQLOperand(propertyValueUint16, WQL_INTEGER_VALUE_TAG));
5978                                break;
5979                
5980 kumpf 1.53                 case CIMTYPE_UINT32:
5981 kumpf 1.11                     Uint32 propertyValueUint32;
5982                                propertyValue.get(propertyValueUint32);
5983 kumpf 1.63                     source.addValue(propertyName.getString(),
5984 kumpf 1.11                         WQLOperand(propertyValueUint32, WQL_INTEGER_VALUE_TAG));
5985                                break;
5986                
5987 kumpf 1.53                 case CIMTYPE_UINT64:
5988 kumpf 1.11                     Uint64 propertyValueUint64;
5989                                propertyValue.get(propertyValueUint64);
5990 kumpf 1.63                     source.addValue(propertyName.getString(),
5991 kumpf 1.11                         WQLOperand(propertyValueUint64, WQL_INTEGER_VALUE_TAG));
5992                                break;
5993                
5994 kumpf 1.53                 case CIMTYPE_SINT8:
5995 kumpf 1.11                     Sint8 propertyValueSint8;
5996                                propertyValue.get(propertyValueSint8);
5997 kumpf 1.63                     source.addValue(propertyName.getString(),
5998 kumpf 1.11                         WQLOperand(propertyValueSint8, WQL_INTEGER_VALUE_TAG));
5999                                break;
6000                
6001 kumpf 1.53                 case CIMTYPE_SINT16:
6002 kumpf 1.11                     Sint16 propertyValueSint16;
6003                                propertyValue.get(propertyValueSint16);
6004 kumpf 1.63                     source.addValue(propertyName.getString(),
6005 kumpf 1.11                         WQLOperand(propertyValueSint16, WQL_INTEGER_VALUE_TAG));
6006                                break;
6007                
6008 kumpf 1.53                 case CIMTYPE_SINT32:
6009 kumpf 1.11                     Sint32 propertyValueSint32;
6010                                propertyValue.get(propertyValueSint32);
6011 kumpf 1.63                     source.addValue(propertyName.getString(),
6012 kumpf 1.11                         WQLOperand(propertyValueSint32, WQL_INTEGER_VALUE_TAG));
6013                                break;                break;
6014                
6015 kumpf 1.53                 case CIMTYPE_SINT64:
6016 kumpf 1.11                     Sint64 propertyValueSint64;
6017                                propertyValue.get(propertyValueSint64);
6018 kumpf 1.63                     source.addValue(propertyName.getString(),
6019 kumpf 1.11                         WQLOperand(propertyValueSint64, WQL_INTEGER_VALUE_TAG));
6020                                break;
6021                
6022 kumpf 1.53                 case CIMTYPE_REAL32:
6023 kumpf 1.11                     Real32 propertyValueReal32;
6024                                propertyValue.get(propertyValueReal32);
6025 kumpf 1.63                     source.addValue(propertyName.getString(),
6026 kumpf 1.11                         WQLOperand(propertyValueReal32, WQL_DOUBLE_VALUE_TAG));
6027                                break;
6028 kumpf 1.10     
6029 kumpf 1.53                 case CIMTYPE_REAL64:
6030 kumpf 1.11                     Real64 propertyValueReal64;
6031                                propertyValue.get(propertyValueReal64);
6032 kumpf 1.63                     source.addValue(propertyName.getString(),
6033 kumpf 1.11                         WQLOperand(propertyValueReal64, WQL_DOUBLE_VALUE_TAG));
6034                                break;
6035 kumpf 1.6      
6036 kumpf 1.53                 case CIMTYPE_BOOLEAN :
6037 kumpf 1.11                     property.getValue().get(booleanValue);
6038 kumpf 1.63                     source.addValue(propertyName.getString(),
6039 kumpf 1.11                         WQLOperand(booleanValue, WQL_BOOLEAN_VALUE_TAG));
6040                                break;
6041 kumpf 1.6      
6042 kumpf 1.53                 case CIMTYPE_CHAR16:
6043                            case CIMTYPE_STRING :
6044 kumpf 1.63                     source.addValue(propertyName.getString(),
6045 kumpf 1.11                         WQLOperand(property.getValue().toString(),
6046                                    WQL_STRING_VALUE_TAG));
6047                                break;
6048 kumpf 1.6      
6049 kumpf 1.53                 case CIMTYPE_DATETIME :
6050 kumpf 1.63                     source.addValue (propertyName.getString(),
6051 kumpf 1.31                         WQLOperand ());
6052                                break;
6053 kumpf 1.6              }
6054                    }
6055 kumpf 1.10     
6056 kumpf 1.48         PEG_METHOD_EXIT ();
6057 kumpf 1.19         return source;
6058 kumpf 1.6      }
6059 kumpf 1.1      
6060 kumpf 1.11     //
6061                //  Class names
6062                //
6063 kumpf 1.1      
6064 kumpf 1.11     /**
6065                    The name of the CIMOM Shutdown alert indication class
6066                 */
6067                //
6068                //  ATTN: Update once CimomShutdownAlertIndication has been defined
6069                //
6070 kumpf 1.63     const CIMName IndicationService::_CLASS_CIMOM_SHUTDOWN_ALERT =
6071                              CIMName ("CIM_AlertIndication");
6072 kumpf 1.1      
6073 kumpf 1.11     /**
6074                    The name of the No Provider alert indication class
6075                 */
6076                //
6077                //  ATTN: Update once NoProviderAlertIndication has been defined
6078                //
6079 kumpf 1.63     const CIMName IndicationService::_CLASS_NO_PROVIDER_ALERT =
6080                              CIMName ("CIM_AlertIndication");
6081 kumpf 1.1      
6082 kumpf 1.11     /**
6083                    The name of the CIMOM shutdown alert indication class
6084                 */
6085                //
6086                //  ATTN: Update once ProviderTerminatedAlertIndication has been defined
6087                //
6088 kumpf 1.63     const CIMName IndicationService::_CLASS_PROVIDER_TERMINATED_ALERT =
6089                              CIMName ("CIM_AlertIndication");
6090 kumpf 1.1      
6091                
6092                //
6093 kumpf 1.11     //  Property names
6094 kumpf 1.1      //
6095                
6096 kumpf 1.11     /**
6097                    The name of the filter reference property for indication subscription class
6098                 */
6099 kumpf 1.63     const CIMName IndicationService::_PROPERTY_FILTER = CIMName ("Filter");
6100 kumpf 1.1      
6101 kumpf 1.11     /**
6102                    The name of the handler reference property for indication subscription class
6103                 */
6104 kumpf 1.63     const CIMName IndicationService::_PROPERTY_HANDLER = CIMName ("Handler");
6105 kumpf 1.1      
6106 kumpf 1.11     /**
6107 kumpf 1.27         The name of the subscription state property for indication subscription 
6108 kumpf 1.11         class
6109                 */
6110 kumpf 1.63     const CIMName IndicationService::_PROPERTY_STATE = 
6111                              CIMName ("SubscriptionState");
6112 kumpf 1.10     
6113 kumpf 1.11     /**
6114 kumpf 1.27         The name of the Other Subscription State property for Indication 
6115 kumpf 1.11         Subscription class
6116                 */
6117 kumpf 1.63     const CIMName IndicationService::_PROPERTY_OTHERSTATE = 
6118                              CIMName ("OtherSubscriptionState");
6119 kumpf 1.10     
6120 kumpf 1.11     /**
6121                    The name of the repeat notification policy property for indication
6122                    subscription class
6123                 */
6124 kumpf 1.63     const CIMName IndicationService::_PROPERTY_REPEATNOTIFICATIONPOLICY =
6125                              CIMName ("RepeatNotificationPolicy");
6126 kumpf 1.10     
6127 kumpf 1.11     /**
6128                    The name of the other repeat notification policy property for
6129                    indication subscription class
6130                 */
6131 kumpf 1.63     const CIMName IndicationService::_PROPERTY_OTHERREPEATNOTIFICATIONPOLICY =
6132                              CIMName ("OtherRepeatNotificationPolicy");
6133 kumpf 1.10     
6134 kumpf 1.11     /**
6135                    The name of the repeat notification interval property for indication
6136                    subscription class
6137                 */
6138 kumpf 1.63     const CIMName IndicationService::_PROPERTY_REPEATNOTIFICATIONINTERVAL =
6139                              CIMName ("RepeatNotificationInterval");
6140 kumpf 1.1      
6141 kumpf 1.11     /**
6142                    The name of the repeat notification gap property for indication
6143                    subscription class
6144                 */
6145 kumpf 1.63     const CIMName IndicationService::_PROPERTY_REPEATNOTIFICATIONGAP =
6146                              CIMName ("RepeatNotificationGap");
6147 kumpf 1.1      
6148 kumpf 1.11     /**
6149                    The name of the repeat notification count property for indication
6150                    subscription class
6151                 */
6152 kumpf 1.63     const CIMName IndicationService::_PROPERTY_REPEATNOTIFICATIONCOUNT =
6153                              CIMName ("RepeatNotificationCount");
6154 kumpf 1.1      
6155 kumpf 1.11     /**
6156 kumpf 1.27         The name of the On Fatal Error Policy property for Indication Subscription 
6157 kumpf 1.11         class
6158                 */
6159 kumpf 1.63     const CIMName IndicationService::_PROPERTY_ONFATALERRORPOLICY = 
6160                              CIMName ("OnFatalErrorPolicy");
6161 kumpf 1.1      
6162 kumpf 1.11     /**
6163 kumpf 1.27         The name of the Other On Fatal Error Policy property for Indication 
6164 kumpf 1.11         Subscription class
6165                 */
6166 kumpf 1.63     const CIMName IndicationService::_PROPERTY_OTHERONFATALERRORPOLICY = 
6167                              CIMName ("OtherOnFatalErrorPolicy");
6168 kumpf 1.1      
6169 kumpf 1.11     /**
6170 kumpf 1.27         The name of the Time Of Last State Change property for Indication 
6171 kumpf 1.11         Subscription class
6172                 */
6173 kumpf 1.63     const CIMName IndicationService::_PROPERTY_LASTCHANGE = 
6174                              CIMName ("TimeOfLastStateChange");
6175 kumpf 1.1      
6176 kumpf 1.11     /**
6177 kumpf 1.27         The name of the Subscription Start Time property for Indication 
6178 kumpf 1.11         Subscription class
6179                 */
6180 kumpf 1.63     const CIMName IndicationService::_PROPERTY_STARTTIME = 
6181                              CIMName ("SubscriptionStartTime");
6182 kumpf 1.1      
6183 kumpf 1.11     /**
6184 kumpf 1.27         The name of the Subscription Duration property for Indication 
6185 kumpf 1.11         Subscription class
6186                 */
6187 kumpf 1.63     const CIMName IndicationService::_PROPERTY_DURATION = 
6188                              CIMName ("SubscriptionDuration");
6189 kumpf 1.1      
6190 kumpf 1.11     /**
6191 kumpf 1.27         The name of the Subscription Time Remaining property for Indication 
6192 kumpf 1.11         Subscription class
6193                 */
6194 kumpf 1.63     const CIMName IndicationService::_PROPERTY_TIMEREMAINING = 
6195                              CIMName ("SubscriptionTimeRemaining");
6196 kumpf 1.1      
6197 kumpf 1.11     /**
6198                    The name of the query property for indication filter class
6199                 */
6200 kumpf 1.63     const CIMName IndicationService::_PROPERTY_QUERY = CIMName ("Query");
6201 kumpf 1.1      
6202 kumpf 1.11     /**
6203                    The name of the query language property for indication filter class
6204                 */
6205 kumpf 1.63     const CIMName IndicationService::_PROPERTY_QUERYLANGUAGE = 
6206                              CIMName ("QueryLanguage");
6207 kumpf 1.1      
6208 kumpf 1.11     /**
6209                    The name of the Source Namespace property for indication filter class
6210                 */
6211 kumpf 1.63     const CIMName IndicationService::_PROPERTY_SOURCENAMESPACE = 
6212                              CIMName ("SourceNamespace");
6213 kumpf 1.1      
6214 kumpf 1.11     /**
6215                    The name of the name property for indication filter and indications handler     classes
6216                 */
6217 kumpf 1.63     const CIMName IndicationService::_PROPERTY_NAME = CIMName ("Name");
6218 kumpf 1.1      
6219 kumpf 1.11     /**
6220 kumpf 1.27         The name of the creation class name property for indication filter and 
6221 kumpf 1.11         indications handler classes
6222                 */
6223 kumpf 1.63     const CIMName IndicationService::_PROPERTY_CREATIONCLASSNAME = 
6224                              CIMName ("CreationClassName");
6225 kumpf 1.1      
6226 kumpf 1.11     /**
6227 kumpf 1.27         The name of the system name property for indication filter and indications 
6228 kumpf 1.11         handler classes
6229                 */
6230 kumpf 1.63     const CIMName IndicationService::_PROPERTY_SYSTEMNAME = 
6231                              CIMName ("SystemName");
6232 kumpf 1.1      
6233 kumpf 1.11     /**
6234 kumpf 1.27         The name of the system creation class name property for indication filter 
6235 kumpf 1.11         and indications handler classes
6236                 */
6237 kumpf 1.63     const CIMName IndicationService::_PROPERTY_SYSTEMCREATIONCLASSNAME = 
6238                              CIMName ("SystemCreationClassName");
6239 kumpf 1.1      
6240 kumpf 1.11     /**
6241                    The name of the Persistence Type property for Indication Handler class
6242                 */
6243 kumpf 1.63     const CIMName IndicationService::_PROPERTY_PERSISTENCETYPE = 
6244                              CIMName ("PersistenceType");
6245 kumpf 1.1      
6246 kumpf 1.11     /**
6247 kumpf 1.27         The name of the Other Persistence Type property for Indication Handler 
6248 kumpf 1.11         class
6249                 */
6250 kumpf 1.63     const CIMName IndicationService::_PROPERTY_OTHERPERSISTENCETYPE = 
6251                              CIMName ("OtherPersistenceType");
6252 kumpf 1.1      
6253 kumpf 1.11     /**
6254 kumpf 1.27         The name of the Destination property for CIM XML Indication Handler 
6255 kumpf 1.13         subclass
6256 kumpf 1.11      */
6257 kumpf 1.63     const CIMName IndicationService::_PROPERTY_DESTINATION = 
6258                              CIMName ("Destination");
6259 kumpf 1.1      
6260 kumpf 1.11     /**
6261 mday  1.73.4.1     The name of the TargetHost property for SNMP Mapper Indication 
6262 kumpf 1.13         Handler subclass
6263                 */
6264 mday  1.73.4.1 const CIMName IndicationService::_PROPERTY_TARGETHOST = 
6265                              CIMName ("TargetHost");
6266                
6267                /**
6268                    The name of the TargetHostFormat property for SNMP Indication Handler subclass
6269                 */
6270                const CIMName IndicationService::_PROPERTY_TARGETHOSTFORMAT = 
6271                              CIMName ("TargetHostFormat");
6272 kumpf 1.13     
6273                /**
6274 mday  1.73.4.1     The name of the SNMPVersion property for SNMP Indication Handler class
6275 kumpf 1.11      */
6276 mday  1.73.4.1 const CIMName IndicationService::_PROPERTY_SNMPVERSION =
6277 kumpf 1.63                   CIMName ("SNMPVersion");
6278 kumpf 1.1      
6279 kumpf 1.11     /**
6280                    The name of the Alert Type property for Alert Indication class
6281                 */
6282 kumpf 1.63     const CIMName IndicationService::_PROPERTY_ALERTTYPE = CIMName ("AlertType");
6283 kumpf 1.1      
6284 kumpf 1.11     /**
6285                    The name of the Other Alert Type property for Alert Indication class
6286                 */
6287 kumpf 1.63     const CIMName IndicationService::_PROPERTY_OTHERALERTTYPE = 
6288                              CIMName ("OtherAlertType");
6289 kumpf 1.1      
6290 kumpf 1.11     /**
6291                    The name of the Perceived Severity property for Alert Indication class
6292                 */
6293 kumpf 1.63     const CIMName IndicationService::_PROPERTY_PERCEIVEDSEVERITY = 
6294                              CIMName ("PerceivedSeverity");
6295 kumpf 1.1      
6296 kumpf 1.11     /**
6297                    The name of the Probable Cause property for Alert Indication class
6298                 */
6299 kumpf 1.63     const CIMName IndicationService::_PROPERTY_PROBABLECAUSE = 
6300                              CIMName ("ProbableCause");
6301 kumpf 1.1      
6302 kumpf 1.11     /**
6303 kumpf 1.16         The name of the Provider Name property for Provider class
6304 kumpf 1.11      */
6305 kumpf 1.63     const CIMName IndicationService::_PROPERTY_PROVIDERNAME = CIMName ("Name");
6306 kumpf 1.1      
6307 kumpf 1.11     /**
6308 kumpf 1.16         The name of the Provider Module Name property for Provider class
6309 kumpf 1.11      */
6310 kumpf 1.63     const CIMName IndicationService::_PROPERTY_PROVIDERMODULENAME = 
6311                              CIMName ("ProviderModuleName");
6312 kumpf 1.10     
6313 kumpf 1.1      
6314 kumpf 1.11     //
6315 kumpf 1.15     //  Qualifier names
6316                //
6317                
6318                /**
6319                    The name of the Indication qualifier for classes
6320                 */
6321 kumpf 1.63     const CIMName IndicationService::_QUALIFIER_INDICATION = CIMName ("INDICATION");
6322 kumpf 1.15     
6323 kumpf 1.1      
6324 kumpf 1.11     //
6325                //  Other literal values
6326                //
6327 kumpf 1.1      
6328 kumpf 1.11     /**
6329                    The WHERE keyword in WQL
6330                 */
6331                const char   IndicationService::_QUERY_WHERE []         = "WHERE";
6332 kumpf 1.1      
6333 kumpf 1.11     /**
6334                    The string representing the asterisk all properties symbol in WQL
6335                 */
6336                const char   IndicationService::_QUERY_ALLPROPERTIES [] = "*";
6337 kumpf 1.1      
6338 kumpf 1.58     /**
6339                    A zero value CIMDateTime interval
6340                 */
6341                const char IndicationService::_ZERO_INTERVAL_STRING [] = 
6342                    "00000000000000.000000:000";
6343 kumpf 1.1      
6344 kumpf 1.11     //
6345                //  Message substrings used in exception messages
6346                //
6347 kumpf 1.1      
6348 mday  1.73.4.2 // l10n
6349                
6350                // some have been commented out and put directly in the code for localization
6351                
6352                // this one is tricky because it is used in _checkRequiredProperty with the two below
6353 kumpf 1.11     const char IndicationService::_MSG_MISSING_REQUIRED [] = "Missing required ";
6354 kumpf 1.1      
6355 kumpf 1.11     const char IndicationService::_MSG_KEY_PROPERTY [] = " key property";
6356 mday  1.73.4.2 const char IndicationService::_MSG_KEY_PROPERTY_KEY [] = 
6357                   "IndicationService.IndicationService._MSG_KEY_PROPERTY";
6358 kumpf 1.1      
6359 kumpf 1.11     const char IndicationService::_MSG_PROPERTY [] = " property";
6360 mday  1.73.4.2 const char IndicationService::_MSG_PROPERTY_KEY [] = 
6361                   "IndicationService.IndicationService._MSG_PROPERTY";
6362 kumpf 1.1      
6363 kumpf 1.27     const char IndicationService::_MSG_PROPERTY_PRESENT [] = 
6364 kumpf 1.11         " property present, but ";
6365 kumpf 1.1      
6366 kumpf 1.11     const char IndicationService::_MSG_VALUE_NOT [] = " value not ";
6367 kumpf 1.1      
6368 mday  1.73.4.2 const char IndicationService::_MSG_PROPERTY_PRESENT_BUT_VALUE_NOT_KEY [] = 
6369                   "IndicationService.IndicationService._MSG_PROPERTY_PRESENT_BUT_VALUE_NOT";
6370                
6371                
6372 kumpf 1.27     const char IndicationService::_MSG_NO_PROVIDERS [] = 
6373 kumpf 1.11         "There are no providers capable of serving the subscription";
6374 mday  1.73.4.2 const char IndicationService::_MSG_NO_PROVIDERS_KEY [] = 
6375                    "IndicationService.IndicationService._MSG_NO_PROVIDERS";
6376 kumpf 1.1      
6377 kumpf 1.27     const char IndicationService::_MSG_NOT_ACCEPTED [] = 
6378 kumpf 1.15         "No providers accepted the subscription";
6379 mday  1.73.4.2 const char IndicationService::_MSG_NOT_ACCEPTED_KEY [] = 
6380                    "IndicationService.IndicationService._MSG_NOT_ACCEPTED";
6381 kumpf 1.15     
6382 kumpf 1.27     const char IndicationService::_MSG_INVALID_CLASSNAME [] = 
6383 kumpf 1.11         "Invalid indication class name ";
6384 kumpf 1.1      
6385 kumpf 1.11     const char IndicationService::_MSG_IN_FROM [] = " in FROM clause of ";
6386 kumpf 1.1      
6387 mday  1.73.4.2 const char IndicationService::_MSG_INVALID_CLASSNAME_IN_FROM_PROPERTY_KEY [] = 
6388                    "IndicationService.IndicationService._MSG_INVALID_CLASSNAME_IN_FROM_PROPERTY";
6389                
6390 kumpf 1.27     const char IndicationService::_MSG_EXPIRED [] = 
6391 kumpf 1.11         "Expired subscription may not be modified; has been deleted";
6392 mday  1.73.4.2 const char IndicationService::_MSG_EXPIRED_KEY [] = 
6393                    "IndicationService.IndicationService._MSG_EXPIRED";
6394 kumpf 1.15     
6395 kumpf 1.27     const char IndicationService::_MSG_REFERENCED [] = 
6396 kumpf 1.15         "A Filter or Handler referenced by a subscription may not be deleted";
6397 mday  1.73.4.2 const char IndicationService::_MSG_REFERENCED_KEY [] = 
6398                    "IndicationService.IndicationService._MSG_REFERENCED";
6399                
6400 kumpf 1.32     
6401                const char IndicationService::_MSG_INVALID_VALUE [] =
6402                    "Invalid value ";
6403                
6404                const char IndicationService::_MSG_FOR_PROPERTY [] =
6405                    " for property ";
6406 kumpf 1.1      
6407 mday  1.73.4.2 const char IndicationService::_MSG_INVALID_VALUE_FOR_PROPERTY_KEY [] =
6408                    "IndicationService.IndicationService._MSG_INVALID_VALUE_FOR_PROPERTY";
6409                
6410 kumpf 1.38     const char IndicationService::_MSG_CLASS_NOT_SERVED [] =
6411                    "The specified class is not served by the Indication Service";
6412 mday  1.73.4.2 const char IndicationService::_MSG_CLASS_NOT_SERVED_KEY [] =
6413                    "IndicationService.IndicationService._MSG_CLASS_NOT_SERVED";
6414 kumpf 1.1      
6415                PEGASUS_NAMESPACE_END

No CVS admin address has been configured
Powered by
ViewCVS 0.9.2