(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 j.alex 1.19        httpMessage->setCloseConnect(closeConnect);
 74             
 75 mday   1.5        queue->enqueue(httpMessage);
 76                }
 77 kumpf  1.15    else
 78                {
 79                   Tracer::trace(TRC_DISCARDED_DATA, Tracer::LEVEL2,
 80                      "Invalid queueId = %i, response not sent.", queueId);
 81                }
 82 mike   1.2  }
 83             
 84 kumpf  1.6  void CIMExportResponseEncoder::sendEMethodError(
 85 j.alex 1.19     Uint32 queueId, 
 86                 HttpMethod httpMethod,
 87                 const String& messageId,
 88                 const String& eMethodName,
 89                 const CIMException& cimException,
 90                 Boolean closeConnect) 
 91 mday   1.5  {
 92 mike   1.20     Buffer message;
 93 kumpf  1.7      message = XmlWriter::formatSimpleEMethodErrorRspMessage(
 94                     eMethodName,
 95                     messageId,
 96 kumpf  1.12         httpMethod,
 97 kumpf  1.8          cimException);
 98 kumpf  1.6  
 99 j.alex 1.19     sendResponse(queueId, message,closeConnect);
100 mike   1.2  }
101             
102 kumpf  1.6  void CIMExportResponseEncoder::sendEMethodError(
103 j.alex 1.19     CIMResponseMessage* response,
104                 const String& cimMethodName,
105                 Boolean closeConnect)
106 mike   1.2  {
107 mday   1.5     Uint32 queueId = response->queueIds.top();
108                response->queueIds.pop();
109 mike   1.2  
110 kumpf  1.6     sendEMethodError(
111 j.alex 1.19        queueId,
112                    response->getHttpMethod(),
113                    response->messageId, 
114                    cimMethodName, 
115                    response->cimException,
116                    closeConnect);
117 mike   1.2  }
118             
119 mday   1.5  void CIMExportResponseEncoder::handleEnqueue(Message *message)
120 mike   1.2  {
121 carolann.graves 1.25    PEGASUS_ASSERT(message != 0);
122 j.alex          1.19 
123 mday            1.5     switch (message->getType())
124                         {
125                            case CIM_EXPORT_INDICATION_RESPONSE_MESSAGE:
126                      	 encodeExportIndicationResponse(
127                      	    (CIMExportIndicationResponseMessage*)message);
128                      	 break;
129 carolann.graves 1.24 
130                              default:
131                                  PEGASUS_ASSERT(0);
132                                  break;
133 mday            1.5     }
134                         
135                         delete message;
136                      }
137 mike            1.2  
138                      
139 mday            1.5  void CIMExportResponseEncoder::handleEnqueue()
140                      {
141                         Message* message = dequeue();
142                         if(message)
143                            handleEnqueue(message);
144 mike            1.2  }
145                      
146                      void CIMExportResponseEncoder::encodeExportIndicationResponse(
147 j.alex          1.19     CIMExportIndicationResponseMessage* response)
148 mike            1.2  {
149 j.alex          1.19 
150                         Boolean closeConnect = response->getCloseConnect();
151                         Tracer::trace(
152                             TRC_HTTP,
153                             Tracer::LEVEL3,
154                             "CIMExportResponseEncoder::handleEnqueue()- response>getCloseConnect() returned %d",
155                             response->getCloseConnect());
156                      
157 kumpf           1.8     if (response->cimException.getCode() != CIM_ERR_SUCCESS)
158 mday            1.5     {
159 j.alex          1.19       sendEMethodError(response, "ExportIndication",closeConnect);
160 mday            1.5        return;
161                         }
162 mike            1.2  
163 j.alex          1.19 
164 mike            1.20    Buffer body;
165 mike            1.2      
166 chuck           1.13 // l10n
167                         // Note: Content-Language will not be set in the response. 
168                         // Export responses are sent in the default language of the
169                         // ExportServer.
170 mike            1.20    Buffer message = XmlWriter::formatSimpleEMethodRspMessage(
171 kumpf           1.12       CIMName ("ExportIndication"), response->messageId, 
172 chuck           1.13       response->getHttpMethod(),
173 kumpf           1.22       ContentLanguageList(),
174 chuck           1.13       body);
175 mike            1.2  
176 j.alex          1.19    sendResponse(response->queueIds.top(), message,closeConnect);
177 mike            1.2  }
178                      
179                      PEGASUS_NAMESPACE_END

No CVS admin address has been configured
Powered by
ViewCVS 0.9.2