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