📄 indicationservice.cpp
字号:
{ cimException = PEGASUS_CIM_EXCEPTION(CIM_ERR_FAILED, exception.getMessage()); }// l10n // Note: not setting Content-Language in the response CIMEnumerateInstanceNamesResponseMessage * response = dynamic_cast <CIMEnumerateInstanceNamesResponseMessage *> (request->buildResponse ()); response->cimException = cimException; response->instanceNames = enumInstanceNames; _enqueueResponse (request, response); PEG_METHOD_EXIT ();}void IndicationService::_handleModifyInstanceRequest (const Message* message){ PEG_METHOD_ENTER (TRC_INDICATION_SERVICE, "IndicationService::_handleModifyInstanceRequest"); CIMModifyInstanceRequestMessage* request = (CIMModifyInstanceRequestMessage*) message; CIMException cimException; Boolean responseSent = false; try { String userName = ((IdentityContainer)request->operationContext.get (IdentityContainer :: NAME)).getUserName(); _checkNonprivilegedAuthorization(userName); // // Get the instance name // CIMObjectPath instanceReference = request->modifiedInstance.getPath (); // // Get instance from repository // CIMInstance instance; instance = _subscriptionRepository->getInstance (request->nameSpace, instanceReference); CIMInstance modifiedInstance = request->modifiedInstance; if (_canModify (request, instanceReference, instance, modifiedInstance)) { // // Set path in instance // instanceReference.setNameSpace (request->nameSpace); instance.setPath (instanceReference); // // Check for expired subscription // try { if (_isExpired (instance)) { // // Delete the subscription instance // _deleteExpiredSubscription (instanceReference); PEG_METHOD_EXIT (); // l10n // String exceptionStr = _MSG_EXPIRED; // throw PEGASUS_CIM_EXCEPTION (CIM_ERR_FAILED, exceptionStr); throw PEGASUS_CIM_EXCEPTION_L (CIM_ERR_FAILED, MessageLoaderParms(_MSG_EXPIRED_KEY, _MSG_EXPIRED)); } } catch (DateTimeOutOfRangeException &) { // // This instance from the repository is invalid // PEG_METHOD_EXIT(); throw; } // // _canModify, above, already checked that propertyList is not // null, and that numProperties is 0 or 1 // CIMPropertyList propertyList = request->propertyList; if (request->propertyList.size () > 0) { // // Get current state from instance // Uint16 currentState; Boolean valid = true; if (_subscriptionRepository->getState (instance, currentState)) { valid = _validateState (currentState); } if (!valid) { // // This instance from the repository is corrupted // L10N TODO DONE -- new throw of exception // PEG_METHOD_EXIT (); //throw PEGASUS_CIM_EXCEPTION (CIM_ERR_FAILED, //_MSG_INVALID_INSTANCES); MessageLoaderParms parms (_MSG_INVALID_INSTANCES_KEY, _MSG_INVALID_INSTANCES); throw PEGASUS_CIM_EXCEPTION_L (CIM_ERR_FAILED, parms); } // // Get new state // // NOTE: _canModify has already validated the // SubscriptionState property in the instance; if missing, it // was added with the default value; if null, it was set to // the default value; if invalid, an exception was thrown // Uint16 newState; modifiedInstance.getProperty (modifiedInstance.findProperty (PEGASUS_PROPERTYNAME_SUBSCRIPTION_STATE)).getValue ().get (newState); // // If Subscription State has changed, // Set Time of Last State Change to current date time // CIMDateTime currentDateTime = CIMDateTime::getCurrentDateTime (); if (newState != currentState) { if (modifiedInstance.findProperty (_PROPERTY_LASTCHANGE) != PEG_NOT_FOUND) { CIMProperty lastChange = modifiedInstance.getProperty (modifiedInstance.findProperty (_PROPERTY_LASTCHANGE)); lastChange.setValue (CIMValue (currentDateTime)); } else { modifiedInstance.addProperty (CIMProperty (_PROPERTY_LASTCHANGE, CIMValue (currentDateTime))); } Array <CIMName> properties = propertyList.getPropertyNameArray (); properties.append (_PROPERTY_LASTCHANGE); propertyList.set (properties); } // // If Subscription is to be enabled, and this is the first // time, set Subscription Start Time // if ((newState == STATE_ENABLED) || (newState == STATE_ENABLEDDEGRADED)) { // // If Subscription Start Time is null, set value // to the current date time // CIMDateTime startTime; CIMProperty startTimeProperty = instance.getProperty (instance.findProperty (_PROPERTY_STARTTIME)); CIMValue startTimeValue = instance.getProperty (instance.findProperty (_PROPERTY_STARTTIME)).getValue (); Boolean setStart = false; if (startTimeValue.isNull ()) { setStart = true; } else { startTimeValue.get (startTime); if (startTime.isInterval()) { if (startTime.equal (CIMDateTime (_ZERO_INTERVAL_STRING))) { setStart = true; } } } if (setStart) { if (modifiedInstance.findProperty (_PROPERTY_STARTTIME) != PEG_NOT_FOUND) { CIMProperty startTime = modifiedInstance.getProperty (modifiedInstance.findProperty (_PROPERTY_STARTTIME)); startTime.setValue (CIMValue (currentDateTime)); } else { modifiedInstance.addProperty (CIMProperty (_PROPERTY_STARTTIME, CIMValue (currentDateTime))); } Array <CIMName> properties = propertyList.getPropertyNameArray (); properties.append (_PROPERTY_STARTTIME); propertyList.set (properties); } }// l10n // Add the language properties to the modified instance. // Note: These came from the Accept-Language and Content-Language // headers in the HTTP messages, and may be empty. AcceptLanguageList acceptLangs = ((AcceptLanguageListContainer)request->operationContext.get (AcceptLanguageListContainer::NAME)).getLanguages(); modifiedInstance.addProperty (CIMProperty (PEGASUS_PROPERTYNAME_INDSUB_ACCEPTLANGS, LanguageParser::buildAcceptLanguageHeader(acceptLangs))); ContentLanguageList contentLangs = ((ContentLanguageListContainer)request->operationContext.get (ContentLanguageListContainer::NAME)).getLanguages(); modifiedInstance.addProperty (CIMProperty (PEGASUS_PROPERTYNAME_INDSUB_CONTENTLANGS, LanguageParser::buildContentLanguageHeader(contentLangs))); Array <CIMName> properties = propertyList.getPropertyNameArray (); properties.append (PEGASUS_PROPERTYNAME_INDSUB_ACCEPTLANGS); properties.append (PEGASUS_PROPERTYNAME_INDSUB_CONTENTLANGS); propertyList.set (properties);// l10n -end // // If subscription is to be enabled, determine if there are // any indication providers that can serve the subscription // Array <ProviderClassList> indicationProviders; CIMPropertyList requiredProperties; CIMNamespaceName sourceNameSpace; String condition; String query; String queryLanguage; Array <CIMName> indicationSubclasses; if (((newState == STATE_ENABLED) || (newState == STATE_ENABLEDDEGRADED)) && ((currentState != STATE_ENABLED) && (currentState != STATE_ENABLEDDEGRADED))) { // // Subscription was previously not enabled but is now to // be enabled // _getCreateParams (instance, indicationSubclasses, indicationProviders, requiredProperties, sourceNameSpace, condition, query, queryLanguage); if (indicationProviders.size () == 0) { // // There are no providers that can support this // subscription // instance.setPath (instanceReference); _subscriptionRepository->reconcileFatalError (instance); PEG_METHOD_EXIT (); // l10n // throw PEGASUS_CIM_EXCEPTION (CIM_ERR_NOT_SUPPORTED, // _MSG_NO_PROVIDERS); throw PEGASUS_CIM_EXCEPTION_L (CIM_ERR_NOT_SUPPORTED, MessageLoaderParms (_MSG_NO_PROVIDERS_KEY, _MSG_NO_PROVIDERS)); } } // // Modify the instance in the repository // try { modifiedInstance.setPath (instanceReference); _subscriptionRepository->modifyInstance (request->nameSpace, modifiedInstance, request->includeQualifiers, propertyList); Logger::put (Logger::STANDARD_LOG, System::CIMSERVER, Logger::TRACE, "IndicationService::_handleModifyInstanceRequest - Name Space: $0 Instance name: $1", request->nameSpace.getString (), modifiedInstance.getClassName ().getString ()); } catch (CIMException & exception) { cimException = exception; } catch (Exception & exception) { cimException = PEGASUS_CIM_EXCEPTION(CIM_ERR_FAILED, exception.getMessage()); } if (cimException.getCode() != CIM_ERR_SUCCESS) { CIMResponseMessage * response = request->buildResponse (); response->cimException = cimException; _enqueueResponse (request, response); PEG_METHOD_EXIT (); return; } // // If subscription is newly enabled, send Create requests // and enable providers // if (((newState == STATE_ENABLED) || (newState == STATE_ENABLEDDEGRADED)) && ((currentState != STATE_ENABLED) && (currentState != STATE_ENABLEDDEGRADED))) { instanceReference.setNameSpace (request->nameSpace); instance.setPath (instanceReference);// l10n _sendAsyncCreateRequests (indicationProviders, sourceNameSpace, requiredProperties, condition, query, queryLanguage, instance, acceptLangs, contentLangs, request, indicationSubclasses, userName, request->authType); // // Response is sent from _handleCreateResponseAggregation // responseSent = true; } else if ((newState == STATE_DISABLED) && ((currentState == STATE_ENABLED) || (currentState == STATE_ENABLEDDEGRADED))) { // // Subscriptio
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -