From ec9e23e1f5c4e08da300fdb3fefcc7b84dd4dd47 Mon Sep 17 00:00:00 2001 From: Robert Tansley Date: Wed, 4 Feb 2004 19:21:53 +0000 Subject: [PATCH] Changed build process to avoid use of symlinks, which have caused so many problems for people installing DSpace with Tomcat. Instead, two .war files are created which can simply be dropped in the appropriate place for Tomcat or other servlet container. A simple LoadDSpaceConfig servlet then loads in the dspace.cfg (from a config parameter in the web.xml contained within each .war) and initialises log4j with the appropriate properties file. A few other cleanups: - Removed redundant ${basedir} references - update and fresh_install targets now give useful hints as to what to do next - fresh_install target builds search + browse indices and config files for 3rd party tools (i.e. bin/index-all and bin/install-configs) git-svn-id: http://scm.dspace.org/svn/repo/trunk@726 9c30dcfa-912a-0410-8fc2-9e0234be79fd --- dspace/build.xml | 235 +++++++++++------- .../WEB-INF/web.xml => etc/dspace-web.xml} | 37 +-- dspace/{config/templates => etc}/oai-web.xml | 32 +-- .../app/webui/servlet/LoadDSpaceConfig.java | 74 ++++++ .../org/dspace/core/ConfigurationManager.java | 29 ++- 5 files changed, 281 insertions(+), 126 deletions(-) rename dspace/{jsp/WEB-INF/web.xml => etc/dspace-web.xml} (95%) rename dspace/{config/templates => etc}/oai-web.xml (80%) create mode 100644 dspace/src/org/dspace/app/webui/servlet/LoadDSpaceConfig.java diff --git a/dspace/build.xml b/dspace/build.xml index 37f72d90cf..0ef79736e0 100644 --- a/dspace/build.xml +++ b/dspace/build.xml @@ -41,27 +41,24 @@ - Date: $Date$ --> - + -===================== DSpace platform build file ===================== +====================== DSpace platform build file ====================== Common usage: Fresh install, including database setup and registry loading: - % ant ; ant fresh_install + % ant fresh_install - Upgrade existing installation, leaving code, data and configuration - % ant ; ant -Dconfig=/installdir/config/dspace.cfg update - - The following target require that the system is installed: - load_registries + Update existing installation, leaving data and configuration intact: + % ant -Dconfig=/installdir/config/dspace.cfg update -====================================================================== +======================================================================== @@ -76,7 +73,7 @@ Common usage: - + @@ -93,35 +90,92 @@ Common usage: - - + + - + - - + + + + + + + + + + + + + + + + + + + + + - + + depends="install_code" + description="Update installed code (without clobbering data/config)"> + +==================================================================== + Updated Web application (.war) files are in the 'build' directory. + + * Stop your Web servlet container (Tomcat, Jetty, Resin etc.) + + * If you're using Tomcat, you need delete the directories + corresponding to the old .war files. For example, if dspace.war + is installed in CATALINA_HOME/webapps/dspace.war, you should + delete the CATALINA_HOME/webapps/dspace directory. Otherwise, + Tomcat will continue to use the old code in that directory. + + * Copy the new dspace.war and dspace-oai.war from the 'build' + directory over the old ones + + * Start up your Web servlet container again. +==================================================================== + + + + + + + + + @@ -131,42 +185,6 @@ Common usage: - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -176,31 +194,26 @@ Common usage: - - - - + + basedir="build/classes" /> - + - - + + - + - @@ -214,14 +227,15 @@ Common usage: - file in etc/ and the DSpace configuration file using system - properties --> - + - + @@ -234,14 +248,15 @@ Common usage: - file in etc/ and the DSpace configuration file using system - properties --> - + - + @@ -252,12 +267,13 @@ Common usage: - + @@ -266,7 +282,7 @@ Common usage: classpathref="build.class.path" fork="yes" failonerror="yes"> - + @@ -279,8 +295,55 @@ Common usage: + + + + + + + + + + + + + + +==================================================================== + The DSpace code has been installed, and the database initialized. + + To complete installation, you should do the following: + + * Install the DSpace UI (dspace.war) and OAI-PMH (dspace-oai.war) + Web applications from the 'build' directory in the appropriate + place for your servlet container. e.g. '/opt/tomcat/webapps' + + * Make an initial administrator account (an e-person) in DSpace: + + ${dspace.dir}/bin/create-administrator + + * Start up your servlet container (Tomcat etc.) + + You should then be able to access your DSpace's 'home page': + + ${dspace.url} + + You should also be able to access the administrator UI: + + ${dspace.url}/dspace-admin +==================================================================== + @@ -290,7 +353,7 @@ Common usage: - + @@ -300,16 +363,16 @@ Common usage: - - + @@ -333,16 +396,16 @@ Common usage: - - + - + diff --git a/dspace/jsp/WEB-INF/web.xml b/dspace/etc/dspace-web.xml similarity index 95% rename from dspace/jsp/WEB-INF/web.xml rename to dspace/etc/dspace-web.xml index c90486a0a4..cea5050618 100644 --- a/dspace/jsp/WEB-INF/web.xml +++ b/dspace/etc/dspace-web.xml @@ -44,6 +44,8 @@ @@ -51,6 +53,17 @@ DSpace Web UI + + + + dspace-config + @@dspace.dir@@/config/dspace.cfg + + The location of the main DSpace configuration file + + + + @@ -91,15 +104,17 @@ /subscribe - - registered-only - /tools - - - + + + load-dspace-config + org.dspace.app.webui.servlet.LoadDSpaceConfig + 1 + + authorize org.dspace.app.webui.servlet.admin.AuthorizeAdminServlet @@ -265,11 +280,6 @@ org.dspace.app.webui.servlet.admin.WorkflowAbortServlet - - itemmap - org.dspace.app.webui.servlet.tools.ItemMapServlet - - @@ -418,11 +428,6 @@ /dspace-admin/workflow - - itemmap - /tools/itemmap - - diff --git a/dspace/config/templates/oai-web.xml b/dspace/etc/oai-web.xml similarity index 80% rename from dspace/config/templates/oai-web.xml rename to dspace/etc/oai-web.xml index 83fc6770a7..b41f9814b5 100644 --- a/dspace/config/templates/oai-web.xml +++ b/dspace/etc/oai-web.xml @@ -1,12 +1,6 @@ - - DSpace OAI-PMH 2.0 + + + dspace-config + @@dspace.dir@@/config/dspace.cfg + + The location of the main DSpace configuration file + + + properties @@dspace.dir@@/config/oaicat.properties @@ -74,6 +70,14 @@ + + + load-dspace-config + org.dspace.app.webui.servlet.LoadDSpaceConfig + 1 + + oai-handler ORG.oclc.oai.server.OAIHandler diff --git a/dspace/src/org/dspace/app/webui/servlet/LoadDSpaceConfig.java b/dspace/src/org/dspace/app/webui/servlet/LoadDSpaceConfig.java new file mode 100644 index 0000000000..d890f65cba --- /dev/null +++ b/dspace/src/org/dspace/app/webui/servlet/LoadDSpaceConfig.java @@ -0,0 +1,74 @@ +/* + * DSpaceServlet.java + * + * Version: $Revision$ + * + * Date: $Date$ + * + * Copyright (c) 2002, Hewlett-Packard Company and Massachusetts + * Institute of Technology. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * - Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * - Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * - Neither the name of the Hewlett-Packard Company nor the name of the + * Massachusetts Institute of Technology nor the names of their + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, + * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS + * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR + * TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE + * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH + * DAMAGE. + */ + +package org.dspace.app.webui.servlet; + +import java.io.File; +import javax.servlet.http.HttpServlet; + +import org.apache.log4j.PropertyConfigurator; + +import org.dspace.core.ConfigurationManager; + + +/** + * Simple servlet to load in DSpace and log4j configurations. Should always + * be started up before other servlets (use ) + * + * @author Robert Tansley + * @version $Revision$ + */ +public class LoadDSpaceConfig extends HttpServlet +{ + public void init() + { + // Get config parameter + String config = getServletContext().getInitParameter("dspace-config"); + + // Load in DSpace config + ConfigurationManager.loadConfig(config); + + // Load in log4j config + String log4jConf = ConfigurationManager.getProperty("dspace.dir") + + File.separator + "config" + File.separator + "log4j.properties"; + + PropertyConfigurator.configure(log4jConf); + } +} diff --git a/dspace/src/org/dspace/core/ConfigurationManager.java b/dspace/src/org/dspace/core/ConfigurationManager.java index 800606a181..f580f2a38c 100644 --- a/dspace/src/org/dspace/core/ConfigurationManager.java +++ b/dspace/src/org/dspace/core/ConfigurationManager.java @@ -100,7 +100,7 @@ public class ConfigurationManager { if (properties == null) { - loadProperties(); + loadConfig(null); } return properties.getProperty(property); @@ -121,7 +121,7 @@ public class ConfigurationManager { if (properties == null) { - loadProperties(); + loadConfig(null); } String stringValue = properties.getProperty(property); @@ -160,7 +160,7 @@ public class ConfigurationManager { if (properties == null) { - loadProperties(); + loadConfig(null); } String stringValue = properties.getProperty(property); @@ -250,7 +250,7 @@ public class ConfigurationManager { if (properties == null) { - loadProperties(); + loadConfig(null); } return license; @@ -258,9 +258,14 @@ public class ConfigurationManager /** - * Load the properties if they aren't already loaded + * Load the DSpace configuration properties. Only does anything if properties + * are not already loaded. Properties are loaded in from the specified file, + * or default locations. + * + * @param configFile The dspace.cfg configuration file to use, + * or null to try default locations */ - private static void loadProperties() + public static void loadConfig(String configFile) { InputStream is; @@ -269,12 +274,16 @@ public class ConfigurationManager return; } + String configProperty = System.getProperty("dspace.configuration"); + try { - // Has the default configuration location been overridden? - String configProperty = System.getProperty("dspace.configuration"); - - if (configProperty != null) + if (configFile != null) + { + is = new FileInputStream(configFile); + } + // Has the default configuration location been overridden? + else if (configProperty != null) { // Load the overriding configuration is = new FileInputStream(configProperty);