001: /**********************************************************************************
002: * $URL: https://source.sakaiproject.org/svn/rights/tags/sakai_2-4-1/rights-api/api/src/java/org/sakaiproject/rights/cover/RightsService.java $
003: * $Id: RightsService.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.cover;
021:
022: import org.sakaiproject.component.cover.ComponentManager;
023:
024: public class RightsService implements
025: org.sakaiproject.rights.api.RightsService {
026: protected static org.sakaiproject.rights.api.RightsService m_instance = null;
027:
028: /**
029: * Access the component instance: special cover only method.
030: *
031: * @return the component instance.
032: */
033: public static org.sakaiproject.rights.api.RightsService getInstance() {
034: if (ComponentManager.CACHE_COMPONENTS) {
035: if (m_instance == null)
036: m_instance = (org.sakaiproject.rights.api.RightsService) ComponentManager
037: .get(org.sakaiproject.rights.api.RightsService.class);
038: return m_instance;
039: } else {
040: return (org.sakaiproject.rights.api.RightsService) ComponentManager
041: .get(org.sakaiproject.rights.api.RightsService.class);
042: }
043: }
044:
045: public org.sakaiproject.rights.api.RightsAssignment addRightsAssignment(
046: String entityRef) {
047: org.sakaiproject.rights.api.RightsService service = getInstance();
048: if (service == null)
049: return null;
050:
051: return service.addRightsAssignment(entityRef);
052: }
053:
054: public org.sakaiproject.rights.api.SiteRightsPolicy addSiteRightsPolicy(
055: String context) {
056: org.sakaiproject.rights.api.RightsService service = getInstance();
057: if (service == null)
058: return null;
059:
060: return service.addSiteRightsPolicy(context);
061: }
062:
063: public org.sakaiproject.rights.api.UserRightsPolicy addUserRightsPolicy(
064: String context, String userId) {
065: org.sakaiproject.rights.api.RightsService service = getInstance();
066: if (service == null)
067: return null;
068:
069: return service.addUserRightsPolicy(context, userId);
070: }
071:
072: public org.sakaiproject.rights.api.RightsAssignment getRightsAssignment(
073: String entityRef)
074: throws org.sakaiproject.exception.IdUnusedException {
075: org.sakaiproject.rights.api.RightsService service = getInstance();
076: if (service == null)
077: return null;
078:
079: return service.getRightsAssignment(entityRef);
080: }
081:
082: public org.sakaiproject.rights.api.SiteRightsPolicy getSiteRightsPolicy(
083: String context) {
084: org.sakaiproject.rights.api.RightsService service = getInstance();
085: if (service == null)
086: return null;
087:
088: return service.getSiteRightsPolicy(context);
089: }
090:
091: public org.sakaiproject.rights.api.UserRightsPolicy getUserRightsPolicy(
092: String context, String userId) {
093: org.sakaiproject.rights.api.RightsService service = getInstance();
094: if (service == null)
095: return null;
096:
097: return service.getUserRightsPolicy(context, userId);
098: }
099:
100: public void save(org.sakaiproject.rights.api.RightsAssignment rights) {
101: org.sakaiproject.rights.api.RightsService service = getInstance();
102: if (service == null)
103: return;
104:
105: service.save(rights);
106: }
107:
108: public void save(org.sakaiproject.rights.api.RightsPolicy policy) {
109: org.sakaiproject.rights.api.RightsService service = getInstance();
110: if (service == null)
111: return;
112:
113: service.save(policy);
114: }
115:
116: public void setRightsAssignment(String entityRef,
117: org.sakaiproject.rights.api.RightsAssignment rights) {
118: org.sakaiproject.rights.api.RightsService service = getInstance();
119: if (service == null)
120: return;
121:
122: service.setRightsAssignment(entityRef, rights);
123: }
124:
125: }
|