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 // Nag Boranna, Hewlett-Packard Company (nagaraja_boranna@hp.com)
30 //%/////////////////////////////////////////////////////////////////////////////
32 #include <Pegasus/Common/Config.h>
34 #include <Pegasus/Common/Constants.h>
35 #include <Pegasus/Common/System.h>
36 #include <Pegasus/Common/XmlWriter.h>
37 #include <Pegasus/Common/HTTPMessage.h>
38 #include "CIMExportRequestEncoder.h"
42 PEGASUS_NAMESPACE_BEGIN
44 CIMExportRequestEncoder::CIMExportRequestEncoder(
45 MessageQueue* outputQueue, ClientAuthenticator* authenticator)
47 Base(PEGASUS_QUEUENAME_EXPORTREQENCODER),
48 _outputQueue(outputQueue),
49 _authenticator(authenticator)
51 String tmpHostName = System::getHostName();
52 _hostName = tmpHostName.allocateCString();
55 CIMExportRequestEncoder::~CIMExportRequestEncoder()
60 void CIMExportRequestEncoder::handleEnqueue(Message *message)
65 _authenticator->setRequestMessage(message);
67 switch (message->getType())
69 case CIM_EXPORT_INDICATION_REQUEST_MESSAGE:
70 _encodeExportIndicationRequest((CIMExportIndicationRequestMessage*)message);
74 //ATTN: Do not delete the message here.
76 // ClientAuthenticator needs this message for resending the request on
77 // authentication challenge from the server. The message is deleted in
78 // the decoder after receiving the valid response from thr server.
84 void CIMExportRequestEncoder::handleEnqueue()
86 Message* message = dequeue();
88 handleEnqueue(message);
91 void CIMExportRequestEncoder::_encodeExportIndicationRequest(
92 CIMExportIndicationRequestMessage* message)
96 XmlWriter::appendInstanceIParameter(
97 params, "NewIndication", message->indicationInstance);
99 Array<Sint8> buffer = XmlWriter::formatSimpleEMethodReqMessage(
100 message->url.allocateCString(),
103 _authenticator->buildRequestAuthHeader(),
106 _outputQueue->enqueue(new HTTPMessage(buffer));
109 PEGASUS_NAMESPACE_END