Example #1
0
  /**
   * Set up basic quick commands for all combinations
   *
   * @throws HarnessException
   */
  @Bugs(ids = "71389") // Hold off on GUI implementation of Quick Commands in 8.X
  //	@BeforeClass( groups = { "always" } )
  public void addQuickCommands() throws HarnessException {
    logger.info("addQuickCommands: start");

    // Create a quick command in the user preferences
    ZimbraAccount.AccountZWC()
        .soapSend(
            "<ModifyPrefsRequest xmlns='urn:zimbraAccount'>"
                + "<pref name='zimbraPrefQuickCommand'>"
                + this.getQuickCommand01().toString()
                + "</pref>"
                + "<pref name='zimbraPrefQuickCommand'>"
                + this.getQuickCommand02().toString()
                + "</pref>"
                + "<pref name='zimbraPrefQuickCommand'>"
                + this.getQuickCommand03().toString()
                + "</pref>"
                + "</ModifyPrefsRequest>");

    // Re-login to pick up the new preferences
    super.startingPage.zRefresh();

    // The AjaxCommonTest.commonTestBeforeMethod() method will log into the client

    logger.info("addQuickCommands: finish");
  }
Example #2
0
  public AjaxQuickCommandTest() {
    logger.info("New " + AjaxQuickCommandTest.class.getCanonicalName());

    command1 = null;
    command2 = null;
    command3 = null;
  }
Example #3
0
  public static TaskItem importFromSOAP(Element GetMsgResponse) throws HarnessException {

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

    TaskItem task = null;

    try {

      // Make sure we only have the GetMsgResponse part
      Element getMsgResponse =
          ZimbraAccount.SoapClient.selectNode(GetMsgResponse, "//mail:GetMsgResponse");

      if (getMsgResponse == null)
        throw new HarnessException("Element does not contain GetMsgResponse");
      Element m = ZimbraAccount.SoapClient.selectNode(getMsgResponse, "//mail:comp");
      if (m == null) throw new HarnessException("Element does not contain an m element");

      // Create the object
      task = new TaskItem();
      // Set task body
      task.settaskBody(m.getAttribute("desc", null));
      // Set task name
      task.setName(m.getAttribute("name", null));
      // Set task id
      task.setId(m.getAttribute("calItemId", null));
      task.setHtmlTaskBody(m.getAttribute("descHtml", null));
      // TODO: parse the <m/> element

      return (task);

    } catch (Exception e) {
      throw new HarnessException(
          "Could not parse GetMsgResponse: " + GetMsgResponse.prettyPrint(), e);
    } finally {
      if (task != null) logger.info(task.prettyPrint());
    }
  }
  public static AppointmentItem importFromSOAP(Element GetAppointmentResponse)
      throws HarnessException {

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

    AppointmentItem appt = null;

    try {

      // Make sure we only have the GetMsgResponse part
      Element getAppointmentResponse =
          ZimbraAccount.SoapClient.selectNode(
              GetAppointmentResponse, "//mail:GetAppointmentResponse");
      if (getAppointmentResponse == null)
        throw new HarnessException("Element does not contain GetAppointmentResponse");

      Element m = ZimbraAccount.SoapClient.selectNode(getAppointmentResponse, "//mail:appt");
      if (m == null) throw new HarnessException("Element does not contain an appt element");

      // Create the object
      appt = new AppointmentItem();

      if (m != null) {

        // Appointment id
        appt.dApptID = m.getAttribute("id");
      }

      String parentFolder = m.getAttribute("l");
      if (parentFolder != null) {

        // Parent folder
        appt.dFolder = parentFolder;
      }

      Element sElement = ZimbraAccount.SoapClient.selectNode(m, "//mail:s");
      if (sElement != null) {

        // Start time
        appt.dStartTime = new ZDate(sElement);
      }

      Element eElement = ZimbraAccount.SoapClient.selectNode(m, "//mail:e");
      if (eElement != null) {

        // End time
        appt.dEndTime = new ZDate(eElement);
      }

      Element compElement = ZimbraAccount.SoapClient.selectNode(m, "//mail:comp");
      if (compElement != null) {

        // Subject
        appt.dSubject = compElement.getAttribute("name");

        // Location
        appt.dLocation = compElement.getAttribute("loc");

        // Display
        appt.dDisplay = compElement.getAttribute("fb");
      }

      Element oElement = ZimbraAccount.SoapClient.selectNode(m, "//mail:or");
      if (oElement != null) {

        // Organizer
        appt.dOrganizer = oElement.getAttribute("a");
      }
      Element mpElement = ZimbraAccount.SoapClient.selectNode(m, "//mail:mp");
      if (mpElement != null) {

        // Get multipart
        appt.dMultipart = mpElement;
      }
      // Parse the required attendees
      ArrayList<String> attendees = new ArrayList<String>();
      Element[] requiredElements =
          ZimbraAccount.SoapClient.selectNodes(m, "//mail:at[@role='REQ']");
      for (Element e : requiredElements) {
        attendees.add(e.getAttribute("a"));
      }
      if (attendees.size() > 0) {
        appt.dAttendees = AppointmentItem.StringListToCommaSeparated(attendees);
      }

      // Parse the optional attendees
      ArrayList<String> optionals = new ArrayList<String>();
      Element[] optionalElements =
          ZimbraAccount.SoapClient.selectNodes(m, "//mail:at[@role='OPT']");
      for (Element e : optionalElements) {
        optionals.add(e.getAttribute("a"));
      }
      if (optionals.size() > 0) {
        appt.dOptionals = AppointmentItem.StringListToCommaSeparated(optionals);
      }

      if (appt.dLocation == "") {

        Element equipElement = ZimbraAccount.SoapClient.selectNode(m, "//mail:at[@cutype='RES']");
        if (equipElement != null) {

          // Equipment
          appt.dEquipment = equipElement.getAttribute("a");
        }

      } else if (appt.dLocation != null) {

        Element equipElement =
            ZimbraAccount.SoapClient.selectNode(m, "//mail:at[@cutype='RES'][2]");
        if (equipElement != null) {

          // Equipment
          appt.dEquipment = equipElement.getAttribute("a");
        }
      }

      Element descElement = ZimbraAccount.SoapClient.selectNode(m, "//mail:fr");
      if (descElement != null) {

        // Body
        appt.dContent = descElement.getTextTrim();
      }

      return (appt);

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