⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 subscriptionrepository.cpp

📁 Pegasus is an open-source implementationof the DMTF CIM and WBEM standards. It is designed to be por
💻 CPP
📖 第 1 页 / 共 3 页
字号:
    {        CIMValue stateValue = instance.getProperty            (stateIndex).getValue ();        if (stateValue.isNull ())        {            PEG_TRACE_STRING (TRC_INDICATION_SERVICE_INTERNAL,                Tracer::LEVEL2,                "Null SubscriptionState property value");            //            //  This is a corrupted/invalid instance            //            return false;        }        else if ((stateValue.getType () != CIMTYPE_UINT16) ||            (stateValue.isArray ()))        {            String traceString;            if (stateValue.isArray ())            {                traceString.append ("array of ");            }            traceString.append (cimTypeToString (stateValue.getType ()));            PEG_TRACE_STRING (TRC_INDICATION_SERVICE_INTERNAL,               Tracer::LEVEL2,               "SubscriptionState property value of incorrect type: "               + traceString);            //            //  This is a corrupted/invalid instance            //            return false;        }        else        {            stateValue.get (state);        }    }    else    {        PEG_TRACE_STRING (TRC_INDICATION_SERVICE_INTERNAL,            Tracer::LEVEL2,            "Missing SubscriptionState property");        //        //  This is a corrupted/invalid instance        //        return false;    }    PEG_METHOD_EXIT ();    return true;}CIMInstance SubscriptionRepository::deleteSubscription (    CIMObjectPath & subscription){    PEG_METHOD_ENTER (TRC_INDICATION_SERVICE,        "SubscriptionRepository::deleteSubscription");    CIMInstance subscriptionInstance;    CIMNamespaceName nameSpace = subscription.getNameSpace ();    subscription.setNameSpace (CIMNamespaceName ());    //    //  Get instance from repository    //    try    {        subscriptionInstance = _repository->getInstance (nameSpace,            subscription);    }    catch (Exception & exception)    {        PEG_TRACE_STRING (TRC_INDICATION_SERVICE_INTERNAL, Tracer::LEVEL2,            "Exception caught in retrieving subscription (" +            subscriptionInstance.getPath ().toString () + "): " +            exception.getMessage ());        //        //  If the subscription could not be retrieved, it may already have        //  been deleted by another thread        //        PEG_METHOD_EXIT ();        return CIMInstance ();    }    //    //  Delete the subscription instance    //    try    {        _repository->deleteInstance (nameSpace, subscription);    }    catch (Exception & exception)    {        PEG_TRACE_STRING (TRC_INDICATION_SERVICE_INTERNAL, Tracer::LEVEL2,            "Exception caught in deleting subscription (" +            subscriptionInstance.getPath ().toString () + "): " +            exception.getMessage ());        //        //  If the subscription could not be deleted, it may already have        //  been deleted by another thread        //        PEG_METHOD_EXIT ();        return CIMInstance ();    }    //    //  Reset namespace in object path    //    subscription.setNameSpace (nameSpace);    PEG_METHOD_EXIT ();    return subscriptionInstance;}Array <CIMInstance> SubscriptionRepository::deleteReferencingSubscriptions (    const CIMNamespaceName & nameSpace,    const CIMName & referenceProperty,    const CIMObjectPath & handler){    PEG_METHOD_ENTER (TRC_INDICATION_SERVICE,        "SubscriptionRepository::deleteReferencingSubscriptions");    Array <CIMInstance> subscriptions;    Array <CIMInstance> deletedSubscriptions;    //    //  Get all subscriptions in all namespaces    //    subscriptions = getAllSubscriptions ();    //    //  Check each subscription for a reference to the specified instance    //    for (Uint32 i = 0; i < subscriptions.size (); i++)    {        //        //  Get the reference property value from the subscription instance        //        CIMValue propValue = subscriptions [i].getProperty            (subscriptions [i].findProperty (referenceProperty)).getValue ();        CIMObjectPath ref;        propValue.get (ref);        //        //  If the Handler reference property value includes namespace, check        //  if it is the namespace of the Handler being deleted.        //  If the Handler reference property value does not include namespace,        //  check if the current subscription namespace is the namespace of the        //  Handler being deleted.        //        CIMNamespaceName handlerNS = ref.getNameSpace ();        if (((handlerNS.isNull ()) &&            (subscriptions[i].getPath ().getNameSpace () == nameSpace))            || (handlerNS == nameSpace))        {            //            //  Remove Host and Namespace from reference property value, if            //  present, before comparing            //            CIMObjectPath href ("", CIMNamespaceName (),                ref.getClassName (), ref.getKeyBindings ());            //            //  Remove Host and Namespace from reference of handler instance to            //  be deleted, if present, before comparing            //            CIMObjectPath iref ("", CIMNamespaceName (),                handler.getClassName (), handler.getKeyBindings ());            //            //  If the current subscription references the specified instance,            //  delete it            //            if (iref == href)            {                //                //  Delete referencing subscription instance from repository                //                try                {                    //                    //  Namespace and host must not be set in path passed to                    //  repository                    //                    CIMObjectPath path ("", CIMNamespaceName (),                        subscriptions [i].getPath ().getClassName (),                        subscriptions [i].getPath ().getKeyBindings ());                    _repository->deleteInstance                        (subscriptions [i].getPath ().getNameSpace (), path);                }                catch (Exception & exception)                {                    //                    //  Deletion of referencing subscription failed                    //                    PEG_TRACE_STRING (TRC_INDICATION_SERVICE_INTERNAL,                        Tracer::LEVEL2,                        "Exception caught deleting referencing subscription (" +                        subscriptions [i].getPath ().toString () + "): " +                        exception.getMessage ());                }                 deletedSubscriptions.append (subscriptions [i]);            }        }    }    PEG_METHOD_EXIT ();    return deletedSubscriptions;}CIMInstance SubscriptionRepository::getHandler (    const CIMInstance & subscription) const{    PEG_METHOD_ENTER (TRC_INDICATION_SERVICE,        "SubscriptionRepository::getHandler");    CIMValue handlerValue;    CIMObjectPath handlerRef;    CIMInstance handlerInstance;    CIMNamespaceName nameSpaceName;    //    //  Get Handler reference from subscription instance    //    handlerValue = subscription.getProperty (subscription.findProperty        (PEGASUS_PROPERTYNAME_HANDLER)).getValue ();    handlerValue.get (handlerRef);    //    //  Get handler namespace - if not set in Handler reference property value,    //  namespace is the namespace of the subscription    //    nameSpaceName = handlerRef.getNameSpace ();    if (nameSpaceName.isNull ())    {        nameSpaceName = subscription.getPath ().getNameSpace ();    }    //    //  Get Handler instance from the repository    //    try    {        handlerInstance = _repository->getInstance            (nameSpaceName, handlerRef, false, false, false,            CIMPropertyList ());    }    catch (const Exception & exception)    {        PEG_TRACE_STRING (TRC_DISCARDED_DATA, Tracer::LEVEL2,            "Exception caught trying to get Handler instance (" +            handlerRef.toString () + "): " +            exception.getMessage ());        PEG_METHOD_EXIT ();        throw;    }    //    //  Set namespace in path in CIMInstance    //    handlerRef.setNameSpace (nameSpaceName);    handlerInstance.setPath (handlerRef);    PEG_METHOD_EXIT ();    return handlerInstance;}Boolean SubscriptionRepository::isTransient (    const CIMNamespaceName & nameSpace,    const CIMObjectPath & handler) const{    PEG_METHOD_ENTER (TRC_INDICATION_SERVICE,        "SubscriptionRepository::isTransient");    CIMValue persistenceValue;    Uint16 persistenceType;    //    //  Get the handler instance from the repository    //    CIMInstance instance;    try    {        instance = _repository->getInstance (nameSpace, handler,            false, false, false, CIMPropertyList ());    }    catch (const Exception &)    {        PEG_METHOD_EXIT ();        throw;    }    //    //  Get Persistence Type    //    persistenceValue = instance.getProperty (instance.findProperty        (PEGASUS_PROPERTYNAME_PERSISTENCETYPE)).getValue ();    persistenceValue.get (persistenceType);    if (persistenceType == PERSISTENCE_TRANSIENT)    {        PEG_METHOD_EXIT ();        return true;    }    else    {        PEG_METHOD_EXIT ();        return false;    }}void SubscriptionRepository::getFilterProperties (    const CIMInstance & subscription,    String & query,    CIMNamespaceName & sourceNameSpace,    String & queryLanguage){    PEG_METHOD_ENTER (TRC_INDICATION_SERVICE,        "SubscriptionRepository::getFilterProperties");    CIMValue filterValue;    CIMObjectPath filterReference;    CIMInstance filterInstance;    CIMNamespaceName nameSpaceName;    filterValue = subscription.getProperty (subscription.findProperty        (PEGASUS_PROPERTYNAME_FILTER)).getValue ();    filterValue.get (filterReference);    //    //  Get filter namespace - if not set in Filter reference property value,    //  namespace is the namespace of the subscription    //    nameSpaceName = filterReference.getNameSpace ();    if (nameSpaceName.isNull ())    {        nameSpaceName = subscription.getPath ().getNameSpace ();    }    try    {        filterInstance = _repository->getInstance (nameSpaceName,            filterReference);    }    catch (const Exception & exception)    {        PEG_TRACE_STRING (TRC_DISCARDED_DATA, Tracer::LEVEL2,            "Exception caught trying to get Filter instance (" +            filterReference.toString () + "): " +            exception.getMessage ());        PEG_METHOD_EXIT ();        throw;    }    query = filterInstance.getProperty (filterInstance.findProperty        (PEGASUS_PROPERTYNAME_QUERY)).getValue ().toString ();    sourceNameSpace = filterInstance.getProperty (filterInstance.findProperty        (_PROPERTY_SOURCENAMESPACE)).getValue ().toString ();    queryLanguage = filterInstance.getProperty        (filterInstance.findProperty (PEGASUS_PROPERTYNAME_QUERYLANGUAGE)).        getValue ().toString ();    PEG_METHOD_EXIT ();}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -