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

   1 a.dunfey 1.11.8.2 //%2006////////////////////////////////////////////////////////////////////////
   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 a.dunfey 1.11.8.2 // Copyright (c) 2006 Hewlett-Packard Development Company, L.P.; IBM Corp.;
  12                   // EMC Corporation; Symantec Corporation; The Open Group.
  13 schuur   1.1      //
  14                   // Permission is hereby granted, free of charge, to any person obtaining a copy
  15                   // of this software and associated documentation files (the "Software"), to
  16                   // deal in the Software without restriction, including without limitation the
  17                   // rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
  18                   // sell copies of the Software, and to permit persons to whom the Software is
  19                   // furnished to do so, subject to the following conditions:
  20 a.dunfey 1.11.8.2 // 
  21 schuur   1.1      // THE ABOVE COPYRIGHT NOTICE AND THIS PERMISSION NOTICE SHALL BE INCLUDED IN
  22                   // ALL COPIES OR SUBSTANTIAL PORTIONS OF THE SOFTWARE. THE SOFTWARE IS PROVIDED
  23                   // "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT
  24                   // LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
  25                   // PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
  26                   // HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
  27                   // ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
  28                   // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
  29                   //
  30                   //==============================================================================
  31                   //
  32                   // Author: Chip Vincent (cvincent@us.ibm.com)
  33                   //
  34                   // Modified By:
  35 brian.campbell 1.3      //         Brian G. Campbell, EMC (campbell_brian@emc.com) - PEP140/phase2
  36 a.dunfey       1.11.8.3 //         Roger Kumpf, Hewlett-Packard Company (roger_kumpf@hp.com)
  37 chip           1.7      //
  38 schuur         1.1      //%/////////////////////////////////////////////////////////////////////////////
  39                         
  40                         #include "OperationResponseHandler.h"
  41 chip           1.7      
  42                         #include <Pegasus/Common/Logger.h>
  43 a.dunfey       1.11.8.4 #include <Pegasus/Provider/CIMOMHandle.h>
  44 chip           1.7      
  45 schuur         1.1      PEGASUS_NAMESPACE_BEGIN
  46                         
  47 a.dunfey       1.11.8.4 /**********************************************************
  48                          * Define CIMOMHandleContext class
  49                          **********************************************************/
  50                         class CIMOMHandleContext : public NormalizerContext
  51                         {
  52                         public:
  53                             CIMOMHandleContext() {}
  54                             virtual ~CIMOMHandleContext() {}
  55                         
  56                             virtual CIMClass getClass(
  57                         	      const CIMNamespaceName& nameSpace,
  58                         	      const CIMName& name);
  59                         
  60                             virtual Array<CIMName> enumerateClassNames(
  61                                 const CIMNamespaceName& nameSpace, const CIMName& className,
  62                                 bool deepInheritance);
  63                         
  64                             virtual AutoPtr<NormalizerContext> clone();
  65                         
  66                         protected:
  67                             CIMOMHandleContext(CIMOMHandle & hndl) : handle(hndl) {}
  68 a.dunfey       1.11.8.4 private:
  69 a.dunfey       1.11.8.5     CIMOMHandleContext(const CIMOMHandleContext &);
  70 a.dunfey       1.11.8.6     CIMOMHandleContext & operator=(const CIMOMHandleContext &);
  71 a.dunfey       1.11.8.4     CIMOMHandle handle;
  72                             OperationContext emptyContext;
  73                         };
  74                         
  75                         CIMClass CIMOMHandleContext::getClass(
  76                             const CIMNamespaceName& nameSpace,
  77                             const CIMName& name)
  78                         {
  79                             // Get the whole class definition
  80                             return handle.getClass(emptyContext, nameSpace, name, false, true, true,
  81                                 CIMPropertyList());
  82                         }
  83                         
  84                         Array<CIMName> CIMOMHandleContext::enumerateClassNames(
  85                             const CIMNamespaceName& nameSpace, const CIMName& className,
  86                             bool deepInheritance)
  87                         {
  88                             return handle.enumerateClassNames(emptyContext, nameSpace, className,
  89                                 deepInheritance);
  90                         }
  91                         
  92 a.dunfey       1.11.8.4 AutoPtr<NormalizerContext> CIMOMHandleContext::clone()
  93                         {
  94                           AutoPtr<NormalizerContext> tmpPtr(new CIMOMHandleContext(handle));
  95                           return tmpPtr;
  96                         }
  97                         
  98                         /**********************************************************
  99                          * End CIMOMHandleContext class
 100                          **********************************************************/
 101                         
 102 chip           1.7      //
 103                         // OperationResponseHandler
 104                         //
 105                         
 106                         OperationResponseHandler::OperationResponseHandler(
 107                             CIMRequestMessage *request,
 108 a.dunfey       1.11.8.3     CIMResponseMessage *response,
 109                             PEGASUS_RESPONSE_CHUNK_CALLBACK_T responseChunkCallback)
 110 chip           1.7          : _request(request),
 111                             _response(response),
 112 a.dunfey       1.11.8.3     _responseChunkCallback(responseChunkCallback),
 113 chip           1.8          _responseObjectTotal(0),
 114 chip           1.7          _responseMessageTotal(0),
 115 a.dunfey       1.11.8.3     _responseObjectThreshold(0)
 116 brian.campbell 1.3      {
 117                         #ifndef PEGASUS_RESPONSE_OBJECT_COUNT_THRESHOLD
 118 chip           1.7       #define PEGASUS_RESPONSE_OBJECT_COUNT_THRESHOLD 100
 119 brian.campbell 1.3      #elif PEGASUS_RESPONSE_OBJECT_COUNT_THRESHOLD  == 0
 120 chip           1.7       #undef PEGASUS_RESPONSE_OBJECT_COUNT_THRESHOLD
 121                          #define PEGASUS_RESPONSE_OBJECT_COUNT_THRESHOLD  ~0
 122 brian.campbell 1.3      #endif
 123                         
 124 a.dunfey       1.11.8.3     if (!request)
 125 a.dunfey       1.4          {
 126                                 _responseObjectThreshold = ~0;
 127                             }
 128                         	else
 129                             {
 130                                 _responseObjectThreshold = PEGASUS_RESPONSE_OBJECT_COUNT_THRESHOLD;
 131 brian.campbell 1.3      
 132                         #ifdef PEGASUS_DEBUG
 133 chip           1.7      	    static const char *responseObjectThreshold =
 134 a.dunfey       1.4      		    getenv("PEGASUS_RESPONSE_OBJECT_COUNT_THRESHOLD");
 135 chip           1.7      
 136                                 if (responseObjectThreshold)
 137 a.dunfey       1.4      	    {
 138 chip           1.7      		    Uint32 i = (Uint32)atoi(responseObjectThreshold);
 139                         
 140                                     if (i > 0)
 141                                     {
 142                                         _responseObjectThreshold = i;
 143                                     }
 144 a.dunfey       1.4      	    }
 145 brian.campbell 1.3      #endif
 146 a.dunfey       1.4          }
 147 brian.campbell 1.3      }
 148                         
 149                         OperationResponseHandler::~OperationResponseHandler()
 150                         {
 151                         	_request = 0;
 152                         	_response = 0;
 153                         }
 154                         
 155 chip           1.7      CIMRequestMessage * OperationResponseHandler::getRequest(void) const
 156                         {
 157                             return(_request);
 158                         }
 159                         
 160                         CIMResponseMessage * OperationResponseHandler::getResponse(void) const
 161                         {
 162                             return(_response);
 163                         }
 164                         
 165                         void OperationResponseHandler::setStatus(
 166                             const Uint32 code,
 167                             const String & message)
 168                         {
 169                             _response->cimException = PEGASUS_CIM_EXCEPTION(CIMStatusCode(code), message);
 170                         }
 171                         
 172                         void OperationResponseHandler::setStatus(
 173                             const Uint32 code,
 174 a.dunfey       1.11.8.2     const ContentLanguageList & langs,
 175 chip           1.7          const String & message)
 176                         {
 177                             _response->cimException =
 178                                 PEGASUS_CIM_EXCEPTION_LANG(
 179                                 langs,
 180                                 CIMStatusCode(code),
 181                                 message);
 182                         }
 183                         
 184                         Boolean OperationResponseHandler::isAsync(void) const
 185                         {
 186                             return(true);
 187                         }
 188                         
 189 brian.campbell 1.3      // This is only called from SimpleResponseHandler.deliver() but lives in this
 190                         // class because all asyncronous response must have a "response" pointer
 191                         // to go through. Only operation classes have a response pointer
 192                         void OperationResponseHandler::send(Boolean isComplete)
 193                         {
 194                         	// some handlers do not send async because their callers cannot handle
 195                         	// partial responses. If this is the case, stop here.
 196                         
 197                         	if (isAsync() == false)
 198                         	{
 199                         		// preserve tradional behavior
 200                         		if (isComplete == true)
 201 chip           1.7              {
 202                                     transfer();
 203                                 }
 204                         
 205                                 return;
 206 brian.campbell 1.3      	}
 207                         
 208                         	SimpleResponseHandler *simpleP = dynamic_cast<SimpleResponseHandler*>(this);
 209                         
 210                         	// It is possible to instantiate this class directly (not derived)
 211 chip           1.7      	// The caller would do this only if the operation does not have any data to
 212 brian.campbell 1.3      	// be returned
 213                         
 214                         	if (! simpleP)
 215                         	{
 216                         		// if there is no data to be returned, then the message should NEVER be
 217                         		// incomplete (even on an error)
 218                         		if (isComplete == false)
 219 chip           1.7              {
 220                                     PEGASUS_ASSERT(false);
 221                                 }
 222                         
 223                                 return;
 224 brian.campbell 1.3      	}
 225                         
 226                         	SimpleResponseHandler &simple = *simpleP;
 227                         	PEGASUS_ASSERT(_response);
 228                         	Uint32 objectCount = simple.size();
 229                         
 230                         	// have not reached threshold yet
 231 chip           1.7      	if ((isComplete == false) && (objectCount < _responseObjectThreshold))
 232                             {
 233                                 return;
 234                             }
 235 brian.campbell 1.3      
 236                         	CIMResponseMessage *response = _response;
 237                         
 238                         	// for complete responses, just use the one handed down from caller
 239                         	// otherwise, create our own that the caller never sees but is
 240                         	// utilized for async responses underneath
 241                         
 242                         	if (isComplete == false)
 243 chip           1.7          {
 244                                 _response = _request->buildResponse();
 245                             }
 246 brian.campbell 1.3      
 247                         	_response->setComplete(isComplete);
 248                         	_responseObjectTotal += objectCount;
 249                         
 250                         	// since we are reusing response for every chunk,keep track of original count
 251                         	_response->setIndex(_responseMessageTotal++);
 252                         
 253                         	// set the originally allocated response to one more than the current.
 254                         	// The reason for doing this is proactive in case of an exception. This
 255                         	// allows the last response to be set as it may not re-enter this code.
 256                         
 257                         	if (isComplete == false)
 258 chip           1.7          {
 259                                 response->setIndex(_responseMessageTotal);
 260                             }
 261 brian.campbell 1.3      
 262                         	validate();
 263                         
 264                         	if (_response->cimException.getCode() != CIM_ERR_SUCCESS)
 265 chip           1.7          {
 266                                 simple.clear();
 267                             }
 268                         
 269 brian.campbell 1.3      	String function = getClass() + "::" + "transfer";
 270 chip           1.7      	Logger::put(
 271                                 Logger::STANDARD_LOG,
 272                                 System::CIMSERVER,
 273                                 Logger::TRACE,
 274                                 function);
 275                         
 276 brian.campbell 1.3      	transfer();
 277                         	simple.clear();
 278                         
 279                         	// l10n
 280 chip           1.7      	_response->operationContext.set(ContentLanguageListContainer(simple.getLanguages()));
 281 brian.campbell 1.3      
 282                         	// call thru ProviderManager to get externally declared entry point
 283                         
 284                         	if (isComplete == false)
 285                         	{
 286 a.dunfey       1.11.8.3 	    _responseChunkCallback(_request, _response);
 287 brian.campbell 1.3      	}
 288                         
 289                         	// put caller's allocated response back in place. Note that _response
 290                         	// is INVALID after sending because it has been deleted externally
 291                         
 292                         	_response = response;
 293                         }
 294                         
 295 chip           1.7      void OperationResponseHandler::transfer(void)
 296                         {
 297                         }
 298                         
 299                         void OperationResponseHandler::validate(void)
 300                         {
 301                         }
 302                         
 303                         String OperationResponseHandler::getClass(void) const
 304                         {
 305                             return(String("OperationResponseHandler"));
 306                         }
 307                         
 308                         Uint32 OperationResponseHandler::getResponseObjectTotal(void) const
 309                         {
 310                             return(_responseObjectTotal);
 311                         }
 312                         
 313                         Uint32 OperationResponseHandler::getResponseMessageTotal(void) const
 314                         {
 315                             return(_responseMessageTotal);
 316 chip           1.7      }
 317                         
 318                         Uint32 OperationResponseHandler::getResponseObjectThreshold(void) const
 319                         {
 320                             return(_responseObjectThreshold);
 321                         }
 322                         
 323                         //
 324                         // GetInstanceResponseHandler
 325                         //
 326                         
 327                         GetInstanceResponseHandler::GetInstanceResponseHandler(
 328 a.dunfey       1.11.8.3     CIMGetInstanceRequestMessage* request,
 329                             CIMGetInstanceResponseMessage* response,
 330                             PEGASUS_RESPONSE_CHUNK_CALLBACK_T responseChunkCallback)
 331                             : OperationResponseHandler(request, response, responseChunkCallback)
 332 chip           1.7      {
 333                             #ifdef PEGASUS_ENABLE_OBJECT_NORMALIZATION
 334                             // Attempt to get the cached class definition used to validate results of this
 335                             // operation. If it does not exist, then this feature is disabled for this
 336                             // operation.
 337                             CIMClass cimClass;
 338                         
 339                             try
 340                             {
 341                                 CachedClassDefinitionContainer container =
 342                                     request->operationContext.get(CachedClassDefinitionContainer::NAME);
 343                         
 344                                 cimClass = container.getClass();
 345                             }
 346                             catch(Exception &)
 347                             {
 348                                 // Do nothing. Container is missing, which implies normalization is disabled
 349                                 // for this operation.
 350                             }
 351                         
 352 a.dunfey       1.11.8.4     AutoPtr<NormalizerContext> tmpContext(new CIMOMHandleContext());
 353                             ObjectNormalizer tmpNormalizer(
 354                                 cimClass,
 355                                 request->includeQualifiers,
 356                                 request->includeClassOrigin,
 357                                 request->nameSpace,
 358                                 tmpContext);
 359                             _normalizer = tmpNormalizer;
 360 chip           1.7          #endif
 361                         }
 362                         
 363                         void GetInstanceResponseHandler::deliver(const CIMInstance & cimInstance)
 364                         {
 365                             if(cimInstance.isUninitialized())
 366                             {
 367                                 MessageLoaderParms message(
 368                                     "Common.Exception.UNINITIALIZED_OBJECT_EXCEPTION",
 369                                     "The object is not initialized.");
 370                         
 371                                 throw CIMException(CIM_ERR_FAILED, message);
 372                             }
 373                         
 374 chip           1.9          if(SimpleInstanceResponseHandler::size() != 0)
 375                             {
 376                                 MessageLoaderParms message(
 377                                     "Server.OperationResponseHandler.TOO_MANY_OBJECTS_DELIVERED",
 378                                     "Too many objects delivered.");
 379                         
 380                                 throw CIMException(CIM_ERR_FAILED, message);
 381                             }
 382                         
 383 chip           1.7          #ifdef PEGASUS_ENABLE_OBJECT_NORMALIZATION
 384                             // The normalizer expects an object path embedded in instances even
 385                             // though it is not required by this operation. Use the requested
 386                             // object path is missing from the instance.
 387                             CIMInstance localInstance(cimInstance);
 388                         
 389                             if(localInstance.getPath().getKeyBindings().size() == 0)
 390                             {
 391                                 // ATTN: should clone before modification
 392                                 localInstance.setPath(static_cast<CIMGetInstanceRequestMessage *>(getRequest())->instanceName);
 393                             }
 394                         
 395                             SimpleInstanceResponseHandler::deliver(_normalizer.processInstance(localInstance));
 396                             #else
 397                             SimpleInstanceResponseHandler::deliver(cimInstance);
 398                             #endif
 399                         }
 400                         
 401 chip           1.9      void GetInstanceResponseHandler::complete(void)
 402                         {
 403 chip           1.10         if(SimpleInstanceResponseHandler::size() == 0)
 404 chip           1.9          {
 405                                 MessageLoaderParms message(
 406                                     "Server.OperationResponseHandler.TOO_FEW_OBJECTS_DELIVERED",
 407                                     "Too few objects delivered.");
 408                         
 409                                 throw CIMException(CIM_ERR_FAILED, message);
 410                             }
 411                         
 412                             SimpleInstanceResponseHandler::complete();
 413                         }
 414                         
 415 chip           1.7      String GetInstanceResponseHandler::getClass(void) const
 416                         {
 417                             return(String("GetInstanceResponseHandler"));
 418                         }
 419                         
 420                         void GetInstanceResponseHandler::transfer(void)
 421                         {
 422                             if(size() > 0)
 423                             {
 424                                 CIMGetInstanceResponseMessage & msg =
 425                                     *static_cast<CIMGetInstanceResponseMessage *>(getResponse());
 426                         
 427                                 msg.cimInstance = getObjects()[0];
 428                             }
 429                         }
 430                         
 431                         void GetInstanceResponseHandler::validate(void)
 432                         {
 433                             if(getResponseObjectTotal() == 0)
 434                             {
 435                                 // error? provider claims success,
 436 chip           1.7              // but did not deliver an instance.
 437                                 setStatus(CIM_ERR_NOT_FOUND);
 438                             }
 439                         }
 440                         
 441                         //
 442                         // EnumerateInstancesResponseHandler
 443                         //
 444                         
 445                         EnumerateInstancesResponseHandler::EnumerateInstancesResponseHandler(
 446 a.dunfey       1.11.8.3     CIMEnumerateInstancesRequestMessage* request,
 447                             CIMEnumerateInstancesResponseMessage* response,
 448                             PEGASUS_RESPONSE_CHUNK_CALLBACK_T responseChunkCallback)
 449                             : OperationResponseHandler(request, response, responseChunkCallback)
 450 chip           1.7      {
 451                             #ifdef PEGASUS_ENABLE_OBJECT_NORMALIZATION
 452                             // Attempt to get the cached class definition used to validate results of this
 453                             // operation. If it does not exist, then this feature is disabled for this
 454                             // operation.
 455                             CIMClass cimClass;
 456                         
 457                             try
 458                             {
 459                                 CachedClassDefinitionContainer container =
 460                                     request->operationContext.get(CachedClassDefinitionContainer::NAME);
 461                         
 462                                 cimClass = container.getClass();
 463                             }
 464                             catch(Exception &)
 465                             {
 466                                 // Do nothing. Container is missing, which implies normalization is disabled
 467                                 // for this operation.
 468                             }
 469                         
 470 a.dunfey       1.11.8.4     AutoPtr<NormalizerContext> tmpContext(new CIMOMHandleContext());
 471                             ObjectNormalizer tmpNormalizer(
 472                                 cimClass,
 473                                 request->includeQualifiers,
 474                                 request->includeClassOrigin,
 475                                 request->nameSpace,
 476                                 tmpContext);
 477                             _normalizer = tmpNormalizer;
 478                         #endif
 479 chip           1.7      }
 480                         
 481                         void EnumerateInstancesResponseHandler::deliver(const CIMInstance & cimInstance)
 482                         {
 483                             if(cimInstance.isUninitialized())
 484                             {
 485                                 MessageLoaderParms message(
 486                                     "Common.Exception.UNINITIALIZED_OBJECT_EXCEPTION",
 487                                     "The object is not initialized.");
 488                         
 489                                 throw CIMException(CIM_ERR_FAILED, message);
 490                             }
 491                         
 492                             #ifdef PEGASUS_ENABLE_OBJECT_NORMALIZATION
 493                             SimpleInstanceResponseHandler::deliver(_normalizer.processInstance(cimInstance));
 494                             #else
 495                             SimpleInstanceResponseHandler::deliver(cimInstance);
 496                             #endif
 497                         }
 498                         
 499                         String EnumerateInstancesResponseHandler::getClass(void) const
 500 chip           1.7      {
 501                             return(String("EnumerateInstancesResponseHandler"));
 502                         }
 503                         
 504                         void EnumerateInstancesResponseHandler::transfer(void)
 505                         {
 506                             CIMEnumerateInstancesResponseMessage & msg =
 507                                 *static_cast<CIMEnumerateInstancesResponseMessage *>(getResponse());
 508                         
 509                             msg.cimNamedInstances = getObjects();
 510                         }
 511                         
 512                         //
 513                         // EnumerateInstanceNamesResponseHandler
 514                         //
 515                         
 516                         EnumerateInstanceNamesResponseHandler::EnumerateInstanceNamesResponseHandler(
 517 a.dunfey       1.11.8.3     CIMEnumerateInstanceNamesRequestMessage* request,
 518                             CIMEnumerateInstanceNamesResponseMessage* response,
 519                             PEGASUS_RESPONSE_CHUNK_CALLBACK_T responseChunkCallback)
 520                             : OperationResponseHandler(request, response, responseChunkCallback)
 521 chip           1.7      {
 522                             #ifdef PEGASUS_ENABLE_OBJECT_NORMALIZATION
 523                             // Attempt to get the cached class definition used to validate results of this
 524                             // operation. If it does not exist, then this feature is disabled for this
 525                             // operation.
 526                             CIMClass cimClass;
 527                         
 528                             try
 529                             {
 530                                 CachedClassDefinitionContainer container =
 531                                     request->operationContext.get(CachedClassDefinitionContainer::NAME);
 532                         
 533                                 cimClass = container.getClass();
 534                             }
 535                             catch(Exception &)
 536                             {
 537                                 // Do nothing. Container is missing, which implies normalization is disabled
 538                                 // for this operation.
 539                             }
 540                         
 541 a.dunfey       1.11.8.4     AutoPtr<NormalizerContext> tmpContext(new CIMOMHandleContext());
 542                             ObjectNormalizer tmpNormalizer(
 543                                 cimClass,
 544                                 false,
 545                                 false,
 546                                 request->nameSpace,
 547                                 tmpContext);
 548                             _normalizer = tmpNormalizer;
 549                         #endif
 550 chip           1.7      }
 551                         
 552                         void EnumerateInstanceNamesResponseHandler::deliver(const CIMObjectPath & cimObjectPath)
 553                         {
 554                             if(cimObjectPath.getClassName().isNull())
 555                             {
 556                                 MessageLoaderParms message(
 557                                     "Common.Exception.UNINITIALIZED_OBJECT_EXCEPTION",
 558                                     "The object is not initialized.");
 559                         
 560                                 throw CIMException(CIM_ERR_FAILED, message);
 561                             }
 562                         
 563                             #ifdef PEGASUS_ENABLE_OBJECT_NORMALIZATION
 564                             SimpleObjectPathResponseHandler::deliver(_normalizer.processInstanceObjectPath(cimObjectPath));
 565                             #else
 566                             SimpleObjectPathResponseHandler::deliver(cimObjectPath);
 567                             #endif
 568                         }
 569                         
 570                         String EnumerateInstanceNamesResponseHandler::getClass(void) const
 571 chip           1.7      {
 572                             return(String("EnumerateInstanceNamesResponseHandler"));
 573                         }
 574                         
 575                         void EnumerateInstanceNamesResponseHandler::transfer(void)
 576                         {
 577                             CIMEnumerateInstanceNamesResponseMessage & msg =
 578                                 *static_cast<CIMEnumerateInstanceNamesResponseMessage *>(getResponse());
 579                         
 580                             msg.instanceNames = getObjects();
 581                         }
 582                         
 583                         //
 584                         // CreateInstanceResponseHandler
 585                         //
 586                         
 587                         CreateInstanceResponseHandler::CreateInstanceResponseHandler(
 588 a.dunfey       1.11.8.3     CIMCreateInstanceRequestMessage* request,
 589                             CIMCreateInstanceResponseMessage* response,
 590                             PEGASUS_RESPONSE_CHUNK_CALLBACK_T responseChunkCallback)
 591                             : OperationResponseHandler(request, response, responseChunkCallback)
 592 chip           1.7      {
 593                         }
 594                         
 595                         void CreateInstanceResponseHandler::deliver(const CIMObjectPath & cimObjectPath)
 596                         {
 597                             if(cimObjectPath.getClassName().isNull())
 598                             {
 599                                 MessageLoaderParms message(
 600                                     "Common.Exception.UNINITIALIZED_OBJECT_EXCEPTION",
 601                                     "The object is not initialized.");
 602                         
 603                                 throw CIMException(CIM_ERR_FAILED, message);
 604                             }
 605                         
 606 chip           1.11         if(SimpleObjectPathResponseHandler::size() != 0)
 607                             {
 608                                 MessageLoaderParms message(
 609                                     "Server.OperationResponseHandler.TOO_MANY_OBJECTS_DELIVERED",
 610                                     "Too many objects delivered.");
 611                         
 612                                 throw CIMException(CIM_ERR_FAILED, message);
 613                             }
 614                         
 615 chip           1.7          SimpleObjectPathResponseHandler::deliver(cimObjectPath);
 616                         }
 617                         
 618 chip           1.9      void CreateInstanceResponseHandler::complete(void)
 619                         {
 620 chip           1.10         if(SimpleObjectPathResponseHandler::size() == 0)
 621 chip           1.9          {
 622                                 MessageLoaderParms message(
 623                                     "Server.OperationResponseHandler.TOO_FEW_OBJECTS_DELIVERED",
 624                                     "Too few objects delivered.");
 625                         
 626                                 throw CIMException(CIM_ERR_FAILED, message);
 627                             }
 628                         
 629                             SimpleObjectPathResponseHandler::complete();
 630                         }
 631                         
 632 chip           1.7      String CreateInstanceResponseHandler::getClass(void) const
 633                         {
 634                             return(String("CreateInstanceResponseHandler"));
 635                         }
 636                         
 637                         #if 0
 638                         // ATTN: is it an error to not return instance name?
 639                         void CreateInstanceResponseHandler::validate(void)
 640                         {
 641                             if(getResponseObjectTotal() == 0)
 642                             {
 643                                 setStatus(CIM_ERR_NOT_FOUND);
 644                             }
 645                         }
 646                         #endif
 647                         
 648                         void CreateInstanceResponseHandler::transfer(void)
 649                         {
 650                             if(size() > 0)
 651                             {
 652                                 CIMCreateInstanceResponseMessage & msg =
 653 chip           1.7                  *static_cast<CIMCreateInstanceResponseMessage *>(getResponse());
 654                         
 655                                 msg.instanceName = getObjects()[0];
 656                             }
 657                         }
 658                         
 659                         //
 660                         // ModifyInstanceResponseHandler
 661                         //
 662                         
 663                         ModifyInstanceResponseHandler::ModifyInstanceResponseHandler(
 664 a.dunfey       1.11.8.3     CIMModifyInstanceRequestMessage* request,
 665                             CIMModifyInstanceResponseMessage* response,
 666                             PEGASUS_RESPONSE_CHUNK_CALLBACK_T responseChunkCallback)
 667                             : OperationResponseHandler(request, response, responseChunkCallback)
 668 chip           1.7      {
 669                         }
 670                         
 671                         String ModifyInstanceResponseHandler::getClass(void) const
 672                         {
 673                             return(String("ModifyInstanceResponseHandler"));
 674                         }
 675                         
 676                         //
 677                         // DeleteInstanceResponseHandler
 678                         //
 679                         
 680                         DeleteInstanceResponseHandler::DeleteInstanceResponseHandler(
 681 a.dunfey       1.11.8.3     CIMDeleteInstanceRequestMessage* request,
 682                             CIMDeleteInstanceResponseMessage* response,
 683                             PEGASUS_RESPONSE_CHUNK_CALLBACK_T responseChunkCallback)
 684                             : OperationResponseHandler(request, response, responseChunkCallback)
 685 chip           1.7      {
 686                         }
 687                         
 688                         String DeleteInstanceResponseHandler::getClass(void) const
 689                         {
 690                             return(String("DeleteInstanceResponseHandler"));
 691                         }
 692                         
 693                         //
 694                         // GetPropertyResponseHandler
 695                         //
 696                         
 697                         GetPropertyResponseHandler::GetPropertyResponseHandler(
 698 a.dunfey       1.11.8.3     CIMGetPropertyRequestMessage* request,
 699                             CIMGetPropertyResponseMessage* response,
 700                             PEGASUS_RESPONSE_CHUNK_CALLBACK_T responseChunkCallback)
 701                             : OperationResponseHandler(request, response, responseChunkCallback)
 702 chip           1.7      {
 703                         }
 704                         
 705                         void GetPropertyResponseHandler::deliver(const CIMValue & cimValue)
 706                         {
 707                             if(cimValue.isNull())
 708                             {
 709                                 MessageLoaderParms message(
 710                                     "Common.Exception.UNINITIALIZED_OBJECT_EXCEPTION",
 711                                     "The object is not initialized.");
 712                         
 713                                 throw CIMException(CIM_ERR_FAILED, message);
 714                             }
 715                         
 716                             SimpleValueResponseHandler::deliver(cimValue);
 717                         }
 718                         
 719                         String GetPropertyResponseHandler::getClass(void) const
 720                         {
 721                             return(String("GetPropertyResponseHandler"));
 722                         }
 723 chip           1.7      
 724                         void GetPropertyResponseHandler::transfer(void)
 725                         {
 726                             if(size() > 0)
 727                             {
 728                                 CIMGetPropertyResponseMessage & msg =
 729                                     *static_cast<CIMGetPropertyResponseMessage *>(getResponse());
 730                         
 731                                 msg.value = getObjects()[0];
 732                             }
 733                         }
 734                         
 735                         void GetPropertyResponseHandler::validate(void)
 736                         {
 737                             // error? provider claims success,
 738                             // but did not deliver an instance.
 739                             if(getResponseObjectTotal() == 0)
 740                             {
 741                                 setStatus(CIM_ERR_NOT_FOUND);
 742                             }
 743                         }
 744 chip           1.7      
 745                         //
 746                         // SetPropertyResponseHandler
 747                         //
 748                         
 749                         SetPropertyResponseHandler::SetPropertyResponseHandler(
 750 a.dunfey       1.11.8.3     CIMSetPropertyRequestMessage* request,
 751                             CIMSetPropertyResponseMessage* response,
 752                             PEGASUS_RESPONSE_CHUNK_CALLBACK_T responseChunkCallback)
 753                             : OperationResponseHandler(request, response, responseChunkCallback)
 754 chip           1.7      {
 755                         }
 756                         
 757                         String SetPropertyResponseHandler::getClass(void) const
 758                         {
 759                             return(String("SetPropertyResponseHandler"));
 760                         }
 761                         
 762                         //
 763                         // ExecQueryResponseHandler
 764                         //
 765                         
 766                         ExecQueryResponseHandler::ExecQueryResponseHandler(
 767 a.dunfey       1.11.8.3     CIMExecQueryRequestMessage* request,
 768                             CIMExecQueryResponseMessage* response,
 769                             PEGASUS_RESPONSE_CHUNK_CALLBACK_T responseChunkCallback)
 770                             : OperationResponseHandler(request, response, responseChunkCallback)
 771 chip           1.7      {
 772                         }
 773                         
 774                         void ExecQueryResponseHandler::deliver(const CIMInstance & cimInstance)
 775                         {
 776                             if(cimInstance.isUninitialized())
 777                             {
 778                                 MessageLoaderParms message(
 779                                     "Common.Exception.UNINITIALIZED_OBJECT_EXCEPTION",
 780                                     "The object is not initialized.");
 781                         
 782                                 throw CIMException(CIM_ERR_FAILED, message);
 783                             }
 784                         
 785                             SimpleInstance2ObjectResponseHandler::deliver(cimInstance);
 786                         }
 787                         
 788                         String ExecQueryResponseHandler::getClass(void) const
 789                         {
 790                             return(String("ExecQueryResponseHandler"));
 791                         }
 792 chip           1.7      
 793                         void ExecQueryResponseHandler::transfer(void)
 794                         {
 795                             CIMExecQueryResponseMessage & msg =
 796                                 *static_cast<CIMExecQueryResponseMessage *>(getResponse());
 797                         
 798                             msg.cimObjects = getObjects();
 799                         }
 800                         
 801                         Boolean ExecQueryResponseHandler::isAsync(void) const
 802                         {
 803                             return(false);
 804                         }
 805                         
 806                         //
 807                         // AssociatorsResponseHandler
 808                         //
 809                         
 810                         AssociatorsResponseHandler::AssociatorsResponseHandler(
 811 a.dunfey       1.11.8.3     CIMAssociatorsRequestMessage* request,
 812                             CIMAssociatorsResponseMessage* response,
 813                             PEGASUS_RESPONSE_CHUNK_CALLBACK_T responseChunkCallback)
 814                             : OperationResponseHandler(request, response, responseChunkCallback)
 815 chip           1.7      {
 816                         }
 817                         
 818                         void AssociatorsResponseHandler::deliver(const CIMObject & cimObject)
 819                         {
 820                             if(cimObject.isUninitialized())
 821                             {
 822                                 MessageLoaderParms message(
 823                                     "Common.Exception.UNINITIALIZED_OBJECT_EXCEPTION",
 824                                     "The object is not initialized.");
 825                         
 826                                 throw CIMException(CIM_ERR_FAILED, message);
 827                             }
 828                         
 829                             SimpleObjectResponseHandler::deliver(cimObject);
 830                         }
 831                         
 832                         String AssociatorsResponseHandler::getClass(void) const
 833                         {
 834                             return(String("AssociatorsResponseHandler"));
 835                         }
 836 chip           1.7      
 837                         void AssociatorsResponseHandler::transfer(void)
 838                         {
 839                             CIMAssociatorsResponseMessage & msg =
 840                                 *static_cast<CIMAssociatorsResponseMessage *>(getResponse());
 841                         
 842                             msg.cimObjects = getObjects();
 843                         }
 844                         
 845                         //
 846                         // AssociatorNamesResponseHandler
 847                         //
 848                         
 849                         AssociatorNamesResponseHandler::AssociatorNamesResponseHandler(
 850 a.dunfey       1.11.8.3     CIMAssociatorNamesRequestMessage* request,
 851                             CIMAssociatorNamesResponseMessage* response,
 852                             PEGASUS_RESPONSE_CHUNK_CALLBACK_T responseChunkCallback)
 853                             : OperationResponseHandler(request, response, responseChunkCallback)
 854 chip           1.7      {
 855                         }
 856                         
 857                         void AssociatorNamesResponseHandler::deliver(const CIMObjectPath & cimObjectPath)
 858                         {
 859                             if(cimObjectPath.getClassName().isNull())
 860                             {
 861                                 MessageLoaderParms message(
 862                                     "Common.Exception.UNINITIALIZED_OBJECT_EXCEPTION",
 863                                     "The object is not initialized.");
 864                         
 865                                 throw CIMException(CIM_ERR_FAILED, message);
 866                             }
 867                         
 868                             SimpleObjectPathResponseHandler::deliver(cimObjectPath);
 869                         }
 870                         
 871                         String AssociatorNamesResponseHandler::getClass(void) const
 872                         {
 873                             return(String("AssociatorNamesResponseHandler"));
 874                         }
 875 chip           1.7      
 876                         void AssociatorNamesResponseHandler::transfer(void)
 877                         {
 878                             CIMAssociatorNamesResponseMessage & msg =
 879                                 *static_cast<CIMAssociatorNamesResponseMessage *>(getResponse());
 880                         
 881                             msg.objectNames = getObjects();
 882                         }
 883                         
 884                         //
 885                         // ReferencesResponseHandler
 886                         //
 887                         
 888                         ReferencesResponseHandler::ReferencesResponseHandler(
 889 a.dunfey       1.11.8.3     CIMReferencesRequestMessage* request,
 890                             CIMReferencesResponseMessage* response,
 891                             PEGASUS_RESPONSE_CHUNK_CALLBACK_T responseChunkCallback)
 892                             : OperationResponseHandler(request, response, responseChunkCallback)
 893 chip           1.7      {
 894                         }
 895                         
 896                         void ReferencesResponseHandler::deliver(const CIMObject & cimObject)
 897                         {
 898                             if(cimObject.isUninitialized())
 899                             {
 900                                 MessageLoaderParms message(
 901                                     "Common.Exception.UNINITIALIZED_OBJECT_EXCEPTION",
 902                                     "The object is not initialized.");
 903                         
 904                                 throw CIMException(CIM_ERR_FAILED, message);
 905                             }
 906                         
 907                             SimpleObjectResponseHandler::deliver(cimObject);
 908                         }
 909                         
 910                         String ReferencesResponseHandler::getClass(void) const
 911                         {
 912                             return(String("ReferencesResponseHandler"));
 913                         }
 914 chip           1.7      
 915                         void ReferencesResponseHandler::transfer(void)
 916                         {
 917                             CIMReferencesResponseMessage & msg =
 918                                 *static_cast<CIMReferencesResponseMessage *>(getResponse());
 919                         
 920                             msg.cimObjects = getObjects();
 921                         }
 922                         
 923                         //
 924                         // ReferenceNamesResponseHandler
 925                         //
 926                         
 927                         ReferenceNamesResponseHandler::ReferenceNamesResponseHandler(
 928 a.dunfey       1.11.8.3     CIMReferenceNamesRequestMessage* request,
 929                             CIMReferenceNamesResponseMessage* response,
 930                             PEGASUS_RESPONSE_CHUNK_CALLBACK_T responseChunkCallback)
 931                             : OperationResponseHandler(request, response, responseChunkCallback)
 932 chip           1.7      {
 933                         }
 934                         
 935                         void ReferenceNamesResponseHandler::deliver(const CIMObjectPath & cimObjectPath)
 936                         {
 937                             if(cimObjectPath.getClassName().isNull())
 938                             {
 939                                 MessageLoaderParms message(
 940                                     "Common.Exception.UNINITIALIZED_OBJECT_EXCEPTION",
 941                                     "The object is not initialized.");
 942                         
 943                                 throw CIMException(CIM_ERR_FAILED, message);
 944                             }
 945                         
 946                             SimpleObjectPathResponseHandler::deliver(cimObjectPath);
 947                         }
 948                         
 949                         String ReferenceNamesResponseHandler::getClass(void) const
 950                         {
 951                             return(String("ReferenceNamesResponseHandler"));
 952                         }
 953 chip           1.7      
 954                         void ReferenceNamesResponseHandler::transfer(void)
 955                         {
 956                             CIMReferenceNamesResponseMessage & msg =
 957                                 *static_cast<CIMReferenceNamesResponseMessage *>(getResponse());
 958                         
 959                             msg.objectNames = getObjects();
 960                         }
 961                         
 962                         //
 963                         // InvokeMethodResponseHandler
 964                         //
 965                         
 966                         InvokeMethodResponseHandler::InvokeMethodResponseHandler(
 967 a.dunfey       1.11.8.3     CIMInvokeMethodRequestMessage* request,
 968                             CIMInvokeMethodResponseMessage* response,
 969                             PEGASUS_RESPONSE_CHUNK_CALLBACK_T responseChunkCallback)
 970                             : OperationResponseHandler(request, response, responseChunkCallback)
 971 chip           1.7      {
 972                         }
 973                         
 974                         void InvokeMethodResponseHandler::deliverParamValue(const CIMParamValue & cimParamValue)
 975                         {
 976                             if(cimParamValue.isUninitialized())
 977                             {
 978                                 MessageLoaderParms message(
 979                                     "Common.Exception.UNINITIALIZED_OBJECT_EXCEPTION",
 980                                     "The object is not initialized.");
 981                         
 982                                 throw CIMException(CIM_ERR_FAILED, message);
 983                             }
 984                         
 985                             SimpleMethodResultResponseHandler::deliverParamValue(cimParamValue);
 986                         }
 987                         
 988                         void InvokeMethodResponseHandler::deliver(const CIMValue & cimValue)
 989                         {
 990                             if(cimValue.isNull())
 991                             {
 992 chip           1.7              MessageLoaderParms message(
 993                                     "Common.Exception.UNINITIALIZED_OBJECT_EXCEPTION",
 994                                     "The object is not initialized.");
 995                         
 996                                 throw CIMException(CIM_ERR_FAILED, message);
 997                             }
 998                         
 999                             SimpleMethodResultResponseHandler::deliver(cimValue);
1000                         }
1001                         
1002                         String InvokeMethodResponseHandler::getClass(void) const
1003                         {
1004                             return(String("InvokeMethodResponseHandler"));
1005                         }
1006                         
1007                         void InvokeMethodResponseHandler::transfer(void)
1008                         {
1009                             CIMInvokeMethodResponseMessage & msg =
1010                                 *static_cast<CIMInvokeMethodResponseMessage *>(getResponse());
1011                         
1012                             msg.outParameters = getParamValues();
1013 chip           1.7      
1014                             // ATTN-RK-20020903: Is it legal for the return value to be null?
1015                             // if not, then the check must be done here since deliver() works off the
1016                             // virtual size, which refers to out parameters!
1017                             msg.retValue = getReturnValue();
1018                         }
1019                         
1020                         //
1021                         // EnableIndicationsResponseHandler
1022                         //
1023                         
1024                         EnableIndicationsResponseHandler::EnableIndicationsResponseHandler(
1025 a.dunfey       1.11.8.3     CIMRequestMessage* request,
1026                             CIMResponseMessage* response,
1027                             CIMInstance& provider,
1028                             PEGASUS_INDICATION_CALLBACK_T indicationCallback,
1029                             PEGASUS_RESPONSE_CHUNK_CALLBACK_T responseChunkCallback)
1030                             : OperationResponseHandler(request, response, responseChunkCallback),
1031                               _indicationCallback(indicationCallback)
1032 chip           1.7      {
1033                             _provider = provider;
1034                         }
1035                         
1036                         void EnableIndicationsResponseHandler::deliver(const CIMIndication & cimIndication)
1037                         {
1038                             OperationContext context;
1039                         
1040                             Array<CIMObjectPath> subscriptionInstanceNames;
1041                         
1042                             context.insert(SubscriptionInstanceNamesContainer(subscriptionInstanceNames));
1043                         
1044                             deliver(context, cimIndication);
1045                         }
1046                         
1047                         void EnableIndicationsResponseHandler::deliver(const OperationContext & context, const CIMIndication & cimIndication)
1048                         {
1049                             if(cimIndication.isUninitialized())
1050                             {
1051                                 MessageLoaderParms message(
1052                                     "Common.Exception.UNINITIALIZED_OBJECT_EXCEPTION",
1053 chip           1.7                  "The object is not initialized.");
1054                         
1055                                 throw CIMException(CIM_ERR_FAILED, message);
1056                             }
1057                         
1058                             // ATTN: temporarily convert indication to instance
1059                             CIMInstance cimInstance(cimIndication);
1060                         
1061                             //  Get list of subscription instance names from context
1062                             Array<CIMObjectPath> subscriptionInstanceNames;
1063                         
1064                             try
1065                             {
1066                                 SubscriptionInstanceNamesContainer container =
1067                                     context.get(SubscriptionInstanceNamesContainer::NAME);
1068                         
1069                                 subscriptionInstanceNames = container.getInstanceNames();
1070                             }
1071                             catch(Exception &)
1072                             {
1073                                 subscriptionInstanceNames.clear();
1074 chip           1.7          }
1075                         
1076                             // l10n
1077 a.dunfey       1.11.8.2     ContentLanguageList contentLangs;
1078 chip           1.7      
1079                             try
1080                             {
1081                                 // Get the Content-Language for this indication.  The provider
1082                                 // does not have to add specify a language for the indication.
1083                                 ContentLanguageListContainer langContainer =
1084                                     context.get(ContentLanguageListContainer::NAME);
1085                         
1086                                 contentLangs = langContainer.getLanguages();
1087                             }
1088                             catch(Exception &)
1089                             {
1090                                 // The provider did not explicitly set a Content-Language for
1091                                 // the indication.  Fall back to the lang set in this object.
1092                                 contentLangs = getLanguages();
1093                             }
1094                             // l10n -end
1095                         
1096                             // create message
1097                             // l10n
1098                             CIMProcessIndicationRequestMessage * request =
1099 chip           1.7              new CIMProcessIndicationRequestMessage(
1100                                 XmlWriter::getNextMessageId(),
1101                                 cimInstance.getPath().getNameSpace(),
1102                                 cimInstance,
1103                                 subscriptionInstanceNames,
1104                                 _provider,
1105                                 QueueIdStack());  // Must be filled in by the callback function
1106                         
1107                             request->operationContext = context;
1108                         
1109                             try
1110                             {
1111                                 request->operationContext.set(ContentLanguageListContainer(contentLangs));
1112                             }
1113                             catch(Exception &)
1114                             {
1115                                 request->operationContext.insert(ContentLanguageListContainer(contentLangs));
1116                             }
1117                         
1118                             _indicationCallback(request);
1119                         }
1120 chip           1.7      
1121                         void EnableIndicationsResponseHandler::deliver(const Array<CIMIndication> & cimIndications)
1122                         {
1123                             OperationContext context;
1124                         
1125                             deliver(context, cimIndications);
1126                         }
1127                         
1128                         void EnableIndicationsResponseHandler::deliver(const OperationContext & context, const Array<CIMIndication> & cimIndications)
1129                         {
1130                             for(Uint32 i = 0, n = cimIndications.size(); i < n; i++)
1131                             {
1132                                 deliver(context, cimIndications[i]);
1133                             }
1134                         }
1135                         
1136                         String EnableIndicationsResponseHandler::getClass(void) const
1137                         {
1138                             return(String("EnableIndicationsResponseHandler"));
1139                         }
1140                         
1141 chip           1.7      Boolean EnableIndicationsResponseHandler::isAsync(void) const
1142                         {
1143                             return(false);
1144                         }
1145                         
1146 schuur         1.1      PEGASUS_NAMESPACE_END

No CVS admin address has been configured
Powered by
ViewCVS 0.9.2