Пример #1
0
  /**
   * Get an AppointmentItem using soap
   *
   * @param account
   * @param query
   * @param start
   * @param end
   * @return
   * @throws HarnessException
   */
  public static AppointmentItem importFromSOAP(
      ZimbraAccount account, String query, ZDate start, ZDate end) throws HarnessException {

    try {
      account.soapSend(
          "<SearchRequest xmlns='urn:zimbraMail' types='appointment' calExpandInstStart='"
              + start.toMillis()
              + "' calExpandInstEnd='"
              + end.toMillis()
              + "'>"
              + "<query>"
              + query
              + "</query>"
              + "</SearchRequest>");

      Element[] results = account.soapSelectNodes("//mail:SearchResponse/mail:appt");
      if (results.length != 1)
        // throw new HarnessException("Query should return 1 result, not "+ results.length);
        return null;

      String id = account.soapSelectValue("//mail:appt", "id");

      account.soapSend(
          "<GetAppointmentRequest xmlns='urn:zimbraMail' id='"
              + id
              + "' includeContent='1'>"
              + "</GetAppointmentRequest>");
      Element getAppointmentResponse = account.soapSelectNode("//mail:GetAppointmentResponse", 1);

      // Using the response, create this item
      return (importFromSOAP(getAppointmentResponse));

    } catch (Exception e) {
      throw new HarnessException(
          "Unable to import using SOAP query("
              + query
              + ") and account("
              + account.EmailAddress
              + ")",
          e);
    }
  }
Пример #2
0
  public static TaskItem importFromSOAP(ZimbraAccount account, String query)
      throws HarnessException {

    try {

      account.soapSend(
          "<SearchRequest xmlns='urn:zimbraMail' types='task' >"
              + "<query>"
              + query
              + "</query>"
              + "</SearchRequest>");

      Element[] results = account.soapSelectNodes("//mail:SearchResponse/mail:task");
      if (results.length != 1)
        throw new HarnessException("Query should return 1 result, not " + results.length);

      String invId = account.soapSelectValue("//mail:SearchResponse/mail:task", "invId");

      account.soapSend(
          "<GetMsgRequest xmlns='urn:zimbraMail'>"
              + "<m id='"
              + invId
              + "' />"
              + "</GetMsgRequest>");
      Element getMsgResponse = account.soapSelectNode("//mail:GetMsgResponse", 1);

      // Using the response, create this item
      return (importFromSOAP(getMsgResponse));

    } catch (Exception e) {
      throw new HarnessException(
          "Unable to import using SOAP query("
              + query
              + ") and account("
              + account.EmailAddress
              + ")",
          e);
    }
  }
Пример #3
0
  public static SignatureItem importFromSOAP(ZimbraAccount account, String name)
      throws HarnessException {

    if (account == null) throw new HarnessException("account cannot be null");
    if (name == null) throw new HarnessException("name cannot be null");
    if (name.trim().length() == 0)
      throw new HarnessException("name cannot be empty: (" + name + ")");

    try {
      account.soapSend("<GetSignaturesRequest xmlns='urn:zimbraAccount'/>");
      Element[] results = account.soapSelectNodes("//acct:signature[@name='" + name + "']");
      return (importFromSOAP(results[0]));

    } catch (Exception e) {
      throw new HarnessException(
          "Unable to import using SOAP name("
              + name
              + ") and account("
              + account.EmailAddress
              + ")",
          e);
    }
  }