1 //%2003////////////////////////////////////////////////////////////////////////
3 // 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 // IBM Corp.; EMC Corporation, The Open Group.
8 // Permission is hereby granted, free of charge, to any person obtaining a copy
9 // of this software and associated documentation files (the "Software"), to
10 // deal in the Software without restriction, including without limitation the
11 // rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
12 // sell copies of the Software, and to permit persons to whom the Software is
13 // furnished to do so, subject to the following conditions:
15 // THE ABOVE COPYRIGHT NOTICE AND THIS PERMISSION NOTICE SHALL BE INCLUDED IN
16 // ALL COPIES OR SUBSTANTIAL PORTIONS OF THE SOFTWARE. THE SOFTWARE IS PROVIDED
17 // "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT
18 // LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
19 // PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
20 // HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
21 // ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
24 //==============================================================================
26 // Author: Mike Brasher (mbrasher@bmc.com)
28 // Modified By: Nitin Upasani, Hewlett-Packard Company (Nitin_Upasani@hp.com)
30 // Nag Boranna, Hewlett-Packard Company (nagaraja_boranna@hp.com)
31 // Carol Ann Krug Graves, Hewlett-Packard Company
32 // (carolann_graves@hp.com)
33 // Yi Zhou, Hewlett-Packard Company (yi_zhou@hp.com)
35 //%/////////////////////////////////////////////////////////////////////////////
37 #include <Pegasus/Common/Config.h>
39 #include <Pegasus/Common/Constants.h>
40 #include <Pegasus/Common/System.h>
41 #include <Pegasus/Common/XmlWriter.h>
42 #include <Pegasus/Common/HTTPMessage.h>
43 #include <Pegasus/Common/Destroyer.h>
44 #include <Pegasus/Common/AcceptLanguages.h> // l10n
45 #include <Pegasus/Common/ContentLanguages.h> // l10n
46 #include "CIMExportRequestEncoder.h"
50 PEGASUS_NAMESPACE_BEGIN
52 CIMExportRequestEncoder::CIMExportRequestEncoder(
53 MessageQueue* outputQueue, ClientAuthenticator* authenticator)
55 MessageQueue(PEGASUS_QUEUENAME_EXPORTREQENCODER),
56 _outputQueue(outputQueue),
57 _hostName(System::getHostName().getCString()),
58 _authenticator(authenticator)
62 CIMExportRequestEncoder::~CIMExportRequestEncoder()
66 void CIMExportRequestEncoder::handleEnqueue()
68 Message* message = dequeue();
73 _authenticator->setRequestMessage(message);
75 switch (message->getType())
77 case CIM_EXPORT_INDICATION_REQUEST_MESSAGE:
78 _encodeExportIndicationRequest((CIMExportIndicationRequestMessage*)message);
82 //ATTN: Do not delete the message here.
84 // ClientAuthenticator needs this message for resending the request on
85 // authentication challenge from the server. The message is deleted in
86 // the decoder after receiving the valid response from the server.
91 void CIMExportRequestEncoder::_encodeExportIndicationRequest(
92 CIMExportIndicationRequestMessage* message)
96 XmlWriter::appendInstanceEParameter(
97 params, "NewIndication", message->indicationInstance);
100 // Note: Accept-Language will not be set in the request
101 // We will accept the default language of the export server.
102 Array<Sint8> buffer = XmlWriter::formatSimpleEMethodReqMessage(
103 message->destinationPath.getCString(),
105 CIMName ("ExportIndication"),
107 message->getHttpMethod(),
108 _authenticator->buildRequestAuthHeader(),
109 AcceptLanguages::EMPTY,
110 message->contentLanguages,
113 _outputQueue->enqueue(new HTTPMessage(buffer));
116 PEGASUS_NAMESPACE_END