version 1.55, 2005/08/11 18:01:28
|
version 1.56, 2005/08/17 20:43:08
|
|
|
| |
const char * thisProvider = "InteropProvider"; | const char * thisProvider = "InteropProvider"; |
| |
|
// This Mutex serializes access to the instance change CIM requests. Keeps from mixing |
|
// instance creates, modifications, and deletes. This keeps the provider from |
|
// simultaneously execute creates, modifications, and deletes of instances. While |
|
// these operations are largely protected by the locking mechanisms of the |
|
// repository this mutex guarantees that the provider will not simultaneously |
|
// execute the instance change operations. |
|
Mutex changeControlMutex; |
/** | /** |
The constants representing the class names we process | The constants representing the class names we process |
*/ | */ |
|
|
// return; | // return; |
if (path.getNameSpace().getString() != PEGASUS_NAMESPACENAME_INTEROP) | if (path.getNameSpace().getString() != PEGASUS_NAMESPACENAME_INTEROP) |
{ | { |
throw PEGASUS_CIM_EXCEPTION(CIM_ERR_NOT_SUPPORTED, |
throw CIMNotSupportedException( |
path.getClassName().getString()); | path.getClassName().getString()); |
} | } |
else | else |
|
|
if (!v1.isNull()) | if (!v1.isNull()) |
v1.get(output); | v1.get(output); |
} | } |
|
else |
|
throw CIMInvalidParameterException( |
|
"Incorrect Property Type for Property " + propertyName.getString()); |
} | } |
return(output); | return(output); |
} | } |
|
|
if ((theValue.getType ()) != expectedType) | if ((theValue.getType ()) != expectedType) |
propertyError = true; | propertyError = true; |
} | } |
|
|
} | } |
PEG_METHOD_EXIT (); | PEG_METHOD_EXIT (); |
return(propertyError); | return(propertyError); |
|
|
} | } |
instance.setPath(instancePath); | instance.setPath(instancePath); |
} | } |
|
|
PEG_METHOD_EXIT(); | PEG_METHOD_EXIT(); |
return(instance); | return(instance); |
} | } |
|
|
{ | { |
PEG_METHOD_EXIT(); | PEG_METHOD_EXIT(); |
// This is poor exception since it reflects internal error. Do error log | // This is poor exception since it reflects internal error. Do error log |
throw PEGASUS_CIM_EXCEPTION (CIM_ERR_NOT_SUPPORTED, |
throw CIMNotSupportedException( |
"Namespace attribute rtnd error for key " + key + "expected " + | "Namespace attribute rtnd error for key " + key + "expected " + |
nameSpace.getString()+ value + " in " + String(thisProvider)); | nameSpace.getString()+ value + " in " + String(thisProvider)); |
} | } |
|
|
} | } |
Boolean _completeCIMNamespaceKeys(CIMInstance& instance) | Boolean _completeCIMNamespaceKeys(CIMInstance& instance) |
{ | { |
|
|
PEG_METHOD_ENTER(TRC_CONTROLPROVIDER, | PEG_METHOD_ENTER(TRC_CONTROLPROVIDER, |
"InteropProvider::_completeCIMNamespaceKeys"); | "InteropProvider::_completeCIMNamespaceKeys"); |
| |
|
|
CIM_NAMESPACE_PROPERTY_SYSTEMCREATIONCLASSNAME, | CIM_NAMESPACE_PROPERTY_SYSTEMCREATIONCLASSNAME, |
System::getSystemCreationClassName ())) | System::getSystemCreationClassName ())) |
{ | { |
|
|
propertyName = CIM_NAMESPACE_PROPERTY_SYSTEMCREATIONCLASSNAME; | propertyName = CIM_NAMESPACE_PROPERTY_SYSTEMCREATIONCLASSNAME; |
valid = false; | valid = false; |
} | } |
|
|
{ | { |
PEG_METHOD_ENTER(TRC_CONTROLPROVIDER, "InteropProvider::createInstance()"); | PEG_METHOD_ENTER(TRC_CONTROLPROVIDER, "InteropProvider::createInstance()"); |
| |
|
AutoMutex autoMut(changeControlMutex); |
|
|
Tracer::trace(TRC_CONTROLPROVIDER, Tracer::LEVEL4, | Tracer::trace(TRC_CONTROLPROVIDER, Tracer::LEVEL4, |
"%s createInstance. InstanceReference= %s", | "%s createInstance. InstanceReference= %s", |
thisProvider, | thisProvider, |
|
|
{ | { |
PEG_METHOD_ENTER(TRC_CONTROLPROVIDER, "InteropProvider::deleteInstance"); | PEG_METHOD_ENTER(TRC_CONTROLPROVIDER, "InteropProvider::deleteInstance"); |
| |
|
AutoMutex autoMut(changeControlMutex); |
|
|
Tracer::trace(TRC_CONTROLPROVIDER, Tracer::LEVEL4, | Tracer::trace(TRC_CONTROLPROVIDER, Tracer::LEVEL4, |
"%s deleteInstance. instanceName= %s", | "%s deleteInstance. instanceName= %s", |
thisProvider, | thisProvider, |
|
|
| |
// create reference from host, namespace, class components of | // create reference from host, namespace, class components of |
// instance name | // instance name |
|
|
CIMObjectPath ref; | CIMObjectPath ref; |
ref.setHost(instanceName.getHost()); | ref.setHost(instanceName.getHost()); |
ref.setClassName(instanceName.getClassName()); | ref.setClassName(instanceName.getClassName()); |
|
|
| |
// deliver a single instance if found. | // deliver a single instance if found. |
CIMInstance rtnInstance; | CIMInstance rtnInstance; |
|
|
for (Uint32 i = 0 ; i < instances.size() ; i++) | for (Uint32 i = 0 ; i < instances.size() ; i++) |
{ | { |
if (instanceName == instances[i].getPath()) | if (instanceName == instances[i].getPath()) |
|
|
| |
if (!myInstance.isUninitialized()) | if (!myInstance.isUninitialized()) |
handler.deliver(myInstance); | handler.deliver(myInstance); |
|
else |
|
throw CIMObjectNotFoundException(instanceName.toString()); |
| |
handler.complete(); | handler.complete(); |
} | } |
|
|
includeQualifiers, | includeQualifiers, |
includeClassOrigin, | includeClassOrigin, |
propertyList); | propertyList); |
|
|
instances.append(instance); | instances.append(instance); |
} | } |
| |
|
|
PEG_METHOD_EXIT(); | PEG_METHOD_EXIT(); |
} | } |
| |
void InteropProvider::modifyObjectManagerInstance(const OperationContext & context, |
/** Determies if an instance modification is to be allowed. This includes |
|
tests to determine the validity of the modified instance, the property |
|
list provided, if qualifier modification was requested. |
|
@param context |
|
@param instanceReference CIMObjectPath defining the path of the instance |
|
to be modified. |
|
@param modifiedIns CIMInstance containing the modifications |
|
@param includeQualifiers Boolean defining if qualifiers are to be modified. |
|
@param propertyList CIMPropertyList provided with the request |
|
@param allowedModifyProperties CIMPropertyList defining properties that |
|
are allowed to be modified by the provider |
|
@return true if there are modifications that can be made. Note that there |
|
is an additional decision to be made by the user whether the modifiedIns |
|
includes all of the properties or they are to be set to default. |
|
@exception CIM_ERR_NOT_SUPPORTED if the specified modification is not supported |
|
@exception CIM_ERR_INVALID_PARAMETER if the modifiedInstance is invalid |
|
*/ |
|
Boolean InteropProvider::isModifyAllowed(const OperationContext & context, |
const CIMObjectPath & instanceReference, | const CIMObjectPath & instanceReference, |
const CIMInstance& modifiedIns, | const CIMInstance& modifiedIns, |
const Boolean includeQualifiers, | const Boolean includeQualifiers, |
const CIMPropertyList& propertyList, | const CIMPropertyList& propertyList, |
ResponseHandler & handler) |
const CIMPropertyList& allowedModifyProperties) |
{ | { |
PEG_METHOD_ENTER(TRC_CONTROLPROVIDER, |
// if property list size does not match allowed list. |
"InteropProvider::modifyObjectManagerInstance"); |
if ((propertyList.size() > allowedModifyProperties.size()) |
|
|| (propertyList.isNull()) |
|
) |
|
{ |
|
throw CIMNotSupportedException( |
|
"Only Modification of " + _toStringPropertyList(allowedModifyProperties) |
|
+ " allowed"); |
|
} |
|
// property list indicates nothing to modify return false |
|
if (propertyList.size() == 0) |
|
{ |
|
return(false); |
|
} |
| |
// the only allowed modification is this one property, statistical data |
// DO NOT allow any qualifier modifications. |
|
if (includeQualifiers) |
|
{ |
|
throw CIMNotSupportedException( |
|
"Qualifier Modification not allowed"); |
|
} |
| |
if (modifiedIns.findProperty(OM_GATHERSTATISTICALDATA) != PEG_NOT_FOUND) |
// Assure that nothing is in the propertylist and NOT in |
|
// the allowed list. |
|
Array<CIMName> allowedArray = allowedModifyProperties.getPropertyNameArray(); |
|
for (Uint32 i = 0 ; i < propertyList.size() ; i++) |
|
{ |
|
if (!Contains(allowedArray, propertyList[i])) |
|
{ |
|
throw CIMNotSupportedException( |
|
"Only Modification of " + _toStringPropertyList(allowedModifyProperties) |
|
+ " allowed"); |
|
} |
|
} |
|
// We have something to modify. Property List is valid |
|
return(true); |
|
} |
|
/** Modify the existing object Manager Object. Only a single property modification |
|
is allowed, the statistical data setting. Any other change is rejected |
|
with an exception |
|
@param instanceReference - Reference for the instance to be modified. |
|
@param modifiedIns CIMInstance defining the change. If this includes more than |
|
a single property, the propertyList must specify modification only of the |
|
statisticaldata property. |
|
@includeQualifiers Boolean which must be false unless there are no qualifiers |
|
in the modifiedIns. |
|
@propertyList CIMPropertyList defining the property to be modified if there |
|
is more than one property in the modifiedIns. |
|
@Exceptions CIMInvalidParameterException if the parameters are not valid for |
|
the modification. |
|
*/ |
|
void InteropProvider::modifyObjectManagerInstance(const OperationContext & context, |
|
const CIMObjectPath & instanceReference, |
|
const CIMInstance& modifiedIns, |
|
const Boolean includeQualifiers, |
|
const CIMPropertyList& propertyList) |
{ | { |
// the following is a temporary hack to set the value of the statistics |
PEG_METHOD_ENTER(TRC_CONTROLPROVIDER, |
// gathering function dynamically. We simply get the value from input |
"InteropProvider::modifyObjectManagerInstance"); |
// and call the internal method to set it each time this object is |
|
// built. |
// Modification only allowed when Performance staticistics are active |
#ifndef PEGASUS_DISABLE_PERFINST | #ifndef PEGASUS_DISABLE_PERFINST |
Boolean statisticsFlag = _getPropertyValue(modifiedIns, |
// the only allowed modification is one property, statistical data |
OM_GATHERSTATISTICALDATA, false); |
Array<CIMName> plA; |
|
plA.append(CIMName(OM_GATHERSTATISTICALDATA)); |
|
CIMPropertyList allowedModifyPropertyList(plA); |
|
|
|
// returns only if no exception and there is property to modify. |
|
if (isModifyAllowed(context, instanceReference, modifiedIns, |
|
includeQualifiers, propertyList, allowedModifyPropertyList)) |
|
{ |
CIMInstance instance; | CIMInstance instance; |
instance = _getInstanceCIMObjectManager(instanceReference, | instance = _getInstanceCIMObjectManager(instanceReference, |
true, true, CIMPropertyList()); | true, true, CIMPropertyList()); |
| |
if (statisticsFlag != _getPropertyValue(instance, OM_GATHERSTATISTICALDATA, false)) |
CIMObjectPath tmpPath; |
|
tmpPath.setClassName(instanceReference.getClassName()); |
|
tmpPath.setKeyBindings(instanceReference.getKeyBindings()); |
|
if (!(tmpPath == instance.getPath()) ) |
|
throw CIMObjectNotFoundException(instanceReference.toString()); |
|
} |
|
else // nothing to modify. return |
|
{ |
|
return; |
|
} |
|
Boolean statisticsFlag; |
|
CIMInstance myInstance; |
|
|
|
// We modify only if this property exists. |
|
// could either use the property from modifiedIns or simply replace |
|
// value in property from object manager. |
|
if (modifiedIns.findProperty(OM_GATHERSTATISTICALDATA) != PEG_NOT_FOUND) |
{ | { |
// set the changed property into the |
myInstance = _getInstanceCIMObjectManager(instanceReference, |
_setPropertyValue(instance, OM_GATHERSTATISTICALDATA, statisticsFlag); |
false, false, propertyList); |
// Modify the object on disk |
statisticsFlag = _getPropertyValue(modifiedIns, OM_GATHERSTATISTICALDATA, false); |
|
// set the changed property into the instance |
|
_setPropertyValue(myInstance, OM_GATHERSTATISTICALDATA, statisticsFlag); |
|
} |
|
else |
|
{ |
|
// if statistics property not in place, simply exit. Nothing to do |
|
// not considered an error |
|
PEG_METHOD_EXIT(); |
|
return; |
|
} |
|
// Modify the instance on disk |
try | try |
{ | { |
_repository->modifyInstance(instanceReference.getNameSpace(), | _repository->modifyInstance(instanceReference.getNameSpace(), |
instance ); |
myInstance, false, propertyList); |
} | } |
catch(const CIMException&) | catch(const CIMException&) |
{ | { |
// ATTN: KS generate log error if this not possible |
|
PEG_METHOD_EXIT(); | PEG_METHOD_EXIT(); |
throw; | throw; |
} | } |
catch(const Exception&) | catch(const Exception&) |
{ | { |
// ATTN: Generate log error. |
|
PEG_METHOD_EXIT(); | PEG_METHOD_EXIT(); |
throw; | throw; |
} | } |
|
|
(statisticsFlag? "true" : "false")); | (statisticsFlag? "true" : "false")); |
StatisticalData* sd = StatisticalData::current(); | StatisticalData* sd = StatisticalData::current(); |
sd->setCopyGSD(statisticsFlag); | sd->setCopyGSD(statisticsFlag); |
} |
PEG_METHOD_EXIT(); |
return; | return; |
#endif |
|
| |
} |
#else |
PEG_METHOD_EXIT(); | PEG_METHOD_EXIT(); |
// ATTN Expand this definition to be more precise since it allows only mod of |
|
// one property and that property MUST be in the instance to be modifiable. |
|
throw CIMNotSupportedException | throw CIMNotSupportedException |
(OM_GATHERSTATISTICALDATA.getString() + | (OM_GATHERSTATISTICALDATA.getString() + |
" modify operation not supported by Interop Provider"); | " modify operation not supported by Interop Provider"); |
|
#endif |
} | } |
//*************************************************************************** | //*************************************************************************** |
//*************************************************************************** | //*************************************************************************** |
|
|
PEG_METHOD_ENTER(TRC_CONTROLPROVIDER, | PEG_METHOD_ENTER(TRC_CONTROLPROVIDER, |
"InteropProvider::modifyInstance"); | "InteropProvider::modifyInstance"); |
| |
|
AutoMutex autoMut(changeControlMutex); |
|
|
Tracer::trace(TRC_CONTROLPROVIDER, Tracer::LEVEL4, | Tracer::trace(TRC_CONTROLPROVIDER, Tracer::LEVEL4, |
"%s modifyInstance. instanceReference= %s, includeQualifiers= %s, PropertyList= %s", | "%s modifyInstance. instanceReference= %s, includeQualifiers= %s, PropertyList= %s", |
thisProvider, | thisProvider, |
|
|
if (classEnum == CIM_OBJECTMANAGER) | if (classEnum == CIM_OBJECTMANAGER) |
{ | { |
modifyObjectManagerInstance(context, instanceReference,modifiedIns, | modifyObjectManagerInstance(context, instanceReference,modifiedIns, |
includeQualifiers, propertyList, handler); |
includeQualifiers, propertyList); |
// for the moment allow modification of the statistics property only | // for the moment allow modification of the statistics property only |
} | } |
| |
else if (classEnum == PG_CIMXMLCOMMUNICATIONMECHANISM) | else if (classEnum == PG_CIMXMLCOMMUNICATIONMECHANISM) |
{ | { |
|
|
PEG_METHOD_EXIT(); | PEG_METHOD_EXIT(); |
throw CIMNotSupportedException | throw CIMNotSupportedException |
(className.getString() + " not supported by Interop Provider"); |
(" Modification of " + className.getString() + " not supported by Interop Provider"); |
} | } |
else if (classEnum == PG_NAMESPACE) | else if (classEnum == PG_NAMESPACE) |
{ | { |