Beispiel #1
0
  public static SignatureItem importFromSOAP(Element sig) throws HarnessException {

    if (sig == null) throw new HarnessException("Element cannot be null");

    SignatureItem item = null;

    try {

      // Make sure we only have the <tag/> part
      Element t = ZimbraAccount.SoapClient.selectNode(sig, "//acct:signature");
      if (t == null) throw new HarnessException("Element does not contain an <tag/> element");

      // Create the object
      item = new SignatureItem();

      // Set the ID
      item.setId(t.getAttribute("id", null));
      // Set tag name
      item.setName(t.getAttribute("name", null));

      Element contentBodyHtml =
          ZimbraAccount.SoapClient.selectNode(sig, "//acct:content[@type='text/html']");
      Element contentBodyText =
          ZimbraAccount.SoapClient.selectNode(sig, "//acct:content[@type='text/plain']");
      if (contentBodyHtml != null) {
        item.dBodyHtmlText = contentBodyHtml.getText().trim();
      } else if (contentBodyText != null) {
        item.dBodyText = contentBodyText.getText().trim();
      }

      return (item);

    } catch (Exception e) {
      throw new HarnessException("Could not parse GetMsgResponse: " + sig.prettyPrint(), e);
    } finally {
      if (item != null) logger.info(item.prettyPrint());
    }
  }