001: /**********************************************************************************
002: * $URL: https://source.sakaiproject.org/svn/rights/tags/sakai_2-4-1/rights-api/api/src/java/org/sakaiproject/rights/api/CreativeCommonsLicense.java $
003: * $Id: CreativeCommonsLicense.java 17729 2006-11-01 15:48:20Z lance@indiana.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.rights.api;
021:
022: import java.util.Collection;
023: import java.util.Stack;
024:
025: import org.sakaiproject.rights.util.RightsException;
026: import org.w3c.dom.Document;
027: import org.w3c.dom.Element;
028:
029: /**
030: * Creative Commons Licenses are described by their characteristics, which come in three types:
031: *
032: * Permissions (rights granted by the license)
033: * Prohibitions (things prohibited by the license)
034: * Requirements (restrictions imposed by the license)
035: *
036: */
037: public interface CreativeCommonsLicense {
038: public String getIdentifier();
039:
040: public String getUri();
041:
042: /*****************************************************
043: * Permissions
044: *****************************************************/
045:
046: /**
047: * @return
048: */
049: public boolean hasPermissions();
050:
051: /**
052: * @return
053: */
054: public Collection getPermissions();
055:
056: /**
057: * @param permission
058: * @throws RightsException
059: */
060: public void addPermission(String permission) throws RightsException;
061:
062: /**
063: * @param permission
064: */
065: public void addPermission(Permission permission);
066:
067: /**
068: * @param permission
069: */
070: public void removePermission(String permission);
071:
072: /**
073: * @param permissions
074: */
075: public void setPermissions(Collection permissions);
076:
077: /*****************************************************
078: * Prohibitions
079: *****************************************************/
080:
081: /**
082: * @return
083: */
084: public boolean hasProhibitions();
085:
086: /**
087: * @return
088: */
089: public Collection getProhibitions();
090:
091: /**
092: * @param prohibition
093: */
094: public void addProhibition(String prohibition)
095: throws RightsException;
096:
097: /**
098: * @param prohibition
099: */
100: public void addProhibition(Prohibition prohibition);
101:
102: /**
103: * @param prohibitions
104: */
105: public void removeProhibitions(Collection prohibitions);
106:
107: /**
108: * @param prohibitions
109: */
110: public void setProhibitions(Collection prohibitions);
111:
112: /*****************************************************
113: * Prohibitions
114: *****************************************************/
115:
116: /**
117: * @return
118: */
119: public boolean hasRequirements();
120:
121: /**
122: * @return
123: */
124: public Collection getRequirements();
125:
126: /**
127: * @param requirement
128: */
129: public void addRequirement(String requirement)
130: throws RightsException;
131:
132: /**
133: * @param requirement
134: */
135: public void addRequirement(Requirement requirement);
136:
137: /**
138: * @param requirements
139: */
140: public void removeRequirements(Collection requirements);
141:
142: /**
143: * @param requirements
144: */
145: public void setRequirements(Collection requirements);
146:
147: /**
148: * Permissions describe rights granted by the license. Three kinds of permissions may be granted:
149: *
150: * Reproduction
151: * the work may be reproduced
152: * Distribution
153: * the work (and, if authorized, derivative works) may be distributed, publicly displayed, and publicly performed
154: * DerivativeWorks
155: * derivative works may be created and reproduced
156: */
157: public class Permission {
158: protected final String m_id;
159:
160: /**
161: * @param id
162: */
163: private Permission(String id) {
164: m_id = id;
165: }
166:
167: /* (non-Javadoc)
168: * @see java.lang.Object#toString()
169: */
170: public String toString() {
171: return m_id;
172: }
173:
174: /* (non-Javadoc)
175: * @see java.lang.Object#equals(java.lang.Object)
176: */
177: public boolean equals(Object obj) {
178: boolean rv = false;
179:
180: if (obj instanceof Permission) {
181: rv = ((Permission) obj).toString().equals(
182: this .toString());
183: }
184:
185: return rv;
186: }
187:
188: /**
189: * @param permitted
190: * @return
191: */
192: public static Permission fromString(String permitted) {
193: if (REPRODUCTION.m_id.equals(permitted))
194: return REPRODUCTION;
195: if (DISTRIBUTION.m_id.equals(permitted))
196: return DISTRIBUTION;
197: if (DERIVATIVE_WORKS.m_id.equals(permitted))
198: return DERIVATIVE_WORKS;
199: return null;
200: }
201:
202: /** the work may be reproduced */
203: public static final Permission REPRODUCTION = new Permission(
204: "Reproduction");
205:
206: /** the work (and, if authorized, derivative works) may be distributed, publicly displayed, and publicly performed */
207: public static final Permission DISTRIBUTION = new Permission(
208: "Distribution");
209:
210: /** derivative works may be created and reproduced */
211: public static final Permission DERIVATIVE_WORKS = new Permission(
212: "DerivativeWorks");
213: }
214:
215: /**
216: * Prohibitions describe things prohibited by the license:
217: *
218: * CommercialUse
219: * rights may be exercised for commercial purposes unless CommercialUse is prohibited
220: */
221: public class Prohibition {
222: protected final String m_id;
223:
224: /**
225: * @param id
226: */
227: private Prohibition(String id) {
228: m_id = id;
229: }
230:
231: /* (non-Javadoc)
232: * @see java.lang.Object#toString()
233: */
234: public String toString() {
235: return m_id;
236: }
237:
238: /* (non-Javadoc)
239: * @see java.lang.Object#equals(java.lang.Object)
240: */
241: public boolean equals(Object obj) {
242: boolean rv = false;
243:
244: if (obj instanceof Prohibition) {
245: rv = ((Prohibition) obj).toString().equals(
246: this .toString());
247: }
248:
249: return rv;
250: }
251:
252: /**
253: * @param prohibited
254: * @return
255: */
256: public static Prohibition fromString(String prohibited) {
257: if (COMMERCIAL_USE.m_id.equals(prohibited))
258: return COMMERCIAL_USE;
259: return null;
260: }
261:
262: /** rights may be exercised for commercial purposes unless CommercialUse is prohibited */
263: public static final Prohibition COMMERCIAL_USE = new Prohibition(
264: "CommercialUse");
265:
266: }
267:
268: /**
269: * Requirements describe restrictions imposed by the license:
270: *
271: * Notice
272: * copyright and license notices must be kept intact
273: * Attribution
274: * credit must be given to copyright holder and/or author
275: * ShareAlike
276: * derivative works must be licensed under the same terms as the original work
277: * SourceCode
278: * source code (the preferred form for making modifications) must be provided for all derivative works
279: */
280: public class Requirement {
281: protected final String m_id;
282:
283: /**
284: * @param id
285: */
286: private Requirement(String id) {
287: m_id = id;
288: }
289:
290: /* (non-Javadoc)
291: * @see java.lang.Object#toString()
292: */
293: public String toString() {
294: return m_id;
295: }
296:
297: /* (non-Javadoc)
298: * @see java.lang.Object#equals(java.lang.Object)
299: */
300: public boolean equals(Object obj) {
301: boolean rv = false;
302:
303: if (obj instanceof Requirement) {
304: rv = ((Requirement) obj).toString().equals(
305: this .toString());
306: }
307:
308: return rv;
309: }
310:
311: /**
312: * @param required
313: * @return
314: */
315: public static Requirement fromString(String required) {
316: if (NOTICE.m_id.equals(required))
317: return NOTICE;
318: if (ATTRIBUTION.m_id.equals(required))
319: return ATTRIBUTION;
320: if (SHARE_ALIKE.m_id.equals(required))
321: return SHARE_ALIKE;
322: if (SOURCE_CODE.m_id.equals(required))
323: return SOURCE_CODE;
324: return null;
325: }
326:
327: /** copyright and license notices must be kept intact */
328: public static final Requirement NOTICE = new Requirement(
329: "Notice");
330:
331: /** credit must be given to copyright holder and/or author */
332: public static final Requirement ATTRIBUTION = new Requirement(
333: "Attribution");
334:
335: /** derivative works must be licensed under the same terms as the original work */
336: public static final Requirement SHARE_ALIKE = new Requirement(
337: "ShareAlike");
338:
339: /** source code (the preferred form for making modifications) must be provided for all derivative works */
340: public static final Requirement SOURCE_CODE = new Requirement(
341: "SourceCode");
342: }
343:
344: /**
345: * @param doc
346: * @param stack
347: * @return
348: */
349: public Element toXml(Document doc, Stack stack);
350:
351: } // interface CreativeCommonsLicense
|