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

Diff for /pegasus/src/Pegasus/ExportServer/CIMExportRequestDecoder.cpp between version 1.56 and 1.57

version 1.56, 2005/07/08 14:51:15 version 1.57, 2005/07/26 21:42:21
Line 37 
Line 37 
 //                              Seema Gupta (gseema@in.ibm.com for PEP135) //                              Seema Gupta (gseema@in.ibm.com for PEP135)
 //              David Dillard, VERITAS Software Corp. //              David Dillard, VERITAS Software Corp.
 //                  (david.dillard@veritas.com) //                  (david.dillard@veritas.com)
   //              John Alex, IBM (johnalex@us.ibm.com) - Bug#2290
 // //
 //%///////////////////////////////////////////////////////////////////////////// //%/////////////////////////////////////////////////////////////////////////////
  
Line 77 
Line 78 
  
 void CIMExportRequestDecoder::sendResponse( void CIMExportRequestDecoder::sendResponse(
    Uint32 queueId,    Uint32 queueId,
    Array<char>& message)      Array<char>& message,
       Boolean closeConnect)
 { {
    MessageQueue* queue = MessageQueue::lookup(queueId);    MessageQueue* queue = MessageQueue::lookup(queueId);
  
    if (queue)    if (queue)
    {    {
       HTTPMessage* httpMessage = new HTTPMessage(message);       HTTPMessage* httpMessage = new HTTPMessage(message);
         httpMessage->setCloseConnect(closeConnect);
       queue->enqueue(httpMessage);       queue->enqueue(httpMessage);
    }    }
 } }
Line 93 
Line 96 
    HttpMethod httpMethod,    HttpMethod httpMethod,
    const String& messageId,    const String& messageId,
    const String& eMethodName,    const String& eMethodName,
    const CIMException& cimException)     const CIMException& cimException,
      Boolean closeConnect)
 { {
     Array<char> message;     Array<char> message;
     message = XmlWriter::formatSimpleEMethodErrorRspMessage(     message = XmlWriter::formatSimpleEMethodErrorRspMessage(
Line 102 
Line 106 
         httpMethod,         httpMethod,
         cimException);         cimException);
  
     sendResponse(queueId, message);      sendResponse(queueId, message,closeConnect);
 } }
  
 void CIMExportRequestDecoder::sendHttpError( void CIMExportRequestDecoder::sendHttpError(
    Uint32 queueId,    Uint32 queueId,
    const String& status,    const String& status,
    const String& cimError,    const String& cimError,
    const String& messageBody)     const String& messageBody,
      Boolean closeConnect)
 { {
     Array<char> message;     Array<char> message;
     message = XmlWriter::formatHttpErrorRspMessage(     message = XmlWriter::formatHttpErrorRspMessage(
Line 117 
Line 122 
         cimError,         cimError,
         messageBody);         messageBody);
  
     sendResponse(queueId, message);      sendResponse(queueId, message,closeConnect);
 } }
  
 void CIMExportRequestDecoder::handleEnqueue(Message *message) void CIMExportRequestDecoder::handleEnqueue(Message *message)
Line 188 
Line 193 
       userName = httpMessage->authInfo->getAuthenticatedUser();       userName = httpMessage->authInfo->getAuthenticatedUser();
    }    }
  
      Boolean closeConnect = httpMessage->getCloseConnect();
      Tracer::trace(
          TRC_HTTP,
          Tracer::LEVEL3,
          "CIMOperationRequestDecoder::handleHTTPMessage()- httpMessage->getCloseConnect() returned %d",httpMessage->getCloseConnect());
   
    // Parse the HTTP message:    // Parse the HTTP message:
  
    String startLine;    String startLine;
Line 228 
Line 239 
        sendHttpError(        sendHttpError(
           queueId,           queueId,
           HTTP_STATUS_NOTIMPLEMENTED,           HTTP_STATUS_NOTIMPLEMENTED,
           "Only POST and M-POST are implemented" );             "Only POST and M-POST are implemented",
              String::EMPTY,
              closeConnect);
        return;        return;
    }    }
    //</bug>    //</bug>
Line 240 
Line 253 
    if( (httpMethod == HTTP_METHOD_M_POST) &&    if( (httpMethod == HTTP_METHOD_M_POST) &&
         (httpVersion == "HTTP/1.0") )         (httpVersion == "HTTP/1.0") )
    {    {
        sendHttpError(queueId,         sendHttpError(
              queueId,
                 HTTP_STATUS_BADREQUEST,                 HTTP_STATUS_BADREQUEST,
                 "M-POST method is not valid with version 1.0" );             "M-POST method is not valid with version 1.0",
              String::EMPTY,
              closeConnect);
        return;        return;
    }    }
    //</bug>    //</bug>
Line 275 
Line 291 
             "ExportServer.CIMExportRequestDecoder.MISSING_HOST_HEADER",             "ExportServer.CIMExportRequestDecoder.MISSING_HOST_HEADER",
             "HTTP request message lacks a Host header field.");             "HTTP request message lacks a Host header field.");
          String msg(MessageLoader::getMessage(parms));          String msg(MessageLoader::getMessage(parms));
          sendHttpError(queueId, HTTP_STATUS_BADREQUEST, "", msg);           sendHttpError(
                queueId,
                HTTP_STATUS_BADREQUEST,
                "",
                msg,
                closeConnect);
          return;          return;
       }       }
    }    }
Line 291 
Line 312 
    // PEGASUS_ASSERT(exportHeaderFound);    // PEGASUS_ASSERT(exportHeaderFound);
    if (!exportHeaderFound)    if (!exportHeaderFound)
    {    {
         sendHttpError(queueId,          sendHttpError(
               queueId,
                     HTTP_STATUS_BADREQUEST,                     HTTP_STATUS_BADREQUEST,
                     "Export header not found");              "Export header not found",
               String::EMPTY,
               closeConnect);
         return;         return;
    }    }
    // </bug>    // </bug>
Line 307 
Line 331 
       //     status "400 Bad Request". The CIM Server MUST include a       //     status "400 Bad Request". The CIM Server MUST include a
       //     CIMError header in the response with a value of       //     CIMError header in the response with a value of
       //     unsupported-operation.       //     unsupported-operation.
       sendHttpError(queueId,        sendHttpError(
             queueId,
                     HTTP_STATUS_BADREQUEST,                     HTTP_STATUS_BADREQUEST,
                     "unsupported-operation");            "unsupported-operation",
             String::EMPTY,
             closeConnect);
       return;       return;
    }    }
  
Line 325 
Line 352 
       //     CIMExportBatch header is present, but the Listener does not       //     CIMExportBatch header is present, but the Listener does not
       //     support Multiple Exports, then it MUST fail the request and       //     support Multiple Exports, then it MUST fail the request and
       //     return a status of "501 Not Implemented".       //     return a status of "501 Not Implemented".
       sendHttpError(queueId,        sendHttpError(
             queueId,
                     HTTP_STATUS_NOTIMPLEMENTED,                     HTTP_STATUS_NOTIMPLEMENTED,
                     "multiple-requests-unsupported");            "multiple-requests-unsupported",
             String::EMPTY,
             closeConnect);
       return;       return;
    }    }
  
Line 346 
Line 376 
       if (cimExportMethod == String::EMPTY)       if (cimExportMethod == String::EMPTY)
       {       {
          // This is not a valid value, and we use EMPTY to mean "absent"          // This is not a valid value, and we use EMPTY to mean "absent"
          sendHttpError(queueId, HTTP_STATUS_BADREQUEST, "header-mismatch");           sendHttpError(
                queueId,
                HTTP_STATUS_BADREQUEST,
                "header-mismatch",
                String::EMPTY,
                closeConnect);
          return;          return;
       }       }
    }    }
Line 392 
Line 427 
         Thread::clearLanguages();         Thread::clearLanguages();
         MessageLoaderParms msgParms("ExportServer.CIMExportRequestDecoder.REQUEST_NOT_VALID","request-not-valid");         MessageLoaderParms msgParms("ExportServer.CIMExportRequestDecoder.REQUEST_NOT_VALID","request-not-valid");
         String msg(MessageLoader::getMessage(msgParms));         String msg(MessageLoader::getMessage(msgParms));
                 sendHttpError(queueId, HTTP_STATUS_BADREQUEST,          sendHttpError(
               queueId,
               HTTP_STATUS_BADREQUEST,
                                         msg,                                         msg,
                     e.getMessage());              e.getMessage(),
               closeConnect);
         return;         return;
    }    }
 // l10n end // l10n end
Line 423 
Line 461 
              String::equalNoCase(cimContentType, "text/xml; charset=\"utf-8\"") ||              String::equalNoCase(cimContentType, "text/xml; charset=\"utf-8\"") ||
              contentTypeHeaderFound))              contentTypeHeaderFound))
    {    {
         sendHttpError(queueId, HTTP_STATUS_BADREQUEST, "header-mismatch",          sendHttpError(
                        "CIMContentType value syntax error.");              queueId,
               HTTP_STATUS_BADREQUEST,
               "header-mismatch",
               "CIMContentType value syntax error.",
               closeConnect);
        return;        return;
    }    }
    // Validating content falls within UTF8    // Validating content falls within UTF8
Line 436 
Line 478 
        {        {
            if (!(isUTF8((char *)&content[count])))            if (!(isUTF8((char *)&content[count])))
            {            {
                sendHttpError(queueId, HTTP_STATUS_BADREQUEST, "request-not-valid",                 sendHttpError(
                        "Invalid UTF-8 character detected.");                     queueId,
                      HTTP_STATUS_BADREQUEST,
                      "request-not-valid",
                      "Invalid UTF-8 character detected.",
                      closeConnect);
                return;                return;
            }            }
            UTF8_NEXT(content,count);            UTF8_NEXT(content,count);
Line 447 
Line 493 
    // If it is a method call, then dispatch it to be handled:    // If it is a method call, then dispatch it to be handled:
  
 // l10n // l10n
    handleMethodRequest(queueId, httpMethod, content, requestUri,     handleMethodRequest(
                        cimProtocolVersion, cimExportMethod, userName,         queueId,
                        acceptLanguages, contentLanguages);         httpMethod,
          content,
          requestUri,
          cimProtocolVersion,
          cimExportMethod,
          userName,
          acceptLanguages,
          contentLanguages,
          closeConnect);
 } }
  
  
Line 462 
Line 516 
    const String& cimExportMethodInHeader,    const String& cimExportMethodInHeader,
    const String& userName,    const String& userName,
         const AcceptLanguages& httpAcceptLanguages, // l10n         const AcceptLanguages& httpAcceptLanguages, // l10n
         const ContentLanguages& httpContentLanguages)      const ContentLanguages& httpContentLanguages,
       Boolean closeConnect)
 { {
 // l10n // l10n
         // Set the Accept-Language into the thread for this service.         // Set the Accept-Language into the thread for this service.
Line 475 
Line 530 
    //    //
    if (_serverTerminating)    if (_serverTerminating)
    {    {
       sendHttpError(queueId, HTTP_STATUS_SERVICEUNAVAILABLE,        sendHttpError(
             queueId,
             HTTP_STATUS_SERVICEUNAVAILABLE,
                     String::EMPTY,                     String::EMPTY,
                     "CIM Listener is shutting down.");            "CIM Listener is shutting down.",
             closeConnect);
       return;       return;
    }    }
  
Line 510 
Line 568 
  
       if (strcmp(cimVersion, "2.0") != 0)       if (strcmp(cimVersion, "2.0") != 0)
       {       {
          sendHttpError(queueId,           sendHttpError(
                queueId,
                        HTTP_STATUS_NOTIMPLEMENTED,                        HTTP_STATUS_NOTIMPLEMENTED,
                        "unsupported-cim-version");               "unsupported-cim-version",
                String::EMPTY,
                closeConnect);
          return;          return;
       }       }
  
Line 539 
Line 600 
  
       if (!dtdVersionAccepted)       if (!dtdVersionAccepted)
       {       {
          sendHttpError(queueId,           sendHttpError(
                queueId,
                        HTTP_STATUS_NOTIMPLEMENTED,                        HTTP_STATUS_NOTIMPLEMENTED,
                        "unsupported-dtd-version");               "unsupported-dtd-version",
                String::EMPTY,
                closeConnect);
          return;          return;
       }       }
  
Line 568 
Line 632 
  
       if (!String::equalNoCase(protocolVersion, cimProtocolVersionInHeader))       if (!String::equalNoCase(protocolVersion, cimProtocolVersionInHeader))
       {       {
          sendHttpError(queueId,           sendHttpError(
                queueId,
                        HTTP_STATUS_BADREQUEST,                        HTTP_STATUS_BADREQUEST,
                        "header-mismatch");               "header-mismatch",
                String::EMPTY,
                closeConnect);
          return;          return;
       }       }
  
Line 600 
Line 667 
       if (!protocolVersionAccepted)       if (!protocolVersionAccepted)
       {       {
          // See Specification for CIM Operations over HTTP section 4.3          // See Specification for CIM Operations over HTTP section 4.3
          sendHttpError(queueId,           sendHttpError(
                queueId,
                        HTTP_STATUS_NOTIMPLEMENTED,                        HTTP_STATUS_NOTIMPLEMENTED,
                        "unsupported-protocol-version");               "unsupported-protocol-version",
                String::EMPTY,
                closeConnect);
   
          return;          return;
       }       }
  
Line 610 
Line 681 
       {       {
          // We wouldn't have gotten here if CIMExportBatch header was          // We wouldn't have gotten here if CIMExportBatch header was
          // specified, so this must be indicative of a header mismatch          // specified, so this must be indicative of a header mismatch
          sendHttpError(queueId, HTTP_STATUS_BADREQUEST, "header-mismatch");           sendHttpError(
                queueId,
                HTTP_STATUS_BADREQUEST,
                "header-mismatch",
                String::EMPTY,
                closeConnect);
          return;          return;
          // Future: When MULTIEXPREQ is supported, must ensure CIMExportMethod          // Future: When MULTIEXPREQ is supported, must ensure CIMExportMethod
          // header is absent, and CIMExportBatch header is present.          // header is absent, and CIMExportBatch header is present.
Line 672 
Line 748 
       if (!String::equalNoCase(cimExportMethodName, cimExportMethodInHeader))       if (!String::equalNoCase(cimExportMethodName, cimExportMethodInHeader))
       {       {
          // ATTN-RK-P3-20020404: How to decode cimExportMethodInHeader?          // ATTN-RK-P3-20020404: How to decode cimExportMethodInHeader?
          sendHttpError(queueId, HTTP_STATUS_BADREQUEST, "header-mismatch");           sendHttpError(
                queueId,
                HTTP_STATUS_BADREQUEST,
                "header-mismatch",
                String::EMPTY,
                closeConnect);
          return;          return;
       }       }
  
Line 708 
Line 789 
             httpMethod,             httpMethod,
             messageId,             messageId,
             cimExportMethodName,             cimExportMethodName,
             e);               e,
                closeConnect);
  
          return;          return;
       }       }
Line 734 
Line 816 
        Logger::put(Logger::ERROR_LOG, System::CIMSERVER, Logger::TRACE,        Logger::put(Logger::ERROR_LOG, System::CIMSERVER, Logger::TRACE,
                    "CIMExportRequestDecoder::handleMethodRequest - XmlValidationError exception has occurred. Message: $0",e.getMessage());                    "CIMExportRequestDecoder::handleMethodRequest - XmlValidationError exception has occurred. Message: $0",e.getMessage());
  
       sendHttpError(queueId, HTTP_STATUS_BADREQUEST, "request-not-valid",        sendHttpError(
                     e.getMessage());            queueId,
             HTTP_STATUS_BADREQUEST,
             "request-not-valid",
             e.getMessage(),
             closeConnect);
       return;       return;
    }    }
    catch (XmlSemanticError& e)    catch (XmlSemanticError& e)
Line 743 
Line 829 
        Logger::put(Logger::ERROR_LOG, System::CIMSERVER, Logger::TRACE,        Logger::put(Logger::ERROR_LOG, System::CIMSERVER, Logger::TRACE,
                    "CIMExportRequestDecoder::handleMethodRequest - XmlSemanticError exception has occurred. Message: $0",e.getMessage());                    "CIMExportRequestDecoder::handleMethodRequest - XmlSemanticError exception has occurred. Message: $0",e.getMessage());
       // ATTN-RK-P2-20020404: Is this the correct response for these errors?       // ATTN-RK-P2-20020404: Is this the correct response for these errors?
       sendHttpError(queueId, HTTP_STATUS_BADREQUEST, "request-not-valid",        sendHttpError(
                     e.getMessage());            queueId,
             HTTP_STATUS_BADREQUEST,
             "request-not-valid",
             e.getMessage(),
             closeConnect);
       return;       return;
    }    }
    catch (XmlException& e)    catch (XmlException& e)
Line 752 
Line 842 
        Logger::put(Logger::ERROR_LOG, System::CIMSERVER, Logger::TRACE,        Logger::put(Logger::ERROR_LOG, System::CIMSERVER, Logger::TRACE,
                    "CIMExportRequestDecoder::handleMethodRequest - XmlException has occurred. Message: $0",e.getMessage());                    "CIMExportRequestDecoder::handleMethodRequest - XmlException has occurred. Message: $0",e.getMessage());
  
       sendHttpError(queueId, HTTP_STATUS_BADREQUEST, "request-not-well-formed",        sendHttpError(
                     e.getMessage());            queueId,
             HTTP_STATUS_BADREQUEST,
             "request-not-well-formed",
             e.getMessage(),
             closeConnect);
       return;       return;
    }    }
    catch (Exception& e)    catch (Exception& e)
Line 761 
Line 855 
       // Don't know why I got this exception.  Seems like a bad thing.       // Don't know why I got this exception.  Seems like a bad thing.
       // Any exceptions we're expecting should be caught separately and       // Any exceptions we're expecting should be caught separately and
       // dealt with appropriately.  This is a last resort.       // dealt with appropriately.  This is a last resort.
       sendHttpError(queueId, HTTP_STATUS_INTERNALSERVERERROR, String::EMPTY,        sendHttpError(
                     e.getMessage());            queueId,
             HTTP_STATUS_INTERNALSERVERERROR,
             String::EMPTY,
             e.getMessage(),
             closeConnect);
       return;       return;
    }    }
    catch (...)    catch (...)
Line 770 
Line 868 
       // Don't know why I got whatever this is.  Seems like a bad thing.       // Don't know why I got whatever this is.  Seems like a bad thing.
       // Any exceptions we're expecting should be caught separately and       // Any exceptions we're expecting should be caught separately and
       // dealt with appropriately.  This is a last resort.       // dealt with appropriately.  This is a last resort.
       sendHttpError(queueId, HTTP_STATUS_INTERNALSERVERERROR);        sendHttpError(
             queueId,
             HTTP_STATUS_INTERNALSERVERERROR,
             String::EMPTY,
             String::EMPTY,
             closeConnect);
       return;       return;
    }    }
  
Line 795 
Line 898 
         }         }
 // l10n end // l10n end
  
      request->setCloseConnect(closeConnect);
   
    _outputQueue->enqueue(request.release());    _outputQueue->enqueue(request.release());
 } }
  


Legend:
Removed from v.1.56  
changed lines
  Added in v.1.57

No CVS admin address has been configured
Powered by
ViewCVS 0.9.2