1 karl 1.5 //%2005////////////////////////////////////////////////////////////////////////
|
2 schuur 1.1 //
|
3 karl 1.2 // 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 schuur 1.1 // IBM Corp.; EMC Corporation, The Open Group.
|
7 karl 1.2 // 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.5 // Copyright (c) 2005 Hewlett-Packard Development Company, L.P.; IBM Corp.;
10 // EMC Corporation; VERITAS Software Corporation; The Open Group.
|
11 schuur 1.1 //
12 // Permission is hereby granted, free of charge, to any person obtaining a copy
13 // of this software and associated documentation files (the "Software"), to
14 // deal in the Software without restriction, including without limitation the
15 // rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
16 // sell copies of the Software, and to permit persons to whom the Software is
17 // furnished to do so, subject to the following conditions:
18 //
19 // THE ABOVE COPYRIGHT NOTICE AND THIS PERMISSION NOTICE SHALL BE INCLUDED IN
20 // ALL COPIES OR SUBSTANTIAL PORTIONS OF THE SOFTWARE. THE SOFTWARE IS PROVIDED
21 // "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT
22 // LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
23 // PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
24 // HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
25 // ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
26 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
27 //
28 //==============================================================================
29 //
30 // Author: Chip Vincent (cvincent@us.ibm.com)
31 //
32 schuur 1.1 // Modified By:
|
33 brian.campbell 1.3 // Brian G. Campbell, EMC (campbell_brian@emc.com) - PEP140/phase2
|
34 schuur 1.1 //%/////////////////////////////////////////////////////////////////////////////
35
36 #include "OperationResponseHandler.h"
|
37 brian.campbell 1.3 #include "ProviderManagerService.h"
|
38 schuur 1.1
39 PEGASUS_NAMESPACE_BEGIN
40
|
41 brian.campbell 1.3 OperationResponseHandler::OperationResponseHandler
42 (CIMRequestMessage *request,
43 CIMResponseMessage *response) :
44 _request(request), _response(response)
45 {
46
47 #ifndef PEGASUS_RESPONSE_OBJECT_COUNT_THRESHOLD
48 #define PEGASUS_RESPONSE_OBJECT_COUNT_THRESHOLD 100
49 #elif PEGASUS_RESPONSE_OBJECT_COUNT_THRESHOLD == 0
50 #undef PEGASUS_RESPONSE_OBJECT_COUNT_THRESHOLD
51 #define PEGASUS_RESPONSE_OBJECT_COUNT_THRESHOLD ~0
52 #endif
53
54 _responseObjectTotal = 0;
55 _responseMessageTotal = 0;
|
56 carolann.graves 1.6
57 if (!request || (request->requestIsOOP == true))
|
58 a.dunfey 1.4 {
59 _responseObjectThreshold = ~0;
60 }
61 else
62 {
63 _responseObjectThreshold = PEGASUS_RESPONSE_OBJECT_COUNT_THRESHOLD;
|
64 brian.campbell 1.3
65 #ifdef PEGASUS_DEBUG
|
66 a.dunfey 1.4 static const char *responseObjectThreshold =
67 getenv("PEGASUS_RESPONSE_OBJECT_COUNT_THRESHOLD");
68 if (responseObjectThreshold)
69 {
70 Uint32 i = (Uint32) atoi(responseObjectThreshold);
71 if (i > 0)
72 _responseObjectThreshold = i;
73 }
|
74 brian.campbell 1.3 #endif
|
75 a.dunfey 1.4 }
|
76 brian.campbell 1.3 }
77
78 OperationResponseHandler::~OperationResponseHandler()
79 {
80 _request = 0;
81 _response = 0;
82 }
83
84 // This is only called from SimpleResponseHandler.deliver() but lives in this
85 // class because all asyncronous response must have a "response" pointer
86 // to go through. Only operation classes have a response pointer
87
88 void OperationResponseHandler::send(Boolean isComplete)
89 {
90 // some handlers do not send async because their callers cannot handle
91 // partial responses. If this is the case, stop here.
92
93 if (isAsync() == false)
94 {
95 // preserve tradional behavior
96 if (isComplete == true)
97 brian.campbell 1.3 transfer();
98 return;
99 }
100
101 SimpleResponseHandler *simpleP = dynamic_cast<SimpleResponseHandler*>(this);
102
103 // It is possible to instantiate this class directly (not derived)
104 // The caller would do this only if the operation does not have any data to
105 // be returned
106
107 if (! simpleP)
108 {
109 // if there is no data to be returned, then the message should NEVER be
110 // incomplete (even on an error)
111 if (isComplete == false)
112 PEGASUS_ASSERT(false);
113 return;
114 }
115
116 SimpleResponseHandler &simple = *simpleP;
117 PEGASUS_ASSERT(_response);
118 brian.campbell 1.3 Uint32 objectCount = simple.size();
119
120 // have not reached threshold yet
121 if (isComplete == false && objectCount < _responseObjectThreshold)
122 return;
123
124 CIMResponseMessage *response = _response;
125
126 // for complete responses, just use the one handed down from caller
127 // otherwise, create our own that the caller never sees but is
128 // utilized for async responses underneath
129
130 if (isComplete == false)
131 _response = _request->buildResponse();
132
133 _response->setComplete(isComplete);
134 _responseObjectTotal += objectCount;
135
136 // since we are reusing response for every chunk,keep track of original count
137 _response->setIndex(_responseMessageTotal++);
138
139 brian.campbell 1.3 // set the originally allocated response to one more than the current.
140 // The reason for doing this is proactive in case of an exception. This
141 // allows the last response to be set as it may not re-enter this code.
142
143 if (isComplete == false)
144 response->setIndex(_responseMessageTotal);
145
146 validate();
147
148 if (_response->cimException.getCode() != CIM_ERR_SUCCESS)
149 simple.clear();
150
151 String function = getClass() + "::" + "transfer";
152 Logger::put(Logger::STANDARD_LOG, System::CIMSERVER, Logger::TRACE,
153 function);
154
155 transfer();
156 simple.clear();
157
158 // l10n
159 _response->operationContext.
160 brian.campbell 1.3 set(ContentLanguageListContainer(simple.getLanguages()));
161
162 // call thru ProviderManager to get externally declared entry point
163
164 if (isComplete == false)
165 {
166 ProviderManagerService::handleCimResponse(*_request, *_response);
167 }
168
169 // put caller's allocated response back in place. Note that _response
170 // is INVALID after sending because it has been deleted externally
171
172 _response = response;
173 }
174
|
175 schuur 1.1 PEGASUS_NAMESPACE_END
|