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

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


    try
    {
      // Parse all documents
      if(request.isMimeContent())
      {
        MimePart part = request.getMimeParts().getRootPart();
        if ((part != null) && (part.getContent().length() > 0))
          requestDocument = XMLUtils.parseXML(part.getContent());
      }
      else
      {
        if (request.getMessage().length() > 0)
          requestDocument = XMLUtils.parseXML(request.getMessage());
      }

      if (response != null) {
          if(response.isMimeContent())
          {
            MimePart part = response.getMimeParts().getRootPart();
            if ((part != null) && (part.getContent().length() > 0))
              responseDocument = XMLUtils.parseXML(part.getContent());
          }
          else
          {
            if (response.getMessage().length() > 0)
              responseDocument = XMLUtils.parseXML(response.getMessage());
View Full Code Here


   * 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

     
      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

    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

        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

      // <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

         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

        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

          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

        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

TOP

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

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.