Examples of MimePartImpl


Examples of org.eclipse.wst.wsi.internal.core.log.impl.MimePartImpl

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