OW_RemoteAssociatorProvider.cpp

Go to the documentation of this file.
00001 /*******************************************************************************
00002 * Copyright (C) 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 
00035 #include "OW_config.h"
00036 #ifndef OW_DISABLE_ASSOCIATION_TRAVERSAL
00037 #include "OW_RemoteAssociatorProvider.hpp"
00038 #include "OW_RemoteProviderUtils.hpp"
00039 #include "OW_Format.hpp"
00040 #include "OW_CIMException.hpp"
00041 #include "OW_CIMObjectPath.hpp"
00042 #include "OW_ProviderEnvironmentIFC.hpp"
00043 #include "OW_Logger.hpp"
00044 #include "OW_ClientCIMOMHandle.hpp"
00045 
00046 namespace OW_NAMESPACE
00047 {
00048 
00049 using namespace WBEMFlags;
00050 
00051 namespace
00052 {
00053    const String COMPONENT_NAME("ow.provider.remote.ifc");
00054 }
00055 
00057 RemoteAssociatorProvider::RemoteAssociatorProvider(const ProviderEnvironmentIFCRef& env, const String& url, const ClientCIMOMHandleConnectionPoolRef& pool,
00058    bool alwaysSendCredentials, bool useConnectionCredentials)
00059    : m_pool(pool)
00060    , m_url(url)
00061    , m_alwaysSendCredentials(alwaysSendCredentials)
00062    , m_useConnectionCredentials(useConnectionCredentials)
00063 {
00064 }
00065 
00067 RemoteAssociatorProvider::~RemoteAssociatorProvider()
00068 {
00069 }
00070 
00072 void
00073 RemoteAssociatorProvider::references(
00074    const ProviderEnvironmentIFCRef &env,
00075    CIMInstanceResultHandlerIFC &result,
00076    const String &ns,
00077    const CIMObjectPath &objectName,
00078    const String &resultClass,
00079    const String &role,
00080    EIncludeQualifiersFlag includeQualifiers,
00081    EIncludeClassOriginFlag includeClassOrigin,
00082    const StringArray *propertyList)
00083 {
00084    LoggerRef lgr = env->getLogger(COMPONENT_NAME);
00085    OW_LOG_DEBUG(lgr, Format("RemoteAssociatorProvider::references ns = %1, objectName = %2, resultClass = %3, role = %4", ns, objectName, resultClass, role));
00086    String lUrl(m_url);
00087    ClientCIMOMHandleRef hdl = RemoteProviderUtils::getRemoteClientCIMOMHandle(lUrl, m_useConnectionCredentials, env, m_pool, m_alwaysSendCredentials);
00088    OW_LOG_DEBUG(lgr, Format("RemoteAssociatorProvider::references got ClientCIMOMHandleRef for url: %1", lUrl));
00089 
00090    ClientCIMOMHandleConnectionPool::HandleReturner returner(hdl, m_pool, lUrl);
00091 
00092    OW_LOG_DEBUG(lgr, "RemoteAssociatorProvider::references calling remote WBEM server");
00093 
00094    try
00095    {
00096       hdl->references(ns, objectName, result, resultClass, role,
00097          includeQualifiers, includeClassOrigin, propertyList);
00098 
00099    }
00100    catch (CIMException& e)
00101    {
00102       if (e.getErrNo() == CIMException::NOT_SUPPORTED)
00103       {
00104          e.setErrNo(CIMException::FAILED); // providers shouldn't ever throw NOT_SUPPORTED
00105       }
00106       OW_LOG_INFO(lgr, Format("RemoteAssociatorProvider::references remote WBEM server threw: %1", e));
00107       throw;
00108    }
00109    catch (const Exception& e)
00110    {
00111       String msg = Format("RemoteAssociatorProvider::references failed calling remote WBEM server: %1", e);
00112       OW_LOG_ERROR(lgr, msg);
00113       OW_THROWCIMMSG_SUBEX(CIMException::FAILED, msg.c_str(), e);
00114    }
00115 
00116 }
00117 
00119 void
00120 RemoteAssociatorProvider::associators(const ProviderEnvironmentIFCRef &env, CIMInstanceResultHandlerIFC &result, const String &ns, const CIMObjectPath &objectName,
00121    const String &assocClass, const String &resultClass, const String &role, const String &resultRole, WBEMFlags:: EIncludeQualifiersFlag includeQualifiers,
00122    WBEMFlags:: EIncludeClassOriginFlag includeClassOrigin, const StringArray *propertyList)
00123 {
00124    LoggerRef lgr = env->getLogger(COMPONENT_NAME);
00125    OW_LOG_DEBUG(lgr, Format("RemoteAssociatorProvider::associators ns = %1, objectName = %2, assocClass = %3, resultClass = %4, role = %5, resultRole = %6",
00126       ns, objectName, assocClass, resultClass, role, resultRole));
00127    String lUrl(m_url);
00128    ClientCIMOMHandleRef hdl = RemoteProviderUtils::getRemoteClientCIMOMHandle(lUrl, m_useConnectionCredentials, env, m_pool, m_alwaysSendCredentials);
00129    OW_LOG_DEBUG(lgr, Format("RemoteAssociatorProvider::associators got ClientCIMOMHandleRef for url: %1", lUrl));
00130 
00131    ClientCIMOMHandleConnectionPool::HandleReturner returner(hdl, m_pool, lUrl);
00132 
00133    OW_LOG_DEBUG(lgr, "RemoteAssociatorProvider::associators calling remote WBEM server");
00134 
00135    try
00136    {
00137       hdl->associators(ns, objectName, result, assocClass, resultClass, role, resultRole,
00138          includeQualifiers, includeClassOrigin, propertyList);
00139 
00140    }
00141    catch (CIMException& e)
00142    {
00143       if (e.getErrNo() == CIMException::NOT_SUPPORTED)
00144       {
00145          e.setErrNo(CIMException::FAILED); // providers shouldn't ever throw NOT_SUPPORTED
00146       }
00147       OW_LOG_INFO(lgr, Format("RemoteAssociatorProvider::associators remote WBEM server threw: %1", e));
00148       throw;
00149    }
00150    catch (const Exception& e)
00151    {
00152       String msg = Format("RemoteAssociatorProvider::associators failed calling remote WBEM server: %1", e);
00153       OW_LOG_ERROR(lgr, msg);
00154       OW_THROWCIMMSG_SUBEX(CIMException::FAILED, msg.c_str(), e);
00155    }
00156 }
00157 
00159 void
00160 RemoteAssociatorProvider::associatorNames(const ProviderEnvironmentIFCRef &env, CIMObjectPathResultHandlerIFC &result, const String &ns, const CIMObjectPath &objectName,
00161    const String &assocClass, const String &resultClass, const String &role, const String &resultRole)
00162 {
00163    LoggerRef lgr = env->getLogger(COMPONENT_NAME);
00164    OW_LOG_DEBUG(lgr, Format("RemoteAssociatorProvider::associatorNames ns = %1, objectName = %2, assocClass = %3, resultClass = %4, role = %5, resultRole = %6",
00165       ns, objectName, assocClass, resultClass, role, resultRole));
00166    String lUrl(m_url);
00167    ClientCIMOMHandleRef hdl = RemoteProviderUtils::getRemoteClientCIMOMHandle(lUrl, m_useConnectionCredentials, env, m_pool, m_alwaysSendCredentials);
00168    OW_LOG_DEBUG(lgr, Format("RemoteAssociatorProvider::associatorNames got ClientCIMOMHandleRef for url: %1", lUrl));
00169 
00170    ClientCIMOMHandleConnectionPool::HandleReturner returner(hdl, m_pool, lUrl);
00171 
00172    OW_LOG_DEBUG(lgr, "RemoteAssociatorProvider::associatorNames calling remote WBEM server");
00173 
00174    try
00175    {
00176       hdl->associatorNames(ns, objectName, result, assocClass, resultClass, role, resultRole);
00177 
00178    }
00179    catch (CIMException& e)
00180    {
00181       if (e.getErrNo() == CIMException::NOT_SUPPORTED)
00182       {
00183          e.setErrNo(CIMException::FAILED); // providers shouldn't ever throw NOT_SUPPORTED
00184       }
00185       OW_LOG_INFO(lgr, Format("RemoteAssociatorProvider::associatorNames remote WBEM server threw: %1", e));
00186       throw;
00187    }
00188    catch (const Exception& e)
00189    {
00190       String msg = Format("RemoteAssociatorProvider::associatorNames failed calling remote WBEM server: %1", e);
00191       OW_LOG_ERROR(lgr, msg);
00192       OW_THROWCIMMSG_SUBEX(CIMException::FAILED, msg.c_str(), e);
00193    }
00194 }
00195 
00197 void
00198 RemoteAssociatorProvider::referenceNames(const ProviderEnvironmentIFCRef &env, CIMObjectPathResultHandlerIFC &result, const String &ns, const CIMObjectPath &objectName,
00199    const String &resultClass, const String &role)
00200 {
00201    LoggerRef lgr = env->getLogger(COMPONENT_NAME);
00202    OW_LOG_DEBUG(lgr, Format("RemoteAssociatorProvider::referenceNames ns = %1, objectName = %2, resultClass = %3, role = %4", ns, objectName, resultClass, role));
00203    String lUrl(m_url);
00204    ClientCIMOMHandleRef hdl = RemoteProviderUtils::getRemoteClientCIMOMHandle(lUrl, m_useConnectionCredentials, env, m_pool, m_alwaysSendCredentials);
00205    OW_LOG_DEBUG(lgr, Format("RemoteAssociatorProvider::referenceNames got ClientCIMOMHandleRef for url: %1", lUrl));
00206 
00207    ClientCIMOMHandleConnectionPool::HandleReturner returner(hdl, m_pool, lUrl);
00208 
00209    OW_LOG_DEBUG(lgr, "RemoteAssociatorProvider::referenceNames calling remote WBEM server");
00210 
00211    try
00212    {
00213       hdl->referenceNames(ns, objectName, result, resultClass, role);
00214 
00215    }
00216    catch (CIMException& e)
00217    {
00218       if (e.getErrNo() == CIMException::NOT_SUPPORTED)
00219       {
00220          e.setErrNo(CIMException::FAILED); // providers shouldn't ever throw NOT_SUPPORTED
00221       }
00222       OW_LOG_INFO(lgr, Format("RemoteAssociatorProvider::referenceNames remote WBEM server threw: %1", e));
00223       throw;
00224    }
00225    catch (const Exception& e)
00226    {
00227       String msg = Format("RemoteAssociatorProvider::referenceNames failed calling remote WBEM server: %1", e);
00228       OW_LOG_ERROR(lgr, msg);
00229       OW_THROWCIMMSG_SUBEX(CIMException::FAILED, msg.c_str(), e);
00230    }
00231 
00232 }
00233 
00234 
00235 } // end namespace OW_NAMESPACE
00236 
00237 
00238 #endif // #ifndef OW_DISABLE_ASSOCIATION_TRAVERSAL

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