📄 namespaceprovider.cpp
字号:
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 NamespaceProvider::getInstance( const OperationContext & context, const CIMObjectPath & instanceName, const Boolean includeQualifiers, const Boolean includeClassOrigin, const CIMPropertyList & properatyList, InstanceResponseHandler & handler) { PEG_METHOD_ENTER(TRC_CONTROLPROVIDER, "NamespaceProvider::getInstance"); CIMNamespaceName childNamespaceName; CIMNamespaceName getNamespaceName; 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, getNamespaceName); if (!Contains(namespaceNames, getNamespaceName)) { //l10n //throw CIMObjectNotFoundException("Namespace deos not exist: " //+ getNamespaceName.getString()); throw CIMObjectNotFoundException(MessageLoaderParms( "ControlProviders.NamespaceProvider.NamespaceProvider.NAMESPACE_DOES_NOT_EXIST", "Namespace does not exist: $0", getNamespaceName.getString())); } PEG_TRACE_STRING(TRC_CONTROLPROVIDER, Tracer::LEVEL4, "Namespace = " + getNamespaceName.getString() + " successfully found."); } catch(const CIMException&) { PEG_METHOD_EXIT(); throw; } catch(const Exception&) { PEG_METHOD_EXIT(); throw; } //Set name of class CIMInstance instance(NAMESPACE_CLASSNAME); // // construct the instance // instance.addProperty(CIMProperty(NAMESPACE_PROPERTYNAME, isRelativeName?childNamespaceName.getString(): parentNamespaceName.getString())); //instance.setPath(instanceName); handler.deliver(instance); // complete processing the request handler.complete(); PEG_METHOD_EXIT(); return ; }void NamespaceProvider::enumerateInstances( const OperationContext & context, const CIMObjectPath & ref, const Boolean includeQualifiers, const Boolean includeClassOrigin, const CIMPropertyList& propertyList, InstanceResponseHandler & handler) { PEG_METHOD_ENTER(TRC_CONTROLPROVIDER, "NamespaceProvider::enumerateInstances()"); // Verify that ClassName == __Namespace if (!ref.getClassName().equal(NAMESPACE_CLASSNAME)) { PEG_METHOD_EXIT(); //l10n //throw CIMNotSupportedException(ref.getClassName().getString() + // " not supported by Namespace Provider"); throw CIMNotSupportedException(MessageLoaderParms( "ControlProviders.NamespaceProvider.NamespaceProvider.NOT_SUPPORTED_BY_NAMESPACEPROVIDER", "$0 not supported by Namespace Provider", ref.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; } CIMNamespaceName parentNamespaceName = ref.getNameSpace(); PEG_TRACE_STRING(TRC_CONTROLPROVIDER, Tracer::LEVEL4, "parentNamespaceName = " + parentNamespaceName.getString()); // begin processing the request handler.processing(); Array<CIMInstance> instanceArray; try { Array<CIMNamespaceName> namespaceNames = _repository->enumerateNameSpaces(); // Build the instances. For now simply build the __Namespace instances // Note that for the moment, the only property is name. for (Uint32 i = 0; i < namespaceNames.size(); i++) { if (_isChild(parentNamespaceName, namespaceNames[i])) { CIMInstance instance(NAMESPACE_CLASSNAME); instance.addProperty( (CIMProperty(NAMESPACE_PROPERTYNAME, namespaceNames[i].getString().subString (parentNamespaceName.getString().size()+1, namespaceNames[i].getString().size()- parentNamespaceName.getString().size()-1)))); instanceArray.append(instance); //instance.setPath(instanceName); PEG_TRACE_STRING(TRC_CONTROLPROVIDER, Tracer::LEVEL4, "childNamespace = " + namespaceNames[i].getString()); } } } catch(const CIMException&) { PEG_METHOD_EXIT(); throw; } catch(const Exception&) { PEG_METHOD_EXIT(); throw; } handler.deliver(instanceArray); // complete processing the request handler.complete(); PEG_METHOD_EXIT(); }void NamespaceProvider::enumerateInstanceNames( const OperationContext & context, const CIMObjectPath & classReference, ObjectPathResponseHandler & handler) { PEG_METHOD_ENTER(TRC_CONTROLPROVIDER, "NamespaceProvider::enumerateInstanceNames()"); // Verify that ClassName == __Namespace if (!classReference.getClassName().equal(NAMESPACE_CLASSNAME)) { PEG_METHOD_EXIT(); //l10n //throw CIMNotSupportedException //(classReference.getClassName().getString() + //" not supported by Namespace Provider"); throw CIMNotSupportedException(MessageLoaderParms( "ControlProviders.NamespaceProvider.NamespaceProvider.NOT_SUPPORTED_BY_NAMESPACEPROVIDER", "$0 not supported by Namespace Provider", classReference.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; } CIMNamespaceName parentNamespaceName = classReference.getNameSpace(); PEG_TRACE_STRING(TRC_CONTROLPROVIDER, Tracer::LEVEL4, "parentNamespaceName = " + parentNamespaceName.getString()); Array<CIMObjectPath> instanceRefs; try { Array<CIMNamespaceName> namespaceNames = _repository->enumerateNameSpaces(); Array<CIMKeyBinding> keyBindings; // Build the instances. For now simply build the __Namespace instances // Note that for the moment, the only property is name. for (Uint32 i = 0; i < namespaceNames.size(); i++) { if (_isChild(parentNamespaceName, namespaceNames[i])) { keyBindings.clear(); keyBindings.append(CIMKeyBinding(NAMESPACE_PROPERTYNAME, namespaceNames[i].getString().subString (parentNamespaceName.getString().size()+1, namespaceNames[i].getString().size()- parentNamespaceName.getString().size()-1), CIMKeyBinding::STRING)); CIMObjectPath ref(String::EMPTY, parentNamespaceName, NAMESPACE_CLASSNAME, keyBindings); instanceRefs.append(ref); PEG_TRACE_STRING(TRC_CONTROLPROVIDER, Tracer::LEVEL4, "childNamespace = " + namespaceNames[i].getString()); } } } catch(const CIMException&) { PEG_METHOD_EXIT(); throw; } catch(const Exception&) { PEG_METHOD_EXIT(); throw; } handler.deliver(instanceRefs); handler.complete(); PEG_METHOD_EXIT();}PEGASUS_NAMESPACE_END
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -