OW_NPIIndicationProviderProxy.cpp

Go to the documentation of this file.
00001 /*******************************************************************************
00002 * Copyright (C) 2001-2004 Vintela, Inc. All rights reserved.
00003 *
00004 * Redistribution and use in source and binary forms, with or without
00005 * modification, are permitted provided that the following conditions are met:
00006 *
00007 *  - Redistributions of source code must retain the above copyright notice,
00008 *    this list of conditions and the following disclaimer.
00009 *
00010 *  - Redistributions in binary form must reproduce the above copyright notice,
00011 *    this list of conditions and the following disclaimer in the documentation
00012 *    and/or other materials provided with the distribution.
00013 *
00014 *  - Neither the name of Vintela, Inc. nor the names of its
00015 *    contributors may be used to endorse or promote products derived from this
00016 *    software without specific prior written permission.
00017 *
00018 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS IS''
00019 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
00020 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
00021 * ARE DISCLAIMED. IN NO EVENT SHALL Vintela, Inc. OR THE CONTRIBUTORS
00022 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
00023 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
00024 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
00025 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
00026 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
00027 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
00028 * POSSIBILITY OF SUCH DAMAGE.
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       // NPI providers only return 0 or 1 for mustPoll.
00180       // OpenWBEM expects mustPoll to return the polling interval,
00181       // so we'll return a reasonable polling interval (5 mins.)
00182       if (rval > 0)
00183       {
00184          return 5 * 60;
00185       }
00186    }
00187    return 0;
00188 }
00189 
00190 } // end namespace OW_NAMESPACE
00191 

Generated on Thu Feb 9 08:48:07 2006 for openwbem by  doxygen 1.4.6