filename = ((MimeBodyPart) bp).getContentID();
/** * Correctly resolves file name from the message part. * Thanx to: Flavio Pompermaier * * @param part {@link Part} to decode file name from. * @return String containing file name. */ public static String resolveFileName(final Part part) throws MessagingException { if (!(part instanceof MimeBodyPart)) { return part.getFileName(); } final String contentType = part.getContentType(); String ret; try { ret = MimeUtility.decodeText(part.getFileName()); } catch (final Exception ex) { // String[] contentId = part.getHeader("Content-ID"); // if (contentId != null && contentId.length > 0) { final String contentId = ((MimeBodyPart) part).getContentID(); if (contentId != null) { ret = contentId + contentTypeForFileName(contentType); } else { ret = defaultFileName(contentType); } } return ret; }
/** * Get the MimeBodyPart referred to by the given ContentID (CID). * Returns null if the part is not found. * * @param CID the ContentID of the desired part * @return the Part * @exception MessagingException for failures */ public synchronized BodyPart getBodyPart(String CID) throws MessagingException { parse(); int count = getCount(); for (int i = 0; i < count; i++) { MimeBodyPart part = (MimeBodyPart)getBodyPart(i); String s = part.getContentID(); if (s != null && s.equals(CID)) return part; } return null; }
/** * Get the MimeBodyPart referred to by the given ContentID (CID). * Returns null if the part is not found. * * @param CID the ContentID of the desired part * @return the Part * @exception MessagingException for failures */ public synchronized BodyPart getBodyPart(String CID) throws MessagingException { parse(); int count = getCount(); for (int i = 0; i < count; i++) { MimeBodyPart part = (MimeBodyPart)getBodyPart(i); String s = part.getContentID(); if (s != null && s.equals(CID)) return part; } return null; }
public BodyPart getBodyPart(String cid) throws MessagingException { parse(); for (int i = 0; i < parts.size(); i++) { MimeBodyPart bodyPart = (MimeBodyPart) parts.get(i); if (cid.equals(bodyPart.getContentID())) { return bodyPart; } } return null; }
public BodyPart getBodyPart(String cid) throws MessagingException { parse(); for (int i = 0; i < parts.size(); i++) { MimeBodyPart bodyPart = (MimeBodyPart) parts.get(i); if (cid.equals(bodyPart.getContentID())) { return bodyPart; } } return null; }
private String getAttachmentKey(BodyPart bp) throws MessagingException, UnsupportedEncodingException { // use the filename as key for the map String key = bp.getFileName(); // if there is no file name we use the Content-ID header if (key == null && bp instanceof MimeBodyPart) { key = ((MimeBodyPart) bp).getContentID(); if (key != null && key.startsWith("<") && key.length() > 2) { // strip <> key = key.substring(1, key.length() - 1); } } // or a generated content id if (key == null) { key = UUID.randomUUID().toString() + "@camel.apache.org"; } return MimeUtility.decodeText(key); } }
/** * Get the MimeBodyPart referred to by the given ContentID (CID). * Returns null if the part is not found. * * @param CID the ContentID of the desired part * @return the Part * @exception MessagingException for failures */ public synchronized BodyPart getBodyPart(String CID) throws MessagingException { parse(); int count = getCount(); for (int i = 0; i < count; i++) { MimeBodyPart part = (MimeBodyPart)getBodyPart(i); String s = part.getContentID(); if (s != null && s.equals(CID)) return part; } return null; }
/** * Get the MimeBodyPart referred to by the given ContentID (CID). * Returns null if the part is not found. * * @param CID the ContentID of the desired part * @return the Part */ public synchronized BodyPart getBodyPart(String CID) throws MessagingException { parse(); int count = getCount(); for (int i = 0; i < count; i++) { MimeBodyPart part = (MimeBodyPart)getBodyPart(i); String s = part.getContentID(); if (s != null && s.equals(CID)) return part; } return null; }
/** * Get the MimeBodyPart referred to by the given ContentID (CID). * Returns null if the part is not found. * * @param CID the ContentID of the desired part * @return the Part * @exception MessagingException for failures */ public synchronized BodyPart getBodyPart(String CID) throws MessagingException { parse(); int count = getCount(); for (int i = 0; i < count; i++) { MimeBodyPart part = (MimeBodyPart)getBodyPart(i); String s = part.getContentID(); if (s != null && s.equals(CID)) return part; } return null; }
/** * Get the MimeBodyPart referred to by the given ContentID (CID). * Returns null if the part is not found. * * @param CID the ContentID of the desired part * @return the Part * @exception MessagingException for failures */ public synchronized BodyPart getBodyPart(String CID) throws MessagingException { parse(); int count = getCount(); for (int i = 0; i < count; i++) { MimeBodyPart part = (MimeBodyPart)getBodyPart(i); String s = part.getContentID(); if (s != null && s.equals(CID)) return part; } return null; }
/** * Get the MimeBodyPart referred to by the given ContentID (CID). * Returns null if the part is not found. * * @param CID the ContentID of the desired part * @return the Part */ public synchronized BodyPart getBodyPart(String CID) throws MessagingException { parse(); int count = getCount(); for (int i = 0; i < count; i++) { MimeBodyPart part = (MimeBodyPart)getBodyPart(i); String s = part.getContentID(); if (s != null && s.equals(CID)) return part; } return null; }
mimeBodyPart.setDisposition(MimeBodyPart.ATTACHMENT); mimeBodyPart.setContentID(attachment); cid.put(attachment,mimeBodyPart.getContentID()); mimeBodyParts.add(mimeBodyPart); } catch (MessagingException e) {
/** * Get the MimeBodyPart referred to by the given ContentID (CID). * Returns null if the part is not found. * * @param CID the ContentID of the desired part * @return the Part * @exception MessagingException for failures */ public synchronized BodyPart getBodyPart(String CID) throws MessagingException { parse(); int count = getCount(); for (int i = 0; i < count; i++) { MimeBodyPart part = (MimeBodyPart)getBodyPart(i); String s = part.getContentID(); if (s != null && s.equals(CID)) return part; } return null; }
/** * Get the MimeBodyPart referred to by the given ContentID (CID). * Returns null if the part is not found. * * @param CID the ContentID of the desired part * @return the Part * @exception MessagingException for failures */ public synchronized BodyPart getBodyPart(String CID) throws MessagingException { parse(); int count = getCount(); for (int i = 0; i < count; i++) { MimeBodyPart part = (MimeBodyPart)getBodyPart(i); String s = part.getContentID(); if (s != null && s.equals(CID)) return part; } return null; }
/** * Get the MimeBodyPart referred to by the given ContentID (CID). * Returns null if the part is not found. * * @param CID the ContentID of the desired part * @return the Part * @exception MessagingException for failures */ public synchronized BodyPart getBodyPart(String CID) throws MessagingException { parse(); int count = getCount(); for (int i = 0; i < count; i++) { MimeBodyPart part = (MimeBodyPart)getBodyPart(i); String s = part.getContentID(); if (s != null && s.equals(CID)) return part; } return null; }
private void initMultipart(MimeMultipart multipart) throws MessagingException { this.mimeMP = multipart; MimeBodyPart part = (MimeBodyPart) multipart.getBodyPart(0); setSoapMessage(new SimpleAttachment(part.getContentID(), part.getDataHandler())); for ( int i = 1; i < multipart.getCount(); i++ ) { part = (MimeBodyPart) multipart.getBodyPart(i); String id = part.getContentID(); if (id.startsWith("<")) { id = id.substring(1, id.length() - 1); } addPart(new SimpleAttachment(id, part.getDataHandler())); } }
MimeBodyPart part = (MimeBodyPart) multipart.getBodyPart(i); if (part != contentPart) { String id = part.getContentID(); if (id == null) { id = "Part" + i;
/** * Correctly resolves file name from the message part. * Thanx to: Flavio Pompermaier * * @param part {@link Part} to decode file name from. * @return String containing file name. */ public static String resolveFileName(final Part part) throws MessagingException { if (!(part instanceof MimeBodyPart)) { return part.getFileName(); } final String contentType = part.getContentType(); String ret; try { ret = MimeUtility.decodeText(part.getFileName()); } catch (final Exception ex) { // String[] contentId = part.getHeader("Content-ID"); // if (contentId != null && contentId.length > 0) { final String contentId = ((MimeBodyPart) part).getContentID(); if (contentId != null) { ret = contentId + contentTypeForFileName(contentType); } else { ret = defaultFileName(contentType); } } return ret; }
final String sRealContentID = StringHelper.trimStartAndEnd (aBodyPart.getContentID (), '<', '>'); ret.setId (sRealContentID);