Updated May 17th: I posted some of the issues that I had to the ATOM working group. Their advice, as ever, was very useful. I have updated the post to contain their recommendations and so no longer require content negotiation.
Updated, May 12th: In recent discussions it has been pointed out to me that I don’t need to choose a specific format for the exchange format (I had previously limited CalAtom to xCal). I have made significant changes to the post to reflect these thoughts.
CalDav is close to final call. I have read the spec and it seems that the bar to implement is fairly high. The spec is 90 pages long, excluding appendices, and it builds upon many other specifications. Google’s Calendar Data api, on the other hand, seems like a much simpler approach but doesn’t reuse any existing calendaring specifications and in no way comes close to the feature set that is in CalDav. CalAtom would be an attempt to rework CalDav to have the underlying protocol be APP instead of WebDav. I think this has the potential to simplify clients and servers and can build on some recent advances in data storage.
The first decision that needs to be made is the data format that will be exchanged by clients and servers. The most natural is iCalendar and this was the one chosen by CalDav. The iCalendar format has also been mapped to xml (xCal, xCalendar) and to rdf (rdfCal). ATOM will actually let us support and mix all of them together and this is the path that I now want to explore. It is worth noting that 30 pages of the CalDav specification are devoted to querying. It would be nice if, instead, we could use a standard query language. There have already been some examples of this. If CalAtom could use a standard search api such as sql, xquery or even sparql then that may save a lot of work, especially if our data store natively supported the chosen query language. Given that ATOM is in xml and that oracle, db2 and sqlserver now support xml storage it would seem that one avenue of investigation should be XQuery or XPath.
So, how would CalAtom work? First up, there would need to be an ATOM collection that can accept calendar posts. The ATOM introspection document would declare a collection that “accepts” data of the appropriate media type e.g. “application/calendar+xml”., “text/calendar” or “application/rdf+xml” (I can’t find a mime type for rdfCal). So with James’s new magic, proposed for the next draft of the atom publishing protocol, the introspection document looks like this.
<?xml version="1.0" encoding='utf-8'?> <service xmlns="http://purl.org/atom/app#"> <workspace title="Main Site" > <collection title="My Calendar" href="http://example.org/calendar" > <accept>application/calendar+xml, text/calendar, application/rdf+xml</accept> </collection> </workspace> </service>
A client can now determine that the “My Calendar” collection will accept xCal, iCalendar and rdfCal (hand waving for rdfCal, as the accept element isn’t limiting enough). So far, so good. Now to create a Calendar event. (For anyone paying real close attention I am going to assume that we follow the same rules for the xCal posts as outlined in section 4.1 of the current CalDav draft, we probably also need some additional extensions to the introspection document that govern the type of xCal entry i.e. vType, vEvent, vJournal or vFreebusy, we’ll ignore this for now). So to create a simple calendar event this is the post (if we are posting as xCal)
POST /calendar HTTP/1.1 Host: example.org User- Agent: Thingio/1.0 Content- Type: application/calendar+xml Content- Length: nnn <?xml version="1.0" encoding="UTF-8"?> <vcalendar version="2.0" prodid="-//hacksw/handcal//NONSGML 1.0//EN"> <vevent> <uid>19970901T130000Zfirstname.lastname@example.org</uid> <dtstamp>19970901T130000Z</dtstamp> <dtstart>19970903T163000Z</dtstart> <dtend>19970903T190000Z</dtend> <summary>Annual Employee Review</summary> <class>PRIVATE</class> <categories> <item>Business</item> <item>Human Resources</item> </categories> </vevent> </vcalendar> with response HTTP/1.1 201 Created Date: Fri, 7 Oct 2005 17:17:11 GMT Content- Length: nnn Content- Type: application/atom+xml; charset="utf-8" Content- Location: http://example.org/calendar/1.atom Location: http://example.org/calendar/1.atom <?xml version="1.0"?> <entry xmlns="http://www.w3.org/2005/Atom"> <title>Annual Employee Review</title> <id>urn:uuid:1225c695-cfb8-4ebb-aaaa-80da344efa6a</id> <updated>2003-12-13T18:30:02Z</updated> <author><name>John Doe</name></author> <summary type="text" /> <link rel="alternate" type="text/calendar" href="http://example.org/calendar/1.ics" /> <link rel="alternate" type="application/rdf+xml" href="http://example.org/calendar/1.rdf" /> <content type="application/calendar+xml" src=http://example.org/calendar/1.xml/> <link rel="edit" type="application/atom+xml" href="http://example.org/calendar/1.atom" /> <link rel="edit-media" type="application/calendar+xml" href=”http://example.org/calendar/1.xml” /> <link rel="edit-media" type="text/calendar" href="http://example.org/calendar/1.ics" /> <link rel="edit-media" type="application/rdf+xml" href="http://example.org/calendar/1.rdf" /> </entry>
So this looks like it will work. Note that the response actually lists 3 “edit-media” urls. The server has accepted a post with an xCal body and made available editable representations of it in its original xcal and also in two additional formats. The server would also accept iCalendar or rdfCal posts. This seems really nice, clients can choose the representation that they want to work with and edit that one. Conventional APP can now be used to get paged access to the collection and to manipulate the collection. This gets us CRUD operations on calendaring resources and as a bonus we also have a feed to the calendar that gets updated when entries change or get added, however it is still a long long way from CalDav.
There are several things still needed, but they all look very doable. I am going to punt on Access Control, although there are some starts on this. Access control will eventually be needed in APP and so we will wait for that discussion to get started. It also appears that CalDav’s Calendar Collection properties (section 5.2) shouldn’t be too difficult to incorporate (they are simply extensions in the Introspection document). Then the biggest remaining item and admittedly the hardest part is querying the calendar, repeating events force things to get complicated pretty quickly and so I am going to leave that for another day, although it seems that the use of XPath or Xquery is going to be the way to go here. For the record Google has very limited query capability at the moment when compared to CalDav.
CalAtom seems to hold a lot of promise, it has (in Atom) a simpler underlying model than CalDav. ATOM and APP has already enticed google into giving it a go for Calendaring and so it seems worthy of further investigation. The challenge for APP is whether it is currently specified enough to start tackling problems outside of its blogging homeland. Only time will tell.