Java 类javax.mail.internet.ParseException 实例源码

项目:zesped    文件:MailSessionHandler.java   
public void sendMessage (Message oMsg,
                         Address[] aAdrFrom, Address[] aAdrReply,
                         Address[] aAdrTo, Address[] aAdrCc, Address[] aAdrBcc)
  throws NoSuchProviderException,SendFailedException,ParseException,
         MessagingException,NullPointerException {              
  oMsg.addFrom(aAdrFrom);
  if (null==aAdrReply)
    oMsg.setReplyTo(aAdrReply);
  else
    oMsg.setReplyTo(aAdrFrom);
  if (aAdrTo!=null) oMsg.addRecipients(javax.mail.Message.RecipientType.TO, aAdrTo);
  if (aAdrCc!=null) oMsg.addRecipients(javax.mail.Message.RecipientType.CC, aAdrCc);
  if (aAdrBcc!=null) oMsg.addRecipients(javax.mail.Message.RecipientType.BCC, aAdrBcc);
  oMsg.setSentDate(new java.util.Date());
  Transport.send(oMsg);
}
项目:diadocsdk-java    文件:DiadocApi.java   
public GeneratedFile GenerateInvoiceDocumentReceiptXml(String boxId, String messageId, String attachmentId, SignerProtos.Signer signer)
        throws IllegalStateException, IOException, ParseException {
    if (boxId == null)
        throw new NullPointerException("boxId");
    if (messageId == null)
        throw new NullPointerException("messageId");
    if (attachmentId == null)
        throw new NullPointerException("attachmentId");
    if (signer == null)
        throw new NullPointerException("signer");

    List<NameValuePair> parameters = new ArrayList<NameValuePair>();
    parameters.add(new BasicNameValuePair("boxId", boxId));
    parameters.add(new BasicNameValuePair("messageId", messageId));
    parameters.add(new BasicNameValuePair("attachmentId", attachmentId));
    HttpResponse webResponse = ReceivePostHttpResponse("/GenerateInvoiceDocumentReceiptXml", parameters, signer.toByteArray());

    return new GeneratedFile(GetHttpResponseFileName(webResponse), GetResponseBytes(webResponse));
}
项目:diadocsdk-java    文件:DiadocApi.java   
public GeneratedFile GenerateDocumentReceiptXml(String boxId, String messageId, String attachmentId, SignerProtos.Signer signer)
        throws IllegalStateException, IOException, ParseException {
    if (boxId == null)
        throw new NullPointerException("boxId");
    if (messageId == null)
        throw new NullPointerException("messageId");
    if (attachmentId == null)
        throw new NullPointerException("attachmentId");
    if (signer == null)
        throw new NullPointerException("signer");

    List<NameValuePair> parameters = new ArrayList<NameValuePair>();
    parameters.add(new BasicNameValuePair("boxId", boxId));
    parameters.add(new BasicNameValuePair("messageId", messageId));
    parameters.add(new BasicNameValuePair("attachmentId", attachmentId));
    HttpResponse webResponse = ReceivePostHttpResponse("/GenerateDocumentReceiptXml", parameters, signer.toByteArray());

    return new GeneratedFile(GetHttpResponseFileName(webResponse), GetResponseBytes(webResponse));
}
项目:diadocsdk-java    文件:DiadocApi.java   
public GeneratedFile GenerateInvoiceCorrectionRequestXml(String boxId, String messageId, String attachmentId,
        InvoiceCorrectionRequestInfoProtos.InvoiceCorrectionRequestInfo invoiceCorrectionInfo) throws IllegalStateException, IOException, ParseException {
    if (boxId == null)
        throw new NullPointerException("boxId");
    if (messageId == null)
        throw new NullPointerException("messageId");
    if (attachmentId == null)
        throw new NullPointerException("attachmentId");

    List<NameValuePair> parameters = new ArrayList<NameValuePair>();
    parameters.add(new BasicNameValuePair("boxId", boxId));
    parameters.add(new BasicNameValuePair("messageId", messageId));
    parameters.add(new BasicNameValuePair("attachmentId", attachmentId));
    HttpResponse webResponse = ReceivePostHttpResponse("/GenerateInvoiceCorrectionRequestXml", parameters, invoiceCorrectionInfo.toByteArray());

    return new GeneratedFile(GetHttpResponseFileName(webResponse), GetResponseBytes(webResponse));
}
项目:diadocsdk-java    文件:DiadocApi.java   
public GeneratedFile GenerateRevocationRequestXml(String boxId, String messageId, String attachmentId,
        RevocationRequestInfoProtos.RevocationRequestInfo revocationRequestInfo) throws IllegalStateException, IOException, ParseException {
    if (boxId == null)
        throw new NullPointerException("boxId");
    if (messageId == null)
        throw new NullPointerException("messageId");
    if (attachmentId == null)
        throw new NullPointerException("attachmentId");

    List<NameValuePair> parameters = new ArrayList<NameValuePair>();
    parameters.add(new BasicNameValuePair("boxId", boxId));
    parameters.add(new BasicNameValuePair("messageId", messageId));
    parameters.add(new BasicNameValuePair("attachmentId", attachmentId));
    HttpResponse webResponse = ReceivePostHttpResponse("/GenerateRevocationRequestXml", parameters, revocationRequestInfo.toByteArray());

    return new GeneratedFile(GetHttpResponseFileName(webResponse), GetResponseBytes(webResponse));
}
项目:diadocsdk-java    文件:DiadocApi.java   
public GeneratedFile GenerateSignatureRejectionXml(String boxId, String messageId, String attachmentId,
        SignatureRejectionInfoProtos.SignatureRejectionInfo signatureRejectionInfo) throws IllegalStateException, IOException, ParseException {
    if (boxId == null)
        throw new NullPointerException("boxId");
    if (messageId == null)
        throw new NullPointerException("messageId");
    if (attachmentId == null)
        throw new NullPointerException("attachmentId");

    List<NameValuePair> parameters = new ArrayList<NameValuePair>();
    parameters.add(new BasicNameValuePair("boxId", boxId));
    parameters.add(new BasicNameValuePair("messageId", messageId));
    parameters.add(new BasicNameValuePair("attachmentId", attachmentId));
    HttpResponse webResponse = ReceivePostHttpResponse("/GenerateSignatureRejectionXml", parameters, signatureRejectionInfo.toByteArray());

    return new GeneratedFile(GetHttpResponseFileName(webResponse), GetResponseBytes(webResponse));
}
项目:diadocsdk-java    文件:DiadocApi.java   
public GeneratedFile GenerateUniversalTransferDocumentXmlForBuyer(
    UniversalTransferDocumentInfoProtos.UniversalTransferDocumentBuyerTitleInfo buyerTitleInfo,
    String boxId,
    String sellerTitleMessageId,
    String sellerTitleAttachmentId
) throws IOException, ParseException {
    if (buyerTitleInfo == null) throw new NullPointerException("buyerTitleInfo");
    if (boxId == null) throw new NullPointerException("boxId");
    if (sellerTitleMessageId == null) throw new NullPointerException("sellerTitleMessageId");
    if (sellerTitleAttachmentId == null) throw new NullPointerException("sellerTitleAttachmentId");
    List<NameValuePair> parameters = new ArrayList<NameValuePair>();
    parameters.add(new BasicNameValuePair("boxId", boxId));
    parameters.add(new BasicNameValuePair("sellerTitleMessageId", sellerTitleMessageId));
    parameters.add(new BasicNameValuePair("sellerTitleAttachmentId", sellerTitleAttachmentId));
    HttpResponse httpResponse = ReceivePostHttpResponse("/GenerateUniversalTransferDocumentXmlForBuyer", parameters, buyerTitleInfo.toByteArray());
    return new GeneratedFile(GetHttpResponseFileName(httpResponse), GetResponseBytes(httpResponse));
}
项目:packagedrone    文件:HttpImporter.java   
private static String fromContentDisposition ( final String field )
{
    if ( field == null || field.isEmpty () )
    {
        return null;
    }

    try
    {
        final ContentDisposition cd = new ContentDisposition ( field );
        return cd.getParameter ( "filename" );
    }
    catch ( final ParseException e )
    {
        return null;
    }
}
项目:package-drone    文件:HttpImporter.java   
private static String fromContentDisposition ( final String field )
{
    if ( field == null || field.isEmpty () )
    {
        return null;
    }

    try
    {
        final ContentDisposition cd = new ContentDisposition ( field );
        return cd.getParameter ( "filename" );
    }
    catch ( final ParseException e )
    {
        return null;
    }
}
项目:wso2-axis2-transports    文件:TextMessageBuilderAdapter.java   
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;
    }
    messageContext.setProperty(Constants.Configuration.CHARACTER_SET_ENCODING, charset);        
    return processDocument(new ReaderInputStream(reader, charset), contentType,
            messageContext);
}
项目:wso2-axis2    文件:TextMessageBuilderAdapter.java   
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;
    }
    messageContext.setProperty(Constants.Configuration.CHARACTER_SET_ENCODING, charset);        
    return processDocument(new ReaderInputStream(reader, charset), contentType,
            messageContext);
}
项目:ScriptBox    文件:HttpFetchHandler.java   
@Override
public boolean isAttachment() {
    boolean result = false;

    String dispositionString = conn.getHeaderField(HEADER_CONTENT_DISPOSITION);
    if (dispositionString != null) {
        try {
            ContentDisposition disposition = new ContentDisposition(dispositionString);

            result = disposition.getDisposition().equals(DISPOSITION_ATTACHMENT);
        } catch (ParseException e) {
        }
    }

    return result;
}
项目:ph-as4    文件:SoapMimeMultipart.java   
public SoapMimeMultipart (@Nonnull final ESOAPVersion eSOAPVersion,
                          @Nonnull final Charset aCharset) throws ParseException
{
  super ("related");

  // type parameter is essential for Axis to work!
  // But no charset! RFC 2387, section 3.4 has a special definition
  final ContentType aContentType = new ContentType (contentType);
  aContentType.setParameter ("type", eSOAPVersion.getMimeType ().getAsString ());
  aContentType.setParameter ("charset", aCharset.name ());
  contentType = aContentType.toString ();
}
项目:diadocsdk-java    文件:DiadocApi.java   
public GeneratedFile GenerateTorg12XmlForBuyer(Torg12InfoProtos.Torg12BuyerTitleInfo buyerTitleInfo, String boxId, String sellerTitleMessageId, String sellerTitleAttachmentId) throws IOException, ParseException {
    if (buyerTitleInfo == null) throw new NullPointerException("buyerTitleInfo");
    if (boxId == null) throw new NullPointerException("boxId");
    if (sellerTitleMessageId == null) throw new NullPointerException("sellerTitleMessageId");
    if (sellerTitleAttachmentId == null) throw new NullPointerException("sellerTitleAttachmentId");
    List<NameValuePair> parameters = new ArrayList<NameValuePair>();
    parameters.add(new BasicNameValuePair("boxId", boxId));
    parameters.add(new BasicNameValuePair("sellerTitleMessageId", sellerTitleMessageId));
    parameters.add(new BasicNameValuePair("sellerTitleAttachmentId", sellerTitleAttachmentId));
    HttpResponse httpResponse = ReceivePostHttpResponse("/GenerateTorg12XmlForBuyer", parameters, buyerTitleInfo.toByteArray());
    return new GeneratedFile(GetHttpResponseFileName(httpResponse), GetResponseBytes(httpResponse));
}
项目:diadocsdk-java    文件:DiadocApi.java   
public GeneratedFile GenerateTovTorg551XmlForBuyer(TovTorgInfoProtos.TovTorgBuyerTitleInfo buyerTitleInfo, String boxId, String sellerTitleMessageId, String sellerTitleAttachmentId) throws IOException, ParseException {
    if (buyerTitleInfo == null) throw new NullPointerException("buyerTitleInfo");
    if (boxId == null) throw new NullPointerException("boxId");
    if (sellerTitleMessageId == null) throw new NullPointerException("sellerTitleMessageId");
    if (sellerTitleAttachmentId == null) throw new NullPointerException("sellerTitleAttachmentId");
    List<NameValuePair> parameters = new ArrayList<NameValuePair>();
    parameters.add(new BasicNameValuePair("boxId", boxId));
    parameters.add(new BasicNameValuePair("sellerTitleMessageId", sellerTitleMessageId));
    parameters.add(new BasicNameValuePair("sellerTitleAttachmentId", sellerTitleAttachmentId));
    HttpResponse httpResponse = ReceivePostHttpResponse("/GenerateTorg12XmlForBuyer?documentVersion=tovtorg_05_01_02", parameters, buyerTitleInfo.toByteArray());
    return new GeneratedFile(GetHttpResponseFileName(httpResponse), GetResponseBytes(httpResponse));
}
项目:diadocsdk-java    文件:DiadocApi.java   
public GeneratedFile GenerateAcceptanceCertificateXmlForBuyer(AcceptanceCertificateInfoProtos.AcceptanceCertificateBuyerTitleInfo buyerTitleInfo, String boxId, String sellerTitleMessageId,
                                                              String sellerTitleAttachmentId) throws IOException, ParseException {
    if (buyerTitleInfo == null) throw new NullPointerException("buyerTitleInfo");
    if (boxId == null) throw new NullPointerException("boxId");
    if (sellerTitleMessageId == null) throw new NullPointerException("sellerTitleMessageId");
    if (sellerTitleAttachmentId == null) throw new NullPointerException("sellerTitleAttachmentId");
    List<NameValuePair> parameters = new ArrayList<NameValuePair>();
    parameters.add(new BasicNameValuePair("boxId", boxId));
    parameters.add(new BasicNameValuePair("sellerTitleMessageId", sellerTitleMessageId));
    parameters.add(new BasicNameValuePair("sellerTitleAttachmentId", sellerTitleAttachmentId));
    HttpResponse httpResponse = ReceivePostHttpResponse("/GenerateAcceptanceCertificateXmlForBuyer", parameters, buyerTitleInfo.toByteArray());
    return new GeneratedFile(GetHttpResponseFileName(httpResponse), GetResponseBytes(httpResponse));
}
项目:diadocsdk-java    文件:DiadocApi.java   
public GeneratedFile GenerateAcceptanceCertificate552XmlForBuyer(AcceptanceCertificate552InfoProtos.AcceptanceCertificate552BuyerTitleInfo buyerTitleInfo, String boxId, String sellerTitleMessageId,
                                                              String sellerTitleAttachmentId) throws IOException, ParseException {
    if (buyerTitleInfo == null) throw new NullPointerException("buyerTitleInfo");
    if (boxId == null) throw new NullPointerException("boxId");
    if (sellerTitleMessageId == null) throw new NullPointerException("sellerTitleMessageId");
    if (sellerTitleAttachmentId == null) throw new NullPointerException("sellerTitleAttachmentId");
    List<NameValuePair> parameters = new ArrayList<NameValuePair>();
    parameters.add(new BasicNameValuePair("boxId", boxId));
    parameters.add(new BasicNameValuePair("sellerTitleMessageId", sellerTitleMessageId));
    parameters.add(new BasicNameValuePair("sellerTitleAttachmentId", sellerTitleAttachmentId));
    parameters.add(new BasicNameValuePair("documentVersion", "rezru_05_01_01"));
    HttpResponse httpResponse = ReceivePostHttpResponse("/GenerateAcceptanceCertificateXmlForBuyer", parameters, buyerTitleInfo.toByteArray());
    return new GeneratedFile(GetHttpResponseFileName(httpResponse), GetResponseBytes(httpResponse));
}
项目:diadocsdk-java    文件:DiadocApi.java   
public GeneratedFile GenerateUniversalTransferDocumentXmlForSeller(UniversalTransferDocumentInfoProtos.UniversalTransferDocumentSellerTitleInfo utdInfo, boolean disableValidation) throws IOException, ParseException {
    if (utdInfo == null) throw new NullPointerException("info");
    HttpResponse httpResponse = ReceivePostHttpResponse(
        "/GenerateUniversalTransferDocumentXmlForSeller" + (disableValidation ? "?disableValidation" : ""),
        null,
        utdInfo.toByteArray());
    return new GeneratedFile(GetHttpResponseFileName(httpResponse), GetResponseBytes(httpResponse));
}
项目:diadocsdk-java    文件:DiadocApi.java   
public GeneratedFile GenerateUniversalCorrectionTransferDocumentXmlForSeller(UniversalTransferDocumentInfoProtos.UniversalCorrectionDocumentSellerTitleInfo ucdInfo, boolean disableValidation) throws IOException, ParseException {
    if (ucdInfo == null) throw new NullPointerException("info");
    HttpResponse httpResponse = ReceivePostHttpResponse(
        "/GenerateUniversalTransferDocumentXmlForSeller"
            + "?correction"
            + (disableValidation ? "&disableValidation" : ""),
        null,
        ucdInfo.toByteArray());
    return new GeneratedFile(GetHttpResponseFileName(httpResponse), GetResponseBytes(httpResponse));
}
项目:diadocsdk-java    文件:DiadocApi.java   
public PrintFormResult GeneratePrintForm(String boxId, String messageId, String documentId) throws IllegalStateException, IOException, ParseException {
    if (Tools.IsNullOrEmpty(boxId))
        throw new NullPointerException("boxId");
    if (Tools.IsNullOrEmpty(messageId))
        throw new NullPointerException("messageId");
    if (Tools.IsNullOrEmpty(documentId))
        throw new NullPointerException("documentId");

    List<NameValuePair> parameters = new ArrayList<NameValuePair>();
    parameters.add(new BasicNameValuePair("boxId", boxId));
    parameters.add(new BasicNameValuePair("messageId", messageId));
    parameters.add(new BasicNameValuePair("documentId", documentId));
    HttpResponse webResponse = ReceiveGetHttpResponse("/GeneratePrintForm", parameters);

    try {
        if (webResponse.getStatusLine().getStatusCode() != HttpStatus.SC_OK)
            throw new IllegalStateException(webResponse.getStatusLine().toString());

        Integer retryAfter = TryGetRetryAfter(webResponse);
        if (retryAfter != null)
            return new PrintFormResult(retryAfter);

        String fileName = GetHttpResponseFileName(webResponse);
        byte[] content = GetResponseBytes(webResponse);
        String contentType = webResponse.getEntity().getContentType().getValue();
        return new PrintFormResult(new PrintFormContent(contentType, fileName, content));
    } finally {
        webResponse.getEntity().getContent().close();
    }
}
项目:diadocsdk-java    文件:DiadocApi.java   
public DocumentProtocolResult GenerateDocumentProtocol(String boxId, String messageId, String documentId) throws IllegalStateException, IOException, ParseException {
    if (Tools.IsNullOrEmpty(boxId))
        throw new NullPointerException("boxId");
    if (Tools.IsNullOrEmpty(messageId))
        throw new NullPointerException("messageId");
    if (Tools.IsNullOrEmpty(documentId))
        throw new NullPointerException("documentId");

    List<NameValuePair> parameters = new ArrayList<NameValuePair>();
    parameters.add(new BasicNameValuePair("boxId", boxId));
    parameters.add(new BasicNameValuePair("messageId", messageId));
    parameters.add(new BasicNameValuePair("documentId", documentId));
    HttpResponse webResponse = ReceiveGetHttpResponse("/GenerateDocumentProtocol", parameters);

    try {
        if (webResponse.getStatusLine().getStatusCode() != HttpStatus.SC_OK)
            throw new IllegalStateException(webResponse.getStatusLine().toString());

        Integer retryAfter = TryGetRetryAfter(webResponse);
        if (retryAfter != null)
            return new DocumentProtocolResult(retryAfter);

        byte[] content = GetResponseBytes(webResponse);
        return new DocumentProtocolResult(DocumentProtocolProtos.DocumentProtocol.parseFrom(content));
    } finally {
        webResponse.getEntity().getContent().close();
    }
}
项目:diadocsdk-java    文件:DiadocApi.java   
public DocumentZipResult GenerateDocumentZip(String boxId, String messageId, String documentId, Boolean fullDocflow) throws IllegalStateException, IOException, ParseException {
    if (Tools.IsNullOrEmpty(boxId))
        throw new NullPointerException("boxId");
    if (Tools.IsNullOrEmpty(messageId))
        throw new NullPointerException("messageId");
    if (Tools.IsNullOrEmpty(documentId))
        throw new NullPointerException("documentId");

    List<NameValuePair> parameters = new ArrayList<NameValuePair>();
    parameters.add(new BasicNameValuePair("boxId", boxId));
    parameters.add(new BasicNameValuePair("messageId", messageId));
    parameters.add(new BasicNameValuePair("documentId", documentId));
    parameters.add(new BasicNameValuePair("fullDocflow", fullDocflow.toString()));

    HttpResponse webResponse = ReceiveGetHttpResponse("/GenerateDocumentZip", parameters);

    try {
        if (webResponse.getStatusLine().getStatusCode() != HttpStatus.SC_OK)
            throw new IllegalStateException(webResponse.getStatusLine().toString());

        Integer retryAfter = TryGetRetryAfter(webResponse);
        if (retryAfter != null)
            return new DocumentZipResult(retryAfter);

        byte[] content = GetResponseBytes(webResponse);
        return new DocumentZipResult(DocumentZipProtos.DocumentZipGenerationResult.parseFrom(content));
    } finally {
        webResponse.getEntity().getContent().close();
    }
}
项目:Camel    文件:MimeMultipartDataFormat.java   
private ContentType getContentType(Exchange exchange) throws ParseException {
    String contentTypeStr = ExchangeHelper.getContentType(exchange);
    if (contentTypeStr == null) {
        contentTypeStr = DEFAULT_CONTENT_TYPE;
    }
    ContentType contentType = new ContentType(contentTypeStr);
    String contentEncoding = ExchangeHelper.getContentEncoding(exchange);
    // add a charset parameter for text subtypes
    if (contentEncoding != null && contentType.match("text/*")) {
        contentType.setParameter("charset", MimeUtility.mimeCharset(contentEncoding));
    }
    return contentType;
}
项目:simple-java-mail    文件:MimeMessageParser.java   
/**
 * Checks whether the MimePart contains an object of the given mime type.
 *
 * @param part     the current MimePart
 * @param mimeType the mime type to check
 * @return {@code true} if the MimePart matches the given mime type, {@code false} otherwise
 */
@SuppressWarnings("WeakerAccess")
public static boolean isMimeType(@Nonnull final MimePart part, @Nonnull final String mimeType) {
    // Do not use part.isMimeType(String) as it is broken for MimeBodyPart
    // and does not really check the actual content type.

    try {
        final ContentType contentType = new ContentType(retrieveDataHandler(part).getContentType());
        return contentType.match(mimeType);
    } catch (final ParseException ex) {
        return retrieveContentType(part).equalsIgnoreCase(mimeType);
    }
}
项目:eml-to-pdf-converter    文件:ContentTypeCleaner.java   
/**
 * Try to parse the given contentType String into a ContentType instance.
 * @param contentType
 * @return new ContentType instance, or null if not parsable
 */
private static ContentType parseContentType(String contentType) {
    try {
        return new ContentType(contentType);
    } catch (ParseException e) {
        return null;
    }
}
项目:eml-to-pdf-converter    文件:ContentTypeCleaner.java   
/**
 * Check if the contentType can be parsed. If not return a fixed version.
 * When thats not possible return a default contentType string.
 * @param contentType
 * @return Fixed contentType string or default
 * @throws ParseException
 */
private static ContentType getParsableContentType(String contentType) throws ParseException {
    Logger.debug("Encountered an unparsable contenttype, try to fix it.");

    // we can't fix an empty contentType, fallback to default
    if (Strings.isNullOrEmpty(contentType)) {
        Logger.debug("ContentType empty, fallback to \"%s\"", DEFAULT_CONTENTTYPE);
        return new ContentType(DEFAULT_CONTENTTYPE);
    }

    ContentType tmp = parseContentType(fixContentType_semicolonSequenceInParams(contentType));
    if (tmp != null) {
        Logger.debug("Fix succeeded (1)");
        return tmp;
    }

    tmp = parseContentType(fixContentType_colonAsParamDelim(contentType));
    if (tmp != null) {
        Logger.debug("Fix succeeded (2)");
        return tmp;
    }

    // Neither did work, lets try to use clean1 and clean2 in conjunction
    tmp = parseContentType(fixContentType_semicolonSequenceInParams(fixContentType_colonAsParamDelim(contentType)));
    if (tmp != null) {
        Logger.debug("Fix succeeded (1&2)");
        return tmp;
    }

    // this is a rather desperate approach but lets try it nevertheless
    tmp = parseContentType(fixContentType_findByBruteForce(contentType));
    if (tmp != null) {
        Logger.debug("Fix succeeded (3)");
        return tmp;
    }

    Logger.debug("Encountered broken ContentType, fallback to default: %s", DEFAULT_CONTENTTYPE);
    return new ContentType(DEFAULT_CONTENTTYPE);
}
项目:caja    文件:DataUriFetcher.java   
private static String charsetFromMime(String mime) {
  String charset;
  try {
    ContentType parsedType = new ContentType(mime);
    charset = parsedType.getParameter("charset");
  } catch (ParseException e) {
    charset = null;
  }
  if (null == charset || "".equals(charset)) {
    return DATA_URI_DEFAULT_CHARSET;
  } else {
    return charset;
  }
}
项目:caja    文件:FetchedData.java   
private static String getCharSet(URLConnection conn) {
  try {
    String contentType = conn.getContentType();
    if (contentType == null) { return ""; }
    String charset = new ContentType(contentType).getParameter("charset");
    return (charset == null) ? "" : charset;
  } catch (ParseException e) {
    return "";
  }
}
项目:wso2-axis2-transports    文件:XMLMessage.java   
public ContentType getContentType() {
    try {
        return new ContentType(contentType);
    } catch (ParseException ex) {
        throw new Error(ex);
    }
}
项目:James    文件:MessageProcessor.java   
/**
 * Method handleParseException.
 * 
 * @param ex
 * @throws MessagingException
 */
protected void handleParseException(ParseException ex) throws MessagingException {
    // Update the flags of the received message
    if (!isLeaveUndeliverable())
        setMessageDeleted();
    if (isMarkUndeliverableSeen())
        setMessageSeen();
    logStatusWarn("Message could not be delivered due to an error parsing a mail address.");
    if (getLogger().isDebugEnabled()) {
        StringBuilder messageBuffer = new StringBuilder("UNDELIVERABLE Message ID: ");
        messageBuffer.append(getMessageIn().getMessageID());
        getLogger().debug(messageBuffer.toString(), ex);
    }
}
项目:James    文件:ParsedConfiguration.java   
/**
 * Sets the blacklist.
 * 
 * @param blacklistValue
 *            The blacklist to set
 */
protected void setBlacklist(String blacklistValue) throws ConfigurationException {
    StringTokenizer st = new StringTokenizer(blacklistValue, ", \t", false);
    Set<MailAddress> blacklist = new HashSet<MailAddress>();
    String token = null;
    while (st.hasMoreTokens()) {
        try {
            token = st.nextToken();
            blacklist.add(new MailAddress(token));
        } catch (ParseException pe) {
            throw new ConfigurationException("Invalid blacklist mail address specified: " + token);
        }
    }
    setBlacklist(blacklist);
}
项目:James    文件:Account.java   
/**
 * Sets the recipient.
 * 
 * @param recipient
 *            The recipient to set
 */
protected void setRecipient(String recipient) throws ConfigurationException {
    if (null == recipient) {
        fieldRecipient = null;
        return;
    }

    try {
        setRecipient(new MailAddress(recipient));
    } catch (ParseException pe) {
        throw new ConfigurationException("Invalid recipient address specified: " + recipient);
    }
}
项目:chicory    文件:MimeMultipartRelated.java   
public MimeMultipartRelated() {
    super("related");
    try {
        baseContentTypeObject = new ContentType(contentType);
    } catch (ParseException ex) {
        throw new RuntimeException("\"multipart/related\" string should be considered well-formed content type", ex);
    }
}
项目:jmp    文件:ContentTypeUtil.java   
/**
 * Returns the primary type of the Content-Type represented by the
 * specified <code>String</code>.
 * @param type the content type
 * @return the primary type
 */
public static String getPrimaryType(String type) throws ParseException {
    if (type == null)
        throw new NullPointerException("null Content-Type");

    ContentType obj = new ContentType(type);
    return obj.getPrimaryType();
}
项目:jmp    文件:ContentTypeUtil.java   
/**
 * Returns the subtype of the Content-Type represented by the
 * specified <code>String</code>.
 * @param  type the content type
 * @return the subtype, or <code>null</code> if no subtype
 */
public static String getSubType(String type) throws ParseException {
    if (type == null)
        throw new NullPointerException("null Content-Type");

    ContentType obj = new ContentType(type);
    return obj.getSubType();
}