Merge r3349 and 3350 from release 1.3 branch

This commit is contained in:
j2blake 2011-07-20 22:08:02 +00:00
parent 9f566a7310
commit 66c1c3b4e4
4 changed files with 56 additions and 9 deletions

View file

@ -724,6 +724,20 @@
http://vivo-trunk.indiana.edu/individual/topLevelOrgURI
</td>
</tr>
<tr>
<td colspan="2">
An absolute file path, pointing to the root directory of the Harvester utility.
You must include the final slash.
</td>
</tr>
<tr class="odd_row">
<td>
harvester.location
</td>
<td>
/usr/local/vivo/harvester/
</td>
</tr>
</tbody>
</table>
<h3 id="deploy">V. Compile and deploy</h3>

View file

@ -1064,6 +1064,20 @@
http://vivo.mydomain.edu/individual/topLevelOrgURI
</td>
</tr>
<tr>
<td colspan="2">
An absolute file path, pointing to the root directory of the Harvester utility.
You must include the final slash.
</td>
</tr>
<tr class="odd_row blue">
<td>
harvester.location
</td>
<td>
/usr/local/vivo/harvester/
</td>
</tr>
</tbody>
</table>
<p>

View file

@ -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.

View file

@ -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/";
}