📄 wqloperationrequestdispatcher.cpp
字号:
//%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 "WQLOperationRequestDispatcher.h"#include <Pegasus/Common/AutoPtr.h>#include <Pegasus/Common/StatisticalData.h>PEGASUS_NAMESPACE_BEGINPEGASUS_USING_STD;void WQLOperationRequestDispatcher::applyQueryToEnumeration( CIMResponseMessage* msg, QueryExpressionRep* query){ CIMEnumerateInstancesResponseMessage* enr = (CIMEnumerateInstancesResponseMessage*) msg; WQLSelectStatement* qs = ((WQLQueryExpressionRep*)query)->_stmt; for (int i = enr->cimNamedInstances.size() - 1; i >= 0; i--) { WQLInstancePropertySource ips(enr->cimNamedInstances[i]); try { if (qs->evaluateWhereClause(&ips)) { // // Specify that missing requested project properties are // allowed to be consistent with clarification from DMTF // qs->applyProjection(enr->cimNamedInstances[i], true); } else enr->cimNamedInstances.remove(i); } catch (...) { enr->cimNamedInstances.remove(i); } }}void WQLOperationRequestDispatcher::handleQueryResponseAggregation( OperationAggregate* poA){ PEG_METHOD_ENTER(TRC_DISPATCHER, "CIMOperationRequestDispatcher::handleExecQueryResponse"); Uint32 numberResponses = poA->numberResponses(); Logger::put(Logger::STANDARD_LOG, System::CIMSERVER, Logger::TRACE, "CIMOperationRequestDispatcher::ExecQuery Response - " "Name Space: $0 Class name: $1 Response Count: $2", poA->_nameSpace.getString(), poA->_className.getString(), numberResponses); if (numberResponses == 0) return; CIMResponseMessage* response = poA->getResponse(0); CIMExecQueryResponseMessage* toResponse = 0; Uint32 startIndex = 0; Uint32 endIndex = numberResponses - 1; Boolean manyResponses = true; if (response->getType() == CIM_ENUMERATE_INSTANCES_RESPONSE_MESSAGE) { CIMRequestMessage* request = poA->getRequest(); AutoPtr<CIMExecQueryResponseMessage> query( new CIMExecQueryResponseMessage( request->messageId, CIMException(), request->queueIds.copyAndPop(), Array<CIMObject>())); query->syncAttributes(request); toResponse = query.release(); } else { toResponse = (CIMExecQueryResponseMessage*) response; manyResponses = false; } // Work backward and delete each response off the end of the array for (Uint32 i = endIndex; i >= startIndex; i--) { if (manyResponses) response = poA->getResponse(i); if (response->getType() == CIM_ENUMERATE_INSTANCES_RESPONSE_MESSAGE) { // convert enumerate instances responses to exec query responses applyQueryToEnumeration(response, poA->_query); CIMEnumerateInstancesResponseMessage* fromResponse = (CIMEnumerateInstancesResponseMessage*) response; CIMClass cimClass; Boolean clsRead=false; for (Uint32 j = 0, m = fromResponse->cimNamedInstances.size(); j < m; j++) { CIMObject co=CIMObject(fromResponse->cimNamedInstances[j]); CIMObjectPath op=co.getPath(); const Array<CIMKeyBinding>& kbs=op.getKeyBindings(); if (kbs.size() == 0) { // no path set why ? if (clsRead == false) { cimClass = _repository->getClass( poA->_nameSpace, op.getClassName(), false,true,false, CIMPropertyList()); clsRead=true; } op = fromResponse->cimNamedInstances[j].buildPath(cimClass); } op.setNameSpace(poA->_nameSpace); op.setHost(System::getHostName()); co.setPath(op); if (manyResponses) toResponse->cimObjects.append(co); } } else { CIMExecQueryResponseMessage* fromResponse = (CIMExecQueryResponseMessage*) response; CIMClass cimClass; Boolean clsRead=false; for (Uint32 j = 0, m = fromResponse->cimObjects.size(); j < m; j++) { CIMObject co=fromResponse->cimObjects[j]; CIMObjectPath op=co.getPath(); const Array<CIMKeyBinding>& kbs=op.getKeyBindings(); if (kbs.size()==0) { // no path set why ? if (clsRead==false) { cimClass = _repository->getClass( poA->_nameSpace,op.getClassName(), false,true,false, CIMPropertyList()); clsRead=true; } op = CIMInstance(fromResponse->cimObjects[j]).buildPath( cimClass); } op.setNameSpace(poA->_nameSpace); op.setHost(System::getHostName()); co.setPath(op); if (manyResponses) toResponse->cimObjects.append(co); } } if (manyResponses) poA->deleteResponse(i); if (i == 0) break; } // for all responses in response list // if we started with an enumerateInstances repsonse, then add it to overall if ((startIndex == 0) && manyResponses) poA->appendResponse(toResponse); PEG_METHOD_EXIT();}void WQLOperationRequestDispatcher::handleQueryRequest( CIMExecQueryRequestMessage* request){ PEG_METHOD_ENTER(TRC_DISPATCHER, "CIMOperationRequestDispatcher::handleExecQueryRequest"); Boolean exception=false; AutoPtr<WQLSelectStatement> selectStatement(new WQLSelectStatement()); AutoPtr<WQLQueryExpressionRep> qx; CIMException cimException; CIMName className; if (request->queryLanguage!="WQL") { cimException = PEGASUS_CIM_EXCEPTION( CIM_ERR_QUERY_LANGUAGE_NOT_SUPPORTED, request->queryLanguage); exception=true; } else { try { WQLParser::parse(request->query, *selectStatement.get()); className = selectStatement->getClassName(); qx.reset(new WQLQueryExpressionRep("WQL", selectStatement.get())); selectStatement.release(); } catch (ParseError&) { cimException = PEGASUS_CIM_EXCEPTION(CIM_ERR_INVALID_QUERY, request->query); exception=true; } catch (MissingNullTerminator&) { cimException = PEGASUS_CIM_EXCEPTION(CIM_ERR_INVALID_QUERY, request->query); exception = true; } if (exception == false) { _checkExistenceOfClass( request->nameSpace, className, cimException); if (cimException.getCode() != CIM_ERR_SUCCESS) exception = true; } } if (exception) {
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -