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

No CVS admin address has been configured
Powered by
ViewCVS 0.9.2