示例#1
0
 @Override
 public synchronized void addBodyPart(BodyPart part, int index) throws MessagingException {
   if (ZPARSER) {
     if (part.getParent() != null) {
       ZimbraLog.misc.warn("adding part that already has a parent");
     }
     if (part instanceof JavaMailMimeBodyPart) {
       JavaMailMimeBodyPart jmpart = (JavaMailMimeBodyPart) part;
       com.zimbra.common.mime.MimePart mp = jmpart.getZimbraMimePart();
       zmultipart.addPart(mp, index);
       partMap.put(mp, jmpart);
       jmpart.setParent(this);
     } else {
       // FIXME: turn the non-shim body part into a shim body part
       throw new IllegalArgumentException("must use JavaMailMimeBodyPart instance as body part");
     }
   } else {
     super.addBodyPart(part, index);
   }
 }
示例#2
0
  /**
   * Fuegt einen DisplayPart hinzu.
   *
   * @param part Aktuell zu behandelnder Part
   * @param displayParts List, in die die DisplayParts einsortiert werden.
   * @param multiparts Map, in die Multiparts gepackt werden.
   */
  private static void addDisplayPart(
      Part part, List<Part> displayParts, Map<Multipart, List<Integer>> multiparts) {

    // Wenn dieser Part ein BodyPart (Teil eines Multipart) ist, Parent
    // heraus-
    // finden und DisplayPart-Nummer in multipart-Map merken
    if (part instanceof BodyPart) {

      BodyPart actPart = (BodyPart) part;
      Multipart parent = actPart.getParent();

      if (parent != null) {

        // Unter "multipart.get(parent)" muss eine Liste existieren, zu
        // der wir
        // die DisplayPart-Nummer (= Groesse der DisplayPart-List)
        // adden.
        ((List<Integer>) multiparts.get(parent)).add(new Integer(displayParts.size()));
      }
    }

    displayParts.add(part);
  }