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

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

No CVS admin address has been configured
Powered by
ViewCVS 0.9.2