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 a.dunfey 1.4 if(request->requestIsOOP == true)
57 {
58 _responseObjectThreshold = ~0;
59 }
60 else
61 {
62 _responseObjectThreshold = PEGASUS_RESPONSE_OBJECT_COUNT_THRESHOLD;
|
63 brian.campbell 1.3
64 #ifdef PEGASUS_DEBUG
|
65 a.dunfey 1.4 static const char *responseObjectThreshold =
66 getenv("PEGASUS_RESPONSE_OBJECT_COUNT_THRESHOLD");
67 if (responseObjectThreshold)
68 {
69 Uint32 i = (Uint32) atoi(responseObjectThreshold);
70 if (i > 0)
71 _responseObjectThreshold = i;
72 }
|
73 brian.campbell 1.3 #endif
|
74 a.dunfey 1.4 }
|
75 brian.campbell 1.3 }
76
77 OperationResponseHandler::~OperationResponseHandler()
78 {
79 _request = 0;
80 _response = 0;
81 }
82
83 // This is only called from SimpleResponseHandler.deliver() but lives in this
84 // class because all asyncronous response must have a "response" pointer
85 // to go through. Only operation classes have a response pointer
86
87 void OperationResponseHandler::send(Boolean isComplete)
88 {
89 // some handlers do not send async because their callers cannot handle
90 // partial responses. If this is the case, stop here.
91
92 if (isAsync() == false)
93 {
94 // preserve tradional behavior
95 if (isComplete == true)
96 brian.campbell 1.3 transfer();
97 return;
98 }
99
100 SimpleResponseHandler *simpleP = dynamic_cast<SimpleResponseHandler*>(this);
101
102 // It is possible to instantiate this class directly (not derived)
103 // The caller would do this only if the operation does not have any data to
104 // be returned
105
106 if (! simpleP)
107 {
108 // if there is no data to be returned, then the message should NEVER be
109 // incomplete (even on an error)
110 if (isComplete == false)
111 PEGASUS_ASSERT(false);
112 return;
113 }
114
115 SimpleResponseHandler &simple = *simpleP;
116 PEGASUS_ASSERT(_response);
117 brian.campbell 1.3 Uint32 objectCount = simple.size();
118
119 // have not reached threshold yet
120 if (isComplete == false && objectCount < _responseObjectThreshold)
121 return;
122
123 CIMResponseMessage *response = _response;
124
125 // for complete responses, just use the one handed down from caller
126 // otherwise, create our own that the caller never sees but is
127 // utilized for async responses underneath
128
129 if (isComplete == false)
130 _response = _request->buildResponse();
131
132 _response->setComplete(isComplete);
133 _responseObjectTotal += objectCount;
134
135 // since we are reusing response for every chunk,keep track of original count
136 _response->setIndex(_responseMessageTotal++);
137
138 brian.campbell 1.3 // set the originally allocated response to one more than the current.
139 // The reason for doing this is proactive in case of an exception. This
140 // allows the last response to be set as it may not re-enter this code.
141
142 if (isComplete == false)
143 response->setIndex(_responseMessageTotal);
144
145 validate();
146
147 if (_response->cimException.getCode() != CIM_ERR_SUCCESS)
148 simple.clear();
149
150 String function = getClass() + "::" + "transfer";
151 Logger::put(Logger::STANDARD_LOG, System::CIMSERVER, Logger::TRACE,
152 function);
153
154 transfer();
155 simple.clear();
156
157 // l10n
158 _response->operationContext.
159 brian.campbell 1.3 set(ContentLanguageListContainer(simple.getLanguages()));
160
161 // call thru ProviderManager to get externally declared entry point
162
163 if (isComplete == false)
164 {
165 ProviderManagerService::handleCimResponse(*_request, *_response);
166 }
167
168 // put caller's allocated response back in place. Note that _response
169 // is INVALID after sending because it has been deleted externally
170
171 _response = response;
172 }
173
|
174 schuur 1.1 PEGASUS_NAMESPACE_END
|