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_PerlAssociatorProviderProxy.hpp"
00032 #include "NPIExternal.hpp"
00033 #include "OW_CIMException.hpp"
00034 #include "OW_Format.hpp"
00035 #include "OW_Logger.hpp"
00036 #include "OW_ResultHandlerIFC.hpp"
00037 #include "OW_NPIProviderIFCUtils.hpp"
00038
00039 namespace OW_NAMESPACE
00040 {
00041
00042 using namespace WBEMFlags;
00043 namespace
00044 {
00045 const String COMPONENT_NAME("ow.provider.perlnpi.ifc");
00046 }
00047
00049 void
00050 PerlAssociatorProviderProxy::associatorNames(
00051 const ProviderEnvironmentIFCRef &env,
00052 CIMObjectPathResultHandlerIFC& result,
00053 const String& ns,
00054 const CIMObjectPath& objectName,
00055 const String& assocClass,
00056 const String& resultClass,
00057 const String& role,
00058 const String& resultRole)
00059 {
00060 OW_LOG_DEBUG(env->getLogger(COMPONENT_NAME), "PerlAssociatorProviderProxy::associatorNames()");
00061 if (m_ftable->fp_associatorNames != NULL)
00062 {
00063 ::NPIHandle _npiHandle = { 0, 0, 0, 0, m_ftable->npicontext};
00064 NPIHandleFreer nhf(_npiHandle);
00065 ProviderEnvironmentIFCRef env2(env);
00066 _npiHandle.thisObject = static_cast<void *>(&env2);
00067
00068
00069
00070 CIMObjectPath assocName2(assocClass);
00071 ::CIMObjectPath _assoc = { static_cast<void *> (&assocName2)};
00072
00073 CIMObjectPath objectNameWithNS(objectName);
00074 objectNameWithNS.setNameSpace(ns);
00075 ::CIMObjectPath _path = { static_cast<void *> (&objectNameWithNS)};
00076 ::Vector v =
00077 m_ftable->fp_associatorNames(&_npiHandle, _assoc, _path,
00078 resultClass.empty() ? 0 : resultClass.c_str(),
00079 role.empty() ? 0 : role.c_str(),
00080 resultRole.empty() ? 0 : resultRole.c_str());
00081 if (_npiHandle.errorOccurred)
00082 {
00083 OW_THROWCIMMSG(CIMException::FAILED, _npiHandle.providerError);
00084 }
00085 ::CIMObjectPath cop;
00086 for (int i=::VectorSize(&_npiHandle, v) - 1; i >= 0; i--)
00087 {
00088 cop.ptr = ::_VectorGet(&_npiHandle,v,i);
00089 CIMObjectPath ow_cop(*
00090 static_cast<CIMObjectPath *>(cop.ptr) );
00091 result.handle(ow_cop);
00092 }
00093 }
00094 else
00095 {
00096 OW_THROWCIMMSG(CIMException::FAILED, "Provider does not support associatorNames");
00097 }
00098 }
00100 void
00101 PerlAssociatorProviderProxy::associators(
00102 const ProviderEnvironmentIFCRef &env,
00103 CIMInstanceResultHandlerIFC& result,
00104 const String& ns,
00105 const CIMObjectPath& objectName,
00106 const String& assocClass,
00107 const String& resultClass,
00108 const String& role,
00109 const String& resultRole,
00110 EIncludeQualifiersFlag includeQualifiers,
00111 EIncludeClassOriginFlag includeClassOrigin,
00112 const StringArray *propertyList)
00113 {
00114 OW_LOG_DEBUG(env->getLogger(COMPONENT_NAME), "PerlAssociatorProviderProxy::associators()");
00115 if (m_ftable->fp_associators != NULL)
00116 {
00117 ::NPIHandle _npiHandle = { 0, 0, 0, 0, m_ftable->npicontext};
00118 NPIHandleFreer nhf(_npiHandle);
00119 ProviderEnvironmentIFCRef env2(env);
00120 _npiHandle.thisObject = static_cast<void *>(&env2);
00121
00122
00123
00124 CIMObjectPath assocName2(assocClass);
00125 ::CIMObjectPath _assoc = { static_cast<void *> (&assocName2)};
00126
00127 CIMObjectPath objectNameWithNS(objectName);
00128 objectNameWithNS.setNameSpace(ns);
00129 ::CIMObjectPath _path = { static_cast<void *> (&objectNameWithNS)};
00130 int _plLen = 0;
00131 std::vector<const char *> _propertyList;
00132 if (propertyList)
00133 {
00134 _plLen = propertyList->size();
00135 for (int i = 0; i < _plLen; i++)
00136 _propertyList.push_back((*propertyList)[i].allocateCString());
00137 }
00138 ::Vector v =
00139 m_ftable->fp_associators(&_npiHandle, _assoc, _path,
00140 resultClass.empty() ? 0 : resultClass.c_str(),
00141 role.empty() ? 0 : role.c_str(),
00142 resultRole.empty() ? 0 : resultRole.c_str(),
00143 includeQualifiers, includeClassOrigin,
00144 _plLen > 0 ? &_propertyList[0] : 0, _plLen);
00145
00146 for (std::vector<const char*>::iterator i = _propertyList.begin();
00147 i != _propertyList.end(); ++i)
00148 {
00149 free(const_cast<void*>(static_cast<const void*>(*i)));
00150 }
00151 if (_npiHandle.errorOccurred)
00152 {
00153 OW_THROWCIMMSG(CIMException::FAILED, _npiHandle.providerError);
00154 }
00155 int n = ::VectorSize(&_npiHandle,v);
00156 OW_LOG_DEBUG(env->getLogger(COMPONENT_NAME), Format("PerlAssociatorProviderProxy::"
00157 "associators() got %1 associator instances", n - 1));
00158 ::CIMInstance my_inst;
00159
00160
00161 ELocalOnlyFlag localOnly = E_NOT_LOCAL_ONLY;
00162 for (int i=0; i < n; i++)
00163 {
00164 my_inst.ptr = _VectorGet(&_npiHandle,v,i);
00165 CIMInstance ow_inst(*
00166 static_cast<CIMInstance *>(my_inst.ptr) );
00167
00168
00169
00170
00171 result.handle( ow_inst.clone(localOnly,includeQualifiers,
00172 includeClassOrigin,propertyList) );
00173 }
00174 }
00175 else
00176 {
00177 OW_THROWCIMMSG(CIMException::FAILED, "Provider does not support associators");
00178 }
00179 }
00181 void
00182 PerlAssociatorProviderProxy::references(
00183 const ProviderEnvironmentIFCRef &env,
00184 CIMInstanceResultHandlerIFC& result,
00185 const String& ns,
00186 const CIMObjectPath& objectName,
00187 const String& resultClass,
00188 const String& role,
00189 EIncludeQualifiersFlag includeQualifiers,
00190 EIncludeClassOriginFlag includeClassOrigin,
00191 const StringArray *propertyList)
00192 {
00193 OW_LOG_DEBUG(env->getLogger(COMPONENT_NAME), "PerlAssociatorProviderProxy::references()");
00194 if (m_ftable->fp_references != NULL)
00195 {
00196 ::NPIHandle _npiHandle = { 0, 0, 0, 0, m_ftable->npicontext};
00197 NPIHandleFreer nhf(_npiHandle);
00198 ProviderEnvironmentIFCRef env2(env);
00199 _npiHandle.thisObject = static_cast<void *>(&env2);
00200
00201
00202
00203 CIMObjectPath assocName2(resultClass);
00204 ::CIMObjectPath _assoc = { static_cast<void *> (&assocName2)};
00205
00206 CIMObjectPath objectNameWithNS(objectName);
00207 objectNameWithNS.setNameSpace(ns);
00208 ::CIMObjectPath _path = { static_cast<void *> (&objectNameWithNS)};
00209 int _plLen = 0;
00210 std::vector<const char *> _propertyList;
00211 if (propertyList)
00212 {
00213 _plLen = propertyList->size();
00214 for (int i = 0; i < _plLen; i++)
00215 _propertyList.push_back((*propertyList)[i].allocateCString());
00216 }
00217 ::Vector v =
00218 m_ftable->fp_references(&_npiHandle, _assoc, _path,
00219 role.empty() ? 0 : role.c_str(),
00220 includeQualifiers, includeClassOrigin,
00221 _plLen > 0 ? &_propertyList[0] : 0, _plLen);
00222
00223 for (std::vector<const char*>::iterator i = _propertyList.begin();
00224 i != _propertyList.end(); ++i)
00225 {
00226 free(const_cast<void*>(static_cast<const void*>(*i)));
00227 }
00228 if (_npiHandle.errorOccurred)
00229 {
00230 OW_THROWCIMMSG(CIMException::FAILED, _npiHandle.providerError);
00231 }
00232 int n = ::VectorSize(&_npiHandle,v);
00233 OW_LOG_DEBUG(env->getLogger(COMPONENT_NAME), Format("PerlAssociatorProviderProxy::"
00234 "references() got %1 associator instances", n - 1));
00235
00236
00237 ELocalOnlyFlag localOnly = E_NOT_LOCAL_ONLY;
00238 ::CIMInstance my_inst;
00239 for (int i=0; i < n; i++)
00240 {
00241 my_inst.ptr = _VectorGet(&_npiHandle,v,i);
00242 CIMInstance ow_inst(*
00243 static_cast<CIMInstance *>(my_inst.ptr) );
00244
00245
00246
00247
00248 result.handle( ow_inst.clone(localOnly,includeQualifiers,
00249 includeClassOrigin,propertyList) );
00250 }
00251 }
00252 else
00253 {
00254 OW_THROWCIMMSG(CIMException::FAILED, "Provider does not support references");
00255 }
00256 }
00258 void
00259 PerlAssociatorProviderProxy::referenceNames(
00260 const ProviderEnvironmentIFCRef &env,
00261 CIMObjectPathResultHandlerIFC& result,
00262 const String& ns,
00263 const CIMObjectPath& objectName,
00264 const String& resultClass,
00265 const String& role)
00266 {
00267 OW_LOG_DEBUG(env->getLogger(COMPONENT_NAME), "PerlAssociatorProviderProxy::referenceNames()");
00268 if (m_ftable->fp_referenceNames != NULL)
00269 {
00270 ::NPIHandle _npiHandle = { 0, 0, 0, 0, m_ftable->npicontext};
00271 NPIHandleFreer nhf(_npiHandle);
00272 ProviderEnvironmentIFCRef env2(env);
00273 _npiHandle.thisObject = static_cast<void *>(&env2);
00274
00275
00276
00277 CIMObjectPath assocName2(resultClass);
00278 ::CIMObjectPath _assoc = { static_cast<void *> (&assocName2)};
00279
00280 CIMObjectPath objectNameWithNS(objectName);
00281 objectNameWithNS.setNameSpace(ns);
00282 ::CIMObjectPath _path = { static_cast<void *> (&objectNameWithNS)};
00283 ::Vector v =
00284 m_ftable->fp_referenceNames(&_npiHandle, _assoc, _path,
00285 role.empty() ? 0 : role.c_str());
00286 if (_npiHandle.errorOccurred)
00287 {
00288 OW_THROWCIMMSG(CIMException::FAILED, _npiHandle.providerError);
00289 }
00290 ::CIMObjectPath my_cop;
00291 for (int i=::VectorSize(&_npiHandle, v) - 1; i >= 0; i--)
00292 {
00293 my_cop.ptr = _VectorGet(&_npiHandle,v,i);
00294 CIMObjectPath ow_cop(*
00295 static_cast<CIMObjectPath*>(my_cop.ptr) );
00296 result.handle(ow_cop);
00297 }
00298 }
00299 else
00300 {
00301 OW_THROWCIMMSG(CIMException::FAILED, "Provider does not support referenceNames");
00302 }
00303 }
00304
00305 }
00306