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

📄 indicationservice.cpp

📁 Pegasus is an open-source implementationof the DMTF CIM and WBEM standards. It is designed to be por
💻 CPP
📖 第 1 页 / 共 5 页
字号:
//%2006//////////////////////////////////////////////////////////////////////////// Copyright (c) 2000, 2001, 2002 BMC Software; Hewlett-Packard Development// Company, L.P.; IBM Corp.; The Open Group; Tivoli Systems.// Copyright (c) 2003 BMC Software; Hewlett-Packard Development Company, L.P.;// IBM Corp.; EMC Corporation, The Open Group.// Copyright (c) 2004 BMC Software; Hewlett-Packard Development Company, L.P.;// IBM Corp.; EMC Corporation; VERITAS Software Corporation; The Open Group.// Copyright (c) 2005 Hewlett-Packard Development Company, L.P.; IBM Corp.;// EMC Corporation; VERITAS Software Corporation; The Open Group.// Copyright (c) 2006 Hewlett-Packard Development Company, L.P.; IBM Corp.;// EMC Corporation; Symantec Corporation; The Open Group.//// Permission is hereby granted, free of charge, to any person obtaining a copy// of this software and associated documentation files (the "Software"), to// deal in the Software without restriction, including without limitation the// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or// sell copies of the Software, and to permit persons to whom the Software is// furnished to do so, subject to the following conditions:// // THE ABOVE COPYRIGHT NOTICE AND THIS PERMISSION NOTICE SHALL BE INCLUDED IN// ALL COPIES OR SUBSTANTIAL PORTIONS OF THE SOFTWARE. THE SOFTWARE IS PROVIDED// "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT// LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR// PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT// HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN// ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.////==============================================================================////%/////////////////////////////////////////////////////////////////////////////#include <Pegasus/Common/Config.h>#include <Pegasus/Common/Constants.h>#include <Pegasus/Common/CIMInstance.h>#include <Pegasus/Common/ArrayInternal.h>#include <Pegasus/Common/CIMDateTime.h>#include <Pegasus/Common/CIMProperty.h>#include <Pegasus/Common/MessageQueue.h>#ifdef PEGASUS_INDICATION_PERFINST#include <Pegasus/Common/Stopwatch.h>#endif#include <Pegasus/Common/System.h>#include <Pegasus/Common/Tracer.h>#include <Pegasus/Common/XmlWriter.h>#include <Pegasus/Common/PegasusVersion.h>#include <Pegasus/Common/AcceptLanguageList.h>#include <Pegasus/Common/ContentLanguageList.h>#include <Pegasus/Common/LanguageParser.h>#include <Pegasus/Common/OperationContextInternal.h>// l10n#include <Pegasus/Common/MessageLoader.h>#include <Pegasus/Common/String.h>#include <Pegasus/Common/IndicationFormatter.h>#include <Pegasus/Server/ProviderRegistrationManager/ProviderRegistrationManager.h>#include <Pegasus/Query/QueryExpression/QueryExpression.h>#include <Pegasus/Query/QueryCommon/QueryException.h>#include <Pegasus/Repository/RepositoryQueryContext.h>#include "IndicationConstants.h"#include "IndicationMessageConstants.h"#include "SubscriptionRepository.h"#include "SubscriptionTable.h"#include "IndicationService.h"PEGASUS_USING_STD;PEGASUS_NAMESPACE_BEGIN// ATTN-RK-20020730: Temporary hack to fix Windows buildBoolean ContainsCIMName(const Array<CIMName>& a, const CIMName& x){    Uint32 n = a.size();    for (Uint32 i = 0; i < n; i++)    {        if (a[i].equal(x))            return true;    }    return false;}Mutex IndicationService::_mutex;IndicationService::IndicationService (    CIMRepository * repository,    ProviderRegistrationManager * providerRegManager)    : MessageQueueService (PEGASUS_QUEUENAME_INDICATIONSERVICE,            MessageQueue::getNextQueueId ()),      _providerRegManager (providerRegManager),      _cimRepository(repository){    _enableSubscriptionsForNonprivilegedUsers = false;    _authenticationEnabled = true;    try    {        // Determine the value for the configuration parameter        // enableSubscriptionsForNonprivilegedUsers        ConfigManager* configManager = ConfigManager::getInstance();        if (ConfigManager::parseBooleanValue(            configManager->getCurrentValue("enableAuthentication")))        {            _enableSubscriptionsForNonprivilegedUsers =                ConfigManager::parseBooleanValue(                    configManager->getCurrentValue(                        "enableSubscriptionsForNonprivilegedUsers"));        }        else        {            _authenticationEnabled = false;            // Authentication needs to be enabled to perform authorization            // tests.            _enableSubscriptionsForNonprivilegedUsers = true;        }     }     catch (...)     {        // If there is an error reading the configuration file then        // the value of _enableSubscriptionsForNonprivilegedUsers will        // default to false (i.e., the more restrictive security        // setting.        PEG_TRACE_STRING (TRC_INDICATION_SERVICE, Tracer::LEVEL4,           "Failure attempting to read configuration parameters during initialization.");     }    Tracer::trace (TRC_INDICATION_SERVICE, Tracer::LEVEL4,        "Value of _enableSubscriptionsForNonprivilegedUsers is %d",        _enableSubscriptionsForNonprivilegedUsers);    try    {        //        //  Create Subscription Repository        //        _subscriptionRepository = new SubscriptionRepository (repository);        //        //  Create Subscription Table        //        _subscriptionTable = new SubscriptionTable (_subscriptionRepository);        // Initialize the Indication Service        _initialize ();    }    catch (Exception & e)    {        PEG_TRACE_STRING (TRC_INDICATION_SERVICE_INTERNAL, Tracer::LEVEL2,           "Exception caught in attempting to initialize Indication Service: " +            e.getMessage ());    }}IndicationService::~IndicationService (void){    delete _subscriptionTable;    delete _subscriptionRepository;}void IndicationService::_handle_async_request(AsyncRequest *req){    if ( req->getType() == async_messages::CIMSERVICE_STOP )    {        req->op->processing();        //        //  Call _terminate        //        _terminate ();        handle_CimServiceStop(static_cast<CimServiceStop *>(req));    }    else if (req->getType () == async_messages::CIMSERVICE_START)    {        req->op->processing ();        handle_CimServiceStart (static_cast <CimServiceStart *> (req));    }    else if ( req->getType() == async_messages::ASYNC_LEGACY_OP_START )    {       try       {          req->op->processing();          Message *legacy =              (static_cast<AsyncLegacyOperationStart *>(req)->get_action());          legacy->put_async(req);          handleEnqueue(legacy);       }       catch(Exception & )       {           PEG_TRACE_STRING(TRC_INDICATION_SERVICE, Tracer::LEVEL3,               "Caught Exception in IndicationService while handling a wrapped legacy  message ");               _make_response(req, async_results::CIM_NAK );       }        return;    }    else        MessageQueueService::_handle_async_request (req);}void IndicationService::handleEnqueue(Message* message){#ifdef PEGASUS_INDICATION_PERFINST    Stopwatch stopWatch;    stopWatch.start();#endif// l10n    // Set the client's requested language into this service thread.    // This will allow functions in this service to return messages    // in the correct language.    CIMMessage * msg = dynamic_cast<CIMMessage *>(message);    if (msg != NULL)    {        if (msg->thread_changed())        {            AcceptLanguageList *langs =  new AcceptLanguageList                (((AcceptLanguageListContainer)msg->operationContext.get                (AcceptLanguageListContainer::NAME)).getLanguages());            Thread::setLanguages(langs);        }    }    else    {        Thread::clearLanguages();    }    switch(message->getType())    {        case CIM_GET_INSTANCE_REQUEST_MESSAGE:            try            {                _handleGetInstanceRequest(message);            }            catch( ... )            {            ;            }            break;        case CIM_ENUMERATE_INSTANCES_REQUEST_MESSAGE:            try            {                _handleEnumerateInstancesRequest(message);            }            catch( ... )            {            ;            }            break;        case CIM_ENUMERATE_INSTANCE_NAMES_REQUEST_MESSAGE:            try            {                _handleEnumerateInstanceNamesRequest(message);            }            catch( ... )            {            ;            }            break;        case CIM_CREATE_INSTANCE_REQUEST_MESSAGE:            try            {                _handleCreateInstanceRequest(message);            }            catch( ... )            {            ;            }            break;        case CIM_MODIFY_INSTANCE_REQUEST_MESSAGE:            try            {                _handleModifyInstanceRequest(message);            }            catch( ... )            {            ;            }            break;        case CIM_DELETE_INSTANCE_REQUEST_MESSAGE:            try            {                _handleDeleteInstanceRequest(message);            }            catch( ... )            {            ;            }            break;        case CIM_PROCESS_INDICATION_REQUEST_MESSAGE:            try            {                _handleProcessIndicationRequest(message);            }            catch( ... )            {            ;            }            break;        case CIM_NOTIFY_PROVIDER_REGISTRATION_REQUEST_MESSAGE:            try            {                _handleNotifyProviderRegistrationRequest(message);            }            catch( ... )            {            ;            }            break;        case CIM_NOTIFY_PROVIDER_TERMINATION_REQUEST_MESSAGE:            try            {                _handleNotifyProviderTerminationRequest(message);            }            catch( ... )            {            ;            }            break;      case CIM_NOTIFY_PROVIDER_ENABLE_REQUEST_MESSAGE:         try         {             _handleNotifyProviderEnableRequest (message);         }         catch (...)         {             ;         }         break;      case CIM_NOTIFY_PROVIDER_FAIL_REQUEST_MESSAGE:         try         {             _handleNotifyProviderFailRequest (message);         }         catch (...)         {             ;         }         break;      default:

⌨️ 快捷键说明

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