Overview
TheAnnouncementService extends the MessageService and provides functionality for managing announcements and announcement channels in Sakai LMS. Announcements are used to broadcast information to site members.
Package: org.sakaiproject.announcement.api
Source: /announcement/announcement-api/api/src/java/org/sakaiproject/announcement/api/AnnouncementService.java
Constants
Application Identifiers
Security Permissions
Core Methods
Channel Management
getAnnouncementChannel
Retrieve a specific announcement channel.String
required
The channel reference
AnnouncementChannel with the specified reference
Throws:
IdUnusedException- If the channel reference is not definedPermissionException- If the user lacks permissions to access the channel
addAnnouncementChannel
Create a new announcement channel.String
required
The channel reference for the new channel
AnnouncementChannelEdit object
Throws:
IdUsedException- If the channel reference is already in useIdInvalidException- If the reference contains invalid charactersPermissionException- If the user lacks permission to add channels
Message Retrieval
getMessages
Retrieve messages from a channel with optional filtering and merging.String
required
The channel’s reference string
Filter
A filtering object to accept messages, or null for no filtering
boolean
required
Order of messages - true for ascending, false for descending
boolean
required
Flag to include merged channel messages from other sites/channels
AnnouncementMessage objects (may be empty)
Example:
getChannelMessages
Retrieve messages with advanced filtering options including merged channels and synoptic views.String
The hosting channel reference
Filter
A filtering object, or null if no filtering is desired
boolean
required
Order of messages - true for ascending, false for descending
String
Delimited list of channel references to merge
boolean
required
Set to true to retrieve messages from all user’s sites
boolean
required
Whether this is being called from a synoptic tool
String
The site we want messages for
Integer
If filter is null, this will filter returned messages by age
AnnouncementMessage objects
Example:
getVisibleMessagesOfTheDay
Retrieve visible Message of the Day (MOTD) announcements.Time
Optional lower-bound date filter - messages before this are excluded
int
required
Maximum number of messages to return (values < 0 are treated as 0)
boolean
required
Sort order - true for oldest-first, false for newest-first
Utility Methods
getAnnouncementReference
Get the announcement entity reference for a given context.String
required
The announcement context (site-id)
getRssUrl
Get the URL to access the announcement RSS feed.Reference
required
The announcement entity reference
clearMessagesCache
Clear the message cache for a specific channel.String
required
The channel reference
getMaxAgeInDaysAndAmountFilter
Create a filter based on maximum age and message count.Integer
Maximum age of messages in days
Integer
Maximum number of messages to return
Filter object configured with the specified parameters
Events
Event Types
Tool IDs
Usage Examples
Complete Example: Creating and Posting an Announcement
See Also
- MessageService API - Parent service interface
- Entity API - Entity and reference handling
- Security API - Permission checking