001: /**********************************************************************************
002: * $URL: $
003: * $Id: $
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 java.util.List;
023:
024: import org.sakaiproject.citation.util.api.OsidConfigurationException;
025: import org.sakaiproject.component.cover.ComponentManager;
026:
027: /*
028: * Static covers for ConfigurationService API methods; adheres to
029: * the ConfigurationService API interface definition
030: */
031: public class ConfigurationService {
032: private static org.sakaiproject.citation.api.ConfigurationService m_instance;
033:
034: /**
035: * @return An instance of the ConfigurationService
036: */
037: public static org.sakaiproject.citation.api.ConfigurationService getInstance() { /*
038: * Caching?
039: */
040: if (ComponentManager.CACHE_COMPONENTS) {
041: if (m_instance == null) {
042: m_instance = (org.sakaiproject.citation.api.ConfigurationService) ComponentManager
043: .get(org.sakaiproject.citation.api.ConfigurationService.class);
044: }
045: return m_instance;
046: }
047: /*
048: * No cache
049: */
050: return (org.sakaiproject.citation.api.ConfigurationService) ComponentManager
051: .get(org.sakaiproject.citation.api.ConfigurationService.class);
052: }
053:
054: /**
055: * Fetch the appropriate XML configuration document for this user
056: */
057: public static String getConfigurationXml()
058: throws OsidConfigurationException {
059: org.sakaiproject.citation.api.ConfigurationService instance = getInstance();
060: if (instance == null) {
061: return null;
062: }
063: return instance.getConfigurationXml();
064: }
065:
066: /**
067: * Is the configuration XML file provided and readable
068: * @return true If the XML file is provided and readable, false otherwise
069: */
070: public static boolean isConfigurationXmlAvailable() {
071: org.sakaiproject.citation.api.ConfigurationService instance = getInstance();
072: if (instance == null) {
073: return false;
074: }
075: return instance.isConfigurationXmlAvailable();
076: }
077:
078: /**
079: * Fetch the appropriate XML database hierarchy document for this user
080: */
081: public static String getDatabaseHierarchyXml()
082: throws OsidConfigurationException {
083: org.sakaiproject.citation.api.ConfigurationService instance = getInstance();
084: if (instance == null) {
085: return null;
086: }
087: return instance.getDatabaseHierarchyXml();
088: }
089:
090: /**
091: * Is the database hierarchy XML file provided and readable
092: * @return true If the XML file is provided and readable, false otherwise
093: */
094: public static boolean isDatabaseHierarchyXmlAvailable() {
095: org.sakaiproject.citation.api.ConfigurationService instance = getInstance();
096: if (instance == null) {
097: return false;
098: }
099: return instance.isDatabaseHierarchyXmlAvailable();
100: }
101:
102: /**
103: * Fetch this user's group affiliations
104: */
105: public static List<String> getGroupIds()
106: throws OsidConfigurationException {
107: org.sakaiproject.citation.api.ConfigurationService instance = getInstance();
108: if (instance == null) {
109: return null;
110: }
111: return instance.getGroupIds();
112: }
113:
114: /**
115: * Fetch the site specific Repository OSID package name
116: */
117: public static String getSiteConfigOsidPackageName() {
118: org.sakaiproject.citation.api.ConfigurationService instance = getInstance();
119: if (instance == null) {
120: return null;
121: }
122: return instance.getSiteConfigOsidPackageName();
123: }
124:
125: /**
126: * Fetch the meta-search username
127: */
128: public static String getSiteConfigMetasearchUsername() {
129: org.sakaiproject.citation.api.ConfigurationService instance = getInstance();
130: if (instance == null) {
131: return null;
132: }
133: return instance.getSiteConfigMetasearchUsername();
134: }
135:
136: /**
137: * Fetch the meta-search password
138: */
139: public static String getSiteConfigMetasearchPassword() {
140: org.sakaiproject.citation.api.ConfigurationService instance = getInstance();
141: if (instance == null) {
142: return null;
143: }
144: return instance.getSiteConfigMetasearchPassword();
145: }
146:
147: /**
148: * Fetch the meta-search base-URL
149: */
150: public static String getSiteConfigMetasearchBaseUrl() {
151: org.sakaiproject.citation.api.ConfigurationService instance = getInstance();
152: if (instance == null) {
153: return null;
154: }
155: return instance.getSiteConfigMetasearchBaseUrl();
156: }
157:
158: /**
159: * Fetch the OpenURL label
160: */
161: public static String getSiteConfigOpenUrlLabel() {
162: org.sakaiproject.citation.api.ConfigurationService instance = getInstance();
163: if (instance == null) {
164: return null;
165: }
166: return instance.getSiteConfigOpenUrlLabel();
167: }
168:
169: /**
170: * Fetch the OpenURL resolver address
171: */
172: public static String getSiteConfigOpenUrlResolverAddress() {
173: org.sakaiproject.citation.api.ConfigurationService instance = getInstance();
174: if (instance == null) {
175: return null;
176: }
177: return instance.getSiteConfigOpenUrlResolverAddress();
178: }
179:
180: /**
181: * Fetch the Google base-URL
182: */
183: public static String getSiteConfigGoogleBaseUrl() {
184: org.sakaiproject.citation.api.ConfigurationService instance = getInstance();
185: if (instance == null) {
186: return null;
187: }
188: return instance.getSiteConfigGoogleBaseUrl();
189: }
190:
191: /**
192: * Fetch the Sakai server key
193: */
194: public static String getSiteConfigSakaiServerKey() {
195: org.sakaiproject.citation.api.ConfigurationService instance = getInstance();
196: if (instance == null) {
197: return null;
198: }
199: return instance.getSiteConfigSakaiServerKey();
200: }
201:
202: /**
203: * Enable/disable Google support
204: */
205: public static void setGoogleScholarEnabled(boolean state) {
206: org.sakaiproject.citation.api.ConfigurationService instance = getInstance();
207: if (instance == null) {
208: return;
209: }
210: instance.setGoogleScholarEnabled(state);
211: }
212:
213: /**
214: * Is Google search enabled?
215: */
216: public static boolean isGoogleScholarEnabled() {
217: org.sakaiproject.citation.api.ConfigurationService instance = getInstance();
218: if (instance == null) {
219: return false;
220: }
221: return instance.isGoogleScholarEnabled();
222: }
223:
224: /**
225: * Enable/disable library support
226: */
227: public static void setLibrarySearchEnabled(boolean state) {
228: org.sakaiproject.citation.api.ConfigurationService instance = getInstance();
229: if (instance == null) {
230: return;
231: }
232: instance.setLibrarySearchEnabled(state);
233: }
234:
235: /**
236: * Is library search enabled?
237: */
238: public static boolean isLibrarySearchEnabled() {
239: org.sakaiproject.citation.api.ConfigurationService instance = getInstance();
240: if (instance == null) {
241: return false;
242: }
243: return instance.isLibrarySearchEnabled();
244: }
245: }
|