/** * Returns the content-type of this DataSource. <p> * * This implementation just invokes the <code>getContentType</code> * method on the MimePart. */ public String getContentType() { try { return part.getContentType(); } catch (MessagingException mex) { // would like to be able to reflect the exception to the // application, but since we can't do that we return a // generic "unknown" value here and hope for another // exception later. return "application/octet-stream"; } }
/** * Returns the content-type of this DataSource. <p> * * This implementation just invokes the <code>getContentType</code> * method on the MimePart. */ @Override public String getContentType() { try { return part.getContentType(); } catch (MessagingException mex) { // would like to be able to reflect the exception to the // application, but since we can't do that we return a // generic "unknown" value here and hope for another // exception later. return "application/octet-stream"; } }
static boolean isMimeType(MimePart part, String mimeType) throws MessagingException { // XXX - lots of room for optimization here! String type = part.getContentType(); try { return new ContentType(type).match(mimeType); } catch (ParseException ex) { // we only need the type and subtype so throw away the rest try { int i = type.indexOf(';'); if (i > 0) return new ContentType(type.substring(0, i)).match(mimeType); } catch (ParseException pex2) { } return type.equalsIgnoreCase(mimeType); } }
static boolean isMimeType(MimePart part, String mimeType) throws MessagingException { // XXX - lots of room for optimization here! String type = part.getContentType(); try { return new ContentType(type).match(mimeType); } catch (ParseException ex) { // we only need the type and subtype so throw away the rest try { int i = type.indexOf(';'); if (i > 0) return new ContentType(type.substring(0, i)).match(mimeType); } catch (ParseException pex2) { } return type.equalsIgnoreCase(mimeType); } }
return encoding; // these encodings are always valid String type = part.getContentType(); if (type == null) return encoding;
return encoding; // these encodings are always valid String type = part.getContentType(); if (type == null) return encoding;
/** * 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 * @throws MessagingException parsing the MimeMessage failed * @throws IOException parsing the MimeMessage failed */ private boolean isMimeType(final MimePart part, final String mimeType) throws MessagingException, IOException { // 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); } }
public String getContentType() { try { return part.getContentType(); } catch (MessagingException e) { return null; } }
public String getContentType() { try { return part.getContentType(); } catch (MessagingException e) { return null; } }
part.getContentType()); part.setHeader("Content-Transfer-Encoding", "8bit"); changed = true;
part.getContentType()); part.setHeader("Content-Transfer-Encoding", "8bit"); changed = true;
/** * Returns the content-type of this DataSource. <p> * * This implementation just invokes the <code>getContentType</code> * method on the MimePart. */ @Override public String getContentType() { try { return part.getContentType(); } catch (MessagingException mex) { // would like to be able to reflect the exception to the // application, but since we can't do that we return a // generic "unknown" value here and hope for another // exception later. return "application/octet-stream"; } }
/** * Returns the content-type of this DataSource. <p> * * This implementation just invokes the <code>getContentType</code> * method on the MimePart. */ public String getContentType() { try { return part.getContentType(); } catch (MessagingException mex) { // would like to be able to reflect the exception to the // application, but since we can't do that we return a // generic "unknown" value here and hope for another // exception later. return "application/octet-stream"; } }
/** * Returns the content-type of this DataSource. <p> * * This implementation just invokes the <code>getContentType</code> * method on the MimePart. */ @Override public String getContentType() { try { return part.getContentType(); } catch (MessagingException mex) { // would like to be able to reflect the exception to the // application, but since we can't do that we return a // generic "unknown" value here and hope for another // exception later. return "application/octet-stream"; } }
@SuppressWarnings("WeakerAccess") public static String retrieveContentType(@Nonnull final MimePart part) { try { return part.getContentType(); } catch (final MessagingException e) { throw new MimeMessageParseException(MimeMessageParseException.ERROR_GETTING_CONTENT_TYPE, e); } }
static boolean isMimeType(MimePart part, String mimeType) throws MessagingException { // XXX - lots of room for optimization here! try { ContentType ct = new ContentType(part.getContentType()); return ct.match(mimeType); } catch (ParseException ex) { return part.getContentType().equalsIgnoreCase(mimeType); } }
static boolean isMimeType(MimePart part, String mimeType) throws MessagingException { // XXX - lots of room for optimization here! try { ContentType ct = new ContentType(part.getContentType()); return ct.match(mimeType); } catch (ParseException ex) { return part.getContentType().equalsIgnoreCase(mimeType); } }
if (mpart != part) { if (needCTHeader) part.setHeader("Content-Type", mpart.getContentType());
if (mpart != part) { if (needCTHeader) part.setHeader("Content-Type", mpart.getContentType());
static boolean isMimeType(MimePart part, String mimeType) throws MessagingException { // XXX - lots of room for optimization here! String type = part.getContentType(); try { return new ContentType(type).match(mimeType); } catch (ParseException ex) { // we only need the type and subtype so throw away the rest try { int i = type.indexOf(';'); if (i > 0) return new ContentType(type.substring(0, i)).match(mimeType); } catch (ParseException pex2) { } return type.equalsIgnoreCase(mimeType); } }