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 // Author: Mike Brasher (mbrasher@bmc.com)
33 //
34 // Modified By: Nitin Upasani, Hewlett-Packard Company (Nitin_Upasani@hp.com)
|
35 kumpf 1.11 // Carol Ann Krug Graves, Hewlett-Packard Company
36 // (carolann_graves@hp.com)
|
37 j.alex 1.19 // John Alex, IBM (johnalex@us.ibm.com) - Bug#2290
|
38 mike 1.2 //
39 //%/////////////////////////////////////////////////////////////////////////////
40
41 #include <Pegasus/Common/Config.h>
42 #include <cctype>
43 #include <cstdio>
|
44 kumpf 1.9 #include <Pegasus/Common/Constants.h>
|
45 mike 1.2 #include <Pegasus/Common/XmlParser.h>
46 #include <Pegasus/Common/XmlReader.h>
47 #include <Pegasus/Common/XmlWriter.h>
48 #include <Pegasus/Common/HTTPMessage.h>
49 #include <Pegasus/Common/Logger.h>
|
50 kumpf 1.15 #include <Pegasus/Common/Tracer.h>
|
51 kumpf 1.22 #include <Pegasus/Common/ContentLanguageList.h>
|
52 mike 1.2 #include "CIMExportResponseEncoder.h"
53
54 PEGASUS_USING_STD;
55
56 PEGASUS_NAMESPACE_BEGIN
57
58 CIMExportResponseEncoder::CIMExportResponseEncoder()
|
59 kumpf 1.9 : Base(PEGASUS_QUEUENAME_EXPORTRESPENCODER)
|
60 mike 1.2 {
61
62 }
63
64 CIMExportResponseEncoder::~CIMExportResponseEncoder()
65 {
66
67 }
68
69 void CIMExportResponseEncoder::sendResponse(
|
70 mday 1.5 Uint32 queueId,
|
71 mike 1.20 Buffer& message,
|
72 j.alex 1.19 Boolean closeConnect)
|
73 mike 1.2 {
|
74 mday 1.5 MessageQueue* queue = MessageQueue::lookup(queueId);
|
75 mike 1.2
|
76 mday 1.5 if (queue)
77 {
78 HTTPMessage* httpMessage = new HTTPMessage(message);
|
79 kumpf 1.15
80 Tracer::traceBuffer(TRC_XML_IO, Tracer::LEVEL2,
81 httpMessage->message.getData(), httpMessage->message.size());
82
|
83 j.alex 1.19 httpMessage->setCloseConnect(closeConnect);
84
|
85 mday 1.5 queue->enqueue(httpMessage);
86 }
|
87 kumpf 1.15 else
88 {
89 Tracer::trace(TRC_DISCARDED_DATA, Tracer::LEVEL2,
90 "Invalid queueId = %i, response not sent.", queueId);
91 }
|
92 mike 1.2 }
93
|
94 kumpf 1.6 void CIMExportResponseEncoder::sendEMethodError(
|
95 j.alex 1.19 Uint32 queueId,
96 HttpMethod httpMethod,
97 const String& messageId,
98 const String& eMethodName,
99 const CIMException& cimException,
100 Boolean closeConnect)
|
101 mday 1.5 {
|
102 mike 1.20 Buffer message;
|
103 kumpf 1.7 message = XmlWriter::formatSimpleEMethodErrorRspMessage(
104 eMethodName,
105 messageId,
|
106 kumpf 1.12 httpMethod,
|
107 kumpf 1.8 cimException);
|
108 kumpf 1.6
|
109 j.alex 1.19 sendResponse(queueId, message,closeConnect);
|
110 mike 1.2 }
111
|
112 kumpf 1.6 void CIMExportResponseEncoder::sendEMethodError(
|
113 j.alex 1.19 CIMResponseMessage* response,
114 const String& cimMethodName,
115 Boolean closeConnect)
|
116 mike 1.2 {
|
117 mday 1.5 Uint32 queueId = response->queueIds.top();
118 response->queueIds.pop();
|
119 mike 1.2
|
120 kumpf 1.6 sendEMethodError(
|
121 j.alex 1.19 queueId,
122 response->getHttpMethod(),
123 response->messageId,
124 cimMethodName,
125 response->cimException,
126 closeConnect);
|
127 mike 1.2 }
128
|
129 mday 1.5 void CIMExportResponseEncoder::handleEnqueue(Message *message)
|
130 mike 1.2 {
|
131 mday 1.5 if (!message)
132 return;
|
133 mike 1.2
|
134 j.alex 1.19
|
135 mday 1.5 switch (message->getType())
136 {
137 case CIM_EXPORT_INDICATION_RESPONSE_MESSAGE:
138 encodeExportIndicationResponse(
139 (CIMExportIndicationResponseMessage*)message);
140 break;
141 }
142
143 delete message;
144 }
|
145 mike 1.2
146
|
147 mday 1.5 void CIMExportResponseEncoder::handleEnqueue()
148 {
149 Message* message = dequeue();
150 if(message)
151 handleEnqueue(message);
|
152 mike 1.2 }
153
154 void CIMExportResponseEncoder::encodeExportIndicationResponse(
|
155 j.alex 1.19 CIMExportIndicationResponseMessage* response)
|
156 mike 1.2 {
|
157 j.alex 1.19
158 Boolean closeConnect = response->getCloseConnect();
159 Tracer::trace(
160 TRC_HTTP,
161 Tracer::LEVEL3,
162 "CIMExportResponseEncoder::handleEnqueue()- response>getCloseConnect() returned %d",
163 response->getCloseConnect());
164
|
165 kumpf 1.8 if (response->cimException.getCode() != CIM_ERR_SUCCESS)
|
166 mday 1.5 {
|
167 j.alex 1.19 sendEMethodError(response, "ExportIndication",closeConnect);
|
168 mday 1.5 return;
169 }
|
170 mike 1.2
|
171 j.alex 1.19
|
172 mike 1.20 Buffer body;
|
173 mike 1.2
|
174 chuck 1.13 // l10n
175 // Note: Content-Language will not be set in the response.
176 // Export responses are sent in the default language of the
177 // ExportServer.
|
178 mike 1.20 Buffer message = XmlWriter::formatSimpleEMethodRspMessage(
|
179 kumpf 1.12 CIMName ("ExportIndication"), response->messageId,
|
180 chuck 1.13 response->getHttpMethod(),
|
181 kumpf 1.22 ContentLanguageList(),
|
182 chuck 1.13 body);
|
183 mike 1.2
|
184 j.alex 1.19 sendResponse(response->queueIds.top(), message,closeConnect);
|
185 mike 1.2 }
186
187 PEGASUS_NAMESPACE_END
|