diff --git a/import-marc.sh b/import-marc.sh index 9569b084c896203e1057176bb355421a879bfcc3..82e8d1b26cc388e91b1a1a5da4a394fb0b0ca34f 100755 --- a/import-marc.sh +++ b/import-marc.sh @@ -52,7 +52,6 @@ then INDEX_OPTIONS='-Xms512m -Xmx512m -DentityExpansionLimit=0' fi - ################################################## # Set SOLRCORE ################################################## @@ -61,15 +60,20 @@ then EXTRA_SOLRMARC_SETTINGS="$EXTRA_SOLRMARC_SETTINGS -Dsolr.core.name=$SOLRCORE" fi - ################################################## # Set VUFIND_HOME ################################################## if [ -z "$VUFIND_HOME" ] then - VUFIND_HOME="/usr/local/vufind" + # set VUFIND_HOME to the absolute path of the directory containing this script + # https://stackoverflow.com/questions/4774054/reliable-way-for-a-bash-script-to-get-the-full-path-to-itself + export VUFIND_HOME="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd)" fi +if [ -z "$VUFIND_LOCAL_DIR" ] +then + echo "WARNING: VUFIND_LOCAL_DIR environment variable is not set. Is this intentional?" +fi ##################################################### # Build java command diff --git a/import/index_java/src/org/vufind/index/ConfigManager.java b/import/index_java/src/org/vufind/index/ConfigManager.java index d9f25087780f1f1cb74304638973b56ba62e1a99..454aace2374ad201cfaac91e5022869626680d69 100644 --- a/import/index_java/src/org/vufind/index/ConfigManager.java +++ b/import/index_java/src/org/vufind/index/ConfigManager.java @@ -66,14 +66,15 @@ public class ConfigManager * Given the base name of a configuration file, locate the full path. * @param filename base name of a configuration file */ - private File findConfigFile(String filename) + private File findConfigFile(String filename) throws IllegalStateException { // Find VuFind's home directory in the environment; if it's not available, // try using a relative path on the assumption that we are currently in // VuFind's import subdirectory: String vufindHome = System.getenv("VUFIND_HOME"); if (vufindHome == null) { - vufindHome = ".."; + // this shouldn't happen since import-marc.sh and .bat always set VUFIND_HOME + throw new IllegalStateException("VUFIND_HOME must be set"); } // Check for VuFind 2.0's local directory environment variable: @@ -133,11 +134,21 @@ public class ConfigManager // Retrieve the file if it is not already cached. if (!configCache.containsKey(filename)) { Ini ini = new Ini(); + File configFile = null; try { - ini.load(new FileReader(findConfigFile(filename))); - configCache.putIfAbsent(filename, ini); + configFile = findConfigFile(filename); + } catch (IllegalStateException e) { + dieWithError("Illegal State: " + e.getMessage()); } catch (Throwable e) { - dieWithError("Unable to access " + filename); + dieWithError("Unable to locate " + filename); + } + try { + if (configFile != null) { + ini.load(new FileReader(configFile)); + configCache.putIfAbsent(filename, ini); + } + } catch (Throwable e) { + dieWithError("Unable to access " + configFile.getAbsolutePath()); } } return configCache.get(filename); @@ -231,4 +242,4 @@ public class ConfigManager logger.error(msg); throw new SolrMarcIndexerException(SolrMarcIndexerException.EXIT, msg); } -} \ No newline at end of file +}