OW_PerlIndicationProviderProxy.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_PerlIndicationProviderProxy.hpp"
00032 #include "NPIExternal.hpp"
00033 #include "OW_CIMException.hpp"
00034 #include "OW_Format.hpp"
00035 #include "OW_Logger.hpp"
00036 #include "OW_NPIProviderIFCUtils.hpp"
00037 #include "OW_WQLSelectStatement.hpp"
00038 
00039 namespace OW_NAMESPACE
00040 {
00041 
00042 namespace
00043 {
00044    const String COMPONENT_NAME("ow.provider.perlnpi.ifc");
00045 }
00046 
00048 void
00049 PerlIndicationProviderProxy::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 
00062       NPIHandleFreer nhf(_npiHandle);
00063       OW_LOG_DEBUG(env->getLogger(COMPONENT_NAME), "deactivateFilter");
00064       ProviderEnvironmentIFCRef env2(env);
00065       _npiHandle.thisObject = static_cast<void *>(&env2);
00066       //WQLSelectStatement mutableFilter(filter);
00067       //CIMObjectPath mutablePath(classes[0], nameSpace);
00068       //SelectExp exp = {&mutableFilter};
00069       //::CIMObjectPath cop = {&mutablePath};
00070       SelectExp exp;
00071       ::CIMObjectPath cop;
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 PerlIndicationProviderProxy::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       //CIMObjectPath mutablePath(classes[0], nameSpace);
00100       //SelectExp exp = {&mutableFilter};
00101       //::CIMObjectPath cop = {&mutablePath};
00102       SelectExp exp;
00103       ::CIMObjectPath cop;
00104       m_ftable->fp_activateFilter( &_npiHandle, exp, eventType.c_str(), cop, firstActivation);
00105       if (_npiHandle.errorOccurred)
00106       {
00107          OW_THROWCIMMSG(CIMException::FAILED,
00108          _npiHandle.providerError);
00109       }
00110    }
00111 }
00113 void
00114 PerlIndicationProviderProxy::authorizeFilter(
00115    const ProviderEnvironmentIFCRef& env,
00116    const WQLSelectStatement& filter,
00117    const String& eventType,
00118    const String& nameSpace,
00119    const StringArray& classes,
00120    const String& owner)
00121 {
00122    OW_LOG_DEBUG(env->getLogger(COMPONENT_NAME), "authorizeFilter");
00123    if (m_ftable->fp_authorizeFilter != NULL)
00124    {
00125       ::NPIHandle _npiHandle = { 0, 0, 0, 0, m_ftable->npicontext};
00126 
00127       NPIHandleFreer nhf(_npiHandle);
00128       OW_LOG_DEBUG(env->getLogger(COMPONENT_NAME), "authorizeFilter2");
00129       ProviderEnvironmentIFCRef env2(env);
00130       _npiHandle.thisObject = static_cast<void *>(&env2);
00131       //WQLSelectStatement mutableFilter(filter);
00132       //CIMObjectPath mutablePath(classes[0], nameSpace);
00133       //SelectExp exp = {&mutableFilter};
00134       //::CIMObjectPath cop = {&mutablePath};
00135       SelectExp exp;
00136       ::CIMObjectPath cop;
00137       m_ftable->fp_authorizeFilter( &_npiHandle, exp, eventType.c_str(), cop, owner.c_str());
00138       if (_npiHandle.errorOccurred)
00139       {
00140          OW_THROWCIMMSG(CIMException::FAILED,
00141          _npiHandle.providerError);
00142       }
00143    }
00144 }
00146 int
00147 PerlIndicationProviderProxy::mustPoll(
00148    const ProviderEnvironmentIFCRef& env,
00149    const WQLSelectStatement& filter,
00150    const String& eventType,
00151    const String& nameSpace,
00152    const StringArray& classes)
00153 {
00154    OW_LOG_DEBUG(env->getLogger(COMPONENT_NAME), "mustPoll");
00155    if (m_ftable->fp_mustPoll != NULL)
00156    {
00157       ::NPIHandle _npiHandle = { 0, 0, 0, 0, m_ftable->npicontext};
00158       NPIHandleFreer nhf(_npiHandle);
00159       OW_LOG_DEBUG(env->getLogger(COMPONENT_NAME), "mustPoll2");
00160       ProviderEnvironmentIFCRef env2(env);
00161       _npiHandle.thisObject = static_cast<void *>(&env2);
00162       //WQLSelectStatement mutableFilter(filter);
00163       //CIMObjectPath mutablePath(classes[0], nameSpace);
00164       //SelectExp exp = {&mutableFilter};
00165       //::CIMObjectPath cop = {&mutablePath};
00166       SelectExp exp;
00167       ::CIMObjectPath cop;
00168       int rval = m_ftable->fp_mustPoll( &_npiHandle, exp, eventType.c_str(), cop);
00169       if (_npiHandle.errorOccurred)
00170       {
00171          OW_THROWCIMMSG(CIMException::FAILED,
00172          _npiHandle.providerError);
00173       }
00174       // Perl providers only return 0 or 1 for mustPoll.
00175       // OpenWBEM expects mustPoll to return the polling interval,
00176       // so we'll return a reasonable polling interval (5 mins.)
00177       if (rval > 0)
00178       {
00179          return 5 * 60;
00180       }
00181    }
00182    return 0;
00183 }
00184 
00185 } // end namespace OW_NAMESPACE
00186 

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