org.exoplatform.calendar.service.impl
Class CalendarServiceImpl

java.lang.Object
  extended by org.exoplatform.calendar.service.impl.CalendarServiceImpl
All Implemented Interfaces:
CalendarService, org.picocontainer.Startable

public class CalendarServiceImpl
extends Object
implements CalendarService, org.picocontainer.Startable

Created by The eXo Platform SARL Author : Hung Nguyen Quang hung.nguyen@exoplatform.com Jul 11, 2007


Field Summary
protected  List<CalendarEventListener> eventListeners_
           
protected  List<CalendarUpdateEventListener> listeners_
           
 
Fields inherited from interface org.exoplatform.calendar.service.CalendarService
CALDAV, EXPORTEDCSV, ICALENDAR
 
Constructor Summary
CalendarServiceImpl(org.exoplatform.container.xml.InitParams params, org.exoplatform.services.jcr.ext.hierarchy.NodeHierarchyCreator nodeHierarchyCreator, org.exoplatform.services.jcr.RepositoryService reposervice, org.exoplatform.services.resources.ResourceBundleService rbs, org.exoplatform.services.cache.CacheService cservice)
           
 
Method Summary
 void addEventListenerPlugin(CalendarEventListener listener)
           
 void addListenerPlugin(CalendarUpdateEventListener listener)
          
 void assignGroupTask(String taskId, String calendarId, String assignee)
          Assigns a group task for an user
 void autoRemoveShareCalendar(String groupId, String username)
          Un-shares group calendars with an user when he is removed from a membership
 void autoShareCalendar(List<String> groupsOfUser, String receiver)
          Shares group calendars with an user when he is assigned a new membership
 Map<String,String> checkFreeBusy(EventQuery eventQuery)
          Gets busy time of participants in a period
 void confirmInvitation(String fromUserId, String toUserId, int calType, String calendarId, String eventId, int answer)
          Confirms invitation to participate in an event
 void confirmInvitation(String fromUserId, String confirmingEmail, String confirmingUser, int calType, String calendarId, String eventId, int answer)
          Confirms an invitation to participate in an event
 org.quartz.JobDetail findSynchronizeRemoteCalendarJob(org.exoplatform.services.scheduler.JobSchedulerService schedulerService, String username)
          Finds job of synchronizing remote calendar of an user
 int generateRss(String username, LinkedHashMap<String,Calendar> calendars, RssData rssData)
          Generates RSS Feed link for list of calendars following RSS standard and stores the feed in storage
 int generateRss(String username, List<String> calendarIds, RssData rssData)
          Generates RSS Feed data for list of calendars following RSS standard and stores the feed in storage
 String getCalDavResourceEtag(String username, String calendarId, String eventId)
          Gets the entity tag of an event in a subscribed calendar.
 String getCalDavResourceHref(String username, String calendarId, String eventId)
          Gets the reference key to remote event of an event in a subscribed calendar.
 Calendar getCalendarById(String calId)
          Gets a calendar by its id
 CalendarImportExport getCalendarImportExports(String type)
          Gets the object performing import/export by type of import/export.
 CalendarSetting getCalendarSetting(String username)
          Gets calendar settings of an user
 JCRDataStorage getDataStorage()
           
 CalendarEvent getEvent(String username, String eventId)
          Gets event/task by its id and its owner
 CalendarEvent getEventById(String eventId)
          Gets event by its Id
 List<EventCategory> getEventCategories(String username)
          Gets all event categories of an user
 EventCategory getEventCategory(String username, String eventCategoryId)
          Gets event category by its id and its owner
 EventCategory getEventCategoryByName(String username, String eventCategoryName)
          Gets event category by its name and its owner
 List<CalendarEvent> getEvents(String username, EventQuery eventQuery, String[] publicCalendarIds)
          Gets all the events and tasks that match the conditions in the given EventQuery object
 List<CalendarEvent> getExceptionEvents(String username, CalendarEvent recurEvent)
          Gets all exception occurrences from a original recurrent event, the exception event always belong to same calendar with original recurrent event
 String[] getExportImportType()
          Gets array of supported types of import/export
 List<FeedData> getFeeds(String username)
          Gets RSS Feed data created by the given user.
 Calendar getGroupCalendar(String calendarId)
          Gets a group/public calendar by its Id
 List<GroupCalendarData> getGroupCalendars(String[] groupIds, boolean isShowAll, String username)
          Gets all the group calendar data of current user
 CalendarEvent getGroupEvent(String eventId)
          Gets a group event by its Id
 CalendarEvent getGroupEvent(String calendarId, String eventId)
          Gets event or task from a given group calendar by its id
 List<CalendarEvent> getGroupEventByCalendar(List<String> calendarIds)
          Gets all events and tasks from a list of public calendars
 Map<String,CalendarEvent> getOccurrenceEvents(CalendarEvent recurEvent, Calendar from, Calendar to, String timezone)
          Gets all occurrences of a repetitive event in a period of time.
 List<CalendarEvent> getOriginalRecurrenceEvents(String username, Calendar from, Calendar to, String[] publicCalendarIds)
          Gets all original repetitive events of an user in period of time
 List<CalendarEvent> getPublicEvents(EventQuery eventQuery)
          Gets all public events and tasks that match the conditions in the given EventQuery
 RemoteCalendar getRemoteCalendar(String owner, String calendarId)
          Gets an user's remote calendar, identified by its ID
 Calendar getRemoteCalendar(String owner, String remoteUrl, String remoteType)
          Gets an user's remote calendar, identified by its URL
 int getRemoteCalendarCount(String username)
          Gets number of remote calendars of an user
 RemoteCalendarService getRemoteCalendarService()
          Gets the RemoteCalendarService object
 ResourceBundle getResourceBundle()
          Gets the resource bundle to support localization
 javax.jcr.Node getRssHome(String username)
          Gets RSS home node where RSS data is stored in data storage.
 GroupCalendarData getSharedCalendars(String username, boolean isShowAll)
          Gets all calendars that are shared with the given user
 CalendarEvent getSharedEvent(String username, String calendarId, String eventId)
          Get shared event by user name, calendar id and event id
 List<CalendarEvent> getSharedEventByCalendars(String username, List<String> calendarIds)
          Gets events in shared calendars
 int getTypeOfCalendar(String userName, String calendarId)
          Gets type of a calendar by user name and calendar id
 Calendar getUserCalendar(String username, String calendarId)
          Gets the given user's private calendar, identified by its ID.
 List<Calendar> getUserCalendars(String username, boolean isShowAll)
          Gets private calendars of the given user.
 List<CalendarEvent> getUserEventByCalendar(String username, List<String> calendarIds)
          Gets all events and tasks from a list of private calendars
 List<CalendarEvent> getUserEvents(String username, EventQuery eventQuery)
          Gets events and tasks that match the conditions in the given EventQuery
 Calendar importRemoteCalendar(RemoteCalendar remoteCalendar)
          Imports an online .ics or through CalDav access to local calendar
 void initNewUser(String userName, CalendarSetting defaultCalendarSetting_)
          Initializes calendar data for a new created user
 boolean isGroupBeingShared(String group, org.exoplatform.services.scheduler.impl.JobSchedulerServiceImpl schedulerService_)
          Checks if a group is belong to a list of groups that's being shared
 boolean isRemoteCalendar(String username, String calendarId)
          Checks if the calendar with given calendarId is a remote calendar
 boolean isValidRemoteUrl(String url, String type, String remoteUser, String remotePassword)
          Checks if the remote URL is valid, in 2 cases of iCalendar URL or CalDav URL, with authentication
 void loadSynchronizeRemoteCalendarJob(String username)
          Initializes job for synchronizing remote calendar
 void moveEvent(String fromCalendar, String toCalendar, String fromType, String toType, List<CalendarEvent> calEvents, String username)
          Saves changes for list of events.
 Calendar refreshRemoteCalendar(String username, String remoteCalendarId)
          Reloads data for a remote calendar
 void removeEventCategory(String username, String eventCategoryId)
          Removes an event category, all events and tasks belong to this category will be removed.
 void removeFeedData(String username, String title)
          Removes the feed data of an user by the feed's title
 void removeOccurrenceInstance(String username, CalendarEvent occurrence)
          Removes only an occurrence instance from recurrence series, this function will get the original event node of the occurrence and then put the recurrence id of the need-to-delete occurrence to excludeId list of original node.
 Calendar removePublicCalendar(String calendarId)
          Removes the group calendar form data base, every events, tasks inside this calendar will be removed too
 CalendarEvent removePublicEvent(String calendarId, String eventId)
          Removes a public event or task, all attachments and reminders of this event will be removed
 void removeRecurrenceSeries(String username, CalendarEvent originalEvent)
          Removes all occurrence from an recurrence series.
 void removeSharedCalendar(String username, String calendarId)
          Removes shared calendars of an user
 void removeSharedCalendarByJob(String username, List<String> unsharedGroups, String calendarId)
          Un-shares a calendar with groups.
 void removeSharedCalendarFolder(String username)
          Removes the shared calendar folder of an user and all references (from shared calendars) to this folder.
 void removeSharedEvent(String username, String calendarId, String eventId)
          Removes event/task from shared calendar
 Calendar removeUserCalendar(String username, String calendarId)
          Removes private calendar by given id, all events and tasks belong to this calendar will be removed
 CalendarEvent removeUserEvent(String username, String calendarId, String eventId)
          Removes an event from the personal calendar
 void saveCalendarSetting(String username, CalendarSetting setting)
          Saves User Calendar setting
 void saveEventCategory(String username, EventCategory eventCategory, boolean isNew)
          Saves an event category to data base
 void saveEventCategory(String username, EventCategory eventCategory, String[] values, boolean isNew)
          
 void saveEventToSharedCalendar(String username, String calendarId, CalendarEvent event, boolean isNew)
          Saves event to shared calendar.
 void savePublicCalendar(Calendar calendar, boolean isNew)
          Saves a calendar to public area (group calendar)
 void savePublicEvent(String calendarId, CalendarEvent event, boolean isNew)
          Saves event or task to a public calendar
 void saveSharedCalendar(String username, Calendar calendar)
          Saves a calendar to shared calendars section
 void saveUserCalendar(String username, Calendar calendar, boolean isNew)
          Saves an user's private calendar to storage
 void saveUserEvent(String username, String calendarId, CalendarEvent event, boolean isNew)
          Saves events/tasks to a personal calendar
 EventPageList searchEvent(String username, EventQuery query, String[] publicCalendarIds)
          Gets an EventPageList of events/tasks of a given list of public calendars that matches the condition
in the given EvenQuery object.
 Map<Integer,String> searchHighlightRecurrenceEvent(String username, EventQuery eventQuery, String[] publicCalendarIds, String timezone)
          Finds all days of month or year that have event/task to highlight from all personal, shared and public calendar of an user
This function is much same like searchHightLightEvent() function but it only counts for recurrent event
 Map<Integer,String> searchHightLightEvent(String username, EventQuery eventQuery, String[] publicCalendarIds)
          Gets the day in month on which there are events.
 void setCalDavResourceEtag(String username, String calendarId, String eventId, String etag)
           
 void setCalDavResourceHref(String username, String calendarId, String eventId, String href)
           
 void setGroupTaskStatus(String taskId, String calendarId, String status)
          Sets status for a group task.
 void shareCalendar(String username, String calendarId, List<String> receiverUsers)
          Shares the private calendar to other users
 void shareCalendarByRunJob(String username, String calendarId, List<String> sharedGroups)
          Shares Calendar with groups
 void start()
           
 void stop()
           
 void stopSynchronizeRemoteCalendarJob(String username)
          Stops an user's job for synchronizing remote calendar
 void updateOccurrenceEvent(String fromCalendar, String toCalendar, String fromType, String toType, List<CalendarEvent> calEvents, String username)
          Updates an occurrence of a repetitive event
 void updateRecurrenceSeries(String fromCalendar, String toCalendar, String fromType, String toType, CalendarEvent occurrence, String username)
          Updates recurrence series from an occurrence, this function is only called if the occurrence event is not changed the from date property.
 Calendar updateRemoteCalendarInfo(RemoteCalendar remoteCalendar)
          Updates a remote calendar
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

listeners_

protected List<CalendarUpdateEventListener> listeners_

eventListeners_

protected List<CalendarEventListener> eventListeners_
Constructor Detail

CalendarServiceImpl

public CalendarServiceImpl(org.exoplatform.container.xml.InitParams params,
                           org.exoplatform.services.jcr.ext.hierarchy.NodeHierarchyCreator nodeHierarchyCreator,
                           org.exoplatform.services.jcr.RepositoryService reposervice,
                           org.exoplatform.services.resources.ResourceBundleService rbs,
                           org.exoplatform.services.cache.CacheService cservice)
                    throws Exception
Throws:
Exception
Method Detail

getDataStorage

public JCRDataStorage getDataStorage()

getUserCalendar

public Calendar getUserCalendar(String username,
                                String calendarId)
                         throws Exception
Gets the given user's private calendar, identified by its ID.

Specified by:
getUserCalendar in interface CalendarService
Parameters:
username - current user name(or user id)
calendarId - Id of the calendar
Returns:
The private Calendar of the given user identified by the given id
Throws:
Exception
See Also:
Calendar

getUserCalendars

public List<Calendar> getUserCalendars(String username,
                                       boolean isShowAll)
                                throws Exception
Gets private calendars of the given user.

The result depends on value of isShowAll parameter. If isShowAll
is true, this method returns all private calendars of this user, otherwise it returns
only calendars selected to be displayed in Calendar setting

Specified by:
getUserCalendars in interface CalendarService
Parameters:
username - current user name(or user id)
isShowAll - If true, returns all private calendars. If false, returns
only calendars that are selected in Calendar Setting
Returns:
List of Calendar objects
Throws:
Exception
See Also:
Calendar, CalendarSetting

saveUserCalendar

public void saveUserCalendar(String username,
                             Calendar calendar,
                             boolean isNew)
                      throws Exception
Saves an user's private calendar to storage

Specified by:
saveUserCalendar in interface CalendarService
Parameters:
username - current user name(or user id)
calendar - Calendar object that will be stored
isNew - Boolean value to know adding a new calendar or just updating this calendar
Throws:
Exception

removeUserCalendar

public Calendar removeUserCalendar(String username,
                                   String calendarId)
                            throws Exception
Removes private calendar by given id, all events and tasks belong to this calendar will be removed

Specified by:
removeUserCalendar in interface CalendarService
Parameters:
username - current user name(or user id)
calendarId - given calendar id
Returns:
Throws:
Exception

getGroupCalendar

public Calendar getGroupCalendar(String calendarId)
                          throws Exception
Gets a group/public calendar by its Id

Specified by:
getGroupCalendar in interface CalendarService
Parameters:
calendarId - given calendar id
Returns:
Calendar object
Throws:
Exception
See Also:
Calendar

getGroupCalendars

public List<GroupCalendarData> getGroupCalendars(String[] groupIds,
                                                 boolean isShowAll,
                                                 String username)
                                          throws Exception
Gets all the group calendar data of current user

The GroupCalendarData contains information about list of calendars with the
group that those calendars belong to.

Specified by:
getGroupCalendars in interface CalendarService
Parameters:
groupIds - The id of groups that current user belongs to
isShowAll - to specify getting all calendars or only calendars selected in Calendar user setting
username - current user name(or user id)
Returns:
List of GroupCalendarData and each GroupCalendarData contains list of calendar objects
Throws:
Exception
See Also:
GroupCalendarData

savePublicCalendar

public void savePublicCalendar(Calendar calendar,
                               boolean isNew)
                        throws Exception
Saves a calendar to public area (group calendar)

Specified by:
savePublicCalendar in interface CalendarService
Parameters:
calendar - Calendar to be saved
isNew - If true, a new calendar will be saved. If false, an existing calendar will be updated.
Throws:
Exception

removePublicCalendar

public Calendar removePublicCalendar(String calendarId)
                              throws Exception
Removes the group calendar form data base, every events, tasks inside this calendar will be removed too

Specified by:
removePublicCalendar in interface CalendarService
Returns:
Throws:
Exception

getEventCategories

public List<EventCategory> getEventCategories(String username)
                                       throws Exception
Gets all event categories of an user

Specified by:
getEventCategories in interface CalendarService
Parameters:
username - current user name(or user id)
Returns:
list of event categories
Throws:
Exception
See Also:
EventCategory

saveEventCategory

public void saveEventCategory(String username,
                              EventCategory eventCategory,
                              boolean isNew)
                       throws Exception
Saves an event category to data base

Every users have their own categories of events. The name of category is unique.

Specified by:
saveEventCategory in interface CalendarService
Parameters:
username - current user name(or user id)
Throws:
Exception

saveEventCategory

public void saveEventCategory(String username,
                              EventCategory eventCategory,
                              String[] values,
                              boolean isNew)
                       throws Exception

Throws:
Exception

removeEventCategory

public void removeEventCategory(String username,
                                String eventCategoryId)
                         throws Exception
Removes an event category, all events and tasks belong to this category will be removed.

Specified by:
removeEventCategory in interface CalendarService
Parameters:
username - current user name(or user id)
eventCategoryId - The unique name of category
Throws:
Exception

getUserEventByCalendar

public List<CalendarEvent> getUserEventByCalendar(String username,
                                                  List<String> calendarIds)
                                           throws Exception
Gets all events and tasks from a list of private calendars

Specified by:
getUserEventByCalendar in interface CalendarService
Parameters:
username - The owner of the calendar
calendarIds - List of calendar id
Returns:
List of events and tasks
Throws:
Exception

getUserEvents

public List<CalendarEvent> getUserEvents(String username,
                                         EventQuery eventQuery)
                                  throws Exception
Gets events and tasks that match the conditions in the given EventQuery

Each property of the EventQuery contains a condition of the query. For example:

After setting value for those properties, the conditions are built in a query statement by the
method EventQuery.getQueryStatement()

Specified by:
getUserEvents in interface CalendarService
Parameters:
username - current user name(or user id)
eventQuery - EventQuery object containing the conditions
Returns:
List of CalendarEvent object (events and tasks)
Throws:
Exception
See Also:
CalendarEvent, EventQuery

getEvent

public CalendarEvent getEvent(String username,
                              String eventId)
                       throws Exception
Description copied from interface: CalendarService
Gets event/task by its id and its owner

Specified by:
getEvent in interface CalendarService
Parameters:
username - user id of the event owner
eventId - id of the event
Returns:
CalendarEvent in the personal calendar of owner
Throws:
Exception

saveUserEvent

public void saveUserEvent(String username,
                          String calendarId,
                          CalendarEvent event,
                          boolean isNew)
                   throws Exception
Saves events/tasks to a personal calendar

Specified by:
saveUserEvent in interface CalendarService
Parameters:
username - current user name(or user id)
calendarId - Id of the calendar to which the event will be saved
event - CalendarEvent object to be saved
isNew - If true, a new event will be saved. If false, an existing event will be updated.
Throws:
Exception

removeUserEvent

public CalendarEvent removeUserEvent(String username,
                                     String calendarId,
                                     String eventId)
                              throws Exception
Removes an event from the personal calendar

All attachments and reminders will be removed

Specified by:
removeUserEvent in interface CalendarService
Parameters:
username - current user name(or user id)
calendarId - Id of the calendar from which the event will be removed.
eventId - Id of the removed event.
Returns:
the removed CalendarEvent object. Null if no event was removed.
Throws:
Exception

getGroupEvent

public CalendarEvent getGroupEvent(String eventId)
                            throws Exception
Gets a group event by its Id

Specified by:
getGroupEvent in interface CalendarService
Returns:
CalendarEvent object or null if event was not found
Throws:
Exception

getGroupEvent

public CalendarEvent getGroupEvent(String calendarId,
                                   String eventId)
                            throws Exception
Gets event or task from a given group calendar by its id

Specified by:
getGroupEvent in interface CalendarService
Parameters:
calendarId - given group calendar id
eventId - given event id
Returns:
CalendarEvent object
Throws:
Exception
See Also:
CalendarEvent

getGroupEventByCalendar

public List<CalendarEvent> getGroupEventByCalendar(List<String> calendarIds)
                                            throws Exception
Gets all events and tasks from a list of public calendars

Specified by:
getGroupEventByCalendar in interface CalendarService
Parameters:
calendarIds - List of Calendar IDs
Returns:
List of CalendarEvent objects
Throws:
Exception
See Also:
CalendarEvent

getPublicEvents

public List<CalendarEvent> getPublicEvents(EventQuery eventQuery)
                                    throws Exception
Gets all public events and tasks that match the conditions in the given EventQuery

Specified by:
getPublicEvents in interface CalendarService
Parameters:
eventQuery - EventQuery object
Returns:
List of calendar event objects
Throws:
Exception
See Also:
CalendarEvent, EventQuery

savePublicEvent

public void savePublicEvent(String calendarId,
                            CalendarEvent event,
                            boolean isNew)
                     throws Exception
Saves event or task to a public calendar

Specified by:
savePublicEvent in interface CalendarService
Parameters:
calendarId - Id of the public calendar to which the event will be saved
event - CalendarEvent object to be saved.
isNew - If true, a new event will be saved. If false, an existing event will be updated.
Throws:
Exception

removePublicEvent

public CalendarEvent removePublicEvent(String calendarId,
                                       String eventId)
                                throws Exception
Removes a public event or task, all attachments and reminders of this event will be removed

Specified by:
removePublicEvent in interface CalendarService
Parameters:
calendarId - given calendar id
eventId - given event or task id
Returns:
the removed CalendarEvent. Null if no event was removed.
Throws:
Exception

getCalendarImportExports

public CalendarImportExport getCalendarImportExports(String type)
Gets the object performing import/export by type of import/export.

There are 2 classes that implements the interface CalendarImportExport:

Specified by:
getCalendarImportExports in interface CalendarService
Parameters:
type - ICS or CSV
Returns:
a CalendarImportExport object that belongs to 1 of those 2 above classes.
See Also:
CalendarImportExport

getExportImportType

public String[] getExportImportType()
                             throws Exception
Gets array of supported types of import/export

Now there are 2 types that are supported: ICS and CSV.

Specified by:
getExportImportType in interface CalendarService
Returns:
array of supported types
Throws:
Exception
See Also:
CalendarImportExport, RemoteCalendarService

saveCalendarSetting

public void saveCalendarSetting(String username,
                                CalendarSetting setting)
                         throws Exception
Saves User Calendar setting

Specified by:
saveCalendarSetting in interface CalendarService
Parameters:
username - current user name(or user id)
setting - CalendarSetting object
Throws:
Exception
See Also:
CalendarSetting

getCalendarSetting

public CalendarSetting getCalendarSetting(String username)
                                   throws Exception
Gets calendar settings of an user

Specified by:
getCalendarSetting in interface CalendarService
Parameters:
username - current user name(or user id)
Returns:
CalendarSetting object
Throws:
Exception
See Also:
CalendarSetting

generateRss

public int generateRss(String username,
                       LinkedHashMap<String,Calendar> calendars,
                       RssData rssData)
                throws Exception
Generates RSS Feed link for list of calendars following RSS standard and stores the feed in storage

This method is called when user selects calendars to generate RSS link in UIEditFeed form.

Specified by:
generateRss in interface CalendarService
Parameters:
username - current user name(or user id)
calendars - the RSS feed will contain events and tasks from the calendars given in this param
rssData - object containing basic informations (url, title, description) of the feed
Returns:
1 if succeed, -1 if fail
Throws:
Exception
See Also:
RssData

getFeeds

public List<FeedData> getFeeds(String username)
                        throws Exception
Gets RSS Feed data created by the given user.

Specified by:
getFeeds in interface CalendarService
Parameters:
username - current user name (or user id)
Returns:
List of FeedData
Throws:
Exception
See Also:
FeedData

getRssHome

public javax.jcr.Node getRssHome(String username)
                          throws Exception
Gets RSS home node where RSS data is stored in data storage.

Specified by:
getRssHome in interface CalendarService
Parameters:
username - current user name(or user id)
Returns:
Rss home node
Throws:
Exception

searchEvent

public EventPageList searchEvent(String username,
                                 EventQuery query,
                                 String[] publicCalendarIds)
                          throws Exception
Gets an EventPageList of events/tasks of a given list of public calendars that matches the condition
in the given EvenQuery object.

Specified by:
searchEvent in interface CalendarService
Parameters:
username - current user name(or user id)
query - EventQuery object
publicCalendarIds - Array of public calendar IDs in which to search events
Returns:
EventPageList object.
Throws:
Exception
See Also:
EventPageList

getEventCategory

public EventCategory getEventCategory(String username,
                                      String eventCategoryId)
                               throws Exception
Gets event category by its id and its owner

Specified by:
getEventCategory in interface CalendarService
Parameters:
username - user id of the event category's owner
eventCategoryId - Id of the event category
Returns:
an EventCategory object
Throws:
Exception
See Also:
EventCategory

searchHightLightEvent

public Map<Integer,String> searchHightLightEvent(String username,
                                                 EventQuery eventQuery,
                                                 String[] publicCalendarIds)
                                          throws Exception
Gets the day in month on which there are events.

This method is used when UIMiniCalendar is loaded or updated. We need to know on which day there are events
to add class 'highlight' for that day in the template.

The given EventQuery always has from date is the first day of the month, and end date is the last
day of the month. The returned result is a Map with key set is the days having events, the values are all "value".

Specified by:
searchHightLightEvent in interface CalendarService
Parameters:
username - current user name(or user id)
eventQuery - EventQuery object
publicCalendarIds - array of public calendar IDs of which to search events
Returns:
a Map with key set is the days having events. Ex: {<14,"value">, <15,"value">}
Throws:
Exception

shareCalendar

public void shareCalendar(String username,
                          String calendarId,
                          List<String> receiverUsers)
                   throws Exception
Shares the private calendar to other users

Specified by:
shareCalendar in interface CalendarService
Parameters:
username - current user name(or user id)
calendarId - Id of the shared calendar
receiverUsers - list of users with whom to share this calendar
Throws:
Exception

getSharedCalendars

public GroupCalendarData getSharedCalendars(String username,
                                            boolean isShowAll)
                                     throws Exception
Gets all calendars that are shared with the given user

Specified by:
getSharedCalendars in interface CalendarService
Parameters:
username - given user name(or user id)
isShowAll - If true, returns all shared calendars, if false, returns only shared calendars that are selected in Calendar Setting.
Returns:
GroupCalendarData object
Throws:
Exception
See Also:
GroupCalendarData

getEvents

public List<CalendarEvent> getEvents(String username,
                                     EventQuery eventQuery,
                                     String[] publicCalendarIds)
                              throws Exception
Gets all the events and tasks that match the conditions in the given EventQuery object

The result includes events of private, public and share calendars.

If publicCalendarIds is not null, the result will include also all public events from those
public calendar.

Specified by:
getEvents in interface CalendarService
Parameters:
username - current user name(or user id)
eventQuery - EventQuery object
publicCalendarIds - Optional array of public calendar IDs of which to get events
Returns:
Throws:
Exception
See Also:
CalendarEvent

removeSharedCalendar

public void removeSharedCalendar(String username,
                                 String calendarId)
                          throws Exception
Removes shared calendars of an user

Specified by:
removeSharedCalendar in interface CalendarService
Parameters:
username - current user name(or user id)
calendarId - given calendar id
Throws:
Exception

removeSharedCalendarFolder

public void removeSharedCalendarFolder(String username)
                                throws Exception
Description copied from interface: CalendarService
Removes the shared calendar folder of an user and all references (from shared calendars) to this folder.

Specified by:
removeSharedCalendarFolder in interface CalendarService
Parameters:
username - the username
Throws:
Exception

saveEventToSharedCalendar

public void saveEventToSharedCalendar(String username,
                                      String calendarId,
                                      CalendarEvent event,
                                      boolean isNew)
                               throws Exception
Saves event to shared calendar.

Specified by:
saveEventToSharedCalendar in interface CalendarService
Parameters:
username - current user name(or user id)
calendarId - given calendar id
event - CalendarEvent object
isNew - If true, a new event will be saved. If false, an existing event will be updated.
Throws:
Exception

checkFreeBusy

public Map<String,String> checkFreeBusy(EventQuery eventQuery)
                                 throws Exception
Gets busy time of participants in a period

The list of participants and the period are given in an EventQuery object.

The returned result is a Map with the key is user name of participants
and the value is pairs of {fromtime, totime} in milliseconds , separated by ','.

Specified by:
checkFreeBusy in interface CalendarService
Parameters:
eventQuery - EventQuery object
Returns:
a Map with the key is user name and value is
Throws:
Exception
See Also:
EventQuery

saveSharedCalendar

public void saveSharedCalendar(String username,
                               Calendar calendar)
                        throws Exception
Saves a calendar to shared calendars section

Specified by:
saveSharedCalendar in interface CalendarService
Parameters:
username - current user name(or user id)
calendar - Calendar object
Throws:
Exception

removeSharedEvent

public void removeSharedEvent(String username,
                              String calendarId,
                              String eventId)
                       throws Exception
Removes event/task from shared calendar

Specified by:
removeSharedEvent in interface CalendarService
Parameters:
username - current user name(or user id)
calendarId - given calendar id
eventId - given event id
Throws:
Exception

moveEvent

public void moveEvent(String fromCalendar,
                      String toCalendar,
                      String fromType,
                      String toType,
                      List<CalendarEvent> calEvents,
                      String username)
               throws Exception
Saves changes for list of events.

This method can be used in 2 cases:

Specified by:
moveEvent in interface CalendarService
Parameters:
fromCalendar - Id of the source calendar
toCalendar - Id of the destination calendar
fromType - type of the source calendar (private/shared/public)
toType - type of the destination calendar (private/shared/public)
calEvents - List of CalendarEvent objects
username - current user name(or user id)
Throws:
Exception

confirmInvitation

public void confirmInvitation(String fromUserId,
                              String toUserId,
                              int calType,
                              String calendarId,
                              String eventId,
                              int answer)
Confirms invitation to participate in an event

This method is called only when user uses exo mail product.

The answer can be: DENY, ACCEPT, NOTSURE

Specified by:
confirmInvitation in interface CalendarService
Parameters:
fromUserId - Id of the invitation owner
toUserId - Id of the invited user
calType - type of the invitation event's calendar
calendarId - Id of the invitation event's calendar
eventId - Id of the invitation event
answer - The answer of the invited user

confirmInvitation

public void confirmInvitation(String fromUserId,
                              String confirmingEmail,
                              String confirmingUser,
                              int calType,
                              String calendarId,
                              String eventId,
                              int answer)
                       throws Exception
Confirms an invitation to participate in an event

Specified by:
confirmInvitation in interface CalendarService
Parameters:
fromUserId - Id of the invitation owner
confirmingEmail - Email of the invited participant
confirmingUser - User id of the invited participant
calType - Type of the invitation event's calendar
calendarId - Id of the invitation event's calendar
eventId - Id of the invitation event
answer - The answer of the invited user. It can be: DENY/ACCEPT/NOT_SURE
Throws:
Exception

start

public void start()
Specified by:
start in interface org.picocontainer.Startable

stop

public void stop()
Specified by:
stop in interface org.picocontainer.Startable

addListenerPlugin

public void addListenerPlugin(CalendarUpdateEventListener listener)
                       throws Exception

Specified by:
addListenerPlugin in interface CalendarService
Throws:
Exception

getTypeOfCalendar

public int getTypeOfCalendar(String userName,
                             String calendarId)
                      throws Exception
Description copied from interface: CalendarService
Gets type of a calendar by user name and calendar id

There a 3 types of calendar:

Specified by:
getTypeOfCalendar in interface CalendarService
Returns:
0 if the calendar is private, 1 if the calendar is shared, 2 if the calendar is public
Throws:
Exception
See Also:
Calendar

generateRss

public int generateRss(String username,
                       List<String> calendarIds,
                       RssData rssData)
                throws Exception
Description copied from interface: CalendarService
Generates RSS Feed data for list of calendars following RSS standard and stores the feed in storage

Specified by:
generateRss in interface CalendarService
Parameters:
username - current user name(or user id)
calendarIds - the RSS feed will contain events and tasks from the calendars given in this param
rssData - object containing basic informations (url, title, description) of the feed
Returns:
1 if succeed, -1 if fail
Throws:
Exception
See Also:
RssData

getResourceBundle

public ResourceBundle getResourceBundle()
                                 throws Exception
Description copied from interface: CalendarService
Gets the resource bundle to support localization

Specified by:
getResourceBundle in interface CalendarService
Returns:
a ResourceBundle object
Throws:
Exception

getEventCategoryByName

public EventCategory getEventCategoryByName(String username,
                                            String eventCategoryName)
                                     throws Exception
Description copied from interface: CalendarService
Gets event category by its name and its owner

Specified by:
getEventCategoryByName in interface CalendarService
Parameters:
username - Id of the owner
eventCategoryName - The name of the category
Returns:
EventCategory object
Throws:
Exception
See Also:
EventCategory

getSharedEventByCalendars

public List<CalendarEvent> getSharedEventByCalendars(String username,
                                                     List<String> calendarIds)
                                              throws Exception
Description copied from interface: CalendarService
Gets events in shared calendars

Specified by:
getSharedEventByCalendars in interface CalendarService
Parameters:
username - current user name
calendarIds - list of shared calendars from which to get events
Returns:
list of CalendarEvent object
Throws:
Exception

removeFeedData

public void removeFeedData(String username,
                           String title)
Description copied from interface: CalendarService
Removes the feed data of an user by the feed's title

Specified by:
removeFeedData in interface CalendarService
Parameters:
username - user id of the feed owner
title - The title of the removed feed

initNewUser

public void initNewUser(String userName,
                        CalendarSetting defaultCalendarSetting_)
                 throws Exception
Description copied from interface: CalendarService
Initializes calendar data for a new created user

Specified by:
initNewUser in interface CalendarService
Parameters:
userName - User id of the new created user
defaultCalendarSetting_ - default calendar setting
Throws:
Exception

addEventListenerPlugin

public void addEventListenerPlugin(CalendarEventListener listener)
                            throws Exception
Specified by:
addEventListenerPlugin in interface CalendarService
Throws:
Exception

assignGroupTask

public void assignGroupTask(String taskId,
                            String calendarId,
                            String assignee)
                     throws Exception
Description copied from interface: CalendarService
Assigns a group task for an user

Specified by:
assignGroupTask in interface CalendarService
Parameters:
taskId - the assigned task
calendarId - Id of the task's calendar
assignee - User id of the assignee
Throws:
Exception

setGroupTaskStatus

public void setGroupTaskStatus(String taskId,
                               String calendarId,
                               String status)
                        throws Exception
Description copied from interface: CalendarService
Sets status for a group task.

Specified by:
setGroupTaskStatus in interface CalendarService
Parameters:
taskId - Id of the task
calendarId - Id of the task's calendar
Throws:
Exception
See Also:
CalendarEvent

isRemoteCalendar

public boolean isRemoteCalendar(String username,
                                String calendarId)
                         throws Exception
Checks if the calendar with given calendarId is a remote calendar

Specified by:
isRemoteCalendar in interface CalendarService
Parameters:
username - the owner of calendar
calendarId - the Id of calendar
Returns:
true if this calendar is remote, otherwise false
Throws:
Exception

isValidRemoteUrl

public boolean isValidRemoteUrl(String url,
                                String type,
                                String remoteUser,
                                String remotePassword)
                         throws Exception
Checks if the remote URL is valid, in 2 cases of iCalendar URL or CalDav URL, with authentication

Specified by:
isValidRemoteUrl in interface CalendarService
Parameters:
url - the remote URL
type - the type of remote calendar, iCalendar or CalDav
remoteUser - the remote user name used to authenticate
remotePassword - the remote password used to authenticate
Returns:
true if remote URL is available in case of iCalendar or supports CalDav access in case of CalDav
Throws:
Exception

updateRemoteCalendarInfo

public Calendar updateRemoteCalendarInfo(RemoteCalendar remoteCalendar)
                                  throws Exception
Updates a remote calendar

Specified by:
updateRemoteCalendarInfo in interface CalendarService
Parameters:
remoteCalendar - a RemoteCalendar object.
Returns:
this calendar after updating
Throws:
Exception
See Also:
RemoteCalendar

refreshRemoteCalendar

public Calendar refreshRemoteCalendar(String username,
                                      String remoteCalendarId)
                               throws Exception
Reloads data for a remote calendar

Specified by:
refreshRemoteCalendar in interface CalendarService
Parameters:
username - owner of the calendar
remoteCalendarId - Id of the remote calendar to refresh
Returns:
the RemoteCalendar object
Throws:
Exception

importRemoteCalendar

public Calendar importRemoteCalendar(RemoteCalendar remoteCalendar)
                              throws Exception
Imports an online .ics or through CalDav access to local calendar

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

getRemoteCalendar

public RemoteCalendar getRemoteCalendar(String owner,
                                        String calendarId)
                                 throws Exception
Gets an user's remote calendar, identified by its ID

Specified by:
getRemoteCalendar in interface CalendarService
Parameters:
owner - user name of the calendar's owner
calendarId - the Id of calendar
Returns:
RemoteCalendar object
Throws:
Exception
See Also:
RemoteCalendar

getRemoteCalendarService

public RemoteCalendarService getRemoteCalendarService()
                                               throws Exception
Gets the RemoteCalendarService object

Specified by:
getRemoteCalendarService in interface CalendarService
Returns:
RemoteCalendarService object
Throws:
Exception

getRemoteCalendar

public Calendar getRemoteCalendar(String owner,
                                  String remoteUrl,
                                  String remoteType)
                           throws Exception
Description copied from interface: CalendarService
Gets an user's remote calendar, identified by its URL

Specified by:
getRemoteCalendar in interface CalendarService
Parameters:
owner - user name of the calendar's owner
remoteUrl - URL of the remote calendar
remoteType - iCalendar or CalDav
Returns:
a Calendar object
Throws:
Exception

getCalDavResourceHref

public String getCalDavResourceHref(String username,
                                    String calendarId,
                                    String eventId)
                             throws Exception
Description copied from interface: CalendarService
Gets the reference key to remote event of an event in a subscribed calendar.

Each event of a CalDav subscribed calendar has a reference key to its respective remote event. This key allows us to know if
an event is deleted or created from remote calendar.

The JCR property holding this value is exo:caldavHref of the node type exo:caldavCalendarEvent.

Specified by:
getCalDavResourceHref in interface CalendarService
Parameters:
username - current user name (or user ID)
calendarId - the subscribed calendar's ID
eventId - Id of the local event
Returns:
reference key to the remote event
Throws:
Exception

getCalDavResourceEtag

public String getCalDavResourceEtag(String username,
                                    String calendarId,
                                    String eventId)
                             throws Exception
Description copied from interface: CalendarService
Gets the entity tag of an event in a subscribed calendar.

Each event of a CalDav subscribed calendar has an entity tag. This value allows us to know if the details content of a remote event
were updated, so that we can update the respective local event properly.

The JCR property holding this value is exo:caldavEtag of the node type exo:caldavCalendarEvent.

Specified by:
getCalDavResourceEtag in interface CalendarService
Parameters:
username - current user name (or user ID)
calendarId - ID of the subscribed calendar
eventId - Id of the local event
Returns:
entity tag for the given event
Throws:
Exception

setCalDavResourceHref

public void setCalDavResourceHref(String username,
                                  String calendarId,
                                  String eventId,
                                  String href)
                           throws Exception
Throws:
Exception

setCalDavResourceEtag

public void setCalDavResourceEtag(String username,
                                  String calendarId,
                                  String eventId,
                                  String etag)
                           throws Exception
Throws:
Exception

loadSynchronizeRemoteCalendarJob

public void loadSynchronizeRemoteCalendarJob(String username)
                                      throws Exception
Description copied from interface: CalendarService
Initializes job for synchronizing remote calendar

Specified by:
loadSynchronizeRemoteCalendarJob in interface CalendarService
Throws:
Exception

stopSynchronizeRemoteCalendarJob

public void stopSynchronizeRemoteCalendarJob(String username)
                                      throws Exception
Description copied from interface: CalendarService
Stops an user's job for synchronizing remote calendar

Specified by:
stopSynchronizeRemoteCalendarJob in interface CalendarService
Throws:
Exception

findSynchronizeRemoteCalendarJob

public org.quartz.JobDetail findSynchronizeRemoteCalendarJob(org.exoplatform.services.scheduler.JobSchedulerService schedulerService,
                                                             String username)
                                                      throws Exception
Description copied from interface: CalendarService
Finds job of synchronizing remote calendar of an user

Specified by:
findSynchronizeRemoteCalendarJob in interface CalendarService
Returns:
a JobDetail object
Throws:
Exception

getRemoteCalendarCount

public int getRemoteCalendarCount(String username)
                           throws Exception
Description copied from interface: CalendarService
Gets number of remote calendars of an user

Specified by:
getRemoteCalendarCount in interface CalendarService
Returns:
number of remote calendars
Throws:
Exception

getOccurrenceEvents

public Map<String,CalendarEvent> getOccurrenceEvents(CalendarEvent recurEvent,
                                                     Calendar from,
                                                     Calendar to,
                                                     String timezone)
                                              throws Exception
Description copied from interface: CalendarService
Gets all occurrences of a repetitive event in a period of time.
The result will be depended on the recurrence rule, the start date of recurrent event and the period of time to view.

Specified by:
getOccurrenceEvents in interface CalendarService
Parameters:
recurEvent - the original recurrent event
from - the from time
to - the to time
Returns:
the map of CalendarEvent object, each entry will contains an occurrence event object with recurrence-id as the key
Throws:
Exception

updateOccurrenceEvent

public void updateOccurrenceEvent(String fromCalendar,
                                  String toCalendar,
                                  String fromType,
                                  String toType,
                                  List<CalendarEvent> calEvents,
                                  String username)
                           throws Exception
Description copied from interface: CalendarService
Updates an occurrence of a repetitive event

This method is called when:

  • User wants to update only one instance of the recurrent series. In this case, a new normal event will be created as an exception event of the series
  • User wants to update an exception event of a recurrent series. In this case, this event will be updated as a normal one

Specified by:
updateOccurrenceEvent in interface CalendarService
Parameters:
fromCalendar - ID of the source calendar
toCalendar - ID of the destination calendar
fromType - type of the source Calendar
toType - type of the destination calendar
calEvents - list of events to be updated
username - current user name (or user ID)
Throws:
Exception

getOriginalRecurrenceEvents

public List<CalendarEvent> getOriginalRecurrenceEvents(String username,
                                                       Calendar from,
                                                       Calendar to,
                                                       String[] publicCalendarIds)
                                                throws Exception
Description copied from interface: CalendarService
Gets all original repetitive events of an user in period of time

Specified by:
getOriginalRecurrenceEvents in interface CalendarService
Parameters:
username - the owner of recurrent event
from - from time
to - to time
Returns:
list of CalendarEvent objects
Throws:
Exception

getExceptionEvents

public List<CalendarEvent> getExceptionEvents(String username,
                                              CalendarEvent recurEvent)
                                       throws Exception
Description copied from interface: CalendarService
Gets all exception occurrences from a original recurrent event, the exception event always belong to same calendar with original recurrent event

Specified by:
getExceptionEvents in interface CalendarService
Parameters:
username - the owner of this recurrent event
recurEvent - the original recurrent event
Returns:
the list of CalendarEvent objects
Throws:
Exception

removeRecurrenceSeries

public void removeRecurrenceSeries(String username,
                                   CalendarEvent originalEvent)
                            throws Exception
Description copied from interface: CalendarService
Removes all occurrence from an recurrence series. It will delete the original event of recurrence series.
All exception occurrences of this series still exist and will be treated as a normal event

Specified by:
removeRecurrenceSeries in interface CalendarService
Parameters:
username - owner of recurrent event, in case of private or shared calendar
originalEvent - the original recurrent event object
Throws:
Exception

updateRecurrenceSeries

public void updateRecurrenceSeries(String fromCalendar,
                                   String toCalendar,
                                   String fromType,
                                   String toType,
                                   CalendarEvent occurrence,
                                   String username)
                            throws Exception
Description copied from interface: CalendarService
Updates recurrence series from an occurrence, this function is only called if the occurrence event is not changed the from date property.
In other way, if the occurrence event move to another date, it will be updated as a 'exception' occurrence and not affects to series

Specified by:
updateRecurrenceSeries in interface CalendarService
Parameters:
fromCalendar - the calendarId of the calendar which the recurrent event belong to before updating
toCalendar - the new calendarId of the recurrent event
fromType - calendarType of recurrent event before updating
toType - calendarType of recurrent event after updating
occurrence - the occurrence contains the new data about recurrence series
username - owner of recurrent event, in case of private and shared calendar
Throws:
Exception

getSharedEvent

public CalendarEvent getSharedEvent(String username,
                                    String calendarId,
                                    String eventId)
                             throws Exception
Description copied from interface: CalendarService
Get shared event by user name, calendar id and event id

Specified by:
getSharedEvent in interface CalendarService
Parameters:
username - current user name
calendarId - id of shared calendar
eventId - id of shared event
Returns:
the CalendarEvent object
Throws:
Exception

removeOccurrenceInstance

public void removeOccurrenceInstance(String username,
                                     CalendarEvent occurrence)
                              throws Exception
Description copied from interface: CalendarService
Removes only an occurrence instance from recurrence series, this function will get the original event node of the occurrence and then put the recurrence id of the need-to-delete occurrence to excludeId list of original node.

Specified by:
removeOccurrenceInstance in interface CalendarService
Parameters:
username - owner of this occurrence event
occurrence - the occurrence event object to remove
Throws:
Exception

searchHighlightRecurrenceEvent

public Map<Integer,String> searchHighlightRecurrenceEvent(String username,
                                                          EventQuery eventQuery,
                                                          String[] publicCalendarIds,
                                                          String timezone)
                                                   throws Exception
Description copied from interface: CalendarService
Finds all days of month or year that have event/task to highlight from all personal, shared and public calendar of an user
This function is much same like searchHightLightEvent() function but it only counts for recurrent event

Specified by:
searchHighlightRecurrenceEvent in interface CalendarService
Parameters:
username - the username of user
eventQuery - EventQuery object to limit time-range
publicCalendarIds - list of public calendar
timezone - timezone
Returns:
Throws:
Exception

shareCalendarByRunJob

public void shareCalendarByRunJob(String username,
                                  String calendarId,
                                  List<String> sharedGroups)
                           throws Exception
Shares Calendar with groups

When a calendar is selected to share with a group, the sharing process will run as job in background to avoid blocking the user. It will send notification for users about starting and finishing the job.

Specified by:
shareCalendarByRunJob in interface CalendarService
Parameters:
username - Id of current user
calendarId - Id of shared calendar
sharedGroups - List of shared groups
Throws:
Exception

removeSharedCalendarByJob

public void removeSharedCalendarByJob(String username,
                                      List<String> unsharedGroups,
                                      String calendarId)
                               throws Exception
Un-shares a calendar with groups.

To avoid letting users wait too long, un-sharing with groups runs as job in background. There are notifications about job starting and finishing

Specified by:
removeSharedCalendarByJob in interface CalendarService
Parameters:
username - Id of current user
unsharedGroups - List of un-shared groups
calendarId - Id of shared calendar
Throws:
Exception
See Also:
CalendarService#shareCalendarByRunJob(String, String, List)}

isGroupBeingShared

public boolean isGroupBeingShared(String group,
                                  org.exoplatform.services.scheduler.impl.JobSchedulerServiceImpl schedulerService_)
                           throws Exception
Description copied from interface: CalendarService
Checks if a group is belong to a list of groups that's being shared

Specified by:
isGroupBeingShared in interface CalendarService
Parameters:
group - Id of the group to be checked
schedulerService_ - The schedule service that manages jobs
Returns:
true if this group is belong to a list of groups that is being shared, false if not.
Throws:
Exception
See Also:
CalendarService#shareCalendarByRunJob(String, String, List)}

getEventById

public CalendarEvent getEventById(String eventId)
                           throws Exception
Description copied from interface: CalendarService
Gets event by its Id

Specified by:
getEventById in interface CalendarService
Parameters:
eventId - Id of the event
Returns:
a CalendarEvent
Throws:
Exception

getCalendarById

public Calendar getCalendarById(String calId)
                         throws Exception
Description copied from interface: CalendarService
Gets a calendar by its id

Specified by:
getCalendarById in interface CalendarService
Parameters:
calId - Id of the calendar
Returns:
a Calendar
Throws:
Exception

autoShareCalendar

public void autoShareCalendar(List<String> groupsOfUser,
                              String receiver)
                       throws Exception
Shares group calendars with an user when he is assigned a new membership

This method is called in NewMembershipListener.postSave(org.exoplatform.services.organization.Membership, boolean).

Specified by:
autoShareCalendar in interface CalendarService
Parameters:
groupsOfUser - List of group id
receiver - User id
Throws:
Exception

autoRemoveShareCalendar

public void autoRemoveShareCalendar(String groupId,
                                    String username)
                             throws Exception
Un-shares group calendars with an user when he is removed from a membership

This method is called in NewMembershipListener.preDelete(org.exoplatform.services.organization.Membership).

Specified by:
autoRemoveShareCalendar in interface CalendarService
Throws:
Exception


Copyright © 2003-2013 eXo Platform SAS. All Rights Reserved.