Skip to content
Snippets Groups Projects
Commit f01f2d35 authored by conors_nli's avatar conors_nli Committed by Demian Katz
Browse files

Improve indexer's VUFIND_HOME handling (#1220)

parent 94ab1005
No related merge requests found
......@@ -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
......
......@@ -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
}
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment