void InstanceProvider::deleteInstance( const OperationContext & context, const CIMObjectPath & instanceReference, ResponseHandler & handler) { // convert a potential fully qualified reference into a local reference // (class name and keys only). CIMObjectPath localReference = CIMObjectPath( String(), CIMNamespaceName(), instanceReference.getClassName(), instanceReference.getKeyBindings()); // begin processing the request handler.processing(); // instance index corresponds to reference index for(Uint32 i = 0, n = _instances.size(); i < n; i++) { if(localReference == _instances[i].getPath()) { // remove instance from the array _instances.remove(i); break; } } // complete processing the request handler.complete(); }
void TimingProvider::modifyInstance( const OperationContext & context, const CIMObjectPath & instanceReference, const CIMInstance & instanceObject, const Boolean includeQualifiers, const CIMPropertyList & propertyList, ResponseHandler & handler) { // convert a potential fully qualified reference into a local reference // (class name and keys only). CIMObjectPath localReference = CIMObjectPath( String(), String(), instanceReference.getClassName(), instanceReference.getKeyBindings()); cout <<"TimingProvider::modifyInstance" << endl; // begin processing the request handler.processing(); // instance index corresponds to reference index for(Uint32 i = 0, n = _instances.size(); i < n; i++) { if(localReference == _instanceNames[i]) { // overwrite existing instance _instances[i] = instanceObject; break; } } // complete processing the request handler.complete(); }
void PG_TestPropertyTypes::deleteInstance( const OperationContext& context, const CIMObjectPath& instanceReference, ResponseHandler& handler) { // synchronously get references Array<CIMObjectPath> references = _enumerateInstanceNames(context, instanceReference); // ensure the Namespace is valid if (!instanceReference.getNameSpace().equal("test/static")) { throw CIMException(CIM_ERR_INVALID_NAMESPACE); } // ensure the class existing in the specified namespace if (!instanceReference.getClassName().equal("PG_TestPropertyTypes")) { throw CIMException(CIM_ERR_INVALID_CLASS); } // ensure the requested object exists Uint32 index = findObjectPath(references, instanceReference); if (index == PEG_NOT_FOUND) { throw CIMException(CIM_ERR_NOT_FOUND); } // begin processing the request handler.processing(); // we do not remove instance // complete processing the request handler.complete(); }
void DefaultInstanceProvider::deleteInstance( const OperationContext & context, const CIMObjectPath & instanceReference, ResponseHandler & handler) { CIMNamespaceName nameSpace = instanceReference.getNameSpace(); // get the class name CIMName className = instanceReference.getClassName(); // create the namespace if necessary if (!_nameSpaceExists(nameSpace)) { _copyNameSpace(nameSpace.getString(), className.getString()); } // check to see if class already exists // if not, copy the class // try { CIMClass cimClass = _repository->getClass(nameSpace, className); } catch (Exception&) { // Class does not exist. Copy the class. // _copyClass(nameSpace.getString(), className.getString()); } // convert a potential fully qualified reference into a local reference // (class name and keys only). CIMObjectPath localReference = CIMObjectPath( String(), String(), instanceReference.getClassName(), instanceReference.getKeyBindings()); // begin processing the request handler.processing(); try { _repository->deleteInstance(nameSpace, localReference); } catch (Exception & ex) { const String msg = "delete Instance failed. " + ex.getMessage(); throw CIMOperationFailedException( msg ); } // complete processing the request handler.complete(); }
void PG_TestPropertyTypes::modifyInstance( const OperationContext& context, const CIMObjectPath& instanceReference, const CIMInstance& instanceObject, const Boolean includeQualifiers, const CIMPropertyList& propertyList, ResponseHandler& handler) { // This provider only allows partial instance modification for the // PropertyUint8 property. if (!(propertyList.isNull() || ((propertyList.size() == 1) && (propertyList[0].equal("PropertyUint8"))))) { throw CIMException(CIM_ERR_NOT_SUPPORTED); } // synchronously get references Array<CIMObjectPath> references = _enumerateInstanceNames(context, instanceReference); // ensure the Namespace is valid if (!instanceReference.getNameSpace().equal("test/static")) { throw CIMException(CIM_ERR_INVALID_NAMESPACE); } // ensure the class existing in the specified namespace if (!instanceReference.getClassName().equal("PG_TestPropertyTypes")) { throw CIMException(CIM_ERR_INVALID_CLASS); } // ensure the property values are valid _testPropertyTypesValue(instanceObject); // ensure the request object exists Uint32 index = findObjectPath(references, instanceReference); if (index == PEG_NOT_FOUND) { throw CIMException(CIM_ERR_NOT_FOUND); } // begin processing the request handler.processing(); // We do nothing here since we like to have static result // complete processing the request handler.complete(); }
/** * Removes the specified instance from the repository. The provider * then tries to retrieve the instance from the repository which should fail. */ void EmbeddedInstanceProvider::deleteInstance( const OperationContext& context, const CIMObjectPath& ref, ResponseHandler& handler) { handler.processing(); if (ref.getClassName().equal(CIMName("PG_EmbeddedError"))) { cimom.deleteInstance( context, STATIC_REPOSITORY, repositoryPath); } handler.complete(); }
void ExceptionsTest::deleteInstance( const OperationContext & context, const CIMObjectPath & instanceReference, ResponseHandler & handler) { // convert a potential fully qualified reference into a local reference // (class name and keys only). CIMObjectPath localReference = CIMObjectPath( String(), String(), instanceReference.getClassName(), instanceReference.getKeyBindings()); // begin processing the request handler.processing(); cout <<"Calling Exception ExceptionsTest::deleteInstance 1" << endl; CheckExceptionType(EXCEPTION_TYPE); // instance index corresponds to reference index for(Uint32 i = 0, n = _instances.size(); i < n; i++) { if(localReference == _instanceNames[i]) { // save the instance locally CIMInstance cimInstance(_instances[i]); // remove instance from the array _instances.remove(i); _instanceNames.remove(i); // exit loop break; } } cout <<"Calling Exception ExceptionsTest::deleteInstance 2" << endl; CheckExceptionType(EXCEPTION_TYPE); // complete processing the request handler.complete(); }
void ConfigSettingProvider::modifyInstance( const OperationContext & context, const CIMObjectPath & instanceReference, const CIMInstance& modifiedIns, const Boolean includeQualifiers, const CIMPropertyList& propertyList, ResponseHandler & handler) { PEG_METHOD_ENTER(TRC_CONFIG, "ConfigSettingProvider::modifyInstance()"); handler.processing(); _modifyInstance( context, instanceReference, modifiedIns, propertyList, 0); handler.complete(); PEG_METHOD_EXIT(); }
bool ClientImpl::GetResponseData(ResponseHandler const& handler) { if (handler.empty()) { return false; } try { windows_shared_memory shm(open_only, WEASEL_IPC_SHARED_MEMORY, read_only); mapped_region region(shm, read_only, WEASEL_IPC_METADATA_SIZE); return handler((LPWSTR)region.get_address(), WEASEL_IPC_BUFFER_LENGTH); } catch (interprocess_exception& /*ex*/) { return false; } return false; }
// // Modify instance based on modifiedInstance. // void UserAuthProvider::modifyInstance( const OperationContext & context, const CIMObjectPath & instanceReference, const CIMInstance& modifiedIns, const Boolean includeQualifiers, const CIMPropertyList & propertyList, ResponseHandler & handler) { PEG_METHOD_ENTER(TRC_USER_MANAGER,"UserAuthProvider::modifyInstance"); // // get userName // String user; try { IdentityContainer container = context.get(IdentityContainer::NAME); user= container.getUserName(); } catch (...) { user= String::EMPTY; } // // verify user authorizations // if ( user != String::EMPTY || user != "" ) { _verifyAuthorization(user); } // // check if the class name requested is PG_Authorization // if (!instanceReference.getClassName().equal (CLASS_NAME_PG_AUTHORIZATION)) { PEG_METHOD_EXIT(); throw PEGASUS_CIM_EXCEPTION ( CIM_ERR_NOT_SUPPORTED, instanceReference.getClassName().getString()); } CIMInstance newInstance = modifiedIns; // begin processing the request handler.processing(); try { // // Get the user name from the instance // String userNameStr; String namespaceStr; String authorizationStr; Uint32 pos = modifiedIns.findProperty ( PROPERTY_NAME_USERNAME ); CIMProperty prop = (CIMProperty)newInstance.getProperty(pos); prop.getValue().get(userNameStr); // // Get the namespace from the instance // pos = modifiedIns.findProperty ( PROPERTY_NAME_NAMESPACE ); prop = (CIMProperty)newInstance.getProperty(pos); prop.getValue().get(namespaceStr); // // Get the authorization from the instance // pos = modifiedIns.findProperty ( PROPERTY_NAME_AUTHORIZATION ); prop = (CIMProperty)newInstance.getProperty(pos); prop.getValue().get(authorizationStr); // // ATTN: Note that the following is a hack, because // modifyInstance() in repository does not like // the hostname and namespace included in the CIMObjectPath // passed to it as a parameter. // CIMObjectPath ref("", CIMNamespaceName (), modifiedIns.getClassName(), instanceReference.getKeyBindings()); CIMInstance newModifiedIns = modifiedIns.clone (); newModifiedIns.setPath (ref); // // call modifyInstances of the repository // _repository->modifyInstance( instanceReference.getNameSpace(), newModifiedIns); // // set authorization in the UserManager // _userManager->setAuthorization( userNameStr, namespaceStr, authorizationStr ); } catch(Exception& e) { PEG_METHOD_EXIT(); throw PEGASUS_CIM_EXCEPTION(CIM_ERR_FAILED, e.getMessage()); } // complete processing the request handler.complete(); PEG_METHOD_EXIT(); return; }
// // Deletes the specified instance. // void UserAuthProvider::deleteInstance( const OperationContext & context, const CIMObjectPath& myInstance, ResponseHandler & handler) { CIMValue userName ; String userNameStr; String namespaceStr; Array<CIMKeyBinding> kbArray; PEG_METHOD_ENTER(TRC_USER_MANAGER,"UserAuthProvider::deleteInstance"); // // get userName // String user; try { IdentityContainer container = context.get(IdentityContainer::NAME); user= container.getUserName(); } catch (...) { user= String::EMPTY; } // // verify user authorizations // if ( user != String::EMPTY || user != "" ) { _verifyAuthorization(user); } // begin processing the request handler.processing(); #ifndef PEGASUS_NO_PASSWORDFILE // // check if the class name requested is PG_User // if (myInstance.getClassName().equal (CLASS_NAME_PG_USER)) { // // Get the user name from the instance // try { kbArray = myInstance.getKeyBindings(); if ( ! kbArray.size() ) { //l10n //throw PEGASUS_CIM_EXCEPTION( CIM_ERR_INVALID_PARAMETER, //"Unable to find Key Property Username"); MessageLoaderParms parms("ControlProviders.UserAuthProvider.UNABLE_TO_FIND_KEY_PROPERTY_USERNAME", "Unable to find Key Property Username"); throw PEGASUS_CIM_EXCEPTION_L( CIM_ERR_INVALID_PARAMETER,parms); } if ( kbArray[0].getName() == PROPERTY_NAME_USERNAME ) { userNameStr = kbArray[0].getValue(); } else { //l10n //throw PEGASUS_CIM_EXCEPTION(CIM_ERR_INVALID_PARAMETER, //"Unexpected Key property"); MessageLoaderParms parms("ControlProviders.UserAuthProvider.UNEXPECTED_KEY_PROPERTY", "Unexpected Key property"); throw PEGASUS_CIM_EXCEPTION_L(CIM_ERR_INVALID_PARAMETER,parms); } // // Remove the user from User Manager // _userManager->removeUser(userNameStr); } catch ( const CIMException & ) { handler.complete(); PEG_METHOD_EXIT(); throw; } catch ( const Exception &e ) { handler.complete(); PEG_METHOD_EXIT(); throw PEGASUS_CIM_EXCEPTION(CIM_ERR_FAILED, e.getMessage()); } } // // check if the class name requested is PG_Authorization // else if (myInstance.getClassName().equal (CLASS_NAME_PG_AUTHORIZATION)) #else if (myInstance.getClassName().equal (CLASS_NAME_PG_AUTHORIZATION)) #endif { try { // // Get the user name and namespace from the instance // kbArray = myInstance.getKeyBindings(); for (Uint32 i = 0; i < kbArray.size(); i++) { if ( kbArray[i].getName() == PROPERTY_NAME_USERNAME ) { userNameStr = kbArray[i].getValue(); } else if ( kbArray[i].getName() == PROPERTY_NAME_NAMESPACE ) { namespaceStr = kbArray[i].getValue(); } } } catch ( CIMException &e ) { PEG_METHOD_EXIT(); throw PEGASUS_CIM_EXCEPTION(CIM_ERR_FAILED, e.getMessage()); } if ( !userNameStr.size() ) { PEG_METHOD_EXIT(); //l10n //throw PEGASUS_CIM_EXCEPTION ( //CIM_ERR_INVALID_PARAMETER, //"Username property can not be empty.") ; MessageLoaderParms parms("ControlProviders.UserAuthProvider.USERNAME_PROPERTY_CANNOT_BE_EMPTY", "Username property can not be empty."); throw PEGASUS_CIM_EXCEPTION_L(CIM_ERR_INVALID_PARAMETER,parms); } else if ( !namespaceStr.size() ) { PEG_METHOD_EXIT(); //l10n //throw PEGASUS_CIM_EXCEPTION ( //CIM_ERR_INVALID_PARAMETER, //"Namespace property can not be empty.") ; MessageLoaderParms parms("ControlProviders.UserAuthProvider.NAMESPACE_PROPERTY_CANNOT_BE_EMPTY", "Namespace property can not be empty."); throw PEGASUS_CIM_EXCEPTION_L(CIM_ERR_INVALID_PARAMETER,parms); } try { // // ATTN: Note that the following is a hack, because // deleteInstance() in repository does not like // the hostname and namespace included in the CIMObjectPath // passed to it as a parameter. // CIMObjectPath ref("", CIMNamespaceName (), myInstance.getClassName(), myInstance.getKeyBindings()); _repository->deleteInstance( myInstance.getNameSpace(), ref); // // remove authorization in the UserManager // _userManager->removeAuthorization( userNameStr, namespaceStr ); } catch ( CIMException &e ) { PEG_METHOD_EXIT(); throw PEGASUS_CIM_EXCEPTION(CIM_ERR_FAILED, e.getMessage()); } } else { PEG_METHOD_EXIT(); throw PEGASUS_CIM_EXCEPTION( CIM_ERR_NOT_FOUND, myInstance.getClassName().getString()); } // complete processing the request handler.complete(); PEG_METHOD_EXIT(); return; }
void NamespaceProvider::deleteInstance( const OperationContext & context, const CIMObjectPath & instanceName, ResponseHandler & handler) { PEG_METHOD_ENTER(TRC_CONTROLPROVIDER, "NamespaceProvider::deleteInstance"); CIMNamespaceName childNamespaceName; CIMNamespaceName deleteNamespaceName; Boolean isRelativeName; // Verify that the className = __namespace if (!instanceName.getClassName().equal(NAMESPACE_CLASSNAME)) { PEG_METHOD_EXIT(); //l10n //throw CIMNotSupportedException(instanceName.getClassName().getString() //+ " not supported by Namespace Provider"); throw CIMNotSupportedException(MessageLoaderParms( "ControlProviders.NamespaceProvider.NamespaceProvider.NOT_SUPPORTED_BY_NAMESPACEPROVIDER", "$0 not supported by Namespace Provider", instanceName.getClassName().getString())); } //ATTN-DME-P3-20020522: ADD AUTHORIZATION CHECK TO __NAMESPACE PROVIDER String userName; try { IdentityContainer container = context.get(IdentityContainer::NAME); userName = container.getUserName(); } catch (...) { userName = String::EMPTY; } _getKeyValue(instanceName, childNamespaceName, isRelativeName); CIMNamespaceName parentNamespaceName = instanceName.getNameSpace(); PEG_TRACE_STRING(TRC_CONTROLPROVIDER, Tracer::LEVEL4, "childNamespaceName = " + childNamespaceName.getString() + (isRelativeName?String("true"):String("false")) + ", parentNamespaceName = " + parentNamespaceName.getString()); // begin processing the request handler.processing(); try { Array<CIMNamespaceName> namespaceNames; namespaceNames = _repository->enumerateNameSpaces(); _generateFullNamespaceName(namespaceNames, parentNamespaceName, childNamespaceName, isRelativeName, deleteNamespaceName); if (deleteNamespaceName.equal (ROOTNS)) { //l10n //throw CIMNotSupportedException("root namespace may be deleted."); throw CIMNotSupportedException(MessageLoaderParms( "ControlProviders.NamespaceProvider.NamespaceProvider.ROOT_NAMESPACE_CANNOT_BE_DELETED", "root namespace may be deleted.")); } _repository->deleteNameSpace(deleteNamespaceName); PEG_TRACE_STRING(TRC_CONTROLPROVIDER, Tracer::LEVEL4, "Namespace = " + deleteNamespaceName.getString() + " successfully deleted."); } catch(const CIMException&) { PEG_METHOD_EXIT(); throw; } catch(const Exception&) { PEG_METHOD_EXIT(); throw; } // complete processing the request handler.complete(); PEG_METHOD_EXIT(); return ; }
void LifecycleIndicationProvider::deleteInstance( const OperationContext & context, const CIMObjectPath & instanceReference, ResponseHandler & handler) { // cout << "LifecycleIndicationProvider::deleteInstance()" << endl; CIMInstance localInstance; // convert a potential fully qualified reference into a local reference // (class name and keys only). CIMObjectPath localReference = CIMObjectPath( String(), CIMNamespaceName(), instanceReference.getClassName(), instanceReference.getKeyBindings()); // begin processing the request handler.processing(); // instance index corresponds to reference index for(Uint32 i = 0, n = _instances.size(); i < n; i++) { if(localReference == _instances[i].getPath()) { localInstance = _instances[i]; // remove instance from the array _instances.remove(i); break; } } // complete processing the request handler.complete(); // If there is at least one subscription active for the lifecycle indication // InstDeletion_for_Sample_LifecycleIndicationProviderClass, then generate // that indication here, embedding the just-deleted instance as the // SourceInstance property. See LifecycleIndicationProviderR.mof. if (_lifecycle_indications_enabled) { CIMInstance indicationInstance( CIMName( "InstDeletion_for_Sample_LifecycleIndicationProviderClass")); CIMObjectPath path; path.setNameSpace("root/SampleProvider"); path.setClassName( "InstDeletion_for_Sample_LifecycleIndicationProviderClass"); indicationInstance.setPath(path); char buffer[32]; sprintf(buffer, "%d", _nextUID++); indicationInstance.addProperty (CIMProperty ("IndicationIdentifier",String(buffer))); CIMDateTime currentDateTime = CIMDateTime::getCurrentDateTime (); indicationInstance.addProperty (CIMProperty ("IndicationTime", currentDateTime)); // Before we send the Lifecycle Indication for the delete of this // instance, change the "lastOp" property value to "deleteInstance". Uint32 ix = localInstance.findProperty(CIMName("lastOp")); if (ix != PEG_NOT_FOUND) { localInstance.removeProperty(ix); localInstance.addProperty( CIMProperty( CIMName("lastOp"), String("deleteInstance"))); } indicationInstance.addProperty (CIMProperty ("SourceInstance",CIMObject(localInstance))); _indication_handler->deliver (indicationInstance); // cout << "LifecycleIndicationProvider::deleteInstance() sent " // "InstDeletion_for_Sample_LifecycleIndicationProviderClass" // << endl; } }