From 66c1c3b4e4bffbeb626a75ee59950ff7e3586ae4 Mon Sep 17 00:00:00 2001 From: j2blake Date: Wed, 20 Jul 2011 22:08:02 +0000 Subject: [PATCH] Merge r3349 and 3350 from release 1.3 branch --- doc/install.html | 14 +++++++++ doc/upgrade-1.3.html | 14 +++++++++ example.deploy.properties | 6 ++++ .../harvester/FileHarvestController.java | 31 +++++++++++++------ 4 files changed, 56 insertions(+), 9 deletions(-) diff --git a/doc/install.html b/doc/install.html index 61926232..37b10c23 100644 --- a/doc/install.html +++ b/doc/install.html @@ -724,6 +724,20 @@ http://vivo-trunk.indiana.edu/individual/topLevelOrgURI + + + An absolute file path, pointing to the root directory of the Harvester utility. + You must include the final slash. + + + + + harvester.location + + + /usr/local/vivo/harvester/ + +

V. Compile and deploy

diff --git a/doc/upgrade-1.3.html b/doc/upgrade-1.3.html index 8cf00971..a0ce84e3 100644 --- a/doc/upgrade-1.3.html +++ b/doc/upgrade-1.3.html @@ -1064,6 +1064,20 @@ http://vivo.mydomain.edu/individual/topLevelOrgURI + + + An absolute file path, pointing to the root directory of the Harvester utility. + You must include the final slash. + + + + + harvester.location + + + /usr/local/vivo/harvester/ + +

diff --git a/example.deploy.properties b/example.deploy.properties index 9e273717..f8b39486 100644 --- a/example.deploy.properties +++ b/example.deploy.properties @@ -154,6 +154,12 @@ visualization.temporal = enabled # # visualization.topLevelOrg = http://vivo.mydomain.edu/individual/topLevelOrgURI +# +# Absolute path on the server of the Harvester root directory. +# You must include the final slash. +# +harvester.location = /usr/local/vivo/harvester/ + # # Default type(s) for Google Refine Reconciliation Service # The format for this property is id, name; id1, name1; id2, name2 etc. diff --git a/src/edu/cornell/mannlib/vitro/webapp/controller/harvester/FileHarvestController.java b/src/edu/cornell/mannlib/vitro/webapp/controller/harvester/FileHarvestController.java index eb7a35f9..7e179b6c 100644 --- a/src/edu/cornell/mannlib/vitro/webapp/controller/harvester/FileHarvestController.java +++ b/src/edu/cornell/mannlib/vitro/webapp/controller/harvester/FileHarvestController.java @@ -20,6 +20,7 @@ import java.util.Set; import javax.servlet.ServletContext; import javax.servlet.ServletException; import javax.servlet.ServletOutputStream; +import javax.servlet.UnavailableException; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import javax.xml.parsers.DocumentBuilderFactory; @@ -81,11 +82,6 @@ public class FileHarvestController extends FreemarkerHttpServlet { */ private static final String PATH_TO_UPLOADS = "harvester/"; - /** - * Absolute path on the server of the Harvester root directory. Include final slash. - */ - private static final String PATH_TO_HARVESTER = "/usr/share/vivo/harvester/"; - /** * Relative path from the Harvester root directory to the main area reserved for the VIVO File Harvest feature. Include * final slash. @@ -130,8 +126,23 @@ public class FileHarvestController extends FreemarkerHttpServlet { } } + /** + * This is the absolute path on the server of the Harvester root directory, including the final slash. + * Unfortunately, this value is not known at the time the servlet is loaded, so we need to initialize + * this in the init() method. I hope nobody calls for this before the servlet is initialized. + */ + private static volatile String pathToHarvester; @Override + public void init() throws ServletException { + super.init(); + pathToHarvester = ConfigurationProperties.getBean(getServletContext()).getProperty("harvester.location"); + if (pathToHarvester == null) { + throw new UnavailableException("The deploy.properties file does not contain a value for 'harvester.location'"); + } + } + + @Override protected ResponseValues processRequest(VitroRequest vreq) { try { cleanUpOldSessions(); @@ -178,8 +189,10 @@ public class FileHarvestController extends FreemarkerHttpServlet { */ public static String getHarvesterPath() { - String harvesterPath = PATH_TO_HARVESTER; - return harvesterPath; + if (pathToHarvester == null) { + throw new IllegalStateException("FileHarvestController has not been initialized yet."); + } + return pathToHarvester; } /** @@ -188,7 +201,7 @@ public class FileHarvestController extends FreemarkerHttpServlet { */ public static String getFileHarvestRootPath() { - String fileHarvestRootPath = PATH_TO_HARVESTER + PATH_TO_FILE_HARVEST_ROOT; + String fileHarvestRootPath = getHarvesterPath() + PATH_TO_FILE_HARVEST_ROOT; return fileHarvestRootPath; } @@ -527,7 +540,7 @@ public class FileHarvestController extends FreemarkerHttpServlet { * @return the location in which the ready-to-run scripts will be placed */ private static String getScriptFileLocation() { - return PATH_TO_HARVESTER + PATH_TO_HARVESTER_SCRIPTS + "temp/"; + return getHarvesterPath() + PATH_TO_HARVESTER_SCRIPTS + "temp/"; }