00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00035 #include "OW_config.h"
00036 #include "OW_CppInstanceProviderIFC.hpp"
00037 #include "OW_ConfigOpts.hpp"
00038 #include "OW_CIMObjectPath.hpp"
00039 #include "OW_CIMException.hpp"
00040 #include "OW_CIMInstance.hpp"
00041 #include "OW_CIMOMEnvironment.hpp"
00042 #include "OW_IndicationServer.hpp"
00043 #include "OW_CIMClass.hpp"
00044 #include "OW_CIMValue.hpp"
00045 #include "OW_CIMOMHandleIFC.hpp"
00046 #include "OW_RepositoryIFC.hpp"
00047
00048 namespace OW_NAMESPACE
00049 {
00050
00051 using namespace WBEMFlags;
00052 namespace
00053 {
00054
00055
00056 class provCIM_IndicationSubscription : public CppInstanceProviderIFC
00057 {
00058 public:
00059 virtual void initialize(const ProviderEnvironmentIFCRef& env)
00060 {
00061 indicationsEnabled = !(env->getConfigItem(ConfigOpts::DISABLE_INDICATIONS_opt, OW_DEFAULT_DISABLE_INDICATIONS).equalsIgnoreCase("true"));
00062
00063 if (indicationsEnabled)
00064 {
00065 CIMOMEnvironment::instance()->getIndicationServer();
00066 if (!CIMOMEnvironment::instance()->getIndicationServer())
00067 {
00068 indicationsEnabled = false;
00069 }
00070 }
00071 }
00072 virtual void getInstanceProviderInfo(InstanceProviderInfo& info)
00073 {
00074 info.addInstrumentedClass("CIM_IndicationSubscription");
00075 }
00076 #ifndef OW_DISABLE_INSTANCE_MANIPULATION
00077 virtual void deleteInstance(const ProviderEnvironmentIFCRef &env, const String &ns, const CIMObjectPath &cop)
00078 {
00079
00080 CIMOMHandleIFCRef rephdl = env->getRepositoryCIMOMHandle();
00081 rephdl->deleteInstance(ns, cop);
00082
00083 CIMOMEnvironment::instance()->getIndicationServer()->startDeleteSubscription(ns, cop);
00084 }
00085 virtual CIMObjectPath createInstance(const ProviderEnvironmentIFCRef &env, const String &ns, const CIMInstance &cimInstance_)
00086 {
00087
00088 CIMInstance cimInstance(cimInstance_);
00089
00090 String username = env->getUserName();
00091 cimInstance.setProperty("__Subscription_UserName", CIMValue(username));
00092 if (!indicationsEnabled)
00093 {
00094 OW_THROWCIMMSG(CIMException::FAILED, "Indication are disabled. Subscription creation is not allowed.");
00095 }
00096 CIMObjectPath rv = env->getRepositoryCIMOMHandle()->createInstance(ns, cimInstance);
00097
00098 CIMOMEnvironment::instance()->getIndicationServer()->startCreateSubscription(ns, cimInstance, username);
00099 return rv;
00100 }
00101 virtual void modifyInstance(const ProviderEnvironmentIFCRef &env, const String &ns, const CIMInstance &modifiedInstance, const CIMInstance &previousInstance,
00102 EIncludeQualifiersFlag includeQualifiers, const StringArray *propertyList, const CIMClass &theClass)
00103 {
00104 if (!indicationsEnabled)
00105 {
00106 OW_THROWCIMMSG(CIMException::FAILED, "Indication are disabled. Subscription creation is not allowed.");
00107 }
00108
00109 CIMOMHandleIFCRef rephdl = env->getRepositoryCIMOMHandle();
00110 rephdl->modifyInstance(ns, modifiedInstance, includeQualifiers, propertyList);
00111
00112 CIMOMEnvironment::instance()->getIndicationServer()->startModifySubscription(ns, modifiedInstance.createModifiedInstance(previousInstance,includeQualifiers,propertyList,theClass));
00113 }
00114 #endif // #ifndef OW_DISABLE_INSTANCE_MANIPULATION
00115 virtual CIMInstance getInstance(const ProviderEnvironmentIFCRef &env, const String &ns, const CIMObjectPath &instanceName, ELocalOnlyFlag localOnly, EIncludeQualifiersFlag includeQualifiers,
00116 EIncludeClassOriginFlag includeClassOrigin, const StringArray *propertyList, const CIMClass &cimClass)
00117 {
00118 return env->getRepositoryCIMOMHandle()->getInstance(ns, instanceName, localOnly, includeQualifiers, includeClassOrigin, propertyList);
00119 }
00120
00121 virtual void enumInstances(const ProviderEnvironmentIFCRef &env, const String &ns, const String &className, CIMInstanceResultHandlerIFC &result, ELocalOnlyFlag localOnly,
00122 EDeepFlag deep, EIncludeQualifiersFlag includeQualifiers, EIncludeClassOriginFlag includeClassOrigin, const StringArray *propertyList, const CIMClass &requestedClass, const CIMClass &cimClass)
00123 {
00124 RepositoryIFCRef rephdl = env->getRepository();
00125 rephdl->enumInstances(ns,className,result,deep,localOnly,includeQualifiers,includeClassOrigin,propertyList, E_DONT_ENUM_SUBCLASSES, env->getOperationContext());
00126 }
00127
00128 virtual void enumInstanceNames(const ProviderEnvironmentIFCRef &env, const String &ns, const String &className, CIMObjectPathResultHandlerIFC &result,
00129 const CIMClass &cimClass)
00130 {
00131 RepositoryIFCRef rephdl = env->getRepository();
00132 rephdl->enumInstanceNames(ns,className,result, E_SHALLOW, env->getOperationContext());
00133 }
00134 private:
00135 bool indicationsEnabled;
00136 };
00137 }
00138 }
00139
00140 OW_PROVIDERFACTORY(OpenWBEM::provCIM_IndicationSubscription, owprovCIM_IndicationSubscription);
00141