001: /**********************************************************************************
002: * $URL: $
003: * $Id: $
004: ***********************************************************************************
005: *
006: * Copyright (c) 2006, 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.content.api;
021:
022: import java.util.List;
023: import java.util.Vector;
024:
025: /**
026: * ResourceToolAction defines the way in which actions are described in a resource-type registration.
027: * Each action should have its own ResourceToolAction defined in the registration.
028: * If the action requires user interaction by a helper, the resource-type registration should include
029: * an action definition that implements the InteractionAction interface.
030: * If an action requires action by another webapp but does not involve user interaction (i.e. it does
031: * not delegate the user interaction to a helper), the resource-type registration should include an
032: * action definition that implements the ServiceLevelAction interface.
033: * Most actions for new resources types are likely to be similar to familiar actions on resources (e.g.
034: * "create", "revise", "delete", etc) and permissions for these actions are handled by the Content Hosting
035: * Service. If an action requires custom permissions, the definition of that action implements the
036: * CustomToolAction interface to provide a way for the Resources tool to determine whether to show
037: * the action as an option in a particular context to a particular user.
038: * A ResourceToolAction deinition should implement at least one of those subinterfaces, and it may
039: * implement all three. If a ResourceToolAction implements both InteractionAction and ServiceLevelAction,
040: * the activity of the helper defined by InteractionAction will occur before the service-level activity
041: * defined by ServiceLevelAction.
042: *
043: * @see org.sakaiproject.content.api.ResourceType
044: */
045: public interface ResourceToolAction {
046: /**
047: * ActionType defines identifiers for types of actions related to resources.
048: */
049: public enum ActionType {
050: /**
051: * Create upload -- Handled by Resources tool. Can create multiple uploads at once.
052: * Metadata and content supplied in same form. Requires content.new permission
053: * in parent folder.
054: */
055: NEW_UPLOAD,
056:
057: /**
058: * Create folder -- Handled by Resources tool. Can create multiple folders at once.
059: * No content; requires metadata only. Requires content.new permission in parent
060: * folder.
061: */
062: NEW_FOLDER,
063:
064: /**
065: * Create URLs -- Handled by Resources tool. Can create multiple URLs at once.
066: * No content; requires metadata only. Requires content.new permission in parent
067: * folder.
068: */
069: NEW_URLS,
070:
071: /**
072: * Create other -- Handled by helper and Resources tool. Can create one item at a time.
073: * Content (and possibly some properties) handled by helper. Metadata supplied in
074: * form that appears after helper finishes. Requires content.new permission in
075: * parent folder.
076: */
077: CREATE,
078:
079: /**
080: * Delete -- Handled by Resources tool. Requires content.delete permission
081: */
082: DELETE,
083:
084: /**
085: * Revise content -- Handled by helper. Requires content.revise.any permission (or
086: * content.revise.own if user is creator).
087: */
088: REVISE_CONTENT,
089:
090: /**
091: * Replace content -- Handled by Resources tool. Requires content.revise.any permission
092: * (or content.revise.own if user is creator).
093: */
094: REPLACE_CONTENT,
095:
096: /**
097: * Revise metadata -- Handled by Resources tool. Requires content.revise.any permission
098: * (or content.revise.own if user is creator).
099: */
100: REVISE_METADATA,
101:
102: /**
103: * Copy -- Handled by Resources tool. Requires content.read permission for item being
104: * copied and content.new permission in folder to which it's copied.
105: */
106: COPY,
107:
108: /**
109: * Move -- Handled by Resources tool. Requires content.delete (or content.update ?) permission for
110: * item being moved and content.new permission in folder to which it's moved.
111: */
112: MOVE,
113:
114: /**
115: * Duplicate -- Handled by Resources tool. Requires content.read permission for item being
116: * duplicated and content.new permission in parent folder.
117: */
118: DUPLICATE,
119:
120: /**
121: * View content -- Handled by AccessServlet (via Resources tool) or helper. Requires
122: * content.read permission.
123: */
124: VIEW_CONTENT,
125:
126: /**
127: * View metadata -- Handled by Resources tool. Requires content.read permission.
128: */
129: VIEW_METADATA,
130:
131: /**
132: * Paste Moved Items -- Handled by Resources tool. Requires content.new permission. The action
133: * is only available after a MOVE action and before some other action that
134: * cancels the PASTE_MOVED.
135: */
136: PASTE_MOVED,
137:
138: /**
139: * Paste Copied Items -- Handled by Resources tool. Requires content.new permission. The action
140: * is only available after a COPY action and before some other action that
141: * cancels the PASTE_COPIED.
142: */
143: PASTE_COPIED,
144:
145: /**
146: * Defines a custom sort order for the contents of a folder -- Handled by Resources tool. Requires
147: * content.revise permission for the folder.
148: */
149: REVISE_ORDER,
150:
151: /**
152: * Revise folder permissions -- Handled by Resources tool. Requires site.upd permission.
153: */
154: REVISE_PERMISSIONS,
155:
156: /**
157: * Custom action -- Handled by helper. May be interactive or service-level. Custom actions
158: * must implement the CustomToolAction interface to provide Resources tool with a way to
159: * determine permissions, as well as either InteractionAction or ServiceLevelAction.
160: */
161: CUSTOM_TOOL_ACTION
162:
163: }
164:
165: public static final String CREATE = "create";
166: public static final String DELETE = "delete";
167: public static final String COPY = "copy";
168: public static final String REVISE_CONTENT = "revise";
169: public static final String REPLACE_CONTENT = "replace";
170: public static final String REVISE_METADATA = "properties";
171: public static final String ACCESS_CONTENT = "access";
172: public static final String ACCESS_PROPERTIES = "info";
173: public static final String DUPLICATE = "duplicate";
174: public static final String MOVE = "move";
175: public static final String PASTE_MOVED = "paste_moved";
176: public static final String PASTE_COPIED = "paste_copied";
177: public static final String PERMISSIONS = "revise_permissions";
178: public static final String REORDER = "revise_order";
179:
180: public static final String ACTION_DELIMITER = ":";
181:
182: /**
183: * Prefix for all keys to Tool Session attributes used in messaging between ResourcesAction and
184: * helpers related to registered resource tool actions. Removing all attributes whose keys begin
185: * with this prefix cleans up the tool session after a helper completes its work.
186: * ResourcesAction will cleanup tool session.
187: */
188: public static final String PREFIX = "resourceToolAction.";
189:
190: public static final String ACTION_PIPE = PREFIX + "action_pipe";
191:
192: public static final String STARTED = PREFIX + "started";
193:
194: public static final String STATE_MODE = PREFIX + "state_mode";
195:
196: public static final String DONE = PREFIX + "done";
197:
198: /**
199: * Access the id of this action (which must be unique within this type and must be limited to alphnumeric characters).
200: * @return
201: */
202: public String getId();
203:
204: /**
205: * Access the id of the ResourceType this action relates to.
206: * @return
207: */
208: public String getTypeId();
209:
210: /**
211: * Access the enumerated constant for this action.
212: * @return
213: */
214: public ActionType getActionType();
215:
216: /**
217: * Access a very short localized string that will be used as a label for this action in the user interface.
218: * If string is longer than about 20 characters, it may be truncated. Shorter strings (less than 10 characters)
219: * are preferred. If this method returns null, the Resources tool will assign a label based on the ActionType.
220: * @return
221: */
222: public String getLabel();
223:
224: /**
225: * Should the resources tool make this action available to the current user with respect to the specified entity?
226: * @param entity
227: * @return
228: */
229: public boolean available(ContentEntity entity);
230:
231: }
|