1 //%/////////////////////////////////////////////////////////////////////////////
3 // Copyright (c) 2000, 2001 BMC Software, Hewlett-Packard Company, IBM,
4 // The Open Group, Tivoli Systems
6 // Permission is hereby granted, free of charge, to any person obtaining a copy
7 // of this software and associated documentation files (the "Software"), to
8 // deal in the Software without restriction, including without limitation the
9 // rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
10 // sell copies of the Software, and to permit persons to whom the Software is
11 // furnished to do so, subject to the following conditions:
13 // THE ABOVE COPYRIGHT NOTICE AND THIS PERMISSION NOTICE SHALL BE INCLUDED IN
14 // ALL COPIES OR SUBSTANTIAL PORTIONS OF THE SOFTWARE. THE SOFTWARE IS PROVIDED
15 // "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT
16 // LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
17 // PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
18 // HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
19 // ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
22 //==============================================================================
24 // Author: Mike Brasher (mbrasher@bmc.com)
26 // Modified By: Nitin Upasani, Hewlett-Packard Company (Nitin_Upasani@hp.com)
28 //%/////////////////////////////////////////////////////////////////////////////
30 #include <Pegasus/Common/Config.h>
33 #include <Pegasus/Common/XmlParser.h>
34 #include <Pegasus/Common/XmlReader.h>
35 #include <Pegasus/Common/Destroyer.h>
36 #include <Pegasus/Common/XmlWriter.h>
37 #include <Pegasus/Common/HTTPMessage.h>
38 #include <Pegasus/Common/Logger.h>
39 #include "CIMExportResponseEncoder.h"
43 PEGASUS_NAMESPACE_BEGIN
45 CIMExportResponseEncoder::CIMExportResponseEncoder()
46 : Base("CIMExportResponseEncoder", MessageQueue::getNextQueueId())
51 CIMExportResponseEncoder::~CIMExportResponseEncoder()
56 void CIMExportResponseEncoder::sendResponse(
58 Array<Sint8>& message)
60 MessageQueue* queue = MessageQueue::lookup(queueId);
64 HTTPMessage* httpMessage = new HTTPMessage(message);
65 queue->enqueue(httpMessage);
69 void CIMExportResponseEncoder::sendEMethodError(
71 const String& messageId,
72 const String& eMethodName,
73 const CIMException& cimException)
76 message = XmlWriter::formatSimpleEMethodErrorRspMessage(
81 sendResponse(queueId, message);
84 void CIMExportResponseEncoder::sendEMethodError(
85 CIMResponseMessage* response,
86 const String& cimMethodName)
88 Uint32 queueId = response->queueIds.top();
89 response->queueIds.pop();
95 response->cimException);
98 void CIMExportResponseEncoder::handleEnqueue(Message *message)
103 switch (message->getType())
105 case CIM_EXPORT_INDICATION_RESPONSE_MESSAGE:
106 encodeExportIndicationResponse(
107 (CIMExportIndicationResponseMessage*)message);
115 void CIMExportResponseEncoder::handleEnqueue()
117 Message* message = dequeue();
119 handleEnqueue(message);
122 const char* CIMExportResponseEncoder::getQueueName() const
124 return "CIMExportResponseEncoder";
127 void CIMExportResponseEncoder::encodeExportIndicationResponse(
128 CIMExportIndicationResponseMessage* response)
130 if (response->cimException.getCode() != CIM_ERR_SUCCESS)
132 sendEMethodError(response, "ExportIndication");
138 Array<Sint8> message = XmlWriter::formatSimpleEMethodRspMessage(
139 "ExportIndication", response->messageId, body);
141 sendResponse(response->queueIds.top(), message);
144 PEGASUS_NAMESPACE_END