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

No CVS admin address has been configured
Powered by
ViewCVS 0.9.2