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