org.exoplatform.calendar.service.impl
Class RemoteCalendarServiceImpl

java.lang.Object
  extended by org.exoplatform.calendar.service.impl.RemoteCalendarServiceImpl
All Implemented Interfaces:
RemoteCalendarService

public class RemoteCalendarServiceImpl
extends Object
implements RemoteCalendarService

Created by The eXo Platform SAS Author : eXoPlatform exo@exoplatform.com Jan 10, 2011


Field Summary
static String ICAL_PROPS_CALENDAR_DESCRIPTION
           
static String ICAL_PROPS_CALENDAR_NAME
           
 
Constructor Summary
RemoteCalendarServiceImpl(JCRDataStorage storage)
           
 
Method Summary
static CalendarEvent calculateEvent(net.fortuna.ical4j.model.component.VEvent event, CalendarEvent exoEvent)
           
 org.apache.jackrabbit.webdav.MultiStatus connectToCalDavServer(RemoteCalendar remoteCalendar)
          First time connect to CalDav server to get data
 InputStream connectToRemoteServer(RemoteCalendar remoteCalendar)
          Connect to remote server
 org.apache.jackrabbit.webdav.MultiStatus doCalendarMultiGet(org.apache.commons.httpclient.HttpClient client, String uri, String[] hrefs)
           
 org.apache.jackrabbit.webdav.MultiStatus doCalendarQuery(org.apache.commons.httpclient.HttpClient client, String uri, Calendar from, Calendar to)
          Send a calendar-query REPORT request to CalDav server
static CalendarEvent generateEvent(net.fortuna.ical4j.model.component.VEvent event, CalendarEvent exoEvent, String username, String calendarId)
           
 net.fortuna.ical4j.model.Calendar getCalDavResource(RemoteCalendar remoteCalendar, String href)
           
 Map<String,String> getEntityTags(org.apache.commons.httpclient.HttpClient client, String uri, Calendar from, Calendar to)
          Get a map of pairs (href,etag) from caldav server This calendar query doesn't include calendar-data element to get data faster
 RemoteCalendar getRemoteCalendar(String url, String type, String remoteUser, String remotePassword)
          Read calendar information(name, description,...) from url.
 org.apache.commons.httpclient.HttpClient getRemoteClient(RemoteCalendar remoteCalendar)
          Get the HttpClient object to prepare for the connection with remote server
 void importCaldavEvent(String username, String calendarId, String eventId, net.fortuna.ical4j.model.Calendar iCalendar, String href, String etag, Boolean isNew)
           
 Calendar importRemoteCalendar(RemoteCalendar remoteCalendar)
          Import iCalendar to local eXo Calendar
 boolean isValidRemoteUrl(String url, String type, String remoteUser, String remotePassword)
          Check if the remote url is valid, in 2 cases of iCalendar url or CalDav url, with authentication
 org.apache.jackrabbit.webdav.client.methods.ReportMethod makeCalDavQueryReport(String uri, Calendar from, Calendar to)
          Make the new REPORT method object to query calendar component on CalDav server
 Calendar refreshRemoteCalendar(String username, String remoteCalendarId)
          Reload remote calendar
static CalendarEvent setEventAttachment(net.fortuna.ical4j.model.component.VEvent event, CalendarEvent exoEvent, String eValue, String sValue)
           
static CalendarEvent setTaskAttachment(net.fortuna.ical4j.model.component.VToDo task, CalendarEvent exoEvent, String username, String calendarId, Map<String,net.fortuna.ical4j.model.component.VFreeBusy> vFreeBusyData)
           
 Calendar synchronizeWithCalDavServer(RemoteCalendar remoteCalendar)
          Do reload data from CalDav server for remote calendar with a time-range condition.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

ICAL_PROPS_CALENDAR_NAME

public static final String ICAL_PROPS_CALENDAR_NAME
See Also:
Constant Field Values

ICAL_PROPS_CALENDAR_DESCRIPTION

public static final String ICAL_PROPS_CALENDAR_DESCRIPTION
See Also:
Constant Field Values
Constructor Detail

RemoteCalendarServiceImpl

public RemoteCalendarServiceImpl(JCRDataStorage storage)
Method Detail

connectToRemoteServer

public InputStream connectToRemoteServer(RemoteCalendar remoteCalendar)
                                  throws Exception
Description copied from interface: RemoteCalendarService
Connect to remote server

Specified by:
connectToRemoteServer in interface RemoteCalendarService
Returns:
response's input stream
Throws:
Exception

isValidRemoteUrl

public boolean isValidRemoteUrl(String url,
                                String type,
                                String remoteUser,
                                String remotePassword)
                         throws IOException,
                                UnsupportedOperationException
Description copied from interface: RemoteCalendarService
Check if the remote url is valid, in 2 cases of iCalendar url or CalDav url, with authentication

Specified by:
isValidRemoteUrl in interface RemoteCalendarService
Parameters:
url - the remote url
type - the type of remote calendar, iCalendar or CalDav
Returns:
true if remote url is available in case of iCalendar and CalDav access support in case of CalDav
Throws:
IOException
UnsupportedOperationException

importRemoteCalendar

public Calendar importRemoteCalendar(RemoteCalendar remoteCalendar)
                              throws Exception
Description copied from interface: RemoteCalendarService
Import iCalendar to local eXo Calendar

Specified by:
importRemoteCalendar in interface RemoteCalendarService
Parameters:
remoteCalendar - object content all properties for remote calendar.
Returns:
Calendar object
Throws:
Exception

refreshRemoteCalendar

public Calendar refreshRemoteCalendar(String username,
                                      String remoteCalendarId)
                               throws Exception
Description copied from interface: RemoteCalendarService
Reload remote calendar

Specified by:
refreshRemoteCalendar in interface RemoteCalendarService
Returns:
Throws:
Exception

connectToCalDavServer

public org.apache.jackrabbit.webdav.MultiStatus connectToCalDavServer(RemoteCalendar remoteCalendar)
                                                               throws Exception
First time connect to CalDav server to get data

Parameters:
remoteCalendar -
Returns:
Throws:
Exception

getCalDavResource

public net.fortuna.ical4j.model.Calendar getCalDavResource(RemoteCalendar remoteCalendar,
                                                           String href)
                                                    throws Exception
Throws:
Exception

getEntityTags

public Map<String,String> getEntityTags(org.apache.commons.httpclient.HttpClient client,
                                        String uri,
                                        Calendar from,
                                        Calendar to)
                                 throws Exception
Get a map of pairs (href,etag) from caldav server This calendar query doesn't include calendar-data element to get data faster

Parameters:
client -
uri -
from -
to -
Returns:
Throws:
Exception

synchronizeWithCalDavServer

public Calendar synchronizeWithCalDavServer(RemoteCalendar remoteCalendar)
                                     throws Exception
Do reload data from CalDav server for remote calendar with a time-range condition. This function first gets entity tag map from server, then compare with data from local to determines which events/task (or other components) need to be update, create or delete

Parameters:
remoteCalendar -
Returns:
Calendar
Throws:
Exception

doCalendarMultiGet

public org.apache.jackrabbit.webdav.MultiStatus doCalendarMultiGet(org.apache.commons.httpclient.HttpClient client,
                                                                   String uri,
                                                                   String[] hrefs)
                                                            throws Exception
Throws:
Exception

doCalendarQuery

public org.apache.jackrabbit.webdav.MultiStatus doCalendarQuery(org.apache.commons.httpclient.HttpClient client,
                                                                String uri,
                                                                Calendar from,
                                                                Calendar to)
                                                         throws Exception
Send a calendar-query REPORT request to CalDav server

Parameters:
client -
uri -
from -
to -
Returns:
Throws:
Exception

importCaldavEvent

public void importCaldavEvent(String username,
                              String calendarId,
                              String eventId,
                              net.fortuna.ical4j.model.Calendar iCalendar,
                              String href,
                              String etag,
                              Boolean isNew)
                       throws Exception
Throws:
Exception

generateEvent

public static CalendarEvent generateEvent(net.fortuna.ical4j.model.component.VEvent event,
                                          CalendarEvent exoEvent,
                                          String username,
                                          String calendarId)
                                   throws Exception
Throws:
Exception

setEventAttachment

public static CalendarEvent setEventAttachment(net.fortuna.ical4j.model.component.VEvent event,
                                               CalendarEvent exoEvent,
                                               String eValue,
                                               String sValue)
                                        throws Exception
Throws:
Exception

setTaskAttachment

public static CalendarEvent setTaskAttachment(net.fortuna.ical4j.model.component.VToDo task,
                                              CalendarEvent exoEvent,
                                              String username,
                                              String calendarId,
                                              Map<String,net.fortuna.ical4j.model.component.VFreeBusy> vFreeBusyData)
                                       throws Exception
Throws:
Exception

calculateEvent

public static CalendarEvent calculateEvent(net.fortuna.ical4j.model.component.VEvent event,
                                           CalendarEvent exoEvent)
                                    throws Exception
Throws:
Exception

getRemoteClient

public org.apache.commons.httpclient.HttpClient getRemoteClient(RemoteCalendar remoteCalendar)
                                                         throws Exception
Get the HttpClient object to prepare for the connection with remote server

Parameters:
remoteCalendar - holds information about remote server
Returns:
HttpClient object
Throws:
Exception

makeCalDavQueryReport

public org.apache.jackrabbit.webdav.client.methods.ReportMethod makeCalDavQueryReport(String uri,
                                                                                      Calendar from,
                                                                                      Calendar to)
                                                                               throws Exception
Make the new REPORT method object to query calendar component on CalDav server

Parameters:
uri - the URI to the calendar collection on server
from - start date of the time range to filter calendar components
to - end date of the time range to filter calendar components
Returns:
ReportMethod object
Throws:
Exception

getRemoteCalendar

public RemoteCalendar getRemoteCalendar(String url,
                                        String type,
                                        String remoteUser,
                                        String remotePassword)
                                 throws Exception
Description copied from interface: RemoteCalendarService
Read calendar information(name, description,...) from url.

Specified by:
getRemoteCalendar in interface RemoteCalendarService
Parameters:
url - url to the calendar data
type - type of the calendar
remoteUser - username
remotePassword - password
Returns:
null if cannot read the calendar information.
Throws:
Exception


Copyright © 2003–2014 eXo Platform SAS. All rights reserved.