Package javax.mail.internet

Examples of javax.mail.internet.ContentType


        String v;
        if ((v = part.getContentType()) != null) {
            // content type as-is
            addAttribute("content-type", v);
            try {
                ContentType ct = new ContentType(v);
                String s;

                // primary part only
                s = ct.getPrimaryType();
                if (s != null) {
                    addAttribute("primary-type", s.toLowerCase());
                }

                // secondary part only
                s = ct.getSubType();
                if (s != null) {
                    addAttribute("secondary-type", s.toLowerCase());
                }

                // primary part '/' secondary part
                s = ct.getBaseType();
                if (s != null) {
                    addAttribute("base-type", s.toLowerCase());
                }

                // list of parameters : parameter-name parameter-value
                ParameterList pl = ct.getParameterList();
                Enumeration names = pl.getNames();
                while (names.hasMoreElements()) {
                    String key = (String) names.nextElement();
                    String value = pl.get(key);
                    addAttribute(key, value);
View Full Code Here


  public SoapMessage read(MimeMessage mime) throws Exception {
    final Object content = mime.getContent();
    if (content instanceof MimeMultipart) {
      MimeMultipart multipart = (MimeMultipart) content;
      ContentType type = new ContentType(mime.getContentType());
      String contentId = type.getParameter("start");
      // Get request
      MimeBodyPart contentPart = null;
            if (contentId != null) {
                contentPart = (MimeBodyPart) multipart.getBodyPart(contentId);
            } else {
View Full Code Here

        } else {
            this.fileStorageThreshold = 1;
        }
        attachmentsMap = new TreeMap();
        try {
            contentType = new ContentType(contentTypeString);
        } catch (ParseException e) {
            throw new OMException(
                    "Invalid Content Type Field in the Mime Message"
                    , e);
        }
View Full Code Here

                            ((InternetAddress)reply.getRecipients(Message.RecipientType.TO)[0]).getAddress());
        Assert.assertEquals(channel.getRecipient().getAddress(),
                            ((InternetAddress)reply.getFrom()[0]).getAddress());
        ByteArrayOutputStream baos = new ByteArrayOutputStream();
        reply.getDataHandler().writeTo(baos);
        return new IncomingMessage<byte[]>(new ContentType(reply.getContentType()), baos.toByteArray());
    }
View Full Code Here

    public OMElement processDocument(Reader reader, String contentType,
                                     MessageContext messageContext) throws AxisFault {
        String charset;
        try {
            ContentType ct = new ContentType(contentType);
            charset = ct.getParameter("charset");
        } catch (ParseException ex) {
            charset = null;
        }
        if (charset == null) {
            charset = MessageContext.DEFAULT_CHAR_SET_ENCODING;
View Full Code Here

        } else {
            this.fileStorageThreshold = 1;
        }
        bodyPartsMap = new HashMap();
        try {
            contentType = new ContentType(contentTypeString);
        } catch (ParseException e) {
            throw new OMException(
                    "Invalid Content Type Field in the Mime Message"
                            ,e);
        }
View Full Code Here

        StringBuilder sb = new StringBuilder();
        Object content = message.getContent(); // throws ME
        if (content instanceof Multipart) {
            Multipart multipart = (Multipart) content;
            String contentType = multipart.getContentType();
            ContentType ct = new ContentType(contentType);
            String boundary=ct.getParameter("boundary");
            for (int i = 0; i < multipart.getCount(); i++) { // throws ME
                sb.append("--");
                sb.append(boundary);
                sb.append("\n");
                BodyPart bodyPart = multipart.getBodyPart(i); // throws ME
View Full Code Here

            MimeHeader mh = itMimeHeaders.next();
            log.trace(mh);
         }
      }

      ContentType contentType = getContentType(mimeHeaders);
      log.debug("createMessage: [contentType=" + contentType + "]");

      SOAPMessageImpl soapMessage = new SOAPMessageImpl();
      if (inputStream != null)
      {
View Full Code Here

      return soapMessage;
   }

   private static ContentType getContentType(MimeHeaders headers) throws SOAPException
   {
      ContentType contentType = null;
      try
      {
         String[] type = headers.getHeader(MimeConstants.CONTENT_TYPE);
         if (type != null)
         {
            contentType = new ContentType(type[0]);
         }
         else
         {
            contentType = new ContentType(MimeConstants.TYPE_SOAP11);
         }
         return contentType;
      }
      catch (ParseException e)
      {
View Full Code Here

    * @param mimeType any MIME type string
    * @return a reduced MIME string containing no type parameters
    */
   public static String getBaseMimeType(String mimeType)
   {
      ContentType contentType;

      if (mimeType == null)
         return null;
      try
      {
         contentType = new ContentType(mimeType);
      }
      catch (ParseException e)
      {
         return null;
      }

      return contentType.getBaseType();
   }
View Full Code Here

TOP

Related Classes of javax.mail.internet.ContentType

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.