From 3dba86e80f9867c49af34bd6255de24a992bc779 Mon Sep 17 00:00:00 2001 From: Mark Diggory Date: Mon, 18 Jun 2007 17:26:04 +0000 Subject: [PATCH] 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 --- .../org/dspace/core/ConfigurationManager.java | 170 +----------------- dspace/bin/install-configs | 54 ------ dspace/config/dspace.cfg | 13 -- dspace/config/oaicat.properties | 8 +- 4 files changed, 4 insertions(+), 241 deletions(-) delete mode 100755 dspace/bin/install-configs diff --git a/dspace-api/src/main/java/org/dspace/core/ConfigurationManager.java b/dspace-api/src/main/java/org/dspace/core/ConfigurationManager.java index 47e3b674b3..342137fe11 100644 --- a/dspace-api/src/main/java/org/dspace/core/ConfigurationManager.java +++ b/dspace-api/src/main/java/org/dspace/core/ConfigurationManager.java @@ -642,152 +642,10 @@ public class ConfigurationManager return (result == null) ? null : result.toString(); } - /** - * Fill out of the configuration file templates in - * dspace.dir/config/templates with appropriate values from - * dspace.cfg, and copy to their appropriate destination. - * The destinations are defined as properties in dspace.cfg - * called config.template.XXX where XXX 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 - * @@property.name@@ are filled out with appropriate properties from - * the configuration. The filled-out configuration file is - * written to the file named by the property - * config.template.XXX where - * XXX 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 dspace.dir/config/templates - * and the property starting with config.template.. - * - * @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: *