OW_CIMRepository.cpp

Go to the documentation of this file.
00001 /*******************************************************************************
00002 * Copyright (C) 2002-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 
00036 #include "OW_config.h"
00037 #include "OW_CIMRepository.hpp"
00038 #include "OW_FileSystem.hpp"
00039 #include "OW_CIMValueCast.hpp"
00040 #include "OW_CIMOMHandleIFC.hpp"
00041 #include "OW_ConfigOpts.hpp"
00042 #include "OW_Format.hpp"
00043 #include "OW_WQLIFC.hpp"
00044 #include "OW_Assertion.hpp"
00045 #include "OW_IOException.hpp"
00046 #include "OW_CIMParamValue.hpp"
00047 #include "OW_ConfigOpts.hpp"
00048 #include "OW_Map.hpp"
00049 #include "OW_CIMQualifierType.hpp"
00050 #include "OW_CIMClass.hpp"
00051 #include "OW_CIMInstance.hpp"
00052 #include "OW_CIMProperty.hpp"
00053 #include "OW_CIMValue.hpp"
00054 #include "OW_CIMQualifier.hpp"
00055 #include "OW_CIMObjectPath.hpp"
00056 #include "OW_OperationContext.hpp"
00057 #include "OW_ServiceIFCNames.hpp"
00058 
00059 namespace OW_NAMESPACE
00060 {
00061 
00062 namespace
00063 {
00064    const String COMPONENT_NAME("ow.repository.hdb");
00065 }
00066 
00067 using namespace WBEMFlags;
00069 CIMRepository::CIMRepository()
00070    : m_checkReferentialIntegrity(false)
00071 {
00072 }
00074 CIMRepository::~CIMRepository()
00075 {
00076    try
00077    {
00078       close();
00079    }
00080    catch (...)
00081    {
00082       // don't let exceptions escape
00083    }
00084 }
00086 void
00087 CIMRepository::open(const String& path)
00088 {
00089    if (m_nStore.isOpen())
00090    {
00091       close();
00092    }
00093    FileSystem::makeDirectory(path);
00094    if (!FileSystem::exists(path))
00095    {
00096       String msg("failed to create directory: " );
00097       msg += path;
00098       OW_THROW_ERRNO_MSG(IOException, msg.c_str());
00099    }
00100    else
00101    {
00102       if (!FileSystem::canWrite(path))
00103       {
00104          String msg("don't have write access to directory: ");
00105          msg += path;
00106          OW_THROW(IOException, msg.c_str());
00107       }
00108    }
00109    String fname = path;
00110    if (!fname.endsWith(String(OW_FILENAME_SEPARATOR)))
00111    {
00112       fname += OW_FILENAME_SEPARATOR;
00113    }
00114    
00115    m_nStore.open(fname + NS_REPOS_NAME);
00116    m_iStore.open(fname + INST_REPOS_NAME);
00117    m_mStore.open(fname + META_REPOS_NAME);
00118 #ifndef OW_DISABLE_ASSOCIATION_TRAVERSAL
00119    m_classAssocDb.open(fname + CLASS_ASSOC_REPOS_NAME);
00120    m_instAssocDb.open(fname + INST_ASSOC_REPOS_NAME);
00121 #endif
00122 }
00123 
00125 void
00126 CIMRepository::close()
00127 {
00128    m_nStore.close();
00129    m_iStore.close();
00130    m_mStore.close();
00131 #ifndef OW_DISABLE_ASSOCIATION_TRAVERSAL
00132    m_classAssocDb.close();
00133    m_instAssocDb.close();
00134 #endif
00135 }
00136 
00138 String
00139 CIMRepository::getName() const
00140 {
00141    return ServiceIFCNames::CIMRepository;
00142 }
00143 
00145 void
00146 CIMRepository::init(const ServiceEnvironmentIFCRef& env)
00147 {
00148    m_nStore.init(env);
00149    m_iStore.init(env);
00150    m_mStore.init(env);
00151 #ifndef OW_DISABLE_ASSOCIATION_TRAVERSAL
00152    m_classAssocDb.init(env);
00153    m_instAssocDb.init(env);
00154 #endif
00155    m_env = env;
00156    m_logger = env->getLogger(COMPONENT_NAME);
00157    if (m_env->getConfigItem(ConfigOpts::CHECK_REFERENTIAL_INTEGRITY_opt,
00158       OW_DEFAULT_CHECK_REFERENTIAL_INTEGRITY).equalsIgnoreCase("true"))
00159    {
00160       m_checkReferentialIntegrity = true;
00161    }
00162 
00163    this->open(m_env->getConfigItem(ConfigOpts::DATADIR_opt, OW_DEFAULT_DATADIR));
00164 }
00165 
00167 void
00168 CIMRepository::shutdown()
00169 {
00170    close();
00171    m_logger = 0;
00172    m_env = 0;
00173 }
00174 
00175 #if !defined(OW_DISABLE_INSTANCE_MANIPULATION) && !defined(OW_DISABLE_NAMESPACE_MANIPULATION)
00176 
00177 void
00178 CIMRepository::createNameSpace(const String& ns,
00179    OperationContext&)
00180 {
00181    if (ns.empty())
00182    {
00183       OW_THROWCIM(CIMException::INVALID_PARAMETER);
00184    }
00185 
00186    // namespaces can't contain :
00187    const char NS_SEPARATOR_C(':');
00188    if (ns.indexOf(NS_SEPARATOR_C) != String::npos)
00189    {
00190       OW_THROWCIMMSG(CIMException::FAILED, Format("Invalid namespace (%1). %2 is not allowed", ns, NS_SEPARATOR_C).c_str());
00191    }
00192 
00193    if (m_nStore.createNameSpace(ns) == -1)
00194    {
00195       OW_THROWCIMMSG(CIMException::ALREADY_EXISTS,
00196          ns.c_str());
00197    }
00198    // TODO: Make this exception safe.
00199    if (m_iStore.createNameSpace(ns) == -1)
00200    {
00201       m_nStore.deleteNameSpace(ns);
00202       OW_THROWCIMMSG(CIMException::FAILED, Format("Failed to create namespace %1", ns).c_str());
00203    }
00204 
00205    if (m_mStore.createNameSpace(ns) == -1)
00206    {
00207       m_nStore.deleteNameSpace(ns);
00208       m_iStore.deleteNameSpace(ns);
00209       OW_THROWCIMMSG(CIMException::FAILED, Format("Failed to create namespace %1", ns).c_str());
00210    }
00211 
00212    OW_LOG_DEBUG(m_logger, Format("CIMRepository created namespace: %1", ns));
00213 }
00215 void
00216 CIMRepository::deleteNameSpace(const String& ns,
00217    OperationContext&)
00218 {
00219    if (ns.empty())
00220    {
00221       OW_THROWCIM(CIMException::INVALID_PARAMETER);
00222    }
00223    // TODO: Make this exception safe.
00224    m_nStore.deleteNameSpace(ns);
00225    m_iStore.deleteNameSpace(ns);
00226    m_mStore.deleteNameSpace(ns);
00227    
00228    OW_LOG_DEBUG(m_logger, Format("CIMRepository deleted namespace: %1", ns));
00229 }
00230 #endif
00231 
00232 void
00233 CIMRepository::enumNameSpace(StringResultHandlerIFC& result,
00234    OperationContext&)
00235 {
00236    // TODO: Move this into m_nStore
00237    HDBHandleLock hdl(&m_nStore, m_nStore.getHandle());
00238    HDBNode nsNode = hdl->getFirstRoot();
00239    //HDBNode nsNode = m_nStore.getNameSpaceNode(hdl, nsName);
00240    //if (!nsNode)
00241    //{
00242    // OW_THROWCIMMSG(CIMException::INVALID_NAMESPACE, nsName.c_str());
00243    //}
00244    //nsNode = hdl->getFirstChild(nsNode);
00245    while (nsNode)
00246    {
00247       result.handle(nsNode.getKey());
00248       nsNode = hdl->getNextSibling(nsNode);
00249    }
00250    OW_LOG_DEBUG(m_logger, "CIMRepository enumerated namespaces");
00251 }
00253 CIMQualifierType
00254 CIMRepository::getQualifierType(const String& ns,
00255    const String& qualifierName,
00256    OperationContext&)
00257 {
00258    OW_LOG_DEBUG(m_logger, Format("CIMRepository getting qualifier type: %1",
00259       CIMObjectPath(qualifierName,ns).toString()));
00260    return m_mStore.getQualifierType(ns, qualifierName);
00261 }
00262 #ifndef OW_DISABLE_QUALIFIER_DECLARATION
00263 
00264 void
00265 CIMRepository::enumQualifierTypes(
00266    const String& ns,
00267    CIMQualifierTypeResultHandlerIFC& result,
00268    OperationContext&)
00269 {
00270    m_mStore.enumQualifierTypes(ns, result);
00271    OW_LOG_DEBUG(m_logger, Format("CIMRepository enumerated qualifiers in namespace: %1", ns));
00272 }
00274 void
00275 CIMRepository::deleteQualifierType(const String& ns, const String& qualName,
00276    OperationContext&)
00277 {
00278    // TODO: What happens if the qualifier is being used???
00279    if (!m_mStore.deleteQualifierType(ns, qualName))
00280    {
00281       if (m_nStore.nameSpaceExists(ns))
00282       {
00283          OW_THROWCIMMSG(CIMException::NOT_FOUND,
00284             String(ns + "/" + qualName).c_str());
00285       }
00286       else
00287       {
00288          OW_THROWCIMMSG(CIMException::INVALID_NAMESPACE,
00289             String(ns + "/" + qualName).c_str());
00290       }
00291    }
00292    
00293    OW_LOG_DEBUG(m_logger, Format("CIMRepository deleted qualifier type: %1 in namespace: %2", qualName, ns));
00294 }
00296 void
00297 CIMRepository::setQualifierType(
00298    const String& ns,
00299    const CIMQualifierType& qt, OperationContext&)
00300 {
00301    m_mStore.setQualifierType(ns, qt);
00302    OW_LOG_DEBUG(m_logger, Format("CIMRepository set qualifier type: %1 in "
00303       "namespace: %2", qt.toString(), ns));
00304 }
00305 #endif // #ifndef OW_DISABLE_QUALIFIER_DECLARATION
00306 
00307 CIMClass
00308 CIMRepository::getClass(
00309    const String& ns, const String& className,
00310    ELocalOnlyFlag localOnly, EIncludeQualifiersFlag includeQualifiers,
00311    EIncludeClassOriginFlag includeClassOrigin, const StringArray* propertyList,
00312    OperationContext&)
00313 {
00314    try
00315    {
00316       CIMClass theClass(CIMNULL);
00317       CIMException::ErrNoType rval = m_mStore.getCIMClass(ns, className,
00318          localOnly, includeQualifiers, includeClassOrigin, propertyList,
00319          theClass);
00320       checkGetClassRvalAndThrow(rval, ns, className);
00321       OW_LOG_DEBUG(m_logger, Format("CIMRepository got class: %1 from "
00322          "namespace: %2", theClass.getName(), ns));
00323       return theClass;
00324    }
00325    catch(HDBException& e)
00326    {
00327       OW_THROWCIM_SUBEX(CIMException::FAILED, e);
00328    }
00329    catch(IOException& e)
00330    {
00331       OW_THROWCIM_SUBEX(CIMException::FAILED, e);
00332    }
00333 }
00335 CIMClass
00336 CIMRepository::_getClass(const String& ns, const CIMName& className)
00337 {
00338    CIMClass theClass(CIMNULL);
00339    CIMException::ErrNoType rval = m_mStore.getCIMClass(ns, className, E_NOT_LOCAL_ONLY, E_INCLUDE_QUALIFIERS, E_INCLUDE_CLASS_ORIGIN, 0, theClass);
00340    checkGetClassRvalAndThrow(rval, ns, className);
00341    return theClass;
00342 }
00344 CIMClass
00345 CIMRepository::_instGetClass(const String& ns, const CIMName& className)
00346 {
00347    CIMClass theClass(CIMNULL);
00348    CIMException::ErrNoType rval = m_mStore.getCIMClass(ns, className, E_NOT_LOCAL_ONLY, E_INCLUDE_QUALIFIERS, E_INCLUDE_CLASS_ORIGIN, 0, theClass);
00349    checkGetClassRvalAndThrowInst(rval, ns, className);
00350    return theClass;
00351 }
00352 #ifndef OW_DISABLE_SCHEMA_MANIPULATION
00353 
00354 namespace
00355 {
00356    class CIMClassDeleter : public CIMClassResultHandlerIFC
00357    {
00358    public:
00359       CIMClassDeleter(MetaRepository& mr, const String& ns_,
00360          InstanceRepository& mi
00361 #ifndef OW_DISABLE_ASSOCIATION_TRAVERSAL
00362          , AssocDb& m_assocDb_
00363 #endif
00364          )
00365       : m_mStore(mr)
00366       , ns(ns_)
00367       , m_iStore(mi)
00368 #ifndef OW_DISABLE_ASSOCIATION_TRAVERSAL
00369       , m_assocDb(m_assocDb_)
00370 #endif
00371       {}
00372    protected:
00373       virtual void doHandle(const CIMClass &c)
00374       {
00375          CIMName cname = c.getName();
00376          if (!m_mStore.deleteClass(ns, cname.toString()))
00377          {
00378             OW_THROWCIM(CIMException::NOT_FOUND);
00379          }
00380          // TODO: this doesn't work quite right.  what about associations to
00381          // the instances we delete?  If we fix deleteInstance to also delete
00382          // associations, then we could just call enumInstances and then
00383          // deleteInstance for all instances.
00384          // delete any instances of the class
00385          m_iStore.deleteClass(ns, cname.toString());
00386 #ifndef OW_DISABLE_ASSOCIATION_TRAVERSAL
00387          // remove class from association index
00388          if (c.isAssociation())
00389          {
00390             AssocDbHandle hdl = m_assocDb.getHandle();
00391             hdl.deleteEntries(ns,c);
00392          }
00393 #endif
00394       }
00395    private:
00396       MetaRepository& m_mStore;
00397       const String& ns;
00398       InstanceRepository& m_iStore;
00399 #ifndef OW_DISABLE_ASSOCIATION_TRAVERSAL
00400       AssocDb& m_assocDb;
00401 #endif
00402    };
00403 }
00405 CIMClass
00406 CIMRepository::deleteClass(const String& ns, const String& className,
00407    OperationContext& acl)
00408 {
00409    try
00410    {
00411       CIMClass cc = _getClass(ns, className);
00412       OW_ASSERT(cc);
00413       // TODO: this doesn't work quite right.  what about associations to
00414       // the instances we delete?
00415       // should this operation be atomic?  If something fails, how can we
00416       // undo so as to not leave things in a weird state?
00417       // We need to also delete the associations to the instances we delete.
00418       // To make this atomic, we need to introduce transactions.  This would
00419       // mean upgrading to a new version of libdb, or else using an SQL
00420       // database that supports transactions.  Either way, a lot of work :-(
00421       // delete the class and any subclasses
00422       CIMClassDeleter ccd(m_mStore, ns, m_iStore
00423 #ifndef OW_DISABLE_ASSOCIATION_TRAVERSAL
00424          , m_classAssocDb
00425 #endif
00426          );
00427       this->enumClasses(ns, className, ccd,
00428          E_DEEP, E_LOCAL_ONLY,
00429          E_EXCLUDE_QUALIFIERS,
00430          E_EXCLUDE_CLASS_ORIGIN,
00431          acl);
00432       ccd.handle(cc);
00433       OW_LOG_DEBUG(m_logger, Format("CIMRepository deleted class: %1 in "
00434          "namespace: %2", className, ns));
00435       return cc;
00436    }
00437    catch(IOException& e)
00438    {
00439       OW_THROWCIM_SUBEX(CIMException::FAILED, e);
00440    }
00441    catch(HDBException& e)
00442    {
00443       OW_THROWCIM_SUBEX(CIMException::FAILED, e);
00444    }
00445 }
00447 void
00448 CIMRepository::createClass(const String& ns, const CIMClass& cimClass_,
00449    OperationContext&)
00450 {
00451    try
00452    {
00453       // m_mStore.createClass modifies cimClass to be consistent with base
00454       // classes, etc.
00455       CIMClass cimClass(cimClass_);
00456 
00457       // validate that any reference properties are valid classes
00458       CIMPropertyArray props(cimClass.getAllProperties());
00459       for (size_t i = 0; i < props.size(); ++i)
00460       {
00461          CIMProperty& prop(props[i]);
00462          CIMDataType type(prop.getDataType());
00463          if (type.isReferenceType())
00464          {
00465             CIMName refClassName(type.getRefClassName());
00466             try
00467             {
00468                _getClass(ns, refClassName);
00469             }
00470             catch (CIMException& e)
00471             {
00472                // if we have a NOT_FOUND, change it into a INVALID_PARAMETER
00473                if (e.getErrNo() == CIMException::NOT_FOUND)
00474                {
00475                   OW_THROWCIMMSG(CIMException::INVALID_PARAMETER,
00476                      Format("Class %1 referenced by reference property %2 doesn't exist in namespace %3",
00477                         refClassName, prop.getName(), ns).c_str());
00478                }
00479                throw;
00480             }
00481          }
00482       }
00483 
00484       m_mStore.createClass(ns, cimClass);
00485       m_iStore.createClass(ns, cimClass);
00486       // we need to re-get the class, so that it will be consistent.  currently
00487       // cimClass only contains "unique" items that are added in the child class.
00488       cimClass = _getClass(ns, cimClass.getName());
00489 #ifndef OW_DISABLE_ASSOCIATION_TRAVERSAL
00490       if (cimClass.isAssociation())
00491       {
00492          AssocDbHandle hdl = m_classAssocDb.getHandle();
00493          hdl.addEntries(ns,cimClass);
00494       }
00495 #endif
00496       OW_LOG_DEBUG(m_logger, Format("Created class: %1:%2", ns, cimClass.toMOF()));
00497    }
00498    catch (HDBException& e)
00499    {
00500       OW_THROWCIM_SUBEX(CIMException::FAILED, e);
00501    }
00502    catch (IOException& e)
00503    {
00504       OW_THROWCIM_SUBEX(CIMException::FAILED, e);
00505    }
00506 }
00508 CIMClass
00509 CIMRepository::modifyClass(
00510    const String& ns,
00511    const CIMClass& cc,
00512    OperationContext&)
00513 {
00514    OW_ASSERT(cc);
00515    try
00516    {
00517       CIMClass origClass = _getClass(ns, cc.getName());
00518       // TODO: this needs to update the subclasses of the modified class.
00519       //       If that's not possible, then we need to throw a
00520       //       CLASS_HAS_CHILDREN CIMException.
00521       // TODO: Need to update the instances of the class and any subclasses.
00522       //       If that's not possible, then we need to throw a
00523       //       CLASS_HAS_INSTANCES CIMException.
00524       m_mStore.modifyClass(ns, cc);
00525       OW_ASSERT(origClass);
00526       OW_LOG_DEBUG(m_logger, Format("Modified class: %1:%2 from %3 to %4", ns,
00527          cc.getName(), origClass.toMOF(), cc.toMOF()));
00528       return origClass;
00529    }
00530    catch (HDBException& e)
00531    {
00532       OW_THROWCIM_SUBEX(CIMException::FAILED, e);
00533    }
00534    catch (IOException& e)
00535    {
00536       OW_THROWCIM_SUBEX(CIMException::FAILED, e);
00537    }
00538 }
00539 #endif // #ifndef OW_DISABLE_SCHEMA_MANIPULATION
00540 
00541 void
00542 CIMRepository::enumClasses(const String& ns,
00543       const String& className,
00544       CIMClassResultHandlerIFC& result,
00545       EDeepFlag deep, ELocalOnlyFlag localOnly, EIncludeQualifiersFlag includeQualifiers,
00546       EIncludeClassOriginFlag includeClassOrigin, OperationContext&)
00547 {
00548    try
00549    {
00550       m_mStore.enumClass(ns, className,
00551          result, deep,
00552          localOnly, includeQualifiers, includeClassOrigin);
00553       OW_LOG_DEBUG(m_logger, Format("CIMRepository enumerated classes: %1:%2", ns,
00554          className));
00555    }
00556    catch (HDBException& e)
00557    {
00558       OW_THROWCIM_SUBEX(CIMException::FAILED, e);
00559    }
00560    catch (IOException& e)
00561    {
00562       OW_THROWCIM_SUBEX(CIMException::FAILED, e);
00563    }
00564 }
00566 void
00567 CIMRepository::enumClassNames(
00568    const String& ns,
00569    const String& className,
00570    StringResultHandlerIFC& result,
00571    EDeepFlag deep, OperationContext&)
00572 {
00573    try
00574    {
00575       m_mStore.enumClassNames(ns, className, result, deep);
00576       OW_LOG_DEBUG(m_logger, Format("CIMRepository enumerated class names: %1:%2", ns,
00577          className));
00578    }
00579    catch (HDBException& e)
00580    {
00581       OW_THROWCIM_SUBEX(CIMException::FAILED, e);
00582    }
00583    catch (IOException& e)
00584    {
00585       OW_THROWCIM_SUBEX(CIMException::FAILED, e);
00586    }
00587 }
00589 namespace {
00590 class CIMNameArrayBuilder : public StringResultHandlerIFC
00591 {
00592 public:
00593    CIMNameArrayBuilder(CIMNameArray& result)
00594       : m_result(result)
00595    {}
00596    void doHandle(const String& name)
00597    {
00598       m_result.push_back(name);
00599    }
00600 private:
00601    CIMNameArray& m_result;
00602 };
00603 // utility function
00604 CIMNameArray getClassChildren(MetaRepository& rep, const String& ns, const CIMName& clsName)
00605 {
00606    CIMNameArray result;
00607    CIMNameArrayBuilder handler(result);
00608    rep.enumClassNames(ns, clsName.toString(), handler, E_DEEP);
00609    return result;
00610 }
00611 
00613 class InstNameEnumerator : public CIMClassResultHandlerIFC
00614 {
00615 public:
00616    InstNameEnumerator(
00617       const String& ns_,
00618       CIMObjectPathResultHandlerIFC& result_,
00619       const ServiceEnvironmentIFCRef& env_,
00620       InstanceRepository& iStore)
00621       : ns(ns_)
00622       , result(result_)
00623       , m_env(env_)
00624       , m_iStore(iStore)
00625    {}
00626 protected:
00627    virtual void doHandle(const CIMClass &cc)
00628    {
00629       LoggerRef lgr(m_env->getLogger(COMPONENT_NAME));
00630       OW_LOG_DEBUG(lgr, Format("CIMServer InstNameEnumerator enumerated derived instance names: %1:%2", ns,
00631          cc.getName()));
00632       m_iStore.getInstanceNames(ns, cc, result);
00633    }
00634 private:
00635    String ns;
00636    CIMObjectPathResultHandlerIFC& result;
00637    const ServiceEnvironmentIFCRef& m_env;
00638    InstanceRepository& m_iStore;
00639 };
00640 }
00642 void
00643 CIMRepository::enumInstanceNames(
00644    const String& ns,
00645    const String& className,
00646    CIMObjectPathResultHandlerIFC& result,
00647    EDeepFlag deep,
00648    OperationContext&)
00649 {
00650    try
00651    {
00652       InstNameEnumerator ie(ns, result, m_env, m_iStore);
00653       CIMClass theClass = _instGetClass(ns, className);
00654       ie.handle(theClass);
00655       // If this is the namespace class then just return now
00656       if (className.equalsIgnoreCase("__Namespace")
00657          || !deep)
00658       {
00659          return;
00660       }
00661       else
00662       {
00663          // TODO: measure whether it would be faster to use
00664          // enumClassNames + getClass() here.
00665          m_mStore.enumClass(ns,className,ie,deep,E_NOT_LOCAL_ONLY,
00666             E_INCLUDE_QUALIFIERS,E_INCLUDE_CLASS_ORIGIN);
00667       }
00668 
00669    }
00670    catch (HDBException& e)
00671    {
00672       OW_THROWCIM_SUBEX(CIMException::FAILED, e);
00673    }
00674    catch (IOException& e)
00675    {
00676       OW_THROWCIM_SUBEX(CIMException::FAILED, e);
00677    }
00678 }
00680 namespace CIMRepositoryImpl
00681 {
00682 
00683 class instEnumerator : public StringResultHandlerIFC
00684 {
00685 public:
00686    instEnumerator(CIMRepository& rep_,
00687       const String& ns_,
00688       const CIMClass& theTopClass_,
00689       CIMInstanceResultHandlerIFC& result_,
00690       EDeepFlag deep_,
00691       ELocalOnlyFlag localOnly_,
00692       EIncludeQualifiersFlag includeQualifiers_,
00693       EIncludeClassOriginFlag includeClassOrigin_,
00694       const StringArray* propertyList_)
00695       : rep(rep_)
00696       , ns(ns_)
00697       , theTopClass(theTopClass_)
00698       , result(result_)
00699       , deep(deep_)
00700       , localOnly(localOnly_)
00701       , includeQualifiers(includeQualifiers_)
00702       , includeClassOrigin(includeClassOrigin_)
00703       , propertyList(propertyList_)
00704    {}
00705    void doHandle(const String& className)
00706    {
00707       CIMClass theClass = rep._instGetClass(ns, className);
00708       rep.m_iStore.getCIMInstances(ns, className, theTopClass, theClass, result,
00709          deep, localOnly, includeQualifiers, includeClassOrigin, propertyList);
00710       OW_LOG_DEBUG(rep.m_logger, Format("CIMRepository Enumerated derived instances: %1:%2", ns, className));
00711    }
00712 private:
00713    CIMRepository& rep;
00714    const String& ns;
00715    const CIMClass& theTopClass;
00716    CIMInstanceResultHandlerIFC& result;
00717    EDeepFlag deep;
00718    ELocalOnlyFlag localOnly;
00719    EIncludeQualifiersFlag includeQualifiers;
00720    EIncludeClassOriginFlag includeClassOrigin;
00721    const StringArray* propertyList;
00722 };
00723 } // end namespace CIMRepositoryImpl
00724 
00726 void
00727 CIMRepository::enumInstances(
00728    const String& ns,
00729    const String& className,
00730    CIMInstanceResultHandlerIFC& result, EDeepFlag deep,
00731    ELocalOnlyFlag localOnly,
00732    EIncludeQualifiersFlag includeQualifiers,
00733    EIncludeClassOriginFlag includeClassOrigin,
00734    const StringArray* propertyList,
00735    EEnumSubclassesFlag enumSubclasses, OperationContext&)
00736 {
00737    // deep means a different thing here than for enumInstanceNames.  See the spec.
00738    try
00739    {
00740       CIMClass theTopClass = _instGetClass(ns, className);
00741       m_iStore.getCIMInstances(ns, className, theTopClass, theTopClass, result,
00742          deep, localOnly, includeQualifiers, includeClassOrigin, propertyList);
00743       
00744       OW_LOG_DEBUG(m_logger, Format("CIMRepository Enumerated instances: %1:%2", ns,
00745          className));
00746       if (enumSubclasses)
00747       {
00748          CIMRepositoryImpl::instEnumerator ie(*this, ns, theTopClass, result, deep, localOnly, includeQualifiers, includeClassOrigin, propertyList);
00749          m_mStore.enumClassNames(ns, className, ie, E_DEEP);
00750       }
00751    }
00752    catch (HDBException& e)
00753    {
00754       OW_THROWCIM_SUBEX(CIMException::FAILED, e);
00755    }
00756    catch (IOException& e)
00757    {
00758       OW_THROWCIM_SUBEX(CIMException::FAILED, e);
00759    }
00760 }
00762 CIMInstance
00763 CIMRepository::getInstance(
00764    const String& ns,
00765    const CIMObjectPath& instanceName,
00766    ELocalOnlyFlag localOnly,
00767    EIncludeQualifiersFlag includeQualifiers,
00768    EIncludeClassOriginFlag includeClassOrigin,
00769    const StringArray* propertyList, OperationContext& context)
00770 {
00771    return getInstance(ns, instanceName, localOnly, includeQualifiers, includeClassOrigin,
00772       propertyList, NULL, context);
00773 }
00775 CIMInstance
00776 CIMRepository::getInstance(
00777    const String& ns,
00778    const CIMObjectPath& instanceName,
00779    ELocalOnlyFlag localOnly,
00780    EIncludeQualifiersFlag includeQualifiers, EIncludeClassOriginFlag includeClassOrigin,
00781    const StringArray* propertyList, CIMClass* pOutClass,
00782    OperationContext&)
00783 {
00784    StringArray lpropList;
00785    if (propertyList)
00786    {
00787       lpropList = *propertyList;
00788    }
00789    CIMInstance ci(CIMNULL);
00790    CIMClass cc(_instGetClass(ns, instanceName.getClassName()));
00791    try
00792    {
00793       ci = m_iStore.getCIMInstance(ns, instanceName, cc, localOnly,
00794          includeQualifiers, includeClassOrigin, propertyList);
00795    }
00796    catch (IOException& e)
00797    {
00798       OW_THROWCIM_SUBEX(CIMException::FAILED, e);
00799    }
00800    OW_ASSERT(ci);
00801    if (pOutClass)
00802    {
00803       *pOutClass = cc;
00804    }
00805    
00806    return ci;
00807 }
00808 #ifndef OW_DISABLE_INSTANCE_MANIPULATION
00809 
00810 CIMInstance
00811 CIMRepository::deleteInstance(const String& ns, const CIMObjectPath& cop_,
00812    OperationContext& acl)
00813 {
00814    CIMObjectPath cop(cop_);
00815    cop.setNameSpace(ns);
00816    OW_LOG_DEBUG(m_logger, Format("CIMRepository::deleteInstance.  cop = %1",
00817       cop.toString()));
00818    try
00819    {
00820       CIMClass theClass(CIMNULL);
00821       CIMInstance oldInst = getInstance(ns, cop, E_NOT_LOCAL_ONLY, E_INCLUDE_QUALIFIERS, E_INCLUDE_CLASS_ORIGIN, NULL,
00822          &theClass, acl);
00823 #ifndef OW_DISABLE_ASSOCIATION_TRAVERSAL
00824       AssocDbHandle hdl = m_instAssocDb.getHandle();
00825       // Ensure no associations exist for this instance
00826       if (hdl.hasAssocEntries(ns, cop))
00827       {
00828          // TODO: Revisit this.  Instead of throwing, it is allowed in the
00829          // spec to to delete the associations that reference the instance.
00830          // See http://dmtf.org/standards/documents/WBEM/DSP200.html
00831          //   2.3.2.4. DeleteInstance
00832          OW_THROWCIMMSG(CIMException::FAILED,
00833             Format("Instance %1 has associations", cop.toString()).c_str());
00834       }
00835       // TODO: It would be good to check for Min(1) relationships to the
00836       // instance.
00837       // If we're deleting an association instance, then remove all
00838       // traces of it in the association database.
00839       if (theClass.isAssociation())
00840       {
00841          hdl.deleteEntries(ns, oldInst);
00842       }
00843 #endif
00844       // Delete the instance from the instance repository
00845       m_iStore.deleteInstance(ns, cop, theClass);
00846       OW_ASSERT(oldInst);
00847       return oldInst;
00848    }
00849    catch(IOException& e)
00850    {
00851       OW_THROWCIM_SUBEX(CIMException::FAILED, e);
00852    }
00853    catch(HDBException& e)
00854    {
00855       OW_THROWCIM_SUBEX(CIMException::FAILED, e);
00856    }
00857 }
00859 CIMObjectPath
00860 CIMRepository::createInstance(
00861    const String& ns,
00862    const CIMInstance& ci,
00863    OperationContext& context)
00864 {
00865    CIMObjectPath rval(ns, ci);
00866    try
00867    {
00868       OW_LOG_DEBUG(m_logger, Format("CIMRepository::createInstance.  ns = %1, "
00869          "instance = %2", ns, ci.toMOF()));
00870       CIMClass theClass = _instGetClass(ns, ci.getClassName());
00871       if (m_checkReferentialIntegrity)
00872       {
00873          if (theClass.isAssociation())
00874          {
00875             CIMPropertyArray pra = ci.getProperties(
00876                CIMDataType::REFERENCE);
00877             for (size_t j = 0; j < pra.size(); j++)
00878             {
00879                CIMValue cv = pra[j].getValue();
00880                if (!cv)
00881                {
00882                   OW_THROWCIMMSG(CIMException::INVALID_PARAMETER,
00883                      "Association has a NULL reference");
00884                }
00885                CIMObjectPath op(CIMNULL);
00886                cv.get(op);
00887                if (!op)
00888                {
00889                   OW_THROWCIMMSG(CIMException::INVALID_PARAMETER,
00890                      "Association has a NULL reference");
00891                }
00892                CIMClass rcc(CIMNULL);
00893                try
00894                {
00895                   m_env->getCIMOMHandle(context, ServiceEnvironmentIFC::E_USE_PROVIDERS,
00896                      ServiceEnvironmentIFC::E_NO_LOCKING)->getInstance(ns, op);
00897                }
00898                catch (CIMException& e)
00899                {
00900                   OW_THROWCIMMSG_SUBEX(CIMException::INVALID_PARAMETER,
00901                      Format("Association references an invalid instance:"
00902                         " %1", op.toString()).c_str(), e);
00903                }
00904             }
00905          }
00906          _validatePropagatedKeys(context, ns, ci, theClass);
00907       }
00908       //TODO: _checkRequiredProperties(theClass, ci);
00909       m_iStore.createInstance(ns, theClass, ci);
00910 #ifndef OW_DISABLE_ASSOCIATION_TRAVERSAL
00911       if (theClass.isAssociation())
00912       {
00913          AssocDbHandle hdl = m_instAssocDb.getHandle();
00914          hdl.addEntries(ns, ci);
00915       }
00916 #endif
00917       OW_ASSERT(rval);
00918       return rval;
00919    }
00920    catch (HDBException& e)
00921    {
00922       OW_THROWCIM_SUBEX(CIMException::FAILED, e);
00923    }
00924    catch (IOException& e)
00925    {
00926       OW_THROWCIM_SUBEX(CIMException::FAILED, e);
00927    }
00928 }
00930 CIMInstance
00931 CIMRepository::modifyInstance(
00932    const String& ns,
00933    const CIMInstance& modifiedInstance,
00934    EIncludeQualifiersFlag includeQualifiers,
00935    const StringArray* propertyList,
00936    OperationContext& acl)
00937 {
00938    try
00939    {
00940       CIMClass theClass(CIMNULL);
00941       CIMObjectPath cop(ns, modifiedInstance);
00942       CIMInstance oldInst = getInstance(ns, cop, E_NOT_LOCAL_ONLY, E_INCLUDE_QUALIFIERS, E_INCLUDE_CLASS_ORIGIN, NULL,
00943          &theClass, acl);
00944       //TODO: _checkRequiredProperties(theClass, modifiedInstance);
00945       m_iStore.modifyInstance(ns, cop, theClass, modifiedInstance, oldInst, includeQualifiers, propertyList);
00946 #ifndef OW_DISABLE_ASSOCIATION_TRAVERSAL
00947       // TODO: Verify that this code is needed.  Aren't all references keys, and thus can't be changed?  So why update the assoc db?
00948       // just create a test to try and break it.
00949       if (theClass.isAssociation())
00950       {
00951          AssocDbHandle adbHdl = m_instAssocDb.getHandle();
00952          adbHdl.deleteEntries(ns, oldInst);
00953          adbHdl.addEntries(ns, modifiedInstance);
00954       }
00955 #endif
00956       OW_ASSERT(oldInst);
00957       return oldInst;
00958    }
00959    catch (HDBException& e)
00960    {
00961       OW_THROWCIM_SUBEX(CIMException::FAILED, e);
00962    }
00963    catch (IOException& e)
00964    {
00965       OW_THROWCIM_SUBEX(CIMException::FAILED, e);
00966    }
00967 }
00968 #if !defined(OW_DISABLE_PROPERTY_OPERATIONS)
00969 
00970 void
00971 CIMRepository::setProperty(
00972    const String& ns,
00973    const CIMObjectPath& name,
00974    const String& propertyName, const CIMValue& valueArg,
00975    OperationContext& context)
00976 {
00977    CIMClass theClass = _instGetClass(ns, name.getClassName());
00978    CIMProperty cp = theClass.getProperty(propertyName);
00979    if (!cp)
00980    {
00981       OW_THROWCIMMSG(CIMException::NO_SUCH_PROPERTY,
00982          propertyName.c_str());
00983    }
00984    // Ensure value passed in is right data type
00985    CIMValue cv(valueArg);
00986    if (cv && (cp.getDataType().getType() != cv.getType()))
00987    {
00988       try
00989       {
00990          // this throws a FAILED CIMException if it can't convert
00991          cv = CIMValueCast::castValueToDataType(cv, cp.getDataType());
00992       }
00993       catch (CIMException& ce)
00994       {
00995          // translate FAILED to TYPE_MISMATCH
00996          if (ce.getErrNo() == CIMException::FAILED)
00997          {
00998             ce.setErrNo(CIMException::TYPE_MISMATCH);
00999          }
01000          throw ce;
01001       }
01002    }
01003    CIMInstance ci = getInstance(ns, name, E_NOT_LOCAL_ONLY, E_INCLUDE_QUALIFIERS, E_INCLUDE_CLASS_ORIGIN, NULL,
01004       NULL, context);
01005    if (!ci)
01006    {
01007       OW_THROWCIMMSG(CIMException::NOT_FOUND, name.toString().c_str());
01008    }
01009    CIMProperty tcp = ci.getProperty(propertyName);
01010    if (cp.isKey() && tcp.getValue() && !tcp.getValue().equal(cv))
01011    {
01012       String msg("Cannot modify key property: ");
01013       msg += cp.getName();
01014       OW_THROWCIMMSG(CIMException::FAILED, msg.c_str());
01015    }
01016    cp.setValue(cv);
01017    ci.setProperty(cp);
01018    modifyInstance(ns, ci, E_INCLUDE_QUALIFIERS, 0, context);
01019 }
01020 #endif // #if !defined(OW_DISABLE_PROPERTY_OPERATIONS)
01021 #endif // #ifndef OW_DISABLE_INSTANCE_MANIPULATION
01022 
01023 #if !defined(OW_DISABLE_PROPERTY_OPERATIONS)
01024 
01025 CIMValue
01026 CIMRepository::getProperty(
01027    const String& ns,
01028    const CIMObjectPath& name,
01029    const String& propertyName, OperationContext& context)
01030 {
01031    CIMClass theClass = _instGetClass(ns,name.getClassName());
01032    CIMProperty cp = theClass.getProperty(propertyName);
01033    if (!cp)
01034    {
01035       OW_THROWCIMMSG(CIMException::NO_SUCH_PROPERTY,
01036          propertyName.c_str());
01037    }
01038    CIMInstance ci = getInstance(ns, name, E_NOT_LOCAL_ONLY, E_INCLUDE_QUALIFIERS, E_INCLUDE_CLASS_ORIGIN, NULL,
01039       NULL, context);
01040    CIMProperty prop = ci.getProperty(propertyName);
01041    if (!prop)
01042    {
01043       OW_THROWCIMMSG(CIMException::NO_SUCH_PROPERTY,
01044          propertyName.c_str());
01045    }
01046    return prop.getValue();
01047 }
01048 #endif // #if !defined(OW_DISABLE_PROPERTY_OPERATIONS)
01049 
01050 CIMValue
01051 CIMRepository::invokeMethod(
01052    const String&,
01053    const CIMObjectPath&,
01054    const String&, const CIMParamValueArray&,
01055    CIMParamValueArray&, OperationContext&)
01056 {
01057    OW_THROWCIM(CIMException::NOT_SUPPORTED);
01058 }
01060 void
01061 CIMRepository::execQuery(
01062    const String&,
01063    CIMInstanceResultHandlerIFC&,
01064    const String&,
01065    const String&, OperationContext&)
01066 {
01067    OW_THROWCIM(CIMException::NOT_SUPPORTED);
01068 }
01069 #ifndef OW_DISABLE_ASSOCIATION_TRAVERSAL
01070 
01071 void
01072 CIMRepository::associators(
01073    const String& ns,
01074    const CIMObjectPath& path,
01075    CIMInstanceResultHandlerIFC& result,
01076    const String& assocClass, const String& resultClass,
01077    const String& role, const String& resultRole,
01078    EIncludeQualifiersFlag includeQualifiers, EIncludeClassOriginFlag includeClassOrigin,
01079    const StringArray* propertyList, OperationContext& context)
01080 {
01081    _commonAssociators(ns, path, assocClass, resultClass, role, resultRole,
01082       includeQualifiers, includeClassOrigin, propertyList, &result, 0, 0,
01083       context);
01084 }
01086 void
01087 CIMRepository::associatorsClasses(
01088    const String& ns,
01089    const CIMObjectPath& path,
01090    CIMClassResultHandlerIFC& result,
01091    const String& assocClass, const String& resultClass,
01092    const String& role, const String& resultRole,
01093    EIncludeQualifiersFlag includeQualifiers, EIncludeClassOriginFlag includeClassOrigin,
01094    const StringArray* propertyList, OperationContext& context)
01095 {
01096    _commonAssociators(ns, path, assocClass, resultClass, role, resultRole,
01097       includeQualifiers, includeClassOrigin, propertyList, 0, 0, &result,
01098       context);
01099 }
01101 void
01102 CIMRepository::associatorNames(
01103    const String& ns,
01104    const CIMObjectPath& path,
01105    CIMObjectPathResultHandlerIFC& result,
01106    const String& assocClass, const String& resultClass,
01107    const String& role, const String& resultRole,
01108    OperationContext& context)
01109 {
01110    _commonAssociators(ns, path, assocClass, resultClass, role, resultRole,
01111       E_EXCLUDE_QUALIFIERS, E_EXCLUDE_CLASS_ORIGIN, 0, 0, &result, 0, context);
01112 }
01114 void
01115 CIMRepository::references(
01116    const String& ns,
01117    const CIMObjectPath& path,
01118    CIMInstanceResultHandlerIFC& result,
01119    const String& resultClass, const String& role,
01120    EIncludeQualifiersFlag includeQualifiers, EIncludeClassOriginFlag includeClassOrigin,
01121    const StringArray* propertyList, OperationContext& context)
01122 {
01123    _commonReferences(ns, path, resultClass, role, includeQualifiers,
01124       includeClassOrigin, propertyList, &result, 0, 0, context);
01125 }
01127 void
01128 CIMRepository::referencesClasses(
01129    const String& ns,
01130    const CIMObjectPath& path,
01131    CIMClassResultHandlerIFC& result,
01132    const String& resultClass, const String& role,
01133    EIncludeQualifiersFlag includeQualifiers, EIncludeClassOriginFlag includeClassOrigin,
01134    const StringArray* propertyList, OperationContext& context)
01135 {
01136    _commonReferences(ns, path, resultClass, role, includeQualifiers,
01137       includeClassOrigin, propertyList, 0, 0, &result, context);
01138 }
01140 void
01141 CIMRepository::referenceNames(
01142    const String& ns,
01143    const CIMObjectPath& path,
01144    CIMObjectPathResultHandlerIFC& result,
01145    const String& resultClass, const String& role,
01146    OperationContext& context)
01147 {
01148    _commonReferences(ns, path, resultClass, role, E_EXCLUDE_QUALIFIERS, E_EXCLUDE_CLASS_ORIGIN, 0, 0, &result, 0,
01149       context);
01150 }
01152 namespace
01153 {
01154    class assocClassBuilder : public CIMClassResultHandlerIFC
01155    {
01156    public:
01157       assocClassBuilder(
01158          CIMClassArray& Assocs_)
01159       : Assocs(Assocs_)
01160       {}
01161    protected:
01162       virtual void doHandle(const CIMClass &cc)
01163       {
01164          if (!cc.isAssociation())
01165          {
01166             OW_THROWCIMMSG(CIMException::INVALID_PARAMETER,
01167                Format("class %1 is not an association", cc.getName()).c_str());
01168          }
01169          Assocs.append(cc);
01170       }
01171    private:
01172       CIMClassArray& Assocs;
01173    };
01174 }
01176 void
01177 CIMRepository::_commonReferences(
01178    const String& ns,
01179    const CIMObjectPath& path_,
01180    const CIMName& resultClass, const CIMName& role,
01181    EIncludeQualifiersFlag includeQualifiers, EIncludeClassOriginFlag includeClassOrigin,
01182    const StringArray* propertyList, CIMInstanceResultHandlerIFC* piresult,
01183    CIMObjectPathResultHandlerIFC* popresult,
01184    CIMClassResultHandlerIFC* pcresult, OperationContext& context)
01185 {
01186    CIMObjectPath path(path_);
01187    path.setNameSpace(ns);
01188    if (!m_nStore.nameSpaceExists(ns))
01189    {
01190       OW_THROWCIMMSG(CIMException::INVALID_NAMESPACE, ns.c_str());
01191    }
01192    // Get all association classes from the repository
01193    // If the result class was specified, only children of it will be
01194    // returned.
01195    CIMClassArray Assocs;
01196    assocClassBuilder assocClassResult(Assocs);
01197    _getAssociationClasses(ns, resultClass, path.getClassName(), assocClassResult, role, context);
01198    StringArray resultClassNames;
01199    for (size_t i = 0; i < Assocs.size(); i++)
01200    {
01201       resultClassNames.append(Assocs[i].getName());
01202    }
01203    SortedVectorSet<CIMName> resultClassNamesSet(resultClassNames.begin(), resultClassNames.end());
01204    if (path.isClassPath())
01205    {
01206       // Process all of the association classes without providers
01207       _staticReferencesClass(path,
01208          resultClass == CIMName() ? 0 : &resultClassNamesSet,
01209          role, includeQualifiers, includeClassOrigin, propertyList, popresult, pcresult, context);
01210    }
01211    else // it's an instance path
01212    {
01213       // Process all of the association classes without providers
01214       if (piresult != 0)
01215       {
01216          // do instances
01217          _staticReferences(path,
01218             resultClass == CIMName() ? 0 : &resultClassNamesSet, role,
01219             includeQualifiers, includeClassOrigin, propertyList, *piresult, context);
01220       }
01221       else if (popresult != 0)
01222       {
01223          // do names (object paths)
01224          _staticReferenceNames(path,
01225             resultClass == CIMName() ? 0 : &resultClassNamesSet, role,
01226             *popresult);
01227       }
01228       else
01229       {
01230          OW_ASSERT(0);
01231       }
01232    }
01233 }
01234 namespace
01235 {
01237    class staticReferencesObjectPathResultHandler : public AssocDbEntryResultHandlerIFC
01238    {
01239    public:
01240       staticReferencesObjectPathResultHandler(
01241          CIMObjectPathResultHandlerIFC& result_)
01242       : result(result_)
01243       {}
01244    protected:
01245       virtual void doHandle(const AssocDbEntry::entry &e)
01246       {
01247          result.handle(e.m_associationPath);
01248       }
01249    private:
01250       CIMObjectPathResultHandlerIFC& result;
01251    };
01252    
01254    class staticReferencesClassResultHandler : public AssocDbEntryResultHandlerIFC
01255    {
01256    public:
01257       staticReferencesClassResultHandler(
01258          CIMClassResultHandlerIFC& result_,
01259          CIMRepository& server_,
01260          String& ns_,
01261          EIncludeQualifiersFlag includeQualifiers_,
01262          EIncludeClassOriginFlag includeClassOrigin_,
01263          const StringArray* propList_,
01264          OperationContext& context_)
01265       : result(result_)
01266       , server(server_)
01267       , ns(ns_)
01268       , includeQualifiers(includeQualifiers_)
01269       , includeClassOrigin(includeClassOrigin_)
01270       , propList(propList_)
01271       , context(context_)
01272       {}
01273    protected:
01274       virtual void doHandle(const AssocDbEntry::entry &e)
01275       {
01276          CIMObjectPath cop = e.m_associationPath;
01277          if (cop.getNameSpace().empty())
01278          {
01279             cop.setNameSpace(ns);
01280          }
01281          CIMClass cc = server.getClass(cop.getNameSpace(),
01282             cop.getClassName(), E_NOT_LOCAL_ONLY, includeQualifiers,
01283             includeClassOrigin, propList, context);
01284          result.handle(cc);
01285       }
01286    private:
01287       CIMClassResultHandlerIFC& result;
01288       CIMRepository& server;
01289       String& ns;
01290       EIncludeQualifiersFlag includeQualifiers;
01291       EIncludeClassOriginFlag includeClassOrigin;
01292       const StringArray* propList;
01293       OperationContext& context;
01294    };
01296    class staticAssociatorsInstResultHandler : public AssocDbEntryResultHandlerIFC
01297    {
01298    public:
01299       staticAssociatorsInstResultHandler(
01300          OperationContext& context_,
01301          const CIMOMHandleIFCRef& hdl_,
01302          CIMInstanceResultHandlerIFC& result_,
01303          EIncludeQualifiersFlag includeQualifiers_,
01304          EIncludeClassOriginFlag includeClassOrigin_,
01305          const StringArray* propertyList_)
01306       : context(context_)
01307       , hdl(hdl_)
01308       , result(result_)
01309       , includeQualifiers(includeQualifiers_)
01310       , includeClassOrigin(includeClassOrigin_)
01311       , propertyList(propertyList_)
01312       {}
01313    protected:
01314       virtual void doHandle(const AssocDbEntry::entry &e)
01315       {
01316          CIMObjectPath op = e.m_associatedObject;
01317          CIMInstance ci = hdl->getInstance(op.getNameSpace(), op, E_NOT_LOCAL_ONLY, includeQualifiers, includeClassOrigin, propertyList);
01318          // TODO: This is a problem because the correct object path may not be passed back! The namespace will be lost, since a CIMInstance can't hold a namespace.
01319          result.handle(ci);
01320       }
01321    private:
01322       OperationContext& context;
01323       CIMOMHandleIFCRef hdl;
01324       CIMInstanceResultHandlerIFC& result;
01325       EIncludeQualifiersFlag includeQualifiers;
01326       EIncludeClassOriginFlag includeClassOrigin;
01327       const StringArray* propertyList;
01328    };
01329    
01331    class staticReferencesInstResultHandler : public AssocDbEntryResultHandlerIFC
01332    {
01333    public:
01334       staticReferencesInstResultHandler(OperationContext& intAclInfo_,
01335          const CIMOMHandleIFCRef& hdl_,
01336          CIMInstanceResultHandlerIFC& result_,
01337          EIncludeQualifiersFlag includeQualifiers_,
01338          EIncludeClassOriginFlag includeClassOrigin_,
01339          const StringArray* propertyList_)
01340       : intAclInfo(intAclInfo_)
01341       , hdl(hdl_)
01342       , result(result_)
01343       , includeQualifiers(includeQualifiers_)
01344       , includeClassOrigin(includeClassOrigin_)
01345       , propertyList(propertyList_)
01346       {}
01347    protected:
01348       virtual void doHandle(const AssocDbEntry::entry &e)
01349       {
01350          CIMObjectPath op = e.m_associationPath;
01351          CIMInstance ci = hdl->getInstance(op.getNameSpace(), op, E_NOT_LOCAL_ONLY, includeQualifiers, includeClassOrigin, propertyList);
01352          result.handle(ci);
01353       }
01354    private:
01355       OperationContext& intAclInfo;
01356       CIMOMHandleIFCRef hdl;
01357       CIMInstanceResultHandlerIFC& result;
01358       EIncludeQualifiersFlag includeQualifiers;
01359       EIncludeClassOriginFlag includeClassOrigin;
01360       const StringArray* propertyList;
01361    };
01362 }
01364 void
01365 CIMRepository::_staticReferences(const CIMObjectPath& path,
01366    const SortedVectorSet<CIMName>* refClasses, const CIMName& role,
01367    EIncludeQualifiersFlag includeQualifiers, EIncludeClassOriginFlag includeClassOrigin,
01368    const StringArray* propertyList, CIMInstanceResultHandlerIFC& result,
01369    OperationContext& context)
01370 {
01371    AssocDbHandle dbhdl = m_instAssocDb.getHandle();
01372    staticReferencesInstResultHandler handler(context, m_env->getCIMOMHandle(context,
01373       ServiceEnvironmentIFC::E_USE_PROVIDERS, ServiceEnvironmentIFC::E_NO_LOCKING), result,
01374       includeQualifiers, includeClassOrigin, propertyList);
01375    dbhdl.getAllEntries(path,
01376       refClasses, 0, role, CIMName(), handler);
01377 }
01379 void
01380 CIMRepository::_staticReferenceNames(const CIMObjectPath& path,
01381    const SortedVectorSet<CIMName>* refClasses, const CIMName& role,
01382    CIMObjectPathResultHandlerIFC& result)
01383 {
01384    AssocDbHandle dbhdl = m_instAssocDb.getHandle();
01385    staticReferencesObjectPathResultHandler handler(result);
01386    dbhdl.getAllEntries(path,
01387       refClasses, 0, role, CIMName(), handler);
01388 }
01390 void
01391 CIMRepository::_commonAssociators(
01392    const String& ns,
01393    const CIMObjectPath& path_,
01394    const CIMName& assocClassName, const CIMName& resultClass,
01395    const CIMName& role, const CIMName& resultRole,
01396    EIncludeQualifiersFlag includeQualifiers, EIncludeClassOriginFlag includeClassOrigin,
01397    const StringArray* propertyList,
01398    CIMInstanceResultHandlerIFC* piresult,
01399    CIMObjectPathResultHandlerIFC* popresult,
01400    CIMClassResultHandlerIFC* pcresult,
01401    OperationContext& context)
01402 {
01403    CIMObjectPath path(path_);
01404    path.setNameSpace(ns);
01405    if (!m_nStore.nameSpaceExists(ns))
01406    {
01407       OW_THROWCIMMSG(CIMException::INVALID_NAMESPACE, ns.c_str());
01408    }
01409    // Get association classes from the association repository
01410    CIMClassArray Assocs;
01411    assocClassBuilder assocClassResult(Assocs);
01412    _getAssociationClasses(ns, assocClassName, path.getClassName(), assocClassResult, role, context);
01413    // If the result class was specified, get a list of all the classes the
01414    // objects must be instances of.
01415    CIMNameArray resultClassNames;
01416    if (resultClass != CIMName())
01417    {
01418       resultClassNames = getClassChildren(m_mStore, ns, resultClass);
01419       resultClassNames.append(resultClass);
01420    }
01421    StringArray assocClassNames;
01422    for (size_t i = 0; i < Assocs.size(); i++)
01423    {
01424       assocClassNames.append(Assocs[i].getName());
01425    }
01426    SortedVectorSet<CIMName> assocClassNamesSet(assocClassNames.begin(),
01427          assocClassNames.end());
01428    SortedVectorSet<CIMName> resultClassNamesSet(resultClassNames.begin(),
01429          resultClassNames.end());
01430    if (path.isClassPath())
01431    {
01432       // Process all of the association classes without providers
01433       _staticAssociatorsClass(path, assocClassName == CIMName() ? 0 : &assocClassNamesSet,
01434          resultClass == CIMName() ? 0 : &resultClassNamesSet,
01435          role, resultRole, includeQualifiers, includeClassOrigin, propertyList, popresult, pcresult, context);
01436    }
01437    else // it's an instance path
01438    {
01439       // Process all of the association classes without providers
01440       if (piresult != 0)
01441       {
01442          // do instances
01443          _staticAssociators(path, assocClassName == CIMName() ? 0 : &assocClassNamesSet,
01444             resultClass == CIMName() ? 0 : &resultClassNamesSet, role, resultRole,
01445             includeQualifiers, includeClassOrigin, propertyList, *piresult, context);
01446       }
01447       else if (popresult != 0)
01448       {
01449          // do names (object paths)
01450          _staticAssociatorNames(path, assocClassName == CIMName() ? 0 : &assocClassNamesSet,
01451             resultClass == CIMName() ? 0 : &resultClassNamesSet, role, resultRole,
01452             *popresult);
01453       }
01454       else
01455       {
01456          OW_ASSERT(0);
01457       }
01458    }
01459 }
01461 void
01462 CIMRepository::_staticAssociators(const CIMObjectPath& path,
01463    const SortedVectorSet<CIMName>* passocClasses,
01464    const SortedVectorSet<CIMName>* presultClasses,
01465    const CIMName& role, const CIMName& resultRole,
01466    EIncludeQualifiersFlag includeQualifiers, EIncludeClassOriginFlag includeClassOrigin,
01467    const StringArray* propertyList, CIMInstanceResultHandlerIFC& result,
01468    OperationContext& context)
01469 {
01470    AssocDbHandle dbhdl = m_instAssocDb.getHandle();
01471    staticAssociatorsInstResultHandler handler(context, m_env->getCIMOMHandle(context,
01472       ServiceEnvironmentIFC::E_USE_PROVIDERS, ServiceEnvironmentIFC::E_NO_LOCKING), result,
01473       includeQualifiers, includeClassOrigin, propertyList);
01474    dbhdl.getAllEntries(path,
01475       passocClasses, presultClasses, role, resultRole, handler);
01476       
01477 }
01478 namespace
01479 {
01481    class staticAssociatorsObjectPathResultHandler : public AssocDbEntryResultHandlerIFC
01482    {
01483    public:
01484       staticAssociatorsObjectPathResultHandler(
01485          CIMObjectPathResultHandlerIFC& result_)
01486       : result(result_)
01487       {}
01488    protected:
01489       virtual void doHandle(const AssocDbEntry::entry &e)
01490       {
01491          result.handle(e.m_associatedObject);
01492       }
01493    private:
01494       CIMObjectPathResultHandlerIFC& result;
01495    };
01496    
01498    class staticAssociatorsClassResultHandler : public AssocDbEntryResultHandlerIFC
01499    {
01500    public:
01501       staticAssociatorsClassResultHandler(
01502          CIMClassResultHandlerIFC& result_,
01503          CIMRepository& server_,
01504          String& ns_,
01505          EIncludeQualifiersFlag includeQualifiers_,
01506          EIncludeClassOriginFlag includeClassOrigin_,
01507          const StringArray* propList_,
01508          OperationContext& context_)
01509       : result(result_)
01510       , server(server_)
01511       , ns(ns_)
01512       , includeQualifiers(includeQualifiers_)
01513       , includeClassOrigin(includeClassOrigin_)
01514       , propList(propList_)
01515       , context(context_)
01516       {}
01517    protected:
01518       virtual void doHandle(const AssocDbEntry::entry &e)
01519       {
01520          CIMObjectPath cop = e.m_associatedObject;
01521          if (cop.getNameSpace().empty())
01522          {
01523             cop.setNameSpace(ns);
01524          }
01525          CIMClass cc = server.getClass(cop.getNameSpace(),
01526             cop.getClassName(), E_NOT_LOCAL_ONLY, includeQualifiers,
01527             includeClassOrigin, propList, context);
01528          result.handle(cc);
01529       }
01530    private:
01531       CIMClassResultHandlerIFC& result;
01532       CIMRepository& server;
01533       String& ns;
01534       EIncludeQualifiersFlag includeQualifiers;
01535       EIncludeClassOriginFlag includeClassOrigin;
01536       const StringArray* propList;
01537       OperationContext& context;
01538    };
01539 }
01541 void
01542 CIMRepository::_staticAssociatorNames(const CIMObjectPath& path,
01543    const SortedVectorSet<CIMName>* passocClasses,
01544    const SortedVectorSet<CIMName>* presultClasses,
01545    const CIMName& role, const CIMName& resultRole,
01546    CIMObjectPathResultHandlerIFC& result)
01547 {
01548    AssocDbHandle dbhdl = m_instAssocDb.getHandle();
01549    staticAssociatorsObjectPathResultHandler handler(result);
01550    dbhdl.getAllEntries(path,
01551       passocClasses, presultClasses, role, resultRole, handler);
01552       
01553 }
01555 void
01556 CIMRepository::_staticAssociatorsClass(
01557    const CIMObjectPath& path,
01558    const SortedVectorSet<CIMName>* assocClassNames,
01559    const SortedVectorSet<CIMName>* resultClasses,
01560    const CIMName& role, const CIMName& resultRole,
01561    EIncludeQualifiersFlag includeQualifiers, EIncludeClassOriginFlag includeClassOrigin,
01562    const StringArray* propertyList, CIMObjectPathResultHandlerIFC* popresult,
01563    CIMClassResultHandlerIFC* pcresult,
01564    OperationContext& context)
01565 {
01566    AssocDbHandle dbhdl = m_classAssocDb.getHandle();
01567    // need to run the query for every superclass of the class arg.
01568    CIMName curClsName = path.getClassName();
01569    CIMObjectPath curPath = path;
01570    while (curClsName != CIMName())
01571    {
01572       if (popresult != 0)
01573       {
01574          staticAssociatorsObjectPathResultHandler handler(*popresult);
01575          dbhdl.getAllEntries(curPath, assocClassNames, resultClasses, role, resultRole,
01576             handler);
01577       }
01578       else if (pcresult != 0)
01579       {
01580          String ns = path.getNameSpace();
01581          staticAssociatorsClassResultHandler handler(*pcresult,*this,
01582             ns, includeQualifiers, includeClassOrigin,
01583             propertyList, context);
01584          dbhdl.getAllEntries(curPath, assocClassNames, resultClasses, role, resultRole,
01585             handler);
01586       }
01587       else
01588       {
01589          OW_ASSERT(0);
01590       }
01591       // get the current class so we can get the name of the superclass
01592       CIMClass theClass = _getClass(curPath.getNameSpace(), curPath.getClassName());
01593       curClsName = theClass.getSuperClass();
01594       curPath.setClassName(curClsName);
01595    }
01596 }
01598 void
01599 CIMRepository::_staticReferencesClass(const CIMObjectPath& path,
01600    const SortedVectorSet<CIMName>* resultClasses,
01601    const CIMName& role,
01602    EIncludeQualifiersFlag includeQualifiers, EIncludeClassOriginFlag includeClassOrigin,
01603    const StringArray* propertyList,
01604    CIMObjectPathResultHandlerIFC* popresult,
01605    CIMClassResultHandlerIFC* pcresult,
01606    OperationContext& context)
01607 {
01608    AssocDbHandle dbhdl = m_classAssocDb.getHandle();
01609    // need to run the query for every superclass of the class arg.
01610    CIMName curClsName = path.getClassName();
01611    CIMObjectPath curPath = path;
01612    while (curClsName != CIMName())
01613    {
01614       OW_LOG_DEBUG(m_logger, Format("curPath = %1", curPath.toString()));
01615       if (popresult != 0)
01616       {
01617          staticReferencesObjectPathResultHandler handler(*popresult);
01618          dbhdl.getAllEntries(curPath, resultClasses, 0, role, CIMName(),
01619             handler);
01620       }
01621       else if (pcresult != 0)
01622       {
01623          String ns = path.getNameSpace();
01624          staticReferencesClassResultHandler handler(*pcresult,*this,
01625             ns, includeQualifiers, includeClassOrigin,
01626             propertyList, context);
01627          dbhdl.getAllEntries(curPath, resultClasses, 0, role, CIMName(),
01628             handler);
01629       }
01630       else
01631       {
01632          OW_ASSERT(0);
01633       }
01634       // get the current class so we can get the name of the superclass
01635       CIMClass theClass = _getClass(curPath.getNameSpace(), curPath.getClassName());
01636       curClsName = theClass.getSuperClass();
01637       curPath.setClassName(curClsName);
01638    }
01639 }
01641 namespace
01642 {
01643    class assocHelper : public CIMClassResultHandlerIFC
01644    {
01645    public:
01646       assocHelper(
01647          CIMClassResultHandlerIFC& handler_,
01648          MetaRepository& m_mStore_,
01649          const String& ns_)
01650       : handler(handler_)
01651       , m_mStore(m_mStore_)
01652       , ns(ns_)
01653       {}
01654    protected:
01655       virtual void doHandle(const CIMClass &cc)
01656       {
01657          handler.handle(cc);
01658          m_mStore.enumClass(ns, cc.getName(), handler, E_DEEP, E_NOT_LOCAL_ONLY, E_INCLUDE_QUALIFIERS, E_INCLUDE_CLASS_ORIGIN);
01659       }
01660    private:
01661       CIMClassResultHandlerIFC& handler;
01662       MetaRepository& m_mStore;
01663       const String& ns;
01664    };
01665 }
01667 void
01668 CIMRepository::_getAssociationClasses(const String& ns,
01669       const CIMName& assocClassName, const CIMName& className,
01670       CIMClassResultHandlerIFC& result, const CIMName& role,
01671       OperationContext& context)
01672 {
01673    if (assocClassName != CIMName())
01674    {
01675       // they gave us a class name so we can use the class association index
01676       // to only look at the ones that could provide associations
01677       m_mStore.enumClass(ns, assocClassName.toString(), result, E_DEEP, E_NOT_LOCAL_ONLY, E_INCLUDE_QUALIFIERS, E_INCLUDE_CLASS_ORIGIN);
01678       CIMClass cc(CIMNULL);
01679       CIMException::ErrNoType rc = m_mStore.getCIMClass(ns, assocClassName.toString(), E_NOT_LOCAL_ONLY, E_INCLUDE_QUALIFIERS, E_INCLUDE_CLASS_ORIGIN, 0, cc);
01680       if (rc != CIMException::SUCCESS)
01681       {
01682          OW_THROWCIM(CIMException::FAILED);
01683       }
01684       result.handle(cc);
01685    }
01686    else
01687    {
01688       // need to get all the assoc classes with dynamic providers
01689       CIMObjectPath cop(className, ns);
01690       _staticReferencesClass(cop,0,role,E_INCLUDE_QUALIFIERS,E_EXCLUDE_CLASS_ORIGIN,0,0,&result, context);
01691       // TODO: test if this is faster
01692       //assocHelper helper(result, m_mStore, ns);
01693       //m_mStore.getTopLevelAssociations(ns, helper);
01694    }
01695 }
01696 #endif // #ifndef OW_DISABLE_ASSOCIATION_TRAVERSAL
01697 
01698 void
01699 CIMRepository::checkGetClassRvalAndThrow(CIMException::ErrNoType rval,
01700    const String& ns, const CIMName& className)
01701 {
01702    if (rval != CIMException::SUCCESS)
01703    {
01704       // check whether the namespace was invalid or not
01705       if (rval == CIMException::NOT_FOUND)
01706       {
01707          if (!m_nStore.nameSpaceExists(ns))
01708          {
01709             OW_THROWCIMMSG(CIMException::INVALID_NAMESPACE, ns.c_str());
01710          }
01711       }
01712       OW_THROWCIMMSG(rval, CIMObjectPath(className, ns).toString().c_str());
01713    }
01714 }
01715 void
01716 CIMRepository::checkGetClassRvalAndThrowInst(CIMException::ErrNoType rval,
01717    const String& ns, const CIMName& className)
01718 {
01719    if (rval != CIMException::SUCCESS)
01720    {
01721       // check whether the namespace was invalid or not
01722       if (rval == CIMException::NOT_FOUND)
01723       {
01724          if (!m_nStore.nameSpaceExists(ns))
01725          {
01726             OW_THROWCIMMSG(CIMException::INVALID_NAMESPACE, ns.c_str());
01727          }
01728          else
01729          {
01730             rval = CIMException::INVALID_CLASS;
01731          }
01732       }
01733       OW_THROWCIMMSG(rval, CIMObjectPath(className, ns).toString().c_str());
01734    }
01735 }
01737 namespace
01738 {
01739    class ClassNameArrayBuilder : public CIMObjectPathResultHandlerIFC
01740    {
01741    public:
01742       ClassNameArrayBuilder(StringArray& names_)
01743       : names(names_)
01744       {}
01745       void doHandle(const CIMObjectPath& op)
01746       {
01747          names.push_back(op.getClassName());
01748       }
01749    private:
01750       StringArray& names;
01751    };
01752 }
01754 void
01755 CIMRepository::_validatePropagatedKeys(OperationContext& context, const String& ns,
01756    const CIMInstance& ci, const CIMClass& theClass)
01757 {
01758    CIMObjectPathArray rv;
01759    CIMPropertyArray kprops = theClass.getKeys();
01760    if (kprops.size() == 0)
01761    {
01762       return;
01763    }
01764    Map<CIMName, CIMPropertyArray> theMap;
01765    Bool hasPropagatedKeys = false;
01766    // Look at all propagated key properties
01767    for (size_t i = 0; i < kprops.size(); i++)
01768    {
01769       CIMQualifier cq = kprops[i].getQualifier(
01770          CIMQualifier::CIM_QUAL_PROPAGATED);
01771       if (!cq)
01772       {
01773          continue;
01774       }
01775       hasPropagatedKeys = true;
01776       CIMValue cv = cq.getValue();
01777       if (!cv)
01778       {
01779          continue;
01780       }
01781       String cls;
01782       cv.get(cls);
01783       if (cls.empty())
01784       {
01785          continue;
01786       }
01787       size_t idx = cls.indexOf('.');
01788       CIMName ppropName;
01789       if (idx != String::npos)
01790       {
01791          ppropName = cls.substring(idx+1);
01792          cls = cls.substring(0,idx);
01793       }
01794       CIMProperty cp = ci.getProperty(kprops[i].getName());
01795       if (!cp || !cp.getValue())
01796       {
01797          OW_THROWCIMMSG(CIMException::INVALID_PARAMETER,
01798             Format("Cannot create instance. Propagated key field missing:"
01799                " %1", kprops[i].getName()).c_str());
01800       }
01801       if (ppropName != CIMName())
01802       {
01803          // We need to use the propagated property name, not the property
01804          // name on ci.  e.g. Given
01805          // [Propagated("fooClass.fooPropName")] string myPropName;
01806          // we need to check for fooPropName as the key to the propagated
01807          // instance, not myPropName.
01808          cp.setName(ppropName);
01809       }
01810       theMap[cls].append(cp);
01811    }
01812    if (!hasPropagatedKeys)
01813    {
01814       return;
01815    }
01816    if (theMap.size() == 0)
01817    {
01818       OW_THROWCIMMSG(CIMException::INVALID_PARAMETER,
01819          "Cannot create instance. Propagated key properties missing");
01820    }
01821    CIMObjectPath op(ns, ci);
01822    Map<CIMName, CIMPropertyArray>::iterator it = theMap.begin();
01823    while (it != theMap.end())
01824    {
01825       CIMName clsname = it->first;
01826       
01827       // since we don't know what class the keys refer to, we get all subclasses
01828       // and try calling getInstance for each to see if we can find one with
01829       // the matching keys.
01830       OW_LOG_DEBUG(m_logger, Format("Getting class children of: %1", clsname));
01831       CIMNameArray classes = getClassChildren(m_mStore, ns,
01832          clsname);
01833       classes.push_back(clsname);
01834       op.setKeys(it->second);
01835       bool found = false;
01836       for (size_t i = 0; i < classes.size(); ++i)
01837       {
01838          op.setClassName(classes[i]);
01839          OW_LOG_DEBUG(m_logger, Format("Trying getInstance of: %1", op.toString()));
01840          try
01841          {
01842             m_env->getCIMOMHandle(context, ServiceEnvironmentIFC::E_USE_PROVIDERS,
01843                ServiceEnvironmentIFC::E_NO_LOCKING)->getInstance(ns, op);
01844             // if the previous line didn't throw, then we found it.
01845             found = true;
01846             break;
01847          }
01848          catch (const CIMException&)
01849          {
01850          }
01851       }
01852       if (!found)
01853       {
01854          OW_THROWCIMMSG(CIMException::INVALID_PARAMETER,
01855             Format("Propagated keys refer to non-existent object: %1",
01856                op.toString()).c_str());
01857       }
01858       ++it;
01859    }
01860 }
01861 
01863 void
01864 CIMRepository::beginOperation(WBEMFlags::EOperationFlag op, OperationContext& context)
01865 {
01866    if (context.keyHasData(OperationContext::BYPASS_LOCKERKEY))
01867    {
01868       return;
01869    }
01870 
01871 // TODO: Make this configurable?  Maybe even a parameter that can be specifed by the client on each request?
01872    const UInt32 LockTimeout = 300; // seconds - 5 mins.
01873    switch (op)
01874    {
01875    case E_CREATE_NAMESPACE:
01876    case E_DELETE_NAMESPACE:
01877    case E_DELETE_INSTANCE:
01878    case E_CREATE_INSTANCE:
01879    case E_MODIFY_INSTANCE:
01880    case E_SET_PROPERTY:
01881    case E_INVOKE_METHOD:
01882    case E_EXEC_QUERY:
01883       m_schemaLock.getWriteLock(LockTimeout);
01884       m_instanceLock.getWriteLock(LockTimeout);
01885       break;
01886    case E_ENUM_NAMESPACE:
01887    case E_GET_QUALIFIER_TYPE:
01888    case E_ENUM_QUALIFIER_TYPES:
01889    case E_GET_CLASS:
01890    case E_ENUM_CLASSES:
01891    case E_ENUM_CLASS_NAMES:
01892    case E_ASSOCIATORS_CLASSES:
01893    case E_REFERENCES_CLASSES:
01894       m_schemaLock.getReadLock(LockTimeout);
01895       break;
01896    case E_DELETE_QUALIFIER_TYPE:
01897    case E_SET_QUALIFIER_TYPE:
01898    case E_DELETE_CLASS:
01899    case E_CREATE_CLASS:
01900    case E_MODIFY_CLASS:
01901       m_schemaLock.getWriteLock(LockTimeout);
01902       break;
01903    case E_ENUM_INSTANCES:
01904    case E_ENUM_INSTANCE_NAMES:
01905    case E_GET_INSTANCE:
01906    case E_GET_PROPERTY:
01907    case E_ASSOCIATOR_NAMES:
01908    case E_ASSOCIATORS:
01909    case E_REFERENCE_NAMES:
01910    case E_REFERENCES:
01911       m_schemaLock.getReadLock(LockTimeout);
01912       m_instanceLock.getReadLock(LockTimeout);
01913       break;
01914    case E_EXPORT_INDICATION:
01915    default:
01916       break;
01917    }
01918 }
01919 
01921 void
01922 CIMRepository::endOperation(WBEMFlags::EOperationFlag op, OperationContext& context, WBEMFlags::EOperationResultFlag result)
01923 {
01924    if (context.keyHasData(OperationContext::BYPASS_LOCKERKEY))
01925    {
01926       return;
01927    }
01928 
01929    switch (op)
01930    {
01931    case E_CREATE_NAMESPACE:
01932    case E_DELETE_NAMESPACE:
01933    case E_DELETE_INSTANCE:
01934    case E_CREATE_INSTANCE:
01935    case E_MODIFY_INSTANCE:
01936    case E_SET_PROPERTY:
01937    case E_INVOKE_METHOD:
01938    case E_EXEC_QUERY:
01939       m_instanceLock.releaseWriteLock();
01940       m_schemaLock.releaseWriteLock();
01941       break;
01942    case E_ENUM_NAMESPACE:
01943    case E_GET_QUALIFIER_TYPE:
01944    case E_ENUM_QUALIFIER_TYPES:
01945    case E_GET_CLASS:
01946    case E_ENUM_CLASSES:
01947    case E_ENUM_CLASS_NAMES:
01948    case E_ASSOCIATORS_CLASSES:
01949    case E_REFERENCES_CLASSES:
01950       m_schemaLock.releaseReadLock();
01951       break;
01952    case E_DELETE_QUALIFIER_TYPE:
01953    case E_SET_QUALIFIER_TYPE:
01954    case E_DELETE_CLASS:
01955    case E_CREATE_CLASS:
01956    case E_MODIFY_CLASS:
01957       m_schemaLock.releaseWriteLock();
01958       break;
01959    case E_ENUM_INSTANCES:
01960    case E_ENUM_INSTANCE_NAMES:
01961    case E_GET_INSTANCE:
01962    case E_GET_PROPERTY:
01963    case E_ASSOCIATOR_NAMES:
01964    case E_ASSOCIATORS:
01965    case E_REFERENCE_NAMES:
01966    case E_REFERENCES:
01967       m_instanceLock.releaseReadLock();
01968       m_schemaLock.releaseReadLock();
01969       break;
01970    case E_EXPORT_INDICATION:
01971    default:
01972       break;
01973    }
01974 }
01975 
01976 
01977 const char* const CIMRepository::INST_REPOS_NAME = "instances";
01978 const char* const CIMRepository::META_REPOS_NAME = "schema";
01979 const char* const CIMRepository::NS_REPOS_NAME = "namespaces";
01980 #ifndef OW_DISABLE_ASSOCIATION_TRAVERSAL
01981 const char* const CIMRepository::CLASS_ASSOC_REPOS_NAME = "classassociation";
01982 const char* const CIMRepository::INST_ASSOC_REPOS_NAME = "instassociation";
01983 #endif
01984 
01985 } // end namespace OW_NAMESPACE
01986 

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