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

  1 karl  1.23 //%2006////////////////////////////////////////////////////////////////////////
  2 mike  1.2  //
  3 karl  1.16 // Copyright (c) 2000, 2001, 2002 BMC Software; Hewlett-Packard Development
  4            // Company, L.P.; IBM Corp.; The Open Group; Tivoli Systems.
  5            // Copyright (c) 2003 BMC Software; Hewlett-Packard Development Company, L.P.;
  6 karl  1.14 // IBM Corp.; EMC Corporation, The Open Group.
  7 karl  1.16 // Copyright (c) 2004 BMC Software; Hewlett-Packard Development Company, L.P.;
  8            // IBM Corp.; EMC Corporation; VERITAS Software Corporation; The Open Group.
  9 karl  1.18 // Copyright (c) 2005 Hewlett-Packard Development Company, L.P.; IBM Corp.;
 10            // EMC Corporation; VERITAS Software Corporation; The Open Group.
 11 karl  1.23 // Copyright (c) 2006 Hewlett-Packard Development Company, L.P.; IBM Corp.;
 12            // EMC Corporation; Symantec Corporation; The Open Group.
 13 mike  1.2  //
 14            // Permission is hereby granted, free of charge, to any person obtaining a copy
 15 kumpf 1.10 // of this software and associated documentation files (the "Software"), to
 16            // deal in the Software without restriction, including without limitation the
 17            // rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
 18 mike  1.2  // sell copies of the Software, and to permit persons to whom the Software is
 19            // furnished to do so, subject to the following conditions:
 20            // 
 21 kumpf 1.10 // THE ABOVE COPYRIGHT NOTICE AND THIS PERMISSION NOTICE SHALL BE INCLUDED IN
 22 mike  1.2  // ALL COPIES OR SUBSTANTIAL PORTIONS OF THE SOFTWARE. THE SOFTWARE IS PROVIDED
 23            // "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT
 24 kumpf 1.10 // LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
 25            // PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
 26            // HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
 27 mike  1.2  // ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
 28            // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 29            //
 30            //==============================================================================
 31            //
 32            //%/////////////////////////////////////////////////////////////////////////////
 33            
 34            #include <Pegasus/Common/Config.h>
 35            #include <cctype>
 36            #include <cstdio>
 37 kumpf 1.9  #include <Pegasus/Common/Constants.h>
 38 mike  1.2  #include <Pegasus/Common/XmlParser.h>
 39            #include <Pegasus/Common/XmlReader.h>
 40            #include <Pegasus/Common/XmlWriter.h>
 41            #include <Pegasus/Common/HTTPMessage.h>
 42            #include <Pegasus/Common/Logger.h>
 43 kumpf 1.15 #include <Pegasus/Common/Tracer.h>
 44 kumpf 1.22 #include <Pegasus/Common/ContentLanguageList.h>
 45 mike  1.2  #include "CIMExportResponseEncoder.h"
 46            
 47            PEGASUS_USING_STD;
 48            
 49            PEGASUS_NAMESPACE_BEGIN
 50            
 51            CIMExportResponseEncoder::CIMExportResponseEncoder()
 52 kumpf 1.9     : Base(PEGASUS_QUEUENAME_EXPORTRESPENCODER)
 53 mike  1.2  {
 54            
 55            }
 56            
 57            CIMExportResponseEncoder::~CIMExportResponseEncoder()
 58            {
 59            
 60            }
 61            
 62            void CIMExportResponseEncoder::sendResponse(
 63 mday  1.5     Uint32 queueId, 
 64 mike  1.20    Buffer& message,
 65 j.alex 1.19    Boolean closeConnect)
 66 mike   1.2  {
 67 mday   1.5     MessageQueue* queue = MessageQueue::lookup(queueId);
 68 mike   1.2  
 69 mday   1.5     if (queue)
 70                {
 71                   HTTPMessage* httpMessage = new HTTPMessage(message);
 72 kumpf  1.15 
 73                   Tracer::traceBuffer(TRC_XML_IO, Tracer::LEVEL2,
 74                      httpMessage->message.getData(), httpMessage->message.size());
 75             
 76 j.alex 1.19        httpMessage->setCloseConnect(closeConnect);
 77             
 78 mday   1.5        queue->enqueue(httpMessage);
 79                }
 80 kumpf  1.15    else
 81                {
 82                   Tracer::trace(TRC_DISCARDED_DATA, Tracer::LEVEL2,
 83                      "Invalid queueId = %i, response not sent.", queueId);
 84                }
 85 mike   1.2  }
 86             
 87 kumpf  1.6  void CIMExportResponseEncoder::sendEMethodError(
 88 j.alex 1.19     Uint32 queueId, 
 89                 HttpMethod httpMethod,
 90                 const String& messageId,
 91                 const String& eMethodName,
 92                 const CIMException& cimException,
 93                 Boolean closeConnect) 
 94 mday   1.5  {
 95 mike   1.20     Buffer message;
 96 kumpf  1.7      message = XmlWriter::formatSimpleEMethodErrorRspMessage(
 97                     eMethodName,
 98                     messageId,
 99 kumpf  1.12         httpMethod,
100 kumpf  1.8          cimException);
101 kumpf  1.6  
102 j.alex 1.19     sendResponse(queueId, message,closeConnect);
103 mike   1.2  }
104             
105 kumpf  1.6  void CIMExportResponseEncoder::sendEMethodError(
106 j.alex 1.19     CIMResponseMessage* response,
107                 const String& cimMethodName,
108                 Boolean closeConnect)
109 mike   1.2  {
110 mday   1.5     Uint32 queueId = response->queueIds.top();
111                response->queueIds.pop();
112 mike   1.2  
113 kumpf  1.6     sendEMethodError(
114 j.alex 1.19        queueId,
115                    response->getHttpMethod(),
116                    response->messageId, 
117                    cimMethodName, 
118                    response->cimException,
119                    closeConnect);
120 mike   1.2  }
121             
122 mday   1.5  void CIMExportResponseEncoder::handleEnqueue(Message *message)
123 mike   1.2  {
124 carolann.graves 1.25    PEGASUS_ASSERT(message != 0);
125 j.alex          1.19 
126 mday            1.5     switch (message->getType())
127                         {
128                            case CIM_EXPORT_INDICATION_RESPONSE_MESSAGE:
129                      	 encodeExportIndicationResponse(
130                      	    (CIMExportIndicationResponseMessage*)message);
131                      	 break;
132 carolann.graves 1.24 
133                              default:
134                                  PEGASUS_ASSERT(0);
135                                  break;
136 mday            1.5     }
137                         
138                         delete message;
139                      }
140 mike            1.2  
141                      
142 mday            1.5  void CIMExportResponseEncoder::handleEnqueue()
143                      {
144                         Message* message = dequeue();
145                         if(message)
146                            handleEnqueue(message);
147 mike            1.2  }
148                      
149                      void CIMExportResponseEncoder::encodeExportIndicationResponse(
150 j.alex          1.19     CIMExportIndicationResponseMessage* response)
151 mike            1.2  {
152 j.alex          1.19 
153                         Boolean closeConnect = response->getCloseConnect();
154                         Tracer::trace(
155                             TRC_HTTP,
156                             Tracer::LEVEL3,
157                             "CIMExportResponseEncoder::handleEnqueue()- response>getCloseConnect() returned %d",
158                             response->getCloseConnect());
159                      
160 kumpf           1.8     if (response->cimException.getCode() != CIM_ERR_SUCCESS)
161 mday            1.5     {
162 j.alex          1.19       sendEMethodError(response, "ExportIndication",closeConnect);
163 mday            1.5        return;
164                         }
165 mike            1.2  
166 j.alex          1.19 
167 mike            1.20    Buffer body;
168 mike            1.2      
169 chuck           1.13 // l10n
170                         // Note: Content-Language will not be set in the response. 
171                         // Export responses are sent in the default language of the
172                         // ExportServer.
173 mike            1.20    Buffer message = XmlWriter::formatSimpleEMethodRspMessage(
174 kumpf           1.12       CIMName ("ExportIndication"), response->messageId, 
175 chuck           1.13       response->getHttpMethod(),
176 kumpf           1.22       ContentLanguageList(),
177 chuck           1.13       body);
178 mike            1.2  
179 j.alex          1.19    sendResponse(response->queueIds.top(), message,closeConnect);
180 mike            1.2  }
181                      
182                      PEGASUS_NAMESPACE_END

No CVS admin address has been configured
Powered by
ViewCVS 0.9.2