Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
$URL: https://source.sakaiproject.org/svn/message/tags/sakai-10.2/message-api/api/src/java/org/sakaiproject/message/api/MessageService.java $ $Id: MessageService.java 308852 2014-04-25 23:22:20Z enietzel@anisakai.com $ Copyright (c) 2003, 2004, 2005, 2006, 2007, 2008 The Sakai Foundation Licensed under the Educational Community License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.opensource.org/licenses/ECL-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. /
 
 
 package org.sakaiproject.message.api;
 
 
 import java.util.List;
 import java.util.Map;

GenericMessageService is the base interface for the different specific Sakai communications service such as Chat, Announcements, etc.

The service manages a set of message channels, each containing a set of messages.

Channels and Messages can be worked with through the MessageChannel and Message APIs and their extensions.

 
 public interface MessageService extends EntityProducerEntitySummary
 {
Security function / event for reading channel / message.
 
 	public static final String SECURE_READ = "read";

Security function / event for adding channel / message.
 
 	public static final String SECURE_ADD = "new";

Event for adding channel / message.
 
 	public static final String SECURE_CREATE = "create";

Security function / event for removing one's own message.
 
 	public static final String SECURE_REMOVE_OWN = "delete.own";

Security function / event for removing anyone's message or channel.
 
 	public static final String SECURE_REMOVE_ANY = "delete.any";

Security function / event for updating one's own message or the channel.
 
 	public static final String SECURE_UPDATE_OWN = "revise.own";

Security function / event for updating any message.
 
 	public static final String SECURE_UPDATE_ANY = "revise.any";

Security function / event for accessing someone elses draft.
 
 	public static final String SECURE_READ_DRAFT = "read.drafts";

Security function giving the user permission to all groups, if granted to at the channel or site level.
 
 	public static final String SECURE_ALL_GROUPS = "all.groups";

The Reference type for a channel.
 
 	public static final String REF_TYPE_CHANNEL = "channel";

The Reference type for a messgae.
 
 	public static final String REF_TYPE_MESSAGE = "msg";

Return a list of all the defined channels.

Deprecated:
since 8 April 2014 (Sakai 10), this is not useful (why would you want all channels in the system) and would perform very badly, use getChannelIds(String context) OR getChannel(String ref) instead
Returns:
a list of MessageChannel (or extension) objects (may be empty).
 
check permissions for getChannel().

Parameters:
ref The channel reference.
Returns:
true if the user is allowed to getChannel(channelId), false if not.
 
 	public boolean allowGetChannel(String ref);

Return a specific channel.

Parameters:
ref The channel reference.
Returns:
the MessageChannel that has the specified name.
Throws:
org.sakaiproject.exception.IdUnusedException If this name is not defined for any channel.
org.sakaiproject.exception.PermissionException If the user does not have any permissions to the channel.
Find the channel, in cache or info store - cache it if newly found. Warning: No check is made on channel permissions -- caller should filter for public messages

Parameters:
ref The channel reference.
Returns:
The channel, if found.
check permissions for addChannel().

Parameters:
ref The channel reference.
Returns:
true if the user is allowed to addChannel(channelId), false if not.
	public boolean allowAddChannel(String ref);

Add a new channel. Must commitEdit() to make official, or cancelEdit() when done!

Parameters:
ref The channel reference.
Returns:
The newly created channel, locked for update.
Throws:
org.sakaiproject.exception.IdUsedException if the id is not unique.
org.sakaiproject.exception.IdInvalidException if the id is not made up of valid characters.
org.sakaiproject.exception.PermissionException if the user does not have permission to add a channel.
check permissions for editChannel()

Parameters:
ref The channel reference.
Returns:
true if the user is allowed to update the channel, false if not.
	public boolean allowEditChannel(String ref);

Return a specific channel, as specified by channel id, locked for update. Must commitEdit() to make official, or cancelEdit() when done!

Parameters:
ref The channel reference.
Returns:
the Channel that has the specified id.
Throws:
org.sakaiproject.exception.IdUnusedException If this name is not a defined channel.
org.sakaiproject.exception.PermissionException If the user does not have any permissions to edit the channel.
org.sakaiproject.exception.InUseException if the channel is locked for edit by someone else.
Commit the changes made to a MessageChannelEdit object, and release the lock. The MessageChannelEdit is disabled, and not to be used after this call.

Parameters:
user The MessageChannelEdit object to commit.
	public void commitChannel(MessageChannelEdit edit);

Cancel the changes made to a MessageChannelEdit object, and release the lock. The MessageChannelEdit is disabled, and not to be used after this call.

Parameters:
user The MessageChannelEdit object to cancel.
	public void cancelChannel(MessageChannelEdit edit);

Check permissions for removeChannel().

Parameters:
ref The channel reference.
Returns:
true if the user is allowed to removeChannel(), false if not.
	public boolean allowRemoveChannel(String ref);

Remove a channel - it must be locked from editChannel().

Parameters:
channel The channel to remove.
Throws:
org.sakaiproject.exception.PermissionException if the user does not have permission to remove a channel.
	public void removeChannel(MessageChannelEdit channelthrows PermissionException;

Access the internal reference which can be used to access the channel from within the system.

Parameters:
context The context.
id The channel id.
Returns:
The the internal reference which can be used to access the channel from within the system.
	public String channelReference(String contextString id);

Access the internal reference which can be used to access the message from within the system.

Parameters:
context The context.
channelId The channel id.
id The message id.
Returns:
The the internal reference which can be used to access the message from within the system.
	public String messageReference(String contextString channelIdString id);

Access the internal reference which can be used to access the message from within the system.

Parameters:
channelRef The channel reference.
id The message id.
Returns:
The the internal reference which can be used to access the message from within the system.
	public String messageReference(String channelRefString id);

Get a message, given a reference. This call avoids the need to have channel security, as long as the user has permissions to the message.

Parameters:
ref The message reference
Returns:
The message.
Throws:
org.sakaiproject.exception.IdUnusedException If this reference does not identify a message.
org.sakaiproject.exception.PermissionException If the user does not have any permissions to the message.
Cancel the changes made to a MessageEdit object, and release the lock. The MessageEdit is disabled, and not to be used after this call.

Parameters:
user The MessageEdit object to cancel.
	public void cancelMessage(MessageEdit edit);

Access a list of messages in the channel, that are after the date, limited to just the n latest messages, ordered as specified, including drafts if specified. Channel read permission is required, unless pubViewOnly is selected - draft read on the channel is required to see drafts.

Parameters:
afterDate if null, no date limit, else limited to only messages after this date.
limitedToLatest if 0, no count limit, else limited to only the latest this number of messages.
ascending if true, sort oldest first, else sort latest first.
includeDrafts if true, include drafts (if the user has draft permission), else leave them out.
pubViewOnly if true, include only messages marked pubview, else include any.
Returns:
A list of Message objects that meet the criteria; may be empty
Throws:
org.sakaiproject.exception.PermissionException If the current user does not have channel read permission.
	public List<MessagegetMessages(String channelRefTime afterDateint limitedToLatestboolean ascendingboolean includeDrafts,
			boolean pubViewOnlythrows PermissionException;

Access a list of channel ids that are defined related to the context.

Parameters:
context The context in which to search
Returns:
A List (String) of channel id for channels withing the context.
	public List<StringgetChannelIds(String context);

        
Get a summary of an Announcement Channel

Parameters:
ref The channel reference.
items Maximum number of items to return
days Maximum number of days to peer back
Returns:
The Map containing the Summary
Throws:
org.sakaiproject.exception.IdUsedException if the id is not unique.
org.sakaiproject.exception.IdInvalidException if the id is not made up of valid characters.
org.sakaiproject.exception.PermissionException if the user does not have permission to add a channel.
        public Map getSummary(String refint itemsint daysthrows IdUsedExceptionIdInvalidExceptionPermissionException;
// MessageService
New to GrepCode? Check out our FAQ X