(file) Return to CQLOperationRequestDispatcher.cpp CVS log (file) (dir) Up to [Pegasus] / pegasus / src / Pegasus / Server

  1 karl  1.6.2.2 //%LICENSE////////////////////////////////////////////////////////////////
  2               //
  3               // 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               //
 10               // 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               //
 17               // The above copyright notice and this permission notice shall be included
 18               // in all copies or substantial portions of the Software.
 19               //
 20               // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
 21               // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
 22 karl  1.6.2.2 // 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               //
 28               //%////////////////////////////////////////////////////////////////////////////
 29               
 30               
 31               #include "CQLOperationRequestDispatcher.h"
 32               
 33               #include <Pegasus/Common/AutoPtr.h>
 34               #include <Pegasus/Common/QueryExpressionRep.h>
 35               #include <Pegasus/Common/StatisticalData.h>
 36               #include <Pegasus/Provider/CIMOMHandleQueryContext.h>
 37 karl  1.6.2.5 #include <Pegasus/Server/EnumerationContext.h>
 38 karl  1.6.2.2 
 39               PEGASUS_NAMESPACE_BEGIN
 40               
 41               PEGASUS_USING_STD;
 42               
 43               void CQLOperationRequestDispatcher::applyQueryToEnumeration(
 44                   CIMResponseMessage* msg,
 45                   QueryExpressionRep* query)
 46               {
 47                   PEG_METHOD_ENTER(TRC_DISPATCHER,
 48                       "CQLOperationRequestDispatcher::applyQueryToEnumeration");
 49               
 50                   CIMEnumerateInstancesResponseMessage* enr =
 51                       (CIMEnumerateInstancesResponseMessage*) msg;
 52                   CQLSelectStatement* qs = ((CQLQueryExpressionRep*)query)->_stmt;
 53               
 54 karl  1.6.2.6     // Get instances in the response data, converting all of them
 55 karl  1.6.2.7     // to C++ Instance format for the evaluator
 56 karl  1.6.2.2     Array<CIMInstance>& a = enr->getResponseData().getInstances();
 57               
 58 karl  1.6.2.6     // Remove any instances from this array that do not match
 59 karl  1.6.2.2     for (int i = a.size() - 1; i >= 0; i--)
 60                   {
 61                       try
 62                       {
 63                           if (qs->evaluate(a[i]))
 64                           {
 65                               //
 66                               // Specify that missing requested project properties are
 67                               // allowed to be consistent with clarification from DMTF
 68                               qs->applyProjection(a[i], true);
 69                           }
 70                           else
 71                           {
 72                               a.remove(i);
 73                           }
 74                       }
 75                       catch (...)
 76                       {
 77                           a.remove(i);
 78                       }
 79                   }
 80 karl  1.6.2.6 
 81                   // Reset the CIMResponseData size since we may have modified it.
 82                   enr->getResponseData().setSize();
 83 karl  1.6.2.2     PEG_METHOD_EXIT();
 84               }
 85               
 86 karl  1.6.2.10 bool CQLOperationRequestDispatcher::handleQueryRequest(
 87 karl  1.6.2.5      CIMExecQueryRequestMessage* request,
 88 karl  1.6.2.10     CIMException& cimException,
 89 karl  1.6.2.9      EnumerationContext* enumerationContext)
 90 karl  1.6.2.2  {
 91                    PEG_METHOD_ENTER(TRC_DISPATCHER,
 92                        "CQLOperationRequestDispatcher::handleQueryRequest");
 93                    Boolean exception=false;
 94                
 95                    CIMOMHandle _ch;
 96                    CIMOMHandleQueryContext _queryOrig(request->nameSpace,_ch);
 97                
 98                    AutoPtr<CQLSelectStatement> selectStatement(
 99                        new CQLSelectStatement(request->queryLanguage,
100                            request->query,
101                            _queryOrig));
102                
103                    AutoPtr<CQLQueryExpressionRep> qx;
104                    CIMName className;
105                
106                    if (request->queryLanguage != "DMTF:CQL")
107                    {
108                        cimException = PEGASUS_CIM_EXCEPTION(
109                            CIM_ERR_QUERY_LANGUAGE_NOT_SUPPORTED, request->queryLanguage);
110                        exception=true;
111 karl  1.6.2.2      }
112                    else
113                    {
114                        try
115                        {
116                            CQLParser::parse(request->query, *selectStatement.get());
117                
118                            Array<CIMObjectPath> classPath =
119                                selectStatement->getClassPathList();
120                            className = classPath[0].getClassName();
121                            qx.reset(
122                                new CQLQueryExpressionRep("DMTF:CQL", selectStatement.get()));
123                            selectStatement.release();
124                        }
125                        catch (ParseError&)
126                        {
127                            cimException =
128                                PEGASUS_CIM_EXCEPTION(CIM_ERR_INVALID_QUERY, request->query);
129                            exception=true;
130                        }
131                        catch (MissingNullTerminator&)
132 karl  1.6.2.2          {
133                            cimException =
134                                PEGASUS_CIM_EXCEPTION(CIM_ERR_INVALID_QUERY, request->query);
135                            exception = true;
136                        }
137                
138                        if (exception == false)
139                        {
140                            if (!_checkExistenceOfClass(request->nameSpace, className))
141                            {
142                                cimException = PEGASUS_CIM_EXCEPTION(
143                                    CIM_ERR_INVALID_CLASS, className.getString());
144                                exception = true;
145                            }
146                        }
147                    }
148                
149                    if (exception)
150                    {
151                        PEG_METHOD_EXIT();
152 karl  1.6.2.10         return false;
153 karl  1.6.2.2      }
154                
155 karl  1.6.2.11     bool rtn = handleQueryRequestCommon(request,
156                        cimException,
157                        enumerationContext,
158                        "DMTF:CQL",
159 karl  1.6.2.4          className,
160 karl  1.6.2.11         qx.release());
161 karl  1.6.2.2  
162                    PEG_METHOD_EXIT();
163 karl  1.6.2.11     return rtn;
164 karl  1.6.2.2  }
165                
166                PEGASUS_NAMESPACE_END

No CVS admin address has been configured
Powered by
ViewCVS 0.9.2