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_CMPIIndicationProviderProxy.hpp"
00035 #include "OW_CIMException.hpp"
00036 #include "OW_Format.hpp"
00037 #include "OW_CMPIProviderIFCUtils.hpp"
00038 #include "OW_WQLSelectStatement.hpp"
00039 #include "OW_Logger.hpp"
00040 #include "cmpisrv.h"
00041 
00042 #define CMPI_POLLING_INTERVAL (5*60)
00043 
00044 namespace OW_NAMESPACE
00045 {
00046 
00047 namespace
00048 {
00049    const String COMPONENT_NAME("ow.provider.cmpi.ifc");
00050 }
00051 
00053 void
00054 CMPIIndicationProviderProxy::deActivateFilter(
00055    const ProviderEnvironmentIFCRef &env,
00056    const WQLSelectStatement &filter,
00057    const String &eventType,
00058    const String& nameSpace,
00059    const StringArray& classes)
00060 {
00061    bool lastActivation = (--m_activationCount == 0);
00062    OW_LOG_DEBUG(env->getLogger(COMPONENT_NAME), "deactivateFilter");
00063    m_ftable->lastAccessTime.setToCurrent();
00064    if (m_ftable->miVector.indMI->ft->deActivateFilter != NULL)
00065    {
00066       CMPIStatus rc = {CMPI_RC_OK, NULL};
00067       ::CMPIOperationContext context;
00068       ProviderEnvironmentIFCRef env2(env);
00069       ::CMPI_Broker localBroker(m_ftable->broker);
00070       localBroker.hdl = static_cast<void *>(&env2);
00071       CMPI_ContextOnStack eCtx(context);
00072       CMPI_ThreadContext thr(&localBroker, &eCtx);
00073       WQLSelectStatement mutableFilter(filter);
00074       CIMObjectPath mutablePath;
00075       mutablePath.setNameSpace(nameSpace);
00076 
00077       if (!classes.empty())
00078          mutablePath.setClassName(classes[0]);
00079 
00080       CMPI_ObjectPathOnStack eRef(mutablePath);
00081       CMPISelectExp exp; 
00082       
00083 		::CMPIIndicationMI *mi = m_ftable->miVector.indMI;
00084       char* _eventType = const_cast<char*>(eventType.c_str());
00085       rc = m_ftable->miVector.indMI->ft->deActivateFilter(mi, &eCtx,
00086          &exp, _eventType, &eRef, lastActivation);
00087 
00088       if (rc.rc != CMPI_RC_OK)
00089       {
00090          OW_THROWCIMMSG(CIMException::ErrNoType(rc.rc), rc.msg ? CMGetCharPtr(rc.msg) : "");
00091       }
00092    }
00093    else
00094    {
00095       OW_THROWCIMMSG(CIMException::FAILED,
00096          "Provider does not support deactivateFilter");
00097    }
00098 }
00100 void
00101 CMPIIndicationProviderProxy::activateFilter(
00102    const ProviderEnvironmentIFCRef &env,
00103    const WQLSelectStatement &filter,
00104    const String &eventType,
00105    const String& nameSpace,
00106    const StringArray& classes)
00107 {
00108    bool firstActivation = (m_activationCount++ == 0);
00109    OW_LOG_DEBUG(env->getLogger(COMPONENT_NAME), "activateFilter");
00110    m_ftable->lastAccessTime.setToCurrent();
00111    if (m_ftable->miVector.indMI->ft->activateFilter != NULL)
00112    {
00113       CMPIStatus rc = {CMPI_RC_OK, NULL};
00114       ::CMPIOperationContext context;
00115       ProviderEnvironmentIFCRef env2(env);
00116       ::CMPI_Broker localBroker(m_ftable->broker);
00117       localBroker.hdl = static_cast<void *>(&env2);
00118       CMPI_ContextOnStack eCtx(context);
00119       CMPI_ThreadContext thr(&localBroker, &eCtx);
00120       WQLSelectStatement mutableFilter(filter);
00121       CIMObjectPath mutablePath;
00122       mutablePath.setNameSpace(nameSpace);
00123 
00124       if (!classes.empty())
00125          mutablePath.setClassName(classes[0]);
00126 
00127       CMPI_ObjectPathOnStack eRef(mutablePath);
00128       CMPISelectExp exp; 
00129       
00130 		::CMPIIndicationMI * mi = m_ftable->miVector.indMI;
00131       char* _eventType = const_cast<char*>(eventType.c_str());
00132 
00133       rc = m_ftable->miVector.indMI->ft->activateFilter(mi, &eCtx, 
00134          &exp, _eventType, &eRef, firstActivation);
00135 
00136       if (rc.rc != CMPI_RC_OK)
00137       {
00138          OW_THROWCIMMSG(CIMException::ErrNoType(rc.rc), rc.msg ? CMGetCharPtr(rc.msg) : "");
00139       }
00140    }
00141    else
00142    {
00143       OW_THROWCIMMSG(CIMException::FAILED,
00144          "Provider does not support activateFilter");
00145    }
00146 }
00148 void
00149 CMPIIndicationProviderProxy::authorizeFilter(
00150    const ProviderEnvironmentIFCRef &env,
00151    const WQLSelectStatement &filter,
00152    const String &eventType,
00153    const String &nameSpace,
00154    const StringArray &classes,
00155    const String &owner)
00156 {
00157    OW_LOG_DEBUG(env->getLogger(COMPONENT_NAME), "authorizeFilter");
00158    m_ftable->lastAccessTime.setToCurrent();
00159    if (m_ftable->miVector.indMI->ft->authorizeFilter != NULL)
00160    {
00161       CMPIStatus rc = {CMPI_RC_OK, NULL};
00162       ::CMPIOperationContext context;
00163       ProviderEnvironmentIFCRef env2(env);
00164       ::CMPI_Broker localBroker(m_ftable->broker);
00165       localBroker.hdl = static_cast<void *>(&env2);
00166       CMPI_ContextOnStack eCtx(context);
00167       CMPI_ThreadContext thr(&localBroker, &eCtx);
00168       WQLSelectStatement mutableFilter(filter);
00169       CIMObjectPath mutablePath;
00170       mutablePath.setNameSpace(nameSpace);
00171 
00172       if (!classes.empty())
00173          mutablePath.setClassName(classes[0]);
00174 
00175       CMPI_ObjectPathOnStack eRef(mutablePath);
00176       CMPISelectExp exp; 
00177       
00178 		::CMPIIndicationMI * mi = m_ftable->miVector.indMI;
00179       char* _eventType = const_cast<char*>(eventType.c_str());
00180       char* _owner = const_cast<char*>(owner.c_str());
00181       rc = m_ftable->miVector.indMI->ft->authorizeFilter(mi, &eCtx, 
00182          &exp, _eventType, &eRef, _owner);
00183       if (rc.rc != CMPI_RC_OK)
00184       {
00185          OW_THROWCIMMSG(CIMException::ErrNoType(rc.rc), rc.msg ? CMGetCharPtr(rc.msg) : "");
00186       }
00187    }
00188    else
00189    {
00190       OW_THROWCIMMSG(CIMException::FAILED,
00191          "Provider does not support authorizeFilter");
00192    }
00193 }
00195 int
00196 CMPIIndicationProviderProxy::mustPoll(
00197    const ProviderEnvironmentIFCRef &env,
00198    const WQLSelectStatement &filter,
00199    const String &eventType,
00200    const String &nameSpace,
00201    const StringArray &classes)
00202 {
00203    OW_LOG_DEBUG(env->getLogger(COMPONENT_NAME), "mustPoll");
00204    m_ftable->lastAccessTime.setToCurrent();
00205    if (m_ftable->miVector.indMI->ft->mustPoll != NULL)
00206    {
00207       CMPIStatus rc = {CMPI_RC_OK, NULL};
00208       ::CMPIOperationContext context;
00209       ProviderEnvironmentIFCRef env2(env);
00210       ::CMPI_Broker localBroker(m_ftable->broker);
00211       localBroker.hdl = static_cast<void *>(&env2);
00212       CMPI_ContextOnStack eCtx(context);
00213       CMPI_ThreadContext thr(&localBroker, &eCtx);
00214       WQLSelectStatement mutableFilter(filter);
00215       CIMObjectPath mutablePath;
00216       mutablePath.setNameSpace(nameSpace);
00217       if (!classes.empty())
00218          mutablePath.setClassName(classes[0]);
00219       CMPI_ObjectPathOnStack eRef(mutablePath);
00220       CMPISelectExp exp; 
00221       
00222 		::CMPIIndicationMI * mi = m_ftable->miVector.indMI;
00223       char* _eventType = const_cast<char*>(eventType.c_str());
00224       rc = m_ftable->miVector.indMI->ft->mustPoll(mi, &eCtx, 
00225          &exp, _eventType, &eRef);
00226 
00227       if (rc.rc != CMPI_RC_OK)
00228       {
00229          OW_THROWCIMMSG(CIMException::ErrNoType(rc.rc), rc.msg ? CMGetCharPtr(rc.msg) : "");
00230       }
00231    }
00232    else
00233    {
00234       OW_THROWCIMMSG(CIMException::FAILED,
00235          "Provider does not support mustPoll");
00236    }
00237 
00238    return CMPI_POLLING_INTERVAL;
00239 }
00240 
00241 } 
00242