1 martin 1.37 //%LICENSE////////////////////////////////////////////////////////////////
|
2 martin 1.38 //
|
3 martin 1.37 // Licensed to The Open Group (TOG) under one or more contributor license
4 // agreements. Refer to the OpenPegasusNOTICE.txt file distributed with
5 // this work for additional information regarding copyright ownership.
6 // Each contributor licenses this file to you under the OpenPegasus Open
7 // Source License; you may not use this file except in compliance with the
8 // License.
|
9 martin 1.38 //
|
10 martin 1.37 // Permission is hereby granted, free of charge, to any person obtaining a
11 // copy of this software and associated documentation files (the "Software"),
12 // to deal in the Software without restriction, including without limitation
13 // the rights to use, copy, modify, merge, publish, distribute, sublicense,
14 // and/or sell copies of the Software, and to permit persons to whom the
15 // Software is furnished to do so, subject to the following conditions:
|
16 martin 1.38 //
|
17 martin 1.37 // The above copyright notice and this permission notice shall be included
18 // in all copies or substantial portions of the Software.
|
19 martin 1.38 //
|
20 martin 1.37 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
21 martin 1.38 // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
22 martin 1.37 // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
23 // IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
24 // CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
25 // TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
26 // SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
27 martin 1.38 //
|
28 martin 1.37 //////////////////////////////////////////////////////////////////////////
|
29 schuur 1.1 //
30 //%/////////////////////////////////////////////////////////////////////////////
31
32 #include "WQLOperationRequestDispatcher.h"
|
33 a.arora 1.2 #include <Pegasus/Common/AutoPtr.h>
|
34 kumpf 1.20 #include <Pegasus/Common/StatisticalData.h>
|
35 schuur 1.1
36 PEGASUS_NAMESPACE_BEGIN
37
38 PEGASUS_USING_STD;
39
40 void WQLOperationRequestDispatcher::applyQueryToEnumeration(
|
41 kumpf 1.24 CIMResponseMessage* msg,
42 QueryExpressionRep* query)
|
43 schuur 1.1 {
|
44 kumpf 1.24 CIMEnumerateInstancesResponseMessage* enr =
45 (CIMEnumerateInstancesResponseMessage*) msg;
46 WQLSelectStatement* qs = ((WQLQueryExpressionRep*)query)->_stmt;
|
47 schuur 1.1
|
48 karl 1.51 // get instances from the response data converting them to
49 // C++ instance format for the evaluator
|
50 thilo.boehm 1.42 Array<CIMInstance>& a = enr->getResponseData().getInstances();
|
51 mike 1.36
|
52 karl 1.51 // Remove any instances from this array that do not match
|
53 mike 1.36 for (int i = a.size() - 1; i >= 0; i--)
|
54 kumpf 1.24 {
|
55 mike 1.36 WQLInstancePropertySource ips(a[i]);
|
56 kumpf 1.24 try
57 {
58 if (qs->evaluateWhereClause(&ips))
59 {
60 //
61 // Specify that missing requested project properties are
62 // allowed to be consistent with clarification from DMTF
63 //
|
64 mike 1.36 qs->applyProjection(a[i], true);
|
65 kumpf 1.24 }
|
66 karl 1.49 else
67 {
68 a.remove(i);
69 }
|
70 kumpf 1.24 }
71 catch (...)
72 {
|
73 mike 1.36 a.remove(i);
|
74 kumpf 1.24 }
75 }
|
76 karl 1.52 // Reset the ResponseData size since we may have modified it.
77 enr->getResponseData().setSize();
|
78 schuur 1.1 }
79
|
80 karl 1.52 bool WQLOperationRequestDispatcher::handleQueryRequest(
81 CIMExecQueryRequestMessage* request,
82 CIMException& cimException,
83 EnumerationContext* enumerationContext)
|
84 schuur 1.1 {
|
85 kumpf 1.21 PEG_METHOD_ENTER(TRC_DISPATCHER,
|
86 kumpf 1.28 "WQLOperationRequestDispatcher::handleQueryRequest");
|
87 kumpf 1.21
|
88 kumpf 1.24 Boolean exception=false;
89 AutoPtr<WQLSelectStatement> selectStatement(new WQLSelectStatement());
|
90 karl 1.52
|
91 kumpf 1.24 AutoPtr<WQLQueryExpressionRep> qx;
|
92 karl 1.52
|
93 kumpf 1.24 CIMName className;
94
95 if (request->queryLanguage!="WQL")
96 {
97 cimException = PEGASUS_CIM_EXCEPTION(
98 CIM_ERR_QUERY_LANGUAGE_NOT_SUPPORTED, request->queryLanguage);
99 exception=true;
100 }
101 else
102 {
103 try
104 {
105 WQLParser::parse(request->query, *selectStatement.get());
106 className = selectStatement->getClassName();
107 qx.reset(new WQLQueryExpressionRep("WQL", selectStatement.get()));
108 selectStatement.release();
109 }
110 catch (ParseError&)
111 {
112 cimException =
113 PEGASUS_CIM_EXCEPTION(CIM_ERR_INVALID_QUERY, request->query);
114 kumpf 1.24 exception=true;
115 }
116 catch (MissingNullTerminator&)
117 {
118 cimException =
119 PEGASUS_CIM_EXCEPTION(CIM_ERR_INVALID_QUERY, request->query);
120 exception = true;
121 }
122
123 if (exception == false)
124 {
|
125 kumpf 1.27 if (!_checkExistenceOfClass(request->nameSpace, className))
126 {
127 cimException = PEGASUS_CIM_EXCEPTION(
128 CIM_ERR_INVALID_CLASS, className.getString());
|
129 kumpf 1.24 exception = true;
|
130 kumpf 1.27 }
|
131 kumpf 1.24 }
132 }
|
133 schuur 1.1
|
134 kumpf 1.21 if (exception)
135 {
136 PEG_METHOD_EXIT();
|
137 karl 1.52 return false;
|
138 schuur 1.1 }
139
|
140 karl 1.52 bool rtn = handleQueryRequestCommon(request,
141 cimException,
142 enumerationContext,
143 "DMTF:CQL",
|
144 karl 1.50 className,
|
145 karl 1.52 qx.release());
|
146 schuur 1.1
|
147 kumpf 1.24 PEG_METHOD_EXIT();
|
148 karl 1.52 return rtn;
|
149 schuur 1.1 }
150
151 PEGASUS_NAMESPACE_END
|