org.jasig.schedassist.impl.caldav
Class DefaultCaldavDialectImpl

java.lang.Object
  extended by org.jasig.schedassist.impl.caldav.DefaultCaldavDialectImpl
All Implemented Interfaces:
CaldavDialect
Direct Known Subclasses:
OracleCommsCaldavDialectImpl

public class DefaultCaldavDialectImpl
extends Object
implements CaldavDialect

Class to encapsulate generation of the dialect between the scheduling assistant and the CalDAV server.

Version:
$Id: DefaultCaldavDialectImpl.java 51 2011-05-06 14:35:33Z nblair $
Author:
Nicholas Blair, nblair@doit.wisc.edu

Field Summary
protected static String DATE_FORMAT
          Date format expected by CalDAV servers.
protected static net.fortuna.ical4j.model.property.ProdId PROD_ID
          ProdId attached to Calendars sent to the CalDAV server by the Scheduling Assistant.
 
Constructor Summary
DefaultCaldavDialectImpl()
           
 
Method Summary
protected  String formatDateTime(Date date)
          Convert the date to a String using the format:
 org.apache.commons.httpclient.methods.RequestEntity generateGetCalendarRequestEntity(Date startDate, Date endDate)
          Generate an appropriate RequestEntity body for retrieving Calendar data between the specified dates.
protected  String generateGetCalendarRequestXML(Date startDate, Date endDate)
          Generate the XML that makes up a valid CalDAV calendar-query request body that would be issued with a REPORT request for Calendar events between the 2 Date arguments.
 org.apache.commons.httpclient.methods.RequestEntity generatePutAppointmentRequestEntity(net.fortuna.ical4j.model.component.VEvent event)
          Generate an appropriate RequestEntity body for storing the specified VEvent.
 String getAccountHomePrefix()
           
 String getAccountHomeSuffix()
           
 URI getCaldavHost()
          Return a URI that resolves to the root address of the CalDAV server, e.g.
 String getCalendarAccountHome(ICalendarAccount calendarAccount)
          Returns a String that represents the "Path" the ICalendarAccount's calendar home directory.
 URI resolveCalendarURI(CalendarWithURI calendar)
          Return a URI that represents the full URI to the URI field within the CalendarWithURI.
 void setAccountHomePrefix(String accountHomePrefix)
           
 void setAccountHomeSuffix(String accountHomeSuffix)
           
 void setCaldavHost(URI caldavHost)
          Annotated with Resource to allow injection by name.
protected  net.fortuna.ical4j.model.Calendar wrapEventInCalendar(net.fortuna.ical4j.model.component.VEvent event)
          Wrap the event in a Calendar.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DATE_FORMAT

protected static final String DATE_FORMAT
Date format expected by CalDAV servers.

See Also:
Constant Field Values

PROD_ID

protected static final net.fortuna.ical4j.model.property.ProdId PROD_ID
ProdId attached to Calendars sent to the CalDAV server by the Scheduling Assistant.

Constructor Detail

DefaultCaldavDialectImpl

public DefaultCaldavDialectImpl()
Method Detail

getAccountHomePrefix

public String getAccountHomePrefix()
Returns:
the accountHomePrefix

setAccountHomePrefix

public void setAccountHomePrefix(String accountHomePrefix)
Parameters:
accountHomePrefix - the accountHomePrefix to set

getAccountHomeSuffix

public String getAccountHomeSuffix()
Returns:
the accountHomeSuffix

setAccountHomeSuffix

public void setAccountHomeSuffix(String accountHomeSuffix)
Parameters:
accountHomeSuffix - the accountHomeSuffix to set

getCaldavHost

public URI getCaldavHost()
Description copied from interface: CaldavDialect
Return a URI that resolves to the root address of the CalDAV server, e.g. 'http://localhost:8080'

Specified by:
getCaldavHost in interface CaldavDialect
Returns:
never null URI for the CalDAV server

setCaldavHost

public void setCaldavHost(URI caldavHost)
Annotated with Resource to allow injection by name.

Parameters:
caldavHost - the caldavHost to set

generateGetCalendarRequestEntity

public org.apache.commons.httpclient.methods.RequestEntity generateGetCalendarRequestEntity(Date startDate,
                                                                                            Date endDate)
Description copied from interface: CaldavDialect
Generate an appropriate RequestEntity body for retrieving Calendar data between the specified dates.

Specified by:
generateGetCalendarRequestEntity in interface CaldavDialect
Returns:
a RequestEntity used with the REPORT request to retrieve an account's Calendar data between the 2 Dates

generateGetCalendarRequestXML

protected String generateGetCalendarRequestXML(Date startDate,
                                               Date endDate)
Generate the XML that makes up a valid CalDAV calendar-query request body that would be issued with a REPORT request for Calendar events between the 2 Date arguments.

Parameters:
startDate -
endDate -
Returns:
calendar-query XML content for REPORT request

generatePutAppointmentRequestEntity

public org.apache.commons.httpclient.methods.RequestEntity generatePutAppointmentRequestEntity(net.fortuna.ical4j.model.component.VEvent event)
Description copied from interface: CaldavDialect
Generate an appropriate RequestEntity body for storing the specified VEvent. Per the CalDAV RFC:
 
                PUT /home/lisa/calendars/events/qwue23489.ics HTTP/1.1
                If-None-Match: *
                Host: cal.example.com
                Content-Type: text/calendar
                Content-Length: xxxx

                BEGIN:VCALENDAR
                VERSION:2.0
                PRODID:-//Example Corp.//CalDAV Client//EN
                BEGIN:VEVENT
                UID:20010712T182145Z-123401@example.com
                DTSTAMP:20060712T182145Z
                DTSTART:20060714T170000Z
                DTEND:20060715T040000Z
                SUMMARY:Bastille Day Party
                END:VEVENT
                END:VCALENDAR
         
This method is focused on all of the content in the above example with the exception of the very first line ('PUT /home/lisa...').

Specified by:
generatePutAppointmentRequestEntity in interface CaldavDialect
Returns:
a RequestEntity used with the PUT request to store the specified VEvent

getCalendarAccountHome

public String getCalendarAccountHome(ICalendarAccount calendarAccount)
Description copied from interface: CaldavDialect
Returns a String that represents the "Path" the ICalendarAccount's calendar home directory. The calendar home directory is used as the base path for retrieving/storing calendar data for that calendar account. The return value MUST be terminated with a "/".

Specified by:
getCalendarAccountHome in interface CaldavDialect
Returns:
the calendar home directory path for the specified calendar account.

resolveCalendarURI

public URI resolveCalendarURI(CalendarWithURI calendar)
Description copied from interface: CaldavDialect
Return a URI that represents the full URI to the URI field within the CalendarWithURI. It's common for CalDAV servers to respond with just a path (e.g. /caldav/some/user/file.ics) in the href attribute for a calendar-query method response. The intent of this method is to return a string that is composed of:
         caldavhost + calendarWithUri.getUri()
         
Implementations may need to adjust from above, but the primary responsibility of this method is to return a string that looks like:
         http://hostname.somewhere.org:8080/caldav/some/user/file.ics
         

Specified by:
resolveCalendarURI in interface CaldavDialect
Returns:
the resolved complete URI to the calendar on the CalDAV server

formatDateTime

protected String formatDateTime(Date date)
Convert the date to a String using the format:
         yyyyMMdd'T'HHmmssZ
         

Parameters:
date -
Returns:

wrapEventInCalendar

protected net.fortuna.ical4j.model.Calendar wrapEventInCalendar(net.fortuna.ical4j.model.component.VEvent event)
Wrap the event in a Calendar. TODO duplicate of eventUtils function, wire in dependency

Parameters:
event -
Returns:


Copyright © 2011 Jasig. All Rights Reserved.