001: /**********************************************************************************
002: * $URL: https://source.sakaiproject.org/svn/rights/tags/sakai_2-4-1/rights-impl/impl/src/java/org/sakaiproject/rights/impl/BasicRightsService.java $
003: * $Id: BasicRightsService.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.impl;
021:
022: import java.util.Hashtable;
023: import java.util.Map;
024:
025: import org.sakaiproject.exception.IdUnusedException;
026: import org.sakaiproject.rights.impl.BaseRightsService;
027: import org.sakaiproject.rights.impl.BaseRightsService.BasicRightsAssignment;
028: import org.sakaiproject.rights.impl.BaseRightsService.Storage;
029: import org.sakaiproject.rights.api.Copyright;
030: import org.sakaiproject.rights.api.CreativeCommonsLicense;
031: import org.sakaiproject.rights.api.RightsAssignment;
032: import org.sakaiproject.rights.api.RightsPolicy;
033: import org.sakaiproject.rights.api.RightsService;
034:
035: public class BasicRightsService extends BaseRightsService {
036: /**********************************************************************************************************************************************************************************************************************************************************
037: * Storage implementation
038: *********************************************************************************************************************************************************************************************************************************************************/
039:
040: protected class BasicStorage implements Storage {
041: protected Map m_copyrights;
042: protected Map m_licenses;
043: protected Map m_rightsAssignments;
044:
045: public BasicStorage() {
046: m_copyrights = new Hashtable();
047: m_licenses = new Hashtable();
048: m_rightsAssignments = new Hashtable();
049: }
050:
051: public void close() {
052: if (m_copyrights != null) {
053: m_copyrights.clear();
054: m_copyrights = null;
055: }
056:
057: if (m_licenses != null) {
058: m_licenses.clear();
059: m_licenses = null;
060: }
061:
062: if (m_rightsAssignments != null) {
063: m_rightsAssignments.clear();
064: m_rightsAssignments = null;
065: }
066: }
067:
068: public Copyright getCopyright(String copyrightId)
069: throws IdUnusedException {
070: Copyright copyright = (Copyright) m_copyrights
071: .get(copyrightId);
072: if (copyright == null) {
073: throw new IdUnusedException(copyrightId);
074: }
075: return copyright;
076: }
077:
078: public CreativeCommonsLicense getLicense(String licenseId)
079: throws IdUnusedException {
080: CreativeCommonsLicense license = (CreativeCommonsLicense) m_licenses
081: .get(licenseId);
082: if (license == null) {
083: throw new IdUnusedException(licenseId);
084: }
085: return license;
086: }
087:
088: public RightsAssignment getRightsAssignment(String entityRef)
089: throws IdUnusedException {
090: RightsAssignment rights = (RightsAssignment) m_rightsAssignments
091: .get(entityRef);
092: if (rights == null) {
093: throw new IdUnusedException(entityRef);
094: }
095: return rights;
096: }
097:
098: public RightsPolicy getRightsPolicy(String context,
099: String userId) throws IdUnusedException {
100: // TODO Auto-generated method stub
101: return null;
102: }
103:
104: public Copyright newCopyright(String rightsId) {
105: return new BasicCopyright(rightsId);
106: }
107:
108: public CreativeCommonsLicense newLicense(String rightsId) {
109: // TODO Auto-generated method stub
110: return null;
111: }
112:
113: public RightsAssignment newRightsAssignment(String entityRef) {
114: return new BasicRightsAssignment(entityRef);
115: }
116:
117: public RightsPolicy newRightsPolicy(String context,
118: String userId) {
119: // TODO Auto-generated method stub
120: return null;
121: }
122:
123: public void open() {
124: }
125:
126: public void remove(Copyright copyright) {
127: // TODO Auto-generated method stub
128:
129: }
130:
131: public void remove(CreativeCommonsLicense license) {
132: // TODO Auto-generated method stub
133:
134: }
135:
136: public void remove(RightsAssignment rights) {
137: // TODO Auto-generated method stub
138:
139: }
140:
141: public void remove(RightsPolicy policy) {
142: // TODO Auto-generated method stub
143:
144: }
145:
146: public String save(Copyright copyright) {
147: // TODO Auto-generated method stub
148: return null;
149: }
150:
151: public String save(CreativeCommonsLicense license) {
152: // TODO Auto-generated method stub
153: return null;
154: }
155:
156: public String save(RightsAssignment rights) {
157: // TODO Auto-generated method stub
158: return null;
159: }
160:
161: public String save(RightsPolicy policy) {
162: // TODO Auto-generated method stub
163: return null;
164: }
165: }
166:
167: /**********************************************************************************************************************************************************************************************************************************************************
168: * BaseRightsService extensions
169: *********************************************************************************************************************************************************************************************************************************************************/
170:
171: /**
172: * Shutdown cleanly
173: */
174: public void destroy() {
175:
176: }
177:
178: /**
179: * Final initialization, once all dependencies are set.
180: */
181: public void init() {
182: }
183:
184: /**
185: * Construct a Storage object.
186: *
187: * @return The new storage object.
188: */
189: protected Storage newStorage() {
190: return new BasicStorage();
191:
192: } // newStorage
193:
194: }
|