Examples of MIMEPart


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

   * Identifies the root part in the list using the "start" attribute.
   * If the "start" attribute does not exist then the first part is designated the root.
   */
  public static MimePart findRootPart(String httpHeaders, Collection parts)
  {
    MimePart root = null;
    String start = Utils.getHttpHeaderSubAttribute(httpHeaders, HTTPConstants.HEADER_CONTENT_TYPE, "start");
    if (!parts.isEmpty())
    {
      // default to the first part in the collection
      root = (MimePart)parts.iterator().next();
     
      if ((start != null) && (!start.equals("")))
      {
      Iterator i = parts.iterator();
      boolean rootNotFound = true;
      while (i.hasNext() && rootNotFound)
      {
        MimePart part = (MimePart)i.next();
        String headers = part.getHeaders();
        if (headers != null)
        {
            String contentId = Utils.getMimeHeaderAttribute(headers, MIMEConstants.HEADER_CONTENT_ID);
            if (start.equals(contentId))
            {
View Full Code Here

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

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

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

    if (!partList.isEmpty())
        {
           Iterator iMimeParts = partList.iterator();
          while (iMimeParts.hasNext())
            {
            MimePart mimePart = (MimePart)iMimeParts.next();
             pw.print(mimePart.toXMLString(""));
            }
        }

        // Add end message element
        pw.println("</" + WSIConstants.ELEM_MESSAGE_CONTENT_WITH_ATTACHMENTS + ">");
View Full Code Here

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

        if (!partList.isEmpty())
        {
           Iterator iMimeParts = partList.iterator();
          while (iMimeParts.hasNext())
            {
            MimePart mimePart = (MimePart)iMimeParts.next();
             pw.print(mimePart.toXMLString(namespaceName));
            }
        }

        // Add end message element
        pw.println("</" + nsName + WSIConstants.ELEM_MESSAGE_CONTENT_WITH_ATTACHMENTS + ">");
View Full Code Here

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

      // <mimePart>
      else if (localName == WSIConstants.ELEM_MIME_PART)
      {
        // Creating a MessageMIMEPart instance
        MimePart part = new MimePartImpl();
        part.setHeaders(mimeHeaders.toString());
        part.setContent(mimeContent.toString());
        part.setBoundaryStrings((String[])boundaries.toArray(new String[0]));

        mimeParts.addPart(part);
      }

      // <messageEntry>
View Full Code Here

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

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

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

        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();
          String type_value = MIMEUtils.getMimeHeaderAttribute(
              part.getHeaders(),
              MIMEConstants.HEADER_CONTENT_TRANSFER_ENCODING);
          if (type_value != null)
          {
            if((type_value == null) || !(type_value.equalsIgnoreCase("7bit") ||
                type_value.equalsIgnoreCase("8bit") ||
View Full Code Here

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

          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
            String cid = MIMEUtils.getMimeHeaderAttribute(
                mimePart.getHeaders(), MIMEConstants.HEADER_CONTENT_ID);
            if (cid != null)
            {
              // If the header value equals the reference URI,
              // the corresponding MIME part is found
              if (cid.equals('<' + ref.substring(4) + '>'))
View Full Code Here

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

        int i = 0;
        while (iMimeParts.hasNext())
        {
          i = i + 1;
          // Getting a MIME part
          MimePart mimePart = (MimePart)iMimeParts.next();
          // Getting a part name form the Content-ID header
          String partName = MIMEUtils.getMimeHeaderAttribute(
            mimePart.getHeaders(), MIMEConstants.HEADER_CONTENT_ID);
          try
          {
            int idx = partName.indexOf("=");
            if((idx != -1) && partName.startsWith("<"))
              partName = encodePartName(partName.substring(1, idx));
          }
          catch (Exception e)
          {
            // Could not extract a part name from the header,
            // proceed with the next MIME part
            continue;
          }

          // If the part is bound by a mime:content element
          if (boundToMimeContent(extElems, partName) && message != null)
          {
            // Getting the corresponding part
            Part part = (Part) message.getParts().get(partName);
            QName refName;
            // If the part refers to global element declaration
            if (part != null && (refName = part.getElementName()) != null)
            {
              mimeContentFound = true;
              // Trying to parse part content
              Document doc = null;
              try
              {
                doc = XMLUtils.parseXML(mimePart.getContent());
              }
              catch (Exception e) {}
              // If the message is not an XML infoset, the assertion failed
              if (doc == null)
              {
View Full Code Here

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

      result = AssertionResult.RESULT_NOT_APPLICABLE;
    }
    else
    {
      MimeParts mimeParts = entryContext.getMessageEntry().getMimeParts();     
      MimePart part = mimeParts.getRootPart();
      if (part == null)
      {
        result = AssertionResult.RESULT_NOT_APPLICABLE;
      }
      else
      {
        String xmlEncoding = null;
        String charset = MIMEUtils.getMimeHeaderSubAttribute(
          part.getHeaders(),
          MIMEConstants.HEADER_CONTENT_TYPE,
          "charset");
        try
        {
          // The HTTP Content-Type header's charset value is either UTF-8 or UTF-16.
          if((charset != null) && (charset.equalsIgnoreCase("utf-8") ||
              charset.equalsIgnoreCase("utf-16")))
          {
            // Looking at the messageContent element of the logged message, either
            // (1) it has a BOM attribute which maps the charset value in the Content-Type header, or
            int bom = 0;
            if ((bom = entryContext.getMessageEntry().getBOM()) != 0)
            {
              if ((bom == WSIConstants.BOM_UTF8
                && !charset.equalsIgnoreCase("utf-8"))
                || ((bom == WSIConstants.BOM_UTF16
                  && !charset.equalsIgnoreCase("utf-16")))
                || ((bom == WSIConstants.BOM_UTF16_BIG_ENDIAN
                  && !charset.equalsIgnoreCase("utf-16"))))
              {
                throw new AssertionFailException("The BOM (" + bom +
                    ") and charset value (" + charset + ")do not match.");
              }
            }
            // (2) it has an XML declaration which matches the charset value in the Content-Type header, or
            else if (((xmlEncoding =
              Utils.getXMLEncoding(part.getContent())) != null) &&
              !xmlEncoding.equals("")) 
            {
              if(!xmlEncoding.equalsIgnoreCase(charset))
              {
                throw new AssertionFailException("The XML declaration encoding (" +
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.