📄 providerregistrationprovider.cpp
字号:
throw PEGASUS_CIM_EXCEPTION_L(CIM_ERR_FAILED, parms); } if (instanceObject.findProperty(_PROPERTY_CAPABILITYID) == PEG_NOT_FOUND) {//L10N_ TODO DONE //throw PEGASUS_CIM_EXCEPTION(CIM_ERR_FAILED, //"Missing CapabilityID which is required property in PG_ConsumerCapabilities class."); MessageLoaderParms parms( "ControlProviders.ProviderRegistrationProvider.ProviderRegistrationProvider.MISSING_CAPABILITY_ID_WHICH_IS_REQUIRED", "Missing CapabilityID which is required property in PG_ConsumerCapabilities class."); throw PEGASUS_CIM_EXCEPTION_L(CIM_ERR_FAILED, parms); } if (instanceObject.findProperty(_PROPERTY_PROVIDERTYPE) == PEG_NOT_FOUND) {//L10N_ TODO DONE //throw PEGASUS_CIM_EXCEPTION(CIM_ERR_FAILED, //"Missing ProviderType which is required property in PG_ConsumerCapabilities class."); MessageLoaderParms parms( "ControlProviders.ProviderRegistrationProvider.ProviderRegistrationProvider.MISSING_PROVIDER_TYPE_WHICH_IS_REQUIRED", "Missing ProviderType which is required property in PG_ConsumerCapabilities class."); throw PEGASUS_CIM_EXCEPTION_L(CIM_ERR_FAILED, parms); } if (instanceObject.findProperty(_PROPERTY_INDICATIONDESTINATIONS) == PEG_NOT_FOUND) {//L10N_ TODO DONE //throw PEGASUS_CIM_EXCEPTION(CIM_ERR_FAILED, //"Missing Destinations which is required property in PG_ConsumerCapabilities class."); MessageLoaderParms parms( "ControlProviders.ProviderRegistrationProvider.ProviderRegistrationProvider.MISSING_DESTINATIONS_TYPE_WHICH_IS_REQUIRED", "Missing Destinations which is required property in PG_ConsumerCapabilities class."); throw PEGASUS_CIM_EXCEPTION_L(CIM_ERR_FAILED, parms); } } else // PEGASUS_CLASSNAME_PROVIDER { // // Name and ProviderModuleName properties must be set // if (instanceObject.findProperty(_PROPERTY_PROVIDER_NAME) == PEG_NOT_FOUND) { //l10n 485 //throw PEGASUS_CIM_EXCEPTION(CIM_ERR_FAILED, //"Missing Name which is required property in PG_Provider class."); throw PEGASUS_CIM_EXCEPTION_L(CIM_ERR_FAILED,MessageLoaderParms( "ControlProviders.ProviderRegistrationProvider.ProviderRegistrationProvider.MISSING_REQUIRED_PROPERTY", "Missing Name which is required property in PG_Provider class.")); } if (instanceObject.findProperty(_PROPERTY_PROVIDERMODULENAME) == PEG_NOT_FOUND) { //l10n 485 //throw PEGASUS_CIM_EXCEPTION(CIM_ERR_FAILED, //"Missing ProviderModuleName which is required property in PG_Provider class."); throw PEGASUS_CIM_EXCEPTION_L(CIM_ERR_FAILED,MessageLoaderParms( "ControlProviders.ProviderRegistrationProvider.ProviderRegistrationProvider.MISSING_PROVIDERMODULENAME_IN_PG_PROVIDER", "Missing ProviderModuleName which is required property in PG_Provider class.")); } } // begin processing the request handler.processing(); try { returnReference = _providerRegistrationManager->createInstance(instanceReference, instance); } catch(const CIMException&) { throw; } handler.deliver(returnReference); // complete processing request handler.complete();}// Unregister a providervoid ProviderRegistrationProvider::deleteInstance( const OperationContext & context, const CIMObjectPath & instanceReference, ResponseHandler & handler){ // get userName and only privileged user can execute this operation String userName; try { IdentityContainer container = context.get(IdentityContainer::NAME); userName = container.getUserName(); } catch (...) { userName = String::EMPTY; } if ((userName != String::EMPTY) && !System::isPrivilegedUser(userName)) { //l10n //throw PEGASUS_CIM_EXCEPTION(CIM_ERR_ACCESS_DENIED, //"You must have superuser privilege to unregister providers."); throw PEGASUS_CIM_EXCEPTION_L(CIM_ERR_ACCESS_DENIED,MessageLoaderParms( "ControlProviders.ProviderRegistrationProvider.ProviderRegistrationProvider.SUPERUSER_PRIVILEGE_REQUIRED_UNREGISTER_PROVIDERS", "You must have superuser privilege to unregister providers.")); } if(!instanceReference.getNameSpace().equal (PEGASUS_NAMESPACENAME_INTEROP)) { throw PEGASUS_CIM_EXCEPTION(CIM_ERR_NOT_SUPPORTED, instanceReference.getNameSpace().getString()); }// l10n // Get the client's list of preferred languages for the response AcceptLanguageList al; try { AcceptLanguageListContainer al_container = (AcceptLanguageListContainer)context.get(AcceptLanguageListContainer::NAME); al = al_container.getLanguages(); } catch (...) { ; // Leave AcceptLanguageList empty } CIMName className = instanceReference.getClassName(); // ensure the class existing in the specified namespace if(!className.equal (PEGASUS_CLASSNAME_PROVIDER) && !className.equal (PEGASUS_CLASSNAME_PROVIDERCAPABILITIES) && !className.equal (PEGASUS_CLASSNAME_CONSUMERCAPABILITIES) && !className.equal (PEGASUS_CLASSNAME_PROVIDERMODULE)) { throw PEGASUS_CIM_EXCEPTION(CIM_ERR_NOT_SUPPORTED, className.getString()); } // begin processing the request handler.processing(); String moduleName; Boolean moduleFound = false; Array<CIMKeyBinding> keys = instanceReference.getKeyBindings(); // // disable provider before delete provider // registration if the class is PG_Provider // if (className.equal (PEGASUS_CLASSNAME_PROVIDER)) { // get module name from reference for(Uint32 i=0; i<keys.size() ; i++) { if(keys[i].getName().equal (_PROPERTY_PROVIDERMODULENAME)) { moduleName = keys[i].getValue(); moduleFound = true; } } // if _PROPERTY_PROVIDERMODULENAME key not found if( !moduleFound) { //l10n 485 //throw PEGASUS_CIM_EXCEPTION(CIM_ERR_NOT_SUPPORTED, //"key ProviderModuleName was not found"); throw PEGASUS_CIM_EXCEPTION_L(CIM_ERR_NOT_SUPPORTED,MessageLoaderParms( "ControlProviders.ProviderRegistrationProvider.ProviderRegistrationProvider.PROVIDERMODULENAME_KEY_NOT_FOUND", "key ProviderModuleName was not found")); } // // disable the provider // try { Sint16 ret_value = _disableModule(instanceReference, moduleName, true, al); // // if the provider disable failed //// l10n if (ret_value == -1) { //l10n //throw PEGASUS_CIM_EXCEPTION(CIM_ERR_FAILED, //"disable the provider failed."); throw PEGASUS_CIM_EXCEPTION_L(CIM_ERR_FAILED,MessageLoaderParms( "ControlProviders.ProviderRegistrationProvider.ProviderRegistrationProvider.DISABLE_PROVIDER_FAILED", "disable the provider failed.")); } // // The provider disable failed since there are pending requests // if (ret_value == -2) {//L10N TODO // throw PEGASUS_CIM_EXCEPTION(CIM_ERR_FAILED, //"disable the provider failed: Provider is busy."); throw PEGASUS_CIM_EXCEPTION_L(CIM_ERR_FAILED,MessageLoaderParms( "ControlProviders.ProviderRegistrationProvider.ProviderRegistrationProvider.DISABLE_PROVIDER_FAILED_PROVIDER_BUSY", "disable the provider failed: Provider is busy.")); } } catch(CIMException&) { throw; } } // // disable provider module before remove provider registration // if the class is PG_ProviderModule // if (className.equal (PEGASUS_CLASSNAME_PROVIDERMODULE)) { // get module name from reference for(Uint32 i=0; i<keys.size() ; i++) { if(keys[i].getName().equal (_PROPERTY_PROVIDERMODULE_NAME)) { moduleName = keys[i].getValue(); moduleFound = true; } } // if _PROPERTY_PROVIDERMODULE_NAME key not found if( !moduleFound) { //l10n 485 //throw PEGASUS_CIM_EXCEPTION(CIM_ERR_NOT_SUPPORTED, //"key Name was not found"); throw PEGASUS_CIM_EXCEPTION_L(CIM_ERR_NOT_SUPPORTED,MessageLoaderParms( "ControlProviders.ProviderRegistrationProvider.ProviderRegistrationProvider.NAME_KEY_NOT_FOUND", "key Name was not found")); } // // disable the provider module // try { Sint16 ret_value = _disableModule(instanceReference, moduleName, false, al); // // if the provider module disable failed //// l10n if (ret_value == -1) { //l10n //throw PEGASUS_CIM_EXCEPTION(CIM_ERR_FAILED, //"disable the provider module failed."); throw PEGASUS_CIM_EXCEPTION_L(CIM_ERR_FAILED,MessageLoaderParms( "ControlProviders.ProviderRegistrationProvider.ProviderRegistrationProvider.DISABLE_PROVIDER_MODULE_FAILED", "disable the provider module failed.")); } // // The provider module disable failed since there are pending requests // if (ret_value == -2) {//L10N TODO //throw PEGASUS_CIM_EXCEPTION(CIM_ERR_FAILED, // "disable the provider module failed: Provider is busy."); throw PEGASUS_CIM_EXCEPTION_L(CIM_ERR_FAILED,MessageLoaderParms( "ControlProviders.ProviderRegistrationProvider.ProviderRegistrationProvider.DISABLE_PROVIDER_MODULE_FAILED_PROVIDER_BUSY", "disable the provider module failed: Provider is busy.")); } } catch(const CIMException&) { throw; } } try { _providerRegistrationManager->deleteInstance(instanceReference); } catch(const CIMException&) { throw; } // complete processing the request handler.complete();}// Block a provider, unblock a provider, and stop a providervoid ProviderRegistrationProvider::invokeMethod( const OperationContext & context, const CIMObjectPath & objectReference, const CIMName & methodName, const Array<CIMParamValue> & inParameters, MethodResultResponseHandler & handler){ // get userName and only privileged user can execute this operation String userName; try { IdentityContainer container = context.get(IdentityContainer::NAME); userName = container.getUserName(); } catch (...) { userName = String::EMPTY; } if ((userName != String::EMPTY) && !System::isPrivilegedUser(userName)) { //l10n //throw PEGASUS_CIM_EXCEPTION(CIM_ERR_ACCESS_DENIED, //"You must have superuser privilege to disable or enable providers."); throw PEGASUS_CIM_EXCEPTION_L(CIM_ERR_ACCESS_DENIED,MessageLoaderParms( "ControlProviders.ProviderRegistrationProvider.ProviderRegistrationProvider.SUPERUSER_PRIVILEGE_REQUIRED_DISABLE_ENABLE_PROVIDERS", "You must have superuser privilege to disable or enable providers.")); } if(!objectReference.getNameSpace().equal (PEGASUS_NAMESPACENAME_INTEROP)) { throw PEGASUS_CIM_EXCEPTION(CIM_ERR_NOT_SUPPORTED, objectReference.getNameSpace().getString()); }// l10n // Get the client's list of preferred languages for the response AcceptLanguageList al; try { AcceptLanguageListContainer al_container = (AcceptLanguageListContainer)context.get(AcceptLanguageListContainer::NAME); al = al_container.getLanguages(); } catch (...) { ; // Leave AcceptLanguageList empty } String moduleName; Boolean moduleFound = false; // get module name from reference Array<CIMKeyBinding> keys = objectReference.getKeyBindings(); for(Uint32 i=0; i<keys.size() ; i++) { if(keys[i].getName().equal (_PROPERTY_PROVIDERMODULE_NAME)) { moduleName = keys[i].getValue(); moduleFound = true; } }
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -