001: /**********************************************************************************
002: * $URL: https://source.sakaiproject.org/svn/citations/tags/sakai_2-4-1/citations-api/api/src/java/org/sakaiproject/citation/cover/CitationService.java $
003: * $Id: CitationService.java 29906 2007-05-03 13:22:13Z ajpoland@iupui.edu $
004: ***********************************************************************************
005: *
006: * Copyright (c) 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.citation.cover;
021:
022: import org.sakaiproject.citation.api.CitationCollection;
023: import org.sakaiproject.component.cover.ComponentManager;
024:
025: /**
026: *
027: */
028: public class CitationService {
029: // public static final String REF_TYPE_EXPORT_RIS = org.sakaiproject.citation.api.CitationService.REF_TYPE_EXPORT_RIS;
030: public static final String REF_TYPE_EXPORT_RIS_SEL = org.sakaiproject.citation.api.CitationService.REF_TYPE_EXPORT_RIS_SEL;
031: public static final String REF_TYPE_EXPORT_RIS_ALL = org.sakaiproject.citation.api.CitationService.REF_TYPE_EXPORT_RIS_ALL;
032: public static final String REF_TYPE_VIEW_LIST = org.sakaiproject.citation.api.CitationService.REF_TYPE_VIEW_LIST;
033: public static final String CITATION_LIST_ID = org.sakaiproject.citation.api.CitationService.CITATION_LIST_ID;
034: public static final String PROP_TEMPORARY_CITATION_LIST = org.sakaiproject.citation.api.CitationService.PROP_TEMPORARY_CITATION_LIST;
035:
036: private static org.sakaiproject.citation.api.CitationService m_instance;
037:
038: /**
039: * Checks permissions to add a CitationList. Returns true if the user
040: * has permission to add a resource in the collection identified by the
041: * parameter.
042: * @param contentCollectionId
043: * @return
044: */
045: public static boolean allowAddCitationList(
046: String contentCollectionId) {
047: org.sakaiproject.citation.api.CitationService instance = getInstance();
048: if (instance == null) {
049: return false;
050: }
051: return instance.allowAddCitationList(contentCollectionId);
052: }
053:
054: /**
055: * Checks permission to revise a CitationList, including permissions
056: * to add, remove or revise citations within the CitationList. Returns
057: * true if the user has permission to revise the resource identified by
058: * the parameter. Also returns true if all of these conditions are met:
059: * (1) the user is the creator of the specified resource, (2) the specified
060: * resource is a temporary CitationList (as identified by the value of
061: * the PROP_TEMPORARY_CITATION_LIST property), and (3) the user has
062: * permission to add resources in the collection containing the
063: * resource.
064: * @param contentResourceId
065: * @return
066: */
067: public static boolean allowReviseCitationList(
068: String contentResourceId) {
069: org.sakaiproject.citation.api.CitationService instance = getInstance();
070: if (instance == null) {
071: return false;
072: }
073: return instance.allowReviseCitationList(contentResourceId);
074: }
075:
076: /**
077: *
078: * @return
079: */
080: public static boolean allowRemoveCitationList(
081: String contentResourceId) {
082: org.sakaiproject.citation.api.CitationService instance = getInstance();
083: if (instance == null) {
084: return false;
085: }
086: return instance.allowRemoveCitationList(contentResourceId);
087: }
088:
089: /* (non-Javadoc)
090: * @see org.sakaiproject.citation.api.CitationService#newCitation(java.lang.String)
091: */
092: public static org.sakaiproject.citation.api.Citation addCitation(
093: java.lang.String mediatype) {
094: org.sakaiproject.citation.api.CitationService instance = getInstance();
095: if (instance == null) {
096: return null;
097: }
098: return instance.addCitation(mediatype);
099: }
100:
101: public static org.sakaiproject.citation.api.CitationCollection addCollection() {
102: org.sakaiproject.citation.api.CitationService instance = getInstance();
103: if (instance == null) {
104: return null;
105: }
106: return instance.addCollection();
107: }
108:
109: public static org.sakaiproject.citation.api.CitationCollection getCollection(
110: java.lang.String collectionId)
111: throws org.sakaiproject.exception.IdUnusedException {
112: org.sakaiproject.citation.api.CitationService instance = getInstance();
113: if (instance == null) {
114: return null;
115: }
116: return instance.getCollection(collectionId);
117: }
118:
119: /* (non-Javadoc)
120: * @see org.sakaiproject.citation.api.CitationService#getDefaultSchema()
121: */
122: public static org.sakaiproject.citation.api.Schema getDefaultSchema() {
123: org.sakaiproject.citation.api.CitationService instance = getInstance();
124: if (instance == null) {
125: return null;
126: }
127: return instance.getDefaultSchema();
128: }
129:
130: /**
131: * Access the component instance: special cover only method.
132: *
133: * @return the component instance.
134: */
135: public static org.sakaiproject.citation.api.CitationService getInstance() {
136: if (ComponentManager.CACHE_COMPONENTS) {
137: if (m_instance == null)
138: m_instance = (org.sakaiproject.citation.api.CitationService) ComponentManager
139: .get(org.sakaiproject.citation.api.CitationService.class);
140: return m_instance;
141: } else {
142: return (org.sakaiproject.citation.api.CitationService) ComponentManager
143: .get(org.sakaiproject.citation.api.CitationService.class);
144: }
145: }
146:
147: public static org.sakaiproject.citation.api.Schema getSchema(
148: java.lang.String name) {
149: org.sakaiproject.citation.api.CitationService instance = getInstance();
150: if (instance == null) {
151: return null;
152: }
153: return instance.getSchema(name);
154: }
155:
156: /* (non-Javadoc)
157: * @see org.sakaiproject.citation.api.CitationService#getSchemas()
158: */
159: public static java.util.List getSchemas() {
160: org.sakaiproject.citation.api.CitationService instance = getInstance();
161: if (instance == null) {
162: return null;
163: }
164: return instance.getSchemas();
165: }
166:
167: public static org.sakaiproject.citation.api.Citation getTemporaryCitation() {
168: org.sakaiproject.citation.api.CitationService instance = getInstance();
169: if (instance == null) {
170: return null;
171: }
172: return instance.getTemporaryCitation();
173: }
174:
175: public static org.sakaiproject.citation.api.Citation getTemporaryCitation(
176: org.osid.repository.Asset asset) {
177: org.sakaiproject.citation.api.CitationService instance = getInstance();
178: if (instance == null) {
179: return null;
180: }
181: return instance.getTemporaryCitation(asset);
182: }
183:
184: /**
185: * @return
186: */
187: public static org.sakaiproject.citation.api.CitationCollection getTemporaryCollection() {
188: org.sakaiproject.citation.api.CitationService instance = getInstance();
189: if (instance == null) {
190: return null;
191: }
192: return instance.getTemporaryCollection();
193: }
194:
195: /**
196: * @return
197: */
198: public static java.util.Set getValidPropertyNames() {
199: org.sakaiproject.citation.api.CitationService instance = getInstance();
200: if (instance == null) {
201: return null;
202: }
203: return instance.getValidPropertyNames();
204: }
205:
206: /**
207: * @param mediatype
208: * @param name
209: * @return
210: */
211: public static boolean isMultivalued(String schemaId, String fieldId) {
212: org.sakaiproject.citation.api.CitationService instance = getInstance();
213: if (instance == null) {
214: return false;
215: }
216: return instance.isMultivalued(schemaId, fieldId);
217: }
218:
219: /* (non-Javadoc)
220: * @see org.sakaiproject.citation.api.CitationService#listSchemas()
221: */
222: public static java.util.List listSchemas() {
223: org.sakaiproject.citation.api.CitationService instance = getInstance();
224: if (instance == null) {
225: return null;
226: }
227: return instance.listSchemas();
228: }
229:
230: public static void save(
231: org.sakaiproject.citation.api.Citation citation) {
232: org.sakaiproject.citation.api.CitationService instance = getInstance();
233: if (instance == null) {
234: return;
235: }
236: instance.save(citation);
237: }
238:
239: public static void save(
240: org.sakaiproject.citation.api.CitationCollection collection) {
241: org.sakaiproject.citation.api.CitationService instance = getInstance();
242: if (instance == null) {
243: return;
244: }
245: instance.save(collection);
246: }
247:
248: public static CitationCollection copyAll(String citationCollectionId) {
249: org.sakaiproject.citation.api.CitationService instance = getInstance();
250: if (instance == null) {
251: return null;
252: }
253: return instance.copyAll(citationCollectionId);
254: }
255:
256: }
|