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

Diff for /pegasus/src/Pegasus/Client/CIMOperationResponseDecoder.cpp between version 1.38 and 1.38.6.3

version 1.38, 2003/04/02 20:10:59 version 1.38.6.3, 2003/08/14 11:55:41
Line 47 
Line 47 
 #include <Pegasus/Common/Exception.h> #include <Pegasus/Common/Exception.h>
 #include "CIMOperationResponseDecoder.h" #include "CIMOperationResponseDecoder.h"
  
   // l10n
   #include <Pegasus/Common/MessageLoader.h>
   
 PEGASUS_USING_STD; PEGASUS_USING_STD;
  
 PEGASUS_NAMESPACE_BEGIN PEGASUS_NAMESPACE_BEGIN
Line 54 
Line 57 
 CIMOperationResponseDecoder::CIMOperationResponseDecoder( CIMOperationResponseDecoder::CIMOperationResponseDecoder(
     MessageQueue* outputQueue,     MessageQueue* outputQueue,
     MessageQueue* encoderQueue,     MessageQueue* encoderQueue,
     ClientAuthenticator* authenticator)      ClientAuthenticator* authenticator,
       Uint32 showInput)
     :     :
     MessageQueue(PEGASUS_QUEUENAME_OPRESPDECODER),     MessageQueue(PEGASUS_QUEUENAME_OPRESPDECODER),
     _outputQueue(outputQueue),     _outputQueue(outputQueue),
     _encoderQueue(encoderQueue),     _encoderQueue(encoderQueue),
     _authenticator(authenticator)      _authenticator(authenticator),
       _showInput(showInput)
 { {
   
 } }
  
 CIMOperationResponseDecoder::~CIMOperationResponseDecoder() CIMOperationResponseDecoder::~CIMOperationResponseDecoder()
Line 112 
Line 116 
  
     if (httpMessage->message.size() == 0)     if (httpMessage->message.size() == 0)
     {     {
   
           // l10n
   
           // CIMClientMalformedHTTPException* malformedHTTPException =
           //   new CIMClientMalformedHTTPException("Empty HTTP response message.");
   
           MessageLoaderParms mlParms("Client.CIMOperationResponseDecoder.EMPTY_RESPONSE", "Empty HTTP response message.");
           String mlString(MessageLoader::getMessage(mlParms));
   
         CIMClientMalformedHTTPException* malformedHTTPException =         CIMClientMalformedHTTPException* malformedHTTPException =
             new CIMClientMalformedHTTPException("Empty HTTP response message.");            new CIMClientMalformedHTTPException(mlString);
   
         ClientExceptionMessage * response =         ClientExceptionMessage * response =
             new ClientExceptionMessage(malformedHTTPException);             new ClientExceptionMessage(malformedHTTPException);
  
Line 126 
Line 140 
     //     //
     // Get the status line info     // Get the status line info
     //     //
   
     String httpVersion;     String httpVersion;
     Uint32 statusCode;     Uint32 statusCode;
     String reasonPhrase;     String reasonPhrase;
Line 135 
Line 148 
         startLine, httpVersion, statusCode, reasonPhrase);         startLine, httpVersion, statusCode, reasonPhrase);
     if (!parsableMessage)     if (!parsableMessage)
     {     {
         CIMClientMalformedHTTPException* malformedHTTPException = new  
             CIMClientMalformedHTTPException("Malformed HTTP response message.");        // l10n
   
         // CIMClientMalformedHTTPException* malformedHTTPException = new
         //   CIMClientMalformedHTTPException("Malformed HTTP response message.");
   
         MessageLoaderParms mlParms("Client.CIMOperationResponseDecoder.MALFORMED_RESPONSE", "Malformed HTTP response message.");
         String mlString(MessageLoader::getMessage(mlParms));
   
         CIMClientMalformedHTTPException* malformedHTTPException =
           new CIMClientMalformedHTTPException(mlString);
   
         ClientExceptionMessage * response =         ClientExceptionMessage * response =
             new ClientExceptionMessage(malformedHTTPException);             new ClientExceptionMessage(malformedHTTPException);
  
Line 144 
Line 167 
         return;         return;
     }     }
  
   #ifdef PEGASUS_CLIENT_TRACE_ENABLE
       if (_showInput & 1)
       {
           cout << "CIMOperatonResponseDecoder";
           httpMessage->printAll(cout);
       }
       if (_showInput & 2)
       {
           Uint32 size = httpMessage->message.size();
           char* tmpBuf = new char[size+1];
   
           strncpy( tmpBuf, httpMessage->message.getData(), size );
           tmpBuf[size] = '\0';
           Logger::put(Logger::STANDARD_LOG,
                                           "CIMCLIENT",
                                           Logger::TRACE,
                                           "CIMOperationRequestDecoder::Response, XML content: $1",
                                           tmpBuf);
           delete []tmpBuf;
       }
   #endif
   
   #ifdef PEGASUS_CLIENT_TRACE_ENABLE
       if (_showInput & 1)
       {
           cout << "CIMOperatonResponseDecoder";
           httpMessage->printAll(cout);
       }
       if (_showInput & 2)
       {
           Uint32 size = httpMessage->message.size();
           char* tmpBuf = new char[size+1];
   
           strncpy( tmpBuf, httpMessage->message.getData(), size );
           tmpBuf[size] = '\0';
           Logger::put(Logger::STANDARD_LOG,
                                           "CIMCLIENT",
                                           Logger::TRACE,
                                           "CIMOperationRequestDecoder::Response, XML content: $1",
                                           tmpBuf);
           delete []tmpBuf;
       }
   #endif
   
     try     try
     {     {
         if (_authenticator->checkResponseHeaderForChallenge(headers))         if (_authenticator->checkResponseHeaderForChallenge(headers))
Line 187 
Line 254 
          // ATTN-SF-P3-20030115: Need to create a specific exception          // ATTN-SF-P3-20030115: Need to create a specific exception
          // to indicate Authentication failure. See JAGae53944.          // to indicate Authentication failure. See JAGae53944.
  
          const String ERROR_MESSAGE = "Authentication failed.";        // l10n
         // const String ERROR_MESSAGE = "Authentication failed.";
   
         MessageLoaderParms mlParms("Client.CIMOperationResponseDecoder.AUTHENTICATION_FAILED", "Authentication failed.");
         String ERROR_MESSAGE(MessageLoader::getMessage(mlParms));
   
          CannotConnectException* cannotConnectException =          CannotConnectException* cannotConnectException =
             new CannotConnectException(ERROR_MESSAGE);             new CannotConnectException(ERROR_MESSAGE);
          ClientExceptionMessage * response =          ClientExceptionMessage * response =
Line 200 
Line 272 
     //     //
     // Check for a success (200 OK) response     // Check for a success (200 OK) response
     //     //
   
     if (statusCode != HTTP_STATUSCODE_OK)     if (statusCode != HTTP_STATUSCODE_OK)
     {     {
         String cimError;         String cimError;
Line 230 
Line 301 
     //     //
     // Search for "CIMOperation" header:     // Search for "CIMOperation" header:
     //     //
   
     String cimOperation;     String cimOperation;
  
     if (!HTTPMessage::lookupHeader(     if (!HTTPMessage::lookupHeader(
         headers, "CIMOperation", cimOperation, true))         headers, "CIMOperation", cimOperation, true))
     {     {
         // l10n
   
         // CIMClientMalformedHTTPException* malformedHTTPException = new
         //   CIMClientMalformedHTTPException("Missing CIMOperation HTTP header");
   
         MessageLoaderParms mlParms("Client.CIMOperationResponseDecoder.MISSING_CIMOP_HEADER", "Missing $0 HTTP header", "CIMOperation");
         String mlString(MessageLoader::getMessage(mlParms));
   
         CIMClientMalformedHTTPException* malformedHTTPException = new         CIMClientMalformedHTTPException* malformedHTTPException = new
             CIMClientMalformedHTTPException("Missing CIMOperation HTTP header");          CIMClientMalformedHTTPException(mlString);
   
         ClientExceptionMessage * response =         ClientExceptionMessage * response =
             new ClientExceptionMessage(malformedHTTPException);             new ClientExceptionMessage(malformedHTTPException);
  
Line 245 
Line 324 
         return;         return;
     }     }
  
   // l10n start
      ContentLanguages contentLanguages  = ContentLanguages::EMPTY;
      try
      {
                   // Get and validate the Content-Language header, if set
                   String contentLanguageHeader;
                   if (HTTPMessage::lookupHeader(
                         headers,
                     "Content-Language",
                         contentLanguageHeader,
                     false) == true)
               {
                           contentLanguages = ContentLanguages(contentLanguageHeader);
               }
      }
      catch (Exception &e)
      {
   
        // l10n
   
        // CIMClientMalformedHTTPException* malformedHTTPException = new
        //  CIMClientMalformedHTTPException("Malformed Content-Language header.");
   
         MessageLoaderParms mlParms("Client.CIMOperationResponseDecoder.MALFORMED_CONTENT", "Malformed Content-Language header.");
         String mlString(MessageLoader::getMessage(mlParms));
   
         CIMClientMalformedHTTPException* malformedHTTPException =
           new CIMClientMalformedHTTPException(mlString);
   
        ClientExceptionMessage * response =
          new ClientExceptionMessage(malformedHTTPException);
   
        _outputQueue->enqueue(response);
        return;
      }
   // l10n end
     //     //
     // Zero-terminate the message:      // Search for "Content-Type" header:
     //     //
  
      String cimContentType;
   
      if (!HTTPMessage::lookupHeader(
                                     headers, "Content-Type", cimContentType, true))
      {
          CIMClientMalformedHTTPException* malformedHTTPException = new
            CIMClientMalformedHTTPException("Missing CIMContentType HTTP header");
          ClientExceptionMessage * response =
            new ClientExceptionMessage(malformedHTTPException);
   
          _outputQueue->enqueue(response);
          return;
      }
   
       //
       // Zero-terminate the message:
       //
     httpMessage->message.append('\0');     httpMessage->message.append('\0');
  
     // Calculate the beginning of the content from the message size and     // Calculate the beginning of the content from the message size and
Line 264 
Line 396 
  
     if (!String::equalNoCase(cimOperation, "MethodResponse"))     if (!String::equalNoCase(cimOperation, "MethodResponse"))
     {     {
   
         // l10n
   
         // CIMClientMalformedHTTPException* malformedHTTPException =
         //   new CIMClientMalformedHTTPException(
         //        String("Received CIMOperation HTTP header value \"") +
         //        cimOperation + "\", expected \"MethodResponse\"");
   
   
         MessageLoaderParms mlParms("Client.CIMOperationResponseDecoder.EXPECTED_METHODRESPONSE", "Received $0 HTTP header value \"$1\", expected \"$2\"", "CIMOperation", cimOperation, "MethodResponse");
         String mlString(MessageLoader::getMessage(mlParms));
   
         CIMClientMalformedHTTPException* malformedHTTPException =         CIMClientMalformedHTTPException* malformedHTTPException =
             new CIMClientMalformedHTTPException(          new CIMClientMalformedHTTPException(mlString);
                 String("Received CIMOperation HTTP header value \"") +  
                 cimOperation + "\", expected \"MethodResponse\"");  
         ClientExceptionMessage * response =         ClientExceptionMessage * response =
             new ClientExceptionMessage(malformedHTTPException);             new ClientExceptionMessage(malformedHTTPException);
  
Line 275 
Line 418 
         return;         return;
     }     }
  
     _handleMethodResponse(content);      _handleMethodResponse(content,
                                                   contentLanguages);  // l10n
 } }
  
 void CIMOperationResponseDecoder::_handleMethodResponse(char* content)  void CIMOperationResponseDecoder::_handleMethodResponse(char* content,
                                                                   const ContentLanguages& contentLanguages) //l10n
 { {
     Message* response = 0;     Message* response = 0;
  
Line 317 
Line 462 
         String messageId;         String messageId;
         String protocolVersion;         String protocolVersion;
  
         if (!XmlReader::getMessageStartTag(parser, messageId, protocolVersion))          if (!XmlReader::getMessageStartTag(parser, messageId, protocolVersion)) {
             throw XmlValidationError(  
                 parser.getLine(), "expected MESSAGE element");            // l10n
   
             // throw XmlValidationError(
             // parser.getLine(), "expected MESSAGE element");
   
             MessageLoaderParms mlParms("Client.CIMOperationResponseDecoder.EXPECTED_ELEMENT",
                                        "expected $0 element", "MESSAGE");
   
             throw XmlValidationError(parser.getLine(), mlParms);
           }
   
  
         if (!String::equalNoCase(protocolVersion, "1.0"))         if (!String::equalNoCase(protocolVersion, "1.0"))
         {         {
   
             // l10n
   
             // CIMClientResponseException* responseException =
             //   new CIMClientResponseException(
             //        String("Received unsupported protocol version \"") +
             //        protocolVersion + "\", expected \"1.0\"");
   
           MessageLoaderParms mlParms("Client.CIMOperationResponseDecoder.UNSUPPORTED_PROTOCOL", "Received unsupported protocol version \"$0\", expected \"1.0\"", protocolVersion);
           String mlString(MessageLoader::getMessage(mlParms));
   
             CIMClientResponseException* responseException =             CIMClientResponseException* responseException =
                 new CIMClientResponseException(            new CIMClientResponseException(mlString);
                     String("Received unsupported protocol version \"") +  
                     protocolVersion + "\", expected \"1.0\"");  
             ClientExceptionMessage * response =             ClientExceptionMessage * response =
                 new ClientExceptionMessage(responseException);                 new ClientExceptionMessage(responseException);
  
Line 401 
Line 566 
                 response = _decodeExecQueryResponse(parser, messageId);                 response = _decodeExecQueryResponse(parser, messageId);
             else             else
             {             {
   
                 // l10n
   
                 // Unrecognized IMethodResponse name attribute                 // Unrecognized IMethodResponse name attribute
                 throw XmlValidationError(parser.getLine(),                // throw XmlValidationError(parser.getLine(),
                     String("Unrecognized IMethodResponse name \"") +                //   String("Unrecognized IMethodResponse name \"") +
                         iMethodResponseName + "\"");                //        iMethodResponseName + "\"");
   
                 MessageLoaderParms mlParms("Client.CIMOperationResponseDecoder.UNRECOGNIZED_NAME",
                                            "Unrecognized $0 name \"$1\"", "IMethodResponse",
                                            iMethodResponseName);
   
                 throw XmlValidationError(parser.getLine(), mlParms);
             }             }
  
             //             //
Line 426 
Line 600 
         }         }
         else         else
         {         {
             throw XmlValidationError(parser.getLine(),            // l10n
                 "expected METHODRESPONSE or IMETHODRESPONSE element");  
             // throw XmlValidationError(parser.getLine(),
             //   "expected METHODRESPONSE or IMETHODRESPONSE element");
   
             MessageLoaderParms mlParms("Client.CIMOperationResponseDecoder.EXPECTED_OR_ELEMENT",
                                        "expected $0 or $1 element", "METHODRESPONSE", "METHODRESPONSE");
   
             throw XmlValidationError(parser.getLine(), mlParms);
         }         }
  
         //         //
Line 444 
Line 625 
  
         if (response)         if (response)
         {         {
   //#ifdef PEGASUS_SNIA_INTEROP_TEST
   //         httpMessage->printAll(cout);
   //#endif
   
             delete response;             delete response;
         }         }
  
Line 464 
Line 649 
             new Exception(x.getMessage()));             new Exception(x.getMessage()));
     }     }
  
   //l10n start
   // l10n TODO - might want to move A-L and C-L to Message
   // to make this more maintainable
           // Add the language header to the request
           CIMMessage * cimmsg = dynamic_cast<CIMMessage *>(response);
           if (cimmsg != NULL)
           {
                   cimmsg->contentLanguages = contentLanguages;
           }
           else
           {
                   ;       // l10n TODO - error back to client here
           }
   // l10n end
   
   
     _outputQueue->enqueue(response);     _outputQueue->enqueue(response);
 } }
  
Line 520 
Line 721 
         if ((entry.type == XmlEntry::EMPTY_TAG) ||         if ((entry.type == XmlEntry::EMPTY_TAG) ||
             !XmlReader::getClassElement(parser, cimClass))             !XmlReader::getClassElement(parser, cimClass))
         {         {
             throw XmlValidationError(parser.getLine(),"expected CLASS element");  
             // l10n
   
             // throw XmlValidationError(parser.getLine(),"expected CLASS element");
   
             MessageLoaderParms mlParms("Client.CIMOperationResponseDecoder.EXPECTED_ELEMENT",
                                        "expected $0 element", "CLASS");
   
             throw XmlValidationError(parser.getLine(), mlParms);
         }         }
  
         XmlReader::expectEndTag(parser, "IRETURNVALUE");         XmlReader::expectEndTag(parser, "IRETURNVALUE");
Line 533 
Line 742 
     }     }
     else     else
     {     {
         throw XmlValidationError(parser.getLine(),  
             "expected ERROR or IRETURNVALUE element");        // l10n
   
         // throw XmlValidationError(parser.getLine(),
         //   "expected ERROR or IRETURNVALUE element");
   
         MessageLoaderParms mlParms("Client.CIMOperationResponseDecoder.EXPECTED_OR_ELEMENT",
                                    "expected $0 or $1 element", "ERROR", "IRETURNVALUE");
   
         throw XmlValidationError(parser.getLine(), mlParms);
     }     }
 } }
  
Line 705 
Line 922 
     }     }
     else     else
     {     {
         throw XmlValidationError(parser.getLine(),  
             "expected ERROR or IRETURNVALUE element");        // l10n
   
         // throw XmlValidationError(parser.getLine(),
         //   "expected ERROR or IRETURNVALUE element");
   
         MessageLoaderParms mlParms("Client.CIMOperationResponseDecoder.EXPECTED_OR_ELEMENT",
                                    "expected $0 or $1 element", "ERROR", "IRETURNVALUE");
   
         throw XmlValidationError(parser.getLine(), mlParms);
     }     }
 } }
  
Line 731 
Line 956 
         if ((entry.type == XmlEntry::EMPTY_TAG) ||         if ((entry.type == XmlEntry::EMPTY_TAG) ||
             !XmlReader::getInstanceElement(parser, cimInstance))             !XmlReader::getInstanceElement(parser, cimInstance))
         {         {
             throw XmlValidationError(  
                 parser.getLine(), "expected INSTANCE element");            // l10n
   
             // throw XmlValidationError(
             // parser.getLine(), "expected INSTANCE element");
   
             MessageLoaderParms mlParms("Client.CIMOperationResponseDecoder.EXPECTED_ELEMENT",
                                        "expected $0 element", "INSTANCE");
   
             throw XmlValidationError(parser.getLine(), mlParms);
         }         }
  
         XmlReader::expectEndTag(parser, "IRETURNVALUE");         XmlReader::expectEndTag(parser, "IRETURNVALUE");
Line 745 
Line 978 
     }     }
     else     else
     {     {
         throw XmlValidationError(parser.getLine(),  
             "expected ERROR or IRETURNVALUE element");        // l10n
   
         // throw XmlValidationError(parser.getLine(),
         //   "expected ERROR or IRETURNVALUE element");
   
         MessageLoaderParms mlParms("Client.CIMOperationResponseDecoder.EXPECTED_OR_ELEMENT",
                                    "expected $0 or $1 element", "ERROR", "IRETURNVALUE");
   
         throw XmlValidationError(parser.getLine(), mlParms);
     }     }
 } }
  
Line 1032 
Line 1273 
     }     }
     else     else
     {     {
         throw XmlValidationError(parser.getLine(),  
             "expected ERROR or IRETURNVALUE element");        // l10n
   
         // throw XmlValidationError(parser.getLine(),
         //   "expected ERROR or IRETURNVALUE element");
   
         MessageLoaderParms mlParms("Client.CIMOperationResponseDecoder.EXPECTED_OR_ELEMENT",
                                    "expected $0 or $1 element", "ERROR", "IRETURNVALUE");
   
         throw XmlValidationError(parser.getLine(), mlParms);
     }     }
 } }
  
Line 1346 
Line 1595 
             {             {
                 if (gotReturnValue)                 if (gotReturnValue)
                 {                 {
                     throw XmlValidationError(parser.getLine(),  
                         "unexpected RETURNVALUE element");                    // l10n
   
                     // throw XmlValidationError(parser.getLine(),
                     //   "unexpected RETURNVALUE element");
   
                     MessageLoaderParms mlParms("Client.CIMOperationResponseDecoder.EXPECTED_ELEMENT",
                                                "expected $0 element", "RETURNVALUE");
   
                     throw XmlValidationError(parser.getLine(), mlParms);
                 }                 }
                 gotReturnValue = true;                 gotReturnValue = true;
             }             }


Legend:
Removed from v.1.38  
changed lines
  Added in v.1.38.6.3

No CVS admin address has been configured
Powered by
ViewCVS 0.9.2