001: /**********************************************************************************
002: * $URL: https://source.sakaiproject.org/svn/chat/tags/sakai_2-4-1/chat-api/api/src/java/org/sakaiproject/chat2/model/ChatManager.java $
003: * $Id: ChatManager.java 22945 2007-03-19 17:15:28Z chmaurer@iupui.edu $
004: ***********************************************************************************
005: *
006: * Copyright (c) 2007 The Sakai Foundation.
007: *
008: * Licensed under the Educational Community License, Version 1.0 (the "License");
009: * you may not use this file except in compliance with the License.
010: * You may obtain a copy of the License at
011: *
012: * http://www.opensource.org/licenses/ecl1.php
013: *
014: * Unless required by applicable law or agreed to in writing, software
015: * distributed under the License is distributed on an "AS IS" BASIS,
016: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
017: * See the License for the specific language governing permissions and
018: * limitations under the License.
019: *
020: **********************************************************************************/package org.sakaiproject.chat2.model;
021:
022: import java.util.Date;
023: import java.util.List;
024:
025: import org.sakaiproject.entity.api.EntitySummary;
026: import org.sakaiproject.entity.api.EntityTransferrer;
027: import org.sakaiproject.exception.PermissionException;
028:
029: /**
030: *
031: * @author andersjb
032: *
033: */
034: public interface ChatManager extends EntitySummary {
035:
036: /** The type string for this application: should not change over time as it may be stored in various parts of persistent entities. */
037: static final String APPLICATION_ID = "sakai:chat";
038:
039: /** This string starts the references to resources in this service. */
040: public static final String REFERENCE_ROOT = "/chat";
041:
042: public static final String REF_TYPE_CHANNEL = "channel";
043:
044: public static final String CHAT = "chat";
045:
046: /** The Reference type for a messgae. */
047: public static final String REF_TYPE_MESSAGE = "msg";
048:
049: public static final String CHAT_TOOL_ID = "sakai.chat";
050:
051: /**
052: * Creates a new ChatChannel but doesn't put it in the database.
053: * @param context Id of what the channel is linked to
054: * @param title String the title of the channel
055: * @param contextDefaultChannel boolean to set this as the default channel in the context
056: * @param checkAuthz boolean indicating if we should check for authorization before creating the channel
057: * @return ChatChannel the new un-saved channel
058: */
059: public ChatChannel createNewChannel(String context, String title,
060: boolean contextDefaultChannel, boolean checkAuthz)
061: throws PermissionException;
062:
063: /**
064: * updates the channel back into the database
065: * @param channel ChatChannel
066: * @param checkAuthz boolean indicating if we should check for authorization before updating
067: */
068: public void updateChannel(ChatChannel channel, boolean checkAuthz)
069: throws PermissionException;
070:
071: /**
072: * deletes the channel from the database. It also removes the ChatMessages
073: * @param channel
074: */
075: public void deleteChannel(ChatChannel channel)
076: throws PermissionException;
077:
078: /**
079: * gets one chat room
080: * @param chatChannelId Id
081: * @return ChatChannel
082: */
083: public ChatChannel getChatChannel(String chatChannelId);
084:
085: /**
086: * gets all the messages from the Channel after the passed date
087: * @param channel ChatChannel
088: * @param context Context of channel and messages to return
089: * @param date Date that the messages need to be newer than. All messages will be returned if null
090: * @param items The number of messages to return. All if set to 0
091: * @param sortAsc Boolean to sort the records in ascending order
092: * @return List of ChatMessages
093: */
094: public List<ChatMessage> getChannelMessages(ChatChannel channel,
095: String context, Date date, int items, boolean sortAsc)
096: throws PermissionException;
097:
098: /**
099: * creates an unsaved Chat Message
100: * @param ChatChannel the channel that the new message will be in
101: * @param String the owner of the message
102: * @return ChatMessage
103: */
104: public ChatMessage createNewMessage(ChatChannel channel,
105: String owner) throws PermissionException;
106:
107: /**
108: * saves a Chat Message
109: * @param ChatMessage the message to update
110: */
111: public void updateMessage(ChatMessage message);
112:
113: /**
114: * delete a Chat Message
115: * @param ChatMessage the message to delete
116: */
117: public void deleteMessage(ChatMessage message)
118: throws PermissionException;
119:
120: /**
121: * gets the message with the id
122: * @param chatMessageId Id
123: * @return ChatMessage
124: */
125: public ChatMessage getMessage(String chatMessageId);
126:
127: /**
128: * Adds a room listener on the room
129: * @param observer RoomObserver the class to observe the room
130: * @param roomId the room being observed
131: */
132: public void addRoomListener(RoomObserver observer, String roomId);
133:
134: /**
135: * Removes a room listener on the room
136: * @param observer RoomObserver the class to stop observing the room
137: * @param roomId the room being observed
138: */
139: public void removeRoomListener(RoomObserver observer, String roomId);
140:
141: /**
142: * sends the message out to the other clients
143: * @param entry ChatMessage
144: */
145: public void sendMessage(ChatMessage entry);
146:
147: /**
148: * gets the rooms associated with the context
149: * @param context Site the channel is in
150: * @param lazy boolean to load the messages lazily or not
151: * @return List of ChatChannel
152: */
153:
154: public List getContextChannels(String context, boolean lazy);
155:
156: /**
157: * Gets the rooms associated with the context
158: * If no rooms are found, one is created with the passed title
159: * @param contextId Id
160: * @param defaultNewTitle String the default name of a new ChatChannel
161: * @return List of ChatChannel
162: */
163: public List getContextChannels(String contextId,
164: String defaultNewTitle);
165:
166: /**
167: * Returns the context's default channel, or null if none.
168: * @param contextId
169: * @return
170: */
171: public ChatChannel getDefaultChannel(String contextId);
172:
173: public boolean getCanDelete(ChatMessage chatMessage);
174:
175: public boolean getCanDelete(ChatMessage message, String placementId);
176:
177: public boolean getCanDelete(ChatChannel channel);
178:
179: //public boolean getCanDelete(ChatChannel channel, String placementId);
180:
181: public boolean getCanEdit(ChatChannel channel);
182:
183: public boolean getCanCreateChannel();
184:
185: public boolean getCanReadMessage(ChatChannel channel);
186:
187: public boolean isMaintainer();
188:
189: /**
190: * Makes the passed channel the dfault in the channel's context
191: * @param channel
192: */
193: public void makeDefaultContextChannel(ChatChannel channel);
194:
195: /**
196: * Returns a Date object that is the offset number of days before the current date
197: * @param offset Difference in days from current date
198: * @return
199: */
200: public Date calculateDateByOffset(int offset);
201:
202: public String serviceName();
203:
204: public String getLabel();
205:
206: }
|