mirror of
https://github.com/DSpace/DSpace.git
synced 2025-10-14 21:43:11 +00:00
Configuration filtering is now completed in Maven "Assembly" packaging.
git-svn-id: http://scm.dspace.org/svn/repo/trunk@2019 9c30dcfa-912a-0410-8fc2-9e0234be79fd
This commit is contained in:
@@ -642,152 +642,10 @@ public class ConfigurationManager
|
||||
return (result == null) ? null : result.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* Fill out of the configuration file templates in
|
||||
* <code>dspace.dir/config/templates</code> with appropriate values from
|
||||
* <code>dspace.cfg</code>, and copy to their appropriate destination.
|
||||
* The destinations are defined as properties in <code>dspace.cfg</code>
|
||||
* called <code>config.template.XXX</code> where <code>XXX</code> is the
|
||||
* filename of the template. If this property doesn't exist, the
|
||||
* configuration file template is skipped.
|
||||
*
|
||||
* @throws IOException
|
||||
* if there was some problem reading the templates or writing
|
||||
* the filled-out configuration files
|
||||
*/
|
||||
public static void installConfigurations() throws IOException
|
||||
{
|
||||
// Get the templates
|
||||
File templateDir = new File(getProperty("dspace.dir") + File.separator
|
||||
+ "config" + File.separator + "templates");
|
||||
|
||||
File[] templateFiles = templateDir.listFiles();
|
||||
|
||||
for (int i = 0; i < templateFiles.length; i++)
|
||||
{
|
||||
installConfigurationFile(templateFiles[i].getName());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Install the given configuration file template in its required location.
|
||||
* Configuration values in the template, specified as
|
||||
* <code>@@property.name@@</code> are filled out with appropriate properties from
|
||||
* the configuration. The filled-out configuration file is
|
||||
* written to the file named by the property
|
||||
* <code>config.template.XXX</code> where
|
||||
* <code>XXX</code> is the name of the template as
|
||||
* passed in to this method.
|
||||
*
|
||||
* @param template
|
||||
* the name of the configuration template. This must correspond
|
||||
* to the filename in <code>dspace.dir/config/templates</code>
|
||||
* and the property starting with <code>config.template.</code>.
|
||||
*
|
||||
* @throws IOException
|
||||
* if there was some problem reading the template or writing the
|
||||
* filled-out configuration file
|
||||
*/
|
||||
private static void installConfigurationFile(String template)
|
||||
throws IOException
|
||||
{
|
||||
// Get the destination: specified in property config.template.XXX
|
||||
String destination = getProperty("config.template." + template);
|
||||
|
||||
if (destination == null)
|
||||
{
|
||||
// If no destination is specified
|
||||
info("Not processing config file template " + template
|
||||
+ " because no destination specified (no property "
|
||||
+ "config.template." + template + ")");
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
info("Installing configuration file template " + template + " to "
|
||||
+ destination);
|
||||
|
||||
// Open the template
|
||||
BufferedReader in = new BufferedReader(new FileReader(
|
||||
getProperty("dspace.dir") + File.separator + "config"
|
||||
+ File.separator + "templates" + File.separator
|
||||
+ template));
|
||||
|
||||
// Open the destination for writing
|
||||
PrintWriter out = new PrintWriter(new FileWriter(destination));
|
||||
|
||||
// We'll keep track of line numbers for error messages etc.
|
||||
int lineNumber = 0;
|
||||
String line;
|
||||
|
||||
// Copy the template, filling out config values
|
||||
while ((line = in.readLine()) != null)
|
||||
{
|
||||
lineNumber++;
|
||||
|
||||
// Find configuration values
|
||||
boolean moreValues = true;
|
||||
|
||||
while (moreValues)
|
||||
{
|
||||
// Look for "@@"
|
||||
int first = line.indexOf("@@");
|
||||
|
||||
if (first > -1)
|
||||
{
|
||||
// Look for the "@@" on the other side
|
||||
int second = line.indexOf("@@", first + 2);
|
||||
|
||||
if (second > -1)
|
||||
{
|
||||
// We have a property
|
||||
String propName = line.substring(first + 2, second);
|
||||
|
||||
String propValue = getProperty(propName);
|
||||
|
||||
if (propValue == null)
|
||||
{
|
||||
warn(template + " line " + lineNumber
|
||||
+ ": Property " + propName
|
||||
+ " not defined in DSpace configuration - "
|
||||
+ "using empty string");
|
||||
|
||||
propValue = "";
|
||||
}
|
||||
|
||||
// Fill in the value
|
||||
line = line.substring(0, first) + propValue
|
||||
+ line.substring(second + 2);
|
||||
}
|
||||
else
|
||||
{
|
||||
// There's a "@@" with no second one... just leave as-is
|
||||
warn(template + " line " + lineNumber
|
||||
+ ": Single @@ - leaving as-is");
|
||||
moreValues = false;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// No more @@'s
|
||||
moreValues = false;
|
||||
}
|
||||
}
|
||||
|
||||
// Write the line
|
||||
out.println(line);
|
||||
}
|
||||
|
||||
in.close();
|
||||
out.close();
|
||||
}
|
||||
|
||||
/**
|
||||
* Command-line interface for running configuration tasks. Possible
|
||||
* arguments:
|
||||
* <ul>
|
||||
* <li><code>-installTemplates</code> processes and installs the
|
||||
* configuration file templates for other tools</li>
|
||||
* <li><code>-property name</code> prints the value of the property
|
||||
* <code>name</code> from <code>dspace.cfg</code> to the standard
|
||||
* output. If the property does not exist, nothing is written.</li>
|
||||
@@ -798,20 +656,7 @@ public class ConfigurationManager
|
||||
*/
|
||||
public static void main(String[] argv)
|
||||
{
|
||||
if ((argv.length == 1) && argv[0].equals("-installTemplates"))
|
||||
{
|
||||
try
|
||||
{
|
||||
info("Installing configuration files for other tools");
|
||||
installConfigurations();
|
||||
System.exit(0);
|
||||
}
|
||||
catch (IOException ie)
|
||||
{
|
||||
warn("Error installing configuration files", ie);
|
||||
}
|
||||
}
|
||||
else if ((argv.length == 2) && argv[0].equals("-property"))
|
||||
if ((argv.length == 2) && argv[0].equals("-property"))
|
||||
{
|
||||
String val = getProperty(argv[1]);
|
||||
|
||||
@@ -847,19 +692,6 @@ public class ConfigurationManager
|
||||
}
|
||||
}
|
||||
|
||||
private static void warn(String string, Exception e)
|
||||
{
|
||||
if (log == null)
|
||||
{
|
||||
System.out.println("WARN: " + string);
|
||||
e.printStackTrace();
|
||||
}
|
||||
else
|
||||
{
|
||||
log.warn(string, e);
|
||||
}
|
||||
}
|
||||
|
||||
private static void warn(String string)
|
||||
{
|
||||
if (log == null)
|
||||
|
@@ -1,54 +0,0 @@
|
||||
#!/bin/sh
|
||||
|
||||
###########################################################################
|
||||
#
|
||||
# install-configs
|
||||
#
|
||||
# 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.
|
||||
#
|
||||
###########################################################################
|
||||
|
||||
# Shell script for processing the configuration file templates for external
|
||||
# tools in DSPACE/config/templates, and installing the filled-out files to
|
||||
# their appropriate locations (defined in dspace.cfg.)
|
||||
|
||||
# Get the DSPACE/bin directory
|
||||
BINDIR=`dirname $0`
|
||||
|
||||
echo "Processing and installing configuration files for external tools"
|
||||
|
||||
$BINDIR/dsrun org.dspace.core.ConfigurationManager -installTemplates
|
@@ -20,19 +20,6 @@ dspace.hostname = dspace.myu.edu
|
||||
# Name of the site
|
||||
dspace.name = DSpace at My University
|
||||
|
||||
|
||||
##### Destinations for configuration files for other tools #####
|
||||
|
||||
# Comment out any lines corresponding to files you don't need, so they
|
||||
# don't get copied
|
||||
|
||||
# Example Apache HTTPD configuration
|
||||
# config.template.apache13.conf = ${dspace.dir}/config/httpd.conf
|
||||
config.template.log4j.properties = ${dspace.dir}/config/log4j.properties
|
||||
config.template.log4j-handle-plugin.properties = ${dspace.dir}/config/log4j-handle-plugin.properties
|
||||
config.template.oaicat.properties = ${dspace.dir}/config/oaicat.properties
|
||||
|
||||
|
||||
##### Database settings #####
|
||||
|
||||
# Database name ("oracle", or "postgres")
|
||||
|
@@ -6,14 +6,12 @@
|
||||
|
||||
# OAICat Configuration file - see OAICat documentation for details
|
||||
|
||||
# Text surrounded by two '@' symbols is replaced with the corresponding
|
||||
# Text surrounded by two '${' and '}' symbols is replaced with the corresponding
|
||||
# property from dspace.cfg. For example:
|
||||
#
|
||||
# @@dspace.url@@
|
||||
# ${dspace.url}
|
||||
#
|
||||
# would be replaced with the dspace.url property in dspace.cfg.
|
||||
# When /dspace/bin/install-configs is run, this file will be installed in the
|
||||
# location specified by the property: config.template.oaicat.properties
|
||||
# would be replaced with the dspace.url property in dspace.cfg on Maven compilation
|
||||
|
||||
AbstractCatalog.oaiCatalogClassName=org.dspace.app.oai.DSpaceOAICatalog
|
||||
AbstractCatalog.recordFactoryClassName=org.dspace.app.oai.DSpaceRecordFactory
|
||||
|
Reference in New Issue
Block a user