Package org.eclipse.wst.wsi.internal.core.log

Examples of org.eclipse.wst.wsi.internal.core.log.MessageEntry


   * @throws WSIException is there is a problem adding log entries.
 
   */
  public synchronized void writeFromQueue() throws WSIException
  {
    MessageEntry requestMessageEntry = null;
    MessageEntry responseMessageEntry = null;
    boolean responseFound = false;

    // Create array that will contain list of index to remove from request list
    int[] requestIndexList = new int[requestList.size()];
    int reqIndexCount = 0;

    synchronized (listLock)
    {
      // If there are entries in the request queue,
      // then try to match them with entries in the response queue
      for (int reqIndex = 0; reqIndex < requestList.size(); reqIndex++)
      {
        // Get request log entry
        requestMessageEntry = (MessageEntry) requestList.elementAt(reqIndex);

        // Check each response log entry to see if the conversationId matches
        responseFound = false;
        for (int respIndex = 0;
          respIndex < responseList.size() && !responseFound;
          respIndex++)
        {
          // Get response log entry
          responseMessageEntry =
            (MessageEntry) responseList.elementAt(respIndex);

          // If the request and response have the same conversationId,
          // then write them out to the log file
          if (requestMessageEntry
            .getConversationId()
            .equals(responseMessageEntry.getConversationId()))
          {
            responseFound = true;

            // Set the id for the log entries
            requestMessageEntry.setId(getNextMessageId());
            responseMessageEntry.setId(getNextMessageId());

            // Write out request and then response
            //==== SS start : what this line is used for??? - causes memory leak, as no removeLogEntry is called ====
            //            log.addLogEntry(requestMessageEntry);
            //==== SS end ===
            StringReader requestReader =
              new StringReader(requestMessageEntry.toXMLString(""));
            logWriter.write(requestReader);

            // Display message
            printMessage(requestMessageEntry);

            // Write out response
            //==== SS start : what this line is used for??? - causes memory leak, as no removeLogEntry is called ====
            //            log.addLogEntry(responseMessageEntry);
            //==== SS end ===
            StringReader responseReader =
              new StringReader(responseMessageEntry.toXMLString(""));
            logWriter.write(responseReader);

            // Display message
            printMessage(responseMessageEntry);

View Full Code Here


    StringBuffer messageBuffer,
    int bom,
    String encoding)
    throws WSIException
  {
    MessageEntry messageEntry = null;

    // Create message entry
    messageEntry =
      createMessageEntry(
        conversationID,
View Full Code Here

    int bom,
    String encoding)
    throws WSIException
  {
    // Create log entry object
    MessageEntry messageEntry = monitor.getLog().createLogEntry();

    // Set input information in log entry
    // NOTE:  The ID is set just before the log entry is written to the log file in LogEntryQueue
    //logEntry.setId(id);
    messageEntry.setConversationId(String.valueOf(conversationID));
    messageEntry.setType(messageType);
    messageEntry.setTimestamp(timestamp);
    messageEntry.setSenderHostAndPort(senderHostAndPort);
    messageEntry.setReceiverHostAndPort(receiverHostAndPort);
    messageEntry.setEncoding(encoding);

    // Get HTTP headers from full message
    String httpHeaders = Utils.getHTTPHeaders(message);
    messageEntry.setHTTPHeaders(httpHeaders);
 
   if (Utils.isMultipartRelatedMessage(httpHeaders))
    {
      MimeParts mimeParts = Utils.parseMultipartRelatedMessage(message, httpHeaders, encoding);
      if (mimeParts == null)
      {
        // problem creating Mimeparts -- treat it as simple SOAP message
        String content = Utils.getContent(message);
        messageEntry.setMessage(content);
        messageEntry.setMimeContent(false);
      }
      else
      {
          messageEntry.setMimeParts(mimeParts);
          messageEntry.setMimeContent(true);
      }
    }
    else
    {
      // Get the message content
      String content = Utils.getContent(message);
      messageEntry.setMessage(content);
      messageEntry.setMimeContent(false);
    }

    // Set the BOM, if there is one
    if (bom != 0)
      messageEntry.setBOM(bom);

    return messageEntry;
  }
View Full Code Here

      result = AssertionResult.RESULT_NOT_APPLICABLE;
    }
    else
    {
      //Get the response message check the faultcode.
      MessageEntry logEntryResponse = entryContext.getResponse();
      if (logEntryResponse != null)
      {
        responseMessage = logEntryResponse.getMessage();

        Document targetDoc = XMLUtils.parseXML(responseMessage);
        NodeList faultCodes = targetDoc.getElementsByTagName("faultcode");
        //                    targetDoc.getElementsByTagNameNS(WSIConstants.NS_URI_SOAP, "faultcode");
View Full Code Here

    TestAssertion testAssertion,
    EntryContext entryContext)
    throws WSIException
  {
    // check request for the "text/xml" content type
    MessageEntry request = entryContext.getRequest();
    String headers = request.getHTTPHeaders();
    String contentType = (String) HTTPUtils.getHttpHeaderTokens(headers, ":")
      .get(HTTPConstants.HEADER_CONTENT_TYPE.toUpperCase());

    // Get HTTP status code
    String httpStatus =
View Full Code Here

      {
        // Assumption: Related messages are sequentially available in the message log.
        if (MessageEntry.TYPE_REQUEST.equalsIgnoreCase(type))
        {
          // Create log entry
          MessageEntry messageEntryRequest =
            createMessageEntry(
                id,
                conversationID,
                type,
                timestamp,
                senderHostAndPort.toString(),
                receiverHostAndPort.toString(),
                messageContent == null ? "" : messageContent.toString(),
                httpHeaders.toString(),
                mimeParts,
                entryElementLocation);

          // Add log entry to the list
          messageEntryList.add(messageEntryRequest);
          // Request is now processed only when the response is received.
        }

        else if (MessageEntry.TYPE_RESPONSE.equalsIgnoreCase(type))
        {
          // Create log entry
          MessageEntry messageEntryResponse =
            createMessageEntry(
                id,
                conversationID,
                type,
                timestamp,
                senderHostAndPort.toString(),
                receiverHostAndPort.toString(),
                messageContent == null ? "" : messageContent.toString(),
                httpHeaders.toString(),
                mimeParts,
                entryElementLocation);

          if (logEntryHandler != null)
          {
            // look up the request message
            // ISSUE : need to throw & catch a nullpointerexception in here...
            MessageEntry messageEntryRequest = findRelatedRequest(messageEntryResponse);

            if (messageEntryRequest != null)
            {
              if (!isMessageEncrypted(messageEntryRequest.getMessage()) &&
                  !isMessageEncrypted(messageEntryResponse.getMessage()))
              {
          if (!omitRequest(messageEntryRequest))
          {
            // Create entry
            // ADD: Need to create entry from report
            //Entry entry = this.reporter.getReport().createEntry();
            Entry entry = new EntryImpl();
            entry.setEntryType(
                  EntryType.getEntryType(MessageValidator.TYPE_MESSAGE_REQUEST));
            entry.setReferenceID(messageEntryRequest.getId());
            entry.setEntryDetail(messageEntryRequest);
 
            // Create the context for the request-response pair
            EntryContext requestTargetContext =
                 new EntryContext(
View Full Code Here

      //if (msgValidator!=null)
      //logEntryList.clear();
       
        /* Process all remaining requests in the messageEntryList */
        for (int i = 0; i < messageEntryList.size(); i++) {
            MessageEntry logEntry = (MessageEntry) messageEntryList.get(i);
            if (!omitRequest(logEntry))
            {
              Entry entry = new EntryImpl();
              entry.setEntryType(EntryType.getEntryType(
                    MessageValidator.TYPE_MESSAGE_REQUEST));
              entry.setReferenceID(logEntry.getId());
              entry.setEntryDetail(logEntry);
              EntryContext requestTargetContext =
                new EntryContext(entry, logEntry, null);
              if (requestTargetContext != null)
                processLogEntry(requestTargetContext);
View Full Code Here

      if (logEntryResponse != null)
      {
        for (int entry = messageEntryList.size() - 1; entry >= 0; entry--)
        {
          // Get the log entry of the matching request
          MessageEntry logEntry = (MessageEntry) messageEntryList.get(entry);
          // Ignore own entry
          if (!logEntryResponse.equals(logEntry))
          {
            if (logEntryResponse
              .getConversationId()
              .equals(logEntry.getConversationId()))
            {
              // found the most recently read message with the same conversationID.
              // From above, this should be the corresponding request. Check as far as possible.
              if (logEntry.getType().equals(MessageEntry.TYPE_REQUEST))
              {
                messageEntryList.remove(entry);
                return logEntry;
              }
              else
View Full Code Here

      String httpHeaders,
      MimeParts mimeParts,
      ElementLocation elementLocation)
    {
      // Create log entry
      MessageEntry messageEntry = new MessageEntryImpl();
      messageEntry.setId(id);
      messageEntry.setConversationId(conversationID);
      messageEntry.setType(type);
      messageEntry.setTimestamp(timestamp);
      messageEntry.setSenderHostAndPort(senderIPPort);
      messageEntry.setReceiverHostAndPort(receiverIPPort);
      messageEntry.setHTTPHeaders(httpHeaders);
      messageEntry.setBOM(bom);
      messageEntry.setElementLocation(elementLocation);

      String encoding = null;
      if (mimeParts == null)
      {
        // Get the encoding for this message content
        encoding = Utils.getXMLEncoding(messageContent);
        messageEntry.setMessage(messageContent);
         messageEntry.setMimeContent(false);
      }
      else
      {
         messageEntry.setMimeParts(mimeParts);
         MimePart root = Utils.findRootPart(httpHeaders, mimeParts.getParts());
         if (root != null)
         {
          // Get the encoding for this message content
          encoding = Utils.getXMLEncoding(root.getContent());
          mimeParts.setRootPart(root);
         }
       // else empty body
         messageEntry.setMimeContent(true);
      }
      if ((encoding == null) || (encoding.equals("")))
         encoding = WSIConstants.DEFAULT_XML_ENCODING;
      messageEntry.setEncoding(encoding);

      return messageEntry;
    }
View Full Code Here

    TestAssertion testAssertion,
    EntryContext entryContext)
    throws WSIException
  {

    MessageEntry request = entryContext.getRequest();
    String requestHeaders = request.getHTTPHeaders();

    // Get HTTP status code
    String httpStatus =
      Utils.getHTTPStatusCode(
        entryContext.getMessageEntry().getHTTPHeaders());
View Full Code Here

TOP

Related Classes of org.eclipse.wst.wsi.internal.core.log.MessageEntry

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.