OW_CMPIIndicationProviderProxy.cpp

Go to the documentation of this file.
00001 /*******************************************************************************
00002 * Copyright (C) 2003-2004 Vintela, Inc., IBM Corp. 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 * Author:        Markus Mueller <sedgewick_de@yahoo.de>
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; // = {&mutableFilter};
00082       //CMPIFlags flgs = 0;
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; // = {&mutableFilter};
00129       //CMPIFlags flgs = 0;
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; // = {&mutableFilter};
00177       //CMPIFlags flgs = 0;
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; // = {&mutableFilter};
00221       //CMPIFlags flgs = 0;
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 } // end namespace OW_NAMESPACE
00242 

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