Note: This is a bit of a long post.

As stated previously in the chat, that I was working on Initial synchronizing and storing of events. With respect to tests, since, I was working on caldav4j, at the time, most of my tests have been assimilated there, here's a couple of method tests which are used for syncing and so forth:

https://github.com/TheAntimist/caldav4j/blob/jcr-dev/src/test/java/org/osaf/caldav4j/methods/NewPropFindTest.java
https://github.com/TheAntimist/caldav4j/blob/jcr-dev/src/test/java/org/osaf/caldav4j/methods/NewCalDAVReportTest.java

The rest of the method tests can be found here:

https://github.com/TheAntimist/caldav4j/tree/jcr-dev/src/test/java/org/osaf/caldav4j/methods

Other than this, I have felt the need for updating the Appointment Entities, and addition of a new Entity called OmCalendar or Calendar entity. Modifications to be made are below:
 - Appointment:
   + Add href i.e. location of event on the server or local.
+ Add OmCalendar object, for the parent calendar to which the Appointment Belongs.
   + icalid, can be used as etags for Appointment. or UID.

 - OmCalendar: This is a tentative list of objects it will encompass
   + href
   + displayname/title
+ user (Seems redundant to have both Appointment user and Calendar user, as Appointments should now be associated to specfic Calendars)
   + sync-token (To store the sync-token or ctag of the calendar)
+ isDisabled, if there is an issue reaching the calendar server, it's set to true.

With respect to sync, I am implementing two ways:

     - Changelog Based:
     This uses PROPFIND method built into CalDAV.
First step during initial sync, would be to get a "ctag" i.e. calendar tag, for the CalDAV server. (Note this has been obsoleted by WebDAV-Sync, now) and "displayname", which is the title of the Calendar.

If it returns a 404 or UnknownHostException, then we can set the calendar to be disabled. As, we can't reach the server.

     After this, we store all these initial info to the DB, using OpenJPA.

Then, we use a "calendar-query" REPORT method, built into CalDAV, for retrieval of all the events and their "etag", which is their identifier and sync tags. Along with this we also request the "calendar-data", associated with the events.

After the events are received, we send the Calendar-Data through a ical parser, which gives back an Appointment object, which will then be stored in the database.

For subsequent updates, we initially check the "ctag", if it's different than the one we have, then we perform a sync operation again, where we have to handle three types of cases: - etag of events have changed and thus, have to be updated to the calendar.
       - There's a new event.
       - event is missing, i.e. that event is deleted.

    - WebDAV-Sync (defined in RFC 6578):
This, will to be implemented as an extension to the REPORT method in DAV. But this makes the job of syncing much simpler. Only thing is that not all servers do support it, but if they do support it, then it's always worth implementing this, for syncing large calendars.

For the syncing part, initially, we request from the server a "sync-token" which, is like the "ctag". After acquiring the sync-token, we then send s "sync" REPORT to the server, with our token.

The response of the REPORT will be a list of changes on the server, specifying all the objects, for that token. Similar to the Changelog Based, method, there can be three cases: addition of new event, modified event, and/or deleted event.

After that, we again parse the calendar-data of these events and store them as Appointments.

For the creating and deleting and updating Appointments in AppointmentDialog, we use the PUT and DELETE method, by converting the Appointment to be created into ical using icalhandler.

Future Plans:

- After the client and Calendar Handling is complete, the following UI modifications need to be made to handle the new Calendars and so on.: There will be a need to modify the CalendarPanel object to include a left pane for Calendars.
   Something like this: http://i.imgur.com/gwluIyx.png

AppointmentModel.load() needs to check for all the calendars, to which the User belongs to, and display all the events related to it. AppointmentDialog, will need to check whether it's a local calendar or a caldav calendar, could be simple by checking if the url is null or empty. Along with this, create and delete events will have to be modified, to work with caldav.

--
Ankush Mishra

Reply via email to