(file) Return to OperationResponseHandler.cpp CVS log (file) (dir) Up to [Pegasus] / pegasus / src / Pegasus / ProviderManager2

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

No CVS admin address has been configured
Powered by
ViewCVS 0.9.2