Examples of MimeParts


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

    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);
View Full Code Here

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

  }
    return parseMultipartRelatedMessage(buffer, httpHeaders, encoding);
  }
  public static MimeParts parseMultipartRelatedMessage(byte[] message, String httpHeaders, String encoding)
  {
    MimeParts mimeParts = new MimePartsImpl();
    String boundary = Utils.getHttpHeaderSubAttribute(httpHeaders, HTTPConstants.HEADER_CONTENT_TYPE, "boundary");
    ArrayList parts = new ArrayList();
   
    if (boundary == null)
    {
      // assume it is a simple SOAP message
      return null;
    }
    else
    {
      String start = Utils.getHttpHeaderSubAttribute(httpHeaders, HTTPConstants.HEADER_CONTENT_TYPE, "start");
      int[] indices = Utils.getBoundaryIndices(message, boundary);
      boolean rootNotFound = true;
     
      for (int i= indices.length - 2; i>=0; i--)
      {
        try
      {
          MimePart part = new MimePartImpl();
          int index = Utils.getFirstCRLFCRLF(message, indices[i]);
          if ((index > indices[i]) && (index < indices[i+1]))
          {
            // the boundary string & mime headers (include the trailing CRLF CRLF)
          String str = new String(message, indices[i], (index - indices[i]), "US-ASCII");
          String delimiter = str.substring(0, str.indexOf("\r\n", 2) + 2);

          if (i == indices.length -2)
          {
            String endDelimiter = new String(message, indices[i + 1], message.length - indices[i + 1], "US-ASCII");
            int j = str.indexOf("\r\n", 2);
            if (j != -1)
              endDelimiter = str.substring(0, str.indexOf("\r\n", 2) + 2);
              part.setBoundaryStrings(new String[]{delimiter, endDelimiter});
            }
          else
            part.setBoundaryStrings(new String[]{delimiter});
      
          // the headers
          String headers = str.substring(delimiter.length());
            if (headers.startsWith("\r\n"))
            {
              // no headers present
              part.setHeaders("");
            }
            else
            {
              part.setHeaders(headers);
            }
           
            // the content
            String contentId = Utils.getMimeHeaderAttribute(headers, MIMEConstants.HEADER_CONTENT_ID);
            int size = indices[i+1] - (index);
           byte[] content = new byte[size];
            System.arraycopy(message, index, content, 0, size);
         
            if ((rootNotFound && (i == 0)) ||
              ((start != null) && (!start.equals("")) && (start.equals(contentId))))
            {
              // root part -- do not encode
              part.setContent(new String(content, encoding));
              mimeParts.setRootPart(part);
            }
            else
            {
              String transferEncoding =  Utils.getMimeHeaderAttribute(headers, MIMEConstants.HEADER_CONTENT_TRANSFER_ENCODING);
  
              if ((transferEncoding != null) && transferEncoding.equalsIgnoreCase("base64"))
                part.setContent(new String(content, encoding));
              else
                part.setContent(Utils.encodeBase64(content));
            }
           parts.add(part);
         }
      }
      catch (Exception e)
      {
        return null;
      }
      }
      int size = parts.size();
      for (int i = size-1; i>=0; i--)
         mimeParts.addPart((MimePart)parts.get(i));
    }
    return mimeParts;
  }
View Full Code Here

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

      byte[] buffer = new byte[i];
      inputStream.read(buffer);
      String message = new String(buffer);
      message = XMLUtils.xmlRemoveEscapedString(message);
      String headers = Utils.getHTTPHeaders(message);
      MimeParts parts = Utils.parseMultipartRelatedMessage(message, headers, Utils.JAVA_ENCODING_DEFAULT);
      System.out.println(Utils.toXMLString(parts));
  }
    catch (Exception e){}
  }
View Full Code Here

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

      result = AssertionResult.RESULT_NOT_APPLICABLE;
    }
    else
    {
      // get MIME parts
      MimeParts parts = entryContext.getMessageEntry().getMimeParts();
      if(parts.count() == 0)
      {
        result = AssertionResult.RESULT_NOT_APPLICABLE;
      }
      else
      {
        Iterator iparts = parts.getParts().iterator();
        // check each part for the Content-Transfer-Encoding field
        int i = 0;
        while (iparts.hasNext())
        {
          MimePart part = (MimePart)iparts.next();
View Full Code Here

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

      {
        throw new AssertionNotApplicableException();
      }
      // get the rrot part of a multipart/related message
      Document root = entryContext.getMessageEntryDocument();
      MimeParts mimeParts = entryContext.getMessageEntry().getMimeParts();

      // get an operation matched for the message
      BindingOperation bindingOperation = validator.getOperationMatch(
        entryContext.getEntry().getEntryType(), root);
      // if no one operation matches, the assertion is not applicable
      if (bindingOperation == null)
        throw new AssertionNotApplicableException();

      // get the corresponding extensibility elements and message
      List extElems;
      Message message;
      if (MessageEntry.TYPE_REQUEST
        .equals(entryContext.getEntry().getEntryType()))
      {
        extElems = bindingOperation.getBindingInput() == null ? null
          : bindingOperation.getBindingInput().getExtensibilityElements();
        message = bindingOperation.getOperation().getInput() == null ? null
          : bindingOperation.getOperation().getInput().getMessage();
      }
      else
      {
        extElems = bindingOperation.getBindingOutput() == null ? null
          : bindingOperation.getBindingOutput().getExtensibilityElements();
        message = bindingOperation.getOperation().getOutput() == null ? null
          : bindingOperation.getOperation().getOutput().getMessage();
      }

      // If there are no extensibility elements in the WSDL binding operation,
      // the assertion is not applicable
      if (extElems == null || extElems.size() < 1)
        throw new AssertionNotApplicableException();

      // Collecting the names of schema elements that are defined
      // with the ref:swaRef schema type
      List swaRefs = getSwaRefs((ExtensibilityElement)extElems.get(0), message);
      // If such schema elements are not found, the assertion is not applicable
      if (swaRefs.isEmpty())
        throw new AssertionNotApplicableException();

      // Going through all the schema element names
      for (int i = 0; i < swaRefs.size(); i++)
      {
        QName elemName = (QName) swaRefs.get(i);
        // Looking for such elements in the root MIME part
        NodeList elems = root.getDocumentElement().getElementsByTagNameNS(
            elemName.getNamespaceURI(), elemName.getLocalPart());
        // Going through all the ref:swaRef references
        for (int j = 0; j < elems.getLength(); j++)
        {
          Node elem = elems.item(j);
          // Getting a value of this reference
          String ref = elem.getFirstChild() == null ? null
            : elem.getFirstChild().getNodeValue();
          // If the value is invalid, the assertion failed
          if (ref == null)
            throw new AssertionFailException("The element " + elem.getNodeName()
              + " of the ref:swaRef schema type is specified, but its vaule"
              + " is invalid.");
          // If the URI does not start with the "cid:" content-id prefix
          // The assertion failed
          if (!ref.startsWith("cid:"))
          {
            throw new AssertionFailException("The URI " + ref
              + " of the ref:swaRef schema type must use the cid: prefix.");
          }
          boolean refFound = false;
          Iterator iMimeParts = mimeParts.getParts().iterator();
          // Going through all the MIME parts of the SOAP message
          while (iMimeParts.hasNext())
          {
            MimePart mimePart = (MimePart)iMimeParts.next();
            // Getting part's Content-ID header
View Full Code Here

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

      {
        throw new AssertionNotApplicableException();
      }
      else
      {
        MimeParts mimeParts = entryContext.getMessageEntry().getMimeParts();
     
        // If the message does not contain non-root MIME parts
        // the assertion is not applicable
        if (mimeParts.count()< 2)
          throw new AssertionNotApplicableException();
     
        // Getting an operation matched for a message
        BindingOperation bindingOperation = validator.getOperationMatch(
          entryContext.getEntry().getEntryType(),
          entryContext.getMessageEntryDocument());
        // If no one operation matches, the assertion is not applicable
        if (bindingOperation == null)
        throw new AssertionNotApplicableException();
        // Getting the corresponding extensibility elements and message
        List extElems;
        Message message;
        if (MessageEntry.TYPE_REQUEST
          .equals(entryContext.getEntry().getEntryType()))
        {
          extElems = bindingOperation.getBindingInput() == null ? null
            : bindingOperation.getBindingInput().getExtensibilityElements();
          message = bindingOperation.getOperation().getInput() == null ? null
            : bindingOperation.getOperation().getInput().getMessage();
        }
        else
        {
          extElems = bindingOperation.getBindingOutput() == null ? null
            : bindingOperation.getBindingOutput().getExtensibilityElements();
          message = bindingOperation.getOperation().getOutput() == null ? null
            : bindingOperation.getOperation().getOutput().getMessage();
        }
        // A variable that indicates a binding contains at least one
        // mime:content element that refers to global element declaration
        boolean mimeContentFound = false;
        // Going through the message MIME parts
        Iterator iMimeParts = mimeParts.getParts().iterator();
        int i = 0;
        while (iMimeParts.hasNext())
        {
          i = i + 1;
          // Getting a MIME part
View Full Code Here

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

    {
      result = AssertionResult.RESULT_NOT_APPLICABLE;
    }
    else
    {
      MimeParts mimeParts = entryContext.getMessageEntry().getMimeParts();     
      MimePart part = mimeParts.getRootPart();
      if (part == null)
      {
        result = AssertionResult.RESULT_NOT_APPLICABLE;
      }
      else
View Full Code Here

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

      {
        throw new AssertionNotApplicableException();
      }
     
      // get message mime parts
      MimeParts mimeParts = entryContext.getMessageEntry().getMimeParts();
     
      BindingOperation bindingOperation = validator.getOperationMatch(
          entryContext.getEntry().getEntryType(),
          entryContext.getMessageEntryDocument());

      // If there is no matched operation, the assertion is not applicable
      if (bindingOperation == null)
        throw new AssertionNotApplicableException();

      // Finding operation extensibility elems
      // in the binding depending on message type
      List extElems = null;
      if (entryContext.getMessageEntry().getType().equals(
        MessageEntry.TYPE_REQUEST)
        && bindingOperation.getBindingInput() != null)
      {
        extElems = bindingOperation
          .getBindingInput().getExtensibilityElements();
      }
      else if (entryContext.getMessageEntry().getType().equals(
        MessageEntry.TYPE_RESPONSE)
        && bindingOperation.getBindingOutput() != null)
      {
        extElems = bindingOperation
          .getBindingOutput().getExtensibilityElements();
      }
      // check list for the first element
      if((extElems == null) || (extElems.size() == 0) ||
         !(extElems.get(0) instanceof MIMEMultipartRelated))
        throw new AssertionNotApplicableException();
     
      // get list mime parts from definition
      MIMEMultipartRelated mime = (MIMEMultipartRelated) extElems.get(0);
      List parts = mime.getMIMEParts();
     
      // skip root part
      for (int i = 1; i < parts.size(); i++)
      {
        String partName = getMIMEContentPart((MIMEPart) parts.get(i));
        // find the corresponding MIME part
        if (findMIMEPart(mimeParts.getParts(), partName) == null)
        {           
          throw new AssertionFailException("The corresponding binding " +
              "operation \"" + bindingOperation.getName() +
              "\" does not contain part \"" + partName + "\"");
        }
View Full Code Here

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

      result = AssertionResult.RESULT_NOT_APPLICABLE;
    }
    else
    {
      // get MIME parts
      MimeParts parts = entryContext.getMessageEntry().getMimeParts();
      if(parts.count() == 0)
      {
        result = AssertionResult.RESULT_NOT_APPLICABLE;
      }
      else
      {
        // check each part for the encoding match
        Iterator iparts = parts.getParts().iterator();
        int i = 0;
        MimePart root = parts.getRootPart();
        while (iparts.hasNext())
        {
          i = 1;
          try
          {
View Full Code Here

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

      {
        throw new AssertionNotApplicableException();
      }
     
      // get message mime parts
      MimeParts mimeParts = entryContext.getMessageEntry().getMimeParts();
     
      BindingOperation bindingOperation = validator.getOperationMatch(
          entryContext.getEntry().getEntryType(),
          entryContext.getMessageEntryDocument());

      // If there is no matched operation, the assertion is not applicable
      if (bindingOperation == null)
        throw new AssertionNotApplicableException();

      // Finding operation extensibility elems
      // in the binding depending on message type
      List extElems = null;
      if (entryContext.getMessageEntry().getType().equals(
        MessageEntry.TYPE_REQUEST)
        && bindingOperation.getBindingInput() != null)
      {
        extElems = bindingOperation
          .getBindingInput().getExtensibilityElements();
      }
      else if (entryContext.getMessageEntry().getType().equals(
        MessageEntry.TYPE_RESPONSE)
        && bindingOperation.getBindingOutput() != null)
      {
        extElems = bindingOperation
          .getBindingOutput().getExtensibilityElements();
      }
      // check list for the first element
      if((extElems == null) || (extElems.size() == 0) ||
         !(extElems.get(0) instanceof MIMEMultipartRelated))
        throw new AssertionNotApplicableException();
     
      // get list mime parts from definition
      MIMEMultipartRelated mime = (MIMEMultipartRelated) extElems.get(0);
      List parts = mime.getMIMEParts();

      if(mimeParts.getRootPart() == null || mimeParts.count()==0)
        throw new AssertionNotApplicableException();
      // skip root part
      for (int i = 1; i < parts.size(); i++)
      {
        String partName = getMIMEContentPart((MIMEPart) parts.get(i));
        // find the corresponding MIME part
        if (findMIMEPart(mimeParts.getParts(), partName) == null)
        {           
          throw new AssertionFailException("The corresponding binding " +
              "operation \"" + bindingOperation.getName() +
              "\" does not contain part \"" + partName + "\"");
        }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.