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

   1 karl  1.196 //%2006////////////////////////////////////////////////////////////////////////
   2 kumpf 1.1   //
   3 karl  1.148 // Copyright (c) 2000, 2001, 2002 BMC Software; Hewlett-Packard Development
   4             // Company, L.P.; IBM Corp.; The Open Group; Tivoli Systems.
   5             // Copyright (c) 2003 BMC Software; Hewlett-Packard Development Company, L.P.;
   6 karl  1.95  // IBM Corp.; EMC Corporation, The Open Group.
   7 karl  1.148 // Copyright (c) 2004 BMC Software; Hewlett-Packard Development Company, L.P.;
   8             // IBM Corp.; EMC Corporation; VERITAS Software Corporation; The Open Group.
   9 karl  1.156 // Copyright (c) 2005 Hewlett-Packard Development Company, L.P.; IBM Corp.;
  10             // EMC Corporation; VERITAS Software Corporation; The Open Group.
  11 karl  1.196 // Copyright (c) 2006 Hewlett-Packard Development Company, L.P.; IBM Corp.;
  12             // EMC Corporation; Symantec Corporation; The Open Group.
  13 kumpf 1.1   //
  14             // Permission is hereby granted, free of charge, to any person obtaining a copy
  15 kumpf 1.47  // of this software and associated documentation files (the "Software"), to
  16             // deal in the Software without restriction, including without limitation the
  17             // rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
  18 kumpf 1.1   // sell copies of the Software, and to permit persons to whom the Software is
  19             // furnished to do so, subject to the following conditions:
  20 karl  1.196 // 
  21 kumpf 1.47  // THE ABOVE COPYRIGHT NOTICE AND THIS PERMISSION NOTICE SHALL BE INCLUDED IN
  22 kumpf 1.1   // ALL COPIES OR SUBSTANTIAL PORTIONS OF THE SOFTWARE. THE SOFTWARE IS PROVIDED
  23             // "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT
  24 kumpf 1.47  // LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
  25             // PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
  26             // HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
  27 kumpf 1.1   // ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
  28             // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
  29             //
  30             //==============================================================================
  31             //
  32             // Author: Nitin Upasani, Hewlett-Packard Company (Nitin_Upasani@hp.com)
  33             //
  34 dj.gorey 1.135 // Modified By:  Carol Ann Krug Graves, Hewlett-Packard Company
  35 kumpf    1.86  //                   (carolann_graves@hp.com)
  36 a.arora  1.136 //               Ben Heilbronn, Hewlett-Packard Company (ben_heilbronn@hp.com)
  37                //               Yi Zhou, Hewlett-Packard Company (yi_zhou@hp.com)
  38 david    1.71  //               Dave Rosckes (rosckes@us.ibm.com)
  39 a.arora  1.136 //               Roger Kumpf, Hewlett-Packard Company (roger_kumpf@hp.com)
  40                //               Seema Gupta (gseema@in.ibm.com for PEP135)
  41                //               Dan Gorey, IBM (djgorey@us.ibm.com)
  42                //               Amit K Arora, IBM (amita@in.ibm.com) for Bug#1730
  43 a.arora  1.140 //               Alagaraja Ramasubramanian (alags_raj@in.ibm.com) for Bug#1090
  44 gs.keenan 1.155 //               Sean Keenan, Hewlett-Packard Company (sean.keenan@hp.com)
  45 david.dillard 1.174 //               David Dillard, VERITAS Software Corp.
  46                     //                  (david.dillard@veritas.com)
  47 aruran.ms     1.181 //               Aruran, IBM (ashanmug@in.ibm.com) for Bug#3603
  48 kumpf         1.1   //
  49                     //%/////////////////////////////////////////////////////////////////////////////
  50                     
  51                     #include <Pegasus/Common/Config.h>
  52 kumpf         1.17  #include <Pegasus/Common/Constants.h>
  53 kumpf         1.204 #include <Pegasus/Common/CIMInstance.h>
  54 kumpf         1.60  #include <Pegasus/Common/ArrayInternal.h>
  55 kumpf         1.1   #include <Pegasus/Common/CIMDateTime.h>
  56                     #include <Pegasus/Common/CIMProperty.h>
  57                     #include <Pegasus/Common/MessageQueue.h>
  58 kumpf         1.73  #ifdef PEGASUS_INDICATION_PERFINST
  59                     #include <Pegasus/Common/Stopwatch.h>
  60                     #endif
  61 kumpf         1.1   #include <Pegasus/Common/System.h>
  62                     #include <Pegasus/Common/Tracer.h>
  63 kumpf         1.6   #include <Pegasus/Common/XmlWriter.h>
  64 kumpf         1.36  #include <Pegasus/Common/PegasusVersion.h>
  65 kumpf         1.195 #include <Pegasus/Common/AcceptLanguageList.h>
  66                     #include <Pegasus/Common/ContentLanguageList.h>
  67 kumpf         1.194 #include <Pegasus/Common/LanguageParser.h>
  68 dj.gorey      1.135 #include <Pegasus/Common/OperationContextInternal.h>
  69 kumpf         1.114 // l10n
  70                     #include <Pegasus/Common/MessageLoader.h>
  71                     #include <Pegasus/Common/String.h>
  72 yi.zhou       1.157 #include <Pegasus/Common/IndicationFormatter.h>
  73 kumpf         1.12  #include <Pegasus/Server/ProviderRegistrationManager/ProviderRegistrationManager.h>
  74 chuck         1.149 #include <Pegasus/Query/QueryExpression/QueryExpression.h>
  75                     #include <Pegasus/Query/QueryCommon/QueryException.h>
  76                     #include <Pegasus/Repository/RepositoryQueryContext.h>
  77 kumpf         1.1   
  78 kumpf         1.114 #include "IndicationConstants.h"
  79                     #include "IndicationMessageConstants.h"
  80                     #include "SubscriptionRepository.h"
  81                     #include "SubscriptionTable.h"
  82 kumpf         1.1   #include "IndicationService.h"
  83                     
  84 humberto      1.78  
  85 kumpf         1.1   PEGASUS_USING_STD;
  86                     
  87                     PEGASUS_NAMESPACE_BEGIN
  88                     
  89 kumpf         1.55  // ATTN-RK-20020730: Temporary hack to fix Windows build
  90                     Boolean ContainsCIMName(const Array<CIMName>& a, const CIMName& x)
  91                     {
  92                         Uint32 n = a.size();
  93                     
  94                         for (Uint32 i = 0; i < n; i++)
  95                         {
  96                             if (a[i].equal(x))
  97                                 return true;
  98                         }
  99                     
 100                         return false;
 101                     }
 102                     
 103 kumpf         1.44  Mutex IndicationService::_mutex;
 104                     
 105 kumpf         1.12  IndicationService::IndicationService (
 106                         CIMRepository * repository,
 107 kumpf         1.14      ProviderRegistrationManager * providerRegManager)
 108 carolann.graves 1.145     : MessageQueueService (PEGASUS_QUEUENAME_INDICATIONSERVICE,
 109 kumpf           1.17              MessageQueue::getNextQueueId ()),
 110 chuck           1.149       _providerRegManager (providerRegManager),
 111                             _cimRepository(repository)
 112 kumpf           1.11  {
 113 kumpf           1.94      _enableSubscriptionsForNonprivilegedUsers = false;
 114 carolann.graves 1.198     _authenticationEnabled = true;
 115 kumpf           1.94  
 116                           try
 117                           {
 118                               // Determine the value for the configuration parameter
 119                               // enableSubscriptionsForNonprivilegedUsers
 120                               ConfigManager* configManager = ConfigManager::getInstance();
 121                       
 122 kumpf           1.202         if (ConfigManager::parseBooleanValue(
 123                                   configManager->getCurrentValue("enableAuthentication")))
 124 kumpf           1.94          {
 125 kumpf           1.202             _enableSubscriptionsForNonprivilegedUsers =
 126                                       ConfigManager::parseBooleanValue(
 127                                           configManager->getCurrentValue(
 128                                               "enableSubscriptionsForNonprivilegedUsers"));
 129 kumpf           1.94          }
 130                               else
 131                               {
 132 carolann.graves 1.198             _authenticationEnabled = false;
 133 kumpf           1.94              // Authentication needs to be enabled to perform authorization
 134                                   // tests.
 135                                   _enableSubscriptionsForNonprivilegedUsers = true;
 136                               }
 137                            }
 138                            catch (...)
 139                            {
 140                               // If there is an error reading the configuration file then
 141                               // the value of _enableSubscriptionsForNonprivilegedUsers will
 142                               // default to false (i.e., the more restrictive security
 143                               // setting.
 144 dj.gorey        1.135         PEG_TRACE_STRING (TRC_INDICATION_SERVICE, Tracer::LEVEL4,
 145 kumpf           1.94             "Failure attempting to read configuration parameters during initialization.");
 146                            }
 147                       
 148 dj.gorey        1.135     Tracer::trace (TRC_INDICATION_SERVICE, Tracer::LEVEL4,
 149                               "Value of _enableSubscriptionsForNonprivilegedUsers is %d",
 150 kumpf           1.94          _enableSubscriptionsForNonprivilegedUsers);
 151                       
 152 kumpf           1.38      try
 153                           {
 154 kumpf           1.114         //
 155                               //  Create Subscription Repository
 156                               //
 157                               _subscriptionRepository = new SubscriptionRepository (repository);
 158                       
 159                               //
 160                               //  Create Subscription Table
 161                               //
 162                               _subscriptionTable = new SubscriptionTable (_subscriptionRepository);
 163                       
 164 kumpf           1.94          // Initialize the Indication Service
 165 kumpf           1.38          _initialize ();
 166                           }
 167 kumpf           1.94      catch (Exception & e)
 168 kumpf           1.38      {
 169 dj.gorey        1.135         PEG_TRACE_STRING (TRC_INDICATION_SERVICE_INTERNAL, Tracer::LEVEL2,
 170 kumpf           1.105            "Exception caught in attempting to initialize Indication Service: " +
 171                                   e.getMessage ());
 172 kumpf           1.38      }
 173 kumpf           1.11  }
 174 kumpf           1.1   
 175 kumpf           1.11  IndicationService::~IndicationService (void)
 176                       {
 177 kumpf           1.120     delete _subscriptionTable;
 178                           delete _subscriptionRepository;
 179 kumpf           1.11  }
 180 kumpf           1.1   
 181 kumpf           1.11  void IndicationService::_handle_async_request(AsyncRequest *req)
 182                       {
 183                           if ( req->getType() == async_messages::CIMSERVICE_STOP )
 184                           {
 185                               req->op->processing();
 186 kumpf           1.73  
 187 kumpf           1.11          //
 188                               //  Call _terminate
 189                               //
 190                               _terminate ();
 191 kumpf           1.97  
 192                               handle_CimServiceStop(static_cast<CimServiceStop *>(req));
 193 kumpf           1.11      }
 194 kumpf           1.43      else if (req->getType () == async_messages::CIMSERVICE_START)
 195 kumpf           1.11      {
 196                               req->op->processing ();
 197 kumpf           1.1   
 198 kumpf           1.11          handle_CimServiceStart (static_cast <CimServiceStart *> (req));
 199                           }
 200                           else if ( req->getType() == async_messages::ASYNC_LEGACY_OP_START )
 201                           {
 202 dj.gorey        1.135        try
 203 mday            1.40         {
 204 kumpf           1.137           req->op->processing();
 205 chip            1.162           Message *legacy =
 206 kumpf           1.137               (static_cast<AsyncLegacyOperationStart *>(req)->get_action());
 207                                 legacy->put_async(req);
 208 chip            1.162 
 209 kumpf           1.137           handleEnqueue(legacy);
 210 mday            1.40         }
 211                              catch(Exception & )
 212                              {
 213 chip            1.162            PEG_TRACE_STRING(TRC_INDICATION_SERVICE, Tracer::LEVEL3,
 214 kumpf           1.137                "Caught Exception in IndicationService while handling a wrapped legacy  message ");
 215                                      _make_response(req, async_results::CIM_NAK );
 216 mday            1.40         }
 217 dj.gorey        1.135 
 218 kumpf           1.11          return;
 219                           }
 220                           else
 221 carolann.graves 1.145         MessageQueueService::_handle_async_request (req);
 222 kumpf           1.11  }
 223 kumpf           1.1   
 224 kumpf           1.11  void IndicationService::handleEnqueue(Message* message)
 225                       {
 226 kumpf           1.73  #ifdef PEGASUS_INDICATION_PERFINST
 227                           Stopwatch stopWatch;
 228 chip            1.162 
 229                           stopWatch.start();
 230 kumpf           1.73  #endif
 231 dj.gorey        1.135 
 232 chuck           1.75  // l10n
 233 kumpf           1.137     // Set the client's requested language into this service thread.
 234                           // This will allow functions in this service to return messages
 235                           // in the correct language.
 236                           CIMMessage * msg = dynamic_cast<CIMMessage *>(message);
 237                           if (msg != NULL)
 238                           {
 239                               if (msg->thread_changed())
 240                               {
 241 kumpf           1.195             AcceptLanguageList *langs =  new AcceptLanguageList
 242 kumpf           1.137                 (((AcceptLanguageListContainer)msg->operationContext.get
 243                                       (AcceptLanguageListContainer::NAME)).getLanguages());
 244                                   Thread::setLanguages(langs);
 245 chuck           1.81          }
 246 kumpf           1.137     }
 247                           else
 248                           {
 249                               Thread::clearLanguages();
 250 chip            1.162     }
 251 kumpf           1.137 
 252                           switch(message->getType())
 253                           {
 254                               case CIM_GET_INSTANCE_REQUEST_MESSAGE:
 255 chip            1.162             try
 256 kumpf           1.137             {
 257                                       _handleGetInstanceRequest(message);
 258                                   }
 259 chip            1.162             catch( ... )
 260 kumpf           1.137             {
 261                                   ;
 262                                   }
 263                                   break;
 264                       
 265                               case CIM_ENUMERATE_INSTANCES_REQUEST_MESSAGE:
 266 chip            1.162             try
 267 kumpf           1.137             {
 268                                       _handleEnumerateInstancesRequest(message);
 269                                   }
 270 chip            1.162             catch( ... )
 271 kumpf           1.137             {
 272                                   ;
 273                                   }
 274                                   break;
 275                       
 276                               case CIM_ENUMERATE_INSTANCE_NAMES_REQUEST_MESSAGE:
 277 chip            1.162             try
 278 kumpf           1.137             {
 279                                       _handleEnumerateInstanceNamesRequest(message);
 280                                   }
 281 chip            1.162             catch( ... )
 282 kumpf           1.137             {
 283                                   ;
 284                                   }
 285                                   break;
 286                       
 287                               case CIM_CREATE_INSTANCE_REQUEST_MESSAGE:
 288                                   try
 289                                   {
 290                                       _handleCreateInstanceRequest(message);
 291                                   }
 292                                   catch( ... )
 293                                   {
 294                                   ;
 295                                   }
 296                                   break;
 297                       
 298                               case CIM_MODIFY_INSTANCE_REQUEST_MESSAGE:
 299                                   try
 300                                   {
 301                                       _handleModifyInstanceRequest(message);
 302                                   }
 303 kumpf           1.137             catch( ... )
 304                                   {
 305                                   ;
 306                                   }
 307                                   break;
 308                       
 309                               case CIM_DELETE_INSTANCE_REQUEST_MESSAGE:
 310                                   try
 311                                   {
 312                                       _handleDeleteInstanceRequest(message);
 313                                   }
 314                                   catch( ... )
 315                                   {
 316                                   ;
 317                                   }
 318                                   break;
 319                       
 320                               case CIM_PROCESS_INDICATION_REQUEST_MESSAGE:
 321                                   try
 322                                   {
 323                                       _handleProcessIndicationRequest(message);
 324 kumpf           1.137             }
 325                                   catch( ... )
 326                                   {
 327                                   ;
 328                                   }
 329                                   break;
 330                       
 331                               case CIM_NOTIFY_PROVIDER_REGISTRATION_REQUEST_MESSAGE:
 332                                   try
 333                                   {
 334                                       _handleNotifyProviderRegistrationRequest(message);
 335                                   }
 336                                   catch( ... )
 337                                   {
 338                                   ;
 339                                   }
 340                                   break;
 341 chuck           1.75  
 342 kumpf           1.137         case CIM_NOTIFY_PROVIDER_TERMINATION_REQUEST_MESSAGE:
 343                                   try
 344                                   {
 345                                       _handleNotifyProviderTerminationRequest(message);
 346                                   }
 347                                   catch( ... )
 348                                   {
 349                                   ;
 350                                   }
 351                                   break;
 352 kumpf           1.96  
 353 kumpf           1.105       case CIM_NOTIFY_PROVIDER_ENABLE_REQUEST_MESSAGE:
 354                                try
 355                                {
 356                                    _handleNotifyProviderEnableRequest (message);
 357                                }
 358                                catch (...)
 359                                {
 360                                    ;
 361                                }
 362                                break;
 363                       
 364 carolann.graves 1.198       case CIM_NOTIFY_PROVIDER_FAIL_REQUEST_MESSAGE:
 365                                try
 366                                {
 367                                    _handleNotifyProviderFailRequest (message);
 368                                }
 369                                catch (...)
 370                                {
 371                                    ;
 372                                }
 373                                break;
 374                       
 375 mday            1.40        default:
 376 kumpf           1.137         //
 377                               //  A message type not supported by the Indication Service
 378                               //  Should not reach here
 379                               //
 380                               // << Mon Apr 29 16:29:10 2002 mdd >>
 381                               PEG_TRACE_STRING(TRC_INDICATION_SERVICE, Tracer::LEVEL3,
 382                                   "IndicationService::handleEnqueue(msg *) rcv'd unsupported msg "
 383 a.arora         1.136             + String(MessageTypeToString(message->getType())));
 384                       
 385                               // Note: not setting Content-Language in the response
 386 a.dunfey        1.134         CIMRequestMessage* cimRequest =
 387 kumpf           1.137             dynamic_cast<CIMRequestMessage*>(message);
 388 a.dunfey        1.134         CIMResponseMessage* response = cimRequest->buildResponse();
 389                               response->cimException = PEGASUS_CIM_EXCEPTION_L(
 390                                   CIM_ERR_NOT_SUPPORTED,
 391 chip            1.162             MessageLoaderParms(
 392 kumpf           1.137                 "IndicationService.IndicationService.UNSUPPORTED_OPERATION",
 393                                       "The requested operation is not supported or not recognized "
 394                                       "by the indication service.")),
 395 a.dunfey        1.134 
 396 carolann.graves 1.145         _enqueueResponse (cimRequest, response);
 397 a.arora         1.136         break;
 398 kumpf           1.137     }
 399 kumpf           1.73  
 400                       #ifdef PEGASUS_INDICATION_PERFINST
 401 david.dillard   1.163     stopWatch.stop();
 402 kumpf           1.73  
 403 dj.gorey        1.135     Tracer::trace (TRC_INDICATION_SERVICE_INTERNAL, Tracer::LEVEL2,
 404 chip            1.162         "%s: %.3f seconds", MessageTypeToString(message->getType()), stopWatch.getElapsed());
 405 kumpf           1.73  #endif
 406 dj.gorey        1.135 
 407 mday            1.40     delete message;
 408 kumpf           1.11  }
 409 kumpf           1.1   
 410 kumpf           1.11  void IndicationService::handleEnqueue(void)
 411                       {
 412                           Message * message = dequeue();
 413 kumpf           1.1   
 414 kumpf           1.11      PEGASUS_ASSERT(message != 0);
 415                           handleEnqueue(message);
 416                       }
 417 kumpf           1.1   
 418 kumpf           1.11  void IndicationService::_initialize (void)
 419                       {
 420 kumpf           1.114     PEG_METHOD_ENTER (TRC_INDICATION_SERVICE, "IndicationService::_initialize");
 421 dj.gorey        1.135 
 422 kumpf           1.73  #ifdef PEGASUS_INDICATION_PERFINST
 423                           Stopwatch stopWatch;
 424 chip            1.162 
 425                           stopWatch.start();
 426 kumpf           1.73  #endif
 427                       
 428 kumpf           1.46      Array <CIMInstance> activeSubscriptions;
 429                           Array <CIMInstance> noProviderSubscriptions;
 430 kumpf           1.114     Boolean invalidInstance = false;
 431 kumpf           1.1   
 432 kumpf           1.11      //
 433                           //  Find required services
 434 kumpf           1.38      //  NOTE: Indication Service expects to find exactly one Provider Manager
 435                           //  Service and exactly one Handler Manager Service
 436 kumpf           1.11      //
 437                           Array <Uint32> pmservices;
 438 kumpf           1.30      find_services (PEGASUS_QUEUENAME_PROVIDERMANAGER_CPP, 0, 0, &pmservices);
 439 mike            1.203     Threads::yield ();
 440 kumpf           1.37      PEGASUS_ASSERT (pmservices.size () == 1);
 441                           _providerManager = pmservices [0];
 442                       
 443 kumpf           1.11      Array <Uint32> hmservices;
 444 kumpf           1.30      find_services (PEGASUS_QUEUENAME_INDHANDLERMANAGER, 0, 0, &hmservices);
 445 mike            1.203     Threads::yield ();
 446 kumpf           1.37      PEGASUS_ASSERT (hmservices.size () == 1);
 447                           _handlerService = hmservices [0];
 448                       
 449 kumpf           1.11      //
 450 kumpf           1.115     //  Set arrays of valid and supported property values
 451                           //
 452                           //  Note: Valid values are defined by the CIM Event Schema MOF
 453                           //  Supported values are a subset of the valid values
 454 dj.gorey        1.135     //  Some valid values, as defined in the MOF, are not currently supported
 455 kumpf           1.115     //  by the Pegasus IndicationService
 456 kumpf           1.32      //
 457                           _validStates.append (_STATE_UNKNOWN);
 458                           _validStates.append (_STATE_OTHER);
 459                           _validStates.append (_STATE_ENABLED);
 460                           _validStates.append (_STATE_ENABLEDDEGRADED);
 461                           _validStates.append (_STATE_DISABLED);
 462 kumpf           1.115     _supportedStates.append (_STATE_ENABLED);
 463                           _supportedStates.append (_STATE_DISABLED);
 464 kumpf           1.32      _validRepeatPolicies.append (_POLICY_UNKNOWN);
 465                           _validRepeatPolicies.append (_POLICY_OTHER);
 466                           _validRepeatPolicies.append (_POLICY_NONE);
 467                           _validRepeatPolicies.append (_POLICY_SUPPRESS);
 468                           _validRepeatPolicies.append (_POLICY_DELAY);
 469 kumpf           1.115     _supportedRepeatPolicies.append (_POLICY_UNKNOWN);
 470                           _supportedRepeatPolicies.append (_POLICY_OTHER);
 471                           _supportedRepeatPolicies.append (_POLICY_NONE);
 472                           _supportedRepeatPolicies.append (_POLICY_SUPPRESS);
 473                           _supportedRepeatPolicies.append (_POLICY_DELAY);
 474 kumpf           1.32      _validErrorPolicies.append (_ERRORPOLICY_OTHER);
 475                           _validErrorPolicies.append (_ERRORPOLICY_IGNORE);
 476                           _validErrorPolicies.append (_ERRORPOLICY_DISABLE);
 477                           _validErrorPolicies.append (_ERRORPOLICY_REMOVE);
 478 kumpf           1.115     _supportedErrorPolicies.append (_ERRORPOLICY_IGNORE);
 479                           _supportedErrorPolicies.append (_ERRORPOLICY_DISABLE);
 480                           _supportedErrorPolicies.append (_ERRORPOLICY_REMOVE);
 481 kumpf           1.32      _validPersistenceTypes.append (_PERSISTENCE_OTHER);
 482                           _validPersistenceTypes.append (_PERSISTENCE_PERMANENT);
 483                           _validPersistenceTypes.append (_PERSISTENCE_TRANSIENT);
 484 kumpf           1.115     _supportedPersistenceTypes.append (_PERSISTENCE_PERMANENT);
 485                           _supportedPersistenceTypes.append (_PERSISTENCE_TRANSIENT);
 486 yi.zhou         1.193     _validSNMPVersion.append (_SNMPV1_TRAP);
 487                           _validSNMPVersion.append (_SNMPV2C_TRAP);
 488                           _validSNMPVersion.append (_SNMPV2C_INFORM);
 489                           _validSNMPVersion.append (_SNMPV3_TRAP);
 490                           _validSNMPVersion.append (_SNMPV3_INFORM);
 491                           _supportedSNMPVersion.append (_SNMPV1_TRAP);
 492                           _supportedSNMPVersion.append (_SNMPV2C_TRAP);
 493 kumpf           1.32  
 494                           //
 495 carolann.graves 1.188     //  Set arrays of names of supported properties for each class
 496                           //
 497                           //  Currently, all properties in these classes in CIM 2.5 through CIM 2.9
 498                           //  final schemas are supported.  If support for a new class is added, a new
 499                           //  list of names of supported properties for the class must be added as a
 500                           //  private member to the IndicationService class, and the array values
 501                           //  must be appended here.  When support for a new property is added, the
 502                           //  property name must be appended to the appropriate array(s) here.
 503                           //
 504                           _supportedSubscriptionProperties.append (_PROPERTY_FILTER);
 505                           _supportedSubscriptionProperties.append (_PROPERTY_HANDLER);
 506                           _supportedSubscriptionProperties.append (_PROPERTY_ONFATALERRORPOLICY);
 507                           _supportedSubscriptionProperties.append (_PROPERTY_OTHERONFATALERRORPOLICY);
 508                           _supportedSubscriptionProperties.append
 509                               (_PROPERTY_FAILURETRIGGERTIMEINTERVAL);
 510                           _supportedSubscriptionProperties.append (_PROPERTY_STATE);
 511                           _supportedSubscriptionProperties.append (_PROPERTY_OTHERSTATE);
 512                           _supportedSubscriptionProperties.append (_PROPERTY_LASTCHANGE);
 513                           _supportedSubscriptionProperties.append (_PROPERTY_DURATION);
 514                           _supportedSubscriptionProperties.append (_PROPERTY_STARTTIME);
 515                           _supportedSubscriptionProperties.append (_PROPERTY_TIMEREMAINING);
 516 carolann.graves 1.188     _supportedSubscriptionProperties.append
 517                               (_PROPERTY_REPEATNOTIFICATIONPOLICY);
 518                           _supportedSubscriptionProperties.append
 519                               (_PROPERTY_OTHERREPEATNOTIFICATIONPOLICY);
 520                           _supportedSubscriptionProperties.append
 521                               (_PROPERTY_REPEATNOTIFICATIONINTERVAL);
 522                           _supportedSubscriptionProperties.append (_PROPERTY_REPEATNOTIFICATIONGAP);
 523                           _supportedSubscriptionProperties.append (_PROPERTY_REPEATNOTIFICATIONCOUNT);
 524                       
 525                           _supportedFormattedSubscriptionProperties =
 526                               _supportedSubscriptionProperties;
 527                           _supportedFormattedSubscriptionProperties.append
 528                               (_PROPERTY_TEXTFORMATOWNINGENTITY);
 529                           _supportedFormattedSubscriptionProperties.append
 530                               (_PROPERTY_TEXTFORMATID);
 531                           _supportedFormattedSubscriptionProperties.append
 532                               (_PROPERTY_TEXTFORMAT);
 533                           _supportedFormattedSubscriptionProperties.append
 534                               (_PROPERTY_TEXTFORMATPARAMETERS);
 535                       
 536                           _supportedFilterProperties.append (_PROPERTY_CAPTION);
 537 carolann.graves 1.188     _supportedFilterProperties.append (_PROPERTY_DESCRIPTION);
 538                           _supportedFilterProperties.append (_PROPERTY_ELEMENTNAME);
 539                           _supportedFilterProperties.append (_PROPERTY_SYSTEMCREATIONCLASSNAME);
 540                           _supportedFilterProperties.append (_PROPERTY_SYSTEMNAME);
 541                           _supportedFilterProperties.append (_PROPERTY_CREATIONCLASSNAME);
 542                           _supportedFilterProperties.append (_PROPERTY_NAME);
 543                           _supportedFilterProperties.append (_PROPERTY_SOURCENAMESPACE);
 544                           _supportedFilterProperties.append (_PROPERTY_QUERY);
 545                           _supportedFilterProperties.append (_PROPERTY_QUERYLANGUAGE);
 546                       
 547                           Array <CIMName> commonListenerDestinationProperties;
 548                           commonListenerDestinationProperties.append (_PROPERTY_CAPTION);
 549                           commonListenerDestinationProperties.append (_PROPERTY_DESCRIPTION);
 550                           commonListenerDestinationProperties.append (_PROPERTY_ELEMENTNAME);
 551                           commonListenerDestinationProperties.append
 552                               (_PROPERTY_SYSTEMCREATIONCLASSNAME);
 553                           commonListenerDestinationProperties.append (_PROPERTY_SYSTEMNAME);
 554                           commonListenerDestinationProperties.append (_PROPERTY_CREATIONCLASSNAME);
 555                           commonListenerDestinationProperties.append (_PROPERTY_NAME);
 556                           commonListenerDestinationProperties.append (_PROPERTY_PERSISTENCETYPE);
 557                           commonListenerDestinationProperties.append (_PROPERTY_OTHERPERSISTENCETYPE);
 558 carolann.graves 1.188 
 559                           _supportedCIMXMLHandlerProperties = commonListenerDestinationProperties;
 560                           _supportedCIMXMLHandlerProperties.append (_PROPERTY_OWNER);
 561                           _supportedCIMXMLHandlerProperties.append
 562                               (PEGASUS_PROPERTYNAME_LSTNRDST_DESTINATION);
 563                       
 564                           _supportedCIMXMLListenerDestinationProperties =
 565                               commonListenerDestinationProperties;
 566                           _supportedCIMXMLListenerDestinationProperties.append
 567                               (PEGASUS_PROPERTYNAME_LSTNRDST_DESTINATION);
 568                       
 569                           _supportedSNMPHandlerProperties = commonListenerDestinationProperties;
 570                           _supportedSNMPHandlerProperties.append (_PROPERTY_OWNER);
 571                           _supportedSNMPHandlerProperties.append
 572                               (PEGASUS_PROPERTYNAME_LSTNRDST_TARGETHOST);
 573                           _supportedSNMPHandlerProperties.append (_PROPERTY_TARGETHOSTFORMAT);
 574                           _supportedSNMPHandlerProperties.append (_PROPERTY_OTHERTARGETHOSTFORMAT);
 575                           _supportedSNMPHandlerProperties.append (_PROPERTY_PORTNUMBER);
 576                           _supportedSNMPHandlerProperties.append (_PROPERTY_SNMPVERSION);
 577                           _supportedSNMPHandlerProperties.append (_PROPERTY_SNMPSECURITYNAME);
 578                           _supportedSNMPHandlerProperties.append (_PROPERTY_SNMPENGINEID);
 579 carolann.graves 1.188 
 580                           _supportedSyslogListenerDestinationProperties =
 581                               commonListenerDestinationProperties;
 582                       
 583                           _supportedEmailListenerDestinationProperties =
 584                               commonListenerDestinationProperties;
 585                           _supportedEmailListenerDestinationProperties.append
 586                               (PEGASUS_PROPERTYNAME_LSTNRDST_MAILTO);
 587                           _supportedEmailListenerDestinationProperties.append
 588                               (PEGASUS_PROPERTYNAME_LSTNRDST_MAILCC);
 589                           _supportedEmailListenerDestinationProperties.append
 590                               (PEGASUS_PROPERTYNAME_LSTNRDST_MAILSUBJECT);
 591                       
 592                           //
 593 kumpf           1.11      //  Get existing active subscriptions from each namespace in the repository
 594                           //
 595 dj.gorey        1.135     invalidInstance = _subscriptionRepository->getActiveSubscriptions
 596 kumpf           1.114         (activeSubscriptions);
 597 kumpf           1.11      noProviderSubscriptions.clear ();
 598 kumpf           1.1   
 599 carolann.graves 1.192     Tracer::trace (TRC_INDICATION_SERVICE, Tracer::LEVEL4,
 600                               "%u active subscription(s) found on initialization",
 601                               activeSubscriptions.size ());
 602                       
 603 kumpf           1.11      String condition;
 604 kumpf           1.124     String query;
 605 kumpf           1.11      String queryLanguage;
 606                           CIMPropertyList propertyList;
 607 kumpf           1.16      Array <ProviderClassList> indicationProviders;
 608 kumpf           1.1   
 609 kumpf           1.83      for (Uint32 i = 0; i < activeSubscriptions.size (); i++)
 610 kumpf           1.11      {
 611                               //
 612                               //  Check for expired subscription
 613                               //
 614 carolann.graves 1.192         try
 615                               {
 616 dj.gorey        1.135             if (_isExpired (activeSubscriptions [i]))
 617                                   {
 618 carolann.graves 1.192                 CIMObjectPath path = activeSubscriptions [i].getPath ();
 619                       
 620                                       Tracer::trace (TRC_INDICATION_SERVICE, Tracer::LEVEL4,
 621                                           "Deleting expired subscription on initialization: %s",
 622                                           (const char *) path.toString ().getCString ());
 623                       
 624 dj.gorey        1.135                 _deleteExpiredSubscription (path);
 625 carolann.graves 1.192                 // If subscription is expired delete the subscription
 626                                       // and continue on to the next one.
 627                                       continue;
 628 dj.gorey        1.135             }
 629 carolann.graves 1.192         }
 630                               catch (DateTimeOutOfRangeException& e)
 631 kumpf           1.11          {
 632 dj.gorey        1.135             //
 633                                   //  This instance from the repository is invalid
 634                                   //  Log a message and skip it
 635                                   //
 636 carolann.graves 1.191             Logger::put_l (Logger::STANDARD_LOG, System::CIMSERVER,
 637 dj.gorey        1.135                 Logger::WARNING,
 638 carolann.graves 1.191                 _MSG_INVALID_INSTANCE_KEY, _MSG_INVALID_INSTANCE,
 639 dj.gorey        1.135                 e.getMessage ());
 640 kumpf           1.11              continue;
 641                               }
 642 kumpf           1.1   
 643 kumpf           1.63          CIMNamespaceName sourceNameSpace;
 644 kumpf           1.73          Array <CIMName> indicationSubclasses;
 645 carolann.graves 1.186         _getCreateParams (activeSubscriptions [i], indicationSubclasses,
 646                                   indicationProviders, propertyList, sourceNameSpace, condition,
 647                                   query, queryLanguage);
 648 kumpf           1.1   
 649 kumpf           1.11          if (indicationProviders.size () == 0)
 650                               {
 651 carolann.graves 1.192             Tracer::trace (TRC_INDICATION_SERVICE, Tracer::LEVEL4,
 652                                       "No providers found for subscription on initialization: %s",
 653                                       (const char *)
 654                                       activeSubscriptions [i].getPath ().toString ().getCString ());
 655                       
 656 kumpf           1.11              //
 657                                   //  There are no providers that can support this subscription
 658 kumpf           1.19              //  Implement the subscription's On Fatal Error Policy
 659                                   //  If subscription is not disabled or removed,
 660 kumpf           1.105             //  Append this subscription to no provider list and
 661                                   //  Insert entries into the subscription hash tables
 662 kumpf           1.11              //
 663 dj.gorey        1.135             if (!_subscriptionRepository->reconcileFatalError
 664 kumpf           1.114                 (activeSubscriptions [i]))
 665 kumpf           1.19              {
 666                                       noProviderSubscriptions.append (activeSubscriptions [i]);
 667 kumpf           1.105 
 668 kumpf           1.114                 _subscriptionTable->insertSubscription (activeSubscriptions [i],
 669 kumpf           1.105                     indicationProviders, indicationSubclasses, sourceNameSpace);
 670 kumpf           1.19              }
 671 kumpf           1.11              continue;
 672                               }
 673 dj.gorey        1.135 
 674 kumpf           1.11          //
 675 kumpf           1.38          //  Send Create request message to each provider
 676 kumpf           1.39          //  NOTE: These Create requests are not associated with a user request,
 677                               //  so there is no associated authType or userName
 678 kumpf           1.15          //  The Creator from the subscription instance is used for userName,
 679                               //  and authType is not set
 680 kumpf           1.11          //
 681 kumpf           1.46          CIMInstance instance = activeSubscriptions [i];
 682 kumpf           1.80          String creator;
 683                               if (!_getCreator (instance, creator))
 684                               {
 685                                   //
 686                                   //  This instance from the repository is corrupted
 687 kumpf           1.114             //  Skip it
 688 kumpf           1.80              //
 689 kumpf           1.114             invalidInstance = true;
 690 carolann.graves 1.144             continue;
 691 kumpf           1.80          }
 692 chuck           1.77  
 693 dj.gorey        1.135 //l10n start
 694 kumpf           1.137         // Get the language tags that were saved with the subscription instance
 695 kumpf           1.195         AcceptLanguageList acceptLangs;
 696 kumpf           1.137         Uint32 propIndex = instance.findProperty
 697                                   (PEGASUS_PROPERTYNAME_INDSUB_ACCEPTLANGS);
 698                               if (propIndex != PEG_NOT_FOUND)
 699 chip            1.162         {
 700 kumpf           1.194             String acceptLangsString;
 701                                   instance.getProperty(propIndex).getValue().get(acceptLangsString);
 702                                   if (acceptLangsString.size())
 703                                   {
 704                                       acceptLangs = LanguageParser::parseAcceptLanguageHeader(
 705                                           acceptLangsString);
 706                                   }
 707 chip            1.162         }
 708 kumpf           1.195         ContentLanguageList contentLangs;
 709 kumpf           1.137         propIndex = instance.findProperty
 710                                   (PEGASUS_PROPERTYNAME_INDSUB_CONTENTLANGS);
 711                               if (propIndex != PEG_NOT_FOUND)
 712 chip            1.162         {
 713 kumpf           1.194             String contentLangsString;
 714                                   instance.getProperty(propIndex).getValue().get(contentLangsString);
 715                                   if (contentLangsString.size())
 716                                   {
 717                                       contentLangs = LanguageParser::parseContentLanguageHeader(
 718                                           contentLangsString);
 719                                   }
 720 chuck           1.77          }
 721 dj.gorey        1.135 // l10n end
 722 chuck           1.75  
 723 carolann.graves 1.172         //
 724                               //  Send Create request message to each provider
 725                               //  Note: SendWait is used instead of SendAsync.  Initialization must
 726                               //  deal with multiple subscriptions, each with multiple providers.
 727                               //  Using SendWait eliminates the need for a callback and the necessity
 728                               //  to handle multiple levels of aggregation, which would add
 729                               //  significant complexity.  Since initialization cannot complete
 730                               //  anyway until responses have been received for all subscriptions,
 731                               //  from all the providers, use of SendWait should not cause a
 732                               //  significant performance issue.
 733                               //
 734                               Array <ProviderClassList> acceptedProviders;
 735 david.dillard   1.174         acceptedProviders = _sendWaitCreateRequests
 736 carolann.graves 1.172             (indicationProviders, sourceNameSpace,
 737 kumpf           1.124             propertyList, condition, query, queryLanguage,
 738 dj.gorey        1.135             activeSubscriptions [i],
 739 kumpf           1.194             acceptLangs,
 740                                   contentLangs,
 741 kumpf           1.137             creator);
 742 kumpf           1.73  
 743 carolann.graves 1.172         if (acceptedProviders.size () == 0)
 744                               {
 745 carolann.graves 1.192             Tracer::trace (TRC_INDICATION_SERVICE, Tracer::LEVEL4,
 746                                       "No providers accepted subscription on initialization: %s",
 747                                       (const char *)
 748                                       activeSubscriptions [i].getPath ().toString ().getCString ());
 749                       
 750 carolann.graves 1.172             //
 751                                   //  No providers accepted the subscription
 752                                   //  Implement the subscription's On Fatal Error Policy
 753                                   //  If subscription is not disabled or removed, send alert and
 754                                   //  Insert entries into the subscription hash tables
 755                                   //
 756                                   if (!_subscriptionRepository->reconcileFatalError
 757                                       (activeSubscriptions [i]))
 758                                   {
 759                                       //
 760                                       //  Insert entries into the subscription hash tables
 761                                       //
 762                                       _subscriptionTable->insertSubscription
 763                                           (activeSubscriptions [i],
 764                                           acceptedProviders,
 765                                           indicationSubclasses,
 766                                           sourceNameSpace);
 767                       
 768                       #if 0
 769                                       //
 770                                       //  Send alert
 771 carolann.graves 1.172                 //
 772                                       //
 773                                       //  Send NoProviderAlertIndication to handler instances
 774                                       //  ATTN: NoProviderAlertIndication must be defined
 775                                       //
 776                                       Array <CIMInstance> subscriptions;
 777                                       subscriptions.append (activeSubscriptions [i]);
 778                                       CIMInstance indicationInstance = _createAlertInstance
 779                                           (_CLASS_NO_PROVIDER_ALERT, subscriptions);
 780 carolann.graves 1.158 
 781 carolann.graves 1.172                 Tracer::trace (TRC_INDICATION_SERVICE, Tracer::LEVEL4,
 782 carolann.graves 1.192                     "Sending NoProvider Alert for %u subscriptions",
 783 carolann.graves 1.172                     subscriptions.size ());
 784                                       _sendAlerts (subscriptions, indicationInstance);
 785                       #endif
 786                       
 787                                       //
 788                                       //  Get Subscription Filter Name and Handler Name
 789                                       //
 790                                       String logString = _getSubscriptionLogString
 791                                           (activeSubscriptions [i]);
 792                       
 793                                       //
 794                                       //  Log a message for the subscription
 795                                       //
 796                                       Logger::put_l (Logger::STANDARD_LOG, System::CIMSERVER,
 797                                           Logger::WARNING, _MSG_NO_PROVIDER_KEY, _MSG_NO_PROVIDER,
 798 carolann.graves 1.186                     logString,
 799                                           activeSubscriptions[i].getPath().getNameSpace().getString());
 800 carolann.graves 1.172             }
 801                               }
 802                               else
 803                               {
 804                                   //
 805                                   //  At least one provider accepted the subscription
 806                                   //  Insert entries into the subscription hash tables
 807                                   //
 808                                   _subscriptionTable->insertSubscription
 809                                       (activeSubscriptions [i],
 810                                       acceptedProviders,
 811                                       indicationSubclasses,
 812                                       sourceNameSpace);
 813                               }
 814 kumpf           1.11      }  // for each active subscription
 815 kumpf           1.1   
 816 kumpf           1.11      //
 817 kumpf           1.114     //  Log a message if any invalid instances were found
 818                           //
 819                           if (invalidInstance)
 820                           {
 821                               Logger::put_l (Logger::STANDARD_LOG, System::CIMSERVER, Logger::WARNING,
 822                                   _MSG_INVALID_INSTANCES_KEY, _MSG_INVALID_INSTANCES);
 823                           }
 824                       
 825                           //
 826 kumpf           1.87      //  Log a message for any subscription for which there is no longer any
 827 kumpf           1.11      //  provider
 828                           //
 829                           if (noProviderSubscriptions.size () > 0)
 830                           {
 831 kumpf           1.87  #if 0
 832 kumpf           1.11          //
 833                               //  Send NoProviderAlertIndication to handler instances
 834                               //  ATTN: NoProviderAlertIndication must be defined
 835                               //
 836                               CIMInstance indicationInstance = _createAlertInstance
 837                                   (_CLASS_NO_PROVIDER_ALERT, noProviderSubscriptions);
 838 kumpf           1.1   
 839 kumpf           1.73          Tracer::trace (TRC_INDICATION_SERVICE, Tracer::LEVEL4,
 840 carolann.graves 1.192             "Sending NoProvider Alert for %u subscriptions",
 841 kumpf           1.73              noProviderSubscriptions.size ());
 842 kumpf           1.11          _sendAlerts (noProviderSubscriptions, indicationInstance);
 843 kumpf           1.87  #endif
 844                               //
 845                               //  Log a message for each subscription
 846                               //
 847                               for (Uint32 i = 0; i < noProviderSubscriptions.size (); i++)
 848                               {
 849 kumpf           1.98              //
 850                                   //  Get Subscription Filter Name and Handler Name
 851                                   //
 852 dj.gorey        1.135             String logString = _getSubscriptionLogString
 853 kumpf           1.98                  (noProviderSubscriptions [i]);
 854                       
 855 dj.gorey        1.135             Logger::put_l (Logger::STANDARD_LOG, System::CIMSERVER,
 856 kumpf           1.87                  Logger::WARNING, _MSG_NO_PROVIDER_KEY, _MSG_NO_PROVIDER,
 857 carolann.graves 1.186                 logString,
 858                                       noProviderSubscriptions[i].getPath().getNameSpace().getString());
 859 kumpf           1.87          }
 860 kumpf           1.11      }
 861 kumpf           1.1   
 862 carolann.graves 1.172     //
 863                           //  Send message to tell Provider Manager that subscription
 864                           //  initialization is complete
 865                           //  Provider Manager calls providers' enableIndications method
 866                           //
 867                           _sendSubscriptionInitComplete ();
 868 carolann.graves 1.158 
 869 kumpf           1.73  #ifdef PEGASUS_INDICATION_PERFINST
 870 chip            1.162     stopWatch.stop();
 871 kumpf           1.73  
 872                           Tracer::trace (TRC_INDICATION_SERVICE_INTERNAL, Tracer::LEVEL2,
 873 chip            1.162         "%s: %.3f seconds", "Initialize", stopWatch.getElapsed());
 874 kumpf           1.73  #endif
 875                       
 876 kumpf           1.48      PEG_METHOD_EXIT ();
 877 kumpf           1.11  }
 878 kumpf           1.1   
 879 kumpf           1.11  void IndicationService::_terminate (void)
 880                       {
 881 kumpf           1.114     PEG_METHOD_ENTER (TRC_INDICATION_SERVICE, "IndicationService::_terminate");
 882                       
 883 kumpf           1.46      Array <CIMInstance> activeSubscriptions;
 884 kumpf           1.11      CIMInstance indicationInstance;
 885 kumpf           1.1   
 886 kumpf           1.11      //
 887 kumpf           1.87      //  A message is already logged that CIM Server is shutting down --
 888                           //  no need to log a message
 889                           //
 890                       #if 0
 891                           //
 892 kumpf           1.73      //  Get existing active subscriptions from hash table
 893 kumpf           1.11      //
 894                           activeSubscriptions = _getActiveSubscriptions ();
 895 kumpf           1.1   
 896 kumpf           1.73      if (activeSubscriptions.size () > 0)
 897                           {
 898                               //
 899                               //  Create CimomShutdownAlertIndication instance
 900                               //  ATTN: CimomShutdownAlertIndication must be defined
 901                               //
 902                               indicationInstance = _createAlertInstance (_CLASS_CIMOM_SHUTDOWN_ALERT,
 903                                   activeSubscriptions);
 904 dj.gorey        1.135 
 905 kumpf           1.73          //
 906                               //  Send CimomShutdownAlertIndication to each unique handler instance
 907                               //
 908                               Tracer::trace (TRC_INDICATION_SERVICE, Tracer::LEVEL4,
 909 carolann.graves 1.192             "Sending CIMServerShutdown Alert for %u subscriptions",
 910 kumpf           1.73              activeSubscriptions.size ());
 911                               _sendAlerts (activeSubscriptions, indicationInstance);
 912                           }
 913 kumpf           1.87  #endif
 914 kumpf           1.120 
 915                           //
 916 dj.gorey        1.135     //  Remove entries from the SubscriptionTable's Active Subscriptions and
 917 kumpf           1.120     //  Subscription Classes tables
 918                           //
 919 dj.gorey        1.135     //  NOTE: The table entries are removed when the SubscriptionTable
 920                           //  destructor is called by the IndicationService destructor.  However,
 921 kumpf           1.120     //  currently the IndicationService destructor is never called, so the
 922 dj.gorey        1.135     //  IndicationService must call the SubscriptionTable clear() function to
 923 kumpf           1.120     //  remove the table entries.
 924                           _subscriptionTable->clear ();
 925 kumpf           1.1   
 926 kumpf           1.48      PEG_METHOD_EXIT ();
 927 kumpf           1.11  }
 928 kumpf           1.6   
 929 kumpf           1.94  void IndicationService::_checkNonprivilegedAuthorization(
 930                           const String & userName)
 931                       {
 932                           PEG_METHOD_ENTER (TRC_INDICATION_SERVICE,
 933 kumpf           1.114         "IndicationService::_checkNonprivilegedAuthorization");
 934 kumpf           1.94  
 935                           Boolean accessDenied = false;
 936                           try
 937                           {
 938                               if (_enableSubscriptionsForNonprivilegedUsers)
 939                               {
 940 carolann.graves 1.170            PEG_METHOD_EXIT();
 941 kumpf           1.94             return;
 942                               }
 943                               else
 944                               {
 945 dj.gorey        1.135            PEG_TRACE_STRING (TRC_INDICATION_SERVICE, Tracer::LEVEL4,
 946 kumpf           1.94                "_checkNonprivilegedAuthorization - checking whether user is privileged"
 947                                     + userName);
 948                                  if (!System::isPrivilegedUser(userName))
 949                                  {
 950                                      accessDenied = true;
 951                                  }
 952                               }
 953                           }
 954                           catch (...)
 955                           {
 956                               PEG_METHOD_EXIT();
 957                               throw PEGASUS_CIM_EXCEPTION(CIM_ERR_FAILED, String::EMPTY);
 958                           }
 959                           if (accessDenied)
 960                           {
 961                              MessageLoaderParms parms(_MSG_NON_PRIVILEGED_ACCESS_DISABLED_KEY,
 962                                 _MSG_NON_PRIVILEGED_ACCESS_DISABLED, userName);
 963                              PEG_METHOD_EXIT();
 964                              throw PEGASUS_CIM_EXCEPTION_L(CIM_ERR_ACCESS_DENIED, parms);
 965                           }
 966 dj.gorey        1.135 }
 967 kumpf           1.94  
 968 kumpf           1.11  void IndicationService::_handleCreateInstanceRequest (const Message * message)
 969                       {
 970 kumpf           1.48      PEG_METHOD_ENTER (TRC_INDICATION_SERVICE,
 971 kumpf           1.114         "IndicationService::_handleCreateInstanceRequest");
 972 kumpf           1.6   
 973 dj.gorey        1.135     CIMCreateInstanceRequestMessage* request =
 974 kumpf           1.11          (CIMCreateInstanceRequestMessage*) message;
 975 kumpf           1.6   
 976 kumpf           1.23      CIMException cimException;
 977 kumpf           1.88      Boolean responseSent = false;
 978 kumpf           1.6   
 979 kumpf           1.45      CIMObjectPath instanceRef;
 980 kumpf           1.1   
 981 kumpf           1.11      CIMInstance instance = request->newInstance.clone ();
 982 kumpf           1.1   
 983 kumpf           1.11      try
 984                           {
 985 kumpf           1.137         String userName = ((IdentityContainer)request->operationContext.get
 986                                   (IdentityContainer :: NAME)).getUserName();
 987 se.gupta        1.123         _checkNonprivilegedAuthorization(userName);
 988                       
 989 kumpf           1.195         AcceptLanguageList acceptLangs =
 990 kumpf           1.137             ((AcceptLanguageListContainer)request->operationContext.get
 991                                   (AcceptLanguageListContainer::NAME)).getLanguages();
 992 kumpf           1.195         ContentLanguageList contentLangs =
 993 kumpf           1.137             ((ContentLanguageListContainer)request->operationContext.get
 994                                   (ContentLanguageListContainer::NAME)).getLanguages();
 995 kumpf           1.105 
 996                               if (_canCreate (instance, request->nameSpace))
 997                               {
 998                                   //
 999 dj.gorey        1.135             //  If the instance is of the PEGASUS_CLASSNAME_INDSUBSCRIPTION
1000 carolann.graves 1.175             //  class or the PEGASUS_CLASSNAME_FORMATTEDINDSUBSCRIPTION
1001 dj.gorey        1.135             //  class and subscription state is enabled, determine if any
1002 kumpf           1.105             //  providers can serve the subscription
1003                                   //
1004                                   Uint16 subscriptionState;
1005                                   String condition;
1006 kumpf           1.124             String query;
1007 kumpf           1.105             String queryLanguage;
1008                                   CIMPropertyList requiredProperties;
1009                                   CIMNamespaceName sourceNameSpace;
1010                                   Array <CIMName> indicationSubclasses;
1011                                   Array <ProviderClassList> indicationProviders;
1012                       
1013 yi.zhou         1.157             if ((instance.getClassName ().equal
1014                                       (PEGASUS_CLASSNAME_INDSUBSCRIPTION)) ||
1015 carolann.graves 1.175                 (instance.getClassName ().equal
1016                                       (PEGASUS_CLASSNAME_FORMATTEDINDSUBSCRIPTION)))
1017 kumpf           1.105             {
1018                                       //
1019                                       //  Get subscription state
1020                                       //
1021 dj.gorey        1.135                 //  NOTE: _canCreate has already validated the
1022                                       //  SubscriptionState property in the instance; if missing, it
1023                                       //  was added with the default value; if null, it was set to
1024 kumpf           1.105                 //  the default value; if invalid, an exception was thrown
1025                                       //
1026                                       CIMValue subscriptionStateValue;
1027                                       subscriptionStateValue = instance.getProperty
1028                                           (instance.findProperty (_PROPERTY_STATE)).getValue ();
1029                                       subscriptionStateValue.get (subscriptionState);
1030                       
1031                                       if ((subscriptionState == _STATE_ENABLED) ||
1032                                           (subscriptionState == _STATE_ENABLEDDEGRADED))
1033                                       {
1034 carolann.graves 1.186                     _getCreateParams (instance, indicationSubclasses,
1035                                               indicationProviders, requiredProperties,
1036                                               sourceNameSpace, condition, query, queryLanguage);
1037 kumpf           1.105 
1038                                           if (indicationProviders.size () == 0)
1039                                           {
1040                                               //
1041 dj.gorey        1.135                         //  There are no providers that can support this
1042 kumpf           1.105                         //  subscription
1043                                               //
1044                                               PEG_METHOD_EXIT ();
1045                       
1046                                               // l10n
1047                                               // throw PEGASUS_CIM_EXCEPTION (CIM_ERR_NOT_SUPPORTED,
1048                                               //  _MSG_NO_PROVIDERS);
1049                       
1050                                               throw PEGASUS_CIM_EXCEPTION_L (CIM_ERR_NOT_SUPPORTED,
1051 dj.gorey        1.135                             MessageLoaderParms(_MSG_NO_PROVIDERS_KEY,
1052 kumpf           1.105                                 _MSG_NO_PROVIDERS));
1053                                           }
1054                       
1055                                           //
1056                                           //  Send Create request message to each provider
1057                                           //
1058 dj.gorey        1.135                     // l10n
1059 carolann.graves 1.164                     _sendAsyncCreateRequests (indicationProviders,
1060 dj.gorey        1.135                         sourceNameSpace, requiredProperties, condition,
1061 kumpf           1.124                         query, queryLanguage, instance,
1062 dj.gorey        1.135                         acceptLangs,
1063 kumpf           1.124                         contentLangs,
1064                                               request,
1065 kumpf           1.105                         indicationSubclasses,
1066 dj.gorey        1.135                         userName, request->authType);
1067 kumpf           1.105 
1068                                           //
1069 kumpf           1.137                     //  Response is sent from _handleCreateResponseAggregation
1070 kumpf           1.105                     //
1071                                           responseSent = true;
1072                                       }
1073                                       else
1074                                       {
1075                                           //
1076                                           //  Create instance for disabled subscription
1077                                           //
1078 dj.gorey        1.135                     instanceRef = _subscriptionRepository->createInstance
1079                                               (instance, request->nameSpace, userName,
1080                                                acceptLangs, contentLangs,
1081 kumpf           1.114                         false);
1082 kumpf           1.105                 }
1083                                   }
1084 dj.gorey        1.135             else
1085 kumpf           1.105             {
1086                                       //
1087                                       //  Create instance for filter or handler
1088                                       //
1089 dj.gorey        1.135                 instanceRef = _subscriptionRepository->createInstance
1090                                           (instance, request->nameSpace, userName,
1091                                            acceptLangs, contentLangs,
1092 kumpf           1.114                     false);
1093 kumpf           1.105             }
1094                               }
1095 kumpf           1.11      }
1096                           catch (CIMException & exception)
1097                           {
1098 kumpf           1.105         cimException = exception;
1099 kumpf           1.11      }
1100                           catch (Exception & exception)
1101                           {
1102 kumpf           1.105         cimException = PEGASUS_CIM_EXCEPTION(CIM_ERR_FAILED,
1103                                   exception.getMessage());
1104 kumpf           1.11      }
1105 kumpf           1.1   
1106 kumpf           1.38      //
1107 kumpf           1.137     //  Send response, if not sent from callback
1108                           //  (for example, if there are no indication providers that can support a
1109                           //  subscription)
1110 kumpf           1.38      //
1111 kumpf           1.88      if (!responseSent)
1112                           {
1113 dj.gorey        1.135 // l10n - no Content-Language in response
1114 carolann.graves 1.145         CIMCreateInstanceResponseMessage * response = dynamic_cast
1115                                   <CIMCreateInstanceResponseMessage *> (request->buildResponse ());
1116                               response->cimException = cimException;
1117                               response->instanceName = instanceRef;
1118                               _enqueueResponse (request, response);
1119 kumpf           1.88      }
1120 kumpf           1.6   
1121 kumpf           1.48      PEG_METHOD_EXIT ();
1122 kumpf           1.11  }
1123 kumpf           1.6   
1124 kumpf           1.11  void IndicationService::_handleGetInstanceRequest (const Message* message)
1125                       {
1126 kumpf           1.48      PEG_METHOD_ENTER (TRC_INDICATION_SERVICE,
1127 kumpf           1.114         "IndicationService::_handleGetInstanceRequest");
1128 kumpf           1.6   
1129 dj.gorey        1.135     CIMGetInstanceRequestMessage* request =
1130 kumpf           1.11          (CIMGetInstanceRequestMessage*) message;
1131 kumpf           1.6   
1132 kumpf           1.23      CIMException cimException;
1133 kumpf           1.11      CIMInstance instance;
1134 kumpf           1.194     String contentLangsString;
1135 kumpf           1.6   
1136 kumpf           1.11      try
1137                           {
1138 kumpf           1.137         String userName = ((IdentityContainer)request->operationContext.get
1139                                   (IdentityContainer :: NAME)).getUserName();
1140 se.gupta        1.123         _checkNonprivilegedAuthorization(userName );
1141 kumpf           1.94  
1142 kumpf           1.11          //
1143 kumpf           1.99          //  Add Creator to property list, if not null
1144                               //  Also, if a Subscription and Time Remaining is requested,
1145                               //  Ensure Subscription Duration and Start Time are in property list
1146                               //
1147                               Boolean setTimeRemaining;
1148                               Boolean startTimeAdded;
1149                               Boolean durationAdded;
1150                               CIMPropertyList propertyList = request->propertyList;
1151                               CIMName className = request->instanceName.getClassName ();
1152 dj.gorey        1.135         _updatePropertyList (className, propertyList, setTimeRemaining,
1153 kumpf           1.99              startTimeAdded, durationAdded);
1154                       
1155                               //
1156 kumpf           1.11          //  Get instance from repository
1157                               //
1158 dj.gorey        1.135         instance = _subscriptionRepository->getInstance
1159                                   (request->nameSpace, request->instanceName, request->localOnly,
1160                                   request->includeQualifiers, request->includeClassOrigin,
1161 kumpf           1.99              propertyList);
1162 kumpf           1.1   
1163 kumpf           1.11          //
1164                               //  Remove Creator property from instance before returning
1165                               //
1166 kumpf           1.80          String creator;
1167                               if (!_getCreator (instance, creator))
1168                               {
1169                                   //
1170                                   //  This instance from the repository is corrupted
1171 humberto        1.82              //  L10N TODO DONE -- new throw of exception
1172 kumpf           1.80              //
1173                                   PEG_METHOD_EXIT ();
1174 dj.gorey        1.135             //throw PEGASUS_CIM_EXCEPTION (CIM_ERR_FAILED,
1175 humberto        1.82                  //_MSG_INVALID_INSTANCES);
1176 chip            1.162             MessageLoaderParms parms(_MSG_INVALID_INSTANCES_KEY,
1177 kumpf           1.137                 _MSG_INVALID_INSTANCES);
1178                                   throw PEGASUS_CIM_EXCEPTION_L(CIM_ERR_FAILED, parms);
1179 kumpf           1.80          }
1180 dj.gorey        1.135         instance.removeProperty (instance.findProperty
1181 kumpf           1.38              (PEGASUS_PROPERTYNAME_INDSUB_CREATOR));
1182 kumpf           1.1   
1183 chuck           1.75  // l10n start
1184                               //
1185                               //  Remove the language properties from instance before returning
1186                               //
1187 kumpf           1.137         Uint32 propIndex = instance.findProperty
1188 chip            1.162             (PEGASUS_PROPERTYNAME_INDSUB_ACCEPTLANGS);
1189 chuck           1.77          if (propIndex != PEG_NOT_FOUND)
1190                               {
1191 dj.gorey        1.135              instance.removeProperty (propIndex);
1192                               }
1193 chuck           1.77  
1194 kumpf           1.137         propIndex = instance.findProperty
1195 chip            1.162             (PEGASUS_PROPERTYNAME_INDSUB_CONTENTLANGS);
1196 chuck           1.77          if (propIndex != PEG_NOT_FOUND)
1197                               {
1198                                    // Get the content languages to be sent in the Content-Language header
1199 kumpf           1.194              instance.getProperty(propIndex).getValue().get(contentLangsString);
1200 dj.gorey        1.135              instance.removeProperty (propIndex);
1201                               }
1202                       // l10n end
1203 chuck           1.75  
1204 kumpf           1.11          //
1205 dj.gorey        1.135         //  If a subscription with a duration, calculate subscription time
1206 kumpf           1.11          //  remaining, and add property to the instance
1207                               //
1208 kumpf           1.99          if (setTimeRemaining)
1209 kumpf           1.11          {
1210 dj.gorey        1.135             try
1211                                   {
1212                                       _setTimeRemaining (instance);
1213                                   }
1214                                   catch (DateTimeOutOfRangeException &)
1215                                   {
1216                                       //
1217                                       //  This instance from the repository is invalid
1218                                       //
1219 carolann.graves 1.170                 PEG_METHOD_EXIT();
1220 dj.gorey        1.135                 throw;
1221                                   }
1222 kumpf           1.99              if (startTimeAdded)
1223                                   {
1224 dj.gorey        1.135                 instance.removeProperty (instance.findProperty
1225 kumpf           1.99                      (_PROPERTY_STARTTIME));
1226                                   }
1227                                   if (durationAdded)
1228                                   {
1229 dj.gorey        1.135                 instance.removeProperty (instance.findProperty
1230 kumpf           1.99                      (_PROPERTY_DURATION));
1231                                   }
1232 kumpf           1.11          }
1233                           }
1234                           catch (CIMException& exception)
1235                           {
1236 kumpf           1.23          cimException = exception;
1237 kumpf           1.11      }
1238                           catch (Exception& exception)
1239                           {
1240 kumpf           1.23          cimException = PEGASUS_CIM_EXCEPTION(CIM_ERR_FAILED,
1241                                                                    exception.getMessage());
1242 kumpf           1.11      }
1243 kumpf           1.10  
1244 carolann.graves 1.145     CIMGetInstanceResponseMessage * response = dynamic_cast
1245                               <CIMGetInstanceResponseMessage *> (request->buildResponse ());
1246                           response->cimException = cimException;
1247 kumpf           1.194     if (contentLangsString.size())
1248                           {
1249                               // Note: setting Content-Language in the response to the
1250                               // contentLanguage in the repository.
1251                               response->operationContext.set(ContentLanguageListContainer(
1252                                   LanguageParser::parseContentLanguageHeader(contentLangsString)));
1253                           }
1254 carolann.graves 1.145     response->cimInstance = instance;
1255                           _enqueueResponse (request, response);
1256 kumpf           1.1   
1257 kumpf           1.48      PEG_METHOD_EXIT ();
1258 kumpf           1.1   }
1259                       
1260 kumpf           1.11  void IndicationService::_handleEnumerateInstancesRequest(const Message* message)
1261 kumpf           1.1   {
1262 kumpf           1.48      PEG_METHOD_ENTER (TRC_INDICATION_SERVICE,
1263 kumpf           1.114         "IndicationService::_handleEnumerateInstancesRequest");
1264 kumpf           1.1   
1265 dj.gorey        1.135     CIMEnumerateInstancesRequestMessage* request =
1266 kumpf           1.11          (CIMEnumerateInstancesRequestMessage*) message;
1267 kumpf           1.1   
1268 kumpf           1.46      Array <CIMInstance> enumInstances;
1269 kumpf           1.80      Array <CIMInstance> returnedInstances;
1270 kumpf           1.1   
1271 kumpf           1.23      CIMException cimException;
1272 kumpf           1.11      CIMInstance cimInstance;
1273 chuck           1.75      String aggregatedLangs = String::EMPTY;    // l10n
1274                       
1275 kumpf           1.11  
1276                           try
1277                           {
1278 kumpf           1.137         String userName = ((IdentityContainer)request->operationContext.get
1279                                   (IdentityContainer :: NAME)).getUserName();
1280 se.gupta        1.123         _checkNonprivilegedAuthorization(userName);
1281 kumpf           1.94  
1282 kumpf           1.99          //
1283                               //  Add Creator to property list, if not null
1284                               //  Also, if a Subscription and Time Remaining is requested,
1285                               //  Ensure Subscription Duration and Start Time are in property list
1286                               //
1287                               Boolean setTimeRemaining;
1288                               Boolean startTimeAdded;
1289                               Boolean durationAdded;
1290                               CIMPropertyList propertyList = request->propertyList;
1291                               _updatePropertyList (request->className,
1292                                   propertyList, setTimeRemaining, startTimeAdded, durationAdded);
1293                       
1294 kumpf           1.206         enumInstances = _subscriptionRepository->enumerateInstancesForClass(
1295                                   request->nameSpace, request->className, request->localOnly,
1296                                   request->includeQualifiers, request->includeClassOrigin,
1297                                   propertyList);
1298 chuck           1.75  
1299                       // l10n
1300 kumpf           1.137         // Vars used to aggregate the content languages of the subscription
1301                               // instances.
1302                               Boolean langMismatch = false;
1303                               Uint32 propIndex;
1304 dj.gorey        1.135 
1305 kumpf           1.11          //
1306 chip            1.162         //  Remove Creator and language properties from instances before
1307 kumpf           1.137         //  returning
1308 kumpf           1.11          //
1309 kumpf           1.83          for (Uint32 i = 0; i < enumInstances.size (); i++)
1310 kumpf           1.11          {
1311 kumpf           1.80              String creator;
1312                                   if (!_getCreator (enumInstances [i], creator))
1313                                   {
1314                                       //
1315                                       //  This instance from the repository is corrupted
1316                                       //  Skip it
1317                                       //
1318 carolann.graves 1.144                 continue;
1319 kumpf           1.80              }
1320 dj.gorey        1.135             enumInstances [i].removeProperty
1321                                       (enumInstances [i].findProperty
1322 kumpf           1.38                  (PEGASUS_PROPERTYNAME_INDSUB_CREATOR));
1323 kumpf           1.11  
1324 chuck           1.75  // l10n start
1325 kumpf           1.137             propIndex = enumInstances [i].findProperty
1326 chip            1.162                 (PEGASUS_PROPERTYNAME_INDSUB_CONTENTLANGS);
1327 chuck           1.77              String contentLangs = String::EMPTY;
1328                                   if (propIndex != PEG_NOT_FOUND)
1329                                   {
1330 kumpf           1.137                 enumInstances [i].getProperty(propIndex).getValue().get
1331 chip            1.162                     (contentLangs);
1332                                       enumInstances [i].removeProperty(propIndex);
1333 chuck           1.77              }
1334 chuck           1.75  
1335 kumpf           1.137             propIndex = enumInstances [i].findProperty
1336                                       (PEGASUS_PROPERTYNAME_INDSUB_ACCEPTLANGS);
1337 chuck           1.77              if (propIndex != PEG_NOT_FOUND)
1338                                   {
1339 kumpf           1.137                 enumInstances [i].removeProperty(propIndex);
1340 chuck           1.77              }
1341                       
1342                                   // Determine what to set into the Content-Language header back to the client
1343 kumpf           1.137             if (!langMismatch)
1344 chuck           1.75              {
1345 kumpf           1.137                 if (contentLangs == String::EMPTY)
1346                                       {
1347                                           langMismatch = true;
1348                                           aggregatedLangs = String::EMPTY;
1349                                       }
1350                                       else
1351                                       {
1352 kumpf           1.115                     if (aggregatedLangs == String::EMPTY)
1353                                           {
1354 dj.gorey        1.135                         aggregatedLangs = contentLangs;
1355 kumpf           1.115                     }
1356                                           else if (aggregatedLangs != contentLangs)
1357                                           {
1358                                               langMismatch = true;
1359 dj.gorey        1.135                         aggregatedLangs = String::EMPTY;
1360 kumpf           1.115                     }
1361 kumpf           1.137                 }
1362                                   }
1363 dj.gorey        1.135 // l10n end
1364 chuck           1.75  
1365 kumpf           1.11              //
1366 dj.gorey        1.135             //  If a subscription with a duration, calculate subscription time
1367 kumpf           1.11              //  remaining, and add property to the instance
1368                                   //
1369 kumpf           1.99              if (setTimeRemaining)
1370 kumpf           1.11              {
1371 dj.gorey        1.135                 try
1372                                       {
1373                                           _setTimeRemaining (enumInstances [i]);
1374                                       } catch (DateTimeOutOfRangeException &)
1375                                       {
1376                                           //
1377                                           //  This instance from the repository is invalid
1378                                           //  Skip it
1379                                           //
1380                                           continue;
1381                                       }
1382 kumpf           1.99                  if (startTimeAdded)
1383                                       {
1384 dj.gorey        1.135                     enumInstances [i].removeProperty
1385 kumpf           1.99                          (enumInstances [i].findProperty (_PROPERTY_STARTTIME));
1386                                       }
1387                                       if (durationAdded)
1388                                       {
1389 dj.gorey        1.135                     enumInstances [i].removeProperty
1390 kumpf           1.99                          (enumInstances [i].findProperty (_PROPERTY_DURATION));
1391                                       }
1392 kumpf           1.11              }
1393 kumpf           1.80  
1394                                   returnedInstances.append (enumInstances [i]);
1395 kumpf           1.11          }
1396 kumpf           1.1       }
1397 kumpf           1.11      catch (CIMException& exception)
1398 kumpf           1.1       {
1399 kumpf           1.23          cimException = exception;
1400 kumpf           1.1       }
1401 kumpf           1.11      catch (Exception& exception)
1402 kumpf           1.1       {
1403 kumpf           1.23          cimException = PEGASUS_CIM_EXCEPTION(CIM_ERR_FAILED,
1404                                                                    exception.getMessage());
1405 kumpf           1.11      }
1406 kumpf           1.1   
1407 carolann.graves 1.145     CIMEnumerateInstancesResponseMessage * response = dynamic_cast
1408                               <CIMEnumerateInstancesResponseMessage *> (request->buildResponse ());
1409                           response->cimException = cimException;
1410 kumpf           1.194     if (aggregatedLangs.size())
1411                           {
1412                               // Note: setting Content-Language in the response to the aggregated
1413                               // contentLanguage from the instances in the repository.
1414                               response->operationContext.set(ContentLanguageListContainer(
1415                                   LanguageParser::parseContentLanguageHeader(aggregatedLangs)));
1416                           }
1417 carolann.graves 1.145     response->cimNamedInstances = returnedInstances;
1418                           _enqueueResponse (request, response);
1419 kumpf           1.1   
1420 kumpf           1.48      PEG_METHOD_EXIT ();
1421 kumpf           1.11  }
1422 kumpf           1.1   
1423 kumpf           1.11  void IndicationService::_handleEnumerateInstanceNamesRequest
1424                           (const Message* message)
1425                       {
1426 kumpf           1.114     PEG_METHOD_ENTER (TRC_INDICATION_SERVICE,
1427 carolann.graves 1.198         "IndicationService::_handleEnumerateInstanceNamesRequest");
1428 dj.gorey        1.135 
1429 kumpf           1.11      CIMEnumerateInstanceNamesRequestMessage* request =
1430                               (CIMEnumerateInstanceNamesRequestMessage*) message;
1431 kumpf           1.1   
1432 kumpf           1.45      Array<CIMObjectPath> enumInstanceNames;
1433 kumpf           1.1   
1434 kumpf           1.23      CIMException cimException;
1435 kumpf           1.1   
1436 kumpf           1.11      try
1437                           {
1438 kumpf           1.137         String userName = ((IdentityContainer)request->operationContext.get
1439                                   (IdentityContainer :: NAME)).getUserName();
1440 se.gupta        1.126         _checkNonprivilegedAuthorization(userName);
1441 dj.gorey        1.135         enumInstanceNames =
1442 kumpf           1.114             _subscriptionRepository->enumerateInstanceNamesForClass
1443 kumpf           1.206             (request->nameSpace, request->className);
1444 kumpf           1.11      }
1445                           catch (CIMException& exception)
1446                           {
1447 kumpf           1.23          cimException = exception;
1448 kumpf           1.11      }
1449                           catch (Exception& exception)
1450                           {
1451 kumpf           1.23          cimException = PEGASUS_CIM_EXCEPTION(CIM_ERR_FAILED,
1452                                                                    exception.getMessage());
1453 kumpf           1.11      }
1454 kumpf           1.1   
1455 chuck           1.75  // l10n
1456                           // Note: not setting Content-Language in the response
1457 carolann.graves 1.145     CIMEnumerateInstanceNamesResponseMessage * response = dynamic_cast
1458 chip            1.162         <CIMEnumerateInstanceNamesResponseMessage *>
1459 carolann.graves 1.145             (request->buildResponse ());
1460                           response->cimException = cimException;
1461                           response->instanceNames = enumInstanceNames;
1462                           _enqueueResponse (request, response);
1463 kumpf           1.1   
1464 kumpf           1.48      PEG_METHOD_EXIT ();
1465 kumpf           1.1   }
1466                       
1467 kumpf           1.11  void IndicationService::_handleModifyInstanceRequest (const Message* message)
1468 kumpf           1.1   {
1469 kumpf           1.48      PEG_METHOD_ENTER (TRC_INDICATION_SERVICE,
1470 kumpf           1.114         "IndicationService::_handleModifyInstanceRequest");
1471 kumpf           1.1   
1472 dj.gorey        1.135     CIMModifyInstanceRequestMessage* request =
1473 kumpf           1.11          (CIMModifyInstanceRequestMessage*) message;
1474 kumpf           1.6   
1475 kumpf           1.23      CIMException cimException;
1476 kumpf           1.88      Boolean responseSent = false;
1477 dj.gorey        1.135 
1478 kumpf           1.11      try
1479 kumpf           1.6       {
1480 kumpf           1.137         String userName = ((IdentityContainer)request->operationContext.get
1481                                   (IdentityContainer :: NAME)).getUserName();
1482 se.gupta        1.123         _checkNonprivilegedAuthorization(userName);
1483 kumpf           1.94  
1484 kumpf           1.6           //
1485 kumpf           1.11          //  Get the instance name
1486 kumpf           1.6           //
1487 dj.gorey        1.135         CIMObjectPath instanceReference =
1488 kumpf           1.46              request->modifiedInstance.getPath ();
1489 dj.gorey        1.135 
1490 kumpf           1.6           //
1491 kumpf           1.11          //  Get instance from repository
1492 kumpf           1.6           //
1493 kumpf           1.19          CIMInstance instance;
1494                       
1495 dj.gorey        1.135         instance = _subscriptionRepository->getInstance
1496 kumpf           1.114             (request->nameSpace, instanceReference);
1497 kumpf           1.19  
1498 kumpf           1.80          CIMInstance modifiedInstance = request->modifiedInstance;
1499                               if (_canModify (request, instanceReference, instance, modifiedInstance))
1500 kumpf           1.1           {
1501 kumpf           1.11              //
1502 carolann.graves 1.186             //  Set path in instance
1503                                   //
1504                                   instanceReference.setNameSpace (request->nameSpace);
1505                                   instance.setPath (instanceReference);
1506                       
1507                                   //
1508 kumpf           1.11              //  Check for expired subscription
1509                                   //
1510 dj.gorey        1.135             try
1511 kumpf           1.1               {
1512 dj.gorey        1.135                 if (_isExpired (instance))
1513                                       {
1514                                         //
1515                                         //  Delete the subscription instance
1516                                         //
1517                                         _deleteExpiredSubscription (instanceReference);
1518                       
1519                                         PEG_METHOD_EXIT ();
1520 humberto        1.78  
1521 kumpf           1.137                   // l10n
1522 humberto        1.78  
1523 dj.gorey        1.135                   // String exceptionStr = _MSG_EXPIRED;
1524                                         // throw PEGASUS_CIM_EXCEPTION (CIM_ERR_FAILED, exceptionStr);
1525 humberto        1.78  
1526 kumpf           1.137                   throw PEGASUS_CIM_EXCEPTION_L (CIM_ERR_FAILED,
1527                                             MessageLoaderParms(_MSG_EXPIRED_KEY, _MSG_EXPIRED));
1528 dj.gorey        1.135                 }
1529                                   } catch (DateTimeOutOfRangeException &)
1530                                   {
1531                                       //
1532                                       //  This instance from the repository is invalid
1533                                       //
1534 carolann.graves 1.170                 PEG_METHOD_EXIT();
1535 dj.gorey        1.135                 throw;
1536 kumpf           1.1               }
1537 dj.gorey        1.135 
1538 kumpf           1.15              //
1539 dj.gorey        1.135             //  _canModify, above, already checked that propertyList is not
1540 kumpf           1.15              //  null, and that numProperties is 0 or 1
1541                                   //
1542 kumpf           1.35              CIMPropertyList propertyList = request->propertyList;
1543 kumpf           1.51              if (request->propertyList.size () > 0)
1544 kumpf           1.1               {
1545 kumpf           1.11                  //
1546                                       //  Get current state from instance
1547                                       //
1548                                       Uint16 currentState;
1549 kumpf           1.114                 Boolean valid = true;
1550                                       if (_subscriptionRepository->getState (instance, currentState))
1551                                       {
1552                                           valid = _validateState (currentState);
1553                                       }
1554                       
1555                                       if (!valid)
1556 kumpf           1.80                  {
1557                                           //
1558                                           //  This instance from the repository is corrupted
1559 humberto        1.82                      //  L10N TODO DONE -- new throw of exception
1560 kumpf           1.80                      //
1561                                           PEG_METHOD_EXIT ();
1562 dj.gorey        1.135                     //throw PEGASUS_CIM_EXCEPTION (CIM_ERR_FAILED,
1563 humberto        1.82                          //_MSG_INVALID_INSTANCES);
1564 dj.gorey        1.135                     MessageLoaderParms parms (_MSG_INVALID_INSTANCES_KEY,
1565 kumpf           1.114                         _MSG_INVALID_INSTANCES);
1566                                           throw PEGASUS_CIM_EXCEPTION_L (CIM_ERR_FAILED, parms);
1567 kumpf           1.80                  }
1568 dj.gorey        1.135 
1569 kumpf           1.11                  //
1570 dj.gorey        1.135                 //  Get new state
1571 kumpf           1.11                  //
1572 dj.gorey        1.135                 //  NOTE: _canModify has already validated the
1573                                       //  SubscriptionState property in the instance; if missing, it
1574                                       //  was added with the default value; if null, it was set to
1575 kumpf           1.80                  //  the default value; if invalid, an exception was thrown
1576                                       //
1577 kumpf           1.11                  Uint16 newState;
1578 dj.gorey        1.135                 modifiedInstance.getProperty (modifiedInstance.findProperty
1579 kumpf           1.80                      (_PROPERTY_STATE)).getValue ().get (newState);
1580 dj.gorey        1.135 
1581 kumpf           1.11                  //
1582                                       //  If Subscription State has changed,
1583                                       //  Set Time of Last State Change to current date time
1584                                       //
1585 dj.gorey        1.135                 CIMDateTime currentDateTime =
1586 kumpf           1.35                      CIMDateTime::getCurrentDateTime ();
1587 kumpf           1.11                  if (newState != currentState)
1588                                       {
1589 kumpf           1.52                      if (modifiedInstance.findProperty (_PROPERTY_LASTCHANGE) !=
1590                                               PEG_NOT_FOUND)
1591 kumpf           1.35                      {
1592                                               CIMProperty lastChange = modifiedInstance.getProperty
1593 dj.gorey        1.135                             (modifiedInstance.findProperty
1594 kumpf           1.35                              (_PROPERTY_LASTCHANGE));
1595                                               lastChange.setValue (CIMValue (currentDateTime));
1596                                           }
1597                                           else
1598                                           {
1599 dj.gorey        1.135                         modifiedInstance.addProperty (CIMProperty
1600 kumpf           1.35                              (_PROPERTY_LASTCHANGE, CIMValue (currentDateTime)));
1601                                           }
1602 dj.gorey        1.135                     Array <CIMName> properties =
1603 kumpf           1.35                          propertyList.getPropertyNameArray ();
1604                                           properties.append (_PROPERTY_LASTCHANGE);
1605                                           propertyList.set (properties);
1606 kumpf           1.11                  }
1607 kumpf           1.13  
1608                                       //
1609 dj.gorey        1.135                 //  If Subscription is to be enabled, and this is the first
1610 kumpf           1.13                  //  time, set Subscription Start Time
1611                                       //
1612 dj.gorey        1.135                 if ((newState == _STATE_ENABLED) ||
1613 kumpf           1.13                      (newState == _STATE_ENABLEDDEGRADED))
1614                                       {
1615                                           //
1616                                           //  If Subscription Start Time is null, set value
1617                                           //  to the current date time
1618                                           //
1619                                           CIMDateTime startTime;
1620 dj.gorey        1.135                     CIMProperty startTimeProperty = instance.getProperty
1621 kumpf           1.13                          (instance.findProperty (_PROPERTY_STARTTIME));
1622                                           CIMValue startTimeValue = instance.getProperty
1623 dj.gorey        1.135                         (instance.findProperty
1624 kumpf           1.13                          (_PROPERTY_STARTTIME)).getValue ();
1625 kumpf           1.35                      Boolean setStart = false;
1626 kumpf           1.13                      if (startTimeValue.isNull ())
1627                                           {
1628 kumpf           1.35                          setStart = true;
1629 kumpf           1.13                      }
1630                                           else
1631                                           {
1632                                               startTimeValue.get (startTime);
1633 chuck           1.149 
1634                                               if (startTime.isInterval())
1635 kumpf           1.13                          {
1636 chuck           1.149                           if (startTime.equal
1637                                                     (CIMDateTime (_ZERO_INTERVAL_STRING)))
1638                                                 {
1639 kumpf           1.35                              setStart = true;
1640 chuck           1.149                           }
1641 kumpf           1.13                          }
1642                                           }
1643 kumpf           1.35  
1644                                           if (setStart)
1645                                           {
1646 kumpf           1.52                          if (modifiedInstance.findProperty (_PROPERTY_STARTTIME)
1647                                                   != PEG_NOT_FOUND)
1648 kumpf           1.35                          {
1649                                                   CIMProperty startTime = modifiedInstance.getProperty
1650                                                       (modifiedInstance.findProperty
1651                                                       (_PROPERTY_STARTTIME));
1652                                                   startTime.setValue (CIMValue (currentDateTime));
1653                                               }
1654                                               else
1655                                               {
1656 dj.gorey        1.135                             modifiedInstance.addProperty (CIMProperty
1657 kumpf           1.35                                  (_PROPERTY_STARTTIME,
1658                                                       CIMValue (currentDateTime)));
1659                                               }
1660                       
1661 dj.gorey        1.135                         Array <CIMName> properties =
1662 kumpf           1.35                              propertyList.getPropertyNameArray ();
1663                                               properties.append (_PROPERTY_STARTTIME);
1664                                               propertyList.set (properties);
1665                                           }
1666 kumpf           1.13                  }
1667 kumpf           1.19  
1668 chuck           1.75  // l10n
1669                                       // Add the language properties to the modified instance.
1670 kumpf           1.137                 // Note:  These came from the Accept-Language and Content-Language
1671                                       // headers in the HTTP messages, and may be empty.
1672 kumpf           1.195                 AcceptLanguageList acceptLangs =
1673 kumpf           1.137                     ((AcceptLanguageListContainer)request->operationContext.get
1674                                           (AcceptLanguageListContainer::NAME)).getLanguages();
1675 chip            1.162                 modifiedInstance.addProperty (CIMProperty
1676                                           (PEGASUS_PROPERTYNAME_INDSUB_ACCEPTLANGS,
1677 kumpf           1.194                     LanguageParser::buildAcceptLanguageHeader(acceptLangs)));
1678 chuck           1.75  
1679 kumpf           1.195                 ContentLanguageList contentLangs =
1680 kumpf           1.137                     ((ContentLanguageListContainer)request->operationContext.get
1681                                           (ContentLanguageListContainer::NAME)).getLanguages();
1682 chip            1.162                 modifiedInstance.addProperty (CIMProperty
1683                                           (PEGASUS_PROPERTYNAME_INDSUB_CONTENTLANGS,
1684 kumpf           1.194                     LanguageParser::buildContentLanguageHeader(contentLangs)));
1685 dj.gorey        1.135 
1686 chuck           1.75                  Array <CIMName> properties = propertyList.getPropertyNameArray ();
1687                                       properties.append (PEGASUS_PROPERTYNAME_INDSUB_ACCEPTLANGS);
1688 dj.gorey        1.135                 properties.append (PEGASUS_PROPERTYNAME_INDSUB_CONTENTLANGS);
1689                                       propertyList.set (properties);
1690 chuck           1.75  // l10n -end
1691                       
1692 kumpf           1.11                  //
1693 dj.gorey        1.135                 //  If subscription is to be enabled, determine if there are
1694 kumpf           1.11                  //  any indication providers that can serve the subscription
1695                                       //
1696 kumpf           1.16                  Array <ProviderClassList> indicationProviders;
1697 kumpf           1.11                  CIMPropertyList requiredProperties;
1698 kumpf           1.63                  CIMNamespaceName sourceNameSpace;
1699 kumpf           1.11                  String condition;
1700 kumpf           1.124                 String query;
1701 kumpf           1.11                  String queryLanguage;
1702 kumpf           1.73                  Array <CIMName> indicationSubclasses;
1703 dj.gorey        1.135 
1704                                       if (((newState == _STATE_ENABLED) ||
1705 kumpf           1.11                       (newState == _STATE_ENABLEDDEGRADED))
1706 dj.gorey        1.135                     && ((currentState != _STATE_ENABLED) &&
1707 kumpf           1.11                          (currentState != _STATE_ENABLEDDEGRADED)))
1708                                       {
1709                                           //
1710 dj.gorey        1.135                     //  Subscription was previously not enabled but is now to
1711 kumpf           1.11                      //  be enabled
1712                                           //
1713 carolann.graves 1.186                     _getCreateParams (instance, indicationSubclasses,
1714                                               indicationProviders, requiredProperties,
1715                                               sourceNameSpace, condition, query, queryLanguage);
1716 dj.gorey        1.135 
1717 kumpf           1.11                      if (indicationProviders.size () == 0)
1718                                           {
1719                                               //
1720 dj.gorey        1.135                         //  There are no providers that can support this
1721 kumpf           1.11                          //  subscription
1722                                               //
1723 kumpf           1.46                          instance.setPath (instanceReference);
1724 kumpf           1.114                         _subscriptionRepository->reconcileFatalError (instance);
1725 kumpf           1.48                          PEG_METHOD_EXIT ();
1726 humberto        1.78  
1727 kumpf           1.137                         // l10n
1728 humberto        1.78                          // throw PEGASUS_CIM_EXCEPTION (CIM_ERR_NOT_SUPPORTED,
1729 kumpf           1.137                         //  _MSG_NO_PROVIDERS);
1730 humberto        1.78  
1731 kumpf           1.137                         throw PEGASUS_CIM_EXCEPTION_L (CIM_ERR_NOT_SUPPORTED,
1732 dj.gorey        1.135                             MessageLoaderParms (_MSG_NO_PROVIDERS_KEY,
1733 kumpf           1.114                             _MSG_NO_PROVIDERS));
1734 kumpf           1.11                      }
1735                                       }
1736 kumpf           1.19  
1737 kumpf           1.11                  //
1738                                       //  Modify the instance in the repository
1739                                       //
1740                                       try
1741                                       {
1742 kumpf           1.46                      modifiedInstance.setPath (instanceReference);
1743 dj.gorey        1.135                     _subscriptionRepository->modifyInstance
1744                                               (request->nameSpace, modifiedInstance,
1745 kumpf           1.35                          request->includeQualifiers, propertyList);
1746 david           1.71  
1747 dj.gorey        1.135                     Logger::put (Logger::STANDARD_LOG, System::CIMSERVER,
1748 kumpf           1.114                         Logger::TRACE,
1749                                               "IndicationService::_handleModifyInstanceRequest - Name Space: $0  Instance name: $1",
1750                                               request->nameSpace.getString (),
1751                                               modifiedInstance.getClassName ().getString ());
1752 kumpf           1.137                 }
1753 kumpf           1.23                  catch (CIMException & exception)
1754                                       {
1755                                           cimException = exception;
1756                                       }
1757 kumpf           1.11                  catch (Exception & exception)
1758                                       {
1759 kumpf           1.23                      cimException = PEGASUS_CIM_EXCEPTION(CIM_ERR_FAILED,
1760                                                              exception.getMessage());
1761                                       }
1762                       
1763                                       if (cimException.getCode() != CIM_ERR_SUCCESS)
1764                                       {
1765 carolann.graves 1.145                     CIMResponseMessage * response = request->buildResponse ();
1766                                           response->cimException = cimException;
1767                                           _enqueueResponse (request, response);
1768 dj.gorey        1.135 
1769 kumpf           1.48                      PEG_METHOD_EXIT ();
1770 kumpf           1.11                      return;
1771                                       }
1772 dj.gorey        1.135 
1773 kumpf           1.11                  //
1774 kumpf           1.38                  //  If subscription is newly enabled, send Create requests
1775                                       //  and enable providers
1776 kumpf           1.11                  //
1777 dj.gorey        1.135                 if (((newState == _STATE_ENABLED) ||
1778 kumpf           1.11                       (newState == _STATE_ENABLEDDEGRADED))
1779 dj.gorey        1.135                     && ((currentState != _STATE_ENABLED) &&
1780 kumpf           1.11                          (currentState != _STATE_ENABLEDDEGRADED)))
1781 kumpf           1.1                   {
1782 kumpf           1.16                      instanceReference.setNameSpace (request->nameSpace);
1783 kumpf           1.46                      instance.setPath (instanceReference);
1784 dj.gorey        1.135 // l10n
1785 carolann.graves 1.164                     _sendAsyncCreateRequests (indicationProviders,
1786 dj.gorey        1.135                         sourceNameSpace, requiredProperties, condition,
1787 kumpf           1.124                         query,
1788 kumpf           1.14                          queryLanguage,
1789 kumpf           1.46                          instance,
1790 dj.gorey        1.135                         acceptLangs,
1791                                               contentLangs,
1792 kumpf           1.88                          request,
1793                                               indicationSubclasses,
1794 se.gupta        1.123                         userName, request->authType);
1795 humberto        1.78  
1796 kumpf           1.73                      //
1797 kumpf           1.137                     //  Response is sent from _handleCreateResponseAggregation
1798 kumpf           1.73                      //
1799 kumpf           1.88                      responseSent = true;
1800 kumpf           1.1                   }
1801 kumpf           1.11                  else if ((newState == _STATE_DISABLED) &&
1802                                                ((currentState == _STATE_ENABLED) ||
1803                                                 (currentState == _STATE_ENABLEDDEGRADED)))
1804                                       {
1805                                           //
1806 dj.gorey        1.135                     //  Subscription was previously enabled but is now to be
1807 kumpf           1.11                      //  disabled
1808                                           //
1809 kumpf           1.16                      Array <ProviderClassList> indicationProviders;
1810 kumpf           1.88                      instanceReference.setNameSpace (request->nameSpace);
1811                                           instance.setPath (instanceReference);
1812 carolann.graves 1.186                     indicationProviders = _getDeleteParams (instance,
1813                                               indicationSubclasses, sourceNameSpace);
1814 dj.gorey        1.135 
1815 kumpf           1.11                      //
1816 kumpf           1.38                      //  Send Delete requests
1817 kumpf           1.11                      //
1818 dj.gorey        1.135 //l10n
1819 kumpf           1.11                      if (indicationProviders.size () > 0)
1820                                           {
1821 carolann.graves 1.164                         _sendAsyncDeleteRequests (indicationProviders,
1822 kumpf           1.90                              sourceNameSpace,
1823 kumpf           1.46                              instance,
1824 dj.gorey        1.135                             acceptLangs,
1825                                                   contentLangs,
1826 kumpf           1.88                              request,
1827                                                   indicationSubclasses,
1828 se.gupta        1.123                             userName, request->authType);
1829 kumpf           1.88  
1830                                               //
1831 chip            1.162                         //  Response is sent from
1832 carolann.graves 1.158                         //  _handleDeleteResponseAggregation
1833 kumpf           1.88                          //
1834                                               responseSent = true;
1835 kumpf           1.11                      }
1836                                       }
1837 kumpf           1.1               }
1838                               }
1839 kumpf           1.11      }
1840                           catch (CIMException& exception)
1841 kumpf           1.1       {
1842 kumpf           1.23          cimException = exception;
1843 kumpf           1.1       }
1844 kumpf           1.11      catch (Exception& exception)
1845 kumpf           1.1       {
1846 kumpf           1.23          cimException = PEGASUS_CIM_EXCEPTION(CIM_ERR_FAILED,
1847                                                                    exception.getMessage());
1848 kumpf           1.1       }
1849                       
1850 kumpf           1.38      //
1851 kumpf           1.137     //  Send response, if not sent from callback
1852                           //  (for example, if there are no indication providers that can support a
1853                           //  subscription)
1854 kumpf           1.38      //
1855 kumpf           1.88      if (!responseSent)
1856                           {
1857 chuck           1.75  // l10n
1858 kumpf           1.88          // Note: don't need to set content-language in the response.
1859 carolann.graves 1.145         CIMResponseMessage * response = request->buildResponse ();
1860                               response->cimException = cimException;
1861                               _enqueueResponse (request, response);
1862 kumpf           1.88      }
1863 kumpf           1.1   
1864 kumpf           1.48      PEG_METHOD_EXIT ();
1865 kumpf           1.1   }
1866                       
1867 kumpf           1.11  void IndicationService::_handleDeleteInstanceRequest (const Message* message)
1868 kumpf           1.1   {
1869 kumpf           1.48      PEG_METHOD_ENTER (TRC_INDICATION_SERVICE,
1870 kumpf           1.114         "IndicationService::_handleDeleteInstanceRequest");
1871 kumpf           1.1   
1872 dj.gorey        1.135     CIMDeleteInstanceRequestMessage* request =
1873 kumpf           1.11          (CIMDeleteInstanceRequestMessage*) message;
1874 kumpf           1.1   
1875 kumpf           1.23      CIMException cimException;
1876 kumpf           1.88      Boolean responseSent = false;
1877 kumpf           1.1   
1878                           try
1879                           {
1880 kumpf           1.137         String userName = ((IdentityContainer)request->operationContext.get
1881                                   (IdentityContainer :: NAME)).getUserName();
1882 se.gupta        1.123         _checkNonprivilegedAuthorization(userName);
1883 kumpf           1.94  
1884 kumpf           1.11          //
1885 dj.gorey        1.135         //  Check if instance may be deleted -- a filter or handler instance
1886 kumpf           1.11          //  referenced by a subscription instance may not be deleted
1887                               //
1888 kumpf           1.16          if (_canDelete (request->instanceName, request->nameSpace,
1889 se.gupta        1.123              userName))
1890 kumpf           1.11          {
1891 kumpf           1.88              //
1892                                   //  If a subscription, get the instance from the repository
1893                                   //
1894                                   CIMInstance subscriptionInstance;
1895 kumpf           1.64              if (request->instanceName.getClassName ().equal
1896 carolann.graves 1.169                     (PEGASUS_CLASSNAME_INDSUBSCRIPTION) ||
1897                                       request->instanceName.getClassName ().equal
1898                                           (PEGASUS_CLASSNAME_FORMATTEDINDSUBSCRIPTION))
1899 kumpf           1.1               {
1900 dj.gorey        1.135                 subscriptionInstance =
1901                                           _subscriptionRepository->getInstance
1902 kumpf           1.11                      (request->nameSpace, request->instanceName);
1903 kumpf           1.1               }
1904                       
1905                                   //
1906 kumpf           1.11              //  Delete instance from repository
1907 kumpf           1.1               //
1908 kumpf           1.11              try
1909 kumpf           1.1               {
1910 dj.gorey        1.135                 _subscriptionRepository->deleteInstance
1911 kumpf           1.114                     (request->nameSpace, request->instanceName);
1912 dj.gorey        1.135 
1913                                       Logger::put (Logger::STANDARD_LOG, System::CIMSERVER,
1914 kumpf           1.114                     Logger::TRACE,
1915                                           "IndicationService::_handleDeleteInstanceRequest - Name Space: $0  Instance name: $1",
1916                                           request->nameSpace.getString (),
1917                                           request->instanceName.getClassName ().getString ());
1918 kumpf           1.1               }
1919 kumpf           1.23              catch (CIMException & exception)
1920                                   {
1921                                       cimException = exception;
1922                                   }
1923 kumpf           1.11              catch (Exception & exception)
1924 kumpf           1.1               {
1925 kumpf           1.23                  cimException = PEGASUS_CIM_EXCEPTION(CIM_ERR_FAILED,
1926                                                          exception.getMessage());
1927                                   }
1928 kumpf           1.11  
1929 kumpf           1.23              if (cimException.getCode() != CIM_ERR_SUCCESS)
1930                                   {
1931 carolann.graves 1.145                 CIMResponseMessage * response = request->buildResponse ();
1932                                       response->cimException = cimException;
1933                                       _enqueueResponse (request, response);
1934 kumpf           1.1   
1935 kumpf           1.48                  PEG_METHOD_EXIT ();
1936 kumpf           1.11                  return;
1937 kumpf           1.1               }
1938 kumpf           1.88  
1939                                   if (request->instanceName.getClassName ().equal
1940 yi.zhou         1.157                 (PEGASUS_CLASSNAME_INDSUBSCRIPTION) ||
1941 carolann.graves 1.186                 request->instanceName.getClassName ().equal
1942                                       (PEGASUS_CLASSNAME_FORMATTEDINDSUBSCRIPTION))
1943 kumpf           1.88              {
1944                                       //
1945                                       //  If subscription is active, send delete requests to providers
1946                                       //  and update hash tables
1947                                       //
1948                                       Uint16 subscriptionState;
1949                                       CIMValue subscriptionStateValue;
1950                                       subscriptionStateValue = subscriptionInstance.getProperty
1951 dj.gorey        1.135                     (subscriptionInstance.findProperty
1952 kumpf           1.88                      (_PROPERTY_STATE)).getValue ();
1953                                       subscriptionStateValue.get (subscriptionState);
1954                       
1955                                       if ((subscriptionState == _STATE_ENABLED) ||
1956                                           (subscriptionState == _STATE_ENABLEDDEGRADED))
1957                                       {
1958                                           Array <ProviderClassList> indicationProviders;
1959                                           Array <CIMName> indicationSubclasses;
1960                                           CIMNamespaceName sourceNamespaceName;
1961                                           CIMObjectPath instanceReference = request->instanceName;
1962                                           instanceReference.setNameSpace (request->nameSpace);
1963                                           subscriptionInstance.setPath (instanceReference);
1964                       
1965 dj.gorey        1.135                     indicationProviders = _getDeleteParams
1966 carolann.graves 1.186                         (subscriptionInstance, indicationSubclasses,
1967                                               sourceNamespaceName);
1968 kumpf           1.88  
1969 kumpf           1.105                     if (indicationProviders.size () > 0)
1970                                           {
1971                                               //
1972                                               //  Send Delete requests
1973                                               //
1974 dj.gorey        1.135 // l10n
1975 carolann.graves 1.164                         _sendAsyncDeleteRequests (indicationProviders,
1976 kumpf           1.105                             sourceNamespaceName, subscriptionInstance,
1977 kumpf           1.137                             ((AcceptLanguageListContainer)
1978                                                   request->operationContext.get
1979                                                   (AcceptLanguageListContainer::NAME)).getLanguages(),
1980                                                   ((ContentLanguageListContainer)
1981                                                   request->operationContext.get
1982                                                   (ContentLanguageListContainer::NAME)).getLanguages(),
1983 kumpf           1.105                             request,
1984                                                   indicationSubclasses,
1985 se.gupta        1.123                             userName, request->authType);
1986 kumpf           1.88  
1987 kumpf           1.105                         //
1988 chip            1.162                         //  Response is sent from
1989 carolann.graves 1.158                         //  _handleDeleteResponseAggregation
1990 kumpf           1.105                         //
1991                                               responseSent = true;
1992                                           }
1993                                           else
1994                                           {
1995                                               //
1996                                               //  Subscription was enabled, but had no providers
1997                                               //  Remove entries from the subscription hash tables
1998                                               //
1999 dj.gorey        1.135                         _subscriptionTable->removeSubscription
2000 kumpf           1.114                             (subscriptionInstance,
2001 kumpf           1.111                             indicationSubclasses, sourceNamespaceName,
2002                                                   indicationProviders);
2003 kumpf           1.105                     }
2004 kumpf           1.88                  }
2005                                   }
2006 kumpf           1.11          }
2007                           }
2008                           catch (CIMException& exception)
2009                           {
2010 kumpf           1.23          cimException = exception;
2011 kumpf           1.11      }
2012                           catch (Exception& exception)
2013                           {
2014 kumpf           1.23          cimException = PEGASUS_CIM_EXCEPTION(CIM_ERR_FAILED,
2015                                                                    exception.getMessage());
2016 kumpf           1.11      }
2017                       
2018 kumpf           1.38      //
2019 kumpf           1.137     //  Send response, if not sent from callback
2020                           //  (for example, if a subscription had no indication providers)
2021 kumpf           1.38      //
2022 kumpf           1.88      if (!responseSent)
2023                           {
2024 carolann.graves 1.145         CIMResponseMessage * response = request->buildResponse ();
2025                               response->cimException = cimException;
2026                               _enqueueResponse (request, response);
2027 kumpf           1.88      }
2028 kumpf           1.11  
2029 kumpf           1.48      PEG_METHOD_EXIT ();
2030 kumpf           1.11  }
2031                       
2032 chuck           1.75  // l10n TODO - might need to globalize another flow and another consumer interface
2033                       // (ie. mdd's) if we can't agree on one export flow and consumer interface
2034                       // (see PEP67)
2035                       
2036 kumpf           1.11  void IndicationService::_handleProcessIndicationRequest (const Message* message)
2037                       {
2038 kumpf           1.73  #ifdef PEGASUS_INDICATION_PERFINST
2039                           Stopwatch stopWatch;
2040                       #endif
2041                       
2042 kumpf           1.48      PEG_METHOD_ENTER (TRC_INDICATION_SERVICE,
2043 kumpf           1.114         "IndicationService::_handleProcessIndicationRequest");
2044 kumpf           1.11  
2045                           CIMProcessIndicationRequestMessage* request =
2046                               (CIMProcessIndicationRequestMessage*) message;
2047                       
2048 kumpf           1.23      CIMException cimException;
2049 kumpf           1.11  
2050 carolann.graves 1.145     CIMResponseMessage * response = request->buildResponse ();
2051                           response->cimException = cimException;
2052 kumpf           1.11  
2053                           String filterQuery;
2054                           Boolean match;
2055                       
2056 kumpf           1.46      Array <CIMInstance> matchedSubscriptions;
2057                           CIMInstance handlerNamedInstance;
2058 kumpf           1.11  
2059                           CIMInstance indication = request->indicationInstance;
2060 kumpf           1.73  
2061 dj.gorey        1.135     PEG_TRACE_STRING (TRC_INDICATION_SERVICE, Tracer::LEVEL4,
2062 kumpf           1.73          "Received Indication " + indication.getClassName().getString());
2063                       
2064 kumpf           1.11      try
2065                           {
2066 kumpf           1.37          //
2067 kumpf           1.39          //  Check if property list contains all properties of class
2068 kumpf           1.37          //  If so, set to null
2069                               //
2070 kumpf           1.67          Array <CIMName> propertyNames;
2071 carolann.graves 1.142         Array <CIMName> indicationClassProperties;
2072 kumpf           1.67          CIMPropertyList propertyList;
2073 kumpf           1.83          for (Uint32 i = 0; i < indication.getPropertyCount(); i++)
2074 carolann.graves 1.142         {
2075 kumpf           1.67              propertyNames.append(indication.getProperty(i).getName());
2076 carolann.graves 1.142         }
2077 dj.gorey        1.135         propertyList = _checkPropertyList (propertyNames,
2078 chip            1.162             request->nameSpace, indication.getClassName (),
2079 carolann.graves 1.142             indicationClassProperties);
2080 kumpf           1.37  
2081 carolann.graves 1.147         //
2082 chip            1.162         //  Retrieve the matching subscriptions based on the class name and
2083 carolann.graves 1.147         //  namespace of the generated indication
2084 chip            1.162         //  If the provider did not include subscriptions in the
2085 carolann.graves 1.147         //  SubscriptionInstanceNamesContainer, the matchedSubscriptions
2086 chip            1.162         //  represent the subscriptions to which the indication should be
2087 carolann.graves 1.147         //  forwarded, if the filter criteria are met
2088                               //
2089 kumpf           1.63          Array <CIMNamespaceName> nameSpaces;
2090 kumpf           1.15          nameSpaces.append (request->nameSpace);
2091 kumpf           1.67  
2092 carolann.graves 1.147 #ifdef PEGASUS_INDICATION_PERFINST
2093 chip            1.162         stopWatch.reset();
2094                               stopWatch.start();
2095 carolann.graves 1.147 #endif
2096                       
2097                               matchedSubscriptions = _getMatchingSubscriptions(
2098                                   indication.getClassName (), nameSpaces, propertyList,
2099                                   true, request->provider);
2100                       
2101                       #ifdef PEGASUS_INDICATION_PERFINST
2102 chip            1.162         stopWatch.stop();
2103 carolann.graves 1.147 
2104                               Tracer::trace (TRC_INDICATION_SERVICE_INTERNAL, Tracer::LEVEL2,
2105                                   "%s: %.3f seconds",
2106 chip            1.162             "Get Matching Subscriptions", stopWatch.getElapsed());
2107 carolann.graves 1.147 #endif
2108                       
2109                               //
2110 chip            1.162         //  If the provider included subscriptions in the
2111                               //  SubscriptionInstanceNamesContainer, verify that each subscription
2112                               //  specified by the provider matches the class name and namespace of
2113                               //  the generated indication by looking for the subscription instance
2114 carolann.graves 1.147         //  in the list of matching subscriptions from the Subscription Classes
2115                               //  table
2116 chip            1.162         //  The subset of subscriptions included by the provider that also
2117 carolann.graves 1.147         //  appear in the matchedSubscriptions list represent the subscriptions
2118                               //  to which the indication should be forwarded, if the filter criteria
2119                               //  are met
2120 chip            1.162         //  Any subscription included by the provider but not matching the
2121                               //  the class name and namespace of the generated indication is ignored
2122 carolann.graves 1.147         //
2123 kumpf           1.68          if (request->subscriptionInstanceNames.size() > 0)
2124                               {
2125 carolann.graves 1.147             Array <CIMInstance> providedSubscriptions;
2126                       
2127 kumpf           1.73  #ifdef PEGASUS_INDICATION_PERFINST
2128 chip            1.162             stopWatch.reset();
2129                                   stopWatch.start();
2130 kumpf           1.73  #endif
2131                       
2132 dj.gorey        1.135             for (Uint32 i = 0; i < request->subscriptionInstanceNames.size();
2133 kumpf           1.68                   i++)
2134                                   {
2135 kumpf           1.73                  //
2136                                       //  Look up the subscription in the active subscriptions table
2137                                       //
2138                                       ActiveSubscriptionsTableEntry tableValue;
2139 kumpf           1.114                 if (_subscriptionTable->getSubscriptionEntry
2140                                           (request->subscriptionInstanceNames [i], tableValue))
2141 kumpf           1.73                  {
2142 carolann.graves 1.141                     //
2143 carolann.graves 1.147                     //  Verify that each subscription specified by the provider
2144 chip            1.162                     //  matches the class name and namespace of the generated
2145                                           //  indication by looking for the subscription instance in
2146 carolann.graves 1.147                     //  the list of matching subscriptions
2147 carolann.graves 1.141                     //
2148 carolann.graves 1.147                     Boolean found = false;
2149                                           for (Uint32 i = 0; i < matchedSubscriptions.size(); i++)
2150                                           {
2151 chip            1.162                         if (matchedSubscriptions [i].identical
2152 carolann.graves 1.147                             (tableValue.subscription))
2153                                               {
2154                                                   found = true;
2155                                                   break;
2156                                               }
2157                                           }
2158                                           if (found)
2159 carolann.graves 1.141                     {
2160 carolann.graves 1.147                         providedSubscriptions.append (tableValue.subscription);
2161 carolann.graves 1.141                     }
2162 kumpf           1.73                  }
2163 kumpf           1.68              }
2164 kumpf           1.73  
2165                       #ifdef PEGASUS_INDICATION_PERFINST
2166 chip            1.162             stopWatch.stop();
2167 kumpf           1.73  
2168 dj.gorey        1.135             Tracer::trace (TRC_INDICATION_SERVICE_INTERNAL, Tracer::LEVEL2,
2169                                       "%s: %.3f seconds",
2170 chip            1.162                 "Look up Subscriptions", stopWatch.getElapsed());
2171 kumpf           1.73  #endif
2172 carolann.graves 1.147             matchedSubscriptions = providedSubscriptions;
2173 kumpf           1.68          }
2174 kumpf           1.11  
2175 carolann.graves 1.147         //
2176 chip            1.162         //  For each matching subscription, determine whether the filter
2177 carolann.graves 1.147         //  criteria are met by the generated indication, and if so, forward to
2178                               //  the handler
2179                               //
2180 kumpf           1.83          for (Uint32 i = 0; i < matchedSubscriptions.size(); i++)
2181 kumpf           1.11          {
2182                                   match = true;
2183                       
2184 kumpf           1.137             //
2185                                   // copy the indication, format it based on the subscription,
2186                                   // and send the formatted indication to the consumer
2187                                   //
2188                                   CIMInstance formattedIndication = indication.clone();
2189 kumpf           1.66  
2190 kumpf           1.15              //
2191                                   //  Check for expired subscription
2192                                   //
2193 dj.gorey        1.135             try
2194 kumpf           1.15              {
2195 dj.gorey        1.135                 if (_isExpired (matchedSubscriptions [i]))
2196                                       {
2197                                           CIMObjectPath path = matchedSubscriptions [i].getPath ();
2198                                           _deleteExpiredSubscription (path);
2199                                           // If the subscription is expired, delete and continue to the next one.
2200                                           continue;
2201                                       }
2202                                   } catch (DateTimeOutOfRangeException &)
2203                                   {
2204                                       //
2205                                       //  This instance from the repository is invalid
2206                                       //  Skip it
2207                                       //
2208 kumpf           1.15                  continue;
2209                                   }
2210                       
2211 chuck           1.149             String queryLanguage;
2212                                   CIMNamespaceName sourceNamespace;
2213 kumpf           1.114             _subscriptionRepository->getFilterProperties (
2214 kumpf           1.46                  matchedSubscriptions[i],
2215 chuck           1.149                 filterQuery,
2216                                       sourceNamespace,
2217                                       queryLanguage);
2218                       
2219                                   QueryExpression queryExpr = _getQueryExpression(filterQuery,
2220                                                                                   queryLanguage,
2221 carolann.graves 1.175                                                             request->nameSpace);
2222 kumpf           1.11  
2223 kumpf           1.73  #ifdef PEGASUS_INDICATION_PERFINST
2224 chip            1.162             stopWatch.reset();
2225                                   stopWatch.start();
2226 kumpf           1.73  #endif
2227 chuck           1.149             if (!queryExpr.evaluate(indication))
2228                                   {
2229 carolann.graves 1.165                 match = false;
2230 chuck           1.149             }
2231 kumpf           1.73  #ifdef PEGASUS_INDICATION_PERFINST
2232 chip            1.162             stopWatch.stop();
2233 kumpf           1.73  
2234 chuck           1.149             Tracer::trace (TRC_INDICATION_SERVICE_INTERNAL, Tracer::LEVEL2,
2235                                                  "%s: %.3f seconds",
2236 chip            1.162                            "Evaluate WHERE clause", stopWatch.getElapsed());
2237 kumpf           1.73  #endif
2238 kumpf           1.1   
2239 kumpf           1.11              if (match)
2240 kumpf           1.1               {
2241 kumpf           1.67                  //
2242 chuck           1.149                 // Format the indication
2243 kumpf           1.67                  //
2244 chuck           1.149                 // This is a two part process:
2245 carolann.graves 1.142                 //
2246 chuck           1.149                 // 1) Call QueryExpression::applyProjection to remove properties
2247                                       // not listed in the SELECT clause.  Note: for CQL, this will handle
2248 chip            1.162                 // properties on embedded objects.
2249                                       //
2250 chuck           1.149                 // QueryExpression::applyProjection throws an exception if
2251                                       // the indication is missing a required property in the SELECT
2252                                       // clause.  Although _getMatchingSubscriptions checked for
2253 chip            1.162                 // the indication missing required properties, it would have
2254 chuck           1.149                 // not detected missing required embedded object properties for CQL.
2255                                       // So, we need to catch the missing property exception here.
2256                                       //
2257                                       // 2) Remove any properties that may be left on the indication
2258                                       // that are not in the indication class.  These are properties
2259                                       // added by the provider incorrectly.  It is possible that
2260                                       // these properties will remain after applyProjection if the
2261                                       // SELECT clause happens to have a property name not on the
2262 chuck           1.153                 // indication class, and the indication has that same property.
2263 chip            1.162                 // Note: If SELECT includes all properties ("*"), it's still
2264                                       // necessary to check, in case the provider added properties not in
2265 chuck           1.149                 // the indication class.
2266                                       //
2267 chip            1.162                 try
2268 chuck           1.149                 {
2269 carolann.graves 1.175                   queryExpr.applyProjection(formattedIndication, true);
2270 chuck           1.149                 }
2271                                       catch (QueryRuntimePropertyException& re)
2272                                       {
2273                                         // The indication was missing a required property.
2274 chuck           1.153                   // The call to _getMatchingSubscriptions above checked for
2275 chip            1.162                   // missing required properties on the base indication object
2276 chuck           1.153                   // so this can only happen for CQL when an embedded object
2277                                         // property is missing.
2278                                         //
2279 chuck           1.149                   // Since this is the same as the indication
2280 chuck           1.153                   // not matching the subscription, just swallow the exception,
2281                                         // and skip this subscription.
2282 chuck           1.149                   PEG_TRACE_STRING (TRC_INDICATION_SERVICE, Tracer::LEVEL4,
2283 carolann.graves 1.164                       "Apply Projection error: " + re.getMessage());
2284 chuck           1.153                   continue;
2285 chuck           1.149                 }
2286 chip            1.162 
2287                                       // Remove any remaining properties not in the indication class
2288 chuck           1.149                 // from the indication.
2289 carolann.graves 1.142                 //
2290                                       for (Uint32 j = 0; j < propertyNames.size(); j++)
2291                                       {
2292 chuck           1.149                   Uint32 rmIndex = formattedIndication.findProperty(propertyNames[j]);
2293                                         if (rmIndex != PEG_NOT_FOUND &&
2294                                             !ContainsCIMName (indicationClassProperties,
2295                                                               propertyNames[j]))
2296                                         {
2297                                           formattedIndication.removeProperty(rmIndex);
2298                                         }
2299 kumpf           1.137                 }
2300 dj.gorey        1.135 
2301 kumpf           1.114                 handlerNamedInstance = _subscriptionRepository->getHandler
2302 kumpf           1.67                      (matchedSubscriptions[i]);
2303 kumpf           1.1   
2304 chuck           1.75  // l10n
2305                       // Note: not expecting any language in the response
2306 kumpf           1.67                  CIMRequestMessage * handler_request =
2307                                           new CIMHandleIndicationRequestMessage (
2308                                               XmlWriter::getNextMessageId (),
2309                                               request->nameSpace,
2310                                               handlerNamedInstance,
2311                                               formattedIndication,
2312 carolann.graves 1.165                         matchedSubscriptions[i],
2313 chuck           1.75                          QueueIdStack(_handlerService, getQueueId()),
2314                                               String::EMPTY,
2315 se.gupta        1.132                         String::EMPTY);
2316 dj.gorey        1.135 
2317 kumpf           1.137                 handler_request->operationContext = request->operationContext;
2318 kumpf           1.79  
2319 kumpf           1.67                  AsyncOpNode* op = this->get_op();
2320 kumpf           1.11  
2321 dj.gorey        1.135                 AsyncLegacyOperationStart *async_req =
2322 kumpf           1.11                      new AsyncLegacyOperationStart(
2323 kumpf           1.67                      op,
2324                                           _handlerService,
2325                                           handler_request,
2326                                           _queueId);
2327                       
2328 dj.gorey        1.135                 PEG_TRACE_STRING(TRC_INDICATION_SERVICE, Tracer::LEVEL4,
2329                                           "Sending (SendAsync) Indication to " +
2330                                           ((MessageQueue::lookup(_handlerService)) ?
2331 kumpf           1.67                      String(((MessageQueue::lookup
2332 dj.gorey        1.135                     (_handlerService))->getQueueName())) :
2333                                           String("BAD queue name")) +
2334 kumpf           1.119                     " via CIMHandleIndicationRequestMessage");
2335 dj.gorey        1.135 
2336 kumpf           1.119                 SendAsync (op,
2337                                                  _handlerService,
2338                                                  IndicationService::_handleIndicationCallBack,
2339                                                  this,
2340                                                  (void *) & (matchedSubscriptions [i]));
2341 kumpf           1.1               }
2342                               }
2343 carolann.graves 1.167 
2344                               //
2345                               //  Log a trace message if there were no matching subscriptions
2346                               //
2347                               if (matchedSubscriptions.size() == 0)
2348                               {
2349                                   PEG_TRACE_STRING (TRC_INDICATION_SERVICE, Tracer::LEVEL2,
2350                                       "No matching subscriptions found for "
2351                                       + indication.getClassName ().getString () +
2352                                       " indication");
2353                               }
2354 kumpf           1.11      }
2355                           catch (CIMException& exception)
2356                           {
2357 kumpf           1.23          response->cimException = exception;
2358 kumpf           1.119 
2359 carolann.graves 1.180         PEG_TRACE_STRING (TRC_DISCARDED_DATA, Tracer::LEVEL2,
2360 kumpf           1.119             "CIMException caught in attempting to process indication: " +
2361                                   exception.getMessage ());
2362 kumpf           1.11      }
2363                           catch (Exception& exception)
2364                           {
2365 kumpf           1.119         response->cimException = PEGASUS_CIM_EXCEPTION (CIM_ERR_FAILED,
2366                                   exception.getMessage ());
2367                       
2368 carolann.graves 1.180         PEG_TRACE_STRING (TRC_DISCARDED_DATA, Tracer::LEVEL2,
2369 kumpf           1.119             "Exception caught in attempting to process indication: " +
2370                                   exception.getMessage ());
2371 kumpf           1.11      }
2372 kumpf           1.173     catch (...)
2373                           {
2374                               response->cimException = PEGASUS_CIM_EXCEPTION_L(
2375                                   CIM_ERR_FAILED,
2376                                   MessageLoaderParms(
2377                                       "IndicationService.IndicationService.UNKNOWN_ERROR",
2378                                       "Unknown Error"));
2379                       
2380 carolann.graves 1.180         PEG_TRACE_STRING (TRC_DISCARDED_DATA, Tracer::LEVEL2,
2381                                   "Unknown error occurred in attempting to process indication.");
2382 kumpf           1.173     }
2383 kumpf           1.11  
2384 carolann.graves 1.145     _enqueueResponse (request, response);
2385 kumpf           1.11  
2386 kumpf           1.48      PEG_METHOD_EXIT ();
2387 kumpf           1.119     return;
2388                       }
2389                       
2390                       void IndicationService::_handleIndicationCallBack (
2391                           AsyncOpNode * operation,
2392                           MessageQueue * destination,
2393                           void * userParameter)
2394                       {
2395                           PEG_METHOD_ENTER (TRC_INDICATION_SERVICE,
2396                               "IndicationService::_handleIndicationCallBack");
2397                       
2398 dj.gorey        1.135     IndicationService * service =
2399 kumpf           1.119         static_cast <IndicationService *> (destination);
2400 dj.gorey        1.135     CIMInstance * subscription =
2401 kumpf           1.137         reinterpret_cast <CIMInstance *> (userParameter);
2402 dj.gorey        1.135     AsyncReply * asyncReply =
2403 kumpf           1.201         static_cast<AsyncReply *>(operation->removeResponse());
2404 dj.gorey        1.135     CIMHandleIndicationResponseMessage * handlerResponse =
2405 kumpf           1.119         reinterpret_cast <CIMHandleIndicationResponseMessage *>
2406                               ((static_cast <AsyncLegacyOperationResult *>
2407                               (asyncReply))->get_result ());
2408                           PEGASUS_ASSERT (handlerResponse != 0);
2409 kumpf           1.11  
2410 kumpf           1.119     if (handlerResponse->cimException.getCode () != CIM_ERR_SUCCESS)
2411                           {
2412                               PEG_TRACE_STRING (TRC_DISCARDED_DATA, Tracer::LEVEL2,
2413                                   "Sending Indication and HandlerService returns "
2414 dj.gorey        1.135             "CIMException: " +
2415 kumpf           1.119             handlerResponse->cimException.getMessage ());
2416                       
2417                               //
2418                               //  ATTN-CAKG-P1-20020326: Implement subscription's OnFatalErrorPolicy
2419                               //
2420                               //service->_subscriptionRepository->reconcileFatalError (*subscription);
2421                           }
2422                       
2423                           delete handlerResponse;
2424                           delete asyncReply;
2425                           operation->release ();
2426                           service->return_op (operation);
2427                       
2428                           PEG_METHOD_EXIT ();
2429 kumpf           1.11  }
2430                       
2431                       void IndicationService::_handleNotifyProviderRegistrationRequest
2432                           (const Message* message)
2433                       {
2434 kumpf           1.114     PEG_METHOD_ENTER ( TRC_INDICATION_SERVICE,
2435 kumpf           1.48          "IndicationService::_handleNotifyProviderRegistrationRequest");
2436 kumpf           1.11  
2437 dj.gorey        1.135     CIMNotifyProviderRegistrationRequestMessage* request =
2438 kumpf           1.11          (CIMNotifyProviderRegistrationRequestMessage*) message;
2439                       
2440 kumpf           1.23      CIMException cimException;
2441 mday            1.8   
2442 kumpf           1.137     ProviderIdContainer pidc = request->operationContext.get
2443 chip            1.162         (ProviderIdContainer::NAME);
2444                           CIMInstance provider = pidc.getProvider();
2445 se.gupta        1.129     CIMInstance providerModule = pidc.getModule();
2446 kumpf           1.63      CIMName className = request->className;
2447                           Array <CIMNamespaceName> newNameSpaces = request->newNamespaces;
2448                           Array <CIMNamespaceName> oldNameSpaces = request->oldNamespaces;
2449 kumpf           1.11      CIMPropertyList newPropertyNames = request->newPropertyNames;
2450                           CIMPropertyList oldPropertyNames = request->oldPropertyNames;
2451 kumpf           1.6   
2452 kumpf           1.46      Array <CIMInstance> newSubscriptions;
2453                           Array <CIMInstance> formerSubscriptions;
2454 kumpf           1.16      Array <ProviderClassList> indicationProviders;
2455                           ProviderClassList indicationProvider;
2456 kumpf           1.6   
2457 kumpf           1.11      newSubscriptions.clear ();
2458                           formerSubscriptions.clear ();
2459 kumpf           1.1   
2460 kumpf           1.11      switch (request->operation)
2461                           {
2462                               case OP_CREATE:
2463                               {
2464 kumpf           1.10              //
2465 kumpf           1.11              //  Get matching subscriptions
2466 kumpf           1.10              //
2467 dj.gorey        1.135             newSubscriptions = _getMatchingSubscriptions (className,
2468 kumpf           1.15                  newNameSpaces, newPropertyNames);
2469 kumpf           1.11  
2470                                   break;
2471                               }
2472 kumpf           1.10  
2473 kumpf           1.11          case OP_DELETE:
2474                               {
2475 kumpf           1.10              //
2476 kumpf           1.11              //  Get matching subscriptions
2477 kumpf           1.10              //
2478 dj.gorey        1.135             formerSubscriptions = _getMatchingSubscriptions (className,
2479 kumpf           1.15                  oldNameSpaces, oldPropertyNames);
2480 kumpf           1.11  
2481                                   break;
2482 kumpf           1.10          }
2483                       
2484 kumpf           1.11          case OP_MODIFY:
2485 kumpf           1.10          {
2486 kumpf           1.11              //
2487                                   //  Get lists of affected subscriptions
2488                                   //
2489 kumpf           1.15              _getModifiedSubscriptions (className, newNameSpaces, oldNameSpaces,
2490 dj.gorey        1.135                 newPropertyNames, oldPropertyNames,
2491 kumpf           1.15                  newSubscriptions, formerSubscriptions);
2492 kumpf           1.11  
2493                                   break;
2494 kumpf           1.10          }
2495 kumpf           1.11          default:
2496                                   //
2497                                   //  Error condition: operation not supported
2498                                   //
2499 kumpf           1.48              PEG_METHOD_EXIT ();
2500 kumpf           1.57              throw PEGASUS_CIM_EXCEPTION(CIM_ERR_NOT_SUPPORTED, String::EMPTY);
2501 kumpf           1.11              break;
2502                           }  // switch
2503                       
2504                           //
2505                           //  Construct provider class list from input provider and class name
2506                           //
2507 kumpf           1.12      indicationProvider.provider = provider;
2508 kumpf           1.15      indicationProvider.providerModule = providerModule;
2509 kumpf           1.11      indicationProvider.classList.append (className);
2510                           indicationProviders.append (indicationProvider);
2511 kumpf           1.10  
2512 kumpf           1.11      if (newSubscriptions.size () > 0)
2513                           {
2514                               CIMPropertyList requiredProperties;
2515                               String condition;
2516 kumpf           1.124         String query;
2517 kumpf           1.11          String queryLanguage;
2518 kumpf           1.10  
2519                               //
2520 dj.gorey        1.135         //  Send Create or Modify request for each subscription that can newly
2521 kumpf           1.16          //  be supported
2522 kumpf           1.10          //
2523 kumpf           1.83          for (Uint32 i = 0; i < newSubscriptions.size (); i++)
2524 kumpf           1.10          {
2525 kumpf           1.63              CIMNamespaceName sourceNameSpace;
2526 kumpf           1.73              Array <CIMName> indicationSubclasses;
2527 carolann.graves 1.186             _getCreateParams (newSubscriptions [i], indicationSubclasses,
2528 kumpf           1.124                 requiredProperties, sourceNameSpace, condition,
2529                                       query, queryLanguage);
2530 kumpf           1.11  
2531                                   //
2532 kumpf           1.39              //  NOTE: These Create or Modify requests are not associated with a
2533                                   //  user request, so there is no associated authType or userName
2534 dj.gorey        1.135             //  The Creator from the subscription instance is used for
2535 kumpf           1.16              //  userName, and authType is not set
2536 kumpf           1.15              //
2537 dj.gorey        1.135             //  NOTE: the subscriptions in the newSubscriptions list came from
2538                                   //  the IndicationService's internal hash tables, and thus
2539 kumpf           1.80              //  each instance is known to have a valid Creator property
2540                                   //
2541 kumpf           1.46              CIMInstance instance = newSubscriptions [i];
2542 kumpf           1.15              String creator = instance.getProperty (instance.findProperty
2543 kumpf           1.38                  (PEGASUS_PROPERTYNAME_INDSUB_CREATOR)).getValue ().toString ();
2544 kumpf           1.11  
2545 chuck           1.77  // l10n start
2546 kumpf           1.195             AcceptLanguageList acceptLangs;
2547 kumpf           1.114             Uint32 propIndex = instance.findProperty
2548 dj.gorey        1.135                 (PEGASUS_PROPERTYNAME_INDSUB_ACCEPTLANGS);
2549 chuck           1.77              if (propIndex != PEG_NOT_FOUND)
2550                                   {
2551 kumpf           1.194                 String acceptLangsString;
2552                                       instance.getProperty(propIndex).getValue().get(
2553                                           acceptLangsString);
2554                                       if (acceptLangsString.size())
2555                                       {
2556                                           acceptLangs = LanguageParser::parseAcceptLanguageHeader(
2557                                               acceptLangsString);
2558                                       }
2559 chuck           1.77              }
2560 kumpf           1.195             ContentLanguageList contentLangs;
2561 kumpf           1.114             propIndex = instance.findProperty
2562 dj.gorey        1.135                 (PEGASUS_PROPERTYNAME_INDSUB_CONTENTLANGS);
2563 chuck           1.77              if (propIndex != PEG_NOT_FOUND)
2564                                   {
2565 kumpf           1.194                 String contentLangsString;
2566                                       instance.getProperty(propIndex).getValue().get(
2567                                           contentLangsString);
2568                                       if (contentLangsString.size())
2569                                       {
2570                                           contentLangs = LanguageParser::parseContentLanguageHeader(
2571                                               contentLangsString);
2572                                       }
2573 chuck           1.77              }
2574                       // l10n end
2575 chuck           1.75  
2576 kumpf           1.11              //
2577 kumpf           1.73              //  Look up the subscription in the active subscriptions table
2578 kumpf           1.16              //
2579 kumpf           1.73              ActiveSubscriptionsTableEntry tableValue;
2580 dj.gorey        1.135             if (_subscriptionTable->getSubscriptionEntry
2581 kumpf           1.114                 (newSubscriptions [i].getPath (), tableValue))
2582 kumpf           1.16              {
2583 kumpf           1.70                  //
2584 dj.gorey        1.135                 //  If the provider is already in the subscription's list,
2585 kumpf           1.73                  //  send a Modify request, otherwise send a Create request
2586 kumpf           1.70                  //
2587 dj.gorey        1.135                 Uint32 providerIndex = _subscriptionTable->providerInList
2588 kumpf           1.114                     (provider, tableValue);
2589 kumpf           1.73                  if (providerIndex != PEG_NOT_FOUND)
2590                                       {
2591                                           //
2592                                           //  Send Modify requests
2593                                           //
2594 chuck           1.75  // l10n
2595 carolann.graves 1.164                     _sendWaitModifyRequests (indicationProviders,
2596 dj.gorey        1.135                         sourceNameSpace,
2597 kumpf           1.124                         requiredProperties, condition, query, queryLanguage,
2598 chuck           1.75                          newSubscriptions [i],
2599 kumpf           1.194                         acceptLangs,
2600                                               contentLangs,
2601 chuck           1.75                          creator);
2602 kumpf           1.73                  }
2603                                       else
2604                                       {
2605                                           //
2606                                           //  Send Create requests
2607                                           //
2608 dj.gorey        1.135 // l10n
2609 carolann.graves 1.172                     Array <ProviderClassList> acceptedProviders;
2610                                           acceptedProviders = _sendWaitCreateRequests
2611 carolann.graves 1.164                         (indicationProviders,
2612 dj.gorey        1.135                         sourceNameSpace, requiredProperties, condition,
2613                                               query, queryLanguage, newSubscriptions [i],
2614 kumpf           1.194                         acceptLangs,
2615                                               contentLangs,
2616 kumpf           1.88                          creator);
2617 kumpf           1.137 
2618 carolann.graves 1.172                     if (acceptedProviders.size () > 0)
2619 carolann.graves 1.164                     {
2620                                               //
2621                                               //  Provider is not yet in the list for this
2622                                               //  subscription; add provider to the list
2623                                               //
2624                                               _subscriptionTable->updateProviders
2625                                                   (instance.getPath (), indicationProvider, true);
2626                                           }
2627 kumpf           1.73                  }
2628 kumpf           1.114             }
2629 kumpf           1.16              else
2630 kumpf           1.10              {
2631 kumpf           1.16                  //
2632 kumpf           1.73                  //  Subscription not found in Active Subscriptions table
2633 kumpf           1.16                  //
2634 kumpf           1.1               }
2635                               }
2636 kumpf           1.87  
2637                               //
2638                               //  NOTE: When a provider that was previously not serving a subscription
2639 kumpf           1.88          //  now serves the subscription due to a provider registration change,
2640 kumpf           1.87          //  a log message is sent, even if there were previously other providers
2641                               //  serving the subscription
2642                               //
2643                       
2644                               //
2645                               //  Log a message for each subscription
2646                               //
2647 kumpf           1.114         CIMClass providerClass = _subscriptionRepository->getClass
2648 kumpf           1.105             (PEGASUS_NAMESPACENAME_INTEROP, PEGASUS_CLASSNAME_PROVIDER,
2649                                    true, true, false, CIMPropertyList ());
2650 kumpf           1.87          CIMInstance providerCopy = provider.clone ();
2651                               CIMObjectPath path = providerCopy.buildPath (providerClass);
2652                               providerCopy.setPath (path);
2653 carolann.graves 1.164         String logString1 = getProviderLogString (providerCopy);
2654                       
2655 kumpf           1.87          for (Uint32 j = 0; j < newSubscriptions.size (); j++)
2656                               {
2657 kumpf           1.98              //
2658                                   //  Get Provider Name, Subscription Filter Name and Handler Name
2659                                   //
2660 dj.gorey        1.135             String logString2 = _getSubscriptionLogString
2661 kumpf           1.98                  (newSubscriptions [j]);
2662                       
2663 kumpf           1.87              Logger::put_l (Logger::STANDARD_LOG, System::CIMSERVER,
2664 kumpf           1.88                  Logger::WARNING, _MSG_PROVIDER_NOW_SERVING_KEY,
2665 carolann.graves 1.186                 _MSG_PROVIDER_NOW_SERVING, logString1, logString2,
2666                                       newSubscriptions [j].getPath ().getNameSpace ().getString ());
2667 kumpf           1.87          }
2668 kumpf           1.1       }
2669 kumpf           1.11  
2670                           if (formerSubscriptions.size () > 0)
2671 kumpf           1.1       {
2672 kumpf           1.16          CIMPropertyList requiredProperties;
2673                               String condition;
2674 kumpf           1.124         String query;
2675 kumpf           1.16          String queryLanguage;
2676 kumpf           1.11  
2677                               //
2678 dj.gorey        1.135         //  Send Delete or Modify request for each subscription that can no
2679 kumpf           1.16          //  longer be supported
2680 kumpf           1.11          //
2681 kumpf           1.83          for (Uint32 i = 0; i < formerSubscriptions.size (); i++)
2682 kumpf           1.11          {
2683 kumpf           1.80              //
2684 kumpf           1.39              //  NOTE: These Delete or Modify requests are not associated with a
2685                                   //  user request, so there is no associated authType or userName
2686 kumpf           1.16              //  The Creator from the subscription instance is used for userName,
2687                                   //  and authType is not set
2688 kumpf           1.80              //
2689 dj.gorey        1.135             //  NOTE: the subscriptions in the formerSubscriptions list came
2690                                   //  from the IndicationService's internal hash tables, and thus
2691 kumpf           1.80              //  each instance is known to have a valid Creator property
2692                                   //
2693 kumpf           1.46              CIMInstance instance = formerSubscriptions [i];
2694 kumpf           1.15              String creator = instance.getProperty (instance.findProperty
2695 kumpf           1.38                  (PEGASUS_PROPERTYNAME_INDSUB_CREATOR)).getValue ().toString ();
2696 chuck           1.77  // l10n start
2697 kumpf           1.195             AcceptLanguageList acceptLangs;
2698 carolann.graves 1.164             Uint32 propIndex = instance.findProperty
2699                                       (PEGASUS_PROPERTYNAME_INDSUB_ACCEPTLANGS);
2700 chuck           1.77              if (propIndex != PEG_NOT_FOUND)
2701                                   {
2702 kumpf           1.194                 String acceptLangsString;
2703                                       instance.getProperty(propIndex).getValue().get(
2704                                           acceptLangsString);
2705                                       if (acceptLangsString.size())
2706                                       {
2707                                           acceptLangs = LanguageParser::parseAcceptLanguageHeader(
2708                                               acceptLangsString);
2709                                       }
2710 chuck           1.77              }
2711 kumpf           1.195             ContentLanguageList contentLangs;
2712 carolann.graves 1.164             propIndex = instance.findProperty
2713                                       (PEGASUS_PROPERTYNAME_INDSUB_CONTENTLANGS);
2714 chuck           1.77              if (propIndex != PEG_NOT_FOUND)
2715                                   {
2716 kumpf           1.194                 String contentLangsString;
2717                                       instance.getProperty(propIndex).getValue().get(
2718                                           contentLangsString);
2719                                       if (contentLangsString.size())
2720                                       {
2721                                           contentLangs = LanguageParser::parseContentLanguageHeader(
2722                                               contentLangsString);
2723                                       }
2724 chuck           1.77              }
2725                       // l10n end
2726 chuck           1.75  
2727 kumpf           1.16              //
2728 kumpf           1.73              //  Look up the subscription in the active subscriptions table
2729 kumpf           1.37              //  If class list contains only the class name from the current
2730 kumpf           1.38              //  operation, send a Delete request
2731                                   //  Otherwise, send a Modify request
2732 kumpf           1.16              //
2733 kumpf           1.73              ActiveSubscriptionsTableEntry tableValue;
2734 dj.gorey        1.135             if (_subscriptionTable->getSubscriptionEntry
2735 kumpf           1.114                 (formerSubscriptions [i].getPath (), tableValue))
2736 kumpf           1.16              {
2737 dj.gorey        1.135                 Uint32 providerIndex = _subscriptionTable->providerInList
2738 kumpf           1.114                     (provider, tableValue);
2739 kumpf           1.73                  if (providerIndex != PEG_NOT_FOUND)
2740 kumpf           1.37                  {
2741 kumpf           1.88                      CIMNamespaceName sourceNameSpace;
2742                                           Array <CIMName> indicationSubclasses;
2743 carolann.graves 1.186                     _getCreateParams (formerSubscriptions [i],
2744                                               indicationSubclasses, requiredProperties,
2745                                               sourceNameSpace, condition, query, queryLanguage);
2746 kumpf           1.88  
2747 kumpf           1.73                      //
2748 dj.gorey        1.135                     //  If class list contains only the class name from the
2749 kumpf           1.73                      //  current delete, send a Delete request
2750                                           //
2751 dj.gorey        1.135                     if ((tableValue.providers [providerIndex].classList.size ()
2752 kumpf           1.73                              == 1) &&
2753 dj.gorey        1.135                         (tableValue.providers [providerIndex].classList
2754 kumpf           1.73                              [0].equal (className)))
2755                                           {
2756 chuck           1.75  // l10n
2757 carolann.graves 1.164                         _sendWaitDeleteRequests (indicationProviders,
2758 kumpf           1.137                             sourceNameSpace,
2759 dj.gorey        1.135                             formerSubscriptions [i],
2760 kumpf           1.194                             acceptLangs,
2761                                                   contentLangs,
2762 chuck           1.75                              creator);
2763 kumpf           1.137 
2764                                               //
2765                                               //
2766 carolann.graves 1.164                         //
2767                                               _subscriptionTable->updateProviders
2768                                                   (instance.getPath (), indicationProvider, false);
2769 kumpf           1.73                      }
2770 dj.gorey        1.135 
2771 kumpf           1.70                      //
2772 kumpf           1.73                      //  Otherwise, send a Modify request
2773 kumpf           1.70                      //
2774 kumpf           1.73                      else
2775                                           {
2776 dj.gorey        1.135                         Uint32 classIndex = _subscriptionTable->classInList
2777 kumpf           1.114                             (className, tableValue.providers [providerIndex]);
2778 kumpf           1.73                          if (classIndex != PEG_NOT_FOUND)
2779                                               {
2780 kumpf           1.137                             //
2781 carolann.graves 1.164                             //  Send Modify requests
2782 kumpf           1.137                             //
2783 carolann.graves 1.164 // l10n
2784                                                   _sendWaitModifyRequests (indicationProviders,
2785                                                       sourceNameSpace,
2786                                                       requiredProperties, condition,
2787                                                       query, queryLanguage,
2788                                                       formerSubscriptions [i],
2789 kumpf           1.194                                 acceptLangs,
2790                                                       contentLangs,
2791 carolann.graves 1.164                                 creator);
2792 kumpf           1.73                          }
2793                                               else
2794                                               {
2795 dj.gorey        1.135                             PEG_TRACE_STRING (TRC_INDICATION_SERVICE_INTERNAL,
2796                                                       Tracer::LEVEL2,
2797 kumpf           1.88                                  "Class " + className.getString() +
2798                                                       " not found in tableValue.providers");
2799 kumpf           1.73                          }
2800                                           }
2801                                       }
2802                                       else
2803                                       {
2804 kumpf           1.37                      //
2805 dj.gorey        1.135                     //  The subscription was not served by the provider
2806 kumpf           1.37                      //
2807                                       }
2808 kumpf           1.16              }
2809                                   else
2810                                   {
2811 kumpf           1.37                  //
2812 kumpf           1.88                  //  Subscription not found in Active Subscriptions table
2813 kumpf           1.37                  //
2814 kumpf           1.16              }
2815 kumpf           1.11          }
2816 kumpf           1.1   
2817 kumpf           1.87  #if 0
2818 kumpf           1.11          //
2819                               //  Create NoProviderAlertIndication instance
2820                               //  ATTN: NoProviderAlertIndication must be defined
2821                               //
2822 dj.gorey        1.135         CIMInstance indicationInstance = _createAlertInstance
2823 kumpf           1.11              (_CLASS_NO_PROVIDER_ALERT, formerSubscriptions);
2824 dj.gorey        1.135 
2825 kumpf           1.11          //
2826                               //  Send NoProviderAlertIndication to each unique handler instance
2827                               //
2828 kumpf           1.73          Tracer::trace (TRC_INDICATION_SERVICE, Tracer::LEVEL4,
2829 carolann.graves 1.192             "Sending NoProvider Alert for %u subscriptions",
2830 kumpf           1.73              formerSubscriptions.size ());
2831 kumpf           1.11          _sendAlerts (formerSubscriptions, indicationInstance);
2832 kumpf           1.87  #endif
2833                               //
2834 kumpf           1.88          //  NOTE: When a provider that was previously serving a subscription
2835                               //  no longer serves the subscription due to a provider registration
2836                               //  change, a log message is sent, even if there are still other
2837 kumpf           1.87          //  providers serving the subscription
2838                               //
2839                       
2840                               //
2841                               //  Log a message for each subscription
2842                               //
2843 kumpf           1.114         CIMClass providerClass = _subscriptionRepository->getClass
2844 kumpf           1.105             (PEGASUS_NAMESPACENAME_INTEROP, PEGASUS_CLASSNAME_PROVIDER,
2845                                    true, true, false, CIMPropertyList ());
2846 kumpf           1.87          CIMInstance providerCopy = provider.clone ();
2847                               CIMObjectPath path = providerCopy.buildPath (providerClass);
2848                               providerCopy.setPath (path);
2849 carolann.graves 1.164         String logString1 = getProviderLogString (providerCopy);
2850                       
2851 kumpf           1.87          for (Uint32 j = 0; j < formerSubscriptions.size (); j++)
2852                               {
2853 kumpf           1.98              //
2854                                   //  Get Provider Name, Subscription Filter Name and Handler Name
2855                                   //
2856 dj.gorey        1.135             String logString2 = _getSubscriptionLogString
2857 kumpf           1.98                  (formerSubscriptions [j]);
2858                       
2859 dj.gorey        1.135             Logger::put_l (Logger::STANDARD_LOG, System::CIMSERVER,
2860                                       Logger::WARNING, _MSG_PROVIDER_NO_LONGER_SERVING_KEY,
2861 carolann.graves 1.186                 _MSG_PROVIDER_NO_LONGER_SERVING, logString1, logString2,
2862                                       formerSubscriptions[j].getPath().getNameSpace().getString());
2863 kumpf           1.87          }
2864 kumpf           1.11      }
2865 kumpf           1.1   
2866 kumpf           1.137     //
2867 carolann.graves 1.164     //  Send response
2868 kumpf           1.137     //
2869 carolann.graves 1.164     CIMResponseMessage * response = request->buildResponse ();
2870                           response->cimException = cimException;
2871                           _enqueueResponse (request, response);
2872 kumpf           1.137 
2873 kumpf           1.48      PEG_METHOD_EXIT ();
2874 kumpf           1.1   }
2875                       
2876 kumpf           1.114 void IndicationService::_handleNotifyProviderTerminationRequest
2877                           (const Message * message)
2878 kumpf           1.73  {
2879                           PEG_METHOD_ENTER (TRC_INDICATION_SERVICE,
2880 kumpf           1.114         "IndicationService::_handleNotifyProviderTermination");
2881 kumpf           1.73  
2882 kumpf           1.46      Array <CIMInstance> providerSubscriptions;
2883 kumpf           1.11      CIMInstance indicationInstance;
2884                       
2885 chip            1.162     CIMNotifyProviderTerminationRequestMessage* request =
2886 kumpf           1.137         (CIMNotifyProviderTerminationRequestMessage*) message;
2887 kumpf           1.11  
2888 kumpf           1.38      Array <CIMInstance> providers = request->providers;
2889 kumpf           1.11  
2890 kumpf           1.83      for (Uint32 i = 0; i < providers.size (); i++)
2891 kumpf           1.38      {
2892                               //
2893                               //  Get list of affected subscriptions
2894                               //
2895 carolann.graves 1.198         //  _subscriptionTable->reflectProviderDisable also updates the
2896 kumpf           1.114         //  Active Subscriptions hash table, and implements each subscription's
2897                               //  On Fatal Error policy, if necessary
2898 kumpf           1.73          //
2899 kumpf           1.38          providerSubscriptions.clear ();
2900 carolann.graves 1.198         providerSubscriptions = _subscriptionTable->reflectProviderDisable
2901 kumpf           1.114             (providers [i]);
2902 dj.gorey        1.135 
2903 kumpf           1.73          if (providerSubscriptions.size () > 0)
2904                               {
2905                                   //
2906                                   //  NOTE: When a provider that was previously serving a subscription
2907                                   //  no longer serves the subscription due to a provider termination,
2908                                   //  an alert is always sent, even if there are still other providers
2909                                   //  serving the subscription
2910                                   //
2911 dj.gorey        1.135 
2912 kumpf           1.87  #if 0
2913 kumpf           1.73              //
2914                                   //  Create ProviderTerminatedAlertIndication instance
2915                                   //  ATTN: ProviderTerminatedAlertIndication must be defined
2916                                   //
2917 dj.gorey        1.135             indicationInstance = _createAlertInstance
2918 kumpf           1.73                  (_CLASS_PROVIDER_TERMINATED_ALERT, providerSubscriptions);
2919 dj.gorey        1.135 
2920 kumpf           1.73              //
2921 dj.gorey        1.135             //  Send ProviderTerminatedAlertIndication to each unique handler
2922 kumpf           1.73              //  instance
2923                                   //
2924                                   Tracer::trace (TRC_INDICATION_SERVICE, Tracer::LEVEL4,
2925 carolann.graves 1.192                 "Sending ProviderDisabled Alert for %u subscriptions",
2926 kumpf           1.73                  providerSubscriptions.size ());
2927                                   _sendAlerts (providerSubscriptions, indicationInstance);
2928 kumpf           1.87  #endif
2929                                   //
2930                                   //  Log a message for each subscription
2931                                   //
2932 kumpf           1.114             CIMClass providerClass = _subscriptionRepository->getClass
2933 kumpf           1.105                 (PEGASUS_NAMESPACENAME_INTEROP, PEGASUS_CLASSNAME_PROVIDER,
2934                                        true, true, false, CIMPropertyList ());
2935 kumpf           1.87              CIMInstance providerCopy = providers [i].clone ();
2936                                   CIMObjectPath path = providerCopy.buildPath (providerClass);
2937                                   providerCopy.setPath (path);
2938                                   for (Uint32 j = 0; j < providerSubscriptions.size (); j++)
2939                                   {
2940 kumpf           1.98                  //
2941                                       //  Get Provider Name, Subscription Filter Name and Handler Name
2942                                       //
2943 kumpf           1.114                 String logString1 = getProviderLogString (providerCopy);
2944 dj.gorey        1.135                 String logString2 = _getSubscriptionLogString
2945 kumpf           1.98                      (providerSubscriptions [j]);
2946                       
2947 dj.gorey        1.135                 Logger::put_l (Logger::STANDARD_LOG, System::CIMSERVER,
2948                                           Logger::WARNING, _MSG_PROVIDER_NO_LONGER_SERVING_KEY,
2949 carolann.graves 1.186                     _MSG_PROVIDER_NO_LONGER_SERVING, logString1, logString2,
2950                                           providerSubscriptions[j].getPath().getNameSpace().getString());
2951 kumpf           1.87              }
2952 kumpf           1.73          }
2953 kumpf           1.38      }
2954 kumpf           1.11  
2955 kumpf           1.137     CIMException cimException;
2956                       
2957 carolann.graves 1.145     CIMResponseMessage * response = request->buildResponse ();
2958                           response->cimException = cimException;
2959 kumpf           1.137     _enqueueResponse (request, response);
2960                       
2961 kumpf           1.48      PEG_METHOD_EXIT ();
2962 kumpf           1.11  }
2963 kumpf           1.1   
2964 kumpf           1.105 void IndicationService::_handleNotifyProviderEnableRequest
2965                           (const Message * message)
2966                       {
2967                           PEG_METHOD_ENTER (TRC_INDICATION_SERVICE,
2968 kumpf           1.114         "IndicationService::_handleNotifyProviderEnableRequest");
2969 kumpf           1.105 
2970                           CIMNotifyProviderEnableRequestMessage * request =
2971                               (CIMNotifyProviderEnableRequestMessage *) message;
2972 carolann.graves 1.198     ProviderIdContainer pidc = request->operationContext.get
2973                               (ProviderIdContainer::NAME);
2974 se.gupta        1.129     CIMInstance providerModule = pidc.getModule();
2975                           CIMInstance provider = pidc.getProvider();
2976 kumpf           1.105     Array <CIMInstance> capabilities = request->capInstances;
2977                       
2978 kumpf           1.118     CIMException cimException;
2979 carolann.graves 1.164     Array <CIMInstance> subscriptions;
2980                           Array <ProviderClassList> indicationProviders;
2981 kumpf           1.118 
2982 kumpf           1.105     //
2983 dj.gorey        1.135     //  Get class name, namespace names, and property list
2984 kumpf           1.105     //  from each capability instance
2985                           //
2986                           Uint32 numCapabilities = capabilities.size ();
2987                           for (Uint32 i = 0; i < numCapabilities; i++)
2988                           {
2989                               CIMName className;
2990                               Array <CIMNamespaceName> namespaceNames;
2991                               CIMPropertyList propertyList;
2992 carolann.graves 1.164         Array <CIMInstance> currentSubscriptions;
2993 kumpf           1.105 
2994                               try
2995                               {
2996                                   String cName;
2997 dj.gorey        1.135             capabilities [i].getProperty (capabilities [i].findProperty
2998 kumpf           1.105                 (_PROPERTY_CLASSNAME)).getValue ().get (cName);
2999                                   className = CIMName (cName);
3000                       
3001                                   Array <String> nsNames;
3002 dj.gorey        1.135             capabilities [i].getProperty (capabilities [i].findProperty
3003 kumpf           1.105                 (_PROPERTY_NAMESPACES)).getValue ().get (nsNames);
3004                                   for (Uint32 j = 0; j < nsNames.size (); j++)
3005                                   {
3006                                       namespaceNames.append (CIMNamespaceName (nsNames [j]));
3007                                   }
3008                       
3009                                   Array <String> pNames;
3010                                   Array <CIMName> propertyNames;
3011 dj.gorey        1.135             Uint32 propertiesIndex = capabilities [i].findProperty
3012 kumpf           1.105                 (_PROPERTY_SUPPORTEDPROPERTIES);
3013                                   if (propertiesIndex != PEG_NOT_FOUND)
3014                                   {
3015 dj.gorey        1.135                 CIMValue propertiesValue = capabilities [i].getProperty
3016 kumpf           1.105                     (propertiesIndex).getValue ();
3017                                       //
3018                                       //  If the property list is not null, set the property names
3019                                       //
3020                                       if (!propertiesValue.isNull ())
3021                                       {
3022                                           propertiesValue.get (pNames);
3023                                           for (Uint32 k = 0; k < pNames.size (); k++)
3024                                           {
3025                                               propertyNames.append (CIMName (pNames [k]));
3026                                           }
3027                                           propertyList.set (propertyNames);
3028                                       }
3029                                   }
3030                               }
3031                               catch (Exception & exception)
3032                               {
3033                                   //
3034                                   //  Error getting information from Capabilities instance
3035                                   //
3036 dj.gorey        1.135             PEG_TRACE_STRING (TRC_INDICATION_SERVICE_INTERNAL, Tracer::LEVEL2,
3037 kumpf           1.105                "Exception caught in handling provider enable notification: " +
3038                                       exception.getMessage ());
3039 kumpf           1.118 
3040 kumpf           1.137             cimException = CIMException(CIM_ERR_FAILED, exception.getMessage());
3041 kumpf           1.105             break;
3042                               }
3043                               catch (...)
3044                               {
3045 dj.gorey        1.135             PEG_TRACE_STRING (TRC_INDICATION_SERVICE_INTERNAL, Tracer::LEVEL2,
3046 kumpf           1.105                "Error in handling provider enable notification");
3047 kumpf           1.118 
3048 kumpf           1.137             cimException = PEGASUS_CIM_EXCEPTION_L(
3049                                       CIM_ERR_FAILED,
3050                                       MessageLoaderParms(
3051                                           "IndicationService.IndicationService.UNKNOWN_ERROR",
3052                                           "Unknown Error"));
3053 kumpf           1.105             break;
3054                               }
3055                       
3056                               //
3057                               //  Get matching subscriptions
3058                               //
3059 carolann.graves 1.164         currentSubscriptions = _getMatchingSubscriptions
3060                                   (className, namespaceNames, propertyList);
3061 kumpf           1.105 
3062 carolann.graves 1.164         for (Uint32 c = 0; c < currentSubscriptions.size (); c++)
3063 kumpf           1.105         {
3064 carolann.graves 1.164             Boolean inList = false;
3065 kumpf           1.105 
3066 carolann.graves 1.164             for (Uint32 m = 0; m < subscriptions.size (); m++)
3067 kumpf           1.105             {
3068                                       //
3069 carolann.graves 1.164                 //  If the current subscription is already in the list of
3070                                       //  matching subscriptions, add the current class to the
3071                                       //  indication provider class list for the subscription
3072 kumpf           1.105                 //
3073 carolann.graves 1.164                 if (currentSubscriptions [c].identical (subscriptions [m]))
3074 kumpf           1.105                 {
3075 carolann.graves 1.164                     inList = true;
3076                                           indicationProviders [m].classList.append (className);
3077                                           break;
3078 kumpf           1.105                 }
3079 carolann.graves 1.164             }
3080 dj.gorey        1.135 
3081 carolann.graves 1.164             if (!inList)
3082                                   {
3083 kumpf           1.105                 //
3084 carolann.graves 1.164                 //  If the current subscription is not already in the list of
3085                                       //  matching subscriptions, add it to the list and add the
3086                                       //  indication provider class list for the subscription
3087 kumpf           1.105                 //
3088 carolann.graves 1.164                 subscriptions.append (currentSubscriptions [c]);
3089                                       ProviderClassList indicationProvider;
3090                                       indicationProvider.provider = provider;
3091                                       indicationProvider.providerModule = providerModule;
3092                                       indicationProvider.classList.append (className);
3093                                       indicationProviders.append (indicationProvider);
3094                                   }
3095                               }
3096                           }  //  for each capability instance
3097                       
3098                           if (subscriptions.size () > 0)
3099                           {
3100                               CIMPropertyList requiredProperties;
3101                               String condition;
3102                               String query;
3103                               String queryLanguage;
3104                       
3105                               //
3106                               //  Get Provider Name
3107                               //
3108                               String logString1 = getProviderLogString (provider);
3109 carolann.graves 1.164 
3110                               for (Uint32 s = 0; s < subscriptions.size (); s++)
3111                               {
3112                                   CIMNamespaceName sourceNameSpace;
3113                                   Array <CIMName> indicationSubclasses;
3114                                   CIMInstance instance = subscriptions [s];
3115 carolann.graves 1.186             _getCreateParams (instance, indicationSubclasses,
3116                                       requiredProperties, sourceNameSpace, condition, query,
3117                                       queryLanguage);
3118 kumpf           1.105 
3119 carolann.graves 1.164             //
3120                                   //  NOTE: These Create requests are not associated with a
3121                                   //  user request, so there is no associated authType or userName
3122                                   //  The Creator from the subscription instance is used for
3123                                   //  userName, and authType is not set
3124                                   //
3125                                   //  NOTE: the subscriptions in the subscriptions list came from
3126                                   //  the IndicationService's internal hash tables, and thus
3127                                   //  each instance is known to have a valid Creator property
3128                                   //
3129                                   String creator = instance.getProperty (instance.findProperty
3130                                       (PEGASUS_PROPERTYNAME_INDSUB_CREATOR)).getValue
3131                                       ().toString ();
3132                       
3133 kumpf           1.195             AcceptLanguageList acceptLangs;
3134 carolann.graves 1.164             Uint32 propIndex = instance.findProperty
3135                                       (PEGASUS_PROPERTYNAME_INDSUB_ACCEPTLANGS);
3136                                   if (propIndex != PEG_NOT_FOUND)
3137                                   {
3138 kumpf           1.194                 String acceptLangsString;
3139                                       instance.getProperty(propIndex).getValue().get(
3140                                           acceptLangsString);
3141                                       if (acceptLangsString.size())
3142                                       {
3143                                           acceptLangs = LanguageParser::parseAcceptLanguageHeader(
3144                                               acceptLangsString);
3145                                       }
3146 carolann.graves 1.164             }
3147 kumpf           1.195             ContentLanguageList contentLangs;
3148 carolann.graves 1.164             propIndex = instance.findProperty
3149                                       (PEGASUS_PROPERTYNAME_INDSUB_CONTENTLANGS);
3150                                   if (propIndex != PEG_NOT_FOUND)
3151                                   {
3152 kumpf           1.194                 String contentLangsString;
3153                                       instance.getProperty(propIndex).getValue().get(
3154                                           contentLangsString);
3155                                       if (contentLangsString.size())
3156                                       {
3157                                           contentLangs = LanguageParser::parseContentLanguageHeader(
3158                                               contentLangsString);
3159                                       }
3160 carolann.graves 1.164             }
3161                       
3162                                   //
3163                                   //  Send Create requests
3164                                   //
3165                                   Array <ProviderClassList> currentIndicationProviders;
3166                                   currentIndicationProviders.append (indicationProviders [s]);
3167 carolann.graves 1.172             Array <ProviderClassList> acceptedProviders;
3168                                   acceptedProviders = _sendWaitCreateRequests
3169 carolann.graves 1.164                 (currentIndicationProviders,
3170                                       sourceNameSpace, requiredProperties, condition,
3171                                       query, queryLanguage, instance,
3172 kumpf           1.194                 acceptLangs,
3173                                       contentLangs,
3174 carolann.graves 1.164                 creator);
3175                       
3176 carolann.graves 1.172             if (acceptedProviders.size () > 0)
3177 carolann.graves 1.164             {
3178 kumpf           1.105                 //
3179 carolann.graves 1.164                 //  Get Subscription entry from Active Subscriptions table
3180 kumpf           1.137                 //
3181 carolann.graves 1.164                 ActiveSubscriptionsTableEntry tableValue;
3182                                       if (_subscriptionTable->getSubscriptionEntry
3183                                           (instance.getPath (), tableValue))
3184                                       {
3185                                           //
3186                                           //  Look for the provider in the subscription's list
3187                                           //
3188                                           Uint32 providerIndex =
3189                                               _subscriptionTable->providerInList
3190                                                   (indicationProviders [s].provider, tableValue);
3191                                           if (providerIndex != PEG_NOT_FOUND)
3192                                           {
3193                                               //
3194                                               //  Provider is already in the list for this
3195                                               //  subscription; add class to provider class list
3196                                               //
3197                                               for (Uint32 cn = 0;
3198                                                    cn < indicationProviders [s].classList.size ();
3199                                                    cn++)
3200                                               {
3201                                                   _subscriptionTable->updateClasses
3202 carolann.graves 1.164                                 (instance.getPath (),
3203                                                       indicationProviders [s].provider,
3204                                                       indicationProviders [s].classList [cn]);
3205                                               }
3206                                           }
3207                                           else
3208                                           {
3209                                               //
3210                                               //  Provider is not yet in the list for this
3211                                               //  subscription; add provider to the list
3212                                               //
3213                                               _subscriptionTable->updateProviders
3214                                                   (instance.getPath (), indicationProviders [s],
3215                                                   true);
3216 kumpf           1.137 
3217 carolann.graves 1.164                         //
3218                                               //  NOTE: When a provider that was previously not
3219                                               //  serving a subscription now serves the
3220                                               //  subscription due to a provider being enabled, a
3221                                               //  log message is sent, even if there were
3222                                               //  previously other providers serving the
3223                                               //  subscription
3224                                               //
3225 dj.gorey        1.135 
3226 carolann.graves 1.164                         //
3227                                               //  Get Subscription Filter Name and Handler Name
3228                                               //
3229                                               String logString2 = _getSubscriptionLogString
3230                                                   (subscriptions [s]);
3231 dj.gorey        1.135 
3232 carolann.graves 1.164                         //
3233                                               //  Log a message for each subscription
3234                                               //
3235                                               Logger::put_l (Logger::STANDARD_LOG,
3236                                                   System::CIMSERVER, Logger::WARNING,
3237                                                   _MSG_PROVIDER_NOW_SERVING_KEY,
3238 carolann.graves 1.186                             _MSG_PROVIDER_NOW_SERVING, logString1, logString2,
3239                                                   subscriptions[s].getPath().getNameSpace().getString());
3240 carolann.graves 1.164                     }
3241                                       }
3242                                   }  //  if any provider accepted the create subscription request
3243                               }  //  for each matching subscription
3244                           }  //  if any matching subscriptions
3245 kumpf           1.118 
3246 kumpf           1.137     //
3247 carolann.graves 1.164     //  Send response
3248 kumpf           1.137     //
3249 carolann.graves 1.164     CIMResponseMessage * response = request->buildResponse ();
3250                           response->cimException = cimException;
3251                           _enqueueResponse (request, response);
3252 kumpf           1.105 
3253                           PEG_METHOD_EXIT ();
3254                       }
3255                       
3256 carolann.graves 1.198 void IndicationService::_handleNotifyProviderFailRequest
3257                           (Message * message)
3258                       {
3259                           PEG_METHOD_ENTER (TRC_INDICATION_SERVICE,
3260                               "IndicationService::_handleNotifyProviderFailRequest");
3261                       
3262                           CIMNotifyProviderFailRequestMessage * request =
3263                               dynamic_cast <CIMNotifyProviderFailRequestMessage *> (message);
3264                       
3265                           String moduleName = request->moduleName;
3266                           String userName = request->userName;
3267                       
3268                           //
3269                           //  Determine providers in module that were serving active subscriptions
3270                           //  and update the Active Subscriptions Table
3271                           //
3272                           Array <ActiveSubscriptionsTableEntry> providerModuleSubscriptions =
3273                               _subscriptionTable->reflectProviderModuleFailure
3274                                   (moduleName, userName, _authenticationEnabled);
3275                       
3276                           //
3277 carolann.graves 1.198     //  FUTURE: Attempt to recreate the subscription state
3278                           //
3279                       
3280                           //
3281                           //  Send response
3282                           //
3283                           CIMResponseMessage * response = request->buildResponse ();
3284                           CIMNotifyProviderFailResponseMessage * failResponse =
3285                               (CIMNotifyProviderFailResponseMessage *) response;
3286                           failResponse->numSubscriptionsAffected =
3287                               providerModuleSubscriptions.size ();
3288                           _enqueueResponse (request, response);
3289                       }
3290                       
3291 kumpf           1.11  Boolean IndicationService::_canCreate (
3292                           CIMInstance & instance,
3293 kumpf           1.63      const CIMNamespaceName & nameSpace)
3294 kumpf           1.11  {
3295 kumpf           1.48      PEG_METHOD_ENTER (TRC_INDICATION_SERVICE, "IndicationService::_canCreate");
3296 kumpf           1.4   
3297 kumpf           1.11      // REVIEW: Derived classes of CIM_IndicationSubscription not
3298                           // handled. It is reasonable for a user to derive from this
3299                           // class and add extra properties.
3300 kumpf           1.4   
3301 kumpf           1.11      // REVIEW: how does the provider manager know to forward
3302                           // requests to this service? Is it by class name? If so,
3303                           // shouldn't the provider use an is-a operator on the new
3304                           // class?
3305 kumpf           1.4   
3306 kumpf           1.11      //
3307 carolann.graves 1.188     //  Validate that all properties in the instance are supported properties,
3308                           //  and reject create if an unknown, unsupported property is found
3309                           //
3310                           _checkSupportedProperties (instance);
3311                       
3312                           //
3313 kumpf           1.11      //  Check all required properties exist
3314 dj.gorey        1.135     //  For a property that has a default value, if it does not exist or is
3315 kumpf           1.34      //  null, add or set property with default value
3316                           //  For a property that has a specified set of valid values, validate
3317 kumpf           1.11      //
3318 yi.zhou         1.157     if ((instance.getClassName ().equal (PEGASUS_CLASSNAME_INDSUBSCRIPTION)) ||
3319 carolann.graves 1.179         (instance.getClassName ().equal
3320                                   (PEGASUS_CLASSNAME_FORMATTEDINDSUBSCRIPTION)))
3321 kumpf           1.11      {
3322                               //
3323                               //  Filter and Handler are key properties for Subscription
3324                               //  No other properties are required
3325                               //
3326 kumpf           1.116         _checkRequiredProperty (instance, _PROPERTY_FILTER, CIMTYPE_REFERENCE,
3327                                   _MSG_KEY_PROPERTY);
3328                               _checkRequiredProperty (instance, _PROPERTY_HANDLER, CIMTYPE_REFERENCE,
3329                                   _MSG_KEY_PROPERTY);
3330 kumpf           1.1   
3331 kumpf           1.34          //
3332 carolann.graves 1.205         //  Get filter and handler property values
3333 kumpf           1.108         //
3334                               CIMProperty filterProperty = instance.getProperty
3335                                   (instance.findProperty (_PROPERTY_FILTER));
3336                               CIMValue filterValue = filterProperty.getValue ();
3337                               CIMObjectPath filterPath;
3338                               filterValue.get (filterPath);
3339 carolann.graves 1.186 
3340 kumpf           1.108         CIMProperty handlerProperty = instance.getProperty
3341                                   (instance.findProperty (_PROPERTY_HANDLER));
3342                               CIMValue handlerValue = handlerProperty.getValue ();
3343                               CIMObjectPath handlerPath;
3344                               handlerValue.get (handlerPath);
3345 carolann.graves 1.186 
3346                               //
3347 carolann.graves 1.179         //  Currently, the Indication Service requires that a Subscription
3348                               //  instance and the Filter and Handler instances to which it refers
3349 carolann.graves 1.186         //  all be created on the same Host.
3350                               //  Developers are recommended NOT to include Host in the
3351 carolann.graves 1.179         //  Filter or Handler reference property values.
3352                               //
3353                       
3354                               //
3355                               //  If Host is included in a Filter or Handler reference property
3356 carolann.graves 1.189         //  value, attempt to validate that it is correct.
3357 carolann.graves 1.179         //  If Host cannot be validated, reject the create operation.
3358                               //
3359                               CIMObjectPath origFilterPath = filterPath;
3360                               if (filterPath.getHost () != String::EMPTY)
3361                               {
3362 carolann.graves 1.189             if (!System::sameHost (filterPath.getHost ()))
3363 carolann.graves 1.179             {
3364                                       //
3365                                       //  Reject subscription creation
3366                                       //
3367                                       String exceptionStr = _MSG_INVALID_VALUE;
3368                                       exceptionStr.append ("$0");
3369                                       exceptionStr.append (_MSG_FOR_PROPERTY);
3370                                       exceptionStr.append ("$1");
3371                       
3372                                       PEG_METHOD_EXIT ();
3373                                       throw PEGASUS_CIM_EXCEPTION_L (CIM_ERR_INVALID_PARAMETER,
3374                                           MessageLoaderParms (_MSG_INVALID_VALUE_FOR_PROPERTY_KEY,
3375 carolann.graves 1.186                     exceptionStr,
3376 carolann.graves 1.179                     origFilterPath.toString(), _PROPERTY_FILTER.getString()));
3377                                   }
3378                               }
3379                       
3380                               CIMObjectPath origHandlerPath = handlerPath;
3381                               if (handlerPath.getHost () != String::EMPTY)
3382                               {
3383 carolann.graves 1.189             if (!System::sameHost (handlerPath.getHost ()))
3384 carolann.graves 1.179             {
3385                                       //
3386                                       //  Reject subscription creation
3387                                       //
3388                                       String exceptionStr = _MSG_INVALID_VALUE;
3389                                       exceptionStr.append ("$0");
3390                                       exceptionStr.append (_MSG_FOR_PROPERTY);
3391                                       exceptionStr.append ("$1");
3392                       
3393                                       PEG_METHOD_EXIT ();
3394                                       throw PEGASUS_CIM_EXCEPTION_L (CIM_ERR_INVALID_PARAMETER,
3395                                           MessageLoaderParms (_MSG_INVALID_VALUE_FOR_PROPERTY_KEY,
3396 carolann.graves 1.186                     exceptionStr,
3397 carolann.graves 1.179                     origHandlerPath.toString(), _PROPERTY_HANDLER.getString()));
3398                                   }
3399                               }
3400                       
3401                               //
3402 carolann.graves 1.205         //  Get Filter namespace - if not set in Filter reference property
3403                               //  value, namespace is the namespace of the subscription
3404                               //
3405                               CIMNamespaceName filterNS = filterPath.getNameSpace ();
3406                               if (filterNS.isNull ())
3407                               {
3408                                   filterNS = nameSpace;
3409                               }
3410                       
3411                               //
3412                               //  Get Handler namespace - if not set in Handler reference property
3413                               //  value, namespace is the namespace of the subscription
3414                               //
3415                               CIMNamespaceName handlerNS = handlerPath.getNameSpace ();
3416                               if (handlerNS.isNull ())
3417                               {
3418                                   handlerNS = nameSpace;
3419                               }
3420                       
3421                               //
3422                               //  Validate the Filter and Handler reference properties
3423 carolann.graves 1.205         //  Ensure Filter and Handler instances can be retrieved from the
3424                               //  repository
3425                               //
3426                               CIMInstance filterInstance =
3427                                   _subscriptionRepository->getInstance (filterNS, filterPath,
3428                                   true, false, false, CIMPropertyList ());
3429                       
3430                               CIMInstance handlerInstance =
3431                                   _subscriptionRepository->getInstance (handlerNS, handlerPath,
3432                                   true, false, false, CIMPropertyList ());
3433                       
3434                               //
3435 kumpf           1.108         //  Set the key bindings in the subscription instance
3436                               //
3437                               Array <CIMKeyBinding> kb;
3438                               kb.append (CIMKeyBinding (_PROPERTY_FILTER, filterValue));
3439                               kb.append (CIMKeyBinding (_PROPERTY_HANDLER, handlerValue));
3440                       
3441                               CIMObjectPath instanceRef = instance.getPath ();
3442                               instanceRef.setKeyBindings (kb);
3443                               instanceRef.setNameSpace (nameSpace);
3444                               instance.setPath (instanceRef);
3445                       
3446                               //
3447                               //  Subscription State, Repeat Notification Policy, and On Fatal Error
3448 dj.gorey        1.135         //  Policy properties each has a default value, a corresponding
3449 kumpf           1.34          //  Other___ property, and a set of valid values
3450                               //
3451 dj.gorey        1.135         _checkPropertyWithOther (instance, _PROPERTY_STATE,
3452                                   _PROPERTY_OTHERSTATE, (Uint16) _STATE_ENABLED,
3453 kumpf           1.115             (Uint16) _STATE_OTHER, _validStates, _supportedStates);
3454 kumpf           1.22  
3455 kumpf           1.34          _checkPropertyWithOther (instance, _PROPERTY_REPEATNOTIFICATIONPOLICY,
3456 kumpf           1.22              _PROPERTY_OTHERREPEATNOTIFICATIONPOLICY, (Uint16) _POLICY_NONE,
3457 dj.gorey        1.135             (Uint16) _POLICY_OTHER, _validRepeatPolicies,
3458 kumpf           1.115             _supportedRepeatPolicies);
3459 kumpf           1.22  
3460 dj.gorey        1.135         _checkPropertyWithOther (instance, _PROPERTY_ONFATALERRORPOLICY,
3461                                   _PROPERTY_OTHERONFATALERRORPOLICY, (Uint16) _ERRORPOLICY_IGNORE,
3462                                   (Uint16) _ERRORPOLICY_OTHER, _validErrorPolicies,
3463 kumpf           1.115             _supportedErrorPolicies);
3464 kumpf           1.116 
3465                               //
3466 dj.gorey        1.135         //  For each remaining property, verify that if the property exists in
3467 kumpf           1.116         //  the instance it is of the correct type
3468                               //
3469 dj.gorey        1.135         _checkProperty (instance, _PROPERTY_FAILURETRIGGERTIMEINTERVAL,
3470 kumpf           1.116             CIMTYPE_UINT64);
3471                               _checkProperty (instance, _PROPERTY_LASTCHANGE, CIMTYPE_DATETIME);
3472                               _checkProperty (instance, _PROPERTY_DURATION, CIMTYPE_UINT64);
3473                               _checkProperty (instance, _PROPERTY_STARTTIME, CIMTYPE_DATETIME);
3474                               _checkProperty (instance, _PROPERTY_TIMEREMAINING, CIMTYPE_UINT64);
3475 dj.gorey        1.135         _checkProperty (instance, _PROPERTY_REPEATNOTIFICATIONINTERVAL,
3476 kumpf           1.116             CIMTYPE_UINT64);
3477 dj.gorey        1.135         _checkProperty (instance, _PROPERTY_REPEATNOTIFICATIONGAP,
3478 kumpf           1.116             CIMTYPE_UINT64);
3479 dj.gorey        1.135         _checkProperty (instance, _PROPERTY_REPEATNOTIFICATIONCOUNT,
3480 kumpf           1.116             CIMTYPE_UINT16);
3481 yi.zhou         1.157 
3482 carolann.graves 1.186         if (instance.getClassName ().equal (
3483                                   PEGASUS_CLASSNAME_FORMATTEDINDSUBSCRIPTION))
3484                               {
3485                                   Array<String> textFormatParams;
3486                                   CIMValue textFormatParamsValue;
3487                                   CIMClass indicationClass;
3488                       
3489                                   // get TextFormatParameters from instance
3490                                   Uint32 textFormatParamsPos =
3491                                   instance.findProperty(_PROPERTY_TEXTFORMATPARAMETERS);
3492 yi.zhou         1.157 
3493                                   if (textFormatParamsPos != PEG_NOT_FOUND)
3494 carolann.graves 1.186             {
3495                                       textFormatParamsValue = instance.getProperty(
3496                                           textFormatParamsPos).getValue();
3497 yi.zhou         1.157 
3498                                       if (!textFormatParamsValue.isNull())
3499 carolann.graves 1.186                 {
3500                                           textFormatParamsValue.get(textFormatParams);
3501                                       }
3502                                   }
3503 yi.zhou         1.157 
3504 carolann.graves 1.186             // get indication class
3505                                   indicationClass = _getIndicationClass (instance);
3506 yi.zhou         1.157 
3507                                   String textFormatStr;
3508                                   CIMValue textFormatValue;
3509                       
3510                                   // get TextFormatStr from instance
3511                                   Uint32 textFormatPos =
3512 chip            1.162             instance.findProperty(_PROPERTY_TEXTFORMAT);
3513 yi.zhou         1.157 
3514                                   if (textFormatPos != PEG_NOT_FOUND)
3515                                   {
3516                                       textFormatValue = instance.getProperty(
3517 carolann.graves 1.186                     textFormatPos).getValue();
3518 yi.zhou         1.157 
3519 yi.zhou         1.161 #if defined(PEGASUS_ENABLE_SYSTEM_LOG_HANDLER) || \
3520                           defined(PEGASUS_ENABLE_EMAIL_HANDLER)
3521 carolann.graves 1.186                 // if the value of textFormat is not null
3522 yi.zhou         1.157                 if (!(textFormatValue.isNull()) &&
3523 carolann.graves 1.186                     (textFormatValue.getType() == CIMTYPE_STRING) &&
3524                                           !(textFormatValue.isArray()))
3525                                       {
3526                                           textFormatValue.get(textFormatStr);
3527 yi.zhou         1.157 
3528 carolann.graves 1.186                     // Validates the syntax and the provided type for the
3529                                           // property TextFormat
3530                                           IndicationFormatter::validateTextFormat (
3531                                               textFormatStr, indicationClass,
3532                                               textFormatParams);
3533 chip            1.162 
3534 carolann.graves 1.186                     // Validates the property names in TextFormatParameters
3535                                           CIMNamespaceName sourceNameSpace;
3536 yi.zhou         1.157                     String query;
3537 carolann.graves 1.186                     String queryLanguage;
3538                                           CIMPropertyList propertyList;
3539 yi.zhou         1.157 
3540 carolann.graves 1.186                     //  Get filter properties
3541                                           _subscriptionRepository->getFilterProperties (instance,
3542                                               query, sourceNameSpace, queryLanguage);
3543 yi.zhou         1.157 
3544                                           //  Build the query expression from the filter query
3545 carolann.graves 1.186                     QueryExpression queryExpression = _getQueryExpression(query,
3546                                               queryLanguage, sourceNameSpace);
3547 chip            1.162 
3548 carolann.graves 1.186                     // the select clause projection
3549                                           propertyList = queryExpression.getPropertyList();
3550 chip            1.162 
3551 carolann.graves 1.186                     IndicationFormatter::validateTextFormatParameters(
3552                                           propertyList, indicationClass, textFormatParams);
3553                                       }
3554 yi.zhou         1.159 #endif
3555 yi.zhou         1.157             }
3556 carolann.graves 1.186         }
3557 dj.gorey        1.135     }
3558 kumpf           1.11      else  // Filter or Handler
3559                           {
3560 kumpf           1.1           //
3561 kumpf           1.11          //  Name, CreationClassName, SystemName, and SystemCreationClassName
3562 dj.gorey        1.135         //  are key properties for Filter and Handler
3563 carolann.graves 1.146         //  Name must exist
3564 kumpf           1.11          //  If others do not exist, add and set to default
3565 carolann.graves 1.146         //  If they exist but are NULL, set value to the default
3566                               //  If they exist and are not NULL, validate the value
3567 kumpf           1.1           //
3568 kumpf           1.116         _checkRequiredProperty (instance, _PROPERTY_NAME, CIMTYPE_STRING,
3569                                   _MSG_KEY_PROPERTY);
3570 kumpf           1.1   
3571 carolann.graves 1.146         _initOrValidateStringProperty (instance, _PROPERTY_CREATIONCLASSNAME,
3572                                   instance.getClassName ().getString ());
3573                       
3574                               _initOrValidateStringProperty (instance, _PROPERTY_SYSTEMNAME,
3575 kumpf           1.34              System::getFullyQualifiedHostName ());
3576 kumpf           1.1   
3577 chip            1.162         _initOrValidateStringProperty (instance,
3578 carolann.graves 1.146             _PROPERTY_SYSTEMCREATIONCLASSNAME,
3579 kumpf           1.34              System::getSystemCreationClassName ());
3580 kumpf           1.1   
3581 kumpf           1.64          if (instance.getClassName ().equal (PEGASUS_CLASSNAME_INDFILTER))
3582 kumpf           1.10          {
3583                                   //
3584 kumpf           1.11              //  Query and QueryLanguage properties are required for Filter
3585 kumpf           1.10              //
3586 kumpf           1.116             _checkRequiredProperty (instance, _PROPERTY_QUERY, CIMTYPE_STRING,
3587                                       _MSG_PROPERTY);
3588 dj.gorey        1.135             _checkRequiredProperty (instance, _PROPERTY_QUERYLANGUAGE,
3589 kumpf           1.116                 CIMTYPE_STRING, _MSG_PROPERTY);
3590 kumpf           1.1   
3591 kumpf           1.10              //
3592 kumpf           1.102             //  Validate the query language is supported
3593                                   //
3594                                   String queryLanguage;
3595                                   instance.getProperty (instance.findProperty
3596                                       (_PROPERTY_QUERYLANGUAGE)).getValue ().get (queryLanguage);
3597 chuck           1.149 
3598                       #ifdef PEGASUS_DISABLE_CQL
3599                                   // Special code to block CQL, if CQL is disabled
3600 kumpf           1.190             if (queryLanguage == "CIM:CQL")
3601 chuck           1.149             {
3602                                     // CQL is not allowed in this case
3603 carolann.graves 1.170               PEG_METHOD_EXIT();
3604 chuck           1.149               throw PEGASUS_CIM_EXCEPTION(CIM_ERR_NOT_SUPPORTED,
3605 chip            1.162                                           queryLanguage);
3606 kumpf           1.102             }
3607 chuck           1.149 #endif
3608 kumpf           1.102 
3609                                   //
3610 kumpf           1.11              //  Default value for Source Namespace is the namespace of the
3611                                   //  Filter registration
3612 kumpf           1.10              //
3613 dj.gorey        1.135             CIMNamespaceName sourceNameSpace = CIMNamespaceName
3614 kumpf           1.63                  (_checkPropertyWithDefault (instance, _PROPERTY_SOURCENAMESPACE,
3615                                        nameSpace.getString()));
3616 kumpf           1.15  
3617                                   //
3618                                   //  Validate the query and indication class name
3619                                   //  An exception is thrown if the query is invalid or the class
3620                                   //  is not an indication class
3621                                   //
3622                                   String filterQuery = instance.getProperty (instance.findProperty
3623                                       (_PROPERTY_QUERY)).getValue ().toString ();
3624 chuck           1.149 
3625                                   QueryExpression queryExpression;
3626                                   try
3627                                   {
3628                                     queryExpression =
3629 chip            1.162                 _getQueryExpression (filterQuery, queryLanguage, sourceNameSpace);
3630 chuck           1.149             }
3631                                   catch (QueryLanguageInvalidException&)
3632                                   {
3633                                     // The filter query had an invalid language name.
3634 carolann.graves 1.170               PEG_METHOD_EXIT();
3635 chuck           1.149               throw PEGASUS_CIM_EXCEPTION(CIM_ERR_NOT_SUPPORTED,
3636                                                                 queryLanguage);
3637                                   }
3638                       
3639 dj.gorey        1.135             CIMName indicationClassName = _getIndicationClassName
3640 chuck           1.149                 (queryExpression, sourceNameSpace);
3641 kumpf           1.117 
3642                                   //
3643 chuck           1.149             // Make sure that the FROM class exists in the repository.
3644 kumpf           1.117             //
3645                                   CIMClass indicationClass = _subscriptionRepository->getClass
3646                                       (sourceNameSpace, indicationClassName,
3647                                       false, false, false, CIMPropertyList ());
3648                       
3649                                   //
3650 chuck           1.149             // Validate all the properties in the SELECT statement exist
3651                                   // on their class context.
3652 kumpf           1.117             //
3653 chuck           1.149             try
3654                                   {
3655                                     queryExpression.validate();
3656                                   }
3657                                   catch (QueryMissingPropertyException& qmp)
3658                                   {
3659                                     // A property does not exist on the class it is scoped to.
3660 carolann.graves 1.170               PEG_METHOD_EXIT();
3661 chuck           1.149               throw PEGASUS_CIM_EXCEPTION
3662 chip            1.162                 (CIM_ERR_INVALID_PARAMETER, qmp.getMessage());
3663 chuck           1.149             }
3664                                   catch (QueryValidationException& qv)
3665 kumpf           1.117             {
3666 chuck           1.149               // Received some other validation error.
3667                                     // This includes detecting an array property
3668                                     // is in the WHERE list for WQL.
3669 carolann.graves 1.170               PEG_METHOD_EXIT();
3670 chuck           1.149               throw PEGASUS_CIM_EXCEPTION
3671 chip            1.162                 (CIM_ERR_NOT_SUPPORTED, qv.getMessage());
3672 kumpf           1.117             }
3673 kumpf           1.11          }
3674 kumpf           1.10  
3675 kumpf           1.11          //
3676 chip            1.162         //  Currently only five subclasses of the Listener Destination
3677 dj.gorey        1.135         //  class are supported -- further subclassing is not currently
3678 kumpf           1.11          //  supported
3679                               //
3680 dj.gorey        1.135         else if ((instance.getClassName ().equal
3681 kumpf           1.64                    (PEGASUS_CLASSNAME_INDHANDLER_CIMXML)) ||
3682 dj.gorey        1.135                  (instance.getClassName ().equal
3683 tony            1.103                   (PEGASUS_CLASSNAME_LSTNRDST_CIMXML)) ||
3684 chip            1.162          (instance.getClassName ().equal
3685                                 (PEGASUS_CLASSNAME_LSTNRDST_SYSTEM_LOG)) ||
3686                                (instance.getClassName ().equal
3687                                 (PEGASUS_CLASSNAME_LSTNRDST_EMAIL)) ||
3688 kumpf           1.64                   (instance.getClassName ().equal
3689                                         (PEGASUS_CLASSNAME_INDHANDLER_SNMP)))
3690 kumpf           1.11          {
3691 yi.zhou         1.161 #ifndef PEGASUS_ENABLE_SYSTEM_LOG_HANDLER
3692                                   if (instance.getClassName ().equal
3693 chip            1.162             (PEGASUS_CLASSNAME_LSTNRDST_SYSTEM_LOG))
3694 yi.zhou         1.161             {
3695                                       //
3696 carolann.graves 1.170                 //  The System Log Handler is not enabled currently,
3697 yi.zhou         1.161                 //  this class is not currently served by the Indication Service
3698                                       //
3699                                       PEG_METHOD_EXIT ();
3700                       
3701                                       throw PEGASUS_CIM_EXCEPTION_L (CIM_ERR_NOT_SUPPORTED,
3702 chip            1.162                 MessageLoaderParms(_MSG_CLASS_NOT_SERVED_KEY,
3703                                   _MSG_CLASS_NOT_SERVED));
3704                               }
3705 yi.zhou         1.161 #endif
3706                       
3707                       #if !defined(PEGASUS_ENABLE_EMAIL_HANDLER)
3708                       
3709                                   if (instance.getClassName ().equal
3710 chip            1.162             (PEGASUS_CLASSNAME_LSTNRDST_EMAIL))
3711 yi.zhou         1.161             {
3712                                       //
3713 carolann.graves 1.170                 //  The Email Handler is not enabled currently,
3714 yi.zhou         1.161                 //  this class is not currently served by the Indication Service
3715                                       //
3716                                       PEG_METHOD_EXIT ();
3717                       
3718                                       throw PEGASUS_CIM_EXCEPTION_L (CIM_ERR_NOT_SUPPORTED,
3719 chip            1.162                 MessageLoaderParms(_MSG_CLASS_NOT_SERVED_KEY,
3720                                          _MSG_CLASS_NOT_SERVED));
3721                               }
3722 yi.zhou         1.161 #endif
3723 kumpf           1.34              _checkPropertyWithOther (instance, _PROPERTY_PERSISTENCETYPE,
3724 kumpf           1.32                  _PROPERTY_OTHERPERSISTENCETYPE, (Uint16) _PERSISTENCE_PERMANENT,
3725 dj.gorey        1.135                 (Uint16) _PERSISTENCE_OTHER, _validPersistenceTypes,
3726 kumpf           1.115                 _supportedPersistenceTypes);
3727 kumpf           1.11  
3728 kumpf           1.116             //
3729 dj.gorey        1.135             //  For remaining property, verify that if the property exists in
3730 kumpf           1.116             //  the instance it is of the correct type
3731                                   //
3732                                   _checkProperty (instance, _PROPERTY_OWNER, CIMTYPE_STRING);
3733                       
3734 dj.gorey        1.135             if (instance.getClassName ().equal
3735                                       (PEGASUS_CLASSNAME_INDHANDLER_CIMXML) ||
3736                                       instance.getClassName ().equal
3737 kumpf           1.105                 (PEGASUS_CLASSNAME_LSTNRDST_CIMXML))
3738 kumpf           1.11              {
3739 kumpf           1.13                  //
3740 dj.gorey        1.135                 //  Destination property is required for CIMXML
3741 kumpf           1.13                  //  Handler subclass
3742                                       //
3743 chip            1.162                 _checkRequiredProperty (instance,
3744                                   PEGASUS_PROPERTYNAME_LSTNRDST_DESTINATION,
3745 kumpf           1.116                     CIMTYPE_STRING, _MSG_PROPERTY);
3746 kumpf           1.11              }
3747                       
3748 dj.gorey        1.135             if (instance.getClassName ().equal
3749 kumpf           1.64                  (PEGASUS_CLASSNAME_INDHANDLER_SNMP))
3750 kumpf           1.11              {
3751 kumpf           1.137                 //
3752 kumpf           1.74                  //  TargetHost property is required for SNMP
3753                                       //  Handler subclass
3754                                       //
3755 chip            1.162                 _checkRequiredProperty (instance,
3756                                   PEGASUS_PROPERTYNAME_LSTNRDST_TARGETHOST,
3757 kumpf           1.116                     CIMTYPE_STRING, _MSG_PROPERTY);
3758 kumpf           1.74  
3759 kumpf           1.11                  //
3760 kumpf           1.74                  //  TargetHostFormat property is required for SNMP
3761 kumpf           1.13                  //  Handler subclass
3762                                       //
3763 kumpf           1.74                  _checkRequiredProperty (instance, _PROPERTY_TARGETHOSTFORMAT,
3764 kumpf           1.116                     CIMTYPE_UINT16, _MSG_PROPERTY);
3765 kumpf           1.13  
3766                                       //
3767 kumpf           1.74                  //  SNMPVersion property is required for SNMP Handler
3768 kumpf           1.11                  //
3769 kumpf           1.74                  _checkRequiredProperty (instance, _PROPERTY_SNMPVERSION,
3770 kumpf           1.116                     CIMTYPE_UINT16, _MSG_PROPERTY);
3771 yi.zhou         1.193                                                                       
3772                                       // Currently, only SNMPv1 trap and SNMPv2C trap are supported,
3773                                       // verify if the value of SNMPVersion is one of them
3774                       
3775                                       _checkValue(instance, _PROPERTY_SNMPVERSION,
3776                                           _validSNMPVersion, _supportedSNMPVersion); 
3777                       
3778 kumpf           1.116                 //
3779 dj.gorey        1.135                 //  For each remaining property, verify that if the property
3780 kumpf           1.116                 //  exists in the instance it is of the correct type
3781                                       //
3782                                       _checkProperty (instance, _PROPERTY_PORTNUMBER, CIMTYPE_UINT32);
3783 dj.gorey        1.135                 _checkProperty (instance, _PROPERTY_SNMPSECURITYNAME,
3784 kumpf           1.116                     CIMTYPE_STRING);
3785 dj.gorey        1.135                 _checkProperty (instance, _PROPERTY_SNMPENGINEID,
3786 kumpf           1.116                     CIMTYPE_STRING);
3787 kumpf           1.11              }
3788 yi.zhou         1.160 
3789                                   if (instance.getClassName ().equal
3790                                       (PEGASUS_CLASSNAME_LSTNRDST_EMAIL))
3791                                   {
3792                                       //
3793                                       //  MailTo property is required for Email
3794                                       //  Handler subclass
3795                                       //
3796 chip            1.162                 _checkRequiredProperty (instance,
3797                                   PEGASUS_PROPERTYNAME_LSTNRDST_MAILTO,
3798 yi.zhou         1.168                     CIMTYPE_STRING, _MSG_PROPERTY, true);
3799 yi.zhou         1.160 
3800 chip            1.162         // get MailTo from handler instance
3801 yi.zhou         1.161                 Array<String> mailTo;
3802 chip            1.162             instance.getProperty(instance.findProperty(
3803 yi.zhou         1.160                   PEGASUS_PROPERTYNAME_LSTNRDST_MAILTO)).getValue().get(mailTo);
3804                       
3805 chip            1.162         // Build mail address string
3806                               String mailAddrStr = String::EMPTY;
3807                                   Uint32 mailAddrSize = mailTo.size();
3808                       
3809                               for (Uint32 i=0; i < mailAddrSize; i++)
3810                               {
3811                                   mailAddrStr.append(mailTo[i]);
3812                       
3813                                   if (i < (mailAddrSize - 1))
3814                                   {
3815                                       mailAddrStr.append(",");
3816                                   }
3817                               }
3818                       
3819                       
3820                               //
3821                               // Email address can not be an empty string
3822                               //
3823                               if (mailAddrStr == String::EMPTY)
3824                               {
3825                                   PEG_METHOD_EXIT();
3826 chip            1.162             throw PEGASUS_CIM_EXCEPTION_L (CIM_ERR_FAILED,
3827                                   MessageLoaderParms("IndicationService.IndicationService._MSG_DO_NOT_HAVE_EMAIL_ADDRESS",
3828                                   "Do not have an e-mail address."));
3829                               }
3830 yi.zhou         1.160 
3831                                       //
3832                                       //  MailSubject property is required for Email
3833                                       //  Handler subclass
3834                                       //
3835 chip            1.162                 _checkRequiredProperty (instance,
3836                                   PEGASUS_PROPERTYNAME_LSTNRDST_MAILSUBJECT,
3837 yi.zhou         1.160                     CIMTYPE_STRING, _MSG_PROPERTY);
3838                       
3839                                       //
3840                                       //  For MailCc property, verify that if the property
3841                                       //  exists in the instance it is of the correct type
3842                                       //
3843 chip            1.162                 _checkProperty (instance,
3844                                   PEGASUS_PROPERTYNAME_LSTNRDST_MAILCC,
3845 yi.zhou         1.187                     CIMTYPE_STRING, true);
3846 yi.zhou         1.160             }
3847 kumpf           1.11          }
3848                       
3849                               else
3850                               {
3851                                   //
3852                                   //  A class not currently served by the Indication Service
3853                                   //
3854 kumpf           1.48              PEG_METHOD_EXIT ();
3855 humberto        1.78  
3856 kumpf           1.116             // l10n
3857 humberto        1.78  
3858                                   // throw PEGASUS_CIM_EXCEPTION (CIM_ERR_NOT_SUPPORTED,
3859 kumpf           1.116             // _MSG_CLASS_NOT_SERVED);
3860 humberto        1.78  
3861 kumpf           1.116             throw PEGASUS_CIM_EXCEPTION_L (CIM_ERR_NOT_SUPPORTED,
3862                                   MessageLoaderParms(_MSG_CLASS_NOT_SERVED_KEY, _MSG_CLASS_NOT_SERVED));
3863 kumpf           1.11          }
3864 kumpf           1.1       }
3865                       
3866 kumpf           1.48      PEG_METHOD_EXIT ();
3867 kumpf           1.11      return true;
3868 kumpf           1.22  }
3869                       
3870 kumpf           1.34  void IndicationService::_checkRequiredProperty (
3871                           CIMInstance & instance,
3872 kumpf           1.63      const CIMName & propertyName,
3873 kumpf           1.116     const CIMType expectedType,
3874 yi.zhou         1.168     const String & message,
3875                           const Boolean isArray)
3876 kumpf           1.34  {
3877 kumpf           1.48      PEG_METHOD_ENTER (TRC_INDICATION_SERVICE,
3878 kumpf           1.114         "IndicationService::_checkRequiredProperty");
3879 kumpf           1.34  
3880                           Boolean missingProperty = false;
3881                       
3882                           //
3883                           //  Required property must exist in instance
3884                           //
3885 kumpf           1.52      if (instance.findProperty (propertyName) == PEG_NOT_FOUND)
3886 kumpf           1.34      {
3887                               missingProperty = true;
3888                           }
3889                           else
3890                           {
3891                               //
3892                               //  Get the property
3893                               //
3894                               CIMProperty theProperty = instance.getProperty
3895                                   (instance.findProperty (propertyName));
3896                               CIMValue theValue = theProperty.getValue ();
3897                       
3898                               //
3899                               //  Required property must have a non-null value
3900                               //
3901                               if (theValue.isNull ())
3902                               {
3903                                   missingProperty = true;
3904                               }
3905 kumpf           1.116         else
3906                               {
3907                                   //
3908                                   //  Check that the property value is of the correct type
3909                                   //
3910 david.dillard   1.174             if ((theValue.getType () != expectedType) ||
3911 carolann.graves 1.179                 (theValue.isArray () != isArray))
3912 kumpf           1.116             {
3913                                       if (theValue.isArray ())
3914                                       {
3915                                           String exceptionStr = _MSG_INVALID_TYPE;
3916                                           exceptionStr.append (_MSG_ARRAY_OF);
3917                                           exceptionStr.append ("$0");
3918                                           exceptionStr.append (_MSG_FOR_PROPERTY);
3919                                           exceptionStr.append ("$1");
3920                       
3921                                           PEG_METHOD_EXIT ();
3922                                           throw PEGASUS_CIM_EXCEPTION_L (CIM_ERR_INVALID_PARAMETER,
3923 dj.gorey        1.135                         MessageLoaderParms
3924                                                   (_MSG_INVALID_TYPE_ARRAY_OF_FOR_PROPERTY_KEY,
3925 kumpf           1.116                             exceptionStr,
3926 dj.gorey        1.135                             cimTypeToString (theValue.getType ()),
3927 kumpf           1.116                             propertyName.getString ()));
3928                                       }
3929                                       else
3930                                       {
3931                                           String exceptionStr = _MSG_INVALID_TYPE;
3932                                           exceptionStr.append ("$0");
3933                                           exceptionStr.append (_MSG_FOR_PROPERTY);
3934                                           exceptionStr.append ("$1");
3935                       
3936                                           PEG_METHOD_EXIT ();
3937                                           throw PEGASUS_CIM_EXCEPTION_L (CIM_ERR_INVALID_PARAMETER,
3938 dj.gorey        1.135                         MessageLoaderParms
3939                                                   (_MSG_INVALID_TYPE_FOR_PROPERTY_KEY,
3940 kumpf           1.116                             exceptionStr,
3941 dj.gorey        1.135                             cimTypeToString (theValue.getType ()),
3942 kumpf           1.116                             propertyName.getString ()));
3943                                       }
3944                                   }
3945                               }
3946 kumpf           1.34      }
3947                       
3948                           if (missingProperty)
3949                           {
3950 humberto        1.78  
3951 kumpf           1.116         // l10n
3952 humberto        1.78  
3953 kumpf           1.116         String exceptionStr = _MSG_MISSING_REQUIRED;
3954                               // exceptionStr.append (propertyName.getString());
3955                               exceptionStr.append ("$0");
3956                               exceptionStr.append (message);
3957 humberto        1.78  
3958 kumpf           1.116         String message_key;
3959 dj.gorey        1.135         if (strcmp(message.getCString(), _MSG_KEY_PROPERTY) == 0)
3960 kumpf           1.116         {
3961                                   message_key = _MSG_KEY_PROPERTY_KEY;
3962 dj.gorey        1.135         }
3963                               else if (strcmp(message.getCString(), _MSG_PROPERTY) == 0)
3964 kumpf           1.116         {
3965                                   message_key = _MSG_PROPERTY_KEY;
3966 dj.gorey        1.135         }
3967                               else
3968 kumpf           1.116         {
3969                                   message_key = String("");
3970                               }
3971                       
3972                               PEG_METHOD_EXIT ();
3973 dj.gorey        1.135 
3974 kumpf           1.116         // l10n
3975                               // throw PEGASUS_CIM_EXCEPTION (CIM_ERR_INVALID_PARAMETER,
3976                               //     exceptionStr);
3977                       
3978                               throw PEGASUS_CIM_EXCEPTION_L (CIM_ERR_INVALID_PARAMETER,
3979 dj.gorey        1.135             MessageLoaderParms(message_key,
3980 kumpf           1.116             exceptionStr, propertyName.getString()));
3981 humberto        1.78  
3982 kumpf           1.34      }
3983 kumpf           1.48      PEG_METHOD_EXIT ();
3984 kumpf           1.34  }
3985                       
3986                       void IndicationService::_checkPropertyWithOther (
3987 kumpf           1.22      CIMInstance & instance,
3988 kumpf           1.63      const CIMName & propertyName,
3989                           const CIMName & otherPropertyName,
3990 kumpf           1.22      const Uint16 defaultValue,
3991 kumpf           1.32      const Uint16 otherValue,
3992 kumpf           1.115     const Array <Uint16> & validValues,
3993                           const Array <Uint16> & supportedValues)
3994 kumpf           1.22  {
3995 kumpf           1.114     PEG_METHOD_ENTER (TRC_INDICATION_SERVICE,
3996                               "IndicationService::_checkPropertyWithOther");
3997                       
3998 kumpf           1.22      Uint16 result = defaultValue;
3999                       
4000                           //
4001                           //  If the property doesn't exist, add it with the default value
4002                           //
4003 kumpf           1.52      if (instance.findProperty (propertyName) == PEG_NOT_FOUND)
4004 kumpf           1.22      {
4005                               instance.addProperty (CIMProperty (propertyName,
4006                                   CIMValue (defaultValue)));
4007                           }
4008                           else
4009                           {
4010                               //
4011                               //  Get the property
4012                               //
4013                               CIMProperty theProperty = instance.getProperty
4014                                   (instance.findProperty (propertyName));
4015                               CIMValue theValue = theProperty.getValue ();
4016                       
4017                               //
4018 dj.gorey        1.135         //  Check that the value is of the correct type
4019 kumpf           1.80          //
4020                               if ((theValue.getType () != CIMTYPE_UINT16) || (theValue.isArray ()))
4021                               {
4022 humberto        1.82              //  L10N TODO DONE -- new throw of exception
4023 dj.gorey        1.135 
4024 kumpf           1.137             String exceptionStr;
4025 kumpf           1.80              if (theValue.isArray ())
4026                                   {
4027 kumpf           1.115                 MessageLoaderParms parms(
4028 dj.gorey        1.135                 "IndicationService.IndicationService._MSG_INVALID_TYPE_ARRAY_OF_FOR_PROPERTY",
4029 kumpf           1.115                 "Invalid type array of $0 for property $1",
4030                                       cimTypeToString(theValue.getType()),
4031                                       propertyName.getString());
4032 dj.gorey        1.135 
4033 kumpf           1.115                 exceptionStr.append(MessageLoader::getMessage(parms));
4034 humberto        1.82              }
4035 kumpf           1.115             else
4036                                   {
4037 kumpf           1.137                 MessageLoaderParms parms(
4038 dj.gorey        1.135                 "IndicationService.IndicationService._MSG_INVALID_TYPE_FOR_PROPERTY",
4039 kumpf           1.115                 "Invalid type $0 for property $1",
4040                                       cimTypeToString(theValue.getType()),
4041                                       propertyName.getString());
4042 dj.gorey        1.135 
4043 kumpf           1.115                 exceptionStr.append(MessageLoader::getMessage(parms));
4044 kumpf           1.80              }
4045                                   PEG_METHOD_EXIT ();
4046                                   throw PEGASUS_CIM_EXCEPTION (CIM_ERR_INVALID_PARAMETER,
4047                                       exceptionStr);
4048                               }
4049                       
4050                               //
4051 kumpf           1.22          //  If the value is null, set to the default value
4052                               //
4053                               if (theValue.isNull ())
4054                               {
4055                                   theProperty.setValue (CIMValue (defaultValue));
4056                               }
4057                               else
4058                               {
4059                                   theValue.get (result);
4060                       
4061                                   //
4062 kumpf           1.35              //  Validate the value
4063 kumpf           1.22              //
4064 kumpf           1.115             //  Note: Valid values are defined by the CIM Event Schema MOF
4065                                   //
4066 kumpf           1.32              if (!Contains (validValues, result))
4067                                   {
4068 kumpf           1.137                 // l10n
4069 humberto        1.78  
4070 kumpf           1.32                  String exceptionStr = _MSG_INVALID_VALUE;
4071 humberto        1.78                  // exceptionStr.append (theValue.toString ());
4072 kumpf           1.137                 exceptionStr.append ("$0");
4073 kumpf           1.32                  exceptionStr.append (_MSG_FOR_PROPERTY);
4074 humberto        1.78                  // exceptionStr.append (propertyName.getString());
4075 kumpf           1.137                 exceptionStr.append ("$1");
4076 humberto        1.78  
4077 kumpf           1.48                  PEG_METHOD_EXIT ();
4078 humberto        1.78  
4079                                       // throw PEGASUS_CIM_EXCEPTION (CIM_ERR_INVALID_PARAMETER,
4080 kumpf           1.137                 //    exceptionStr);
4081 humberto        1.78  
4082                                       throw PEGASUS_CIM_EXCEPTION_L (CIM_ERR_INVALID_PARAMETER,
4083 dj.gorey        1.135                     MessageLoaderParms(_MSG_INVALID_VALUE_FOR_PROPERTY_KEY,
4084 kumpf           1.115                     exceptionStr,
4085                                           theValue.toString(), propertyName.getString()));
4086                                   }
4087                       
4088                                   //
4089                                   //  Check for valid values that are not supported
4090                                   //
4091                                   //  Note: Supported values are a subset of the valid values
4092 dj.gorey        1.135             //  Some valid values, as defined in the MOF, are not currently
4093 kumpf           1.115             //  supported by the Pegasus IndicationService
4094                                   //
4095                                   if (!Contains (supportedValues, result))
4096                                   {
4097                                       String exceptionStr = _MSG_UNSUPPORTED_VALUE;
4098                                       exceptionStr.append ("$0");
4099                                       exceptionStr.append (_MSG_FOR_PROPERTY);
4100                                       exceptionStr.append ("$1");
4101                       
4102                                       PEG_METHOD_EXIT ();
4103                       
4104                                       throw PEGASUS_CIM_EXCEPTION_L (CIM_ERR_NOT_SUPPORTED,
4105                                           MessageLoaderParms (_MSG_UNSUPPORTED_VALUE_FOR_PROPERTY_KEY,
4106                                           exceptionStr,
4107                                           theValue.toString (), propertyName.getString ()));
4108 kumpf           1.32              }
4109 kumpf           1.22          }
4110                       
4111                               //
4112                               //  If the value is Other, the Other
4113 kumpf           1.116         //  property must exist, value must not be NULL and type must be String
4114 kumpf           1.22          //
4115                               if (result == otherValue)
4116                               {
4117 kumpf           1.52              if (instance.findProperty (otherPropertyName) == PEG_NOT_FOUND)
4118 kumpf           1.22              {
4119 kumpf           1.137                 // l10n
4120 dj.gorey        1.135 
4121 kumpf           1.137                 String exceptionStr = _MSG_MISSING_REQUIRED;
4122                                       // exceptionStr.append (otherPropertyName.getString());
4123                                       exceptionStr.append ("$0");
4124                                       exceptionStr.append (_MSG_PROPERTY);
4125 dj.gorey        1.135 
4126 kumpf           1.137                 PEG_METHOD_EXIT ();
4127 dj.gorey        1.135 
4128 kumpf           1.137                 // l10n
4129 humberto        1.78  
4130 kumpf           1.137                 // throw PEGASUS_CIM_EXCEPTION (CIM_ERR_INVALID_PARAMETER,
4131                                       //     exceptionStr);
4132 humberto        1.78  
4133 kumpf           1.137                 throw PEGASUS_CIM_EXCEPTION_L (CIM_ERR_INVALID_PARAMETER,
4134 dj.gorey        1.135                   MessageLoaderParms(_MSG_PROPERTY_KEY,
4135 kumpf           1.115                   exceptionStr,
4136                                         otherPropertyName.getString()));
4137 kumpf           1.22              }
4138                                   else
4139                                   {
4140                                       CIMProperty otherProperty = instance.getProperty
4141                                           (instance.findProperty (otherPropertyName));
4142                                       CIMValue theOtherValue = otherProperty.getValue ();
4143                                       if (theOtherValue.isNull ())
4144                                       {
4145 kumpf           1.137                     // l10n
4146 humberto        1.78  
4147 kumpf           1.22                      String exceptionStr = _MSG_MISSING_REQUIRED;
4148 humberto        1.78                      // exceptionStr.append (otherPropertyName.getString());
4149 kumpf           1.137                     exceptionStr.append ("$0");
4150 kumpf           1.22                      exceptionStr.append (_MSG_PROPERTY);
4151 humberto        1.78  
4152 kumpf           1.48                      PEG_METHOD_EXIT ();
4153 humberto        1.78  
4154 kumpf           1.137                     // l10n
4155 humberto        1.78                      // throw PEGASUS_CIM_EXCEPTION (CIM_ERR_INVALID_PARAMETER,
4156 kumpf           1.137                     //  exceptionStr);
4157 humberto        1.78  
4158 kumpf           1.137                     throw PEGASUS_CIM_EXCEPTION_L (CIM_ERR_INVALID_PARAMETER,
4159 dj.gorey        1.135                         MessageLoaderParms(_MSG_PROPERTY_KEY,
4160 kumpf           1.115                         exceptionStr,
4161                                               otherPropertyName.getString()));
4162 kumpf           1.22                  }
4163 kumpf           1.116                 else if (theOtherValue.getType () != CIMTYPE_STRING)
4164                                       {
4165                                           //
4166 dj.gorey        1.135                     //  Property exists and is not null,
4167 kumpf           1.116                     //  but is not of correct type
4168                                           //
4169                                           String exceptionStr = _MSG_INVALID_TYPE;
4170                                           exceptionStr.append ("$0");
4171                                           exceptionStr.append (_MSG_FOR_PROPERTY);
4172                                           exceptionStr.append ("$1");
4173                       
4174                                           PEG_METHOD_EXIT ();
4175                                           throw PEGASUS_CIM_EXCEPTION_L (CIM_ERR_INVALID_PARAMETER,
4176 dj.gorey        1.135                         MessageLoaderParms
4177                                                   (_MSG_INVALID_TYPE_FOR_PROPERTY_KEY,
4178 kumpf           1.116                             exceptionStr,
4179 dj.gorey        1.135                             cimTypeToString (theOtherValue.getType ()),
4180 kumpf           1.116                             otherPropertyName.getString ()));
4181                                       }
4182 kumpf           1.22              }
4183                               }
4184                       
4185                               //
4186                               //  If value is not Other, Other property must not exist
4187                               //  or must be NULL
4188                               //
4189 kumpf           1.52          else if (instance.findProperty (otherPropertyName) != PEG_NOT_FOUND)
4190 kumpf           1.22          {
4191                                   CIMProperty otherProperty = instance.getProperty
4192                                       (instance.findProperty (otherPropertyName));
4193                                   CIMValue theOtherValue = otherProperty.getValue ();
4194                                   if (!theOtherValue.isNull ())
4195                                   {
4196 kumpf           1.137                 // l10n
4197 dj.gorey        1.135 
4198 kumpf           1.137                 // String exceptionStr = otherPropertyName.getString();
4199                                       String exceptionStr ("$0");
4200                                       exceptionStr.append (_MSG_PROPERTY_PRESENT);
4201                                       // exceptionStr.append (propertyName.getString());
4202                                       exceptionStr.append ("$1");
4203                                       exceptionStr.append (_MSG_VALUE_NOT);
4204                                       // exceptionStr.append (CIMValue (otherValue).toString ());
4205                                       exceptionStr.append ("$2");
4206 humberto        1.78  
4207 kumpf           1.48                  PEG_METHOD_EXIT ();
4208 humberto        1.78  
4209 kumpf           1.137                 // l10n
4210 humberto        1.78  
4211                                       // throw PEGASUS_CIM_EXCEPTION (CIM_ERR_INVALID_PARAMETER,
4212 kumpf           1.137                 //  exceptionStr);
4213 humberto        1.78  
4214 kumpf           1.137                 throw PEGASUS_CIM_EXCEPTION_L (CIM_ERR_INVALID_PARAMETER,
4215 dj.gorey        1.135                     MessageLoaderParms(_MSG_PROPERTY_PRESENT_BUT_VALUE_NOT_KEY,
4216 kumpf           1.115                     exceptionStr,
4217                                           otherPropertyName.getString(),
4218                                           propertyName.getString(),
4219                                           CIMValue (otherValue).toString ()));
4220 kumpf           1.22              }
4221                               }
4222                           }
4223                       
4224 kumpf           1.48      PEG_METHOD_EXIT ();
4225 kumpf           1.1   }
4226                       
4227 kumpf           1.34  String IndicationService::_checkPropertyWithDefault (
4228                           CIMInstance & instance,
4229 kumpf           1.63      const CIMName & propertyName,
4230 kumpf           1.34      const String & defaultValue)
4231                       {
4232 kumpf           1.114     PEG_METHOD_ENTER (TRC_INDICATION_SERVICE,
4233                               "IndicationService::_checkPropertyWithDefault");
4234                       
4235 kumpf           1.34      String result = defaultValue;
4236                       
4237                           //
4238                           //  If the property doesn't exist, add it with the default value
4239                           //
4240 kumpf           1.52      if (instance.findProperty (propertyName) == PEG_NOT_FOUND)
4241 kumpf           1.34      {
4242                               instance.addProperty (CIMProperty (propertyName,
4243                                   CIMValue (defaultValue)));
4244                           }
4245                           else
4246                           {
4247                               //
4248                               //  Get the property
4249                               //
4250                               CIMProperty theProperty = instance.getProperty
4251                                   (instance.findProperty (propertyName));
4252                               CIMValue theValue = theProperty.getValue ();
4253                       
4254                               //
4255                               //  If the value is null, set to the default value
4256                               //
4257                               if (theValue.isNull ())
4258                               {
4259                                   theProperty.setValue (CIMValue (defaultValue));
4260                               }
4261 david.dillard   1.174         else if ((theValue.getType () != CIMTYPE_STRING) ||
4262 carolann.graves 1.165                  (theValue.isArray ()))
4263 kumpf           1.116         {
4264                                   //
4265                                   //  Property exists and is not null,
4266                                   //  but is not of correct type
4267                                   //
4268 carolann.graves 1.165             if (theValue.isArray ())
4269                                   {
4270                                       String exceptionStr = _MSG_INVALID_TYPE;
4271                                       exceptionStr.append (_MSG_ARRAY_OF);
4272                                       exceptionStr.append ("$0");
4273                                       exceptionStr.append (_MSG_FOR_PROPERTY);
4274                                       exceptionStr.append ("$1");
4275                       
4276                                       PEG_METHOD_EXIT ();
4277                                       throw PEGASUS_CIM_EXCEPTION_L (CIM_ERR_INVALID_PARAMETER,
4278                                           MessageLoaderParms
4279                                               (_MSG_INVALID_TYPE_ARRAY_OF_FOR_PROPERTY_KEY,
4280                                               exceptionStr,
4281                                               cimTypeToString (theValue.getType ()),
4282                                               propertyName.getString ()));
4283                                   }
4284                                   else
4285                                   {
4286                                       String exceptionStr = _MSG_INVALID_TYPE;
4287                                       exceptionStr.append ("$0");
4288                                       exceptionStr.append (_MSG_FOR_PROPERTY);
4289 carolann.graves 1.165                 exceptionStr.append ("$1");
4290 kumpf           1.116 
4291 carolann.graves 1.165                 PEG_METHOD_EXIT ();
4292                                       throw PEGASUS_CIM_EXCEPTION_L (CIM_ERR_INVALID_PARAMETER,
4293                                           MessageLoaderParms
4294                                               (_MSG_INVALID_TYPE_FOR_PROPERTY_KEY,
4295                                               exceptionStr,
4296                                               cimTypeToString (theValue.getType ()),
4297                                               propertyName.getString ()));
4298                                   }
4299 kumpf           1.116         }
4300 kumpf           1.34          else
4301                               {
4302                                   theValue.get (result);
4303                               }
4304                           }
4305                       
4306 gs.keenan       1.155     PEG_METHOD_EXIT ();
4307 kumpf           1.34      return result;
4308 kumpf           1.116 }
4309                       
4310 carolann.graves 1.146 String IndicationService::_initOrValidateStringProperty (
4311                           CIMInstance & instance,
4312                           const CIMName & propertyName,
4313                           const String & defaultValue)
4314                       {
4315                           PEG_METHOD_ENTER (TRC_INDICATION_SERVICE,
4316                               "IndicationService::_initOrValidateStringProperty");
4317                       
4318                           String result = defaultValue;
4319                       
4320                           String propertyValue = _checkPropertyWithDefault (instance, propertyName,
4321                               defaultValue);
4322                           if (propertyValue != defaultValue)
4323                           {
4324                               //
4325                               //  Property value specified is invalid
4326                               //
4327                               String exceptionStr = _MSG_INVALID_VALUE;
4328                               exceptionStr.append ("$0");
4329                               exceptionStr.append (_MSG_FOR_PROPERTY);
4330                               exceptionStr.append ("$1");
4331 carolann.graves 1.146 
4332                               PEG_METHOD_EXIT ();
4333                       
4334                               throw PEGASUS_CIM_EXCEPTION_L (CIM_ERR_INVALID_PARAMETER,
4335                                   MessageLoaderParms (_MSG_INVALID_VALUE_FOR_PROPERTY_KEY,
4336                                   exceptionStr,
4337                                   propertyValue, propertyName.getString ()));
4338                           }
4339                       
4340 gs.keenan       1.155     PEG_METHOD_EXIT ();
4341 carolann.graves 1.146     return result;
4342 gs.keenan       1.155 }
4343 carolann.graves 1.146 
4344 kumpf           1.116 void IndicationService::_checkProperty (
4345                           CIMInstance & instance,
4346                           const CIMName & propertyName,
4347 yi.zhou         1.187     const CIMType expectedType,
4348                           const Boolean isArray)
4349 kumpf           1.116 {
4350                           PEG_METHOD_ENTER (TRC_INDICATION_SERVICE,
4351                               "IndicationService::_checkProperty");
4352                       
4353                           //
4354                           //  If the property exists, get it
4355                           //
4356                           Uint32 propPos = instance.findProperty (propertyName);
4357                           if (propPos != PEG_NOT_FOUND)
4358                           {
4359                               CIMProperty theProperty = instance.getProperty (propPos);
4360                               CIMValue theValue = theProperty.getValue ();
4361                       
4362                               //
4363                               //  If the value is not null, check the type
4364                               //
4365                               if (!theValue.isNull ())
4366                               {
4367 yi.zhou         1.187             if ((theValue.getType () != expectedType) || 
4368                                       (theValue.isArray () != isArray))
4369 kumpf           1.116             {
4370                                       //
4371                                       //  Property exists and is not null, but is not of correct type
4372                                       //
4373                                       if (theValue.isArray ())
4374                                       {
4375                                           String exceptionStr = _MSG_INVALID_TYPE;
4376                                           exceptionStr.append (_MSG_ARRAY_OF);
4377                                           exceptionStr.append ("$0");
4378                                           exceptionStr.append (_MSG_FOR_PROPERTY);
4379                                           exceptionStr.append ("$1");
4380                       
4381                                           PEG_METHOD_EXIT ();
4382                                           throw PEGASUS_CIM_EXCEPTION_L (CIM_ERR_INVALID_PARAMETER,
4383 dj.gorey        1.135                         MessageLoaderParms
4384                                                   (_MSG_INVALID_TYPE_ARRAY_OF_FOR_PROPERTY_KEY,
4385 kumpf           1.116                             exceptionStr,
4386 dj.gorey        1.135                             cimTypeToString (theValue.getType ()),
4387 kumpf           1.116                             propertyName.getString ()));
4388                                       }
4389                                       else
4390                                       {
4391                                           String exceptionStr = _MSG_INVALID_TYPE;
4392                                           exceptionStr.append ("$0");
4393                                           exceptionStr.append (_MSG_FOR_PROPERTY);
4394                                           exceptionStr.append ("$1");
4395                       
4396                                           PEG_METHOD_EXIT ();
4397                                           throw PEGASUS_CIM_EXCEPTION_L (CIM_ERR_INVALID_PARAMETER,
4398 dj.gorey        1.135                         MessageLoaderParms
4399                                                   (_MSG_INVALID_TYPE_FOR_PROPERTY_KEY,
4400 kumpf           1.116                             exceptionStr,
4401 dj.gorey        1.135                             cimTypeToString (theValue.getType ()),
4402 kumpf           1.116                             propertyName.getString ()));
4403                                       }
4404                                   }
4405                               }
4406                           }
4407 kumpf           1.34  
4408 kumpf           1.48      PEG_METHOD_EXIT ();
4409 kumpf           1.34  }
4410                       
4411 carolann.graves 1.188 void IndicationService::_checkSupportedProperties (
4412                           const CIMInstance & instance)
4413                       {
4414                           PEG_METHOD_ENTER (TRC_INDICATION_SERVICE,
4415                               "IndicationService::_checkSupportedProperties");
4416                       
4417                           CIMName className = instance.getClassName ();
4418                           Array <CIMName> emptyArray;
4419                           Array <CIMName> & supportedProperties = emptyArray;
4420                       
4421                           //
4422                           //  Get list of supported properties for the class
4423                           //
4424                           if (className.equal (PEGASUS_CLASSNAME_INDSUBSCRIPTION))
4425                           {
4426                               supportedProperties = _supportedSubscriptionProperties;
4427                           }
4428                           else if (className.equal (PEGASUS_CLASSNAME_FORMATTEDINDSUBSCRIPTION))
4429                           {
4430                               supportedProperties = _supportedFormattedSubscriptionProperties;
4431                           }
4432 carolann.graves 1.188     else if (className.equal (PEGASUS_CLASSNAME_INDFILTER))
4433                           {
4434                               supportedProperties = _supportedFilterProperties;
4435                           }
4436                           else if (className.equal (PEGASUS_CLASSNAME_INDHANDLER_CIMXML))
4437                           {
4438                               supportedProperties = _supportedCIMXMLHandlerProperties;
4439                           }
4440                           else if (className.equal (PEGASUS_CLASSNAME_LSTNRDST_CIMXML))
4441                           {
4442                               supportedProperties = _supportedCIMXMLListenerDestinationProperties;
4443                           }
4444                           else if (className.equal (PEGASUS_CLASSNAME_INDHANDLER_SNMP))
4445                           {
4446                               supportedProperties = _supportedSNMPHandlerProperties;
4447                           }
4448                           else if (className.equal (PEGASUS_CLASSNAME_LSTNRDST_SYSTEM_LOG))
4449                           {
4450                               supportedProperties = _supportedSyslogListenerDestinationProperties;
4451                           }
4452                           else if (className.equal (PEGASUS_CLASSNAME_LSTNRDST_EMAIL))
4453 carolann.graves 1.188     {
4454                               supportedProperties = _supportedEmailListenerDestinationProperties;
4455                           }
4456                           else
4457                           {
4458                               PEGASUS_ASSERT (false);
4459                           }
4460                       
4461                           //
4462                           //  Check if each property in the instance is in the list of supported,
4463                           //  known properties for its class
4464                           //
4465                           for (Uint32 i = 0; i < instance.getPropertyCount (); i++)
4466                           {
4467                               if (!ContainsCIMName (supportedProperties,
4468                                   instance.getProperty (i).getName ()))
4469                               {
4470                                   //
4471                                   //  Throw an exception if an unknown, unsupported property was found
4472                                   //
4473                                   PEG_METHOD_EXIT ();
4474 carolann.graves 1.188             throw PEGASUS_CIM_EXCEPTION_L (CIM_ERR_NOT_SUPPORTED,
4475                                       MessageLoaderParms (_MSG_PROPERTY_NOT_SUPPORTED_KEY,
4476                                           _MSG_PROPERTY_NOT_SUPPORTED, 
4477                                           instance.getProperty (i).getName ().getString (),
4478                                           className.getString ()));
4479                               }
4480                           }
4481                       
4482                           PEG_METHOD_EXIT ();
4483                       }
4484                       
4485 yi.zhou         1.193 void IndicationService::_checkValue (
4486                           const CIMInstance & instance,
4487                           const CIMName & propertyName,
4488                           const Array <Uint16> & validValues,
4489                           const Array <Uint16> & supportedValues)
4490                       {
4491                           PEG_METHOD_ENTER (TRC_INDICATION_SERVICE,
4492                               "IndicationService::_checkValue");
4493                       
4494                           Uint16 theValue;
4495                       
4496                           // get the property value
4497                           Uint32 propPos = instance.findProperty (propertyName);
4498                           if (propPos != PEG_NOT_FOUND)
4499                           {
4500 carolann.graves 1.198         CIMValue propertyValue = (instance.getProperty(propPos)).getValue();
4501 yi.zhou         1.193 
4502                               if (!(propertyValue.isNull()))
4503                               {
4504                                   propertyValue.get(theValue);
4505                       
4506                                   // Validate the value
4507                                   // Note: Valid values are defined by the PG Events MOF
4508                                   if (!Contains(validValues, theValue))
4509                                   {
4510                                       String exceptionStr = _MSG_INVALID_VALUE;
4511                                       exceptionStr.append ("$0");
4512                                       exceptionStr.append (_MSG_FOR_PROPERTY);
4513                                       exceptionStr.append ("$1");
4514                       
4515                                       PEG_METHOD_EXIT ();
4516                       
4517                                       throw PEGASUS_CIM_EXCEPTION_L (CIM_ERR_INVALID_PARAMETER,
4518                                           MessageLoaderParms (_MSG_INVALID_VALUE_FOR_PROPERTY_KEY,
4519                                           exceptionStr,
4520                                           theValue,
4521                                           propertyName.getString()));
4522 yi.zhou         1.193                 
4523                                   }
4524                       
4525                                   // Check for valid values that are not supported 
4526                                   // Note: Supported values are a subset of the valid values 
4527                                   // Some valid values, as defined in the MOF, are not currently 
4528                                   // supported 
4529                                   if (!Contains(supportedValues, theValue))
4530                                   {
4531                                       String exceptionStr = _MSG_UNSUPPORTED_VALUE;
4532                                       exceptionStr.append ("$0");
4533                                       exceptionStr.append (_MSG_FOR_PROPERTY);
4534                                       exceptionStr.append ("$1");
4535                       
4536                                       PEG_METHOD_EXIT ();
4537                       
4538                                       throw PEGASUS_CIM_EXCEPTION_L (CIM_ERR_NOT_SUPPORTED,
4539                                           MessageLoaderParms (_MSG_UNSUPPORTED_VALUE_FOR_PROPERTY_KEY,
4540                                           exceptionStr,
4541                                           theValue,
4542                                           propertyName.getString()));
4543 yi.zhou         1.193                 
4544                                   }
4545                               }
4546                       
4547                           }
4548                       
4549                           PEG_METHOD_EXIT ();
4550                       }
4551                       
4552 kumpf           1.11  Boolean IndicationService::_canModify (
4553                           const CIMModifyInstanceRequestMessage * request,
4554 kumpf           1.45      const CIMObjectPath & instanceReference,
4555 kumpf           1.80      const CIMInstance & instance,
4556                           CIMInstance & modifiedInstance)
4557 kumpf           1.1   {
4558 kumpf           1.48      PEG_METHOD_ENTER (TRC_INDICATION_SERVICE, "IndicationService::_canModify");
4559 kumpf           1.1   
4560 kumpf           1.11      //
4561 dj.gorey        1.135     //  Currently, only modification allowed is of Subscription State
4562 kumpf           1.11      //  property in Subscription class
4563                           //
4564 yi.zhou         1.157     if (!(instanceReference.getClassName ().equal
4565                               (PEGASUS_CLASSNAME_INDSUBSCRIPTION)) &&
4566 chip            1.162     !(instanceReference.getClassName ().equal
4567                           (PEGASUS_CLASSNAME_FORMATTEDINDSUBSCRIPTION)))
4568 kumpf           1.11      {
4569 kumpf           1.48          PEG_METHOD_EXIT ();
4570 kumpf           1.57          throw PEGASUS_CIM_EXCEPTION(CIM_ERR_NOT_SUPPORTED, String::EMPTY);
4571 kumpf           1.11      }
4572 kumpf           1.1   
4573 kumpf           1.11      if (request->includeQualifiers)
4574 kumpf           1.1       {
4575 kumpf           1.48          PEG_METHOD_EXIT ();
4576 kumpf           1.57          throw PEGASUS_CIM_EXCEPTION(CIM_ERR_NOT_SUPPORTED, String::EMPTY);
4577 kumpf           1.11      }
4578 kumpf           1.1   
4579 kumpf           1.11      //
4580                           //  Request is invalid if property list is null, meaning all properties
4581                           //  are to be updated
4582                           //
4583                           if (request->propertyList.isNull ())
4584                           {
4585 kumpf           1.48          PEG_METHOD_EXIT ();
4586 kumpf           1.57          throw PEGASUS_CIM_EXCEPTION(CIM_ERR_NOT_SUPPORTED, String::EMPTY);
4587 kumpf           1.11      }
4588 kumpf           1.1   
4589 kumpf           1.11      //
4590                           //  Request is invalid if more than one property is specified
4591                           //
4592 kumpf           1.51      else if (request->propertyList.size () > 1)
4593 kumpf           1.1       {
4594 kumpf           1.48          PEG_METHOD_EXIT ();
4595 kumpf           1.57          throw PEGASUS_CIM_EXCEPTION(CIM_ERR_NOT_SUPPORTED, String::EMPTY);
4596 kumpf           1.1       }
4597 kumpf           1.11  
4598                           //
4599                           //  For request to be valid, zero or one property must be specified
4600                           //  If one property specified, it must be Subscription State property
4601                           //
4602 kumpf           1.51      else if ((request->propertyList.size () == 1) &&
4603 kumpf           1.64               (!request->propertyList[0].equal (_PROPERTY_STATE)))
4604 kumpf           1.1       {
4605 kumpf           1.48          PEG_METHOD_EXIT ();
4606 kumpf           1.57          throw PEGASUS_CIM_EXCEPTION(CIM_ERR_NOT_SUPPORTED, String::EMPTY);
4607 kumpf           1.1       }
4608                       
4609 kumpf           1.80      //
4610                           //  Check the SubscriptionState property in the modified instance
4611                           //
4612 dj.gorey        1.135     _checkPropertyWithOther (modifiedInstance, _PROPERTY_STATE,
4613                               _PROPERTY_OTHERSTATE, (Uint16) _STATE_ENABLED, (Uint16) _STATE_OTHER,
4614 kumpf           1.115         _validStates, _supportedStates);
4615 kumpf           1.32  
4616 kumpf           1.11      //
4617                           //  Get creator from instance
4618                           //
4619 kumpf           1.80      String creator;
4620                           if (!_getCreator (instance, creator))
4621                           {
4622                               //
4623                               //  This instance from the repository is corrupted
4624 humberto        1.82          //  L10N TODO DONE -- new throw of exception
4625 kumpf           1.80          //
4626                               PEG_METHOD_EXIT ();
4627 dj.gorey        1.135         //throw PEGASUS_CIM_EXCEPTION (CIM_ERR_FAILED,
4628 humberto        1.82              //_MSG_INVALID_INSTANCES);
4629 chip            1.162         MessageLoaderParms parms(_MSG_INVALID_INSTANCES_KEY,
4630 kumpf           1.137             _MSG_INVALID_INSTANCES);
4631                               throw PEGASUS_CIM_EXCEPTION_L(CIM_ERR_FAILED, parms);
4632 kumpf           1.80      }
4633 kumpf           1.1   
4634 kumpf           1.11      //
4635                           //  Current user must be privileged user or instance Creator to modify
4636 kumpf           1.13      //  NOTE: if authentication was not turned on when instance was created,
4637                           //  instance creator will be String::EMPTY
4638 dj.gorey        1.135     //  If creator is String::EMPTY, anyone may modify or delete the
4639 kumpf           1.13      //  instance
4640                           //
4641 kumpf           1.137     String currentUser = ((IdentityContainer)request->operationContext.get
4642                               (IdentityContainer :: NAME)).getUserName();
4643 kumpf           1.13      if ((creator != String::EMPTY) &&
4644 dj.gorey        1.135         (!System::isPrivilegedUser (currentUser)) &&
4645 kumpf           1.11          (currentUser != creator))
4646                           {
4647 kumpf           1.48          PEG_METHOD_EXIT ();
4648 kumpf           1.57          throw PEGASUS_CIM_EXCEPTION(CIM_ERR_ACCESS_DENIED, String::EMPTY);
4649 kumpf           1.11      }
4650 kumpf           1.1   
4651 gs.keenan       1.155     PEG_METHOD_EXIT ();
4652 kumpf           1.11      return true;
4653 kumpf           1.1   }
4654                       
4655 kumpf           1.11  Boolean IndicationService::_canDelete (
4656 kumpf           1.45      const CIMObjectPath & instanceReference,
4657 kumpf           1.63      const CIMNamespaceName & nameSpace,
4658 kumpf           1.16      const String & currentUser)
4659 kumpf           1.1   {
4660 kumpf           1.114     PEG_METHOD_ENTER (TRC_INDICATION_SERVICE, "IndicationService::_canDelete");
4661                       
4662 kumpf           1.63      CIMName superClass;
4663                           CIMName propName;
4664 kumpf           1.11  
4665                           //
4666 carolann.graves 1.179     //  Get the instance to be deleted from the repository
4667 kumpf           1.16      //
4668 kumpf           1.19      CIMInstance instance;
4669                       
4670 dj.gorey        1.135     instance = _subscriptionRepository->getInstance
4671 kumpf           1.114         (nameSpace, instanceReference);
4672 kumpf           1.19  
4673 kumpf           1.16      //
4674                           //  Get creator from instance
4675                           //
4676 kumpf           1.80      String creator;
4677                           if (!_getCreator (instance, creator))
4678                           {
4679                               //
4680                               //  This instance from the repository is corrupted
4681 dj.gorey        1.135         //  Allow the delete if a Privileged User
4682                               //      (or authentication turned off),
4683 kumpf           1.80          //  Otherwise disallow as access denied
4684                               //
4685                               if ((!System::isPrivilegedUser (currentUser)) &&
4686                                   (currentUser != String::EMPTY))
4687                               {
4688                                   PEG_METHOD_EXIT ();
4689                                   throw PEGASUS_CIM_EXCEPTION (CIM_ERR_ACCESS_DENIED, String::EMPTY);
4690                               }
4691                           }
4692 kumpf           1.16  
4693                           //
4694                           //  Current user must be privileged user or instance Creator to delete
4695                           //  NOTE: if authentication was not turned on when instance was created,
4696                           //  instance creator will be String::EMPTY
4697 dj.gorey        1.135     //  If creator is String::EMPTY, anyone may modify or delete the
4698 kumpf           1.16      //  instance
4699                           //
4700                           if ((creator != String::EMPTY) &&
4701                               (!System::isPrivilegedUser (currentUser)) &&
4702                               (currentUser != creator))
4703                           {
4704 kumpf           1.48          PEG_METHOD_EXIT ();
4705 kumpf           1.57          throw PEGASUS_CIM_EXCEPTION(CIM_ERR_ACCESS_DENIED, String::EMPTY);
4706 kumpf           1.16      }
4707                       
4708                           //
4709 kumpf           1.11      //  Get the class and superclass of the instance to be deleted
4710                           //
4711 kumpf           1.19      CIMClass refClass;
4712                       
4713 kumpf           1.114     refClass = _subscriptionRepository->getClass (nameSpace,
4714 dj.gorey        1.135         instanceReference.getClassName (), true, true, false,
4715 kumpf           1.114         CIMPropertyList ());
4716 kumpf           1.11      superClass = refClass.getSuperClassName();
4717 kumpf           1.1   
4718 kumpf           1.11      //
4719 carolann.graves 1.169     //  If the class is Filter or superclass is Handler or Listener Destination,
4720                           //  check for subscription instances referring to the instance to be deleted
4721 kumpf           1.11      //
4722 carolann.graves 1.169     if ((superClass.equal (PEGASUS_CLASSNAME_INDHANDLER)) ||
4723                               (superClass.equal (PEGASUS_CLASSNAME_LSTNRDST)) ||
4724                               (instanceReference.getClassName().equal (PEGASUS_CLASSNAME_INDFILTER)))
4725                           {
4726 david.dillard   1.174         if (instanceReference.getClassName ().equal
4727 carolann.graves 1.169                (PEGASUS_CLASSNAME_INDFILTER))
4728 kumpf           1.11          {
4729                                   propName = _PROPERTY_FILTER;
4730                               }
4731 yi.zhou         1.157         else if ((superClass.equal (PEGASUS_CLASSNAME_INDHANDLER)) ||
4732 carolann.graves 1.169             (superClass.equal (PEGASUS_CLASSNAME_LSTNRDST)))
4733 kumpf           1.1           {
4734 kumpf           1.11              propName = _PROPERTY_HANDLER;
4735 kumpf           1.1   
4736 kumpf           1.11              //
4737 dj.gorey        1.135             //  If deleting transient handler, first delete any referencing
4738 kumpf           1.11              //  subscriptions
4739                                   //
4740 dj.gorey        1.135             if (_subscriptionRepository->isTransient (nameSpace,
4741 kumpf           1.114                 instanceReference))
4742 kumpf           1.1               {
4743 kumpf           1.11                  _deleteReferencingSubscriptions (nameSpace, propName,
4744                                           instanceReference);
4745 kumpf           1.48                  PEG_METHOD_EXIT ();
4746 kumpf           1.11                  return true;
4747 kumpf           1.1               }
4748 kumpf           1.11          }
4749 kumpf           1.1   
4750 kumpf           1.11          //
4751 carolann.graves 1.186         //  Get all the subscriptions from the repository
4752 kumpf           1.11          //
4753 dj.gorey        1.135         Array <CIMInstance> subscriptions =
4754 carolann.graves 1.186             _subscriptionRepository->getAllSubscriptions ();
4755 kumpf           1.1   
4756 kumpf           1.11          CIMValue propValue;
4757 kumpf           1.1   
4758 kumpf           1.11          //
4759 dj.gorey        1.135         //  Check each subscription for a reference to the instance to be
4760 kumpf           1.11          //  deleted
4761                               //
4762 kumpf           1.83          for (Uint32 i = 0; i < subscriptions.size(); i++)
4763 kumpf           1.11          {
4764                                   //
4765                                   //  Get the subscription Filter or Handler property value
4766                                   //
4767 kumpf           1.46              propValue = subscriptions[i].getProperty
4768                                       (subscriptions[i].findProperty
4769 kumpf           1.11                  (propName)).getValue();
4770 dj.gorey        1.135 
4771 kumpf           1.45              CIMObjectPath ref;
4772 kumpf           1.11              propValue.get (ref);
4773 kumpf           1.4   
4774 kumpf           1.11              //
4775 carolann.graves 1.186             //  If the Filter or Handler reference property value includes
4776                                   //  namespace, check if it is the namespace of the Filter or Handler
4777                                   //  being deleted.
4778                                   //  If the Filter or Handler reference property value does not
4779                                   //  include namespace, check if the current subscription namespace
4780                                   //  is the namespace of the Filter or Handler being deleted.
4781 carolann.graves 1.179             //
4782 carolann.graves 1.186             CIMNamespaceName instanceNS = ref.getNameSpace ();
4783                                   if (((instanceNS.isNull ()) && 
4784                                       (subscriptions[i].getPath ().getNameSpace () == nameSpace)) 
4785                                       || (instanceNS == nameSpace))
4786                                   {
4787                       
4788                                       //
4789                                       //  Remove Host and Namespace from reference property value, if
4790                                       //  present, before comparing
4791                                       //
4792                                       CIMObjectPath path ("", CIMNamespaceName (),
4793                                           ref.getClassName (), ref.getKeyBindings ());
4794 carolann.graves 1.179 
4795 carolann.graves 1.186                 //
4796                                       //  Remove Host and Namespace from reference of instance to be
4797                                       //  deleted, if present, before comparing
4798                                       //
4799                                       CIMObjectPath iref ("", CIMNamespaceName (),
4800                                           instanceReference.getClassName (),
4801                                           instanceReference.getKeyBindings ());
4802                       
4803                                       //
4804                                       //  If the current subscription Filter or Handler is the
4805                                       //  instance to be deleted, it may not be deleted
4806                                       //
4807                                       if (iref == path)
4808                                       {
4809                                           PEG_METHOD_EXIT ();
4810                                           throw PEGASUS_CIM_EXCEPTION_L (CIM_ERR_FAILED,
4811                                               MessageLoaderParms
4812                                                   (_MSG_REFERENCED_KEY, _MSG_REFERENCED));
4813                                       }
4814 kumpf           1.1               }
4815                               }
4816                           }
4817                       
4818 kumpf           1.48      PEG_METHOD_EXIT ();
4819 kumpf           1.11      return true;
4820                       }
4821 kumpf           1.4   
4822 kumpf           1.46  Array <CIMInstance> IndicationService::_getMatchingSubscriptions (
4823 kumpf           1.63      const CIMName & supportedClass,
4824                           const Array <CIMNamespaceName> nameSpaces,
4825 kumpf           1.89      const CIMPropertyList & supportedProperties,
4826                           const Boolean checkProvider,
4827 dj.gorey        1.135     const CIMInstance & provider)
4828 kumpf           1.1   {
4829 kumpf           1.114     PEG_METHOD_ENTER (TRC_INDICATION_SERVICE,
4830                               "IndicationService::_getMatchingSubscriptions");
4831                       
4832 kumpf           1.46      Array <CIMInstance> matchingSubscriptions;
4833                           Array <CIMInstance> subscriptions;
4834 kumpf           1.1   
4835 dj.gorey        1.135     subscriptions = _subscriptionTable->getMatchingSubscriptions
4836 kumpf           1.114         (supportedClass, nameSpaces, checkProvider, provider);
4837 kumpf           1.1   
4838 kumpf           1.114     for (Uint32 i = 0; i < subscriptions.size (); i++)
4839 kumpf           1.11      {
4840 kumpf           1.114         Boolean match = true;
4841                       
4842 kumpf           1.11          //
4843 kumpf           1.114         //  If supported properties is null (all properties)
4844                               //  the subscription can be supported
4845 kumpf           1.11          //
4846 kumpf           1.114         if (!supportedProperties.isNull ())
4847 kumpf           1.73          {
4848 kumpf           1.114             String filterQuery;
4849 chuck           1.149             String queryLanguage;
4850 kumpf           1.114             CIMName indicationClassName;
4851                                   CIMNamespaceName sourceNameSpace;
4852                                   CIMPropertyList propertyList;
4853 kumpf           1.73  
4854 kumpf           1.114             //
4855                                   //  Get filter properties
4856                                   //
4857 dj.gorey        1.135             _subscriptionRepository->getFilterProperties
4858 carolann.graves 1.186                 (subscriptions [i], filterQuery, sourceNameSpace,
4859 chuck           1.149                  queryLanguage);
4860                       
4861                                   QueryExpression queryExpr = _getQueryExpression(filterQuery,
4862                                                                                   queryLanguage,
4863                                                                                   sourceNameSpace);
4864 chip            1.162 
4865 kumpf           1.114             //
4866                                   //  Get indication class name from filter query
4867                                   //
4868 dj.gorey        1.135             indicationClassName = _getIndicationClassName
4869 chuck           1.149                 (queryExpr, sourceNameSpace);
4870 dj.gorey        1.135 
4871 kumpf           1.114             //
4872 carolann.graves 1.175             //  Get required property list from filter query (WHERE clause)
4873 kumpf           1.114             //
4874 chuck           1.149             //  Note that the supportedClass is passed in,
4875                                   //  not the indicationClassName.
4876                                   //  The supportedClass is the class of the indication
4877 chip            1.162             //  instance, while the indicationClassName is the FROM class.
4878 chuck           1.149             //  This is needed because CQL can have class scoping operators
4879                                   //  on properties that may not be the same class
4880                                   //  as the FROM class.  The required properties
4881                                   //  for an indication are based on its class,
4882                                   //  not the FROM class.
4883                                   //
4884                                   //  Also note that for CQL, this does not return
4885                                   //  required embedded object properties.
4886                                   propertyList = _getPropertyList (queryExpr,
4887                                                                    sourceNameSpace,
4888                                                                    supportedClass);
4889 dj.gorey        1.135 
4890 kumpf           1.114             //
4891                                   //  If the subscription requires all properties,
4892 dj.gorey        1.135             //  but supported property list does not include all
4893 kumpf           1.114             //  properties, the subscription cannot be supported
4894                                   //
4895                                   if (propertyList.isNull ())
4896                                   {
4897 carolann.graves 1.166                 //
4898                                       //  Current subscription does not match
4899                                       //  Continue to next subscription in list
4900                                       //
4901 kumpf           1.114                 match = false;
4902 carolann.graves 1.166                 continue;
4903 kumpf           1.114             }
4904 dj.gorey        1.135             else
4905 kumpf           1.114             {
4906                                       //
4907 carolann.graves 1.175                 //  Compare subscription required property list
4908 kumpf           1.114                 //  with supported property list
4909                                       //
4910 dj.gorey        1.135                 for (Uint32 j = 0;
4911                                            j < propertyList.size () && match;
4912 kumpf           1.114                      j++)
4913                                       {
4914                                           if (!ContainsCIMName
4915                                               (supportedProperties.getPropertyNameArray(),
4916                                               propertyList [j]))
4917 kumpf           1.73                      {
4918                                               match = false;
4919 kumpf           1.89                          break;
4920 kumpf           1.73                      }
4921                                       }
4922 kumpf           1.114             }
4923                               }
4924 kumpf           1.11  
4925 kumpf           1.114         if (match)
4926                               {
4927                                   //
4928                                   //  Add current subscription to list
4929                                   //
4930                                   matchingSubscriptions.append (subscriptions [i]);
4931 kumpf           1.73          }
4932                           }
4933 kumpf           1.1   
4934 kumpf           1.48      PEG_METHOD_EXIT ();
4935 kumpf           1.19      return matchingSubscriptions;
4936 kumpf           1.1   }
4937                       
4938 kumpf           1.11  void IndicationService::_getModifiedSubscriptions (
4939 kumpf           1.63      const CIMName & supportedClass,
4940                           const Array <CIMNamespaceName> & newNameSpaces,
4941                           const Array <CIMNamespaceName> & oldNameSpaces,
4942 kumpf           1.11      const CIMPropertyList & newProperties,
4943                           const CIMPropertyList & oldProperties,
4944 kumpf           1.46      Array <CIMInstance> & newSubscriptions,
4945                           Array <CIMInstance> & formerSubscriptions)
4946 kumpf           1.1   {
4947 kumpf           1.114     PEG_METHOD_ENTER (TRC_INDICATION_SERVICE,
4948                               "IndicationService::_getModifiedSubscriptions");
4949                       
4950 kumpf           1.73      Array <CIMInstance> newList;
4951                           Array <CIMInstance> formerList;
4952                           Array <CIMInstance> bothList;
4953 kumpf           1.1   
4954 kumpf           1.11      newSubscriptions.clear ();
4955                           formerSubscriptions.clear ();
4956                       
4957 kumpf           1.1       //
4958 dj.gorey        1.135     //  For each newly supported namespace, lookup to retrieve list of
4959 kumpf           1.73      //  subscriptions for the indication class-source namespace pair
4960                           //
4961 dj.gorey        1.135     newList = _subscriptionTable->getMatchingSubscriptions
4962 kumpf           1.114         (supportedClass, newNameSpaces);
4963 kumpf           1.73  
4964                           //
4965 dj.gorey        1.135     //  For each formerly supported namespace, lookup to retrieve list of
4966 kumpf           1.73      //  subscriptions for the indication class-source namespace pair
4967                           //
4968 dj.gorey        1.135     formerList = _subscriptionTable->getMatchingSubscriptions
4969 kumpf           1.114         (supportedClass, oldNameSpaces);
4970 kumpf           1.73  
4971                           //
4972 dj.gorey        1.135     //  Find subscriptions that appear in both lists, and move them to a third
4973 kumpf           1.73      //  list
4974 kumpf           1.1       //
4975 kumpf           1.73      Sint8 found;
4976 kumpf           1.83      for (Uint32 p = 0; p < newList.size (); p++)
4977 kumpf           1.73      {
4978                               found = -1;
4979 kumpf           1.83          for (Uint32 q = 0; q < formerList.size (); q++)
4980 kumpf           1.73          {
4981                                   if (newList [p].identical (formerList [q]))
4982                                   {
4983                                       found = q;
4984                                       bothList.append (newList [p]);
4985                                       break;
4986                                   }
4987                               }
4988                               if (found >= 0)
4989                               {
4990                                   newList.remove (p);
4991                                   p--;
4992                                   formerList.remove (found);
4993                               }
4994                           }
4995 kumpf           1.1   
4996                           //
4997 dj.gorey        1.135     //  For indicationClassName-sourceNamespace pair that is now supported, but
4998                           //  previously was not, add to list of newly supported subscriptions if
4999 kumpf           1.73      //  required properties are now supported
5000 kumpf           1.1       //
5001 kumpf           1.83      for (Uint32 n = 0; n < newList.size (); n++)
5002 kumpf           1.1       {
5003 kumpf           1.73          String filterQuery;
5004 chuck           1.149         String queryLanguage;
5005 kumpf           1.73          CIMName indicationClassName;
5006                               CIMNamespaceName sourceNameSpace;
5007                               CIMPropertyList requiredProperties;
5008 kumpf           1.11  
5009                               //
5010 kumpf           1.73          //  Get filter properties
5011                               //
5012 carolann.graves 1.186         _subscriptionRepository->getFilterProperties (newList [n], filterQuery,
5013 chuck           1.149             sourceNameSpace, queryLanguage);
5014                               QueryExpression queryExpression = _getQueryExpression(filterQuery,
5015                                                                                     queryLanguage,
5016                                                                                     sourceNameSpace);
5017 dj.gorey        1.135 
5018 kumpf           1.73          //
5019                               //  Get indication class name from filter query (FROM clause)
5020                               //
5021 chuck           1.149         indicationClassName = _getIndicationClassName (queryExpression,
5022 kumpf           1.73              sourceNameSpace);
5023 dj.gorey        1.135 
5024 kumpf           1.73          //
5025 carolann.graves 1.175         //  Get required property list from filter query (WHERE clause)
5026 kumpf           1.11          //
5027 chuck           1.149         //  Note: the supportedClass is passed to _getPropertyList
5028                               //  rather than the FROM class because CQL could have
5029                               //  class scoping operators that scope properties to
5030                               //  specific subclasses of the FROM.
5031                               //
5032                               requiredProperties = _getPropertyList (queryExpression,
5033                                   sourceNameSpace, supportedClass);
5034 kumpf           1.19  
5035 kumpf           1.1           //
5036 kumpf           1.73          //  Check if required properties are now supported
5037 kumpf           1.1           //
5038 kumpf           1.73          if (_inPropertyList (requiredProperties, newProperties))
5039 kumpf           1.1           {
5040 kumpf           1.73              newSubscriptions.append (newList [n]);
5041                               }
5042                           }
5043 kumpf           1.13  
5044 kumpf           1.73      //
5045 dj.gorey        1.135     //  For indicationClassName-sourceNamespace pair that was previously
5046                           //  supported, but now is not, add to list of formerly supported
5047 kumpf           1.73      //  subscriptions
5048                           //
5049 kumpf           1.83      for (Uint32 f = 0; f < formerList.size (); f++)
5050 kumpf           1.73      {
5051                               formerSubscriptions.append (formerList [f]);
5052                           }
5053 kumpf           1.1   
5054 kumpf           1.73      //
5055 dj.gorey        1.135     //  For indicationClassName-sourceNamespace pair that is now supported,
5056 kumpf           1.73      //  and was also previously supported, add to appropriate list, based on
5057 dj.gorey        1.135     //  required properties
5058 kumpf           1.73      //
5059 kumpf           1.83      for (Uint32 b = 0; b < bothList.size (); b++)
5060 kumpf           1.73      {
5061                               String filterQuery;
5062 chuck           1.149         String queryLanguage;
5063 kumpf           1.73          CIMName indicationClassName;
5064                               CIMNamespaceName sourceNameSpace;
5065                               CIMPropertyList requiredProperties;
5066                               Boolean newMatch = false;
5067                               Boolean formerMatch = false;
5068 kumpf           1.1   
5069 kumpf           1.73          //
5070                               //  Get filter properties
5071                               //
5072 carolann.graves 1.186         _subscriptionRepository->getFilterProperties (bothList [b], filterQuery,
5073 chuck           1.149             sourceNameSpace, queryLanguage);
5074                               QueryExpression queryExpression = _getQueryExpression(filterQuery,
5075                                                                                     queryLanguage,
5076                                                                                     sourceNameSpace);
5077 dj.gorey        1.135 
5078 kumpf           1.73          //
5079                               //  Get indication class name from filter query (FROM clause)
5080                               //
5081 chuck           1.149         indicationClassName = _getIndicationClassName (queryExpression,
5082 kumpf           1.73              sourceNameSpace);
5083 dj.gorey        1.135 
5084 kumpf           1.73          //
5085 carolann.graves 1.175         //  Get required property list from filter query (WHERE clause)
5086 kumpf           1.73          //
5087 chuck           1.149         //  Note: the supportedClass is passed to _getPropertyList
5088                               //  rather than the FROM class because CQL could have
5089                               //  class scoping operators that scope properties to
5090                               //  specific subclasses of the FROM.
5091                               //
5092                               requiredProperties = _getPropertyList (queryExpression,
5093                                   sourceNameSpace, supportedClass);
5094 kumpf           1.1   
5095 kumpf           1.73          //
5096 dj.gorey        1.135         //  Check required properties
5097 kumpf           1.73          //
5098 dj.gorey        1.135         newMatch = _inPropertyList (requiredProperties,
5099 kumpf           1.73              newProperties);
5100 dj.gorey        1.135         formerMatch = _inPropertyList (requiredProperties,
5101 kumpf           1.73              oldProperties);
5102 kumpf           1.15  
5103 kumpf           1.73          //
5104                               //  Add current subscription to appropriate list
5105                               //
5106                               if (newMatch && !formerMatch)
5107                               {
5108                                   newSubscriptions.append (bothList [b]);
5109                               }
5110                               else if (!newMatch && formerMatch)
5111                               {
5112                                   formerSubscriptions.append (bothList [b]);
5113                               }
5114                           }
5115 kumpf           1.11  
5116 kumpf           1.48      PEG_METHOD_EXIT ();
5117 kumpf           1.11  }
5118                       
5119 kumpf           1.15  Boolean IndicationService::_inPropertyList (
5120                           const CIMPropertyList & requiredProperties,
5121                           const CIMPropertyList & supportedProperties)
5122                       {
5123 kumpf           1.48      PEG_METHOD_ENTER (TRC_INDICATION_SERVICE,
5124 kumpf           1.114         "IndicationService::_inPropertyList");
5125 kumpf           1.22  
5126 kumpf           1.15      //
5127                           //  If property list is null (all properties)
5128                           //  all the required properties are supported
5129                           //
5130                           if (supportedProperties.isNull ())
5131                           {
5132 carolann.graves 1.170         PEG_METHOD_EXIT();
5133 kumpf           1.15          return true;
5134                           }
5135                           else
5136                           {
5137                               //
5138                               //  If the subscription requires all properties,
5139 dj.gorey        1.135         //  but property list does not include all
5140 kumpf           1.15          //  properties, the required properties cannot be supported
5141                               //
5142                               if (requiredProperties.isNull ())
5143                               {
5144 carolann.graves 1.170             PEG_METHOD_EXIT();
5145 kumpf           1.15              return false;
5146                               }
5147                               else
5148                               {
5149                                   //
5150                                   //  Compare required property list
5151                                   //  with property list
5152                                   //
5153 kumpf           1.83              for (Uint32 i = 0; i < requiredProperties.size (); i++)
5154 kumpf           1.15              {
5155 dj.gorey        1.135                 if (!ContainsCIMName
5156                                           (supportedProperties.getPropertyNameArray (),
5157 kumpf           1.51                      requiredProperties[i]))
5158 kumpf           1.15                  {
5159 carolann.graves 1.170                     PEG_METHOD_EXIT();
5160 kumpf           1.15                      return false;
5161                                       }
5162                                   }
5163                               }
5164                           }
5165                       
5166 kumpf           1.48      PEG_METHOD_EXIT ();
5167 kumpf           1.15      return true;
5168                       }
5169                       
5170 chuck           1.149 QueryExpression IndicationService::_getQueryExpression (const String& filterQuery,
5171                                                                               const String& queryLanguage,
5172                                                                               const CIMNamespaceName ns) const
5173                       {
5174                         PEG_METHOD_ENTER (TRC_INDICATION_SERVICE,
5175                                           "IndicationService::_getQueryExpression");
5176                       
5177                         try
5178                         {
5179                           RepositoryQueryContext ctx(ns, _cimRepository);
5180                           QueryExpression queryExpression(queryLanguage, filterQuery, ctx);
5181                           PEG_METHOD_EXIT ();
5182                           return queryExpression;
5183                         }
5184                         catch (QueryParseException & qpe)
5185                         {
5186                           String exceptionStr = qpe.getMessage ();
5187 chip            1.162 
5188 chuck           1.149     PEG_METHOD_EXIT ();
5189                           throw PEGASUS_CIM_EXCEPTION (CIM_ERR_INVALID_PARAMETER, exceptionStr);
5190                         }
5191                         catch (ParseError & pe)
5192                         {
5193                           String exceptionStr = pe.getMessage ();
5194 chip            1.162 
5195 chuck           1.149     PEG_METHOD_EXIT ();
5196                           throw PEGASUS_CIM_EXCEPTION (CIM_ERR_INVALID_PARAMETER, exceptionStr);
5197                         }
5198                         catch (MissingNullTerminator & mnt)
5199                         {
5200                           String exceptionStr = mnt.getMessage ();
5201 chip            1.162 
5202 kumpf           1.48      PEG_METHOD_EXIT ();
5203 chuck           1.149     throw PEGASUS_CIM_EXCEPTION (CIM_ERR_INVALID_PARAMETER, exceptionStr);
5204                         }
5205 kumpf           1.1   }
5206                       
5207 kumpf           1.63  CIMName IndicationService::_getIndicationClassName (
5208 chuck           1.149     const QueryExpression & queryExpression,
5209 kumpf           1.63      const CIMNamespaceName & nameSpaceName) const
5210 kumpf           1.1   {
5211 kumpf           1.114     PEG_METHOD_ENTER (TRC_INDICATION_SERVICE,
5212                               "IndicationService::_getIndicationClassName");
5213                       
5214 kumpf           1.63      CIMName indicationClassName;
5215                           Array <CIMName> indicationSubclasses;
5216 kumpf           1.1   
5217 chuck           1.149     // Get the class paths in the FROM list.
5218                           // Note: neither WQL nor CQL support joins, so we can
5219                           // assume one class path.
5220                           // Note: neither WQL not CQL support wbem-uri for class paths,
5221                           // so we can ignore the parts of the path before the class name.
5222                           Array<CIMObjectPath> fromPaths = queryExpression.getClassPathList();
5223                           indicationClassName = fromPaths[0].getClassName();
5224 kumpf           1.11  
5225 kumpf           1.114     //
5226                           //  Validate that class is an Indication class
5227                           //  The Indication Qualifier should exist and have the value True
5228                           //
5229 dj.gorey        1.135     Boolean validClass = _subscriptionRepository->validateIndicationClassName
5230 kumpf           1.114         (indicationClassName, nameSpaceName);
5231 kumpf           1.1   
5232 kumpf           1.15      if (!validClass)
5233 kumpf           1.1       {
5234 kumpf           1.114         // l10n
5235 humberto        1.78          // String exceptionStr = _MSG_INVALID_CLASSNAME;
5236 kumpf           1.137         String exceptionStr = String ("Invalid indication class name ");
5237 humberto        1.78          // exceptionStr.append (indicationClassName.getString());
5238 humberto        1.84          exceptionStr.append ("$0");
5239 humberto        1.78          // exceptionStr.append (_MSG_IN_FROM);
5240 humberto        1.85          exceptionStr.append (" in FROM clause of ");
5241 humberto        1.78          // exceptionStr.append (PEGASUS_CLASSNAME_INDFILTER.getString());
5242 humberto        1.85          exceptionStr.append ("$1");
5243 kumpf           1.15          exceptionStr.append (" ");
5244 humberto        1.78          // exceptionStr.append (_PROPERTY_QUERY.getString());
5245 humberto        1.85          exceptionStr.append ("$2");
5246 kumpf           1.11          exceptionStr.append (_MSG_PROPERTY);
5247 humberto        1.78  
5248 kumpf           1.48          PEG_METHOD_EXIT ();
5249 humberto        1.78  
5250 kumpf           1.137         // l10n
5251 humberto        1.78  
5252 dj.gorey        1.135         // throw PEGASUS_CIM_EXCEPTION (CIM_ERR_INVALID_PARAMETER,
5253 kumpf           1.137         //  exceptionStr);
5254 humberto        1.78  
5255 dj.gorey        1.135         throw PEGASUS_CIM_EXCEPTION_L (CIM_ERR_INVALID_PARAMETER,
5256 kumpf           1.114             MessageLoaderParms (
5257 dj.gorey        1.135             _MSG_INVALID_CLASSNAME_IN_FROM_PROPERTY_KEY, exceptionStr,
5258                                   indicationClassName.getString (),
5259                                   PEGASUS_CLASSNAME_INDFILTER.getString (),
5260 kumpf           1.114             _PROPERTY_QUERY.getString ()));
5261 kumpf           1.11      }
5262 kumpf           1.1   
5263 kumpf           1.48      PEG_METHOD_EXIT ();
5264 kumpf           1.19      return indicationClassName;
5265 kumpf           1.1   }
5266                       
5267 kumpf           1.114 Array <ProviderClassList> IndicationService::_getIndicationProviders (
5268 chip            1.162     const QueryExpression & queryExpression,
5269 kumpf           1.114     const CIMNamespaceName & nameSpace,
5270                           const CIMName & indicationClassName,
5271 chuck           1.149     const Array <CIMName> & indicationSubclasses) const
5272 kumpf           1.22  {
5273 kumpf           1.48      PEG_METHOD_ENTER (TRC_INDICATION_SERVICE,
5274 kumpf           1.114         "IndicationService::_getIndicationProviders");
5275 kumpf           1.22  
5276 kumpf           1.16      ProviderClassList provider;
5277                           Array <ProviderClassList> indicationProviders;
5278 kumpf           1.12      Array <CIMInstance> providerInstances;
5279                           Array <CIMInstance> providerModuleInstances;
5280 kumpf           1.1   
5281 chuck           1.149     CIMPropertyList requiredPropertyList;
5282                       
5283 kumpf           1.11      //
5284 kumpf           1.12      //  For each indication subclass, get providers
5285 kumpf           1.1       //
5286 carolann.graves 1.192     for (Uint32 i = 0, n = indicationSubclasses.size (); i < n; i++)
5287 kumpf           1.1       {
5288 carolann.graves 1.179         //  Get required property list from filter query (WHERE clause)
5289 carolann.graves 1.175         //  from this indication subclass
5290 chuck           1.149         //
5291                               requiredPropertyList = _getPropertyList (queryExpression,
5292                                                                        nameSpace,
5293                                                                        indicationSubclasses[i]);
5294                       
5295 kumpf           1.1           //
5296 kumpf           1.12          //  Get providers that can serve the subscription
5297 kumpf           1.1           //
5298 kumpf           1.12          providerInstances.clear ();
5299                               providerModuleInstances.clear ();
5300                               if (_providerRegManager->getIndicationProviders
5301                                       (nameSpace,
5302                                        indicationSubclasses [i],
5303 kumpf           1.14                   requiredPropertyList,
5304 kumpf           1.12                   providerInstances,
5305                                        providerModuleInstances))
5306 kumpf           1.1           {
5307 dj.gorey        1.135             PEGASUS_ASSERT (providerInstances.size () ==
5308 kumpf           1.12                              providerModuleInstances.size ());
5309 dj.gorey        1.135 
5310 carolann.graves 1.192             Tracer::trace (TRC_INDICATION_SERVICE, Tracer::LEVEL4,
5311                                       "%u indication provider(s) found for class %s",
5312                                       providerInstances.size (),
5313                                       (const char *) 
5314                                       indicationSubclasses[i].getString ().getCString ());
5315 chip            1.162 
5316 kumpf           1.1               //
5317 dj.gorey        1.135             //  Merge into list of ProviderClassList structs
5318 kumpf           1.1               //
5319 carolann.graves 1.192             for (Uint32 j = 0, n = providerInstances.size (); j < n; j++)
5320 kumpf           1.1               {
5321 kumpf           1.12                  provider.classList.clear ();
5322 carolann.graves 1.192                 Boolean duplicate = false;
5323 kumpf           1.1   
5324                                       //
5325 kumpf           1.12                  //  See if indication provider is already in list
5326 kumpf           1.1                   //
5327 carolann.graves 1.192                 for (Uint32 k = 0, n = indicationProviders.size ();
5328                                            k < n && !duplicate; k++)
5329 kumpf           1.1                   {
5330 dj.gorey        1.135                     if ((providerInstances [j].getPath ().identical
5331                                               (indicationProviders [k].provider.getPath ())) &&
5332 kumpf           1.114                         (providerModuleInstances [j].getPath ().identical
5333                                               (indicationProviders [k].providerModule.getPath ())))
5334 kumpf           1.1                       {
5335 kumpf           1.12                          //
5336                                               //  Indication provider is already in list
5337                                               //  Add subclass to provider's class list
5338                                               //
5339 dj.gorey        1.135                         indicationProviders [k].classList.append
5340 kumpf           1.12                              (indicationSubclasses [i]);
5341                                               duplicate = true;
5342 kumpf           1.1                       }
5343 kumpf           1.11                  }
5344 dj.gorey        1.135 
5345 kumpf           1.12                  if (!duplicate)
5346 kumpf           1.11                  {
5347 kumpf           1.1                       //
5348 kumpf           1.11                      //  Current provider is not yet in list
5349                                           //  Create new list entry
5350 kumpf           1.1                       //
5351 kumpf           1.12                      provider.provider = providerInstances [j];
5352                                           provider.providerModule = providerModuleInstances [j];
5353                                           provider.classList.append (indicationSubclasses [i]);
5354                                           indicationProviders.append (provider);
5355                                       }
5356                                   }  // for each indication provider instance
5357                               }  // if any providers
5358                           }  // for each indication subclass
5359 dj.gorey        1.135 
5360 kumpf           1.48      PEG_METHOD_EXIT ();
5361 kumpf           1.19      return indicationProviders;
5362 kumpf           1.1   }
5363                       
5364 dj.gorey        1.135 CIMPropertyList IndicationService::_getPropertyList
5365 chuck           1.149     (const QueryExpression & queryExpression,
5366 kumpf           1.63       const CIMNamespaceName & nameSpaceName,
5367                            const CIMName & indicationClassName) const
5368 kumpf           1.1   {
5369 kumpf           1.114     PEG_METHOD_ENTER (TRC_INDICATION_SERVICE,
5370                               "IndicationService::_getPropertyList");
5371                       
5372 kumpf           1.67      CIMPropertyList propertyList;
5373 kumpf           1.1   
5374 carolann.graves 1.175     //  Get all the properties referenced in the condition (WHERE clause)
5375 chuck           1.149     //  Note: for CQL, this only returns the properties directly on the
5376                           //  class name passed in, not any properties on embedded objects.
5377 kumpf           1.1       //
5378 chuck           1.149     try
5379                           {
5380                             CIMObjectPath classPath (String::EMPTY,
5381                                                      nameSpaceName,
5382                                                      indicationClassName);
5383 carolann.graves 1.175       propertyList = queryExpression.getWherePropertyList (classPath);
5384 chuck           1.149     }
5385                           catch (QueryException & qe)
5386                           {
5387                             // The class path was not the FROM class, or a subclass
5388                             // of the FROM class.
5389                             String exceptionStr = qe.getMessage ();
5390 chip            1.162 
5391 chuck           1.149       PEG_METHOD_EXIT ();
5392                             throw PEGASUS_CIM_EXCEPTION (CIM_ERR_FAILED, exceptionStr);
5393                           }
5394                       
5395 kumpf           1.67      if (propertyList.isNull ())
5396 kumpf           1.11      {
5397 kumpf           1.67          //
5398 dj.gorey        1.135         //  Return null property list for all properties
5399 kumpf           1.67          //
5400 carolann.graves 1.170         PEG_METHOD_EXIT();
5401 kumpf           1.67          return propertyList;
5402                           }
5403                           else
5404                           {
5405                               Array <CIMName> propertyArray;
5406                       
5407 chuck           1.149         //  Get the property names
5408 kumpf           1.67          //
5409                               propertyArray = propertyList.getPropertyNameArray ();
5410                       
5411 carolann.graves 1.142         Array <CIMName> indicationClassProperties;
5412 carolann.graves 1.170         PEG_METHOD_EXIT();
5413 dj.gorey        1.135         return _checkPropertyList (propertyArray, nameSpaceName,
5414 carolann.graves 1.142             indicationClassName, indicationClassProperties);
5415 kumpf           1.11      }
5416 kumpf           1.37  }
5417                       
5418 dj.gorey        1.135 CIMPropertyList IndicationService::_checkPropertyList
5419 kumpf           1.54      (const Array <CIMName> & propertyList,
5420 kumpf           1.63       const CIMNamespaceName & nameSpaceName,
5421 carolann.graves 1.142      const CIMName & indicationClassName,
5422                            Array <CIMName> & indicationClassProperties) const
5423 kumpf           1.37  {
5424 kumpf           1.48      PEG_METHOD_ENTER (TRC_INDICATION_SERVICE,
5425 kumpf           1.114         "IndicationService::_checkPropertyList");
5426 kumpf           1.37  
5427 kumpf           1.14      //
5428 kumpf           1.17      //  Check if list includes all properties in class
5429                           //  If so, must be set to NULL
5430 kumpf           1.14      //
5431 kumpf           1.19      CIMClass indicationClass;
5432                       
5433 kumpf           1.114     //
5434                           //  Get the indication class object from the repository
5435                           //  Specify localOnly=false because superclass properties are needed
5436                           //  Specify includeQualifiers=false because qualifiers are not needed
5437                           //
5438 dj.gorey        1.135     indicationClass = _subscriptionRepository->getClass
5439                               (nameSpaceName, indicationClassName, false, false, false,
5440 kumpf           1.114          CIMPropertyList ());
5441 kumpf           1.19  
5442 kumpf           1.17      Boolean allProperties = true;
5443 carolann.graves 1.142     for (Uint32 i = 0; i < indicationClass.getPropertyCount (); i++)
5444 kumpf           1.17      {
5445 chip            1.162         indicationClassProperties.append
5446 carolann.graves 1.142             (indicationClass.getProperty (i).getName ());
5447 dj.gorey        1.135         if (!ContainsCIMName (propertyList,
5448 kumpf           1.37              indicationClass.getProperty (i).getName ()))
5449 kumpf           1.17          {
5450                                   allProperties = false;
5451                               }
5452                           }
5453 kumpf           1.14  
5454 kumpf           1.17      if (allProperties)
5455                           {
5456                               //
5457                               //  Return NULL CIMPropertyList
5458                               //
5459 kumpf           1.48          PEG_METHOD_EXIT ();
5460 kumpf           1.18          return CIMPropertyList ();
5461 kumpf           1.17      }
5462                           else
5463                           {
5464 kumpf           1.48          PEG_METHOD_EXIT ();
5465 kumpf           1.19          return CIMPropertyList (propertyList);
5466 kumpf           1.17      }
5467 kumpf           1.11  }
5468                       
5469 dj.gorey        1.135 String IndicationService::_getCondition
5470 kumpf           1.11      (const String & filterQuery) const
5471                       {
5472 kumpf           1.114     PEG_METHOD_ENTER (TRC_INDICATION_SERVICE,
5473                               "IndicationService::_getCondition");
5474                       
5475 kumpf           1.11      String condition = String::EMPTY;
5476                       
5477                           //
5478                           //  Get condition substring from filter query
5479                           //
5480                           if (filterQuery.find (_QUERY_WHERE) != PEG_NOT_FOUND)
5481                           {
5482 dj.gorey        1.135         condition = filterQuery.subString (filterQuery.find
5483 kumpf           1.11              (_QUERY_WHERE) + 6);
5484                           }
5485                       
5486 kumpf           1.48      PEG_METHOD_EXIT ();
5487 kumpf           1.19      return condition;
5488 kumpf           1.11  }
5489                       
5490 kumpf           1.114 void IndicationService::_deleteReferencingSubscriptions (
5491 kumpf           1.63      const CIMNamespaceName & nameSpace,
5492 kumpf           1.114     const CIMName & referenceProperty,
5493                           const CIMObjectPath & handler)
5494 kumpf           1.11  {
5495 kumpf           1.48      PEG_METHOD_ENTER (TRC_INDICATION_SERVICE,
5496 kumpf           1.114         "IndicationService::_deleteReferencingSubscriptions");
5497 kumpf           1.19  
5498 kumpf           1.114     Array <CIMInstance> deletedSubscriptions;
5499 kumpf           1.19  
5500 kumpf           1.11      //
5501 kumpf           1.114     //  Delete referencing subscriptions from the repository
5502 kumpf           1.11      //
5503 dj.gorey        1.135     deletedSubscriptions =
5504                               _subscriptionRepository->deleteReferencingSubscriptions
5505 kumpf           1.114         (nameSpace, referenceProperty, handler);
5506 kumpf           1.11  
5507                           //
5508 kumpf           1.114     //  Send delete request to each provider for each deleted subscription
5509 kumpf           1.11      //
5510 kumpf           1.114     for (Uint32 i = 0; i < deletedSubscriptions.size (); i++)
5511 kumpf           1.11      {
5512 kumpf           1.114         Array <ProviderClassList> indicationProviders;
5513                               Array <CIMName> indicationSubclasses;
5514                               CIMNamespaceName sourceNamespaceName;
5515 kumpf           1.11  
5516 carolann.graves 1.186         indicationProviders = _getDeleteParams (deletedSubscriptions [i],
5517                                   indicationSubclasses, sourceNamespaceName);
5518 kumpf           1.11  
5519 kumpf           1.1           //
5520 kumpf           1.114         //  Send Delete requests
5521 kumpf           1.1           //
5522 dj.gorey        1.135         //  NOTE: These Delete requests are not associated with a user
5523 kumpf           1.114         //  request, so there is no associated authType or userName
5524                               //  The Creator from the subscription instance is used for userName,
5525                               //  and authType is not set
5526 kumpf           1.1           //
5527 kumpf           1.114         CIMInstance instance = deletedSubscriptions [i];
5528                               String creator = String::EMPTY;
5529                               _getCreator (instance, creator);
5530 chuck           1.75  
5531 dj.gorey        1.135 // l10n start
5532 kumpf           1.195         AcceptLanguageList acceptLangs;
5533 kumpf           1.114         Uint32 propIndex = instance.findProperty
5534 dj.gorey        1.135             (PEGASUS_PROPERTYNAME_INDSUB_ACCEPTLANGS);
5535 kumpf           1.114         if (propIndex != PEG_NOT_FOUND)
5536                               {
5537 kumpf           1.194             String acceptLangsString;
5538                                   instance.getProperty(propIndex).getValue().get(
5539                                       acceptLangsString);
5540                                   if (acceptLangsString.size())
5541                                   {
5542                                       acceptLangs = LanguageParser::parseAcceptLanguageHeader(
5543                                           acceptLangsString);
5544                                   }
5545 kumpf           1.114         }
5546 kumpf           1.195         ContentLanguageList contentLangs;
5547 kumpf           1.114         propIndex = instance.findProperty
5548 dj.gorey        1.135             (PEGASUS_PROPERTYNAME_INDSUB_CONTENTLANGS);
5549 kumpf           1.114         if (propIndex != PEG_NOT_FOUND)
5550                               {
5551 kumpf           1.194             String contentLangsString;
5552                                   instance.getProperty(propIndex).getValue().get(
5553                                       contentLangsString);
5554                                   if (contentLangsString.size())
5555                                   {
5556                                       contentLangs = LanguageParser::parseContentLanguageHeader(
5557                                           contentLangsString);
5558                                   }
5559 kumpf           1.114         }
5560 chuck           1.77  // l10n end
5561 chuck           1.75  
5562 dj.gorey        1.135 // l10n
5563 carolann.graves 1.164         _sendAsyncDeleteRequests (indicationProviders, sourceNamespaceName,
5564 dj.gorey        1.135             deletedSubscriptions [i],
5565 kumpf           1.194             acceptLangs,
5566                                   contentLangs,
5567 kumpf           1.114             0,  // no request
5568                                   indicationSubclasses,
5569                                   creator);
5570 kumpf           1.11      }
5571                       
5572 kumpf           1.48      PEG_METHOD_EXIT ();
5573 kumpf           1.11  }
5574                       
5575                       Boolean IndicationService::_isExpired (
5576                           const CIMInstance & instance) const
5577                       {
5578 kumpf           1.48      PEG_METHOD_ENTER (TRC_INDICATION_SERVICE, "IndicationService::_isExpired");
5579 kumpf           1.11  
5580 kumpf           1.35      Boolean isExpired = true;
5581                           Uint64 timeRemaining = 0;
5582 kumpf           1.1   
5583 kumpf           1.11      //
5584 kumpf           1.35      //  Get time remaining, if subscription has a duration
5585 kumpf           1.11      //
5586 kumpf           1.35      if (_getTimeRemaining (instance, timeRemaining))
5587 kumpf           1.13      {
5588 kumpf           1.35          if (timeRemaining > 0)
5589                               {
5590                                   isExpired = false;
5591                               }
5592 kumpf           1.13      }
5593                           else
5594                           {
5595 kumpf           1.35          //
5596                               //  If there is no duration, the subscription has no expiration date
5597                               //
5598                               isExpired = false;
5599 kumpf           1.13      }
5600 kumpf           1.1   
5601 kumpf           1.48      PEG_METHOD_EXIT ();
5602 kumpf           1.35      return isExpired;
5603 kumpf           1.1   }
5604                       
5605 kumpf           1.11  void IndicationService::_deleteExpiredSubscription (
5606 kumpf           1.45      CIMObjectPath & subscription)
5607 kumpf           1.1   {
5608 kumpf           1.48      PEG_METHOD_ENTER (TRC_INDICATION_SERVICE,
5609 kumpf           1.114         "IndicationService::_deleteExpiredSubscription");
5610 kumpf           1.1   
5611 kumpf           1.88      CIMInstance subscriptionInstance;
5612 kumpf           1.35  
5613 kumpf           1.11      //
5614 kumpf           1.114     //  Delete instance from repository
5615 kumpf           1.88      //
5616 dj.gorey        1.135     subscriptionInstance = _subscriptionRepository->deleteSubscription
5617 kumpf           1.114         (subscription);
5618 kumpf           1.88  
5619                           //
5620 dj.gorey        1.135     //  If a valid instance object was returned, the subscription was
5621 kumpf           1.114     //  successfully deleted
5622 kumpf           1.11      //
5623 kumpf           1.114     if (!subscriptionInstance.isUninitialized ())
5624 kumpf           1.11      {
5625 kumpf           1.114         //
5626                               //  If subscription was active, send delete requests to providers
5627                               //  and update hash tables
5628                               //
5629                               Uint16 subscriptionState;
5630                               CIMValue subscriptionStateValue;
5631                               subscriptionStateValue = subscriptionInstance.getProperty
5632 dj.gorey        1.135             (subscriptionInstance.findProperty
5633 kumpf           1.114             (_PROPERTY_STATE)).getValue ();
5634                               subscriptionStateValue.get (subscriptionState);
5635 kumpf           1.1   
5636 kumpf           1.114         if ((subscriptionState == _STATE_ENABLED) ||
5637                                   (subscriptionState == _STATE_ENABLEDDEGRADED))
5638                               {
5639                                   Array <ProviderClassList> indicationProviders;
5640                                   Array <CIMName> indicationSubclasses;
5641                                   CIMNamespaceName sourceNamespaceName;
5642 kumpf           1.88  
5643 kumpf           1.114             subscriptionInstance.setPath (subscription);
5644 kumpf           1.88  
5645 carolann.graves 1.186             indicationProviders = _getDeleteParams (subscriptionInstance,
5646 kumpf           1.114                 indicationSubclasses, sourceNamespaceName);
5647 kumpf           1.88  
5648 kumpf           1.114             //
5649                                   //  Send Delete requests
5650                                   //
5651 dj.gorey        1.135             //  NOTE: These Delete requests are not associated with a user
5652 kumpf           1.114             //  request, so there is no associated authType or userName
5653                                   //  The Creator from the subscription instance is used for userName,
5654                                   //  and authType is not set
5655                                   //
5656                                   String creator;
5657                                   _getCreator (subscriptionInstance, creator);
5658 kumpf           1.88  
5659 kumpf           1.114             //
5660 dj.gorey        1.135             // Get the language tags that were saved with the subscription
5661                                   // instance
5662 kumpf           1.114             //
5663 kumpf           1.195             AcceptLanguageList acceptLangs;
5664 kumpf           1.114             Uint32 propIndex = subscriptionInstance.findProperty
5665                                       (PEGASUS_PROPERTYNAME_INDSUB_ACCEPTLANGS);
5666                                   if (propIndex != PEG_NOT_FOUND)
5667 dj.gorey        1.135             {
5668 kumpf           1.194                 String acceptLangsString;
5669                                       subscriptionInstance.getProperty(propIndex).getValue().get(
5670                                           acceptLangsString);
5671                                       if (acceptLangsString.size())
5672                                       {
5673                                           acceptLangs = LanguageParser::parseAcceptLanguageHeader(
5674                                               acceptLangsString);
5675                                       }
5676 dj.gorey        1.135             }
5677 kumpf           1.195             ContentLanguageList contentLangs;
5678 kumpf           1.114             propIndex = subscriptionInstance.findProperty
5679                                       (PEGASUS_PROPERTYNAME_INDSUB_CONTENTLANGS);
5680                                   if (propIndex != PEG_NOT_FOUND)
5681 dj.gorey        1.135             {
5682 kumpf           1.194                 String contentLangsString;
5683                                       subscriptionInstance.getProperty(propIndex).getValue().get(
5684                                           contentLangsString);
5685                                       if (contentLangsString.size())
5686                                       {
5687                                           contentLangs = LanguageParser::parseContentLanguageHeader(
5688                                               contentLangsString);
5689                                       }
5690 kumpf           1.114             }
5691 kumpf           1.88  
5692 dj.gorey        1.135 // l10n
5693 kumpf           1.114             subscriptionInstance.setPath (subscription);
5694 carolann.graves 1.164             _sendAsyncDeleteRequests (indicationProviders,
5695 kumpf           1.114                 sourceNamespaceName, subscriptionInstance,
5696 kumpf           1.194                 acceptLangs,
5697                                       contentLangs,
5698 kumpf           1.114                 0, // no request
5699                                       indicationSubclasses,
5700                                       creator);
5701                               }
5702                           }
5703                           else
5704                           {
5705 kumpf           1.88          //
5706 kumpf           1.114         //  The subscription may have already been deleted by another thread
5707 kumpf           1.88          //
5708                           }
5709                       
5710                           PEG_METHOD_EXIT ();
5711                       }
5712 kumpf           1.1   
5713 kumpf           1.35  Boolean IndicationService::_getTimeRemaining (
5714                           const CIMInstance & instance,
5715                           Uint64 & timeRemaining) const
5716 kumpf           1.1   {
5717 kumpf           1.48      PEG_METHOD_ENTER (TRC_INDICATION_SERVICE,
5718 kumpf           1.114         "IndicationService::_getTimeRemaining");
5719 kumpf           1.1   
5720 kumpf           1.35      Boolean hasDuration = true;
5721                           timeRemaining = 0;
5722                       
5723 kumpf           1.11      //
5724                           //  Calculate time remaining from subscription
5725                           //  start time, subscription duration, and current date time
5726                           //
5727 kumpf           1.1   
5728 kumpf           1.11      //
5729 dj.gorey        1.135     //  NOTE: It is assumed that the instance passed to this method is a
5730 kumpf           1.35      //  subscription instance, and that the Start Time property exists
5731                           //  and has a value
5732 kumpf           1.11      //
5733 kumpf           1.1   
5734 kumpf           1.11      //
5735                           //  Get Subscription Start Time
5736                           //
5737                           CIMValue startTimeValue;
5738                           CIMDateTime startTime;
5739 carolann.graves 1.171     Uint32 startTimeIndex = instance.findProperty (_PROPERTY_STARTTIME);
5740                           PEGASUS_ASSERT (startTimeIndex != PEG_NOT_FOUND);
5741                           startTimeValue = instance.getProperty (startTimeIndex).getValue ();
5742                           PEGASUS_ASSERT (!(startTimeValue.isNull ()));
5743 kumpf           1.11      startTimeValue.get (startTime);
5744 kumpf           1.1   
5745 kumpf           1.11      //
5746                           //  Get Subscription Duration
5747                           //
5748 carolann.graves 1.171     Uint32 durationIndex = instance.findProperty (_PROPERTY_DURATION);
5749                           if (durationIndex != PEG_NOT_FOUND)
5750 kumpf           1.35      {
5751                               CIMValue durationValue;
5752 carolann.graves 1.171         durationValue = instance.getProperty (durationIndex).getValue ();
5753 kumpf           1.35          if (durationValue.isNull ())
5754                               {
5755                                   hasDuration = false;
5756                               }
5757                               else
5758                               {
5759                                   Uint64 duration;
5760                                   durationValue.get (duration);
5761 kumpf           1.1   
5762 kumpf           1.35              //
5763 david.dillard   1.174             //  A Start Time set to the _ZERO_INTERVAL_STRING indicates that
5764 carolann.graves 1.171             //  the subscription has not yet been enabled for the first time
5765                                   //  In this case, the time remaining is equal to the Duration
5766 kumpf           1.35              //
5767 carolann.graves 1.171             if (startTime.isInterval ())
5768                                   {
5769                                       if (startTime.equal (CIMDateTime (_ZERO_INTERVAL_STRING)))
5770                                       {
5771                                           timeRemaining = (Sint64) duration;
5772                                       }
5773 dj.gorey        1.135 
5774 carolann.graves 1.171                 //
5775                                       //  Any interval value other than _ZERO_INTERVAL_STRING
5776                                       //  indicates an invalid Start Time value in the instance
5777                                       //
5778                                       else
5779                                       {
5780                                           PEGASUS_ASSERT (false);
5781                                       }
5782 kumpf           1.65              }
5783 carolann.graves 1.171 
5784                                   else
5785 kumpf           1.65              {
5786 carolann.graves 1.171                 //
5787 david.dillard   1.174                 //  Get current date time, and calculate Subscription Time
5788 carolann.graves 1.171                 //  Remaining
5789                                       //
5790                                       CIMDateTime currentDateTime = CIMDateTime::getCurrentDateTime();
5791                       
5792                                       Sint64 difference;
5793                                       try
5794                                       {
5795                                           difference = CIMDateTime::getDifference
5796                                               (startTime, currentDateTime);
5797                                       }
5798                       
5799                                       // Check if the date time is out of range.
5800 david.dillard   1.174                 catch (const DateTimeOutOfRangeException& )
5801 carolann.graves 1.171                 {
5802                                           PEG_METHOD_EXIT();
5803 david.dillard   1.174                     throw;
5804 carolann.graves 1.171                 }
5805 kumpf           1.65  
5806 carolann.graves 1.171                 PEGASUS_ASSERT (difference >= 0);
5807                                       if (((Sint64) duration - difference) >= 0)
5808                                       {
5809                                           timeRemaining = (Sint64) duration - difference;
5810                                       }
5811 kumpf           1.35              }
5812                               }
5813                           }
5814                           else
5815 kumpf           1.1       {
5816 kumpf           1.35          hasDuration = false;
5817 kumpf           1.1       }
5818 kumpf           1.35  
5819 kumpf           1.48      PEG_METHOD_EXIT ();
5820 kumpf           1.35      return hasDuration;
5821                       }
5822                       
5823                       void IndicationService::_setTimeRemaining (
5824                           CIMInstance & instance)
5825                       {
5826 kumpf           1.48      PEG_METHOD_ENTER (TRC_INDICATION_SERVICE,
5827 kumpf           1.114         "IndicationService::_setTimeRemaining");
5828 kumpf           1.35  
5829                           Uint64 timeRemaining = 0;
5830                           if (_getTimeRemaining (instance, timeRemaining))
5831 kumpf           1.1       {
5832 kumpf           1.35          //
5833                               //  Add or set the value of the property with the calculated value
5834                               //
5835 kumpf           1.52          if (instance.findProperty (_PROPERTY_TIMEREMAINING) == PEG_NOT_FOUND)
5836 kumpf           1.35          {
5837 dj.gorey        1.135             instance.addProperty (CIMProperty
5838 kumpf           1.35                  (_PROPERTY_TIMEREMAINING, timeRemaining));
5839                               }
5840 dj.gorey        1.135         else
5841 kumpf           1.35          {
5842 dj.gorey        1.135             CIMProperty remaining = instance.getProperty
5843 kumpf           1.35                  (instance.findProperty (_PROPERTY_TIMEREMAINING));
5844                                   remaining.setValue (CIMValue (timeRemaining));
5845                               }
5846 kumpf           1.1       }
5847                       
5848 kumpf           1.48      PEG_METHOD_EXIT ();
5849 kumpf           1.1   }
5850                       
5851 kumpf           1.38  void IndicationService::_getCreateParams (
5852 kumpf           1.11      const CIMInstance & subscriptionInstance,
5853 kumpf           1.73      Array <CIMName> & indicationSubclasses,
5854 kumpf           1.16      Array <ProviderClassList> & indicationProviders,
5855 kumpf           1.11      CIMPropertyList & propertyList,
5856 kumpf           1.63      CIMNamespaceName & sourceNameSpace,
5857 kumpf           1.11      String & condition,
5858 kumpf           1.124     String & query,
5859 kumpf           1.11      String & queryLanguage)
5860 kumpf           1.1   {
5861 kumpf           1.114     PEG_METHOD_ENTER (TRC_INDICATION_SERVICE,
5862                               "IndicationService::_getCreateParams");
5863                       
5864 kumpf           1.63      CIMName indicationClassName;
5865 kumpf           1.11      condition = String::EMPTY;
5866 kumpf           1.124     query = String::EMPTY;
5867 kumpf           1.11      queryLanguage = String::EMPTY;
5868 kumpf           1.1   
5869 kumpf           1.11      //
5870 kumpf           1.16      //  Get filter properties
5871 kumpf           1.11      //
5872 carolann.graves 1.186     _subscriptionRepository->getFilterProperties (subscriptionInstance, query,
5873                               sourceNameSpace, queryLanguage);
5874 chuck           1.149 
5875                           //
5876                           //  Build the query expression from the filter query
5877                           //
5878                           QueryExpression queryExpression = _getQueryExpression(query,
5879                                                                                queryLanguage,
5880                                                                                sourceNameSpace);
5881 dj.gorey        1.135 
5882 kumpf           1.11      //
5883                           //  Get indication class name from filter query (FROM clause)
5884                           //
5885 chuck           1.149     indicationClassName = _getIndicationClassName (queryExpression,
5886                                                                          sourceNameSpace);
5887 dj.gorey        1.135 
5888 kumpf           1.1       //
5889                           //  Get list of subclass names for indication class
5890                           //
5891 dj.gorey        1.135     indicationSubclasses = _subscriptionRepository->getIndicationSubclasses
5892 kumpf           1.114         (sourceNameSpace, indicationClassName);
5893 kumpf           1.19  
5894 kumpf           1.1   
5895                           //
5896 kumpf           1.11      //  Get indication provider class lists
5897 kumpf           1.1       //
5898 chuck           1.149     indicationProviders = _getIndicationProviders(
5899                                queryExpression,
5900 chip            1.162          sourceNameSpace,
5901                                indicationClassName,
5902 chuck           1.149          indicationSubclasses);
5903 kumpf           1.11  
5904                           if (indicationProviders.size () > 0)
5905 kumpf           1.1       {
5906 chuck           1.149       condition = _getCondition (query);
5907 kumpf           1.16      }
5908                       
5909 kumpf           1.48      PEG_METHOD_EXIT ();
5910 kumpf           1.16  }
5911 dj.gorey        1.135 
5912 kumpf           1.38  void IndicationService::_getCreateParams (
5913 kumpf           1.16      const CIMInstance & subscriptionInstance,
5914 kumpf           1.73      Array <CIMName> & indicationSubclasses,
5915 kumpf           1.16      CIMPropertyList & propertyList,
5916 kumpf           1.63      CIMNamespaceName & sourceNameSpace,
5917 kumpf           1.16      String & condition,
5918 kumpf           1.124     String & query,
5919 kumpf           1.16      String & queryLanguage)
5920                       {
5921 kumpf           1.114     PEG_METHOD_ENTER (TRC_INDICATION_SERVICE,
5922                               "IndicationService::_getCreateParams");
5923                       
5924 kumpf           1.16      condition = String::EMPTY;
5925 kumpf           1.124     query = String::EMPTY;
5926 kumpf           1.16      queryLanguage = String::EMPTY;
5927                       
5928                           //
5929                           //  Get filter properties
5930                           //
5931 carolann.graves 1.186     _subscriptionRepository->getFilterProperties (subscriptionInstance, query,
5932                               sourceNameSpace, queryLanguage);
5933 chuck           1.149     QueryExpression queryExpression = _getQueryExpression(query,
5934                                                                                queryLanguage,
5935                                                                                sourceNameSpace);
5936 dj.gorey        1.135 
5937 kumpf           1.16      //
5938 carolann.graves 1.175     //  Get indication class name from filter query (FROM clause)
5939 kumpf           1.16      //
5940 chuck           1.149     CIMName indicationClassName = _getIndicationClassName (queryExpression,
5941                                                                                  sourceNameSpace);
5942 carolann.graves 1.175     //
5943                           //  Get required property list from filter query (WHERE clause)
5944                           //
5945 chuck           1.149     propertyList = _getPropertyList (queryExpression,
5946 kumpf           1.70          sourceNameSpace, indicationClassName);
5947 kumpf           1.11  
5948 kumpf           1.16      //
5949                           //  Get condition from filter query (WHERE clause)
5950                           //
5951 chuck           1.149     condition = _getCondition (query);
5952 dj.gorey        1.135 
5953 kumpf           1.73      //
5954                           //  Get list of subclass names for indication class
5955                           //
5956 dj.gorey        1.135     indicationSubclasses = _subscriptionRepository->getIndicationSubclasses
5957 kumpf           1.114             (sourceNameSpace, indicationClassName);
5958 kumpf           1.73  
5959 kumpf           1.48      PEG_METHOD_EXIT ();
5960 kumpf           1.1   }
5961 dj.gorey        1.135 
5962 kumpf           1.38  Array <ProviderClassList> IndicationService::_getDeleteParams (
5963 kumpf           1.73      const CIMInstance & subscriptionInstance,
5964                           Array <CIMName> & indicationSubclasses,
5965                           CIMNamespaceName & sourceNameSpace)
5966 kumpf           1.1   {
5967 kumpf           1.114     PEG_METHOD_ENTER (TRC_INDICATION_SERVICE,
5968                               "IndicationService::_getDeleteParams");
5969                       
5970 kumpf           1.11      String filterQuery;
5971 chuck           1.149     String queryLanguage;
5972 kumpf           1.63      CIMName indicationClassName;
5973 kumpf           1.16      Array <ProviderClassList> indicationProviders;
5974 kumpf           1.6   
5975 kumpf           1.1       //
5976 kumpf           1.16      //  Get filter properties
5977 kumpf           1.11      //
5978 dj.gorey        1.135     _subscriptionRepository->getFilterProperties (subscriptionInstance,
5979 carolann.graves 1.186         filterQuery, sourceNameSpace, queryLanguage);
5980 chuck           1.149     QueryExpression queryExpression = _getQueryExpression(filterQuery,
5981                                                                                queryLanguage,
5982                                                                                sourceNameSpace);
5983 dj.gorey        1.135 
5984 kumpf           1.11      //
5985                           //  Get indication class name from filter query (FROM clause)
5986                           //
5987 chuck           1.149     indicationClassName = _getIndicationClassName (queryExpression,
5988                                                                          sourceNameSpace);
5989 dj.gorey        1.135 
5990 kumpf           1.11      //
5991                           //  Get list of subclass names for indication class
5992                           //
5993 dj.gorey        1.135     indicationSubclasses = _subscriptionRepository->getIndicationSubclasses
5994 kumpf           1.114         (sourceNameSpace, indicationClassName);
5995 kumpf           1.19  
5996 kumpf           1.11      //
5997 kumpf           1.73      //  Get indication provider class lists from Active Subscriptions table
5998 kumpf           1.11      //
5999 kumpf           1.73      ActiveSubscriptionsTableEntry tableValue;
6000 dj.gorey        1.135     if (_subscriptionTable->getSubscriptionEntry
6001 kumpf           1.114         (subscriptionInstance.getPath (), tableValue))
6002 kumpf           1.73      {
6003                               indicationProviders = tableValue.providers;
6004                           }
6005                           else
6006                           {
6007                               //
6008 kumpf           1.88          //  Subscription not found in Active Subscriptions table
6009 kumpf           1.73          //
6010                           }
6011 kumpf           1.11  
6012 kumpf           1.48      PEG_METHOD_EXIT ();
6013 kumpf           1.11      return indicationProviders;
6014                       }
6015 dj.gorey        1.135 
6016                       // l10n
6017 carolann.graves 1.164 void IndicationService::_sendAsyncCreateRequests
6018 kumpf           1.88      (const Array <ProviderClassList> & indicationProviders,
6019                            const CIMNamespaceName & nameSpace,
6020                            const CIMPropertyList & propertyList,
6021                            const String & condition,
6022 kumpf           1.124      const String & query,
6023 kumpf           1.88       const String & queryLanguage,
6024                            const CIMInstance & subscription,
6025 kumpf           1.195      const AcceptLanguageList & acceptLangs,
6026                            const ContentLanguageList & contentLangs,
6027 kumpf           1.88       const CIMRequestMessage * origRequest,
6028                            const Array <CIMName> & indicationSubclasses,
6029                            const String & userName,
6030                            const String & authType)
6031                       {
6032 kumpf           1.114     PEG_METHOD_ENTER (TRC_INDICATION_SERVICE,
6033 carolann.graves 1.164         "IndicationService::_sendAsyncCreateRequests");
6034 kumpf           1.114 
6035 kumpf           1.88      CIMValue propValue;
6036                           Uint16 repeatNotificationPolicy;
6037 mday            1.20  
6038 kumpf           1.107     // If there are no providers to accept the subscription, just return
6039                           if (indicationProviders.size() == 0)
6040                           {
6041 carolann.graves 1.170         PEG_METHOD_EXIT();
6042 kumpf           1.107         return;
6043                           }
6044                       
6045 kumpf           1.88      //
6046                           //  Get repeat notification policy value from subscription instance
6047                           //
6048 dj.gorey        1.135     propValue = subscription.getProperty
6049                               (subscription.findProperty
6050 kumpf           1.88          (_PROPERTY_REPEATNOTIFICATIONPOLICY)).getValue ();
6051                           propValue.get (repeatNotificationPolicy);
6052                       
6053 w.otsuka        1.154     CIMRequestMessage * aggRequest=0;
6054 dj.gorey        1.135 
6055 kumpf           1.88      if (origRequest == 0)
6056                           {
6057                               //
6058                               //  Initialize -- no request associated with this create
6059                               //
6060                               aggRequest = 0;
6061                           }
6062                           else
6063                           {
6064                               //
6065 carolann.graves 1.164         //  Create Instance or Modify Instance
6066 kumpf           1.88          //
6067                               switch (origRequest->getType ())
6068                               {
6069                                   case CIM_CREATE_INSTANCE_REQUEST_MESSAGE:
6070                                   {
6071                                       CIMCreateInstanceRequestMessage * request =
6072                                           (CIMCreateInstanceRequestMessage *) origRequest;
6073                                       CIMCreateInstanceRequestMessage * requestCopy =
6074                                           new CIMCreateInstanceRequestMessage (* request);
6075                                       aggRequest = requestCopy;
6076                                       break;
6077                                   }
6078                       
6079                                   case CIM_MODIFY_INSTANCE_REQUEST_MESSAGE:
6080                                   {
6081                                       CIMModifyInstanceRequestMessage * request =
6082                                           (CIMModifyInstanceRequestMessage *) origRequest;
6083                                       CIMModifyInstanceRequestMessage * requestCopy =
6084                                           new CIMModifyInstanceRequestMessage (* request);
6085                                       aggRequest = requestCopy;
6086                                       break;
6087 kumpf           1.88              }
6088                       
6089                                   default:
6090                                   {
6091 dj.gorey        1.135                 PEG_TRACE_STRING (TRC_INDICATION_SERVICE_INTERNAL,
6092 kumpf           1.114                     Tracer::LEVEL2, "Unexpected origRequest type " +
6093 kumpf           1.88                      String (MessageTypeToString (origRequest->getType ())) +
6094 carolann.graves 1.164                     " in _sendAsyncCreateRequests");
6095                                       PEGASUS_ASSERT (false);
6096 kumpf           1.88                  break;
6097                                   }
6098                               }
6099                           }
6100                       
6101                           //
6102                           //  Create an aggregate object for the create subscription requests
6103                           //
6104 dj.gorey        1.135     IndicationOperationAggregate * operationAggregate =
6105 kumpf           1.88          new IndicationOperationAggregate (aggRequest, indicationSubclasses);
6106                           operationAggregate->setNumberIssued (indicationProviders.size ());
6107                       
6108                           //
6109                           //  Send Create request to each provider
6110                           //
6111                           for (Uint32 i = 0; i < indicationProviders.size (); i++)
6112                           {
6113                               //
6114                               //  Create the create subscription request
6115                               //
6116 dj.gorey        1.135 // l10n
6117 se.gupta        1.131        CIMCreateSubscriptionRequestMessage * request =
6118 kumpf           1.88              new CIMCreateSubscriptionRequestMessage
6119                                       (XmlWriter::getNextMessageId (),
6120                                       nameSpace,
6121                                       subscription,
6122 dj.gorey        1.135                 indicationProviders [i].classList,
6123 kumpf           1.88                  propertyList,
6124                                       repeatNotificationPolicy,
6125 kumpf           1.124                 query,
6126 kumpf           1.88                  QueueIdStack (_providerManager, getQueueId ()),
6127                                       authType,
6128 se.gupta        1.132                 userName);
6129 kumpf           1.88  
6130                               //
6131                               //  Store a copy of the request in the operation aggregate instance
6132                               //
6133                               CIMCreateSubscriptionRequestMessage * requestCopy =
6134                                   new CIMCreateSubscriptionRequestMessage (* request);
6135 chip            1.162         requestCopy->operationContext.insert(ProviderIdContainer
6136 kumpf           1.137             (indicationProviders [i].providerModule,
6137 chip            1.162             indicationProviders [i].provider));
6138 kumpf           1.88          operationAggregate->appendRequest (requestCopy);
6139                       
6140 chip            1.162         request->operationContext.insert(ProviderIdContainer
6141 kumpf           1.137             (indicationProviders [i].providerModule,
6142 chip            1.162             indicationProviders [i].provider));
6143 kumpf           1.137         request->operationContext.insert(SubscriptionInstanceContainer
6144                                   (subscription));
6145                               request->operationContext.insert(SubscriptionFilterConditionContainer
6146                                   (condition,queryLanguage));
6147 carolann.graves 1.164         request->operationContext.insert(SubscriptionFilterQueryContainer
6148                                   (query,queryLanguage,nameSpace));
6149 kumpf           1.137         request->operationContext.insert(IdentityContainer(userName));
6150                               request->operationContext.set(ContentLanguageListContainer
6151                                   (contentLangs));
6152                               request->operationContext.set(AcceptLanguageListContainer(acceptLangs));
6153 se.gupta        1.126 
6154 dj.gorey        1.135         AsyncOpNode * op = this->get_op ();
6155 kumpf           1.88  
6156                               AsyncLegacyOperationStart * async_req =
6157 kumpf           1.200             new AsyncLegacyOperationStart(
6158 kumpf           1.88                  op,
6159                                       _providerManager,
6160                                       request,
6161                                       _queueId);
6162                       
6163 dj.gorey        1.135         SendAsync
6164                                   (op,
6165                                   _providerManager,
6166 kumpf           1.88              IndicationService::_aggregationCallBack,
6167 dj.gorey        1.135             this,
6168 kumpf           1.88              operationAggregate);
6169                           }
6170 kumpf           1.31  
6171 kumpf           1.48      PEG_METHOD_EXIT ();
6172 mday            1.20  }
6173                       
6174 carolann.graves 1.172 Array <ProviderClassList> IndicationService::_sendWaitCreateRequests
6175 kumpf           1.16      (const Array <ProviderClassList> & indicationProviders,
6176 kumpf           1.63       const CIMNamespaceName & nameSpace,
6177 kumpf           1.11       const CIMPropertyList & propertyList,
6178                            const String & condition,
6179 kumpf           1.124      const String & query,
6180 kumpf           1.11       const String & queryLanguage,
6181 kumpf           1.46       const CIMInstance & subscription,
6182 kumpf           1.195      const AcceptLanguageList & acceptLangs,
6183                            const ContentLanguageList & contentLangs,
6184 kumpf           1.15       const String & userName,
6185                            const String & authType)
6186 kumpf           1.11  {
6187 kumpf           1.114     PEG_METHOD_ENTER (TRC_INDICATION_SERVICE,
6188 carolann.graves 1.164         "IndicationService::_sendWaitCreateRequests");
6189 kumpf           1.114 
6190 kumpf           1.11      CIMValue propValue;
6191                           Uint16 repeatNotificationPolicy;
6192 carolann.graves 1.172     Array <ProviderClassList> acceptedProviders;
6193                           acceptedProviders.clear ();
6194 kumpf           1.11  
6195 carolann.graves 1.164     // If there are no providers to accept the subscription, just return
6196 kumpf           1.107     if (indicationProviders.size() == 0)
6197                           {
6198 carolann.graves 1.170         PEG_METHOD_EXIT();
6199 carolann.graves 1.172         return acceptedProviders;
6200 kumpf           1.107     }
6201                       
6202 kumpf           1.1       //
6203 kumpf           1.14      //  Get repeat notification policy value from subscription instance
6204 kumpf           1.1       //
6205 dj.gorey        1.135     propValue = subscription.getProperty
6206 kumpf           1.88          (subscription.findProperty
6207 kumpf           1.11          (_PROPERTY_REPEATNOTIFICATIONPOLICY)).getValue ();
6208                           propValue.get (repeatNotificationPolicy);
6209                       
6210 kumpf           1.88      //
6211 carolann.graves 1.164     //  Send Create request to each provider
6212 kumpf           1.88      //
6213 carolann.graves 1.164     for (Uint32 i = 0; i < indicationProviders.size (); i++)
6214 kumpf           1.88      {
6215                               //
6216 carolann.graves 1.164         //  Create the create subscription request
6217 kumpf           1.88          //
6218 carolann.graves 1.164         CIMCreateSubscriptionRequestMessage * request =
6219                                   new CIMCreateSubscriptionRequestMessage
6220                                       (XmlWriter::getNextMessageId (),
6221                                       nameSpace,
6222                                       subscription,
6223                                       indicationProviders [i].classList,
6224                                       propertyList,
6225                                       repeatNotificationPolicy,
6226                                       query,
6227                                       QueueIdStack (_providerManager, getQueueId ()),
6228                                       authType,
6229                                       userName);
6230                       
6231                               //
6232                               //  Set operation context
6233                               //
6234                               request->operationContext.insert(ProviderIdContainer
6235                                   (indicationProviders [i].providerModule,
6236                                   indicationProviders [i].provider));
6237                               request->operationContext.insert(SubscriptionInstanceContainer
6238                                   (subscription));
6239 carolann.graves 1.164         request->operationContext.insert(SubscriptionFilterConditionContainer
6240                                   (condition,queryLanguage));
6241                               request->operationContext.insert(SubscriptionFilterQueryContainer
6242                                   (query,queryLanguage,nameSpace));
6243                               request->operationContext.insert(IdentityContainer(userName));
6244                               request->operationContext.set(ContentLanguageListContainer
6245                                   (contentLangs));
6246                               request->operationContext.set(AcceptLanguageListContainer(acceptLangs));
6247                       
6248                               AsyncOpNode * op = this->get_op ();
6249                       
6250                               AsyncLegacyOperationStart * asyncRequest =
6251 kumpf           1.200             new AsyncLegacyOperationStart(
6252 carolann.graves 1.164                 op,
6253                                       _providerManager,
6254                                       request,
6255                                       _queueId);
6256                       
6257                               AsyncReply * asyncReply = SendWait (asyncRequest);
6258                       
6259                               CIMCreateSubscriptionResponseMessage * response =
6260                                   reinterpret_cast <CIMCreateSubscriptionResponseMessage *>
6261                                   ((static_cast <AsyncLegacyOperationResult *>
6262                                   (asyncReply))->get_result ());
6263                       
6264                               if (response->cimException.getCode () == CIM_ERR_SUCCESS)
6265 kumpf           1.88          {
6266 carolann.graves 1.172             acceptedProviders.append (indicationProviders [i]);
6267 kumpf           1.88          }
6268                               else
6269                               {
6270 carolann.graves 1.164             //
6271                                   //  Provider rejected the subscription
6272                                   //
6273                                   PEG_TRACE_STRING (TRC_INDICATION_SERVICE_INTERNAL, Tracer::LEVEL3,
6274                                       "Provider (" +
6275                                       indicationProviders [i].provider.getPath ().toString () +
6276                                       ") rejected create subscription: " +
6277                                       response->cimException.getMessage ());
6278 kumpf           1.88          }
6279 carolann.graves 1.164 
6280 carolann.graves 1.185         delete response;
6281 carolann.graves 1.164         delete asyncRequest;
6282                               delete asyncReply;
6283                           }  //  for each indication provider
6284                       
6285                           PEG_METHOD_EXIT ();
6286 carolann.graves 1.172     return acceptedProviders;
6287 carolann.graves 1.164 }
6288                       
6289                       // l10n
6290                       void IndicationService::_sendWaitModifyRequests
6291                           (const Array <ProviderClassList> & indicationProviders,
6292                            const CIMNamespaceName & nameSpace,
6293                            const CIMPropertyList & propertyList,
6294                            const String & condition,
6295                            const String & query,
6296                            const String & queryLanguage,
6297                            const CIMInstance & subscription,
6298 kumpf           1.195      const AcceptLanguageList & acceptLangs,
6299                            const ContentLanguageList & contentLangs,
6300 carolann.graves 1.164      const String & userName,
6301                            const String & authType)
6302                       {
6303                           PEG_METHOD_ENTER (TRC_INDICATION_SERVICE,
6304                               "IndicationService::_sendWaitModifyRequests");
6305                       
6306                           CIMValue propValue;
6307                           Uint16 repeatNotificationPolicy;
6308                       
6309                           // If there are no providers to accept the subscription update, just return
6310                           if (indicationProviders.size() == 0)
6311 kumpf           1.88      {
6312 carolann.graves 1.170         PEG_METHOD_EXIT();
6313 carolann.graves 1.164         return;
6314 kumpf           1.88      }
6315                       
6316 carolann.graves 1.164     //
6317                           //  Get repeat notification policy value from subscription instance
6318                           //
6319                           propValue = subscription.getProperty
6320                               (subscription.findProperty
6321                               (_PROPERTY_REPEATNOTIFICATIONPOLICY)).getValue ();
6322                           propValue.get (repeatNotificationPolicy);
6323 kumpf           1.88  
6324                           //
6325                           //  Send Modify request to each provider
6326                           //
6327                           for (Uint32 i = 0; i < indicationProviders.size (); i++)
6328                           {
6329                       // l10n
6330                               CIMModifySubscriptionRequestMessage * request =
6331                                   new CIMModifySubscriptionRequestMessage
6332                                       (XmlWriter::getNextMessageId (),
6333                                       nameSpace,
6334                                       subscription,
6335 dj.gorey        1.135                 indicationProviders [i].classList,
6336 kumpf           1.88                  propertyList,
6337                                       repeatNotificationPolicy,
6338 kumpf           1.124                 query,
6339 kumpf           1.88                  QueueIdStack (_providerManager, getQueueId ()),
6340                                       authType,
6341 se.gupta        1.132                 userName);
6342 kumpf           1.88  
6343                               //
6344 carolann.graves 1.164         //  Set operation context
6345 kumpf           1.88          //
6346 chip            1.162         request->operationContext.insert(ProviderIdContainer
6347 kumpf           1.137             (indicationProviders [i].providerModule,
6348                                   indicationProviders [i].provider));
6349                               request->operationContext.insert(SubscriptionInstanceContainer
6350                                   (subscription));
6351                               request->operationContext.insert(SubscriptionFilterConditionContainer
6352                                   (condition,queryLanguage));
6353 carolann.graves 1.164         request->operationContext.insert(SubscriptionFilterQueryContainer
6354                                   (query,queryLanguage,nameSpace));
6355 kumpf           1.137         request->operationContext.insert(IdentityContainer(userName));
6356                               request->operationContext.set(ContentLanguageListContainer
6357                                   (contentLangs));
6358                               request->operationContext.set(AcceptLanguageListContainer(acceptLangs));
6359 se.gupta        1.126 
6360 kumpf           1.137         AsyncOpNode * op = this->get_op ();
6361 kumpf           1.88  
6362 carolann.graves 1.164         AsyncLegacyOperationStart * asyncRequest =
6363 kumpf           1.200             new AsyncLegacyOperationStart(
6364 kumpf           1.88                  op,
6365                                       _providerManager,
6366                                       request,
6367                                       _queueId);
6368                       
6369 carolann.graves 1.164         AsyncReply * asyncReply = SendWait (asyncRequest);
6370                       
6371                               CIMModifySubscriptionResponseMessage * response =
6372                                   reinterpret_cast <CIMModifySubscriptionResponseMessage *>
6373                                   ((static_cast <AsyncLegacyOperationResult *>
6374                                   (asyncReply))->get_result ());
6375                       
6376                               if (!(response->cimException.getCode () == CIM_ERR_SUCCESS))
6377                               {
6378                                   //
6379                                   //  Provider rejected the subscription
6380                                   //
6381                                   PEG_TRACE_STRING (TRC_INDICATION_SERVICE_INTERNAL, Tracer::LEVEL3,
6382                                       "Provider (" +
6383                                       indicationProviders [i].provider.getPath ().toString () +
6384                                       ") rejected modify subscription: " +
6385                                       response->cimException.getMessage ());
6386                               }
6387                       
6388                               delete asyncRequest;
6389                               delete asyncReply;
6390 carolann.graves 1.164     }  //  for each indication provider
6391 kumpf           1.88  
6392                           PEG_METHOD_EXIT ();
6393                       }
6394                       
6395                       // l10n
6396 carolann.graves 1.164 void IndicationService::_sendAsyncDeleteRequests
6397 kumpf           1.88      (const Array <ProviderClassList> & indicationProviders,
6398                            const CIMNamespaceName & nameSpace,
6399                            const CIMInstance & subscription,
6400 kumpf           1.195      const AcceptLanguageList & acceptLangs,
6401                            const ContentLanguageList & contentLangs,
6402 kumpf           1.88       const CIMRequestMessage * origRequest,
6403                            const Array <CIMName> & indicationSubclasses,
6404                            const String & userName,
6405                            const String & authType)
6406                       {
6407                           PEG_METHOD_ENTER (TRC_INDICATION_SERVICE,
6408 carolann.graves 1.164         "IndicationService::_sendAsyncDeleteRequests");
6409 kumpf           1.88  
6410 kumpf           1.107     // If there are no providers to delete the subscription, just return
6411                           if (indicationProviders.size() == 0)
6412                           {
6413 carolann.graves 1.170         PEG_METHOD_EXIT();
6414 kumpf           1.107         return;
6415                           }
6416                       
6417 carolann.graves 1.198     //
6418                           //  Update subscription hash tables
6419                           //
6420                           _subscriptionTable->removeSubscription
6421                               (subscription,
6422                               indicationSubclasses,
6423                               nameSpace,
6424                               indicationProviders);
6425                       
6426 w.otsuka        1.154     CIMRequestMessage * aggRequest = 0;
6427 kumpf           1.88  
6428                           if (origRequest == 0)
6429                           {
6430                               //
6431 dj.gorey        1.135         //  Delete a referencing or expired subscription -- no request
6432 kumpf           1.88          //  associated with this delete
6433                               //
6434                               aggRequest = 0;
6435                           }
6436                           else
6437                           {
6438                               //
6439 carolann.graves 1.164         //  Delete Instance or Modify Instance
6440 kumpf           1.88          //
6441                               switch (origRequest->getType ())
6442                               {
6443                                   case CIM_DELETE_INSTANCE_REQUEST_MESSAGE:
6444                                   {
6445                                       CIMDeleteInstanceRequestMessage * request =
6446                                           (CIMDeleteInstanceRequestMessage *) origRequest;
6447                                       CIMDeleteInstanceRequestMessage * requestCopy =
6448                                           new CIMDeleteInstanceRequestMessage (* request);
6449                                       aggRequest = requestCopy;
6450                                       break;
6451                                   }
6452                       
6453                                   case CIM_MODIFY_INSTANCE_REQUEST_MESSAGE:
6454                                   {
6455                                       CIMModifyInstanceRequestMessage * request =
6456                                           (CIMModifyInstanceRequestMessage *) origRequest;
6457                                       CIMModifyInstanceRequestMessage * requestCopy =
6458                                           new CIMModifyInstanceRequestMessage (* request);
6459                                       aggRequest = requestCopy;
6460                                       break;
6461 kumpf           1.88              }
6462                       
6463                                   default:
6464                                   {
6465 dj.gorey        1.135                 PEG_TRACE_STRING (TRC_INDICATION_SERVICE_INTERNAL,
6466 kumpf           1.114                     Tracer::LEVEL2, "Unexpected origRequest type " +
6467 kumpf           1.88                      String (MessageTypeToString (origRequest->getType ())) +
6468 carolann.graves 1.164                     " in _sendAsyncDeleteRequests");
6469                                       PEGASUS_ASSERT (false);
6470 kumpf           1.88                  break;
6471                                   }
6472                               }
6473                           }
6474                       
6475 kumpf           1.11      //
6476 kumpf           1.88      //  Create an aggregate object for the delete subscription requests
6477 kumpf           1.11      //
6478 kumpf           1.88      IndicationOperationAggregate * operationAggregate =
6479                               new IndicationOperationAggregate (aggRequest, indicationSubclasses);
6480                           operationAggregate->setNumberIssued (indicationProviders.size ());
6481 mday            1.20  
6482 kumpf           1.88      //
6483                           //  Send Delete request to each provider
6484                           //
6485 kumpf           1.83      for (Uint32 i = 0; i < indicationProviders.size (); i++)
6486 kumpf           1.11      {
6487 kumpf           1.88  // l10n
6488                               CIMDeleteSubscriptionRequestMessage * request =
6489                                   new CIMDeleteSubscriptionRequestMessage
6490 kumpf           1.11                  (XmlWriter::getNextMessageId (),
6491                                       nameSpace,
6492 kumpf           1.46                  subscription,
6493 kumpf           1.96                  indicationProviders [i].classList,
6494 kumpf           1.88                  QueueIdStack (_providerManager, getQueueId ()),
6495                                       authType,
6496 se.gupta        1.132                 userName);
6497 kumpf           1.88  
6498                               //
6499                               //  Store a copy of the request in the operation aggregate instance
6500                               //
6501                               CIMDeleteSubscriptionRequestMessage * requestCopy =
6502                                   new CIMDeleteSubscriptionRequestMessage (* request);
6503 chip            1.162         requestCopy->operationContext.insert(ProviderIdContainer
6504 kumpf           1.137             (indicationProviders [i].providerModule,
6505                                   indicationProviders [i].provider));
6506 kumpf           1.88          operationAggregate->appendRequest (requestCopy);
6507                       
6508 chip            1.162         request->operationContext.insert(ProviderIdContainer
6509 kumpf           1.137             (indicationProviders [i].providerModule,
6510 chip            1.162             indicationProviders [i].provider));
6511 kumpf           1.137         request->operationContext.insert(SubscriptionInstanceContainer
6512                                   (subscription));
6513                               request->operationContext.insert(IdentityContainer(userName));
6514                               request->operationContext.set(ContentLanguageListContainer
6515                                   (contentLangs));
6516                               request->operationContext.set(AcceptLanguageListContainer(acceptLangs));
6517 se.gupta        1.121 
6518 kumpf           1.88          AsyncOpNode * op = this->get_op ();
6519 kumpf           1.1   
6520 kumpf           1.11          AsyncLegacyOperationStart * async_req =
6521 kumpf           1.200             new AsyncLegacyOperationStart(
6522 kumpf           1.11                  op,
6523                                       _providerManager,
6524                                       request,
6525                                       _queueId);
6526 kumpf           1.1   
6527 dj.gorey        1.135         SendAsync
6528 kumpf           1.88              (op,
6529                                   _providerManager,
6530                                   IndicationService::_aggregationCallBack,
6531                                   this,
6532                                   operationAggregate);
6533                           }
6534                       
6535                           PEG_METHOD_EXIT ();
6536                       }
6537                       
6538 carolann.graves 1.164 void IndicationService::_sendWaitDeleteRequests
6539                           (const Array <ProviderClassList> & indicationProviders,
6540                            const CIMNamespaceName & nameSpace,
6541                            const CIMInstance & subscription,
6542 kumpf           1.195      const AcceptLanguageList & acceptLangs,
6543                            const ContentLanguageList & contentLangs,
6544 carolann.graves 1.164      const String & userName,
6545                            const String & authType)
6546                       {
6547                           PEG_METHOD_ENTER (TRC_INDICATION_SERVICE,
6548                               "IndicationService::_sendWaitDeleteRequests");
6549                       
6550                           // If there are no providers to delete the subscription, just return
6551                           if (indicationProviders.size() == 0)
6552                           {
6553 carolann.graves 1.170         PEG_METHOD_EXIT();
6554 carolann.graves 1.164         return;
6555                           }
6556                       
6557                           //
6558                           //  Send Delete request to each provider
6559                           //
6560                           for (Uint32 i = 0; i < indicationProviders.size (); i++)
6561                           {
6562                               CIMDeleteSubscriptionRequestMessage * request =
6563                                   new CIMDeleteSubscriptionRequestMessage
6564                                       (XmlWriter::getNextMessageId (),
6565                                       nameSpace,
6566                                       subscription,
6567                                       indicationProviders [i].classList,
6568                                       QueueIdStack (_providerManager, getQueueId ()),
6569                                       authType,
6570                                       userName);
6571                       
6572                               //
6573                               //  Set operation context
6574                               //
6575 carolann.graves 1.164         request->operationContext.insert(ProviderIdContainer
6576                                   (indicationProviders [i].providerModule,
6577                                   indicationProviders [i].provider));
6578                               request->operationContext.insert(SubscriptionInstanceContainer
6579                                   (subscription));
6580                               request->operationContext.insert(IdentityContainer(userName));
6581                               request->operationContext.set(ContentLanguageListContainer
6582                                   (contentLangs));
6583                               request->operationContext.set(AcceptLanguageListContainer(acceptLangs));
6584                       
6585                               AsyncOpNode * op = this->get_op ();
6586                       
6587                               AsyncLegacyOperationStart * asyncRequest =
6588 kumpf           1.200             new AsyncLegacyOperationStart(
6589 carolann.graves 1.164                 op,
6590                                       _providerManager,
6591                                       request,
6592                                       _queueId);
6593                       
6594                               AsyncReply * asyncReply = SendWait (asyncRequest);
6595                       
6596                               CIMDeleteSubscriptionResponseMessage * response =
6597                                   reinterpret_cast <CIMDeleteSubscriptionResponseMessage *>
6598                                   ((static_cast <AsyncLegacyOperationResult *>
6599                                   (asyncReply))->get_result ());
6600                       
6601                               if (!(response->cimException.getCode () == CIM_ERR_SUCCESS))
6602                               {
6603                                   //
6604                                   //  Provider rejected the subscription
6605                                   //
6606                                   PEG_TRACE_STRING (TRC_INDICATION_SERVICE_INTERNAL, Tracer::LEVEL3,
6607                                       "Provider (" +
6608                                       indicationProviders [i].provider.getPath ().toString () +
6609                                       ") rejected delete subscription: " +
6610 carolann.graves 1.164                 response->cimException.getMessage ());
6611                               }
6612                       
6613                               delete asyncRequest;
6614                               delete asyncReply;
6615                           }  //  for each indication provider
6616                       
6617                           PEG_METHOD_EXIT ();
6618                       }
6619                       
6620 kumpf           1.88  void IndicationService::_aggregationCallBack (
6621                           AsyncOpNode * op,
6622                           MessageQueue * q,
6623                           void * userParameter)
6624                       {
6625                           PEG_METHOD_ENTER (TRC_INDICATION_SERVICE,
6626                               "IndicationService::_aggregationCallBack");
6627                       
6628                           IndicationService * service = static_cast <IndicationService *> (q);
6629                       
6630 dj.gorey        1.135     AsyncRequest * asyncRequest =
6631 kumpf           1.201         static_cast<AsyncRequest *>(op->removeRequest());
6632                           AsyncReply * asyncReply = static_cast<AsyncReply *>(op->removeResponse());
6633 kumpf           1.88  
6634 dj.gorey        1.135     IndicationOperationAggregate * operationAggregate =
6635 kumpf           1.88          reinterpret_cast <IndicationOperationAggregate *> (userParameter);
6636                           PEGASUS_ASSERT (operationAggregate != 0);
6637                       
6638 w.otsuka        1.154     CIMResponseMessage * response = 0;
6639 kumpf           1.88      Uint32 msgType = asyncReply->getType ();
6640 dj.gorey        1.135     PEGASUS_ASSERT ((msgType == async_messages::ASYNC_LEGACY_OP_RESULT) ||
6641 kumpf           1.88                      (msgType == async_messages::ASYNC_MODULE_OP_RESULT));
6642                       
6643                           if (msgType == async_messages::ASYNC_LEGACY_OP_RESULT)
6644                           {
6645                               response = reinterpret_cast <CIMResponseMessage *>
6646 dj.gorey        1.135             ((static_cast <AsyncLegacyOperationResult *>
6647 kumpf           1.88              (asyncReply))->get_result ());
6648                           }
6649                           else if (msgType == async_messages::ASYNC_MODULE_OP_RESULT)
6650                           {
6651                               response = reinterpret_cast <CIMResponseMessage *>
6652                                   ((static_cast <AsyncModuleOperationResult *>
6653                                   (asyncReply))->get_result ());
6654                           }
6655                       
6656                           PEGASUS_ASSERT (response != 0);
6657                       
6658                           delete asyncRequest;
6659                           delete asyncReply;
6660                           op->release ();
6661                           service->return_op (op);
6662                       
6663                           Boolean isDoneAggregation = operationAggregate->appendResponse (response);
6664                           if (isDoneAggregation)
6665                           {
6666                               service->_handleOperationResponseAggregation (operationAggregate);
6667                           }
6668 kumpf           1.88  
6669                           PEG_METHOD_EXIT ();
6670                       }
6671                       
6672                       void IndicationService::_handleOperationResponseAggregation (
6673                           IndicationOperationAggregate * operationAggregate)
6674                       {
6675                           PEG_METHOD_ENTER (TRC_INDICATION_SERVICE,
6676                               "IndicationService::_handleOperationResponseAggregation");
6677                       
6678                           switch (operationAggregate->getRequest (0)->getType ())
6679                           {
6680                               case CIM_CREATE_SUBSCRIPTION_REQUEST_MESSAGE:
6681                               {
6682                                   _handleCreateResponseAggregation (operationAggregate);
6683                                   break;
6684                               }
6685                       
6686                               case CIM_DELETE_SUBSCRIPTION_REQUEST_MESSAGE:
6687                               {
6688                                   _handleDeleteResponseAggregation (operationAggregate);
6689 kumpf           1.88              break;
6690                               }
6691                       
6692                               default:
6693                               {
6694 dj.gorey        1.135             PEG_TRACE_STRING (TRC_INDICATION_SERVICE_INTERNAL, Tracer::LEVEL2,
6695                                       "Unexpected request type " + String (MessageTypeToString
6696 kumpf           1.88                      (operationAggregate->getRequest (0)->getType ())) +
6697                                       " in _handleOperationResponseAggregation");
6698 carolann.graves 1.164             PEGASUS_ASSERT (false);
6699 kumpf           1.88              break;
6700                               }
6701                           }
6702                       
6703                           //
6704                           //  Requests and responses are deleted in destructor
6705                           //
6706                           delete operationAggregate;
6707                       
6708                           PEG_METHOD_EXIT ();
6709                       }
6710                       
6711                       void IndicationService::_handleCreateResponseAggregation (
6712                           IndicationOperationAggregate * operationAggregate)
6713                       {
6714                           PEG_METHOD_ENTER (TRC_INDICATION_SERVICE,
6715                               "IndicationService::_handleCreateResponseAggregation");
6716                       
6717 kumpf           1.104     Array <ProviderClassList> acceptedProviders;
6718 kumpf           1.88      CIMObjectPath instanceRef;
6719                           CIMException cimException;
6720                       
6721                           //
6722                           //  Examine provider responses
6723                           //
6724 carolann.graves 1.172     acceptedProviders.clear ();
6725 kumpf           1.88      for (Uint32 i = 0; i < operationAggregate->getNumberResponses (); i++)
6726                           {
6727                               //
6728 carolann.graves 1.172         //  Find provider from which response was sent
6729 kumpf           1.88          //
6730                               CIMResponseMessage * response = operationAggregate->getResponse (i);
6731 dj.gorey        1.135         ProviderClassList provider = operationAggregate->findProvider
6732 kumpf           1.88              (response->messageId);
6733                               if (response->cimException.getCode () == CIM_ERR_SUCCESS)
6734                               {
6735                                   //
6736 carolann.graves 1.172             //  If response is SUCCESS, provider accepted the subscription
6737                                   //  Add provider to list of providers that accepted subscription
6738 kumpf           1.88              //
6739 kumpf           1.104             acceptedProviders.append (provider);
6740 kumpf           1.88          }
6741                               else
6742                               {
6743 dj.gorey        1.135             PEG_TRACE_STRING (TRC_INDICATION_SERVICE_INTERNAL, Tracer::LEVEL3,
6744 kumpf           1.88                  "Provider (" + provider.provider.getPath().toString() +
6745                                       ") rejected create subscription: " +
6746                                       response->cimException.getMessage ());
6747                               }
6748                           }
6749                       
6750                           CIMCreateSubscriptionRequestMessage * request =
6751 dj.gorey        1.135         (CIMCreateSubscriptionRequestMessage *)
6752 kumpf           1.88              operationAggregate->getRequest (0);
6753 carolann.graves 1.172     if (acceptedProviders.size () == 0)
6754 kumpf           1.88      {
6755                               //
6756                               //  No providers accepted this subscription
6757                               //
6758 carolann.graves 1.172         if (operationAggregate->requiresResponse ())
6759 kumpf           1.88          {
6760                                   //
6761 carolann.graves 1.164             //  For Create Instance or Modify Instance request, set CIM
6762                                   //  exception for response
6763 kumpf           1.88              //
6764                                   // l10n
6765                                   cimException = PEGASUS_CIM_EXCEPTION_L (CIM_ERR_NOT_SUPPORTED,
6766                                       MessageLoaderParms (_MSG_NOT_ACCEPTED_KEY, _MSG_NOT_ACCEPTED));
6767                               }
6768                           }
6769                       
6770                           else
6771                           {
6772                               //
6773                               //  At least one provider accepted the subscription
6774                               //
6775                               if (operationAggregate->getOrigType () ==
6776                                   CIM_CREATE_INSTANCE_REQUEST_MESSAGE)
6777                               {
6778                                   //
6779                                   //  Create Instance -- create the instance in the repository
6780                                   //
6781                                   CIMCreateInstanceRequestMessage * origRequest =
6782                                       (CIMCreateInstanceRequestMessage *)
6783                                           operationAggregate->getOrigRequest ();
6784 dj.gorey        1.135 
6785 kumpf           1.88              CIMInstance instance = request->subscriptionInstance;
6786                                   try
6787                                   {
6788 chip            1.162                 instanceRef = _subscriptionRepository->createInstance
6789                                           (request->subscriptionInstance, origRequest->nameSpace,
6790 kumpf           1.137                     ((IdentityContainer)origRequest->operationContext.get
6791 chip            1.162                         (IdentityContainer::NAME)).getUserName(),
6792 kumpf           1.137                     ((AcceptLanguageListContainer)request->operationContext.get
6793                                               (AcceptLanguageListContainer::NAME)).getLanguages(),
6794                                           ((ContentLanguageListContainer)request->operationContext.get
6795                                               (ContentLanguageListContainer::NAME)).getLanguages(),
6796                                               true);
6797 chip            1.162                 instanceRef.setNameSpace
6798 kumpf           1.88                      (request->subscriptionInstance.getPath().getNameSpace());
6799                                       instance.setPath (instanceRef);
6800                                   }
6801                                   catch (CIMException & exception)
6802                                   {
6803                                       cimException = exception;
6804                                   }
6805                                   catch (Exception & exception)
6806                                   {
6807                                       cimException = PEGASUS_CIM_EXCEPTION
6808                                           (CIM_ERR_FAILED, exception.getMessage ());
6809                                   }
6810                       
6811                                   if (cimException.getCode () == CIM_ERR_SUCCESS)
6812                                   {
6813                                       //
6814                                       //  Insert entries into the subscription hash tables
6815                                       //
6816 carolann.graves 1.158                 _subscriptionTable->insertSubscription
6817 dj.gorey        1.135                     (instance,
6818 kumpf           1.104                     acceptedProviders,
6819 dj.gorey        1.135                     operationAggregate->getIndicationSubclasses (),
6820 kumpf           1.88                      request->nameSpace);
6821                       
6822                                   }
6823                               }
6824 carolann.graves 1.172         else  //  CIM_MODIFY_INSTANCE_REQUEST_MESSAGE
6825 kumpf           1.88          {
6826 david.dillard   1.174             PEGASUS_ASSERT (operationAggregate->getOrigType () ==
6827 carolann.graves 1.172                 CIM_MODIFY_INSTANCE_REQUEST_MESSAGE);
6828 kumpf           1.88  
6829                                   //
6830                                   //  Insert entries into the subscription hash tables
6831                                   //
6832 carolann.graves 1.158             _subscriptionTable->insertSubscription
6833 dj.gorey        1.135                 (request->subscriptionInstance,
6834 kumpf           1.104                 acceptedProviders,
6835 dj.gorey        1.135                 operationAggregate->getIndicationSubclasses (),
6836 kumpf           1.88                  request->nameSpace);
6837                               }
6838                           }
6839                       
6840                           //
6841 carolann.graves 1.164     //  For Create Instance or Modify Instance request, send response
6842 kumpf           1.88      //
6843 carolann.graves 1.158     if (operationAggregate->requiresResponse ())
6844 kumpf           1.88      {
6845                               if (operationAggregate->getOrigType () ==
6846                                   CIM_CREATE_INSTANCE_REQUEST_MESSAGE)
6847                               {
6848                                   // l10n
6849                                   // Note: don't need to set Content-language in the response
6850 carolann.graves 1.145             CIMCreateInstanceResponseMessage * response = dynamic_cast
6851 chip            1.162                 <CIMCreateInstanceResponseMessage *>
6852 carolann.graves 1.145                     (operationAggregate->getOrigRequest ()->buildResponse ());
6853                                   response->cimException = cimException;
6854                                   response->instanceName = instanceRef;
6855                                   _enqueueResponse (operationAggregate->getOrigRequest (), response);
6856 kumpf           1.88          }
6857                       
6858 carolann.graves 1.164         else  //  CIM_MODIFY_INSTANCE_REQUEST_MESSAGE
6859 kumpf           1.88          {
6860 carolann.graves 1.164             PEGASUS_ASSERT (operationAggregate->getOrigType () ==
6861                                                   CIM_MODIFY_INSTANCE_REQUEST_MESSAGE);
6862 kumpf           1.88              // l10n
6863                                   // Note: don't need to set Content-language in the response
6864                                   //
6865 chip            1.162             CIMResponseMessage * response =
6866 carolann.graves 1.145                 operationAggregate->getOrigRequest ()->buildResponse ();
6867                                   response->cimException = cimException;
6868                                   _enqueueResponse (operationAggregate->getOrigRequest (), response);
6869 kumpf           1.88          }
6870 kumpf           1.137     }
6871                       
6872 kumpf           1.48      PEG_METHOD_EXIT ();
6873 kumpf           1.1   }
6874                       
6875 kumpf           1.88  void IndicationService::_handleDeleteResponseAggregation (
6876                           IndicationOperationAggregate * operationAggregate)
6877 mday            1.21  {
6878 kumpf           1.48      PEG_METHOD_ENTER (TRC_INDICATION_SERVICE,
6879 kumpf           1.88          "IndicationService::_handleDeleteResponseAggregation");
6880 kumpf           1.37  
6881 kumpf           1.88      CIMException cimException;
6882 kumpf           1.100     Array <ProviderClassList> checkProviders;
6883 mday            1.21  
6884 kumpf           1.37      //
6885 kumpf           1.88      //  Examine provider responses
6886 kumpf           1.37      //
6887 kumpf           1.88      for (Uint32 i = 0; i < operationAggregate->getNumberResponses (); i++)
6888 kumpf           1.37      {
6889 kumpf           1.88          //
6890 kumpf           1.100         //  Find provider from which response was sent and add to list
6891                               //
6892                               CIMResponseMessage * response = operationAggregate->getResponse (i);
6893 dj.gorey        1.135         ProviderClassList provider = operationAggregate->findProvider
6894 kumpf           1.100             (response->messageId);
6895                               checkProviders.append (provider);
6896                       
6897                               //
6898 kumpf           1.88          //  If response is not SUCCESS, provider rejected the delete
6899                               //
6900                               if (response->cimException.getCode () != CIM_ERR_SUCCESS)
6901                               {
6902                                   //
6903                                   //  Log a trace message
6904                                   //
6905 kumpf           1.114             PEG_TRACE_STRING (TRC_INDICATION_SERVICE_INTERNAL, Tracer::LEVEL3,
6906 kumpf           1.88                  "Provider (" + provider.provider.getPath ().toString() +
6907                                       ") rejected delete subscription: " +
6908                                       response->cimException.getMessage ());
6909                               }
6910 kumpf           1.37      }
6911 kumpf           1.88  
6912                           //
6913 carolann.graves 1.164     //  For Delete Instance or Modify Instance request, send response
6914 kumpf           1.114     //
6915 carolann.graves 1.158     if (operationAggregate->requiresResponse ())
6916 kumpf           1.111     {
6917 kumpf           1.114         CIMResponseMessage * response;
6918                               if (operationAggregate->getOrigType () ==
6919                                   CIM_DELETE_INSTANCE_REQUEST_MESSAGE)
6920 kumpf           1.111         {
6921 kumpf           1.114             // l10n
6922                                   // Note: don't need to set Content-language in the response
6923 carolann.graves 1.145             response = operationAggregate->getOrigRequest ()->buildResponse ();
6924                                   response->cimException = cimException;
6925 kumpf           1.111         }
6926 kumpf           1.114 
6927 carolann.graves 1.164         else  //  CIM_MODIFY_INSTANCE_REQUEST_MESSAGE
6928 kumpf           1.111         {
6929 carolann.graves 1.164             PEGASUS_ASSERT (operationAggregate->getOrigType () ==
6930                                                   CIM_MODIFY_INSTANCE_REQUEST_MESSAGE);
6931 kumpf           1.114             // l10n
6932                                   // Note: don't need to set Content-language in the response
6933 carolann.graves 1.145             response = operationAggregate->getOrigRequest ()->buildResponse ();
6934                                   response->cimException = cimException;
6935 kumpf           1.137         }
6936                       
6937 carolann.graves 1.145         _enqueueResponse (operationAggregate->getOrigRequest (), response);
6938 kumpf           1.111     }
6939                       
6940                           PEG_METHOD_EXIT ();
6941                       }
6942                       
6943 kumpf           1.11  CIMInstance IndicationService::_createAlertInstance (
6944 kumpf           1.63      const CIMName & alertClassName,
6945 kumpf           1.46      const Array <CIMInstance> & subscriptions)
6946 kumpf           1.10  {
6947 kumpf           1.48      PEG_METHOD_ENTER (TRC_INDICATION_SERVICE,
6948 kumpf           1.114         "IndicationService::_createAlertInstance");
6949 kumpf           1.10  
6950 kumpf           1.11      CIMInstance indicationInstance (alertClassName);
6951 kumpf           1.10  
6952 dj.gorey        1.135     //
6953 kumpf           1.11      //  Add property values for all required properties of CIM_AlertIndication
6954 dj.gorey        1.135     //
6955                           indicationInstance.addProperty
6956 kumpf           1.11          (CIMProperty (_PROPERTY_ALERTTYPE, CIMValue ((Uint16) _TYPE_OTHER)));
6957 kumpf           1.10      //
6958 kumpf           1.38      //  ATTN: what should Other Alert Type value be??
6959                           //  Currently using Alert class name
6960 kumpf           1.10      //
6961 dj.gorey        1.135     indicationInstance.addProperty
6962 kumpf           1.63          (CIMProperty (_PROPERTY_OTHERALERTTYPE, alertClassName.getString()));
6963 kumpf           1.10  
6964 dj.gorey        1.135     indicationInstance.addProperty
6965 kumpf           1.11          (CIMProperty (_PROPERTY_PERCEIVEDSEVERITY,
6966                                             CIMValue ((Uint16) _SEVERITY_WARNING)));
6967 kumpf           1.10      //
6968 kumpf           1.38      //  ATTN: what should Probable Cause value be??
6969                           //  Currently using Unknown
6970 kumpf           1.10      //
6971 dj.gorey        1.135     indicationInstance.addProperty
6972 kumpf           1.11          (CIMProperty (_PROPERTY_PROBABLECAUSE,
6973 dj.gorey        1.135                       CIMValue ((Uint16) _CAUSE_UNKNOWN)));
6974 kumpf           1.10  
6975 dj.gorey        1.135     //
6976 kumpf           1.11      //  Add properties specific to each alert class
6977                           //  ATTN: update once alert classes have been defined
6978                           //  NB: for _CLASS_NO_PROVIDER_ALERT and _CLASS_PROVIDER_TERMINATED_ALERT,
6979                           //  one of the properties will be a list of affected subscriptions
6980 kumpf           1.13      //  It is for that reason that subscriptions is passed in as a parameter
6981 dj.gorey        1.135     //
6982 kumpf           1.64      if (alertClassName.equal (_CLASS_CIMOM_SHUTDOWN_ALERT))
6983 kumpf           1.11      {
6984                           }
6985 kumpf           1.64      else if (alertClassName.equal (_CLASS_NO_PROVIDER_ALERT))
6986 kumpf           1.10      {
6987                           }
6988 kumpf           1.64      else if (alertClassName.equal (_CLASS_PROVIDER_TERMINATED_ALERT))
6989 kumpf           1.10      {
6990                           }
6991 kumpf           1.11  
6992 kumpf           1.48      PEG_METHOD_EXIT ();
6993 kumpf           1.19      return indicationInstance;
6994 kumpf           1.10  }
6995                       
6996 mday            1.21  
6997 kumpf           1.87  #if 0
6998 dj.gorey        1.135 void IndicationService::_sendAlertsCallBack(AsyncOpNode *op,
6999 kumpf           1.137     MessageQueue *q,
7000                           void *parm)
7001 mday            1.21  {
7002 kumpf           1.48      PEG_METHOD_ENTER (TRC_INDICATION_SERVICE,
7003 kumpf           1.114         "IndicationService::_sendAlertsCallBack");
7004 mday            1.21  
7005 dj.gorey        1.135    IndicationService *service =
7006 mday            1.21        static_cast<IndicationService *>(q);
7007 dj.gorey        1.135    CIMInstance *_handler =
7008 kumpf           1.46        reinterpret_cast<CIMInstance *>(parm);
7009 dj.gorey        1.135 
7010 mday            1.21     AsyncRequest *asyncRequest = static_cast<AsyncRequest *>(op->get_request());
7011                          AsyncReply *asyncReply = static_cast<AsyncReply *>(op->get_response());
7012                          CIMRequestMessage *request = reinterpret_cast<CIMRequestMessage *>
7013                             ((static_cast<AsyncLegacyOperationStart *>(asyncRequest))->get_action());
7014                       
7015 dj.gorey        1.135    CIMHandleIndicationResponseMessage* response =
7016 mday            1.21        reinterpret_cast<CIMHandleIndicationResponseMessage *>
7017                             ((static_cast<AsyncLegacyOperationResult *>
7018 kumpf           1.137       (asyncReply))->get_result());
7019 mday            1.21  
7020 kumpf           1.37     PEGASUS_ASSERT(response != 0);
7021                          if (response->cimException.getCode() == CIM_ERR_SUCCESS)
7022                          {
7023                          }
7024                          else
7025                          {
7026                          }
7027 dj.gorey        1.135 
7028 mday            1.21     //
7029                          //  ATTN: Check for return value indicating invalid queue ID
7030 kumpf           1.37     //  If received, need to find Handler Manager Service queue ID
7031 mday            1.21     //  again
7032                          //
7033                       
7034 dj.gorey        1.135 // << Mon Jul 15 09:59:16 2002 mdd >> handler is allocated as an element in an array,
7035                       // don't delete here.
7036                       //   delete _handler;
7037 mday            1.21     delete request;
7038                          delete response;
7039                          delete asyncRequest;
7040                          delete asyncReply;
7041 mday            1.29     op->release();
7042 mday            1.21     service->return_op(op);
7043 kumpf           1.73  
7044                           PEG_METHOD_EXIT ();
7045 mday            1.21  }
7046                       
7047                       
7048 kumpf           1.11  void IndicationService::_sendAlerts (
7049 kumpf           1.46      const Array <CIMInstance> & subscriptions,
7050 kumpf           1.11      /* const */ CIMInstance & alertInstance)
7051 kumpf           1.10  {
7052 kumpf           1.114     PEG_METHOD_ENTER (TRC_INDICATION_SERVICE, "IndicationService::_sendAlerts");
7053                       
7054 kumpf           1.46      CIMInstance current;
7055 kumpf           1.11  
7056 dj.gorey        1.135     PEG_TRACE_STRING (TRC_INDICATION_SERVICE, Tracer::LEVEL4,
7057 kumpf           1.73          "Sending alert: " + alertInstance.getClassName().getString());
7058                       
7059 kumpf           1.10      //
7060 kumpf           1.11      //  Get list of unique handler instances for all subscriptions in list
7061 kumpf           1.10      //
7062 kumpf           1.83      for (Uint32 i = 0; i < subscriptions.size (); i++)
7063 kumpf           1.11      {
7064 dj.gorey        1.135         PEG_TRACE_STRING (TRC_INDICATION_SERVICE, Tracer::LEVEL4,
7065 kumpf           1.73              "Alert subscription: " + subscriptions [i].getPath().toString());
7066                       
7067 kumpf           1.11          //
7068                               //  Get handler instance
7069                               //
7070 kumpf           1.114         current = _subscriptionRepository->getHandler (subscriptions [i]);
7071 kumpf           1.11  
7072 chip            1.162     // ATTN: For the handlers which do not need subscription instance
7073                           // need to check duplicate alter
7074 kumpf           1.11  
7075 yi.zhou         1.157             //
7076                                   //  Send handle indication request to the handler
7077                                   //
7078                                   CIMHandleIndicationRequestMessage * handler_request =
7079                                       new CIMHandleIndicationRequestMessage (
7080                                           XmlWriter::getNextMessageId (),
7081                                           current.getPath ().getNameSpace (),
7082                                           current,
7083 chip            1.162             subscriptions [i],
7084 yi.zhou         1.157                     alertInstance,
7085                                           QueueIdStack (_handlerService, getQueueId ()));
7086 kumpf           1.10  
7087 yi.zhou         1.157             AsyncOpNode* op = this->get_op();
7088 kumpf           1.11  
7089 yi.zhou         1.157             AsyncLegacyOperationStart *async_req =
7090                                       new AsyncLegacyOperationStart(
7091                                           op,
7092                                           _handlerService,
7093                                           handler_request,
7094                                           _queueId);
7095 kumpf           1.10  
7096 yi.zhou         1.157             SendAsync(op,
7097 kumpf           1.137                   _handlerService,
7098                                         IndicationService::_sendAlertsCallBack,
7099                                         this,
7100 yi.zhou         1.157                   (void *)&current);
7101 kumpf           1.10  
7102                           }
7103 kumpf           1.24  
7104 kumpf           1.48      PEG_METHOD_EXIT ();
7105 kumpf           1.24  }
7106 kumpf           1.87  #endif
7107 kumpf           1.24  
7108 carolann.graves 1.158 void IndicationService::_sendSubscriptionInitComplete ()
7109 mday            1.28  {
7110 chip            1.162     PEG_METHOD_ENTER (TRC_INDICATION_SERVICE,
7111 carolann.graves 1.158         "IndicationService::_sendSubscriptionInitComplete");
7112 mday            1.28  
7113 kumpf           1.88      //
7114 carolann.graves 1.158     //  Create the Subscription Init Complete request
7115 kumpf           1.88      //
7116 carolann.graves 1.158     CIMSubscriptionInitCompleteRequestMessage * request =
7117                               new CIMSubscriptionInitCompleteRequestMessage
7118                                   (XmlWriter::getNextMessageId (),
7119                                   QueueIdStack (_providerManager, getQueueId ()));
7120 kumpf           1.137 
7121                           //
7122 carolann.graves 1.158     //  Send Subscription Initialization Complete request to provider manager
7123 kumpf           1.88      //
7124 carolann.graves 1.158     AsyncOpNode * op = this->get_op ();
7125 kumpf           1.31  
7126 carolann.graves 1.158     AsyncLegacyOperationStart * asyncRequest =
7127 kumpf           1.200         new AsyncLegacyOperationStart(
7128 carolann.graves 1.158             op,
7129 dj.gorey        1.135             _providerManager,
7130 carolann.graves 1.158             request,
7131                                   _queueId);
7132 kumpf           1.100 
7133 konrad.r        1.177     AutoPtr<AsyncReply>  asyncReply (SendWait (asyncRequest));
7134 konrad.r        1.176     op->release();
7135                           delete op;
7136 kumpf           1.100     //
7137 carolann.graves 1.158     //  Note: the response does not contain interesting data
7138 kumpf           1.100     //
7139 kumpf           1.10  
7140 kumpf           1.48      PEG_METHOD_EXIT ();
7141 kumpf           1.10  }
7142                       
7143 kumpf           1.80  Boolean IndicationService::_getCreator (
7144                           const CIMInstance & instance,
7145                           String & creator) const
7146                       {
7147                           PEG_METHOD_ENTER (TRC_INDICATION_SERVICE, "IndicationService::_getCreator");
7148                       
7149 dj.gorey        1.135     Uint32 creatorIndex = instance.findProperty
7150 kumpf           1.80          (PEGASUS_PROPERTYNAME_INDSUB_CREATOR);
7151                           if (creatorIndex != PEG_NOT_FOUND)
7152                           {
7153 dj.gorey        1.135         CIMValue creatorValue = instance.getProperty
7154 kumpf           1.80              (creatorIndex).getValue ();
7155                               if (creatorValue.isNull ())
7156                               {
7157 dj.gorey        1.135             PEG_TRACE_STRING (TRC_INDICATION_SERVICE_INTERNAL,
7158                                       Tracer::LEVEL2,
7159 kumpf           1.80                  "Null Subscription Creator property value");
7160                       
7161                                   //
7162                                   //  This is a corrupted/invalid instance
7163                                   //
7164 carolann.graves 1.170             PEG_METHOD_EXIT();
7165 kumpf           1.80              return false;
7166                               }
7167                               else if ((creatorValue.getType () != CIMTYPE_STRING) ||
7168                                   (creatorValue.isArray ()))
7169                               {
7170                                   String traceString;
7171                                   if (creatorValue.isArray ())
7172                                   {
7173                                       traceString.append ("array of ");
7174                                   }
7175                                   traceString.append (cimTypeToString (creatorValue.getType ()));
7176 dj.gorey        1.135             PEG_TRACE_STRING (TRC_INDICATION_SERVICE_INTERNAL,
7177 kumpf           1.114                Tracer::LEVEL2,
7178 kumpf           1.80                 "Subscription Creator property value of incorrect type: "
7179                                      + traceString);
7180                       
7181                                   //
7182                                   //  This is a corrupted/invalid instance
7183                                   //
7184 carolann.graves 1.170             PEG_METHOD_EXIT();
7185 kumpf           1.80              return false;
7186                               }
7187                               else
7188                               {
7189                                   creatorValue.get (creator);
7190                               }
7191                           }
7192                           else
7193                           {
7194 dj.gorey        1.135         PEG_TRACE_STRING (TRC_INDICATION_SERVICE_INTERNAL,
7195                                   Tracer::LEVEL2,
7196 kumpf           1.80              "Missing Subscription Creator property");
7197                       
7198                               //
7199                               //  This is a corrupted/invalid instance
7200                               //
7201 carolann.graves 1.170         PEG_METHOD_EXIT();
7202 kumpf           1.80          return false;
7203                           }
7204                       
7205                           PEG_METHOD_EXIT ();
7206                           return true;
7207                       }
7208                       
7209 kumpf           1.114 Boolean IndicationService::_validateState (
7210                           const Uint16 state) const
7211 kumpf           1.80  {
7212 kumpf           1.114     //
7213                           //  Validate the value
7214                           //
7215                           if (!Contains (_validStates, state))
7216 kumpf           1.80      {
7217                               //
7218                               //  This is a corrupted/invalid instance
7219                               //
7220                               return false;
7221                           }
7222                       
7223                           return true;
7224 kumpf           1.99  }
7225                       
7226                       void IndicationService::_updatePropertyList
7227                           (CIMName & className,
7228                            CIMPropertyList & propertyList,
7229                            Boolean & setTimeRemaining,
7230                            Boolean & startTimeAdded,
7231                            Boolean & durationAdded)
7232                       {
7233                           PEG_METHOD_ENTER ( TRC_INDICATION_SERVICE,
7234                               "IndicationService::_updatePropertyList");
7235                       
7236                           //
7237                           //  A null propertyList means all properties
7238                           //  If the class is Subscription, that includes the Time Remaining property
7239                           //
7240 yi.zhou         1.157     if (className.equal (PEGASUS_CLASSNAME_INDSUBSCRIPTION) ||
7241 chip            1.162     className.equal (PEGASUS_CLASSNAME_FORMATTEDINDSUBSCRIPTION))
7242 kumpf           1.99      {
7243                               setTimeRemaining = true;
7244                           }
7245                           else
7246                           {
7247                               setTimeRemaining = false;
7248                           }
7249                           startTimeAdded = false;
7250                           durationAdded = false;
7251                           if (!propertyList.isNull ())
7252                           {
7253                               setTimeRemaining = false;
7254                               Array <CIMName> properties = propertyList.getPropertyNameArray ();
7255                       
7256                               //
7257                               //  Add Creator to property list
7258                               //
7259 dj.gorey        1.135         if (!ContainsCIMName (properties,
7260 kumpf           1.99              PEGASUS_PROPERTYNAME_INDSUB_CREATOR))
7261                               {
7262                                   properties.append (PEGASUS_PROPERTYNAME_INDSUB_CREATOR);
7263                               }
7264                       
7265                               //
7266                               //  If a Subscription and Time Remaining is requested,
7267                               //  Ensure Subscription Duration and Start Time are in property list
7268                               //
7269 yi.zhou         1.157         if (className.equal (PEGASUS_CLASSNAME_INDSUBSCRIPTION) ||
7270 chip            1.162         className.equal (PEGASUS_CLASSNAME_FORMATTEDINDSUBSCRIPTION))
7271 kumpf           1.99          {
7272                                   if (ContainsCIMName (properties, _PROPERTY_TIMEREMAINING))
7273                                   {
7274                                       setTimeRemaining = true;
7275                                       if (!ContainsCIMName (properties, _PROPERTY_STARTTIME))
7276                                       {
7277                                           properties.append (_PROPERTY_STARTTIME);
7278                                           startTimeAdded = true;
7279                                       }
7280                                       if (!ContainsCIMName (properties, _PROPERTY_DURATION))
7281                                       {
7282                                           properties.append (_PROPERTY_DURATION);
7283                                           durationAdded = true;
7284                                       }
7285                                   }
7286                               }
7287                               propertyList.clear ();
7288                               propertyList.set (properties);
7289                           }
7290                       
7291                           PEG_METHOD_EXIT ();
7292 kumpf           1.80  }
7293                       
7294 kumpf           1.98  String IndicationService::_getSubscriptionLogString
7295                           (CIMInstance & subscription)
7296                       {
7297                           //
7298 carolann.graves 1.186     //  Get Subscription Filter namespace and Name, and Handler namespace and
7299                           //  Name
7300 kumpf           1.98      //
7301                           String logString;
7302                           CIMValue filterValue;
7303                           CIMObjectPath filterPath;
7304 carolann.graves 1.186     CIMNamespaceName filterNS;
7305 kumpf           1.98      Array <CIMKeyBinding> filterKeyBindings;
7306                           CIMValue handlerValue;
7307                           CIMObjectPath handlerPath;
7308 carolann.graves 1.186     CIMNamespaceName handlerNS;
7309 kumpf           1.98      Array <CIMKeyBinding> handlerKeyBindings;
7310                           filterValue = subscription.getProperty (subscription.findProperty
7311                               (_PROPERTY_FILTER)).getValue ();
7312                           filterValue.get (filterPath);
7313 carolann.graves 1.186 
7314                           //
7315                           //  Get Filter namespace - if not set in Filter reference property
7316                           //  value, namespace is the namespace of the subscription
7317                           //
7318                           filterNS = filterPath.getNameSpace ();
7319                           if (filterNS.isNull ())
7320                           {
7321                               filterNS = subscription.getPath ().getNameSpace ();
7322                           }
7323                           logString.append (filterNS.getString ());
7324                           logString.append (" ");
7325 kumpf           1.98      filterKeyBindings = filterPath.getKeyBindings ();
7326                           for (Uint32 i = 0; i < filterKeyBindings.size (); i++)
7327                           {
7328                               if (filterKeyBindings [i].getName ().equal (_PROPERTY_NAME))
7329                               {
7330                                   logString.append (filterKeyBindings [i].getValue ());
7331                                   logString.append (", ");
7332                                   break;
7333                               }
7334                           }
7335 dj.gorey        1.135     handlerValue = subscription.getProperty
7336 kumpf           1.98          (subscription.findProperty
7337                               (_PROPERTY_HANDLER)).getValue ();
7338                           handlerValue.get (handlerPath);
7339 carolann.graves 1.186 
7340                           //
7341                           //  Get Handler namespace - if not set in Handler reference property
7342                           //  value, namespace is the namespace of the subscription
7343                           //
7344                           handlerNS = handlerPath.getNameSpace ();
7345                           if (handlerNS.isNull ())
7346                           {
7347                               handlerNS = subscription.getPath ().getNameSpace ();
7348                           }
7349                           logString.append (handlerNS.getString ());
7350                           logString.append (" ");
7351 kumpf           1.98      handlerKeyBindings = handlerPath.getKeyBindings ();
7352                           for (Uint32 j = 0; j < handlerKeyBindings.size (); j++)
7353                           {
7354                               if (handlerKeyBindings [j].getName ().equal (_PROPERTY_NAME))
7355                               {
7356                                   logString.append (handlerKeyBindings [j].getValue ());
7357                                   break;
7358                               }
7359                           }
7360                       
7361                           return logString;
7362                       }
7363                       
7364 kumpf           1.114 String IndicationService::getProviderLogString
7365 kumpf           1.98      (CIMInstance & provider)
7366                       {
7367                           String logString;
7368 dj.gorey        1.135 
7369                           logString = provider.getProperty (provider.findProperty
7370 kumpf           1.98          (_PROPERTY_NAME)).getValue ().toString ();
7371                       
7372                           return logString;
7373 kumpf           1.105 }
7374                       
7375 yi.zhou         1.157 CIMClass IndicationService::_getIndicationClass (
7376                           const CIMInstance & subscriptionInstance)
7377                       {
7378                           PEG_METHOD_ENTER (TRC_INDICATION_SERVICE,
7379 chip            1.162     "IndicationService::_getIndicationClass");
7380 yi.zhou         1.157 
7381                           CIMNamespaceName sourceNameSpace;
7382                           String query;
7383                           String queryLanguage;
7384                           CIMName indicationClassName;
7385                           CIMClass indicationClass;
7386                       
7387                           //  Get filter properties
7388 carolann.graves 1.186     _subscriptionRepository->getFilterProperties (subscriptionInstance, query,
7389                               sourceNameSpace, queryLanguage);
7390 yi.zhou         1.157 
7391                           //  Build the query expression from the filter query
7392                           QueryExpression queryExpression = _getQueryExpression(query,
7393 chip            1.162                               queryLanguage,
7394                                                     sourceNameSpace);
7395 yi.zhou         1.157 
7396                           //  Get indication class name from filter query
7397                           indicationClassName = _getIndicationClassName(
7398 chip            1.162     queryExpression, sourceNameSpace);
7399 yi.zhou         1.157 
7400                           //
7401                           //  Get the indication class object from the repository
7402                           //  Specify localOnly=false because superclass properties are needed
7403                           //  Specify includeQualifiers=false because qualifiers are not needed
7404                           //
7405                           indicationClass = _subscriptionRepository->getClass
7406                               (sourceNameSpace, indicationClassName, false, false, false,
7407                                CIMPropertyList ());
7408                       
7409 carolann.graves 1.170     PEG_METHOD_EXIT();
7410 yi.zhou         1.157     return indicationClass;
7411                       }
7412 dj.gorey        1.135 
7413 yi.zhou         1.157 PEGASUS_NAMESPACE_END

No CVS admin address has been configured
Powered by
ViewCVS 0.9.2