version 1.164, 2006/10/03 18:18:44
|
version 1.165, 2006/10/04 19:44:31
|
|
|
| |
//////////////////////////////////////////////////////////////////////////////// | //////////////////////////////////////////////////////////////////////////////// |
// | // |
|
// _beginInstanceTransaction() |
|
// |
|
// Creates rollback files to allow an incomplete transaction to be voided. |
|
// |
|
//////////////////////////////////////////////////////////////////////////////// |
|
|
|
void _beginInstanceTransaction( |
|
const String& indexFilePath, |
|
const String& dataFilePath) |
|
{ |
|
PEG_METHOD_ENTER(TRC_REPOSITORY, "_beginInstanceTransaction"); |
|
|
|
// |
|
// Begin the transaction (an incomplete transaction will cause |
|
// a rollback the next time an instance-oriented routine is invoked). |
|
// |
|
|
|
if (!InstanceIndexFile::beginTransaction(indexFilePath)) |
|
{ |
|
PEG_METHOD_EXIT(); |
|
throw PEGASUS_CIM_EXCEPTION_L(CIM_ERR_FAILED, |
|
MessageLoaderParms("Repository.CIMRepository.BEGIN_FAILED", |
|
"begin failed")); |
|
} |
|
|
|
if (!InstanceDataFile::beginTransaction(dataFilePath)) |
|
{ |
|
PEG_METHOD_EXIT(); |
|
throw PEGASUS_CIM_EXCEPTION_L(CIM_ERR_FAILED, |
|
MessageLoaderParms("Repository.CIMRepository.BEGIN_FAILED", |
|
"begin failed")); |
|
} |
|
|
|
PEG_METHOD_EXIT(); |
|
} |
|
|
|
//////////////////////////////////////////////////////////////////////////////// |
|
// |
|
// _commitInstanceTransaction() |
|
// |
|
// Removes the rollback files to complete the transaction. |
|
// |
|
//////////////////////////////////////////////////////////////////////////////// |
|
|
|
void _commitInstanceTransaction( |
|
const String& indexFilePath, |
|
const String& dataFilePath) |
|
{ |
|
PEG_METHOD_ENTER(TRC_REPOSITORY, "_commitInstanceTransaction"); |
|
|
|
// |
|
// Commit the transaction by removing the rollback files. |
|
// |
|
|
|
if (!InstanceIndexFile::commitTransaction(indexFilePath)) |
|
{ |
|
PEG_METHOD_EXIT(); |
|
throw PEGASUS_CIM_EXCEPTION_L(CIM_ERR_FAILED, |
|
MessageLoaderParms("Repository.CIMRepository.COMMIT_FAILED", |
|
"commit failed")); |
|
} |
|
|
|
if (!InstanceDataFile::commitTransaction(dataFilePath)) |
|
{ |
|
PEG_METHOD_EXIT(); |
|
throw PEGASUS_CIM_EXCEPTION_L(CIM_ERR_FAILED, |
|
MessageLoaderParms("Repository.CIMRepository.COMMIT_FAILED", |
|
"commit failed")); |
|
} |
|
|
|
PEG_METHOD_EXIT(); |
|
} |
|
|
|
//////////////////////////////////////////////////////////////////////////////// |
|
// |
|
// _rollbackInstanceTransaction() |
|
// |
|
// Restores instance index and data files to void an incomplete operation. |
|
// If there are no rollback files, this method has no effect. |
|
// |
|
//////////////////////////////////////////////////////////////////////////////// |
|
|
|
void _rollbackInstanceTransaction( |
|
const String& indexFilePath, |
|
const String& dataFilePath) |
|
{ |
|
PEG_METHOD_ENTER(TRC_REPOSITORY, "_rollbackInstanceTransaction"); |
|
|
|
if (!InstanceIndexFile::rollbackTransaction(indexFilePath)) |
|
{ |
|
PEG_METHOD_EXIT(); |
|
throw PEGASUS_CIM_EXCEPTION_L(CIM_ERR_FAILED, |
|
MessageLoaderParms("Repository.CIMRepository.ROLLBACK_FAILED", |
|
"rollback failed")); |
|
} |
|
|
|
if (!InstanceDataFile::rollbackTransaction(dataFilePath)) |
|
{ |
|
PEG_METHOD_EXIT(); |
|
throw PEGASUS_CIM_EXCEPTION_L(CIM_ERR_FAILED, |
|
MessageLoaderParms( |
|
"Repository.CIMRepository.ROLLBACK_FAILED", |
|
"rollback failed")); |
|
} |
|
|
|
PEG_METHOD_EXIT(); |
|
} |
|
|
|
//////////////////////////////////////////////////////////////////////////////// |
|
// |
// CIMRepository | // CIMRepository |
// | // |
// The following are not implemented: | // The following are not implemented: |
|
|
PEG_METHOD_ENTER(TRC_REPOSITORY, "CIMRepository::getInstance"); | PEG_METHOD_ENTER(TRC_REPOSITORY, "CIMRepository::getInstance"); |
| |
ReadLock lock(_lock); | ReadLock lock(_lock); |
|
|
CIMInstance cimInstance = _getInstance(nameSpace, | CIMInstance cimInstance = _getInstance(nameSpace, |
instanceName, | instanceName, |
localOnly, | localOnly, |
|
|
} | } |
| |
// | // |
// Get the index for this instance: |
// Get paths of index and data files: |
// | // |
| |
Uint32 index; |
|
Uint32 size; |
|
|
|
String indexFilePath = _getInstanceIndexFilePath( | String indexFilePath = _getInstanceIndexFilePath( |
nameSpace, instanceName.getClassName()); | nameSpace, instanceName.getClassName()); |
| |
String dataFilePath = _getInstanceDataFilePath( | String dataFilePath = _getInstanceDataFilePath( |
nameSpace, instanceName.getClassName()); | nameSpace, instanceName.getClassName()); |
| |
|
// |
|
// Get the index for this instance: |
|
// |
|
|
|
Uint32 index; |
|
Uint32 size; |
|
|
if (!InstanceIndexFile::lookupEntry( | if (!InstanceIndexFile::lookupEntry( |
indexFilePath, instanceName, index, size)) | indexFilePath, instanceName, index, size)) |
{ | { |
|
|
true); | true); |
} | } |
| |
_filterInstance(cimInstance, propertyList, localOnly, includeQualifiers, includeClassOrigin); |
_filterInstance( |
|
cimInstance, |
|
propertyList, |
|
localOnly, |
|
includeQualifiers, |
|
includeClassOrigin); |
| |
PEG_METHOD_EXIT(); | PEG_METHOD_EXIT(); |
return cimInstance; | return cimInstance; |
|
|
// from last time an instance-oriented function was called. | // from last time an instance-oriented function was called. |
// | // |
| |
if (!InstanceIndexFile::rollbackTransaction(indexFilePath)) |
_rollbackInstanceTransaction(indexFilePath, dataFilePath); |
{ |
|
PEG_METHOD_EXIT(); |
|
//l10n |
|
//throw PEGASUS_CIM_EXCEPTION(CIM_ERR_FAILED, "rollback failed"); |
|
throw PEGASUS_CIM_EXCEPTION_L(CIM_ERR_FAILED, |
|
MessageLoaderParms("Repository.CIMRepository.ROLLBACK_FAILED", |
|
"rollback failed")); |
|
//l10n end |
|
} |
|
|
|
if (!InstanceDataFile::rollbackTransaction(dataFilePath)) |
|
{ |
|
PEG_METHOD_EXIT(); |
|
//l10n |
|
//throw PEGASUS_CIM_EXCEPTION(CIM_ERR_FAILED, "rollback failed"); |
|
throw PEGASUS_CIM_EXCEPTION_L(CIM_ERR_FAILED, |
|
MessageLoaderParms("Repository.CIMRepository.ROLLBACK_FAILED", |
|
"rollback failed")); |
|
//l10n end |
|
} |
|
| |
// | // |
// Lookup instance from the index file (raise error if not found). | // Lookup instance from the index file (raise error if not found). |
|
|
} | } |
| |
// | // |
// Begin the transaction (any return prior to commit will cause |
|
// a rollback next time an instance-oriented routine is invoked). |
|
// |
|
|
|
if (!InstanceIndexFile::beginTransaction(indexFilePath)) |
|
{ |
|
PEG_METHOD_EXIT(); |
|
//l10n |
|
//throw PEGASUS_CIM_EXCEPTION(CIM_ERR_FAILED, "begin failed"); |
|
throw PEGASUS_CIM_EXCEPTION_L(CIM_ERR_FAILED, |
|
MessageLoaderParms("Repository.CIMRepository.BEGIN_FAILED", |
|
"begin failed")); |
|
//l10n end |
|
} |
|
|
|
if (!InstanceDataFile::beginTransaction(dataFilePath)) |
|
{ |
|
PEG_METHOD_EXIT(); |
|
//l10n |
|
//throw PEGASUS_CIM_EXCEPTION(CIM_ERR_FAILED, "begin failed"); |
|
throw PEGASUS_CIM_EXCEPTION_L(CIM_ERR_FAILED, |
|
MessageLoaderParms("Repository.CIMRepository.BEGIN_FAILED", |
|
"begin failed")); |
|
//l10n end |
|
} |
|
|
|
// |
|
// Remove entry from index file. | // Remove entry from index file. |
// | // |
| |
|
_beginInstanceTransaction(indexFilePath, dataFilePath); |
|
|
Uint32 freeCount; | Uint32 freeCount; |
| |
if (!InstanceIndexFile::deleteEntry(indexFilePath, instanceName, freeCount)) | if (!InstanceIndexFile::deleteEntry(indexFilePath, instanceName, freeCount)) |
|
|
//l10n end | //l10n end |
} | } |
| |
// |
_commitInstanceTransaction(indexFilePath, dataFilePath); |
// Commit the transaction: |
|
// |
|
|
|
if (!InstanceIndexFile::commitTransaction(indexFilePath)) |
|
{ |
|
PEG_METHOD_EXIT(); |
|
//l10n |
|
//throw PEGASUS_CIM_EXCEPTION(CIM_ERR_FAILED, "commit failed"); |
|
throw PEGASUS_CIM_EXCEPTION_L(CIM_ERR_FAILED, |
|
MessageLoaderParms("Repository.CIMRepository.COMMIT_FAILED", |
|
"commit failed")); |
|
//l10n end |
|
} |
|
|
|
if (!InstanceDataFile::commitTransaction(dataFilePath)) |
|
{ |
|
PEG_METHOD_EXIT(); |
|
//l10n |
|
//throw PEGASUS_CIM_EXCEPTION(CIM_ERR_FAILED, "commit failed"); |
|
throw PEGASUS_CIM_EXCEPTION_L(CIM_ERR_FAILED, |
|
MessageLoaderParms("Repository.CIMRepository.COMMIT_FAILED", |
|
"commit failed")); |
|
//l10n end |
|
} |
|
| |
// | // |
// Compact the index and data files if the free count max was | // Compact the index and data files if the free count max was |
|
|
// Get paths to data and index files: | // Get paths to data and index files: |
// | // |
| |
String dataFilePath = _getInstanceDataFilePath( |
String indexFilePath = _getInstanceIndexFilePath( |
nameSpace, newInstance.getClassName()); | nameSpace, newInstance.getClassName()); |
| |
String indexFilePath = _getInstanceIndexFilePath( |
String dataFilePath = _getInstanceDataFilePath( |
nameSpace, newInstance.getClassName()); | nameSpace, newInstance.getClassName()); |
| |
// | // |
|
|
// from last time an instance-oriented function was called. | // from last time an instance-oriented function was called. |
// | // |
| |
if (!InstanceIndexFile::rollbackTransaction(indexFilePath)) |
_rollbackInstanceTransaction(indexFilePath, dataFilePath); |
{ |
|
PEG_METHOD_EXIT(); |
|
//l10n |
|
//throw PEGASUS_CIM_EXCEPTION(CIM_ERR_FAILED, "rollback failed"); |
|
throw PEGASUS_CIM_EXCEPTION_L(CIM_ERR_FAILED, |
|
MessageLoaderParms("Repository.CIMRepository.ROLLBACK_FAILED", |
|
"rollback failed")); |
|
//l10n end |
|
} |
|
|
|
if (!InstanceDataFile::rollbackTransaction(dataFilePath)) |
|
{ |
|
PEG_METHOD_EXIT(); |
|
//l10n |
|
//throw PEGASUS_CIM_EXCEPTION(CIM_ERR_FAILED, "rollback failed"); |
|
throw PEGASUS_CIM_EXCEPTION_L(CIM_ERR_FAILED, |
|
MessageLoaderParms( |
|
"Repository.CIMRepository.ROLLBACK_FAILED", |
|
"rollback failed")); |
|
//l10n end |
|
} |
|
| |
// | // |
// Resolve the instance. Looks up class and fills out properties but | // Resolve the instance. Looks up class and fills out properties but |
|
|
_createAssocInstEntries(nameSpace, cimClass, cimInstance, instanceName); | _createAssocInstEntries(nameSpace, cimClass, cimInstance, instanceName); |
| |
// | // |
// Begin the transaction (any return prior to commit will cause |
|
// a rollback next time an instance-oriented routine is invoked). |
|
// |
|
|
|
if (!InstanceIndexFile::beginTransaction(indexFilePath)) |
|
{ |
|
PEG_METHOD_EXIT(); |
|
//l10n |
|
//throw PEGASUS_CIM_EXCEPTION(CIM_ERR_FAILED, "begin failed"); |
|
throw PEGASUS_CIM_EXCEPTION_L(CIM_ERR_FAILED, |
|
MessageLoaderParms("Repository.CIMRepository.BEGIN_FAILED", |
|
"begin failed")); |
|
//l10n end |
|
} |
|
|
|
if (!InstanceDataFile::beginTransaction(dataFilePath)) |
|
{ |
|
PEG_METHOD_EXIT(); |
|
//l10n |
|
//throw PEGASUS_CIM_EXCEPTION(CIM_ERR_FAILED, "begin failed"); |
|
throw PEGASUS_CIM_EXCEPTION_L(CIM_ERR_FAILED, |
|
MessageLoaderParms("Repository.CIMRepository.BEGIN_FAILED", |
|
"begin failed")); |
|
//l10n end |
|
} |
|
|
|
// |
|
// Save instance to file: | // Save instance to file: |
// | // |
| |
|
_beginInstanceTransaction(indexFilePath, dataFilePath); |
|
|
Uint32 index; | Uint32 index; |
Uint32 size; | Uint32 size; |
| |
{ | { |
Buffer data; | Buffer data; |
streamer->encode(data, cimInstance); | streamer->encode(data, cimInstance); |
// XmlWriter::appendInstanceElement(data, cimInstance); |
|
size = data.size(); | size = data.size(); |
| |
if (!InstanceDataFile::appendInstance(dataFilePath, data, index)) | if (!InstanceDataFile::appendInstance(dataFilePath, data, index)) |
{ | { |
//l10n |
|
//errMessage.append("Failed to create instance: "); |
|
//errMessage.append(instanceName.toString()); |
|
PEG_METHOD_EXIT(); | PEG_METHOD_EXIT(); |
//throw PEGASUS_CIM_EXCEPTION(CIM_ERR_FAILED, errMessage); |
|
throw PEGASUS_CIM_EXCEPTION_L(CIM_ERR_FAILED, | throw PEGASUS_CIM_EXCEPTION_L(CIM_ERR_FAILED, |
MessageLoaderParms( | MessageLoaderParms( |
"Repository.CIMRepository.FAILED_TO_CREATE_INSTANCE", | "Repository.CIMRepository.FAILED_TO_CREATE_INSTANCE", |
"Failed to create instance: $0", | "Failed to create instance: $0", |
instanceName.toString())); | instanceName.toString())); |
//l10n end |
|
} | } |
} | } |
| |
|
|
if (!InstanceIndexFile::createEntry( | if (!InstanceIndexFile::createEntry( |
indexFilePath, instanceName, index, size)) | indexFilePath, instanceName, index, size)) |
{ | { |
//l10n |
|
//errMessage.append("Failed to create instance: "); |
|
//errMessage.append(instanceName.toString()); |
|
PEG_METHOD_EXIT(); | PEG_METHOD_EXIT(); |
//throw PEGASUS_CIM_EXCEPTION(CIM_ERR_FAILED, errMessage); |
|
throw PEGASUS_CIM_EXCEPTION_L(CIM_ERR_FAILED, | throw PEGASUS_CIM_EXCEPTION_L(CIM_ERR_FAILED, |
MessageLoaderParms( | MessageLoaderParms( |
"Repository.CIMRepository.FAILED_TO_CREATE_INSTANCE", | "Repository.CIMRepository.FAILED_TO_CREATE_INSTANCE", |
"Failed to create instance: $0", | "Failed to create instance: $0", |
instanceName.toString())); | instanceName.toString())); |
//l10n end |
|
} | } |
| |
// |
_commitInstanceTransaction(indexFilePath, dataFilePath); |
// Commit the changes: |
|
// |
|
|
|
if (!InstanceIndexFile::commitTransaction(indexFilePath)) |
|
{ |
|
PEG_METHOD_EXIT(); |
|
//l10n |
|
//throw PEGASUS_CIM_EXCEPTION(CIM_ERR_FAILED, "commit failed"); |
|
throw PEGASUS_CIM_EXCEPTION_L(CIM_ERR_FAILED, |
|
MessageLoaderParms("Repository.CIMRepository.COMMIT_FAILED", |
|
"commit failed")); |
|
//l10n end |
|
} |
|
|
|
if (!InstanceDataFile::commitTransaction(dataFilePath)) |
|
{ |
|
PEG_METHOD_EXIT(); |
|
//l10n |
|
//throw PEGASUS_CIM_EXCEPTION(CIM_ERR_FAILED, "commit failed"); |
|
throw PEGASUS_CIM_EXCEPTION_L(CIM_ERR_FAILED, |
|
MessageLoaderParms("Repository.CIMRepository.COMMIT_FAILED", |
|
"commit failed")); |
|
//l10n end |
|
} |
|
| |
Resolver::resolveInstance (cimInstance, _context, nameSpace, cimClass, | Resolver::resolveInstance (cimInstance, _context, nameSpace, cimClass, |
true); | true); |
|
|
nameSpace, instance.getClassName()); | nameSpace, instance.getClassName()); |
| |
// | // |
// First attempt rollback: |
// Attempt rollback (if there are no rollback files, this will have no |
// |
// effect). This code is here to rollback uncommitted changes left over |
|
// from last time an instance-oriented function was called. |
if (!InstanceIndexFile::rollbackTransaction(indexFilePath)) |
|
{ |
|
PEG_METHOD_EXIT(); |
|
//l10n |
|
//throw PEGASUS_CIM_EXCEPTION(CIM_ERR_FAILED, "rollback failed"); |
|
throw PEGASUS_CIM_EXCEPTION_L(CIM_ERR_FAILED, |
|
MessageLoaderParms("Repository.CIMRepository.ROLLBACK_FAILED", |
|
"rollback failed")); |
|
//l10n end |
|
} |
|
|
|
if (!InstanceDataFile::rollbackTransaction(dataFilePath)) |
|
{ |
|
PEG_METHOD_EXIT(); |
|
//l10n |
|
//throw PEGASUS_CIM_EXCEPTION(CIM_ERR_FAILED, "rollback failed"); |
|
throw PEGASUS_CIM_EXCEPTION_L(CIM_ERR_FAILED, |
|
MessageLoaderParms("Repository.CIMRepository.ROLLBACK_FAILED", |
|
"rollback failed")); |
|
//l10n end |
|
} |
|
|
|
// |
|
// Begin the transaction: |
|
// | // |
| |
if (!InstanceIndexFile::beginTransaction(indexFilePath)) |
_rollbackInstanceTransaction(indexFilePath, dataFilePath); |
{ |
|
PEG_METHOD_EXIT(); |
|
//l10n |
|
//throw PEGASUS_CIM_EXCEPTION(CIM_ERR_FAILED, "begin failed"); |
|
throw PEGASUS_CIM_EXCEPTION_L(CIM_ERR_FAILED, |
|
MessageLoaderParms("Repository.CIMRepository.BEGIN_FAILED", |
|
"begin failed")); |
|
//l10n end |
|
} |
|
|
|
if (!InstanceDataFile::beginTransaction(dataFilePath)) |
|
{ |
|
PEG_METHOD_EXIT(); |
|
//l10n |
|
//throw PEGASUS_CIM_EXCEPTION(CIM_ERR_FAILED, "begin failed"); |
|
throw PEGASUS_CIM_EXCEPTION_L(CIM_ERR_FAILED, |
|
MessageLoaderParms("Repository.CIMRepository.BEGIN_FAILED", |
|
"begin failed")); |
|
//l10n end |
|
} |
|
| |
// | // |
// Do this: | // Do this: |
|
|
// Disallow operation if the instance name was changed: | // Disallow operation if the instance name was changed: |
// | // |
| |
// For for bugzilla 1508. Hostname and namespace are not included |
// For bugzilla 1508. Hostname and namespace are not included |
// in the comparison here. | // in the comparison here. |
CIMObjectPath modifiedInstancePath = modifiedInstance.getPath(); | CIMObjectPath modifiedInstancePath = modifiedInstance.getPath(); |
modifiedInstancePath.setNameSpace(CIMNamespaceName()); | modifiedInstancePath.setNameSpace(CIMNamespaceName()); |
|
|
if (instanceName != modifiedInstancePath) | if (instanceName != modifiedInstancePath) |
{ | { |
PEG_METHOD_EXIT(); | PEG_METHOD_EXIT(); |
//l10n |
|
//throw PEGASUS_CIM_EXCEPTION(CIM_ERR_FAILED, |
|
//"Attempted to modify a key property"); |
|
throw PEGASUS_CIM_EXCEPTION_L(CIM_ERR_FAILED, | throw PEGASUS_CIM_EXCEPTION_L(CIM_ERR_FAILED, |
MessageLoaderParms( | MessageLoaderParms( |
"Repository.CIMRepository.ATTEMPT_TO_MODIFY_KEY_PROPERTY", | "Repository.CIMRepository.ATTEMPT_TO_MODIFY_KEY_PROPERTY", |
"Attempted to modify a key property")); | "Attempted to modify a key property")); |
//l10n end |
|
} | } |
| |
Uint32 oldSize; | Uint32 oldSize; |
|
|
// Modify the data file: | // Modify the data file: |
// | // |
| |
|
_beginInstanceTransaction(indexFilePath, dataFilePath); |
|
|
{ | { |
Buffer out; | Buffer out; |
streamer->encode(out, cimInstance); | streamer->encode(out, cimInstance); |
|
|
| |
if (!InstanceDataFile::appendInstance(dataFilePath, out, newIndex)) | if (!InstanceDataFile::appendInstance(dataFilePath, out, newIndex)) |
{ | { |
//l10n |
|
//errMessage.append("Failed to modify instance "); |
|
//errMessage.append(instanceName.toString()); |
|
PEG_METHOD_EXIT(); | PEG_METHOD_EXIT(); |
//throw PEGASUS_CIM_EXCEPTION(CIM_ERR_FAILED, errMessage); |
|
throw PEGASUS_CIM_EXCEPTION_L(CIM_ERR_FAILED, | throw PEGASUS_CIM_EXCEPTION_L(CIM_ERR_FAILED, |
MessageLoaderParms( | MessageLoaderParms( |
"Repository.CIMRepository.FAILED_TO_MODIFY_INSTANCE", | "Repository.CIMRepository.FAILED_TO_MODIFY_INSTANCE", |
"Failed to modify instance $0", | "Failed to modify instance $0", |
instanceName.toString())); | instanceName.toString())); |
//l10n end |
|
} | } |
} | } |
| |
|
|
if (!InstanceIndexFile::modifyEntry(indexFilePath, instanceName, newIndex, | if (!InstanceIndexFile::modifyEntry(indexFilePath, instanceName, newIndex, |
newSize, freeCount)) | newSize, freeCount)) |
{ | { |
//l10n |
|
//errMessage.append("Failed to modify instance "); |
|
//errMessage.append(instanceName.toString()); |
|
PEG_METHOD_EXIT(); | PEG_METHOD_EXIT(); |
//throw PEGASUS_CIM_EXCEPTION(CIM_ERR_FAILED, errMessage); |
|
throw PEGASUS_CIM_EXCEPTION_L(CIM_ERR_FAILED, | throw PEGASUS_CIM_EXCEPTION_L(CIM_ERR_FAILED, |
MessageLoaderParms( | MessageLoaderParms( |
"Repository.CIMRepository.FAILED_TO_MODIFY_INSTANCE", | "Repository.CIMRepository.FAILED_TO_MODIFY_INSTANCE", |
"Failed to modify instance $0", | "Failed to modify instance $0", |
instanceName.toString())); | instanceName.toString())); |
//l10n end |
|
} |
|
|
|
// |
|
// Commit the transaction: |
|
// |
|
|
|
if (!InstanceIndexFile::commitTransaction(indexFilePath)) |
|
{ |
|
PEG_METHOD_EXIT(); |
|
//l10n |
|
//throw PEGASUS_CIM_EXCEPTION(CIM_ERR_FAILED, "commit failed"); |
|
throw PEGASUS_CIM_EXCEPTION_L(CIM_ERR_FAILED, |
|
MessageLoaderParms("Repository.CIMRepository.COMMIT_FAILED", |
|
"commit failed")); |
|
//l10n end |
|
} | } |
| |
if (!InstanceDataFile::commitTransaction(dataFilePath)) |
_commitInstanceTransaction(indexFilePath, dataFilePath); |
{ |
|
PEG_METHOD_EXIT(); |
|
//l10n |
|
//throw PEGASUS_CIM_EXCEPTION(CIM_ERR_FAILED, "commit failed"); |
|
throw PEGASUS_CIM_EXCEPTION_L(CIM_ERR_FAILED, |
|
MessageLoaderParms("Repository.CIMRepository.COMMIT_FAILED", |
|
"commit failed")); |
|
//l10n end |
|
} |
|
| |
// | // |
// Compact the index and data files if the free count max was | // Compact the index and data files if the free count max was |
|
|
Array<Uint32> sizes; | Array<Uint32> sizes; |
| |
// | // |
// Form the name of the instance index file |
// Form the names of the instance index and data files |
// | // |
| |
String indexFilePath = _getInstanceIndexFilePath(nameSpace, className); | String indexFilePath = _getInstanceIndexFilePath(nameSpace, className); |
|
|
// |
|
// Form the name of the instance file |
|
// |
|
|
|
String dataFilePath = _getInstanceDataFilePath(nameSpace, className); | String dataFilePath = _getInstanceDataFilePath(nameSpace, className); |
| |
// | // |
|
|
Uint32 pos=(&(buffer[indices[i]]))-buffer; | Uint32 pos=(&(buffer[indices[i]]))-buffer; |
streamer->decode(data, pos, tmpInstance); | streamer->decode(data, pos, tmpInstance); |
| |
// XmlParser parser(&(buffer[indices[i]])); |
|
// |
|
// XmlReader::getObject(parser, tmpInstance); |
|
|
|
Resolver::resolveInstance (tmpInstance, _context, nameSpace, | Resolver::resolveInstance (tmpInstance, _context, nameSpace, |
true); | true); |
tmpInstance.setPath (instanceNames[i]); | tmpInstance.setPath (instanceNames[i]); |
|
|
PEG_METHOD_ENTER(TRC_REPOSITORY, | PEG_METHOD_ENTER(TRC_REPOSITORY, |
"CIMRepository::enumerateInstanceNamesForSubtree"); | "CIMRepository::enumerateInstanceNamesForSubtree"); |
| |
ReadLock lock(_lock); |
// It is not necessary to control access to the ReadWriteSem _lock here. |
|
// This method calls enumerateInstanceNamesForClass, which does its own |
|
// access control. |
| |
// | // |
// Get names of descendent classes: | // Get names of descendent classes: |
// | // |
Array<CIMName> classNames; |
|
| |
|
Array<CIMName> classNames; |
classNames.append(className); | classNames.append(className); |
|
|
try |
|
{ |
|
_nameSpaceManager.getSubClassNames(nameSpace, className, true, classNames); | _nameSpaceManager.getSubClassNames(nameSpace, className, true, classNames); |
} |
|
catch(const CIMException&) |
|
{ |
|
PEG_METHOD_EXIT(); |
|
throw; |
|
} |
|
| |
// | // |
// Get instance names from each qualifying instance file for the class: |
// Enumerate instance names for each of the subclasses |
// | // |
Array<CIMObjectPath> instanceNames; | Array<CIMObjectPath> instanceNames; |
Array<Uint32> indices; |
|
Array<Uint32> sizes; |
|
| |
for (Uint32 i = 0; i < classNames.size(); i++) | for (Uint32 i = 0; i < classNames.size(); i++) |
{ | { |
// |
instanceNames.appendArray( |
// Form the name of the class index file: |
enumerateInstanceNamesForClass(nameSpace, classNames[i])); |
// |
|
|
|
String indexFilePath = _getInstanceIndexFilePath( |
|
nameSpace, classNames[i]); |
|
|
|
// |
|
// Get all instances for that class: |
|
// |
|
|
|
Array<Uint32> freeFlags; |
|
|
|
if (!InstanceIndexFile::enumerateEntries( |
|
indexFilePath, freeFlags, indices, sizes, instanceNames, false)) |
|
{ |
|
//l10n |
|
//String errMessage = "Failed to load instance names in class "; |
|
//errMessage.append(classNames[i].getString()); |
|
PEG_METHOD_EXIT(); |
|
//throw PEGASUS_CIM_EXCEPTION(CIM_ERR_FAILED, errMessage); |
|
throw PEGASUS_CIM_EXCEPTION_L(CIM_ERR_FAILED, |
|
MessageLoaderParms( |
|
"Repository.CIMRepository.FAILED_TO_LOAD_INSTANCE_NAMES", |
|
"Failed to load instance names in class $0", |
|
classNames[i].getString())); |
|
//l10n end |
|
} |
|
} | } |
| |
PEG_METHOD_EXIT(); | PEG_METHOD_EXIT(); |
|
|
Array<Uint32> sizes; | Array<Uint32> sizes; |
| |
// | // |
// Form the name of the class index file: |
// Form the names of the instance index and data files |
// | // |
| |
String indexFilePath = _getInstanceIndexFilePath(nameSpace, className); | String indexFilePath = _getInstanceIndexFilePath(nameSpace, className); |
|
String dataFilePath = _getInstanceDataFilePath(nameSpace, className); |
| |
// | // |
// Get all instances for the class: | // Get all instances for the class: |
|
|
| |
ReadLock lock(_lock); | ReadLock lock(_lock); |
| |
if (!_nameSpaceManager.classExists(nameSpace, instanceName.getClassName())) |
|
{ |
|
throw PEGASUS_CIM_EXCEPTION( |
|
CIM_ERR_INVALID_CLASS, instanceName.getClassName().getString()); |
|
} |
|
|
|
// | // |
// Get the index for this instance: |
// Retrieve the specified instance |
// | // |
| |
Uint32 index; |
CIMInstance cimInstance = _getInstance( |
Uint32 size; |
nameSpace, instanceName, false, true, true, CIMPropertyList()); |
|
|
String indexFilePath = _getInstanceIndexFilePath( |
|
nameSpace, instanceName.getClassName()); |
|
|
|
String dataFilePath = _getInstanceDataFilePath( |
|
nameSpace, instanceName.getClassName()); |
|
|
|
if (!InstanceIndexFile::lookupEntry( |
|
indexFilePath, instanceName, index, size)) |
|
{ |
|
PEG_METHOD_EXIT(); |
|
throw PEGASUS_CIM_EXCEPTION(CIM_ERR_NOT_FOUND, instanceName.toString()); |
|
} |
|
|
|
// |
|
// Load the instance into memory: |
|
// |
|
|
|
CIMInstance cimInstance; |
|
|
|
if (!_loadInstance(dataFilePath, cimInstance, index, size)) |
|
{ |
|
PEG_METHOD_EXIT(); |
|
throw CannotOpenFile(dataFilePath); |
|
} |
|
| |
// | // |
// Grab the property from the instance: |
// Get the requested property from the instance |
// | // |
| |
Uint32 pos = cimInstance.findProperty(propertyName); | Uint32 pos = cimInstance.findProperty(propertyName); |