Search in sources :

Example 1 with ZApptSummaryResult

use of com.zimbra.client.ZMailbox.ZApptSummaryResult in project zm-mailbox by Zimbra.

the class ZMailboxUtil method doGetAppointmentSummaries.

/*


<CreateAppointmentRequest xmlns="urn:zimbraMail">
 <m d="1173202005230" l="10">
  <inv>
   <comp status="CONF" fb="B" transp="O" allDay="0" name="test yearly">
    <s tz="(GMT-08.00) Pacific Time (US &amp; Canada)" d="20070308T130000"/>
    <e tz="(GMT-08.00) Pacific Time (US &amp; Canada)" d="20070308T150000"/>
      <or a="user1@slapshot.liquidsys.com"/>
       <recur>
        <add>
         <rule freq="YEA">
            <interval ival="1"/>
         </rule>
        </add>
      </recur>
    </comp></inv><su>test yearly</su><mp ct="multipart/alternative"><mp ct="text/plain"><content></content></mp><mp ct="text/html"><content>&lt;html&gt;&lt;body&gt;&lt;/body&gt;&lt;/html&gt;</content></mp></mp></m></CreateAppointmentRequest>
     */
/*
    private void testCreateAppt() throws ServiceException {

        ZMailbox.ZOutgoingMessage message = new ZOutgoingMessage();
        message.setSubject("test zclient API");
        message.setMessagePart(new MessagePart("text/plain", "this is da body"));
        ZInvite invite = new ZInvite();
        ZComponent comp = new ZComponent();
        comp.setStart(new ZDateTime("20070309T170000", mMbox.getPrefs().getTimeZoneWindowsId()));
        comp.setEnd(new ZDateTime("20070309T210000", mMbox.getPrefs().getTimeZoneWindowsId()));
        comp.setOrganizer(new ZOrganizer(mMbox.getName()));
        comp.setName("test zclient API");
        comp.setLocation("Zimbra");
        invite.getComponents().add(comp);

        ZAppointmentResult response = mMbox.createAppointment(ZFolder.ID_CALENDAR, null, message, invite, null);
        stdout.printf("calItemId(%s) inviteId(%s)%n", response.getCalItemId(), response.getInviteId());
    }
*/
private void doGetAppointmentSummaries(String[] args) throws ServiceException {
    long startTime = DateUtil.parseDateSpecifier(args[0], new Date().getTime());
    long endTime = DateUtil.parseDateSpecifier(args[1], (new Date().getTime()) + Constants.MILLIS_PER_WEEK);
    String folderId = args.length == 3 ? lookupFolderId(args[2]) : null;
    List<ZApptSummaryResult> results = mMbox.getApptSummaries(null, startTime, endTime, new String[] { folderId }, TimeZone.getDefault(), ZSearchParams.TYPE_APPOINTMENT);
    if (results.size() != 1)
        return;
    ZApptSummaryResult result = results.get(0);
    stdout.print("[");
    boolean first = true;
    for (ZAppointmentHit appt : result.getAppointments()) {
        if (!first)
            stdout.println(",");
        stdout.print(ZJSONObject.toString(appt));
        if (first)
            first = false;
    }
    stdout.println("]");
}
Also used : ZAppointmentHit(com.zimbra.client.ZAppointmentHit) ZApptSummaryResult(com.zimbra.client.ZMailbox.ZApptSummaryResult) Date(java.util.Date)

Aggregations

ZAppointmentHit (com.zimbra.client.ZAppointmentHit)1 ZApptSummaryResult (com.zimbra.client.ZMailbox.ZApptSummaryResult)1 Date (java.util.Date)1