c6ab110415f899deb97a167c286262e3f21e7d83
[tpot/pegasus.git.bak/pegasus.git] / src / Pegasus / WsmServer / WsmRequestDecoder.h
1 //%LICENSE////////////////////////////////////////////////////////////////
2 //
3 // Licensed to The Open Group (TOG) under one or more contributor license
4 // agreements.  Refer to the OpenPegasusNOTICE.txt file distributed with
5 // this work for additional information regarding copyright ownership.
6 // Each contributor licenses this file to you under the OpenPegasus Open
7 // Source License; you may not use this file except in compliance with the
8 // License.
9 //
10 // Permission is hereby granted, free of charge, to any person obtaining a
11 // copy of this software and associated documentation files (the "Software"),
12 // to deal in the Software without restriction, including without limitation
13 // the rights to use, copy, modify, merge, publish, distribute, sublicense,
14 // and/or sell copies of the Software, and to permit persons to whom the
15 // Software is furnished to do so, subject to the following conditions:
16 //
17 // The above copyright notice and this permission notice shall be included
18 // in all copies or substantial portions of the Software.
19 //
20 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
21 // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
22 // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
23 // IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
24 // CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
25 // TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
26 // SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
27 //
28 //////////////////////////////////////////////////////////////////////////
29 //
30 //%////////////////////////////////////////////////////////////////////////////
31
32 #ifndef Pegasus_WsmRequestDecoder_h
33 #define Pegasus_WsmRequestDecoder_h
34
35 #include <Pegasus/Common/Config.h>
36 #include <Pegasus/Common/MessageQueue.h>
37 #include <Pegasus/Common/HTTPMessage.h>
38 #include <Pegasus/Common/AcceptLanguageList.h>
39 #include <Pegasus/Common/ContentLanguageList.h>
40 #include <Pegasus/WsmServer/WsmRequest.h>
41
42 PEGASUS_NAMESPACE_BEGIN
43
44 class WsmReader;
45 class WsmProcessor;
46
47 /** This class decodes WS-Man operation requests and passes them down-stream.
48  */
49 class WsmRequestDecoder : public MessageQueue
50 {
51 public:
52
53     WsmRequestDecoder(WsmProcessor* wsmProcessor);
54
55     ~WsmRequestDecoder();
56
57     void sendResponse(
58         Uint32 queueId,
59         Buffer& message,
60         Boolean httpCloseConnect = false);
61
62     void sendHttpError(
63         Uint32 queueId,
64         const String& status,
65         const String& cimError = String::EMPTY,
66         const String& messageBody = String::EMPTY,
67         Boolean httpCloseConnect = false);
68
69     virtual void handleEnqueue(Message *);
70
71     virtual void handleEnqueue();
72
73     void handleHTTPMessage(HTTPMessage* httpMessage);
74
75     void handleWsmMessage(
76         Uint32 queueId,
77         HttpMethod httpMethod,
78         char* content,
79         Uint32 contentLength,
80         String& soapAction,
81         const String& authType,
82         const String& userName,
83         const String& ipAddress,
84         const AcceptLanguageList& httpAcceptLanguages,
85         const ContentLanguageList& httpContentLanguages,
86         Boolean httpCloseConnect);
87
88     // Sets the flag to indicate whether or not the CIMServer is shutting down.
89     void setServerTerminating(Boolean flag) { _serverTerminating = flag; }
90
91 private:
92
93     void _checkRequiredHeader(
94         const char* headerName,
95         Boolean headerSpecified);
96
97     void _checkNoSelectorsEPR(const WsmEndpointReference& epr);
98
99     WxfGetRequest* _decodeWSTransferGet(
100         WsmReader& wsmReader,
101         const String& messageId,
102         const WsmEndpointReference& epr);
103
104     WxfPutRequest* _decodeWSTransferPut(
105         WsmReader& wsmReader,
106         const String& messageId,
107         const WsmEndpointReference& epr);
108
109     WxfCreateRequest* _decodeWSTransferCreate(
110         WsmReader& wsmReader,
111         const String& messageId,
112         const WsmEndpointReference& epr);
113
114     WxfDeleteRequest* _decodeWSTransferDelete(
115         WsmReader& wsmReader,
116         const String& messageId,
117         const WsmEndpointReference& epr);
118
119     WsenEnumerateRequest* _decodeWSEnumerationEnumerate(
120         WsmReader& wsmReader,
121         const String& messageId,
122         const WsmEndpointReference& epr,
123         Boolean requestItemCount);
124
125     WsenPullRequest* _decodeWSEnumerationPull(
126         WsmReader& wsmReader,
127         const String& messageId,
128         const WsmEndpointReference& epr,
129         Boolean requestItemCount);
130
131     WsenReleaseRequest* _decodeWSEnumerationRelease(
132         WsmReader& wsmReader,
133         const String& messageId,
134         const WsmEndpointReference& epr);
135
136     // The queue to which to forward the decoded WsmRequests.
137     WsmProcessor* _wsmProcessor;
138
139     // Flag to indicate whether or not the CIMServer is shutting down.
140     Boolean _serverTerminating;
141 };
142
143 PEGASUS_NAMESPACE_END
144
145 #endif /* Pegasus_WsmRequestDecoder_h */