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