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

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

No CVS admin address has been configured
Powered by
ViewCVS 0.9.2