version 1.14, 2006/10/20 19:19:44
|
version 1.14.8.2, 2007/11/12 06:57:37
|
|
|
// | // |
//============================================================================== | //============================================================================== |
// | // |
// Author: Carol Ann Krug Graves, Hewlett-Packard Company |
|
// (carolann_graves@hp.com) |
|
// |
|
// Modified By: David Dillard, VERITAS Software Corp. |
|
// (david.dillard@veritas.com) |
|
// |
|
//%///////////////////////////////////////////////////////////////////////////// | //%///////////////////////////////////////////////////////////////////////////// |
| |
#include <Pegasus/Common/Config.h> | #include <Pegasus/Common/Config.h> |
|
|
| |
#include "IndicationConstants.h" | #include "IndicationConstants.h" |
#include "SubscriptionRepository.h" | #include "SubscriptionRepository.h" |
|
#include "IndicationMessageConstants.h" |
| |
PEGASUS_USING_STD; | PEGASUS_USING_STD; |
| |
|
|
CIMRepository * repository) | CIMRepository * repository) |
: _repository (repository) | : _repository (repository) |
{ | { |
|
_normalizedSubscriptionTable = |
|
new NormalizedSubscriptionTable(getAllSubscriptions()); |
} | } |
| |
SubscriptionRepository::~SubscriptionRepository () | SubscriptionRepository::~SubscriptionRepository () |
{ | { |
} | } |
| |
|
void SubscriptionRepository::beginCreateSubscription( |
|
const CIMObjectPath &subPath) |
|
{ |
|
Boolean subscriptionExists; |
|
AutoMutex mtx(_normalizedSubscriptionTableMutex); |
|
if(_normalizedSubscriptionTable->exists(subPath, subscriptionExists)) |
|
{ |
|
if (subscriptionExists) |
|
{ |
|
throw PEGASUS_CIM_EXCEPTION(CIM_ERR_ALREADY_EXISTS, |
|
subPath.toString()); |
|
} |
|
throw PEGASUS_CIM_EXCEPTION_L(CIM_ERR_FAILED, |
|
MessageLoaderParms(_MSG_DUPLICATE_SUBSCRIPTION_REQUEST_KEY, |
|
_MSG_DUPLICATE_SUBSCRIPTION_REQUEST, subPath.toString())); |
|
} |
|
_normalizedSubscriptionTable->add(subPath, false); |
|
} |
|
|
|
void SubscriptionRepository::cancelCreateSubscription( |
|
const CIMObjectPath &subPath) |
|
{ |
|
AutoMutex mtx(_normalizedSubscriptionTableMutex); |
|
_normalizedSubscriptionTable->remove(subPath); |
|
} |
|
|
|
void SubscriptionRepository::commitCreateSubscription( |
|
const CIMObjectPath &subPath) |
|
{ |
|
AutoMutex mtx(_normalizedSubscriptionTableMutex); |
|
_normalizedSubscriptionTable->remove(subPath); |
|
_normalizedSubscriptionTable->add(subPath, true); |
|
} |
|
|
CIMObjectPath SubscriptionRepository::createInstance ( | CIMObjectPath SubscriptionRepository::createInstance ( |
CIMInstance instance, | CIMInstance instance, |
const CIMNamespaceName & nameSpace, | const CIMNamespaceName & nameSpace, |
|
|
PEG_METHOD_ENTER (TRC_INDICATION_SERVICE, | PEG_METHOD_ENTER (TRC_INDICATION_SERVICE, |
"SubscriptionRepository::getState"); | "SubscriptionRepository::getState"); |
| |
Uint32 stateIndex = instance.findProperty (PEGASUS_PROPERTYNAME_SUBSCRIPTION_STATE); |
Uint32 stateIndex = instance.findProperty |
|
(PEGASUS_PROPERTYNAME_SUBSCRIPTION_STATE); |
if (stateIndex != PEG_NOT_FOUND) | if (stateIndex != PEG_NOT_FOUND) |
{ | { |
CIMValue stateValue = instance.getProperty | CIMValue stateValue = instance.getProperty |
(stateIndex).getValue (); | (stateIndex).getValue (); |
if (stateValue.isNull ()) | if (stateValue.isNull ()) |
{ | { |
PEG_TRACE_STRING (TRC_INDICATION_SERVICE_INTERNAL, |
PEG_TRACE_CSTRING (TRC_INDICATION_SERVICE_INTERNAL, |
Tracer::LEVEL2, | Tracer::LEVEL2, |
"Null SubscriptionState property value"); | "Null SubscriptionState property value"); |
| |
|
|
} | } |
else | else |
{ | { |
PEG_TRACE_STRING (TRC_INDICATION_SERVICE_INTERNAL, |
PEG_TRACE_CSTRING (TRC_INDICATION_SERVICE_INTERNAL, |
Tracer::LEVEL2, | Tracer::LEVEL2, |
"Missing SubscriptionState property"); | "Missing SubscriptionState property"); |
| |
|
|
// | // |
try | try |
{ | { |
_repository->deleteInstance (nameSpace, subscription); |
deleteInstance (nameSpace, subscription); |
} | } |
catch (Exception & exception) | catch (Exception & exception) |
{ | { |
|
|
CIMObjectPath path ("", CIMNamespaceName (), | CIMObjectPath path ("", CIMNamespaceName (), |
subscriptions [i].getPath ().getClassName (), | subscriptions [i].getPath ().getClassName (), |
subscriptions [i].getPath ().getKeyBindings ()); | subscriptions [i].getPath ().getKeyBindings ()); |
_repository->deleteInstance |
deleteInstance |
(subscriptions [i].getPath ().getNameSpace (), path); | (subscriptions [i].getPath ().getNameSpace (), path); |
} | } |
catch (Exception & exception) | catch (Exception & exception) |
|
|
const CIMObjectPath & instanceName) | const CIMObjectPath & instanceName) |
{ | { |
_repository->deleteInstance (nameSpace, instanceName); | _repository->deleteInstance (nameSpace, instanceName); |
|
// If deleted instance was SubscriptionInstance, delete from |
|
// Normalized subscriptions table. |
|
if (instanceName.getClassName().equal( |
|
PEGASUS_CLASSNAME_INDSUBSCRIPTION) || |
|
instanceName.getClassName ().equal( |
|
PEGASUS_CLASSNAME_FORMATTEDINDSUBSCRIPTION)) |
|
{ |
|
CIMObjectPath tmpPath = instanceName; |
|
tmpPath.setNameSpace(nameSpace); |
|
_normalizedSubscriptionTable->remove(tmpPath); |
|
} |
} | } |
| |
Array <CIMInstance> SubscriptionRepository::enumerateInstancesForClass ( | Array <CIMInstance> SubscriptionRepository::enumerateInstancesForClass ( |
|
|
// | // |
try | try |
{ | { |
_repository->deleteInstance |
deleteInstance |
(subscription.getPath ().getNameSpace (), | (subscription.getPath ().getNameSpace (), |
subscription.getPath ()); | subscription.getPath ()); |
} | } |