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
00031
00032
00033 #include "OW_config.h"
00034 #include "OW_CMPIAssociatorProviderProxy.hpp"
00035 #include "OW_CIMClass.hpp"
00036 #include "OW_CIMException.hpp"
00037 #include "OW_Format.hpp"
00038 #include "OW_CMPIProviderIFCUtils.hpp"
00039 #include "OW_Logger.hpp"
00040 #include "cmpisrv.h"
00041
00042 #ifdef OW_HAVE_ALLOCA_H
00043 #include <alloca.h>
00044 #endif
00045 #include <stdlib.h>
00046
00047 namespace OW_NAMESPACE
00048 {
00049
00050 using namespace WBEMFlags;
00051
00052 namespace
00053 {
00054 const String COMPONENT_NAME("ow.provider.cmpi.ifc");
00055 }
00057 void CMPIAssociatorProviderProxy::associatorNames(
00058 const ProviderEnvironmentIFCRef &env,
00059 CIMObjectPathResultHandlerIFC& result,
00060 const String& ns,
00061 const CIMObjectPath& objectName,
00062 const String& assocClass,
00063 const String& resultClass,
00064 const String& role,
00065 const String& resultRole)
00066 {
00067 OW_LOG_DEBUG(env->getLogger(COMPONENT_NAME), "CMPIAssociatorProviderProxy::associatorNames()");
00068
00069 m_ftable->lastAccessTime.setToCurrent();
00070
00071 if (m_ftable->miVector.assocMI->ft->associatorNames != NULL)
00072 {
00073 CMPIStatus rc = {CMPI_RC_OK, NULL};
00074 ::CMPIOperationContext context;
00075 ProviderEnvironmentIFCRef env2(env);
00076 ::CMPI_Broker localBroker(m_ftable->broker);
00077 localBroker.hdl = static_cast<void *>(&env2);
00078 CMPI_ContextOnStack eCtx(context);
00079 CMPI_ThreadContext thr(&localBroker, &eCtx);
00080
00081
00082 CIMObjectPath objectNameWithNS(objectName);
00083 objectNameWithNS.setNameSpace(ns);
00084 CMPI_ObjectPathOnStack eRef(objectNameWithNS);
00085 CMPI_ResultOnStack eRes(result);
00086
00087 char *aClass = const_cast<char*>(assocClass.c_str());
00088
00089 CMPIFlags flgs = 0;
00090 char *_resultClass = const_cast<char*>(resultClass.empty() ? 0 :
00091 resultClass.c_str());
00092
00093 char *_role = const_cast<char*>(role.empty() ? 0 : role.c_str());
00094
00095 char *_resultRole = const_cast<char*>(resultRole.empty() ? 0 :
00096 resultRole.c_str());
00097
00098 eCtx.ft->addEntry(&eCtx, const_cast<char*>(CMPIInvocationFlags),
00099 (CMPIValue *)&flgs, CMPI_uint32);
00100
00101 ::CMPIAssociationMI *mi = m_ftable->miVector.assocMI;
00102
00103 rc = m_ftable->miVector.assocMI->ft->associatorNames(mi, &eCtx, &eRes,
00104 &eRef, aClass, _resultClass, _role, _resultRole);
00105
00106 if (rc.rc != CMPI_RC_OK)
00107 {
00108 OW_THROWCIMMSG(CIMException::ErrNoType(rc.rc), rc.msg ? CMGetCharPtr(rc.msg) : "");
00109 }
00110 }
00111 else
00112 {
00113 OW_THROWCIMMSG(CIMException::FAILED,
00114 "Provider does not support associatorNames");
00115 }
00116 }
00118 void CMPIAssociatorProviderProxy::associators(
00119 const ProviderEnvironmentIFCRef &env,
00120 CIMInstanceResultHandlerIFC& result,
00121 const String& ns,
00122 const CIMObjectPath& objectName,
00123 const String& assocClass,
00124 const String& resultClass,
00125 const String& role,
00126 const String& resultRole,
00127 EIncludeQualifiersFlag includeQualifiers,
00128 EIncludeClassOriginFlag includeClassOrigin,
00129 const StringArray *propertyList)
00130 {
00131 OW_LOG_DEBUG(env->getLogger(COMPONENT_NAME), "CMPIAssociatorProviderProxy::associators()");
00132
00133 m_ftable->lastAccessTime.setToCurrent();
00134
00135 if (m_ftable->miVector.assocMI->ft->associators != NULL)
00136 {
00137 const char **props = NULL;
00138 int pCount = 0;
00139
00140 CMPIStatus rc = {CMPI_RC_OK, NULL};
00141 ::CMPIOperationContext context;
00142 ProviderEnvironmentIFCRef env2(env);
00143 ::CMPI_Broker localBroker(m_ftable->broker);
00144 localBroker.hdl = static_cast<void *>(&env2);
00145 CMPI_ContextOnStack eCtx(context);
00146 CMPI_ThreadContext thr(&localBroker, &eCtx);
00147
00148 CIMObjectPath objectNameWithNS(objectName);
00149 objectNameWithNS.setNameSpace(ns);
00150 CMPI_ObjectPathOnStack eRef(objectNameWithNS);
00151 CMPI_ResultOnStack eRes(result);
00152
00153 char* aClass = const_cast<char*>(assocClass.c_str());
00154
00155 if (propertyList && propertyList->size() > 0)
00156 {
00157 pCount = propertyList->size();
00158 props = reinterpret_cast<const char **>
00159 (alloca(1+pCount*sizeof(char *)));
00160
00161 for (int i = 0; i < pCount; i++)
00162 {
00163 props[i]= const_cast<char*>((*propertyList)[i].c_str());
00164 }
00165
00166 props[pCount]=NULL;
00167 }
00168
00169 CMPIFlags flgs = 0;
00170
00171 if (includeQualifiers)
00172 {
00173 flgs |= CMPI_FLAG_IncludeQualifiers;
00174 }
00175
00176 if (includeClassOrigin)
00177 {
00178 flgs |= CMPI_FLAG_IncludeClassOrigin;
00179 }
00180
00181 char *_resultClass = const_cast<char*>(resultClass.empty() ? 0 :
00182 resultClass.c_str());
00183
00184 char *_role = const_cast<char*>(role.empty() ? 0 : role.c_str());
00185
00186 char * _resultRole = const_cast<char*>(resultRole.empty() ? 0 :
00187 resultRole.c_str());
00188
00189 eCtx.ft->addEntry(&eCtx, const_cast<char*>(CMPIInvocationFlags),
00190 (CMPIValue *)&flgs, CMPI_uint32);
00191
00192 ::CMPIAssociationMI * mi = m_ftable->miVector.assocMI;
00193
00194 rc=m_ftable->miVector.assocMI->ft->associators(
00195 mi,&eCtx,&eRes,&eRef, aClass,
00196 _resultClass, _role, _resultRole, props);
00197
00198 if (rc.rc != CMPI_RC_OK)
00199 {
00200 OW_THROWCIMMSG(CIMException::ErrNoType(rc.rc), rc.msg ? CMGetCharPtr(rc.msg) : "");
00201 }
00202 }
00203 else
00204 {
00205 OW_THROWCIMMSG(CIMException::FAILED,
00206 "Provider does not support associators");
00207 }
00208 }
00210 void CMPIAssociatorProviderProxy::references(
00211 const ProviderEnvironmentIFCRef &env,
00212 CIMInstanceResultHandlerIFC& result,
00213 const String& ns,
00214 const CIMObjectPath& objectName,
00215 const String& resultClass,
00216 const String& role,
00217 EIncludeQualifiersFlag includeQualifiers,
00218 EIncludeClassOriginFlag includeClassOrigin,
00219 const StringArray *propertyList)
00220 {
00221 OW_LOG_DEBUG(env->getLogger(COMPONENT_NAME), "CMPIAssociatorProviderProxy::references()");
00222
00223 m_ftable->lastAccessTime.setToCurrent();
00224
00225 if (m_ftable->miVector.assocMI->ft->references != NULL)
00226 {
00227 const char **props = NULL;
00228 int pCount = 0;
00229
00230 CMPIStatus rc = {CMPI_RC_OK, NULL};
00231 ::CMPIOperationContext context;
00232 ProviderEnvironmentIFCRef env2(env);
00233
00234 ::CMPI_Broker localBroker(m_ftable->broker);
00235 localBroker.hdl = static_cast<void *>(&env2);
00236
00237 CMPI_ContextOnStack eCtx(context);
00238 CMPI_ThreadContext thr(&localBroker, &eCtx);
00239
00240 CIMObjectPath objectNameWithNS(objectName);
00241 objectNameWithNS.setNameSpace(ns);
00242 CMPI_ObjectPathOnStack eRef(objectNameWithNS);
00243 CMPI_ResultOnStack eRes(result);
00244 char *aClass = const_cast<char*>(resultClass.c_str());
00245
00246 if (propertyList)
00247 {
00248 if (propertyList->size() > 0)
00249 {
00250 pCount = propertyList->size();
00251 props = reinterpret_cast<const char **>
00252 (alloca(1+pCount*sizeof(char *)));
00253
00254 for (int i = 0; i < pCount; i++)
00255 {
00256 props[i] = ((*propertyList)[i].c_str());
00257 }
00258
00259 props[pCount] = NULL;
00260 }
00261 }
00262
00263 CMPIFlags flgs = 0;
00264
00265 if (includeQualifiers)
00266 {
00267 flgs |= CMPI_FLAG_IncludeQualifiers;
00268 }
00269
00270 if (includeClassOrigin)
00271 {
00272 flgs |= CMPI_FLAG_IncludeClassOrigin;
00273 }
00274
00275 char *_role = const_cast<char*>(role.empty() ? 0 : role.c_str());
00276 eCtx.ft->addEntry(&eCtx, const_cast<char*>(CMPIInvocationFlags),
00277 (CMPIValue *)&flgs, CMPI_uint32);
00278
00279 ::CMPIAssociationMI *mi = m_ftable->miVector.assocMI;
00280 rc=m_ftable->miVector.assocMI->ft->references(mi, &eCtx, &eRes, &eRef,
00281 aClass, _role, props);
00282
00283 if (rc.rc != CMPI_RC_OK)
00284 {
00285 OW_THROWCIMMSG(CIMException::ErrNoType(rc.rc), rc.msg ? CMGetCharPtr(rc.msg) : "");
00286 }
00287 }
00288 else
00289 {
00290 OW_THROWCIMMSG(CIMException::FAILED,
00291 "Provider does not support references");
00292 }
00293 }
00295 void CMPIAssociatorProviderProxy::referenceNames(
00296 const ProviderEnvironmentIFCRef &env,
00297 CIMObjectPathResultHandlerIFC& result,
00298 const String& ns,
00299 const CIMObjectPath& objectName,
00300 const String& resultClass,
00301 const String& role)
00302 {
00303 OW_LOG_DEBUG(env->getLogger(COMPONENT_NAME), "CMPIAssociatorProviderProxy::referenceNames()");
00304
00305 m_ftable->lastAccessTime.setToCurrent();
00306
00307 if (m_ftable->miVector.assocMI->ft->referenceNames != NULL)
00308 {
00309 CMPIStatus rc = {CMPI_RC_OK, NULL};
00310 ::CMPIOperationContext context;
00311
00312 ProviderEnvironmentIFCRef env2(env);
00313 ::CMPI_Broker localBroker(m_ftable->broker);
00314 localBroker.hdl = static_cast<void *>(&env2);
00315
00316 CMPI_ContextOnStack eCtx(context);
00317 CMPI_ThreadContext thr(&localBroker, &eCtx);
00318
00319
00320 CIMObjectPath objectNameWithNS(objectName);
00321 objectNameWithNS.setNameSpace(ns);
00322
00323 CMPI_ObjectPathOnStack eRef(objectNameWithNS);
00324 CMPI_ResultOnStack eRes(result);
00325 char* aClass = const_cast<char*>(resultClass.c_str());
00326 CMPIFlags flgs = 0;
00327 char* _role = const_cast<char*>(role.empty() ? 0 : role.c_str());
00328 eCtx.ft->addEntry(&eCtx, const_cast<char*>(CMPIInvocationFlags),
00329 (CMPIValue *)&flgs, CMPI_uint32);
00330
00331 ::CMPIAssociationMI * mi = m_ftable->miVector.assocMI;
00332 rc = m_ftable->miVector.assocMI->ft->referenceNames(
00333 mi, &eCtx, &eRes, &eRef, aClass, _role);
00334
00335 if (rc.rc != CMPI_RC_OK)
00336 {
00337 OW_THROWCIMMSG(CIMException::ErrNoType(rc.rc), rc.msg ? CMGetCharPtr(rc.msg) : "");
00338 }
00339 }
00340 else
00341 {
00342 OW_THROWCIMMSG(CIMException::FAILED,
00343 "Provider does not support referenceNames");
00344 }
00345 }
00346
00347 }
00348