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
009: * "License"); 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, WITHOUT
016: * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
017: * License for the specific language governing permissions and limitations under
018: * the License.
019: *
020: ******************************************************************************/package org.sakaiproject.citation.impl;
021:
022: import java.util.List;
023: import java.util.ArrayList;
024:
025: import org.apache.commons.logging.Log;
026: import org.apache.commons.logging.LogFactory;
027:
028: import org.sakaiproject.citation.util.api.OsidConfigurationException;
029: import org.sakaiproject.citation.api.SiteOsidConfiguration;
030:
031: /**
032: * Sample Repository OSID configuration
033: */
034: public class SampleSiteOsidConfiguration implements
035: SiteOsidConfiguration {
036: private static Log _log = LogFactory
037: .getLog(SampleSiteOsidConfiguration.class);
038:
039: /*
040: * Citation Helper XML configuration files (rooted in <sakai.home>)
041: */
042: public static final String CATEGORIES_XML = sakaiHome("org.sakaiproject.citation/categories.xml");
043: public static final String CONFIGURATION_XML = sakaiHome("org.sakaiproject.citation/configuration.xml");
044:
045: /**
046: * Simple public constructor
047: */
048: public SampleSiteOsidConfiguration() {
049: }
050:
051: /*
052: * Interface methods
053: */
054:
055: /**
056: * Initialization - do whatever is appropriate here
057: */
058: public void init() throws OsidConfigurationException {
059: }
060:
061: /**
062: * Fetch the appropriate XML configuration document for this user. Typically,
063: * this will be an absolute path: /tomcat-home/sakai/config.xml
064: *<p>
065: * Return null to force the use of the siteConfigXml property from
066: * components.xml
067: *
068: * @return Configuration XML (eg /tomcat-home/sakai/config.xml)
069: */
070: public String getConfigurationXml()
071: throws OsidConfigurationException {
072: return CONFIGURATION_XML;
073: }
074:
075: /**
076: /**
077: * Fetch the appropriate XML database document for this user. Typically,
078: * this will be an absolute path: /tomcat-home/sakai/database.xml
079: *<p>
080: * Return null to force the use of the databaseXml property from
081: * components.xml
082: *
083: * @return Hierarchy XML (eg /tomcat-home/sakai/database.xml)
084: */
085: public String getDatabaseHierarchyXml()
086: throws OsidConfigurationException {
087: return CATEGORIES_XML;
088: }
089:
090: /**
091: * Fetch this user's group affiliations (ALL in this example)
092: * @return A list of group ID strings (empty if no IDs exist)
093: */
094: public List<String> getGroupIds() throws OsidConfigurationException {
095: ArrayList<String> groupList = new ArrayList();
096:
097: groupList.add("all");
098: groupList.add("free");
099:
100: return groupList;
101: }
102:
103: /*
104: * Helpers
105: */
106:
107: /**
108: * Using a relative path specification, create a full path based
109: * on the system level <code>sakai.home</code> property.
110: *
111: * @param relativePath Relative file specification (eg sakaibrary/config.xml)
112: */
113: private static String sakaiHome(String relativePath) {
114: String sakaiHome = System.getProperty("sakai.home", "sakai");
115: String separator = System.getProperty("file.separator");
116:
117: if ((!sakaiHome.endsWith(separator))
118: && (!sakaiHome.endsWith("/"))) {
119: sakaiHome += "/";
120: }
121: return sakaiHome + relativePath;
122: }
123: }
|