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 #include "OW_config.h"
00031 #include "OW_FTABLERef.hpp"
00032 #include "OW_PerlInstanceProviderProxy.hpp"
00033 #include "NPIExternal.hpp"
00034 #include "OW_CIMClass.hpp"
00035 #include "OW_CIMException.hpp"
00036 #include "OW_Format.hpp"
00037 #include "OW_Logger.hpp"
00038 #include "OW_ResultHandlerIFC.hpp"
00039 #include "OW_NPIProviderIFCUtils.hpp"
00040
00041 namespace OW_NAMESPACE
00042 {
00043
00044
00045 #define DDD(X) // X
00046 using namespace WBEMFlags;
00047 namespace
00048 {
00049 const String COMPONENT_NAME("ow.provider.perlnpi.ifc");
00050 }
00051
00053 PerlInstanceProviderProxy::~PerlInstanceProviderProxy()
00054 {
00055 }
00057 void
00058 PerlInstanceProviderProxy::enumInstanceNames(
00059 const ProviderEnvironmentIFCRef& env,
00060 const String& ns,
00061 const String& className,
00062 CIMObjectPathResultHandlerIFC& result,
00063 const CIMClass& cimClass )
00064 {
00065 OW_LOG_DEBUG(env->getLogger(COMPONENT_NAME), "PerlInstanceProviderProxy::enumInstanceNames()");
00066 if (m_ftable->fp_enumInstanceNames!= NULL)
00067 {
00068 ::NPIHandle _npiHandle = { 0, 0, 0, 0, m_ftable->npicontext};
00069 NPIHandleFreer nhf(_npiHandle);
00070 ProviderEnvironmentIFCRef env2(env);
00071 _npiHandle.thisObject = static_cast<void *>(&env2);
00072
00073
00074 CIMClass cimClass2(cimClass);
00075 ::CIMClass _cc = { static_cast<void *> (&cimClass2)};
00076 CIMObjectPath cop(className, ns);
00077 ::CIMObjectPath _cop = { static_cast<void *> (&cop)};
00078 ::Vector v =
00079 m_ftable->fp_enumInstanceNames(&_npiHandle,_cop,true,_cc);
00080
00081
00082 if (_npiHandle.errorOccurred)
00083 {
00084 OW_THROWCIMMSG(CIMException::FAILED,
00085 _npiHandle.providerError);
00086 }
00087 ::CIMObjectPath my_cop;
00088 for (int i=0,n=VectorSize(&_npiHandle,v); i < n; i++)
00089 {
00090 my_cop.ptr = _VectorGet(&_npiHandle,v,i);
00091 CIMObjectPath ow_cop(*
00092 static_cast<CIMObjectPath *>(my_cop.ptr) );
00093 ow_cop.setClassName(cimClass.getName());
00094 result.handle(ow_cop);
00095 }
00096
00097 }
00098 else
00099 {
00100 OW_THROWCIMMSG(CIMException::FAILED, "Provider does not support enumInstanceNames");
00101 }
00102 }
00104 void
00105 PerlInstanceProviderProxy::enumInstances(
00106 const ProviderEnvironmentIFCRef& env,
00107 const String& ns,
00108 const String& className,
00109 CIMInstanceResultHandlerIFC& result,
00110 ELocalOnlyFlag localOnly,
00111 EDeepFlag deep,
00112 EIncludeQualifiersFlag includeQualifiers,
00113 EIncludeClassOriginFlag includeClassOrigin,
00114 const StringArray* propertyList,
00115 const CIMClass& requestedClass,
00116 const CIMClass& cimClass )
00117 {
00118 OW_LOG_DEBUG(env->getLogger(COMPONENT_NAME), "PerlInstanceProviderProxy::enumInstances()");
00119 if (m_ftable->fp_enumInstances == NULL)
00120 {
00121 OW_THROWCIMMSG(CIMException::FAILED, "Provider does not support enumInstances");
00122 }
00123 ::NPIHandle _npiHandle = { 0, 0, 0, 0, m_ftable->npicontext};
00124 NPIHandleFreer nhf(_npiHandle);
00125 ProviderEnvironmentIFCRef env2(env);
00126 _npiHandle.thisObject = static_cast<void *>(&env2);
00127
00128
00129 CIMClass cimClass2(cimClass);
00130 ::CIMClass _cc = { static_cast<void *> (&cimClass2)};
00131 CIMObjectPath cop(className, ns);
00132 ::CIMObjectPath _cop = { static_cast<void *> (&cop)};
00133 int de = deep;
00134 int lo = localOnly;
00135 ::Vector v =
00136 m_ftable->fp_enumInstances(&_npiHandle, _cop, de, _cc, lo);
00137
00138 if (_npiHandle.errorOccurred)
00139 {
00140 OW_THROWCIMMSG(CIMException::FAILED,
00141 _npiHandle.providerError);
00142 }
00143 ::CIMInstance my_inst;
00144 for (int i=0,n=VectorSize(&_npiHandle,v); i < n; i++)
00145 {
00146 my_inst.ptr = _VectorGet(&_npiHandle,v,i);
00147 CIMInstance ow_inst(*
00148 static_cast<CIMInstance *>(my_inst.ptr) );
00149
00150 ow_inst.setClassName(cimClass.getName());
00151 result.handle(ow_inst.clone(localOnly,deep,includeQualifiers,
00152 includeClassOrigin,propertyList,requestedClass,cimClass));
00153 }
00154 }
00155
00157 CIMInstance
00158 PerlInstanceProviderProxy::getInstance(const ProviderEnvironmentIFCRef &env,
00159 const String& ns,
00160 const CIMObjectPath& instanceName,
00161 ELocalOnlyFlag localOnly,
00162 EIncludeQualifiersFlag includeQualifiers,
00163 EIncludeClassOriginFlag includeClassOrigin,
00164 const StringArray* propertyList,
00165 const CIMClass& cimClass)
00166 {
00167 CIMInstance rval;
00168 OW_LOG_DEBUG(env->getLogger(COMPONENT_NAME), "PerlInstanceProviderProxy::getInstance()");
00169 if (m_ftable->fp_getInstance != NULL)
00170 {
00171 ::NPIHandle _npiHandle = { 0, 0, 0, 0, m_ftable->npicontext};
00172 NPIHandleFreer nhf(_npiHandle);
00173 ProviderEnvironmentIFCRef env2(env);
00174 _npiHandle.thisObject = static_cast<void *>(&env2);
00175
00176
00177 CIMClass cimClass2(cimClass);
00178 ::CIMClass _cc = { static_cast<void *> (&cimClass2)};
00179 CIMObjectPath cop(instanceName);
00180 cop.setNameSpace(ns);
00181 ::CIMObjectPath _cop = { static_cast<void *> (&cop)};
00182 int lo = localOnly;
00183 ::CIMInstance my_inst =
00184 m_ftable->fp_getInstance(&_npiHandle, _cop, _cc, lo);
00185 if (_npiHandle.errorOccurred)
00186 {
00187 OW_THROWCIMMSG(CIMException::FAILED,
00188 _npiHandle.providerError);
00189 }
00190 CIMInstance ow_inst(*
00191 static_cast<CIMInstance *>(my_inst.ptr));
00192
00193 ow_inst.setClassName(cimClass.getName());
00194 rval = ow_inst;
00195 rval = rval.clone(localOnly,includeQualifiers,includeClassOrigin,propertyList);
00196 }
00197 else
00198 {
00199 OW_THROWCIMMSG(CIMException::FAILED, "Provider does not support getInstance");
00200 }
00201 return rval;
00202 }
00203 #ifndef OW_DISABLE_INSTANCE_MANIPULATION
00204
00205 CIMObjectPath
00206 PerlInstanceProviderProxy::createInstance(
00207 const ProviderEnvironmentIFCRef &env, const String& ns,
00208 const CIMInstance& cimInstance)
00209 {
00210 CIMObjectPath rval;
00211 OW_LOG_DEBUG(env->getLogger(COMPONENT_NAME), "PerlInstanceProviderProxy::createInstance()");
00212 if (m_ftable->fp_createInstance != NULL)
00213 {
00214 ::NPIHandle _npiHandle = { 0, 0, 0, 0, m_ftable->npicontext};
00215 NPIHandleFreer nhf(_npiHandle);
00216 ProviderEnvironmentIFCRef env2(env);
00217 _npiHandle.thisObject = static_cast<void *>(&env2);
00218
00219
00220 CIMInstance cimInstance2(cimInstance);
00221 ::CIMInstance _ci = { static_cast<void *> (&cimInstance2)};
00222 CIMObjectPath cop(ns, cimInstance);
00223 ::CIMObjectPath _cop = { static_cast<void *> (const_cast<CIMObjectPath*>(&cop))};
00224 ::CIMObjectPath _rcop =
00225 m_ftable->fp_createInstance(&_npiHandle, _cop, _ci);
00226 if (_npiHandle.errorOccurred)
00227 {
00228 OW_THROWCIMMSG(CIMException::FAILED,
00229 _npiHandle.providerError);
00230 }
00231 rval = *(static_cast<CIMObjectPath *>(_rcop.ptr) );
00232 }
00233 else
00234 {
00235 OW_THROWCIMMSG(CIMException::FAILED, "Provider does not support createInstance");
00236 }
00237 return rval;
00238 }
00240 void
00241 PerlInstanceProviderProxy::modifyInstance(const ProviderEnvironmentIFCRef &env,
00242 const String& ns,
00243 const CIMInstance& modifiedInstance,
00244 const CIMInstance& previousInstance,
00245 EIncludeQualifiersFlag includeQualifiers,
00246 const StringArray* propertyList,
00247 const CIMClass& theClass)
00248 {
00249 OW_LOG_DEBUG(env->getLogger(COMPONENT_NAME), "PerlInstanceProviderProxy::modifyInstance()");
00250 if (m_ftable->fp_setInstance != NULL)
00251 {
00252 ::NPIHandle _npiHandle = { 0, 0, 0, 0, m_ftable->npicontext};
00253 NPIHandleFreer nhf(_npiHandle);
00254 ProviderEnvironmentIFCRef env2(env);
00255 _npiHandle.thisObject = static_cast<void *>(&env2);
00256
00257
00258 CIMInstance newInst(modifiedInstance.createModifiedInstance(
00259 previousInstance, includeQualifiers, propertyList, theClass));
00260 ::CIMInstance _ci = { static_cast<void *> (&newInst)};
00261 CIMObjectPath cop(ns, modifiedInstance);
00262 ::CIMObjectPath _cop = { static_cast<void *> (&cop)};
00263 m_ftable->fp_setInstance(&_npiHandle, _cop, _ci);
00264 if (_npiHandle.errorOccurred)
00265 {
00266 OW_THROWCIMMSG(CIMException::FAILED,
00267 _npiHandle.providerError);
00268 }
00269 }
00270 else
00271 {
00272 OW_THROWCIMMSG(CIMException::FAILED, "Provider does not support modifyInstance");
00273 }
00274 }
00276 void
00277 PerlInstanceProviderProxy::deleteInstance(const ProviderEnvironmentIFCRef &env,
00278 const String& ns, const CIMObjectPath& cop)
00279 {
00280 OW_LOG_DEBUG(env->getLogger(COMPONENT_NAME), "PerlInstanceProviderProxy::deleteInstance()");
00281 if (m_ftable->fp_deleteInstance!= NULL)
00282 {
00283 ::NPIHandle _npiHandle = { 0, 0, 0, 0, m_ftable->npicontext};
00284 NPIHandleFreer nhf(_npiHandle);
00285 ProviderEnvironmentIFCRef env2(env);
00286 _npiHandle.thisObject = static_cast<void *>(&env2);
00287
00288
00289 CIMObjectPath copWithNS(cop);
00290 copWithNS.setNameSpace(ns);
00291 ::CIMObjectPath _cop = { static_cast<void *> (&copWithNS)};
00292 m_ftable->fp_deleteInstance(&_npiHandle, _cop);
00293 if (_npiHandle.errorOccurred)
00294 {
00295 OW_THROWCIMMSG(CIMException::FAILED,
00296 _npiHandle.providerError);
00297 }
00298 }
00299 else
00300 {
00301 OW_THROWCIMMSG(CIMException::FAILED, "Provider does not support deleteInstance");
00302 }
00303 }
00304 #endif // #ifndef OW_DISABLE_INSTANCE_MANIPULATION
00305
00306 }
00307