Exemplo n.º 1
0
  private static Map<String, Attachment> saveAttachments(
      Collection<MimePart> partsToAttach, Resource container)
      throws MessagingException, IOException, NoSuchAlgorithmException {
    Map<String, Attachment> result = new HashMap<>();

    for (MimePart partToAttach : partsToAttach) {
      Attachment attachment = saveAttachment(partToAttach, container);
      if (partToAttach.getContentID() != null) {
        String cid = partToAttach.getContentID().trim();
        cid = cid.replace("<", "");
        cid = cid.replace(">", "");
        result.put(cid, attachment);
      }
    }

    return result;
  }
Exemplo n.º 2
0
 /**
  * Returns true if the given part is root part.
  *
  * <p>The given part is root part, if the part is the first one and the given root id is not
  * defined or the content id of the part equals to the given root id.
  *
  * @param part
  * @param nthPart
  * @param rootId
  * @return
  * @throws MessagingException
  */
 private static boolean isRootPart(MimePart part, int nthPart, String rootId)
     throws MessagingException {
   return (rootId == null && nthPart == 0) || StringUtils.equals(part.getContentID(), rootId);
 }