/** testReferences - * */ int testReferences(const CIMObjectPath& objectName, const CIMName& resultClass, const String& role, CIMPropertyList& propertyList, Uint32 expectedCount ) { CDEBUG ("testRefrenceNames " << objectName.toString() << " resultClass " << resultClass << " role " << role); Array<CIMObject> result = c.references( NAMESPACE, objectName, resultClass, role, false, false, propertyList); CDEBUG(" Rtned from c.references "); if (verbose) { for (Uint32 i = 0; i < result.size(); i++) { cout << "[" << result[i].getPath().toString() << "]" << endl; } } CDEBUG(" Now try the size comparison with input "); if (result.size() != expectedCount) { cout << "ReferenceName Error Object " << objectName.toString() << "Expected count = " << expectedCount << " received " << result.size(); } return 0; }
int testReferenceNames(const CIMObjectPath& objectName, const CIMName& resultClass, const String& role, Uint32 expectedCount ) { //CIMObjectPath instanceName = CIMObjectPath ("Person.name=\"Mike\""); CDEBUG ("testReferenceNames " << objectName.toString() << " resultClass " << resultClass << " role " << role); Array<CIMObjectPath> result = c.referenceNames( NAMESPACE, objectName, resultClass, role); CDEBUG("Return from Instance Names"); Array<CIMObject> resultObjects = c.references( NAMESPACE, objectName, resultClass, role); CDEBUG("Return from calls. compare sizes"); if (result.size() != resultObjects.size()) { cout << "ERROR, Reference and reference Name size difference" << endl; } CDEBUG("Size tests finished, now compare the returns"); for (Uint32 i = 0; i < result.size(); i++) { if (resultObjects[i].getPath().toString() != result[i].toString()) { cout << "Name response Error: " << resultObjects[i].getPath().toString() << " != " << result[i].toString() << endl; } } CDEBUG("Returns Compared. Now to the display"); if (verbose) { cout << "REQUEST: References, Object: " << objectName << " Filter: " << resultClass << " role: " << role << endl << "RESPONSE:"; for (Uint32 i = 0; i < result.size(); i++) cout << " " << result[i].getClassName().getString() << ""; cout << endl; } if (result.size() != expectedCount) { cout << "ReferenceName Error Object " << objectName.toString() << "Expected count: " << expectedCount << " Received: " << result.size() <<endl; return 0; } return 0; }
int testAssocNames(const CIMObjectPath& objectName, const CIMName& assocClass, const CIMName& resultClass, const String& role, const String& resultRole, Uint32 expectedCount ) { //CIMObjectPath instanceName = CIMObjectPath ("Person.name=\"Mike\""); CDEBUG ("testReferenceNames " << objectName.toString() << " resultClass " << resultClass << " role " << role); Array<CIMObjectPath> result = c.associatorNames( NAMESPACE, objectName, assocClass, resultClass, role, resultRole); Array<CIMObject> resultObjects = c.associators( NAMESPACE, objectName, assocClass, resultClass, role, resultClass); if (result.size() != resultObjects.size()) { cout << "ERROR, Associator and AssociatorName count returned difference" << endl; } for (Uint32 i = 0; i < result.size(); i++) { if (resultObjects[i].getPath().toString() != result[i].toString()) { cout << "Name response Error" << endl; } } if (verbose) { cout << "REQUEST: Associators, Object: " << objectName << " assocClass " << assocClass << " resultClass " << resultClass << " role " << role << " resultClass " << resultClass << endl << "RESPONSE: "; for (Uint32 i = 0; i < result.size(); i++) cout << " " << result[i].toString() << " "; cout << endl; } if (result.size() != expectedCount) { cout << "AssociatorName Error Object " << objectName.toString() << "Expected count = " << expectedCount << " received " << result.size(); return 1; } return 0; }
/* ================================================================================ NAME : _constructKeyBindings DESCRIPTION : Constructs an array of keybindings for an IP Interface ASSUMPTIONS : None PRE-CONDITIONS : POST-CONDITIONS : NOTES : PARAMETERS : className, Process ================================================================================ */ Array<CIMKeyBinding> BIPTLEpProvider::_constructKeyBindings( const CIMNamespaceName &nameSpace, const IPInterface &_ipif) { #ifdef DEBUG cout << "BIPTLEpProvider::_constructKeyBindings()" << endl; #endif Array<CIMKeyBinding> keyBindings; String s, sn; CIMObjectPath op; if (_ipif.getSystemName(sn) == false) { throw CIMNotSupportedException( String("Host-specific module doesn't support Key `") + PROPERTY_SYSTEM_NAME.getString() + String("'")); } // Construct the key bindings op = CIMObjectPath(sn, //hostname nameSpace, CLASS_CIM_LAN_ENDPOINT, _constructReference( CLASS_CIM_LAN_ENDPOINT, sn,_ipif.get_LANInterfaceName()) ); keyBindings.append(CIMKeyBinding(PROPERTY_ANTECEDENT, op.toString(), CIMKeyBinding::REFERENCE)); if (_ipif.getName(s)) { op = CIMObjectPath(sn, //hostname nameSpace, CLASS_CIM_IP_PROTOCOL_ENDPOINT, _constructReference( CLASS_CIM_IP_PROTOCOL_ENDPOINT, sn,s) ); keyBindings.append(CIMKeyBinding(PROPERTY_DEPENDENT, op.toString(), CIMKeyBinding::REFERENCE)); } else { throw CIMNotSupportedException( String("Host-specific module doesn't support Key `") + PROPERTY_NAME.getString() + String("'")); } #ifdef DEBUG cout << "BIPTLEpProvider::_constructKeyBindings() -- done" << endl; #endif return keyBindings; }
void UNIX_ApplicationSystemDirectoryFixture::Run() { CIMName className("UNIX_ApplicationSystemDirectory"); CIMNamespaceName nameSpace("root/cimv2"); UNIX_ApplicationSystemDirectory _p; UNIX_ApplicationSystemDirectoryProvider _provider; Uint32 propertyCount; CIMOMHandle omHandle; _provider.initialize(omHandle); _p.initialize(); for(int pIndex = 0; _p.load(pIndex); pIndex++) { CIMInstance instance = _provider.constructInstance(className, nameSpace, _p); CIMObjectPath path = instance.getPath(); cout << path.toString() << endl; propertyCount = instance.getPropertyCount(); for(Uint32 i = 0; i < propertyCount; i++) { CIMProperty propertyItem = instance.getProperty(i); if (propertyItem.getType() == CIMTYPE_REFERENCE) { CIMValue subValue = propertyItem.getValue(); CIMInstance subInstance; subValue.get(subInstance); CIMObjectPath subPath = subInstance.getPath(); cout << " Name: " << propertyItem.getName().getString() << ": " << subPath.toString() << endl; Uint32 subPropertyCount = subInstance.getPropertyCount(); for(Uint32 j = 0; j < subPropertyCount; j++) { CIMProperty subPropertyItem = subInstance.getProperty(j); cout << " Name: " << subPropertyItem.getName().getString() << " - Value: " << subPropertyItem.getValue().toString() << endl; } } else { cout << " Name: " << propertyItem.getName().getString() << " - Value: " << propertyItem.getValue().toString() << endl; } } cout << "------------------------------------" << endl; cout << endl; } _p.finalize(); }
void test04 (CIMClient & client) { CIMObjectPath instanceName; instanceName.setNameSpace (providerNamespace); instanceName.setClassName (CLASSNAME); Array < CIMParamValue > inParams; Array < CIMParamValue > outParams; /* [EmbeddedObject] String returnInstance(); */ CIMValue retValue = client.invokeMethod (providerNamespace, instanceName, "returnInstance", inParams, outParams); PEGASUS_TEST_ASSERT (retValue.getType () == CIMTYPE_OBJECT); PEGASUS_TEST_ASSERT (!retValue.isArray ()); PEGASUS_TEST_ASSERT (!retValue.isNull ()); CIMObject result; retValue.get (result); CIMObjectPath objPath = result.getPath(); PEGASUS_TEST_ASSERT (objPath.toString() == "TestCMPI_Instance"); }
Uint32 _testReferences( CIMClient& client, CIMObjectPath instancePath, CIMName referenceClass) { if (verbose) { cout << "\nObject Name: " << instancePath.toString() << endl; } // get the association reference instances // String role; Array<CIMObject> resultObjects = client.references(NAMESPACE, instancePath, referenceClass,role); Uint32 size = resultObjects.size(); if (verbose) { if (size > 0) { cout << " \n " << referenceClass.getString() << " :: "; for (Uint32 i = 0; i < size ; ++i) { cout << resultObjects[i].getPath().toString(); } cout << endl; } } return size; }
void _testReferenceNames(CIMClient& client, CIMObjectPath instancePath, Uint32 numExpectedObjects) { if (verbose) { cout << "Object Name: " << instancePath.toString() << endl; } try { // get the reference instance names // Array<CIMObjectPath> resultObjectPaths; CIMName resultClass; String role; resultObjectPaths = client.referenceNames( providerNamespace, instancePath, resultClass, role); // verify result _verifyResult(resultObjectPaths.size(), numExpectedObjects); // display result _displayResult(resultObjectPaths); } catch (Exception& e) { _errorExit(e.getMessage()); } }
void _testAssociatorNames(CIMClient& client, CIMName assocClass, CIMObjectPath instancePath, Uint32 numExpectedObjects) { if (verbose) { cout << "Association Class: " << assocClass.getString() << endl; cout << "Object Name: " << instancePath.toString() << endl; } try { // Get the names of the CIM instances that are associated to the // specified source instance via an instance of the AssocClass. // CIMName resultClass; String role; String resultRole; Array<CIMObjectPath> resultObjectPaths = client.associatorNames(providerNamespace, instancePath, assocClass, resultClass, role, resultRole); // verify result _verifyResult(resultObjectPaths.size(), numExpectedObjects); // display result _displayResult(resultObjectPaths); } catch (Exception& e) { _errorExit(e.getMessage()); } }
static void _BubbleSort(Array<CIMKeyBinding>& x) { Uint32 n = x.size(); // // If the key is a reference, the keys in the reference must also be // sorted // for (Uint32 k = 0; k < n ; k++) if (x[k].getType () == CIMKeyBinding::REFERENCE) { CIMObjectPath tmp (x[k].getValue ()); Array <CIMKeyBinding> keyBindings = tmp.getKeyBindings (); _BubbleSort (keyBindings); tmp.setKeyBindings (keyBindings); x[k].setValue (tmp.toString ()); } if (n < 2) return; for (Uint32 i = 0; i < n - 1; i++) { for (Uint32 j = 0; j < n - 1; j++) { if (String::compareNoCase(x[j].getName().getString(), x[j+1].getName().getString()) > 0) { CIMKeyBinding t = x[j]; x[j] = x[j+1]; x[j+1] = t; } } } }
CIMObjectPath _buildSubscriptionPath (const CIMObjectPath & filterPath, const CIMObjectPath & handlerPath) { CIMObjectPath path; Array <CIMKeyBinding> keyBindings; keyBindings.append (CIMKeyBinding ("Filter", filterPath.toString (), CIMKeyBinding::REFERENCE)); keyBindings.append (CIMKeyBinding ("Handler", handlerPath.toString (), CIMKeyBinding::REFERENCE)); path.setClassName (SUBSCRIPTION_CLASSNAME); path.setKeyBindings (keyBindings); return path; }
void InstanceProvider::createInstance( const OperationContext & context, const CIMObjectPath & instanceReference, const CIMInstance & instanceObject, ObjectPathResponseHandler & handler) { // Validate the class name if (!instanceObject.getClassName().equal("Sample_InstanceProviderClass")) { throw CIMNotSupportedException( instanceObject.getClassName().getString()); } // Find the key property Uint32 idIndex = instanceObject.findProperty("Identifier"); if (idIndex == PEG_NOT_FOUND) { throw CIMInvalidParameterException("Missing key value"); } CIMInstance cimInstance = instanceObject.clone(); // Create the new instance name CIMValue idValue = instanceObject.getProperty(idIndex).getValue(); Array<CIMKeyBinding> keys; keys.append(CIMKeyBinding("Identifier", idValue)); CIMObjectPath instanceName = CIMObjectPath( String(), CIMNamespaceName(), instanceObject.getClassName(), keys); cimInstance.setPath(instanceName); // Determine whether this instance already exists for(Uint32 i = 0, n = _instances.size(); i < n; i++) { if(instanceName == _instances[i].getPath()) { throw CIMObjectAlreadyExistsException(instanceName.toString()); } } // begin processing the request handler.processing(); // add the new instance to the array _instances.append(cimInstance); // deliver the new instance name handler.deliver(instanceName); // complete processing the request handler.complete(); }
void _deleteSubscriptionInstance (CIMClient & client, const String & filterName, const String & handlerName, const CIMNamespaceName & filterNS, const CIMNamespaceName & handlerNS, const CIMNamespaceName & subscriptionNS) { Array<CIMKeyBinding> filterKeyBindings; filterKeyBindings.append (CIMKeyBinding ("SystemCreationClassName", System::getSystemCreationClassName (), CIMKeyBinding::STRING)); filterKeyBindings.append (CIMKeyBinding ("SystemName", System::getFullyQualifiedHostName (), CIMKeyBinding::STRING)); filterKeyBindings.append (CIMKeyBinding ("CreationClassName", PEGASUS_CLASSNAME_INDFILTER.getString(), CIMKeyBinding::STRING)); filterKeyBindings.append (CIMKeyBinding ("Name", filterName, CIMKeyBinding::STRING)); CIMObjectPath filterPath ("", filterNS, PEGASUS_CLASSNAME_INDFILTER, filterKeyBindings); Array<CIMKeyBinding> handlerKeyBindings; handlerKeyBindings.append (CIMKeyBinding ("SystemCreationClassName", System::getSystemCreationClassName (), CIMKeyBinding::STRING)); handlerKeyBindings.append (CIMKeyBinding ("SystemName", System::getFullyQualifiedHostName (), CIMKeyBinding::STRING)); handlerKeyBindings.append (CIMKeyBinding ("CreationClassName", PEGASUS_CLASSNAME_INDHANDLER_CIMXML.getString(), CIMKeyBinding::STRING)); handlerKeyBindings.append (CIMKeyBinding ("Name", handlerName, CIMKeyBinding::STRING)); CIMObjectPath handlerPath ("", handlerNS, PEGASUS_CLASSNAME_INDHANDLER_CIMXML, handlerKeyBindings); Array<CIMKeyBinding> subscriptionKeyBindings; subscriptionKeyBindings.append (CIMKeyBinding ("Filter", filterPath.toString (), CIMKeyBinding::REFERENCE)); subscriptionKeyBindings.append (CIMKeyBinding ("Handler", handlerPath.toString (), CIMKeyBinding::REFERENCE)); CIMObjectPath subscriptionPath ("", CIMNamespaceName (), PEGASUS_CLASSNAME_INDSUBSCRIPTION, subscriptionKeyBindings); client.deleteInstance (subscriptionNS, subscriptionPath); }
CIMObjectPath _buildSubscriptionPath (const String & filterName, const CIMName & handlerClass, const String & handlerName) { CIMObjectPath filterPath = _buildFilterOrHandlerPath (PEGASUS_CLASSNAME_INDFILTER, filterName); CIMObjectPath handlerPath = _buildFilterOrHandlerPath (handlerClass, handlerName); Array < CIMKeyBinding > subscriptionKeyBindings; subscriptionKeyBindings.append (CIMKeyBinding ("Filter", filterPath.toString (), CIMKeyBinding::REFERENCE)); subscriptionKeyBindings. append (CIMKeyBinding ("Handler", handlerPath.toString (), CIMKeyBinding::REFERENCE)); CIMObjectPath subscriptionPath ("", CIMNamespaceName (), PEGASUS_CLASSNAME_INDSUBSCRIPTION, subscriptionKeyBindings); return subscriptionPath; }
void _checkSubscriptionPath (const CIMObjectPath & path, const String & filterName, const CIMName & handlerClass, const String & handlerName) { PEGASUS_ASSERT (path.getClassName () == PEGASUS_CLASSNAME_INDSUBSCRIPTION); Array < CIMKeyBinding > keyBindings = path.getKeyBindings (); Boolean filterFound = false; Boolean handlerFound = false; for (Uint32 i = 0; i < keyBindings.size (); i++) { if (keyBindings[i].getName ().equal ("Filter")) { filterFound = true; CIMObjectPath filterPath = _buildFilterOrHandlerPath (PEGASUS_CLASSNAME_INDFILTER, filterName); PEGASUS_ASSERT (keyBindings[i].getValue () == filterPath.toString ()); } else if (keyBindings[i].getName ().equal ("Handler")) { handlerFound = true; CIMObjectPath handlerPath = _buildFilterOrHandlerPath (handlerClass, handlerName); PEGASUS_ASSERT (keyBindings[i].getValue () == handlerPath.toString ()); } else { PEGASUS_ASSERT (false); } } PEGASUS_ASSERT (filterFound); PEGASUS_ASSERT (handlerFound); }
Uint32 _testReferenceNames(CIMClient& client, CIMObjectPath instancePath, CIMName referenceClass) { if (verbose) { cout << "\nObject Name: " << instancePath.toString() << endl; } // get the reference instance names // String role; Array<CIMObjectPath> resultObjectPaths = client.referenceNames(NAMESPACE, instancePath, referenceClass, role); return resultObjectPaths.size(); }
CIMInstance ProviderIndicationCountTable::getProviderIndicationDataInstance( const CIMObjectPath& instanceName) { PEG_METHOD_ENTER(TRC_INDICATION_SERVICE, "ProviderIndicationCountTable::getProviderIndicationDataInstance"); // // Gets provider module name and provider name from the provider indication // data instance object path // String providerModuleName; String providerName; Array<CIMKeyBinding> keys = instanceName.getKeyBindings(); for (Uint32 i = 0; i < keys.size(); i++) { if (keys[i].getName() == _PROPERTY_PROVIDERNAME) { providerName = keys[i].getValue(); } else if (keys[i].getName() == _PROPERTY_PROVIDERMODULENAME) { providerModuleName = keys[i].getValue(); } } String providerKey = _generateKey(providerModuleName, providerName); _ProviderIndicationCountTableEntry entry; WriteLock lock(_tableLock); if (_table.lookup(providerKey, entry)) { CIMInstance providerIndDataInstance = _buildProviderIndDataInstance(entry); PEG_METHOD_EXIT(); return providerIndDataInstance; } PEG_METHOD_EXIT(); throw CIMObjectNotFoundException(instanceName.toString()); }
Uint32 _testAssociatorNames(CIMClient& client, CIMName assocClass, CIMObjectPath instancePath) { if (verbose) { cout << "\nAssociation Class: " << assocClass.getString() << endl; cout << "\nObject Name: " << instancePath.toString() << endl; } // Get the names of the CIM instances that are associated to the // specified source instance via an instance of the AssocClass. // CIMName resultClass; String role; String resultRole; Array<CIMObjectPath> resultObjectPaths = client.associatorNames( NAMESPACE, instancePath, assocClass, resultClass, role, resultRole); return resultObjectPaths.size(); }
void LargeDataProvider::createInstance( const OperationContext & context, const CIMObjectPath & instanceReference, const CIMInstance & instanceObject, ObjectPathResponseHandler & handler) { cout << "---------------------------------" << endl; cout << "LargeDataProvider::createInstance" << endl; cout << "---------------------------------" << endl; // convert a potential fully qualified reference into a local reference // (class name and keys only). CIMObjectPath localReference = CIMObjectPath( String(), String(), instanceReference.getClassName(), instanceReference.getKeyBindings()); // instance index corresponds to reference index for(Uint32 i = 0, n = _instanceNames.size(); i < n; i++) { if(localReference == _instanceNames[i]) { throw CIMObjectAlreadyExistsException( localReference.toString()); } } // begin processing the request handler.processing(); // add the new instance to the array _instances.append(instanceObject); _instanceNames.append(instanceReference); // deliver the new instance handler.deliver(_instanceNames[_instanceNames.size() - 1]); // complete processing the request handler.complete(); }
/***************************************************************************** * * Implementation of InstanceProvider enumerateInstanceNames method * *****************************************************************************/ void InteropProvider::enumerateInstanceNames( const OperationContext & context, const CIMObjectPath & classReference, ObjectPathResponseHandler & handler) { PEG_METHOD_ENTER(TRC_CONTROLPROVIDER, "InteropProvider::enumerateInstanceNames()"); initProvider(); PEG_TRACE((TRC_CONTROLPROVIDER, Tracer::LEVEL4, "%s enumerateInstanceNames. classReference= %s", thisProvider, (const char *) classReference.toString().getCString())); // test for legal namespace for this provider. Exception if not // namespaceSupported(classReference); // NOTE: Above is commented out because the routing tables will always // do the right thing and that's the only way requests get here. // begin processing the request handler.processing(); // Utilize the local enumeration method to retrieve the instances and // extract the instance names. Array<CIMInstance> instances = localEnumerateInstances( context, classReference, CIMPropertyList()); for (Uint32 i = 0 ; i < instances.size() ; i++) { handler.deliver(instances[i].getPath()); } handler.complete(); PEG_METHOD_EXIT(); }
Uint32 _testAssociators( CIMClient& client, CIMName assocClass, CIMObjectPath instancePath) { if (verbose) { cout << "\nAssociation Class: " << assocClass.getString() << endl; cout << "\nObject Name: " << instancePath.toString() << endl; } CIMName resultClass; String role; String resultRole; // Get the CIM instances that are associated with the specified source // instance via an instance of the AssocClass // Array<CIMObject> resultObjects = client.associators(NAMESPACE, instancePath, assocClass, resultClass, role, resultRole); Uint32 size = resultObjects.size(); if (verbose) { if (size > 0) { cout << " \n " << assocClass.getString() << " :: "; for (Uint32 i = 0; i < size ; ++i) { cout << resultObjects[i].getPath().toString(); } cout << endl; } } return size; }
Str(const CIMObjectPath& x) : _cstr(x.toString().getCString()) { }
PEGASUS_NAMESPACE_BEGIN /***************************************************************************** * * Implementation of AssociationProvider associators method * *****************************************************************************/ void InteropProvider::associators( const OperationContext & context, const CIMObjectPath & objectName, const CIMName & associationClass, const CIMName & resultClass, const String & role, const String & resultRole, const Boolean includeQualifiers, const Boolean includeClassOrigin, const CIMPropertyList & propertyList, ObjectResponseHandler & handler) { PEG_METHOD_ENTER(TRC_CONTROLPROVIDER, "InteropProvider::associators()"); initProvider(); PEG_TRACE((TRC_CONTROLPROVIDER, Tracer::LEVEL4, "%s associators. objectName= %s, assocClass= %s resultClass= %s " "role= %s resultRole %s, includeQualifiers= %s, " "includeClassOrigin= %s, PropertyList= %s", thisProvider, (const char *)objectName.toString().getCString(), (const char *)associationClass.getString().getCString(), (const char *)resultClass.getString().getCString(), (const char *)role.getCString(), (const char *)resultRole.getCString(), boolToString(includeQualifiers), boolToString(includeClassOrigin), (const char *)propertyListToString(propertyList).getCString())); handler.processing(); String originRole = role; String targetRole = resultRole; Uint32 numIterations = 1; // // The localReferences call retrieves instances of the desired association // class and sets the originRole and targetRole properties if currently // empty. // if (associationClass.equal(PEGASUS_CLASSNAME_PG_REFERENCEDPROFILE)) { if (originRole.size() == 0 && targetRole.size() == 0) { originRole = String("Antecedent"); targetRole = String("Dependent"); numIterations = 2; } } for (Uint32 i = 0; i < numIterations; ++i) { Array<CIMInstance> refs = localReferences( context, objectName, associationClass, originRole, targetRole, CIMPropertyList(), resultClass); if( refs.size() ) { Array<CIMInstance> refObjs = getReferencedInstances(refs,targetRole,context,propertyList); ConstArrayIterator<CIMInstance> refsIterator(refObjs); for(Uint32 i = 0; i < refsIterator.size(); i++) { handler.deliver(refsIterator[i]); } } if (numIterations == 2) { originRole = String("Dependent"); targetRole = String("Antecedent"); } } handler.complete(); PEG_METHOD_EXIT(); }
/***************************************************************************** * * Implementation of AssociationProvider references method * *****************************************************************************/ void InteropProvider::references( const OperationContext & context, const CIMObjectPath & objectName, const CIMName & resultClass, const String & role, const Boolean includeQualifiers, const Boolean includeClassOrigin, const CIMPropertyList & propertyList, ObjectResponseHandler & handler) { PEG_METHOD_ENTER(TRC_CONTROLPROVIDER, "InteropProvider::references()"); initProvider(); PEG_TRACE((TRC_CONTROLPROVIDER, Tracer::LEVEL4, "%s references. objectName= %s, resultClass= %s role= %s " "includeQualifiers= %s, includeClassOrigin= %s, PropertyList= %s", thisProvider, (const char *)objectName.toString().getCString(), (const char *)resultClass.getString().getCString(), (const char *)role.getCString(), boolToString(includeQualifiers), boolToString(includeClassOrigin), (const char *)propertyListToString(propertyList).getCString())); handler.processing(); String tmpRole = role; String tmpTarget; Uint32 numIterations = 1; // // Makes call to internal references method to get result, supplying the // role parameter, but obviously not setting a resultRole/target parameter. // if (resultClass.equal(PEGASUS_CLASSNAME_PG_REFERENCEDPROFILE)) { if (tmpRole.size() == 0) { tmpRole = String("Antecedent"); tmpTarget = String("Dependent"); numIterations = 2; } } for (Uint32 i = 0; i < numIterations; ++i) { Array<CIMInstance> refs = localReferences( context, objectName, resultClass, tmpRole, tmpTarget); for (Uint32 j = 0, n = refs.size(); j < n; ++j) { refs[j].filter(includeQualifiers, includeClassOrigin, propertyList); handler.deliver((CIMObject)refs[j]); } if (numIterations == 2) { tmpRole = String("Dependent"); tmpTarget = String("Antecedent"); } } handler.complete(); PEG_METHOD_EXIT(); }
/***************************************************************************** * * Implementation of AssociationProvider associatorNames method * *****************************************************************************/ void InteropProvider::associatorNames( const OperationContext & context, const CIMObjectPath & objectName, const CIMName & associationClass, const CIMName & resultClass, const String & role, const String & resultRole, ObjectPathResponseHandler & handler) { PEG_METHOD_ENTER(TRC_CONTROLPROVIDER, "InteropProvider::associatorNames()"); initProvider(); PEG_TRACE((TRC_CONTROLPROVIDER, Tracer::LEVEL4, "%s associatorNames.objectName= %s, assocClass= %s resultClass= %s " "role= %s resultRole = %s", thisProvider, (const char *)objectName.toString().getCString(), (const char *)associationClass.getString().getCString(), (const char *)resultClass.getString().getCString(), (const char *)role.getCString(), (const char *)resultRole.getCString())); handler.processing(); String originRole = role; String targetRole = resultRole; Uint32 numIterations = 1; // // The localReferences call retrieves instances of the desired association // class and sets the originRole and targetRole properties if currently // empty. // if (associationClass.equal(PEGASUS_CLASSNAME_PG_REFERENCEDPROFILE)) { if (originRole.size() == 0 && targetRole.size() == 0) { originRole = String("Antecedent"); targetRole = String("Dependent"); numIterations = 2; } } for (Uint32 i = 0; i < numIterations; ++i) { Array<CIMInstance> refs = localReferences( context, objectName, associationClass, originRole, targetRole, CIMPropertyList(), resultClass); for (Uint32 j = 0, n = refs.size(); j < n; ++j) { CIMInstance & currentRef = refs[j]; CIMObjectPath currentTarget = getRequiredValue<CIMObjectPath>( currentRef, targetRole); handler.deliver(currentTarget); } if (numIterations == 2) { originRole = String("Dependent"); targetRole = String("Antecedent"); } } handler.complete(); PEG_METHOD_EXIT(); }
/* ================================================================================ NAME : getInstance DESCRIPTION : Returns a single instance. ASSUMPTIONS : None PRE-CONDITIONS : POST-CONDITIONS : NOTES : LocalOnly, DeepInheritance and propertyList are not : respected by this provider. Localization is not supported PARAMETERS : ================================================================================ */ void BIPTLEpProvider::getInstance(const OperationContext &ctx, const CIMObjectPath &instanceName, const Boolean includeQualifiers, const Boolean includeClassOrigin, const CIMPropertyList &propertyList, InstanceResponseHandler &handler) { #ifdef DEBUG cout << "BIPTLEpProvider::getInstance(" << instanceName.toString() << ")" << endl; #endif CIMKeyBinding kb; CIMName className = instanceName.getClassName(); CIMNamespaceName nameSpace = instanceName.getNameSpace(); int i; int keysFound; // this will be used as a bit array String sn; // system name String lepName, // LAN Endpoint Name ipeName, // IP Protocol Endpoint Name refCCN, // Reference's Creation Class Name refName; // Reference's Name // Grab the system name if (IPInterface::getSystemName(sn) == false) sn = String::EMPTY; // Validate the classname _checkClass(className); // Extract the key values Array<CIMKeyBinding> kbArray = instanceName.getKeyBindings(); // Leave immediately if wrong number of keys if ( kbArray.size() != NUMKEYS_PG_BINDS_IP_TO_LAN_ENDPOINT ) throw CIMInvalidParameterException("Wrong number of keys"); // Validate the keys. // Each loop iteration will set a bit in keysFound when a valid // key is found. If the expected bits aren't all set when // the loop finishes, it's a problem for (i=0, keysFound=0; i < NUMKEYS_PG_BINDS_IP_TO_LAN_ENDPOINT; i++) { kb = kbArray[i]; CIMName keyName = kb.getName(); String keyValue = kb.getValue(); // Antecedent must match if (keyName.equal (PROPERTY_ANTECEDENT)) { if (_goodPERefKeys(keyValue, refCCN, refName) && String::equalNoCase(refCCN, CLASS_CIM_LAN_ENDPOINT.getString())) { keysFound |= 1; lepName = refName; } else throw CIMInvalidParameterException(keyValue+": bad value for key "+ keyName.getString()); } // Dependent must match else if (keyName.equal (PROPERTY_DEPENDENT)) { if (_goodPERefKeys(keyValue, refCCN, refName) && String::equalNoCase(refCCN, CLASS_CIM_IP_PROTOCOL_ENDPOINT.getString())) { keysFound |= 2; ipeName = refName; } else throw CIMInvalidParameterException(keyValue+": bad value for key "+ keyName.getString()); } // Key name was not recognized by any of the above tests else throw CIMInvalidParameterException(keyName.getString()+ ": Unrecognized key"); } // for // We could get here if we didn't get all the keys, which // could happen if the right number of keys were supplied, // and they all had valid names and values, but there were // any duplicates (e.g., two Names, no SystemName) if (keysFound != (1<<NUMKEYS_PG_BINDS_IP_TO_LAN_ENDPOINT)-1) throw CIMInvalidParameterException("Bad object name"); // Get the Interface List InterfaceList _ifList; IPInterface _ipif; // Make sure the LAN Endpoint name is embedded in the IP Protocol Endpoint // name. If we can find the request interface and if it's one that // binds to a LAN Interface, then we've found the right one, so // return it to the client. if (ipeName.find(lepName) != PEG_NOT_FOUND && _ifList.findInterface(ipeName, _ipif) && _ipif.bindsToLANInterface()) { /* Notify processing is starting. */ handler.processing(); /* Return the instance. */ handler.deliver(_constructInstance(className, nameSpace, _ipif)); /* Notify processing is complete. */ handler.complete(); return; } throw CIMObjectNotFoundException(ipeName+": No such IP Interface"); return; // can never execute, but required to keep compiler happy }
// CIMMethodProvider interface void DynamicIndicationProvider::invokeMethod( const OperationContext& context, const CIMObjectPath& objectReference, const CIMName& methodName, const Array<CIMParamValue>& inParameters, MethodResultResponseHandler& handler) { PEG_METHOD_ENTER(TRC_CONTROLPROVIDER, "DynamicIndicationProvider::invokeMethod"); Uint32 severity; String classname; String description; char buf[256]; PEG_TRACE((TRC_CONTROLPROVIDER, Tracer::LEVEL4,"Class %s", (const char*)objectReference.toString().getCString())); PEG_TRACE((TRC_CONTROLPROVIDER, Tracer::LEVEL4,"Method %s", (const char*)methodName.getString().getCString())); handler.processing(); if (String::equal( objectReference.getClassName().getString(), _DynamicIndicationClassName)) { if (String::equal(methodName.getString(), _DynamicIndicationMethod)) { try { ((inParameters[0]).getValue()).get(severity); ((inParameters[1]).getValue()).get(classname); ((inParameters[2]).getValue()).get(description); PEG_TRACE(( TRC_CONTROLPROVIDER, Tracer::LEVEL4, "severity:!%d!, classname!%s! description!%s!\n", severity, (const char*)classname.getCString(), (const char*)description.getCString())); } catch (...) { PEG_METHOD_EXIT(); throw CIMException(CIM_ERR_INVALID_PARAMETER); } } else { PEG_METHOD_EXIT(); throw CIMException(CIM_ERR_METHOD_NOT_FOUND); } } else { PEG_METHOD_EXIT(); throw CIMException(CIM_ERR_INVALID_CLASS); } sendIndication(severity, classname, description); unsigned int execStatus = 0; CIMValue cimRetValue(execStatus); handler.deliver(cimRetValue); handler.complete(); PEG_METHOD_EXIT(); }
/* ================================================================================ NAME : _goodPERefKeys DESCRIPTION : Checks to see if this is a value reference to a : Protocol Endpoint with good values for SCCN, SN, : and CCN. If it is, it returns the Name; : otherwise, it returns false. ASSUMPTIONS : None PRE-CONDITIONS : POST-CONDITIONS : NOTES : ================================================================================ */ Boolean BIPTLEpProvider::_goodPERefKeys(const CIMObjectPath &instName, String &rccn, // CreationClassName String &rname) // Name { #ifdef DEBUG cout << "BIPTLEpProvider::_goodPERefKeys(" << instName.toString() << ")" << endl; #endif int keysFound, // this will be used as a bit array i; Array<CIMKeyBinding> kbArray = instName.getKeyBindings(); if ( kbArray.size() != NUMKEYS_CIM_PROTOCOL_ENDPOINT) throw CIMInvalidParameterException("Wrong number of keys in reference"); for (i=0, keysFound=0; i < NUMKEYS_CIM_PROTOCOL_ENDPOINT; i++) { CIMKeyBinding kb = kbArray[i]; CIMName keyName = kb.getName(); String keyValue = kb.getValue(); // SystemCreationClassName if (keyName.equal (PROPERTY_SYSTEM_CREATION_CLASS_NAME)) { if (String::equalNoCase(keyValue, CLASS_CIM_UNITARY_COMPUTER_SYSTEM.getString()) || String::equal(keyValue, String::EMPTY) ) keysFound |= 1; else return false; // invalid value for SystemCreationClassName } // SystemName else if (keyName.equal (PROPERTY_SYSTEM_NAME)) { String sn; // System Name if (IPInterface::getSystemName(sn) == false) sn = String::EMPTY; if (String::equalNoCase(keyValue,sn) || String::equal(keyValue, String::EMPTY) ) keysFound |= 2; else return false; // invalid value for SystemName } // CreationClassName else if (keyName.equal (PROPERTY_CREATION_CLASS_NAME)) { rccn = keyValue; keysFound |= 4; } // Name must be a valid IP interface, but we will know that later // For now, just verify that it's present else if (keyName.equal (PROPERTY_NAME)) { rname = keyValue; keysFound |= 8; } // Key name was not recognized by any of the above tests else return false; } // for // We could get here if we didn't get all the keys, which // could happen if the right number of keys were supplied, // and they all had valid names and values, but there were // any duplicates (e.g., two Names, no SystemName) if (keysFound != (1<<NUMKEYS_CIM_PROTOCOL_ENDPOINT)-1) return false; #ifdef DEBUG cout << "BIPTLEpProvider::_goodPERefKeys() - success!" << endl; #endif return true; }
void test01() { { String on1; on1 = "//atp:77/root/cimv25:" "TennisPlayer.last=\"Rafter\",first=\"Patrick\""; String on2; on2 = "//atp:77/root/cimv25:" "TennisPlayer.first=\"Patrick\",last=\"Rafter\""; CIMObjectPath r = on1; PEGASUS_TEST_ASSERT(r.toString() != on1); PEGASUS_TEST_ASSERT(r.toString() == on2); CIMObjectPath r2 = r; CIMObjectPath r3 = CIMObjectPath ("//atp:77/root/cimv25:" "TennisPlayer.first=\"Chris\",last=\"Evert\""); if (verbose) { XmlWriter::printValueReferenceElement(r, false); cout << r.toString() << endl; } Buffer mofOut; MofWriter::appendValueReferenceElement(mofOut, r); r.clear(); } { CIMObjectPath r1 = CIMObjectPath ("MyClass.z=true,y=1234,x=\"Hello World\""); CIMObjectPath r2 = CIMObjectPath ("myclass.X=\"Hello World\",Z=true,Y=1234"); CIMObjectPath r3 = CIMObjectPath ("myclass.X=\"Hello\",Z=true,Y=1234"); // cout << r1.toString() << endl; // cout << r2.toString() << endl; PEGASUS_TEST_ASSERT(r1 == r2); PEGASUS_TEST_ASSERT(r1 != r3); } // Test case independence and order independence of parameters. { CIMObjectPath r1 = CIMObjectPath ("X.a=123,b=true"); CIMObjectPath r2 = CIMObjectPath ("x.B=TRUE,A=123"); PEGASUS_TEST_ASSERT(r1 == r2); PEGASUS_TEST_ASSERT(r1.makeHashCode() == r2.makeHashCode()); CIMObjectPath r3 = CIMObjectPath ("x.B=TRUE,A=123,c=FALSE"); PEGASUS_TEST_ASSERT(r1 != r3); String keyValue; Array<CIMKeyBinding> kbArray; { Boolean found = false; kbArray = r3.getKeyBindings(); for (Uint32 i = 0; i < kbArray.size(); i++) { if (verbose) { cout << "keyName= " << kbArray[i].getName().getString() << " Value= " << kbArray[i].getValue() << endl; } if ( kbArray[i].getName() == CIMName ("B") ) { keyValue = kbArray[i].getValue(); if(keyValue == "TRUE") found = true; } } if(!found) { cerr << "Key Binding Test error " << endl; exit(1); } //ATTN: KS 12 May 2002 P3 DEFER - keybinding manipulation. too // simplistic. // This code demonstrates that it is not easy to manipulate and // test keybindings. Needs better tool both in CIMObjectPath and // separate. } } // Test building from component parts of CIM Reference. { CIMObjectPath r1 ("atp:77", CIMNamespaceName ("root/cimv25"), CIMName ("TennisPlayer")); CIMObjectPath r2 ("//atp:77/root/cimv25:TennisPlayer."); //cout << "r1 " << r1.toString() << endl; //cout << "r2 " << r2.toString() << endl; PEGASUS_TEST_ASSERT(r1 == r2); PEGASUS_TEST_ASSERT(r1.toString() == r2.toString()); } { String hostName = "atp:77"; String nameSpace = "root/cimv2"; String className = "tennisplayer"; CIMObjectPath r1; r1.setHost(hostName); r1.setNameSpace(nameSpace); r1.setClassName(className); PEGASUS_TEST_ASSERT(r1.getClassName().equal(CIMName ("TENNISPLAYER"))); PEGASUS_TEST_ASSERT(!r1.getClassName().equal(CIMName ("blob"))); String newHostName = r1.getHost(); //cout << "HostName = " << newHostName << endl; CIMObjectPath r2 (hostName, nameSpace, className); PEGASUS_TEST_ASSERT(r1 == r2); } // Test cases for the Hostname. CIMObjectPaths allows the // host to include the domain. Eg. xyz.company.com // First, try a good hostname CIMObjectPath h0("//usoPen-9.ustA-1-a.org:77/root/cimv25:" "TennisPlayer.first=\"Chris\",last=\"Evert\""); CIMObjectPath h1("//usoPen-9:77/root/cimv25:" "TennisPlayer.first=\"Chris\",last=\"Evert\""); CIMObjectPath h2("//usoPen-9/root/cimv25:" "TennisPlayer.first=\"Chris\",last=\"Evert\""); CIMObjectPath h3("//usoPen-9.ustA-1-a.org:0/root/cimv25:" "TennisPlayer.first=\"Chris\",last=\"Evert\""); CIMObjectPath h4("//usoPen-9.ustA-1-a.org:9876/root/cimv25:" "TennisPlayer.first=\"Chris\",last=\"Evert\""); CIMObjectPath h5("//usoPen-9.ustA-1-a.org:65535/root/cimv25:" "TennisPlayer.first=\"Chris\",last=\"Evert\""); CIMObjectPath h6("//usopen-9.usta-1-a.1org:77/root/cimv25:" "TennisPlayer.first=\"Chris\",last=\"Evert\""); CIMObjectPath h7("//192.168.1.com:77/root/cimv25:" "TennisPlayer.first=\"Chris\",last=\"Evert\""); CIMObjectPath h8("//192.168.0.org/root/cimv25:" "TennisPlayer.first=\"Chris\",last=\"Evert\""); CIMObjectPath h9("//192.168.1.80.com:77/root/cimv25:" "TennisPlayer.first=\"Chris\",last=\"Evert\""); CIMObjectPath h10("//192.168.0.80.org/root/cimv25:" "TennisPlayer.first=\"Chris\",last=\"Evert\""); CIMObjectPath h11("//192.168.1.80.255.com:77/root/cimv25:" "TennisPlayer.first=\"Chris\",last=\"Evert\""); CIMObjectPath h12("//192.168.0.80.254.org/root/cimv25:" "TennisPlayer.first=\"Chris\",last=\"Evert\""); CIMObjectPath h13("//192.168.257.80.com:77/root/cimv25:" "TennisPlayer.first=\"Chris\",last=\"Evert\""); CIMObjectPath h14("//192.256.0.80.org/root/cimv25:" "TennisPlayer.first=\"Chris\",last=\"Evert\""); CIMObjectPath h15("//localhost/root/cimv25:" "TennisPlayer.first=\"Chris\",last=\"Evert\""); CIMObjectPath h16("//ou812/root/cimv25:" "TennisPlayer.first=\"Chris\",last=\"Evert\""); CIMObjectPath h17("//u812/root/cimv25:" "TennisPlayer.first=\"Chris\",last=\"Evert\""); // Hostname with '_' character support checks, see bug#2556. CIMObjectPath h18("//_atp:9999/_root/_cimv25:_TennisPlayer"); CIMObjectPath h19("//a_tp/_root/_cimv25:_TennisPlayer"); CIMObjectPath h20("//atp_:9999/_root/_cimv25:_TennisPlayer"); CIMObjectPath h21("//atp_-9:9999/_root/_cimv25:_TennisPlayer"); CIMObjectPath h22( "//_a_t_p_-9.ustA-1-a.org:9999/_root/_cimv25:_TennisPlayer"); CIMObjectPath h23("//_/root/cimv25:_TennisPlayer"); CIMObjectPath h24("//_______/root/cimv25:_TennisPlayer"); // try IPAddress as hostname which should be good CIMObjectPath h_ip0("//192.168.1.80:77/root/cimv25:" "TennisPlayer.first=\"Chris\",last=\"Evert\""); CIMObjectPath h_ip1("//192.168.0.255/root/cimv25:" "TennisPlayer.first=\"Chris\",last=\"Evert\""); // Try IPv6 Addresses. CIMObjectPath ip6_1("//[::1]:77/root/cimv25:" "TennisPlayer.first=\"Chris\",last=\"Evert\""); CIMObjectPath ip6_2("//[::ffff:192.1.2.3]:77/root/cimv25:" "TennisPlayer.first=\"Chris\",last=\"Evert\""); CIMObjectPath ip6_3("//[fffe:233:321:234d:e45:fad4:78:12]:77/root/cimv25:" "TennisPlayer.first=\"Chris\",last=\"Evert\""); CIMObjectPath ip6_4("//[fffe::]:77/root/cimv25:" "TennisPlayer.first=\"Chris\",last=\"Evert\""); Boolean errorDetected = false; // Invalid IPV6 Addresses try { // IPv6 addresses must be enclosed in brackets CIMObjectPath ip6_mb("//fffe::12ef:127/root/cimv25:" "TennisPlayer.first=\"Chris\",last=\"Evert\""); } catch (const Exception&) { errorDetected = true; } PEGASUS_TEST_ASSERT(errorDetected); errorDetected = false; try { // IPv6 address invalid CIMObjectPath ip6_invalid("//[fffe::sd:77]/root/cimv25:" "TennisPlayer.first=\"Chris\",last=\"Evert\""); } catch (const Exception&) { errorDetected = true; } PEGASUS_TEST_ASSERT(errorDetected); errorDetected = false; try { //Port number out of range. CIMObjectPath h_Port("//usoPen-9.ustA-1-a.org:9876543210/root/cimv25:" "TennisPlayer.first=\"Chris\",last=\"Evert\""); } catch (const Exception&) { errorDetected = true; } PEGASUS_TEST_ASSERT(errorDetected); errorDetected = false; try { //Port number out of range. CIMObjectPath h_Port("//usoPen-9.ustA-1-a.org:65536/root/cimv25:" "TennisPlayer.first=\"Chris\",last=\"Evert\""); } catch (const Exception&) { errorDetected = true; } PEGASUS_TEST_ASSERT(errorDetected); errorDetected = false; try { //Port number out of range. CIMObjectPath h_Port("//usoPen-9.ustA-1-a.org:100000/root/cimv25:" "TennisPlayer.first=\"Chris\",last=\"Evert\""); } catch (const Exception&) { errorDetected = true; } PEGASUS_TEST_ASSERT(errorDetected); errorDetected = false; try { //more than three digits in an octect CIMObjectPath h_ErrIp0("//192.1600008.1.80:77/root/cimv25:" "TennisPlayer.first=\"Chris\",last=\"Evert\""); } catch (const Exception&) { errorDetected = true; } PEGASUS_TEST_ASSERT(errorDetected); errorDetected = false; try { // Octet out of range CIMObjectPath op("//192.168.256.80:77/root/cimv25:" "TennisPlayer.first=\"Chris\",last=\"Evert\""); } catch (const Exception&) { errorDetected = true; } PEGASUS_TEST_ASSERT(errorDetected); errorDetected = false; try { // Missing port is okay, needs be ignored CIMObjectPath op("//192.168.1.80:/root/cimv25:" "TennisPlayer.first=\"Chris\",last=\"Evert\""); } catch (const Exception&) { errorDetected = true; } PEGASUS_TEST_ASSERT(!errorDetected); errorDetected = false; try { // Too many octets CIMObjectPath op("//192.168.1.80.12/root/cimv25:" "TennisPlayer.first=\"Chris\",last=\"Evert\""); } catch (const Exception&) { errorDetected = true; } PEGASUS_TEST_ASSERT(errorDetected); errorDetected = false; try { // Too few octets CIMObjectPath op("//192.168.80:77/root/cimv25:" "TennisPlayer.first=\"Chris\",last=\"Evert\""); } catch (const Exception&) { errorDetected = true; } PEGASUS_TEST_ASSERT(errorDetected); errorDetected = false; try { // Missing port is okay, needs be ignored CIMObjectPath op("//usopen-9.usta-1-a.org:/root/cimv25:" "TennisPlayer.first=\"Chris\",last=\"Evert\""); } catch (Exception&) { errorDetected = true; } PEGASUS_TEST_ASSERT(!errorDetected); errorDetected = false; try { // Hostname (IP) without trailing '/' (with port) CIMObjectPath op("//192.168.256.80:77"); } catch (const Exception&) { errorDetected = true; } PEGASUS_TEST_ASSERT(errorDetected); errorDetected = false; try { // Hostname (IP) without trailing '/' (without port) CIMObjectPath op("//192.168.256.80"); } catch (const Exception&) { errorDetected = true; } PEGASUS_TEST_ASSERT(errorDetected); errorDetected = false; try { // Hostname without trailing '/' (with port) CIMObjectPath op("//usopen-9.usta-1-a.org:77"); } catch (const Exception&) { errorDetected = true; } PEGASUS_TEST_ASSERT(errorDetected); errorDetected = false; try { // Hostname without trailing '/' (without port) CIMObjectPath op("//usopen-9.usta-1-a.org"); } catch (const Exception&) { errorDetected = true; } PEGASUS_TEST_ASSERT(errorDetected); errorDetected = false; try { // Invalid first character CIMObjectPath op("//+usopen-9.usta-1-a.1org:77/root/cimv25:" "TennisPlayer.first=\"Chris\",last=\"Evert\""); } catch (Exception&) { errorDetected = true; } PEGASUS_TEST_ASSERT(errorDetected); errorDetected = false; try { // Non-alphanum char (?) CIMObjectPath op("//usopen-9.usta?-1-a.org:77/root/cimv25:" "TennisPlayer.first=\"Chris\",last=\"Evert\""); } catch (Exception&) { errorDetected = true; } PEGASUS_TEST_ASSERT(errorDetected); errorDetected = false; try { // Leading dot CIMObjectPath op("//.usopen-9.usta-1-a.org:77/root/cimv25:" "TennisPlayer.first=\"Chris\",last=\"Evert\""); } catch (Exception&) { errorDetected = true; } PEGASUS_TEST_ASSERT(errorDetected); errorDetected = false; try { // Dot in the wrong spot (before a -) CIMObjectPath op("//usopen.-9.usta-1-a.org:77/root/cimv25:" "TennisPlayer.first=\"Chris\",last=\"Evert\""); } catch (Exception&) { errorDetected = true; } PEGASUS_TEST_ASSERT(errorDetected); errorDetected = false; try { // Two dots in a row CIMObjectPath op("//usopen-9.usta-1-a..org:77/root/cimv25:" "TennisPlayer.first=\"Chris\",last=\"Evert\""); } catch (Exception&) { errorDetected = true; } PEGASUS_TEST_ASSERT(errorDetected); errorDetected = false; try { // Trailing dot CIMObjectPath op("//usopen-9.usta-1-a.org.:77/root/cimv25:" "TennisPlayer.first=\"Chris\",last=\"Evert\""); } catch (Exception&) { errorDetected = true; } PEGASUS_TEST_ASSERT(errorDetected); }
String CIMObjectPath::_toStringCanonical() const { CIMObjectPath ref; *ref._rep = *this->_rep; // Normalize hostname by changing to lower case ref._rep->_host.toLower(); // ICU_TODO: // Normalize namespace by changing to lower case if (!ref._rep->_nameSpace.isNull()) { String nameSpaceLower = ref._rep->_nameSpace.getString(); nameSpaceLower.toLower(); // ICU_TODO: ref._rep->_nameSpace = nameSpaceLower; } // Normalize class name by changing to lower case if (!ref._rep->_className.isNull()) { String classNameLower = ref._rep->_className.getString(); classNameLower.toLower(); // ICU_TODO: ref._rep->_className = classNameLower; } for (Uint32 i = 0, n = ref._rep->_keyBindings.size(); i < n; i++) { // Normalize key binding name by changing to lower case if (!ref._rep->_keyBindings[i]._rep->_name.isNull()) { String keyBindingNameLower = ref._rep->_keyBindings[i]._rep->_name.getString(); keyBindingNameLower.toLower(); // ICU_TODO: ref._rep->_keyBindings[i]._rep->_name = keyBindingNameLower; } // Normalize the key value switch (ref._rep->_keyBindings[i]._rep->_type) { case CIMKeyBinding::REFERENCE: try { // Convert reference to CIMObjectPath and recurse ref._rep->_keyBindings[i]._rep->_value = CIMObjectPath(ref._rep->_keyBindings[i]._rep->_value). _toStringCanonical(); } catch (Exception&) { // Leave value unchanged if the CIMObjectPath parsing fails } break; case CIMKeyBinding::BOOLEAN: // Normalize the boolean string by changing to lower case ref._rep->_keyBindings[i]._rep->_value.toLower(); // ICU_TODO: break; case CIMKeyBinding::NUMERIC: // Normalize the numeric string by converting to integer and back Uint64 uValue; Sint64 sValue; // First try converting to unsigned integer if (StringConversion::stringToUnsignedInteger( ref._rep->_keyBindings[i]._rep->_value.getCString(), uValue)) { char buffer[32]; // Should need 21 chars max sprintf(buffer, "%" PEGASUS_64BIT_CONVERSION_WIDTH "u", uValue); ref._rep->_keyBindings[i]._rep->_value = String(buffer); } // Next try converting to signed integer else if (StringConversion::stringToSignedInteger( ref._rep->_keyBindings[i]._rep->_value.getCString(), sValue)) { char buffer[32]; // Should need 21 chars max sprintf(buffer, "%" PEGASUS_64BIT_CONVERSION_WIDTH "d", sValue); ref._rep->_keyBindings[i]._rep->_value = String(buffer); } // Leave value unchanged if it cannot be converted to an integer break; default: // CIMKeyBinding::STRING // No normalization required for STRING break; } } // Note: key bindings are sorted when set in the CIMObjectPath return ref.toString(); }