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_NPIIndicationProviderProxy.hpp"
00032 #include "NPIExternal.hpp"
00033 #include "OW_CIMException.hpp"
00034 #include "OW_Format.hpp"
00035 #include "OW_NPIProviderIFCUtils.hpp"
00036 #include "OW_WQLSelectStatement.hpp"
00037 #include "OW_Logger.hpp"
00038 
00039 namespace OW_NAMESPACE
00040 {
00041 
00042 namespace
00043 {
00044    const String COMPONENT_NAME("ow.provider.npi.ifc");
00045 }
00046 
00048 void
00049 NPIIndicationProviderProxy::deActivateFilter(
00050    const ProviderEnvironmentIFCRef &env,
00051    const WQLSelectStatement &filter,
00052    const String &eventType,
00053    const String& nameSpace,
00054    const StringArray& classes)
00055 {
00056    bool lastActivation = (--m_activationCount == 0);
00057    OW_LOG_DEBUG(env->getLogger(COMPONENT_NAME), "deactivateFilter");
00058    if (m_ftable->fp_deActivateFilter != NULL)
00059    {
00060          ::NPIHandle _npiHandle = { 0, 0, 0, 0, m_ftable->npicontext};
00061       NPIHandleFreer nhf(_npiHandle);
00062       OW_LOG_DEBUG(env->getLogger(COMPONENT_NAME), "deactivateFilter");
00063       ProviderEnvironmentIFCRef env2(env);
00064       _npiHandle.thisObject = static_cast<void *>(&env2);
00065       WQLSelectStatement mutableFilter(filter);
00066       CIMObjectPath mutablePath;
00067       mutablePath.setNameSpace(nameSpace);
00068       if (!classes.empty())
00069          mutablePath.setClassName(classes[0]);
00070       SelectExp exp = {&mutableFilter};
00071       ::CIMObjectPath cop = {&mutablePath};
00072       m_ftable->fp_deActivateFilter( &_npiHandle, exp, eventType.c_str(), cop, lastActivation);
00073       if (_npiHandle.errorOccurred)
00074       {
00075          OW_THROWCIMMSG(CIMException::FAILED,
00076          _npiHandle.providerError);
00077       }
00078    }
00079 }
00081 void
00082 NPIIndicationProviderProxy::activateFilter(
00083    const ProviderEnvironmentIFCRef &env,
00084    const WQLSelectStatement &filter,
00085    const String &eventType,
00086    const String& nameSpace,
00087    const StringArray& classes)
00088 {
00089    bool firstActivation = (m_activationCount++ == 0);
00090    OW_LOG_DEBUG(env->getLogger(COMPONENT_NAME), "activateFilter");
00091    if (m_ftable->fp_activateFilter != NULL)
00092    {
00093       OW_LOG_DEBUG(env->getLogger(COMPONENT_NAME), "activateFilter2");
00094          ::NPIHandle _npiHandle = { 0, 0, 0, 0, m_ftable->npicontext};
00095       NPIHandleFreer nhf(_npiHandle);
00096       ProviderEnvironmentIFCRef env2(env);
00097       _npiHandle.thisObject = static_cast<void *>(&env2);
00098       WQLSelectStatement mutableFilter(filter);
00099       SelectExp exp = {&mutableFilter};
00100       
00101       CIMObjectPath mutablePath;
00102       mutablePath.setNameSpace(nameSpace);
00103       if (!classes.empty())
00104          mutablePath.setClassName(classes[0]);
00105       ::CIMObjectPath cop = {&mutablePath};
00106       m_ftable->fp_activateFilter( &_npiHandle, exp, eventType.c_str(), cop, firstActivation);
00107       if (_npiHandle.errorOccurred)
00108       {
00109          OW_THROWCIMMSG(CIMException::FAILED,
00110          _npiHandle.providerError);
00111       }
00112    }
00113 }
00115 void
00116 NPIIndicationProviderProxy::authorizeFilter(
00117    const ProviderEnvironmentIFCRef &env,
00118    const WQLSelectStatement &filter,
00119    const String &eventType,
00120    const String& nameSpace,
00121    const StringArray& classes,
00122    const String &owner)
00123 {
00124    OW_LOG_DEBUG(env->getLogger(COMPONENT_NAME), "authorizeFilter");
00125    if (m_ftable->fp_deActivateFilter != NULL)
00126    {
00127          ::NPIHandle _npiHandle = { 0, 0, 0, 0, m_ftable->npicontext};
00128       NPIHandleFreer nhf(_npiHandle);
00129       OW_LOG_DEBUG(env->getLogger(COMPONENT_NAME), "authorizeFilter2");
00130       ProviderEnvironmentIFCRef env2(env);
00131       _npiHandle.thisObject = static_cast<void *>(&env2);
00132       WQLSelectStatement mutableFilter(filter);
00133       SelectExp exp = {&mutableFilter};
00134       
00135       CIMObjectPath mutablePath;
00136       mutablePath.setNameSpace(nameSpace);
00137       if (!classes.empty())
00138          mutablePath.setClassName(classes[0]);
00139       ::CIMObjectPath cop = {&mutablePath};
00140       m_ftable->fp_authorizeFilter( &_npiHandle, exp, eventType.c_str(), cop, owner.c_str());
00141       if (_npiHandle.errorOccurred)
00142       {
00143          OW_THROWCIMMSG(CIMException::FAILED,
00144          _npiHandle.providerError);
00145       }
00146    }
00147 }
00149 int
00150 NPIIndicationProviderProxy::mustPoll(
00151    const ProviderEnvironmentIFCRef &env,
00152    const WQLSelectStatement &filter,
00153    const String &eventType,
00154    const String& nameSpace,
00155    const StringArray& classes)
00156 {
00157    OW_LOG_DEBUG(env->getLogger(COMPONENT_NAME), "mustPoll");
00158    if (m_ftable->fp_mustPoll != NULL)
00159    {
00160          ::NPIHandle _npiHandle = { 0, 0, 0, 0, m_ftable->npicontext};
00161       NPIHandleFreer nhf(_npiHandle);
00162       OW_LOG_DEBUG(env->getLogger(COMPONENT_NAME), "mustPoll2");
00163       ProviderEnvironmentIFCRef env2(env);
00164       _npiHandle.thisObject = static_cast<void *>(&env2);
00165       WQLSelectStatement mutableFilter(filter);
00166       SelectExp exp = {&mutableFilter};
00167       
00168       CIMObjectPath mutablePath;
00169       mutablePath.setNameSpace(nameSpace);
00170       if (!classes.empty())
00171          mutablePath.setClassName(classes[0]);
00172       ::CIMObjectPath cop = {&mutablePath};
00173       int rval = m_ftable->fp_mustPoll( &_npiHandle, exp, eventType.c_str(), cop);
00174       if (_npiHandle.errorOccurred)
00175       {
00176          OW_THROWCIMMSG(CIMException::FAILED,
00177          _npiHandle.providerError);
00178       }
00179       
00180       
00181       
00182       if (rval > 0)
00183       {
00184          return 5 * 60;
00185       }
00186    }
00187    return 0;
00188 }
00189 
00190 } 
00191