📄 indicationservice.cpp
字号:
false); } } } catch (CIMException & exception) { cimException = exception; } catch (Exception & exception) { cimException = PEGASUS_CIM_EXCEPTION(CIM_ERR_FAILED, exception.getMessage()); } // // Send response, if not sent from callback // (for example, if there are no indication providers that can support a // subscription) // if (!responseSent) {// l10n - no Content-Language in response CIMCreateInstanceResponseMessage * response = dynamic_cast <CIMCreateInstanceResponseMessage *> (request->buildResponse ()); response->cimException = cimException; response->instanceName = instanceRef; _enqueueResponse (request, response); } PEG_METHOD_EXIT ();}void IndicationService::_handleGetInstanceRequest (const Message* message){ PEG_METHOD_ENTER (TRC_INDICATION_SERVICE, "IndicationService::_handleGetInstanceRequest"); CIMGetInstanceRequestMessage* request = (CIMGetInstanceRequestMessage*) message; CIMException cimException; CIMInstance instance; String contentLangsString; try { String userName = ((IdentityContainer)request->operationContext.get (IdentityContainer :: NAME)).getUserName(); _checkNonprivilegedAuthorization(userName ); // // Add Creator to property list, if not null // Also, if a Subscription and Time Remaining is requested, // Ensure Subscription Duration and Start Time are in property list // Boolean setTimeRemaining; Boolean startTimeAdded; Boolean durationAdded; CIMPropertyList propertyList = request->propertyList; CIMName className = request->instanceName.getClassName (); _updatePropertyList (className, propertyList, setTimeRemaining, startTimeAdded, durationAdded); // // Get instance from repository // instance = _subscriptionRepository->getInstance (request->nameSpace, request->instanceName, request->localOnly, request->includeQualifiers, request->includeClassOrigin, propertyList); // // Remove Creator property from instance before returning // String creator; if (!_getCreator (instance, creator)) { // // 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); } instance.removeProperty (instance.findProperty (PEGASUS_PROPERTYNAME_INDSUB_CREATOR));// l10n start // // Remove the language properties from instance before returning // Uint32 propIndex = instance.findProperty (PEGASUS_PROPERTYNAME_INDSUB_ACCEPTLANGS); if (propIndex != PEG_NOT_FOUND) { instance.removeProperty (propIndex); } propIndex = instance.findProperty (PEGASUS_PROPERTYNAME_INDSUB_CONTENTLANGS); if (propIndex != PEG_NOT_FOUND) { // Get the content languages to be sent in the Content-Language header instance.getProperty(propIndex).getValue().get(contentLangsString); instance.removeProperty (propIndex); }// l10n end // // If a subscription with a duration, calculate subscription time // remaining, and add property to the instance // if (setTimeRemaining) { try { _setTimeRemaining (instance); } catch (DateTimeOutOfRangeException &) { // // This instance from the repository is invalid // PEG_METHOD_EXIT(); throw; } if (startTimeAdded) { instance.removeProperty (instance.findProperty (_PROPERTY_STARTTIME)); } if (durationAdded) { instance.removeProperty (instance.findProperty (_PROPERTY_DURATION)); } } } catch (CIMException& exception) { cimException = exception; } catch (Exception& exception) { cimException = PEGASUS_CIM_EXCEPTION(CIM_ERR_FAILED, exception.getMessage()); } CIMGetInstanceResponseMessage * response = dynamic_cast <CIMGetInstanceResponseMessage *> (request->buildResponse ()); response->cimException = cimException; if (contentLangsString.size()) { // Note: setting Content-Language in the response to the // contentLanguage in the repository. response->operationContext.set(ContentLanguageListContainer( LanguageParser::parseContentLanguageHeader(contentLangsString))); } response->cimInstance = instance; _enqueueResponse (request, response); PEG_METHOD_EXIT ();}void IndicationService::_handleEnumerateInstancesRequest(const Message* message){ PEG_METHOD_ENTER (TRC_INDICATION_SERVICE, "IndicationService::_handleEnumerateInstancesRequest"); CIMEnumerateInstancesRequestMessage* request = (CIMEnumerateInstancesRequestMessage*) message; Array <CIMInstance> enumInstances; Array <CIMInstance> returnedInstances; CIMException cimException; CIMInstance cimInstance; String aggregatedLangs = String::EMPTY; // l10n try { String userName = ((IdentityContainer)request->operationContext.get (IdentityContainer :: NAME)).getUserName(); _checkNonprivilegedAuthorization(userName); // // Add Creator to property list, if not null // Also, if a Subscription and Time Remaining is requested, // Ensure Subscription Duration and Start Time are in property list // Boolean setTimeRemaining; Boolean startTimeAdded; Boolean durationAdded; CIMPropertyList propertyList = request->propertyList; _updatePropertyList (request->className, propertyList, setTimeRemaining, startTimeAdded, durationAdded); enumInstances = _subscriptionRepository->enumerateInstancesForClass( request->nameSpace, request->className, request->localOnly, request->includeQualifiers, request->includeClassOrigin, propertyList);// l10n // Vars used to aggregate the content languages of the subscription // instances. Boolean langMismatch = false; Uint32 propIndex; // // Remove Creator and language properties from instances before // returning // for (Uint32 i = 0; i < enumInstances.size (); i++) { String creator; if (!_getCreator (enumInstances [i], creator)) { // // This instance from the repository is corrupted // Skip it // continue; } enumInstances [i].removeProperty (enumInstances [i].findProperty (PEGASUS_PROPERTYNAME_INDSUB_CREATOR));// l10n start propIndex = enumInstances [i].findProperty (PEGASUS_PROPERTYNAME_INDSUB_CONTENTLANGS); String contentLangs = String::EMPTY; if (propIndex != PEG_NOT_FOUND) { enumInstances [i].getProperty(propIndex).getValue().get (contentLangs); enumInstances [i].removeProperty(propIndex); } propIndex = enumInstances [i].findProperty (PEGASUS_PROPERTYNAME_INDSUB_ACCEPTLANGS); if (propIndex != PEG_NOT_FOUND) { enumInstances [i].removeProperty(propIndex); } // Determine what to set into the Content-Language header back to the client if (!langMismatch) { if (contentLangs == String::EMPTY) { langMismatch = true; aggregatedLangs = String::EMPTY; } else { if (aggregatedLangs == String::EMPTY) { aggregatedLangs = contentLangs; } else if (aggregatedLangs != contentLangs) { langMismatch = true; aggregatedLangs = String::EMPTY; } } }// l10n end // // If a subscription with a duration, calculate subscription time // remaining, and add property to the instance // if (setTimeRemaining) { try { _setTimeRemaining (enumInstances [i]); } catch (DateTimeOutOfRangeException &) { // // This instance from the repository is invalid // Skip it // continue; } if (startTimeAdded) { enumInstances [i].removeProperty (enumInstances [i].findProperty (_PROPERTY_STARTTIME)); } if (durationAdded) { enumInstances [i].removeProperty (enumInstances [i].findProperty (_PROPERTY_DURATION)); } } returnedInstances.append (enumInstances [i]); } } catch (CIMException& exception) { cimException = exception; } catch (Exception& exception) { cimException = PEGASUS_CIM_EXCEPTION(CIM_ERR_FAILED, exception.getMessage()); } CIMEnumerateInstancesResponseMessage * response = dynamic_cast <CIMEnumerateInstancesResponseMessage *> (request->buildResponse ()); response->cimException = cimException; if (aggregatedLangs.size()) { // Note: setting Content-Language in the response to the aggregated // contentLanguage from the instances in the repository. response->operationContext.set(ContentLanguageListContainer( LanguageParser::parseContentLanguageHeader(aggregatedLangs))); } response->cimNamedInstances = returnedInstances; _enqueueResponse (request, response); PEG_METHOD_EXIT ();}void IndicationService::_handleEnumerateInstanceNamesRequest (const Message* message){ PEG_METHOD_ENTER (TRC_INDICATION_SERVICE, "IndicationService::_handleEnumerateInstanceNamesRequest"); CIMEnumerateInstanceNamesRequestMessage* request = (CIMEnumerateInstanceNamesRequestMessage*) message; Array<CIMObjectPath> enumInstanceNames; CIMException cimException; try { String userName = ((IdentityContainer)request->operationContext.get (IdentityContainer :: NAME)).getUserName(); _checkNonprivilegedAuthorization(userName); enumInstanceNames = _subscriptionRepository->enumerateInstanceNamesForClass (request->nameSpace, request->className); } catch (CIMException& exception) { cimException = exception; } catch (Exception& exception)
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -