Skip to main content

Overview

The AnnouncementService 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
Returns: The AnnouncementChannel with the specified reference Throws:
  • IdUnusedException - If the channel reference is not defined
  • PermissionException - If the user lacks permissions to access the channel
Example:

addAnnouncementChannel

Create a new announcement channel.
String
required
The channel reference for the new channel
Returns: The newly created AnnouncementChannelEdit object Throws:
  • IdUsedException - If the channel reference is already in use
  • IdInvalidException - If the reference contains invalid characters
  • PermissionException - If the user lacks permission to add channels
Example:

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
Returns: List of 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
Returns: List of 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
Returns: List of visible MOTD announcements Example:

Utility Methods

getAnnouncementReference

Get the announcement entity reference for a given context.
String
required
The announcement context (site-id)
Returns: Announcement entity reference

getRssUrl

Get the URL to access the announcement RSS feed.
Reference
required
The announcement entity reference
Returns: URL for announcement RSS feed

clearMessagesCache

Clear the message cache for a specific channel.
String
required
The channel reference
Example:

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
Returns: A Filter object configured with the specified parameters

Events

Event Types

Tool IDs

Usage Examples

Complete Example: Creating and Posting an Announcement

See Also