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

  1 martin 1.30 //%LICENSE////////////////////////////////////////////////////////////////
  2 martin 1.31 //
  3 martin 1.30 // 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.31 //
 10 martin 1.30 // 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.31 //
 17 martin 1.30 // The above copyright notice and this permission notice shall be included
 18             // in all copies or substantial portions of the Software.
 19 martin 1.31 //
 20 martin 1.30 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
 21 martin 1.31 // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
 22 martin 1.30 // 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.31 //
 28 martin 1.30 //////////////////////////////////////////////////////////////////////////
 29 mike   1.2  //
 30             //%/////////////////////////////////////////////////////////////////////////////
 31             
 32             #include <Pegasus/Common/Config.h>
 33             #include <cctype>
 34             #include <cstdio>
 35 kumpf  1.9  #include <Pegasus/Common/Constants.h>
 36 mike   1.2  #include <Pegasus/Common/XmlParser.h>
 37             #include <Pegasus/Common/XmlReader.h>
 38             #include <Pegasus/Common/XmlWriter.h>
 39             #include <Pegasus/Common/HTTPMessage.h>
 40             #include <Pegasus/Common/Logger.h>
 41 kumpf  1.15 #include <Pegasus/Common/Tracer.h>
 42 kumpf  1.22 #include <Pegasus/Common/ContentLanguageList.h>
 43 mike   1.2  #include "CIMExportResponseEncoder.h"
 44             
 45             PEGASUS_USING_STD;
 46             
 47             PEGASUS_NAMESPACE_BEGIN
 48             
 49             CIMExportResponseEncoder::CIMExportResponseEncoder()
 50 kumpf  1.28     : Base(PEGASUS_QUEUENAME_EXPORTRESPENCODER)
 51 mike   1.2  {
 52             }
 53             
 54             CIMExportResponseEncoder::~CIMExportResponseEncoder()
 55             {
 56             }
 57             
 58             void CIMExportResponseEncoder::sendResponse(
 59 kumpf  1.28     Uint32 queueId,
 60                 Buffer& message,
 61                 Boolean closeConnect)
 62             {
 63                 MessageQueue* queue = MessageQueue::lookup(queueId);
 64             
 65                 if (queue)
 66                 {
 67                     HTTPMessage* httpMessage = new HTTPMessage(message);
 68             
 69                     httpMessage->setCloseConnect(closeConnect);
 70             
 71                     queue->enqueue(httpMessage);
 72                 }
 73                 else
 74                 {
 75 marek  1.29         PEG_TRACE((TRC_DISCARDED_DATA, Tracer::LEVEL1,
 76 kumpf  1.28             "Invalid queueId = %i, response not sent.", queueId));
 77                 }
 78 mike   1.2  }
 79             
 80 kumpf  1.6  void CIMExportResponseEncoder::sendEMethodError(
 81 kumpf  1.28     Uint32 queueId,
 82 j.alex 1.19     HttpMethod httpMethod,
 83                 const String& messageId,
 84                 const String& eMethodName,
 85                 const CIMException& cimException,
 86 kumpf  1.28     Boolean closeConnect)
 87 mday   1.5  {
 88 mike   1.20     Buffer message;
 89 kumpf  1.7      message = XmlWriter::formatSimpleEMethodErrorRspMessage(
 90                     eMethodName,
 91                     messageId,
 92 kumpf  1.12         httpMethod,
 93 kumpf  1.8          cimException);
 94 kumpf  1.6  
 95 j.alex 1.19     sendResponse(queueId, message,closeConnect);
 96 mike   1.2  }
 97             
 98 kumpf  1.6  void CIMExportResponseEncoder::sendEMethodError(
 99 j.alex 1.19     CIMResponseMessage* response,
100                 const String& cimMethodName,
101                 Boolean closeConnect)
102 mike   1.2  {
103 kumpf  1.28     Uint32 queueId = response->queueIds.top();
104                 response->queueIds.pop();
105 mike   1.2  
106 kumpf  1.28     sendEMethodError(
107                     queueId,
108                     response->getHttpMethod(),
109                     response->messageId,
110                     cimMethodName,
111                     response->cimException,
112                     closeConnect);
113 mike   1.2  }
114             
115 mday   1.5  void CIMExportResponseEncoder::handleEnqueue(Message *message)
116 mike   1.2  {
117 kumpf  1.28     PEGASUS_ASSERT(message != 0);
118 j.alex 1.19 
119 kumpf  1.28     switch (message->getType())
120                 {
121                     case CIM_EXPORT_INDICATION_RESPONSE_MESSAGE:
122                         encodeExportIndicationResponse(
123                             (CIMExportIndicationResponseMessage*)message);
124                         break;
125 carolann.graves 1.24 
126                              default:
127                                  PEGASUS_ASSERT(0);
128                                  break;
129 kumpf           1.28     }
130                      
131                          delete message;
132 mday            1.5  }
133 mike            1.2  
134                      
135 mday            1.5  void CIMExportResponseEncoder::handleEnqueue()
136                      {
137 kumpf           1.28     Message* message = dequeue();
138                          if (message)
139                              handleEnqueue(message);
140 mike            1.2  }
141                      
142                      void CIMExportResponseEncoder::encodeExportIndicationResponse(
143 j.alex          1.19     CIMExportIndicationResponseMessage* response)
144 mike            1.2  {
145 kumpf           1.28     Boolean closeConnect = response->getCloseConnect();
146                          PEG_TRACE((
147                              TRC_HTTP,
148 marek           1.29         Tracer::LEVEL4,
149 kumpf           1.28         "CIMExportResponseEncoder::handleEnqueue() - "
150                                  "response>getCloseConnect() returned %d",
151                              response->getCloseConnect()));
152                      
153                          if (response->cimException.getCode() != CIM_ERR_SUCCESS)
154                          {
155                              sendEMethodError(response, "ExportIndication",closeConnect);
156                              return;
157                          }
158                      
159                      
160                          Buffer body;
161                      
162                          // Note: Content-Language will not be set in the response.
163                          // Export responses are sent in the default language of the
164                          // ExportServer.
165                          Buffer message = XmlWriter::formatSimpleEMethodRspMessage(
166                             CIMName ("ExportIndication"), response->messageId,
167                             response->getHttpMethod(),
168                             ContentLanguageList(),
169                             body);
170 j.alex          1.19 
171 kumpf           1.28     sendResponse(response->queueIds.top(), message,closeConnect);
172 mike            1.2  }
173                      
174                      PEGASUS_NAMESPACE_END

No CVS admin address has been configured
Powered by
ViewCVS 0.9.2