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

No CVS admin address has been configured
Powered by
ViewCVS 0.9.2