Overview
TheCalendarService manages calendars and calendar events in Sakai LMS. Each site can have one or more calendars containing events that can be viewed, edited, and shared.
Package: org.sakaiproject.calendar.api
Source: /calendar/calendar-api/api/src/java/org/sakaiproject/calendar/api/CalendarService.java
Constants
Application Identifiers
Event Types
Security Permissions
View Types
Recurrence Modification Types
Calendar Management
addCalendar
Create a new calendar.String
required
The new calendar reference
CalendarEdit object
Throws:
IdUsedException- If the reference is already in useIdInvalidException- If the reference contains invalid charactersPermissionException- If the user lacks permission to add calendars
commitCalendar() to finalize or cancelCalendar() to discard
Example:
getCalendar
Retrieve a specific calendar.String
required
The calendar reference
Calendar with the specified reference
Throws:
IdUnusedException- If the calendar doesn’t existPermissionException- If the user lacks permissions
editCalendar
Get a locked calendar for editing.String
required
The calendar reference
CalendarEdit object for editing
Throws:
IdUnusedException- If the calendar doesn’t existPermissionException- If the user lacks permissionInUseException- If the calendar is locked by another user
commitCalendar(), cancelCalendar(), or removeCalendar() when done
commitCalendar
Commit changes to a calendar and release the lock.CalendarEdit
required
The calendar edit object to commit
CalendarEdit is disabled after this call
cancelCalendar
Cancel changes to a calendar and release the lock.CalendarEdit
required
The calendar edit object to cancel
removeCalendar
Remove a calendar that is locked for edit.CalendarEdit
required
The calendar to remove
PermissionException if the user lacks permission
Event Management
getEvents
Merge events from multiple calendars within a time range.List
required
List of calendar references
TimeRange
Time period to select events (null = one year before and after)
CalendarEventVector with the union of all events
Example:
getFilteredEvents
Retrieve filtered events for the current user.Map<EventFilterKey, Object>
required
Filter options (supports “limit” and “siteId”)
CalendarEvent objects matching the filter
Example:
Recurrence
newRecurrence
Create a new recurrence rule.String
required
The frequency description (“DAILY”, “WEEKLY”, “MONTHLY”, “YEARLY”)
int
The recurrence interval
int
Number of occurrences
Time
Time after which recurrences stop
RecurrenceRule object
Example:
Reference Methods
calendarReference
Get the internal reference for a calendar.String
required
The context (site ID)
String
required
The calendar ID
eventReference
Get the internal reference for an event.String
required
The context (site ID)
String
required
The calendar ID
String
required
The event ID
calendarICalReference
Get the iCal reference for a calendar.Reference
required
The calendar reference
calendarPdfReference
Get the PDF reference for a calendar.String
required
The context (site ID)
String
required
The calendar ID
int
required
The view type (DAY_VIEW, WEEK_VIEW, etc.)
String
required
Time range for the PDF
String
required
The user name for the PDF
boolean
required
Whether to reverse event order
Permission Checking
allowGetCalendar
Check if the user can get a calendar.String
required
The calendar reference
true if the user is allowed to get the calendar
allowEditCalendar
Check if the user can edit a calendar.String
required
The calendar reference
true if the user can edit the calendar
allowImportCalendar
Check if the user can import calendar events.String
required
The calendar reference
true if the user can import events
allowSubscribeCalendar
Check if the user can subscribe to external calendars.String
required
The calendar reference
true if the user can subscribe to external calendars
Export and Subscription
getExportEnabled
Check if public iCal export is enabled for a calendar.String
required
The calendar reference
true if export is enabled
setExportEnabled
Enable or disable public iCal export for a calendar.String
required
The calendar reference
boolean
required
True to enable, false to disable
Utility Methods
getCalendarReferences
Get all calendar references for a site.String
required
The site ID
isCalendarToolInitialized
Check if the calendar tool has been initialized for a site.String
required
The site ID
true if the calendar has been created
getUpcomingDaysLimit
Get the limit on upcoming days for filtered events.calendar.upcoming_days_limit)
Complete Example
See Also
- Time API - Time and TimeRange objects
- Entity API - Entity and reference handling