Package javax.mail.internet

Examples of javax.mail.internet.ContentType


     * @throws IOException
     */
    private Part getMessagePart(Message message, AxisConfiguration axisCfg)
            throws MessagingException, IOException {
       
        ContentType contentType = new ContentType(message.getContentType());
        if (contentType.getBaseType().equalsIgnoreCase("multipart/mixed")) {
            Multipart multipart = (Multipart)message.getContent();
            Part textMainPart = null;
            for (int i=0; i<multipart.getCount(); i++) {
                MimeBodyPart bodyPart = (MimeBodyPart)multipart.getBodyPart(i);
                ContentType partContentType = new ContentType(bodyPart.getContentType());
                if (axisCfg.getMessageBuilder(partContentType.getBaseType()) != null) {
                    if (partContentType.getBaseType().equalsIgnoreCase("text/plain")) {
                        // If it's a text/plain part, remember it. We will return
                        // it later if we don't find something more interesting.
                        textMainPart = bodyPart;
                    } else {
                        return bodyPart;
View Full Code Here


     *             if the message doesn't have one of the supported types (i.e. is neither MTOM nor
     *             SOAP with attachments) or if the instance was not created from a stream
     */
    public String getAttachmentSpecType() {
        if (this.applicationType == null) {
            ContentType contentType = delegate.getContentType();
            if (contentType == null) {
                throw new OMException("Unable to determine the attachment spec type because the " +
                    "Attachments object doesn't have a known content type");
            }
            applicationType = contentType.getParameter("type");
            if ((MTOMConstants.MTOM_TYPE).equalsIgnoreCase(applicationType)) {
                this.applicationType = MTOMConstants.MTOM_TYPE;
            } else if ((MTOMConstants.SWA_TYPE).equalsIgnoreCase(applicationType)) {
                this.applicationType = MTOMConstants.SWA_TYPE;
            } else if ((MTOMConstants.SWA_TYPE_12).equalsIgnoreCase(applicationType)) {
View Full Code Here

      throw new getRDFException("Unable to open connection.");
  }
  String contentT = con.getContentType();
  String HTTPcharset = null;
  if (contentT != null) {
      ContentType contentType = null;
      try {
    contentType = new ContentType(con.getContentType());
      } catch (javax.mail.internet.ParseException e) {
    throw new getRDFException("Unparsable content type.");
      }
      HTTPcharset = contentType.getParameter("charset");
  }
 
  // need buffer for lookahead for encoding detection
  BufferedInputStream bis = null;
  try {
View Full Code Here

        final Object content = mime.getContent();
        if (content instanceof MimeMultipart == false) {
            throw new UnsupportedOperationException("Expected a javax.mail.internet.MimeMultipart object but found a " + content.getClass());
        }
        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

  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

        // Do not use part.isMimeType(String) as it is broken for MimeBodyPart
        // and does not really check the actual content type.

        try
        {
            final ContentType ct = new ContentType(part.getDataHandler().getContentType());
            return ct.match(mimeType);
        }
        catch (final ParseException ex)
        {
            return part.getContentType().equalsIgnoreCase(mimeType);
        }
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

        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

                // Extract the charset encoding from the configured content type and
                // set the CHARACTER_SET_ENCODING property as e.g. SOAPBuilder relies on this.
                String charSetEnc = null;
                try {
                    if (contentType != null) {
                        charSetEnc = new ContentType(contentType).getParameter("charset");
                    }
                } catch (ParseException ex) {
                    // ignore
                }
                msgContext.setProperty(Constants.Configuration.CHARACTER_SET_ENCODING, charSetEnc);
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

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.