From f58fdcdba4558df50bee06a5e5596e98dc2a5413 Mon Sep 17 00:00:00 2001 From: gojomo Date: Sat, 5 Feb 2011 03:26:02 +0000 Subject: [PATCH] * Heritrix use heritrix.home, if available, to find default logging.properties (to let those who launch Heritrix from elsewhere save themselves from HttpClient's copious logging) --- .../java/org/archive/crawler/Heritrix.java | 24 +++++++++---------- 1 file changed, 11 insertions(+), 13 deletions(-) diff --git a/engine/src/main/java/org/archive/crawler/Heritrix.java b/engine/src/main/java/org/archive/crawler/Heritrix.java index a9f6d4df..53b7c779 100644 --- a/engine/src/main/java/org/archive/crawler/Heritrix.java +++ b/engine/src/main/java/org/archive/crawler/Heritrix.java @@ -138,7 +138,8 @@ public class Heritrix { "The full path to the logging properties file " + "(eg, conf/logging.properties). If present, this file " + "will be used to configure Java logging. Defaults to " + - "./conf/logging.properties"); + "${heritrix.home}/conf/logging.properties or if no " + + "heritrix.home property set, ./conf/logging.properties"); options.addOption("b", "web-bind-hosts", true, "A comma-separated list of addresses/hostnames for the " + "web interface to bind to."); @@ -152,7 +153,7 @@ public class Heritrix { private static File getDefaultPropertiesFile() { - File confDir = new File(CONF); + File confDir = new File(getHeritrixHome(),CONF); File props = new File(confDir, PROPERTIES); return props; } @@ -474,20 +475,17 @@ public class Heritrix { * @return Heritrix home directory. * @throws IOException */ - protected static File getHeritrixHome() - throws IOException { - File heritrixHome = null; + protected static File getHeritrixHome() { String home = System.getProperty("heritrix.home"); if (home != null && home.length() > 0) { - heritrixHome = new File(home); - if (!heritrixHome.exists()) { - throw new IOException("HERITRIX_HOME <" + home + - "> does not exist."); - } - } else { - heritrixHome = new File(new File("").getAbsolutePath()); + File candidate = new File(home); + if (candidate.exists()) { + return candidate; + } + logger.warning("HERITRIX_HOME <" + home +"> does not exist; " + + "using current working directory instead."); } - return heritrixHome; + return new File(System.getProperty("user.dir")); }