org.jasig.schedassist.impl.caldav
Class CaldavCalendarDataDaoImpl

java.lang.Object
  extended by org.jasig.schedassist.impl.caldav.CaldavCalendarDataDaoImpl
All Implemented Interfaces:
ICalendarDataDao, org.springframework.beans.factory.InitializingBean

@Service
public class CaldavCalendarDataDaoImpl
extends Object
implements ICalendarDataDao, org.springframework.beans.factory.InitializingBean

Implementation of ICalendarDataDao for CalDAV-capable calendar servers. Requires the following be provided (via setter injection):

The cancelUpdatesVisitorCalendar property can be useful for CalDAV servers that do not delete appointments in an attendee's calendar when the organizer deletes the event. Oracle Communications Suite Calendar server for example will not delete the event from the visitor's calendar when the event is removed from the owner's calendar; the event remains with it's STATUS property set to CANCELLED. Setting the caldav.cancelUpdatesVisitorCalendar property to true will add behavior to cancelAppointment(IScheduleVisitor, IScheduleOwner, VEvent) and leaveAppointment(IScheduleVisitor, IScheduleOwner, VEvent) remove the CANCELLED entries from the visitor's calendar. This instance constructs a DefaultCaldavEventUtilsImpl instance with a NullAffiliationSourceImpl; if you need to override the IEventUtils instance, a setter is provided (setEventUtils(IEventUtils)). Lastly this instance constructs a NoopHttpMethodInterceptorImpl instance; if you need to override the HttpMethodInterceptor a setter is provided (setMethodInterceptor(HttpMethodInterceptor)).

Version:
$Id: CaldavCalendarDataDaoImpl.java 50 2011-05-05 21:07:25Z nblair $
Author:
Nicholas Blair, nblair@doit.wisc.edu

Field Summary
protected  org.apache.commons.logging.Log log
           
 
Constructor Summary
CaldavCalendarDataDaoImpl()
           
 
Method Summary
 void afterPropertiesSet()
          Injects the Credentials and AuthScope into the HttpClient's HttpState.
 void cancelAppointment(IScheduleVisitor visitor, IScheduleOwner owner, net.fortuna.ical4j.model.component.VEvent appointment)
           
 void checkForConflicts(IScheduleOwner owner, AvailableBlock block)
           
protected  net.fortuna.ical4j.model.Calendar consolidate(List<CalendarWithURI> calendars)
          Consolidate the Calendars within the argument, returning 1.
 net.fortuna.ical4j.model.component.VEvent createAppointment(IScheduleVisitor visitor, IScheduleOwner owner, AvailableBlock block, String eventDescription)
           
protected  int deleteCalendar(CalendarWithURI calendarWithURI, ICalendarAccount calendarAccount)
           
protected  String generateEventUri(ICalendarAccount owner, net.fortuna.ical4j.model.component.VEvent event)
          This method is intended to generate a unique URI to use with the PUT method in createAppointment(IScheduleVisitor, IScheduleOwner, AvailableBlock, String).
 net.fortuna.ical4j.model.Calendar getCalendar(ICalendarAccount calendarAccount, Date startDate, Date endDate)
           
protected  List<CalendarWithURI> getCalendarsInternal(ICalendarAccount calendarAccount, Date startDate, Date endDate)
           
 net.fortuna.ical4j.model.component.VEvent getExistingAppointment(IScheduleOwner owner, AvailableBlock block)
           
protected  CalendarWithURI getExistingAppointmentInternal(IScheduleOwner owner, Date startTime, Date endTime)
          This method returns the CalendarWithURI containing a single VEvent that was created with the Scheduling Assistant with the specified IScheduleOwner as the owner and the specified start and end times.
protected  CalendarWithURI getExistingAppointmentInternalForVisitor(IScheduleVisitor visitor, Date startTime, Date endTime, net.fortuna.ical4j.model.property.Uid eventUid)
          Special method used when cancelUpdatesVisitorCalendar is set to true.
 net.fortuna.ical4j.model.component.VEvent joinAppointment(IScheduleVisitor visitor, IScheduleOwner owner, net.fortuna.ical4j.model.component.VEvent appointment)
           
 net.fortuna.ical4j.model.component.VEvent leaveAppointment(IScheduleVisitor visitor, IScheduleOwner owner, net.fortuna.ical4j.model.component.VEvent appointment)
           
 List<CalendarWithURI> peekAtAvailableScheduleReflections(IScheduleOwner owner, Date startDate, Date endDate)
           
 void purgeAvailableScheduleReflections(IScheduleOwner owner, Date startDate, Date endDate)
           
protected  CalendarWithURI purgeDeclinedAttendees(CalendarWithURI calendarWithURI, ICalendarAccount owner)
          This method will inspect IScheduleVisitor Attendees among the SchedulingAssistantAppointments in the Calendar argument.
protected  int putExistingEvent(ICalendarAccount eventOwner, net.fortuna.ical4j.model.component.VEvent event, String etag)
          Update an existing event using CalDAV PUT.
protected  int putNewEvent(ICalendarAccount eventOwner, net.fortuna.ical4j.model.component.VEvent event)
          Store a new event using CalDAV PUT.
 void reflectAvailableSchedule(IScheduleOwner owner, AvailableSchedule schedule)
           
 void setApplicationEventPublisher(org.springframework.context.ApplicationEventPublisher applicationEventPublisher)
           
 void setCaldavAdminAuthScope(org.apache.commons.httpclient.auth.AuthScope caldavAdminAuthScope)
           
 void setCaldavAdminCredentials(org.apache.commons.httpclient.Credentials caldavAdminCredentials)
           
 void setCaldavDialect(CaldavDialect caldavDialect)
           
 void setCancelUpdatesVisitorCalendar(String cancelUpdatesVisitorCalendar)
           
 void setEventUtils(IEventUtils eventUtils)
           
 void setHttpClient(org.apache.commons.httpclient.HttpClient httpClient)
           
 void setMethodInterceptor(HttpMethodInterceptor methodInterceptor)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

log

protected final org.apache.commons.logging.Log log
Constructor Detail

CaldavCalendarDataDaoImpl

public CaldavCalendarDataDaoImpl()
Method Detail

setHttpClient

public void setHttpClient(org.apache.commons.httpclient.HttpClient httpClient)
Parameters:
httpClient - the httpClient to set

setCaldavAdminCredentials

public void setCaldavAdminCredentials(org.apache.commons.httpclient.Credentials caldavAdminCredentials)
Parameters:
caldavAdminCredentials - the caldavAdminCredentials to set

setCaldavAdminAuthScope

public void setCaldavAdminAuthScope(org.apache.commons.httpclient.auth.AuthScope caldavAdminAuthScope)
Parameters:
caldavAdminAuthScope - the caldavAdminAuthScope to set

setEventUtils

public void setEventUtils(IEventUtils eventUtils)
Parameters:
eventUtils - the eventUtils to set

setCaldavDialect

public void setCaldavDialect(CaldavDialect caldavDialect)
Parameters:
caldavDialect - the caldavDialect to set

setMethodInterceptor

public void setMethodInterceptor(HttpMethodInterceptor methodInterceptor)
Parameters:
methodInterceptor - the methodInterceptor to set

setApplicationEventPublisher

public void setApplicationEventPublisher(org.springframework.context.ApplicationEventPublisher applicationEventPublisher)
Parameters:
applicationEventPublisher - the applicationEventPublisher to set

setCancelUpdatesVisitorCalendar

public void setCancelUpdatesVisitorCalendar(String cancelUpdatesVisitorCalendar)
Parameters:
cancelUpdatesVisitorCalendar - the cancelUpdatesVisitorCalendar to set

afterPropertiesSet

public void afterPropertiesSet()
                        throws Exception
Injects the Credentials and AuthScope into the HttpClient's HttpState. This task is performed in afterPropertiesSet because HttpState.setCredentials(AuthScope, Credentials)'s method signature is not supported by Spring's DI.

Specified by:
afterPropertiesSet in interface org.springframework.beans.factory.InitializingBean
Throws:
Exception
See Also:
HttpState.setCredentials(AuthScope, Credentials), InitializingBean.afterPropertiesSet()

getCalendar

public net.fortuna.ical4j.model.Calendar getCalendar(ICalendarAccount calendarAccount,
                                                     Date startDate,
                                                     Date endDate)
Specified by:
getCalendar in interface ICalendarDataDao

getExistingAppointment

public net.fortuna.ical4j.model.component.VEvent getExistingAppointment(IScheduleOwner owner,
                                                                        AvailableBlock block)
Specified by:
getExistingAppointment in interface ICalendarDataDao

createAppointment

public net.fortuna.ical4j.model.component.VEvent createAppointment(IScheduleVisitor visitor,
                                                                   IScheduleOwner owner,
                                                                   AvailableBlock block,
                                                                   String eventDescription)
Specified by:
createAppointment in interface ICalendarDataDao

cancelAppointment

public void cancelAppointment(IScheduleVisitor visitor,
                              IScheduleOwner owner,
                              net.fortuna.ical4j.model.component.VEvent appointment)
Specified by:
cancelAppointment in interface ICalendarDataDao

deleteCalendar

protected int deleteCalendar(CalendarWithURI calendarWithURI,
                             ICalendarAccount calendarAccount)
Parameters:
calendarWithURI -
calendarAccount -
Returns:

joinAppointment

public net.fortuna.ical4j.model.component.VEvent joinAppointment(IScheduleVisitor visitor,
                                                                 IScheduleOwner owner,
                                                                 net.fortuna.ical4j.model.component.VEvent appointment)
                                                          throws SchedulingException
Specified by:
joinAppointment in interface ICalendarDataDao
Throws:
SchedulingException

leaveAppointment

public net.fortuna.ical4j.model.component.VEvent leaveAppointment(IScheduleVisitor visitor,
                                                                  IScheduleOwner owner,
                                                                  net.fortuna.ical4j.model.component.VEvent appointment)
                                                           throws SchedulingException
Specified by:
leaveAppointment in interface ICalendarDataDao
Throws:
SchedulingException

checkForConflicts

public void checkForConflicts(IScheduleOwner owner,
                              AvailableBlock block)
                       throws ConflictExistsException
Specified by:
checkForConflicts in interface ICalendarDataDao
Throws:
ConflictExistsException

reflectAvailableSchedule

public void reflectAvailableSchedule(IScheduleOwner owner,
                                     AvailableSchedule schedule)
Specified by:
reflectAvailableSchedule in interface ICalendarDataDao

purgeAvailableScheduleReflections

public void purgeAvailableScheduleReflections(IScheduleOwner owner,
                                              Date startDate,
                                              Date endDate)
Specified by:
purgeAvailableScheduleReflections in interface ICalendarDataDao

peekAtAvailableScheduleReflections

public List<CalendarWithURI> peekAtAvailableScheduleReflections(IScheduleOwner owner,
                                                                Date startDate,
                                                                Date endDate)
Parameters:
owner -
startDate -
endDate -
Returns:

generateEventUri

protected String generateEventUri(ICalendarAccount owner,
                                  net.fortuna.ical4j.model.component.VEvent event)
This method is intended to generate a unique URI to use with the PUT method in createAppointment(IScheduleVisitor, IScheduleOwner, AvailableBlock, String). It is implemented by the following:
         caldavDialect.calculateCalendarAccountHome(owner.getCalendarAccount) + "/sched-assist-" + randomAlphanumeric + ".ics"
 

Parameters:
owner -
Returns:

getCalendarsInternal

protected List<CalendarWithURI> getCalendarsInternal(ICalendarAccount calendarAccount,
                                                     Date startDate,
                                                     Date endDate)
Parameters:
calendarAccount -
startDate -
endDate -
Returns:

consolidate

protected net.fortuna.ical4j.model.Calendar consolidate(List<CalendarWithURI> calendars)
Consolidate the Calendars within the argument, returning 1.

Parameters:
calendars -
Returns:
never null
Throws:
net.fortuna.ical4j.data.ParserException
See Also:
Calendars.merge(Calendar, Calendar)

getExistingAppointmentInternal

protected CalendarWithURI getExistingAppointmentInternal(IScheduleOwner owner,
                                                         Date startTime,
                                                         Date endTime)
This method returns the CalendarWithURI containing a single VEvent that was created with the Scheduling Assistant with the specified IScheduleOwner as the owner and the specified start and end times.

Parameters:
owner -
startTime -
endTime -
Returns:
the matching Scheduling Assistant VEvent, or null if none for this IScheduleOwner at the specified times

getExistingAppointmentInternalForVisitor

protected CalendarWithURI getExistingAppointmentInternalForVisitor(IScheduleVisitor visitor,
                                                                   Date startTime,
                                                                   Date endTime,
                                                                   net.fortuna.ical4j.model.property.Uid eventUid)
Special method used when cancelUpdatesVisitorCalendar is set to true. Returns the CalendarWithURI in the visitor's account for the event with the specified start, end and eventuid.

Parameters:
owner -
startTime -
endTime -
eventUid -
Returns:
the matching event, or null if not found.

putNewEvent

protected int putNewEvent(ICalendarAccount eventOwner,
                          net.fortuna.ical4j.model.component.VEvent event)
                   throws org.apache.commons.httpclient.HttpException,
                          IOException
Store a new event using CalDAV PUT.

Parameters:
eventOwner -
event -
Returns:
Throws:
org.apache.commons.httpclient.HttpException
IOException

putExistingEvent

protected int putExistingEvent(ICalendarAccount eventOwner,
                               net.fortuna.ical4j.model.component.VEvent event,
                               String etag)
                        throws org.apache.commons.httpclient.HttpException,
                               IOException
Update an existing event using CalDAV PUT.

Parameters:
eventOwner -
event -
etag -
Returns:
Throws:
org.apache.commons.httpclient.HttpException
IOException

purgeDeclinedAttendees

protected CalendarWithURI purgeDeclinedAttendees(CalendarWithURI calendarWithURI,
                                                 ICalendarAccount owner)
This method will inspect IScheduleVisitor Attendees among the SchedulingAssistantAppointments in the Calendar argument. If an Attendee on an SchedulingAssistantAppointment has Partstat#DECLINED, the appointment will be cancelled (if one on one or lone visitor on group appt) or the attendee will be removed (group appointment with multiple attending visitors).

Parameters:
calendarWithURI -
session -
owner -
Returns:
the calendar minus any events or attendees that have been removed.
Throws:
SchedulingException
StatusException


Copyright © 2011 Jasig. All Rights Reserved.