OW_RepositoryCIMOMHandle.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 
00035 #include "OW_config.h"
00036 #include "OW_RepositoryCIMOMHandle.hpp"
00037 #include "OW_CIMFeatures.hpp"
00038 #include "OW_CIMValue.hpp"
00039 #include "OW_CIMProperty.hpp"
00040 #include "OW_CIMObjectPath.hpp"
00041 #include "OW_CIMClass.hpp"
00042 #include "OW_CIMInstance.hpp"
00043 #include "OW_CIMQualifierType.hpp"
00044 #include "OW_Enumeration.hpp"
00045 
00046 namespace OW_NAMESPACE
00047 {
00048 
00049 using namespace WBEMFlags;
00051 RepositoryCIMOMHandle::RepositoryCIMOMHandle(const RepositoryIFCRef& pRepos, OperationContext& context, ELockingFlag lock)
00052    : CIMOMHandleIFC()
00053    , m_pServer(pRepos)
00054    , m_lock(lock)
00055    , m_context(context)
00056 {
00057 }
00059 class OperationScope
00060 {
00061 public:
00062    OperationScope(RepositoryCIMOMHandle* pHdl, EOperationFlag op, OperationContext& context)
00063    : m_pHdl(pHdl)
00064    , m_op(op)
00065    , m_context(context)
00066    , m_result(WBEMFlags::E_FAILED)
00067    {
00068       m_pHdl->beginOperation(m_op, m_context);
00069    }
00070    ~OperationScope()
00071    {
00072       m_pHdl->endOperation(m_op, m_context, m_result);
00073    }
00074    void completedSuccessfully()
00075    {
00076       m_result = WBEMFlags::E_SUCCESS;
00077    }
00078 private:
00079    RepositoryCIMOMHandle* m_pHdl;
00080    EOperationFlag m_op;
00081    OperationContext& m_context;
00082    WBEMFlags::EOperationResultFlag m_result;
00083 };
00084 
00086 void
00087 RepositoryCIMOMHandle::close()
00088 {
00089 }
00091 #if !defined(OW_DISABLE_INSTANCE_MANIPULATION) && !defined(OW_DISABLE_NAMESPACE_MANIPULATION)
00092 void
00093 RepositoryCIMOMHandle::createNameSpace(const String& ns)
00094 {
00095    OperationScope os(this, E_CREATE_NAMESPACE, m_context);
00096    m_pServer->createNameSpace(ns, m_context);
00097    os.completedSuccessfully();
00098 }
00100 void
00101 RepositoryCIMOMHandle::deleteNameSpace(const String& ns)
00102 {
00103    OperationScope os(this, E_DELETE_NAMESPACE, m_context);
00104    m_pServer->deleteNameSpace(ns, m_context);
00105    os.completedSuccessfully();
00106 }
00107 #endif
00108 
00109 void
00110 RepositoryCIMOMHandle::enumNameSpace(StringResultHandlerIFC& result)
00111 {
00112    OperationScope os(this, E_ENUM_NAMESPACE, m_context);
00113    m_pServer->enumNameSpace(result, m_context);
00114    os.completedSuccessfully();
00115 }
00117 void
00118 RepositoryCIMOMHandle::enumClass(const String& ns,
00119    const String& className,
00120    CIMClassResultHandlerIFC& result,
00121    EDeepFlag deep,
00122    ELocalOnlyFlag localOnly,
00123    EIncludeQualifiersFlag includeQualifiers,
00124    EIncludeClassOriginFlag includeClassOrigin)
00125 {
00126    OperationScope os(this, E_ENUM_CLASSES, m_context);
00127    m_pServer->enumClasses(ns, className, result, deep, localOnly, includeQualifiers,
00128       includeClassOrigin, m_context);
00129    os.completedSuccessfully();
00130 }
00132 void
00133 RepositoryCIMOMHandle::enumClassNames(const String& ns,
00134       const String& className,
00135       StringResultHandlerIFC& result,
00136       EDeepFlag deep)
00137 {
00138    OperationScope os(this, E_ENUM_CLASS_NAMES, m_context);
00139    m_pServer->enumClassNames(ns, className, result, deep, m_context);
00140    os.completedSuccessfully();
00141 }
00143 void
00144 RepositoryCIMOMHandle::enumInstances(
00145    const String& ns,
00146    const String& className,
00147    CIMInstanceResultHandlerIFC& result,
00148    EDeepFlag deep,
00149    ELocalOnlyFlag localOnly,
00150    EIncludeQualifiersFlag includeQualifiers,
00151    EIncludeClassOriginFlag includeClassOrigin,
00152    const StringArray* propertyList)
00153 {
00154    OperationScope os(this, E_ENUM_INSTANCES, m_context);
00155    m_pServer->enumInstances(ns, className, result, deep, localOnly, includeQualifiers,
00156       includeClassOrigin, propertyList, E_ENUM_SUBCLASSES, m_context);
00157    os.completedSuccessfully();
00158 }
00160 void
00161 RepositoryCIMOMHandle::enumInstanceNames(
00162    const String& ns,
00163    const String& className,
00164    CIMObjectPathResultHandlerIFC& result)
00165 {
00166    OperationScope os(this, E_ENUM_INSTANCE_NAMES, m_context);
00167    m_pServer->enumInstanceNames(ns, className, result, E_DEEP, m_context);
00168    os.completedSuccessfully();
00169 }
00171 CIMQualifierType
00172 RepositoryCIMOMHandle::getQualifierType(const String& ns,
00173       const String& qualifierName)
00174 {
00175    OperationScope os(this, E_GET_QUALIFIER_TYPE, m_context);
00176    CIMQualifierType rval = m_pServer->getQualifierType(ns, qualifierName, m_context);
00177    os.completedSuccessfully();
00178    return rval;
00179 }
00180 #ifndef OW_DISABLE_QUALIFIER_DECLARATION
00181 
00182 void
00183 RepositoryCIMOMHandle::deleteQualifierType(const String& ns, const String& qualName)
00184 {
00185    OperationScope os(this, E_DELETE_QUALIFIER_TYPE, m_context);
00186    m_pServer->deleteQualifierType(ns, qualName, m_context);
00187    os.completedSuccessfully();
00188 }
00190 void
00191 RepositoryCIMOMHandle::enumQualifierTypes(
00192    const String& ns,
00193    CIMQualifierTypeResultHandlerIFC& result)
00194 {
00195    OperationScope os(this, E_ENUM_QUALIFIER_TYPES, m_context);
00196    m_pServer->enumQualifierTypes(ns, result, m_context);
00197    os.completedSuccessfully();
00198 }
00200 void
00201 RepositoryCIMOMHandle::setQualifierType(const String& ns,
00202    const CIMQualifierType& qt)
00203 {
00204    OperationScope os(this, E_SET_QUALIFIER_TYPE, m_context);
00205    m_pServer->setQualifierType(ns, qt, m_context);
00206    os.completedSuccessfully();
00207 }
00208 #endif // #ifndef OW_DISABLE_QUALIFIER_DECLARATION
00209 
00210 CIMClass
00211 RepositoryCIMOMHandle::getClass(
00212    const String& ns,
00213    const String& className,
00214    ELocalOnlyFlag localOnly,
00215    EIncludeQualifiersFlag includeQualifiers,
00216    EIncludeClassOriginFlag includeClassOrigin,
00217    const StringArray* propertyList)
00218 {
00219    OperationScope os(this, E_GET_CLASS, m_context);
00220    CIMClass cls = m_pServer->getClass(ns, className, localOnly,
00221       includeQualifiers, includeClassOrigin, propertyList, m_context);
00222    os.completedSuccessfully();
00223    return cls;
00224 }
00226 CIMInstance
00227 RepositoryCIMOMHandle::getInstance(
00228    const String& ns,
00229    const CIMObjectPath& instanceName,
00230    ELocalOnlyFlag localOnly,
00231    EIncludeQualifiersFlag includeQualifiers,
00232    EIncludeClassOriginFlag includeClassOrigin,
00233    const StringArray* propertyList)
00234 {
00235    OperationScope os(this, E_GET_INSTANCE, m_context);
00236    CIMInstance rval = m_pServer->getInstance(ns, instanceName, localOnly, includeQualifiers,
00237       includeClassOrigin, propertyList, m_context);
00238    os.completedSuccessfully();
00239    return rval;
00240 }
00242 CIMValue
00243 RepositoryCIMOMHandle::invokeMethod(
00244    const String& ns,
00245    const CIMObjectPath& path,
00246    const String& methodName, const CIMParamValueArray& inParams,
00247    CIMParamValueArray& outParams)
00248 {
00249    OperationScope os(this, E_INVOKE_METHOD, m_context);
00250    CIMValue rval = m_pServer->invokeMethod(ns, path, methodName, inParams, outParams,
00251       m_context);
00252    os.completedSuccessfully();
00253    return rval;
00254 }
00255 #ifndef OW_DISABLE_SCHEMA_MANIPULATION
00256 
00257 void
00258 RepositoryCIMOMHandle::modifyClass(
00259    const String& ns,
00260    const CIMClass& cc)
00261 {
00262    OperationScope os(this, E_MODIFY_CLASS, m_context);
00263    m_pServer->modifyClass(ns, cc, m_context);
00264    os.completedSuccessfully();
00265 }
00267 void
00268 RepositoryCIMOMHandle::createClass(const String& ns,
00269    const CIMClass& cc)
00270 {
00271    OperationScope os(this, E_CREATE_CLASS, m_context);
00272    m_pServer->createClass(ns, cc, m_context);
00273    os.completedSuccessfully();
00274 }
00276 void
00277 RepositoryCIMOMHandle::deleteClass(const String& ns, const String& className)
00278 {
00279    OperationScope os(this, E_DELETE_CLASS, m_context);
00280    m_pServer->deleteClass(ns, className, m_context);
00281    os.completedSuccessfully();
00282 }
00283 #endif // #ifndef OW_DISABLE_SCHEMA_MANIPULATION
00284 #ifndef OW_DISABLE_INSTANCE_MANIPULATION
00285 
00286 void
00287 RepositoryCIMOMHandle::modifyInstance(
00288    const String& ns,
00289    const CIMInstance& modifiedInstance,
00290    EIncludeQualifiersFlag includeQualifiers,
00291    const StringArray* propertyList)
00292 {
00293    OperationScope os(this, E_MODIFY_INSTANCE, m_context);
00294    m_pServer->modifyInstance(ns, modifiedInstance, includeQualifiers,
00295       propertyList, m_context);
00296    os.completedSuccessfully();
00297 }
00299 CIMObjectPath
00300 RepositoryCIMOMHandle::createInstance(const String& ns,
00301    const CIMInstance& ci)
00302 {
00303    OperationScope os(this, E_CREATE_INSTANCE, m_context);
00304    CIMObjectPath rval = m_pServer->createInstance(ns, ci, m_context);
00305    os.completedSuccessfully();
00306    return rval;
00307 }
00309 void
00310 RepositoryCIMOMHandle::deleteInstance(const String& ns, const CIMObjectPath& path)
00311 {
00312    OperationScope os(this, E_DELETE_INSTANCE, m_context);
00313    m_pServer->deleteInstance(ns, path, m_context);
00314    os.completedSuccessfully();
00315 }
00316 #if !defined(OW_DISABLE_PROPERTY_OPERATIONS)
00317 
00318 void
00319 RepositoryCIMOMHandle::setProperty(
00320    const String& ns,
00321    const CIMObjectPath& name,
00322    const String& propertyName, const CIMValue& cv)
00323 {
00324    OperationScope os(this, E_SET_PROPERTY, m_context);
00325    m_pServer->setProperty(ns, name, propertyName, cv, m_context);
00326    os.completedSuccessfully();
00327 }
00328 #endif // #if !defined(OW_DISABLE_PROPERTY_OPERATIONS)
00329 #endif // #ifndef OW_DISABLE_INSTANCE_MANIPULATION
00330 
00331 #if !defined(OW_DISABLE_PROPERTY_OPERATIONS)
00332 
00333 CIMValue
00334 RepositoryCIMOMHandle::getProperty(
00335    const String& ns,
00336    const CIMObjectPath& name,
00337    const String& propertyName)
00338 {
00339    OperationScope os(this, E_GET_PROPERTY, m_context);
00340    CIMValue rval = m_pServer->getProperty(ns, name, propertyName, m_context);
00341    os.completedSuccessfully();
00342    return rval;
00343 }
00344 #endif // #if !defined(OW_DISABLE_PROPERTY_OPERATIONS)
00345 
00346 #ifndef OW_DISABLE_ASSOCIATION_TRAVERSAL
00347 
00348 void
00349 RepositoryCIMOMHandle::associatorNames(
00350    const String& ns,
00351    const CIMObjectPath& path,
00352    CIMObjectPathResultHandlerIFC& result,
00353    const String& assocClass, const String& resultClass,
00354    const String& role, const String& resultRole)
00355 {
00356    OperationScope os(this, E_ASSOCIATOR_NAMES, m_context);
00357    m_pServer->associatorNames(ns, path, result, assocClass, resultClass, role,
00358       resultRole, m_context);
00359    os.completedSuccessfully();
00360 }
00362 void
00363 RepositoryCIMOMHandle::associators(
00364    const String& ns,
00365    const CIMObjectPath& path,
00366    CIMInstanceResultHandlerIFC& result,
00367    const String& assocClass, const String& resultClass,
00368    const String& role, const String& resultRole,
00369    EIncludeQualifiersFlag includeQualifiers,
00370    EIncludeClassOriginFlag includeClassOrigin,
00371    const StringArray* propertyList)
00372 {
00373    OperationScope os(this, E_ASSOCIATORS, m_context);
00374    m_pServer->associators(ns, path, result, assocClass, resultClass, role,
00375       resultRole, includeQualifiers, includeClassOrigin, propertyList,
00376       m_context);
00377    os.completedSuccessfully();
00378 }
00380 void
00381 RepositoryCIMOMHandle::associatorsClasses(
00382    const String& ns,
00383    const CIMObjectPath& path,
00384    CIMClassResultHandlerIFC& result,
00385    const String& assocClass, const String& resultClass,
00386    const String& role, const String& resultRole,
00387    EIncludeQualifiersFlag includeQualifiers,
00388    EIncludeClassOriginFlag includeClassOrigin,
00389    const StringArray* propertyList)
00390 {
00391    OperationScope os(this, E_ASSOCIATORS_CLASSES, m_context);
00392    m_pServer->associatorsClasses(ns, path, result, assocClass, resultClass, role,
00393       resultRole, includeQualifiers, includeClassOrigin, propertyList,
00394       m_context);
00395    os.completedSuccessfully();
00396 }
00398 void
00399 RepositoryCIMOMHandle::referenceNames(
00400    const String& ns,
00401    const CIMObjectPath& path,
00402    CIMObjectPathResultHandlerIFC& result,
00403    const String& resultClass, const String& role)
00404 {
00405    OperationScope os(this, E_REFERENCE_NAMES, m_context);
00406    m_pServer->referenceNames(ns, path, result, resultClass, role, m_context);
00407    os.completedSuccessfully();
00408 }
00410 void
00411 RepositoryCIMOMHandle::references(
00412    const String& ns,
00413    const CIMObjectPath& path,
00414    CIMInstanceResultHandlerIFC& result,
00415    const String& resultClass, const String& role,
00416    EIncludeQualifiersFlag includeQualifiers,
00417    EIncludeClassOriginFlag includeClassOrigin,
00418    const StringArray* propertyList)
00419 {
00420    OperationScope os(this, E_REFERENCES, m_context);
00421    m_pServer->references(ns, path, result, resultClass, role,
00422       includeQualifiers, includeClassOrigin, propertyList, m_context);
00423    os.completedSuccessfully();
00424 }
00426 void
00427 RepositoryCIMOMHandle::referencesClasses(
00428    const String& ns,
00429    const CIMObjectPath& path,
00430    CIMClassResultHandlerIFC& result,
00431    const String& resultClass, const String& role,
00432    EIncludeQualifiersFlag includeQualifiers,
00433    EIncludeClassOriginFlag includeClassOrigin,
00434    const StringArray* propertyList)
00435 {
00436    OperationScope os(this, E_REFERENCES_CLASSES, m_context);
00437    m_pServer->referencesClasses(ns, path, result, resultClass, role,
00438       includeQualifiers, includeClassOrigin, propertyList, m_context);
00439    os.completedSuccessfully();
00440 }
00441 #endif // #ifndef OW_DISABLE_ASSOCIATION_TRAVERSAL
00442 
00443 void
00444 RepositoryCIMOMHandle::execQuery(
00445    const String& ns,
00446    CIMInstanceResultHandlerIFC& result,
00447    const String& query,
00448    const String& queryLanguage)
00449 {
00450    OperationScope os(this, E_EXEC_QUERY, m_context);
00451    m_pServer->execQuery(ns, result, query, queryLanguage, m_context);
00452    os.completedSuccessfully();
00453 }
00455 void
00456 RepositoryCIMOMHandle::beginOperation(WBEMFlags::EOperationFlag op, OperationContext& m_context)
00457 {
00458    if (m_lock)
00459    {
00460       m_pServer->beginOperation(op, m_context);
00461    }
00462 }
00463 
00465 void
00466 RepositoryCIMOMHandle::endOperation(WBEMFlags::EOperationFlag op, OperationContext& m_context, WBEMFlags::EOperationResultFlag result)
00467 {
00468    if (m_lock)
00469    {
00470       m_pServer->endOperation(op, m_context, result);
00471    }
00472 }
00473 
00474 } // end namespace OW_NAMESPACE
00475 

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