001: /**********************************************************************************
002: * $URL: https://source.sakaiproject.org/svn/message/tags/sakai_2-4-1/message-api/api/src/java/org/sakaiproject/message/api/MessageHeader.java $
003: * $Id: MessageHeader.java 10272 2006-06-07 13:39:32Z ggolden@umich.edu $
004: ***********************************************************************************
005: *
006: * Copyright (c) 2003, 2004, 2005, 2006 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.message.api;
021:
022: import java.util.Collection;
023: import java.util.Stack;
024:
025: import org.sakaiproject.entity.api.AttachmentContainer;
026: import org.sakaiproject.time.api.Time;
027: import org.sakaiproject.user.api.User;
028: import org.w3c.dom.Document;
029: import org.w3c.dom.Element;
030:
031: /**
032: * <p>
033: * MessageHeader is the base Interface for a Sakai Message headers. Header fields common to all message service message headers are defined here.
034: * </p>
035: */
036: public interface MessageHeader extends AttachmentContainer {
037: /**
038: * <p>
039: * MessageAccess enumerates different access modes for the message: channel-wide or grouped.
040: * </p>
041: */
042: public class MessageAccess {
043: private final String m_id;
044:
045: private MessageAccess(String id) {
046: m_id = id;
047: }
048:
049: public String toString() {
050: return m_id;
051: }
052:
053: static public MessageAccess fromString(String access) {
054: // if (PUBLIC.m_id.equals(access)) return PUBLIC;
055: if (CHANNEL.m_id.equals(access))
056: return CHANNEL;
057: if (GROUPED.m_id.equals(access))
058: return GROUPED;
059: return null;
060: }
061:
062: /** public access to the message: pubview */
063: // public static final MessageAccess PUBLIC = new MessageAccess("public");
064: /** channel (site) level access to the message */
065: public static final MessageAccess CHANNEL = new MessageAccess(
066: "channel");
067:
068: /** grouped access; only members of the getGroup() groups (authorization groups) have access */
069: public static final MessageAccess GROUPED = new MessageAccess(
070: "grouped");
071: }
072:
073: /**
074: * Access the unique (within the channel) message id.
075: *
076: * @return The unique (within the channel) message id.
077: */
078: String getId();
079:
080: /**
081: * Access the date/time the message was sent to the channel.
082: *
083: * @return The date/time the message was sent to the channel.
084: */
085: Time getDate();
086:
087: /**
088: * Access the User who sent the message to the channel.
089: *
090: * @return The User who sent the message to the channel.
091: */
092: User getFrom();
093:
094: /**
095: * Access the draft status of the message.
096: *
097: * @return True if the message is a draft, false if not.
098: */
099: boolean getDraft();
100:
101: /**
102: * Access the groups defined for this message.
103: *
104: * @return A Collection (String) of group refs (authorization group ids) defined for this message; empty if none are defined.
105: */
106: Collection getGroups();
107:
108: /**
109: * Access the groups, as Group objects, defined for this message.
110: *
111: * @return A Collection (Group) of group objects defined for this message; empty if none are defined.
112: */
113: Collection getGroupObjects();
114:
115: /**
116: * Access the access mode for the message - how we compute who has access to the message.
117: *
118: * @return The MessageAccess access mode for the message.
119: */
120: MessageAccess getAccess();
121:
122: /**
123: * Serialize the resource into XML, adding an element to the doc under the top of the stack element.
124: *
125: * @param doc
126: * The DOM doc to contain the XML (or null for a string return).
127: * @param stack
128: * The DOM elements, the top of which is the containing element of the new "resource" element.
129: * @return The newly added element.
130: */
131: Element toXml(Document doc, Stack stack);
132: }
|