---FILE HARVEST---
web.xml: Add file harvest mapping fileharvest.xml: renamed from testfile.xml testfile.xml: deleted CsvFileHarvestJob.java: bug fixes FileHarvestController.java: renamed from TestFileController.java TestFileController.java: deleted
This commit is contained in:
parent
2b2d1a3769
commit
52a933c20d
4 changed files with 43 additions and 16 deletions
|
@ -1356,6 +1356,15 @@
|
||||||
<url-pattern>/qrcode/about</url-pattern>
|
<url-pattern>/qrcode/about</url-pattern>
|
||||||
</servlet-mapping>
|
</servlet-mapping>
|
||||||
|
|
||||||
|
<servlet>
|
||||||
|
<servlet-name>FileHarvestController</servlet-name>
|
||||||
|
<servlet-class>edu.cornell.mannlib.vitro.webapp.controller.harvester.FileHarvestController</servlet-class>
|
||||||
|
</servlet>
|
||||||
|
<servlet-mapping>
|
||||||
|
<servlet-name>FileHarvestController</servlet-name>
|
||||||
|
<url-pattern>/harvester/harvest</url-pattern>
|
||||||
|
</servlet-mapping>
|
||||||
|
|
||||||
|
|
||||||
<!-- ============================== servlet-mappings ======================== -->
|
<!-- ============================== servlet-mappings ======================== -->
|
||||||
<servlet-mapping>
|
<servlet-mapping>
|
||||||
|
|
|
@ -77,7 +77,7 @@
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
var newLi = document.createElement("li");
|
var newLi = document.createElement("li");
|
||||||
newLi.innerHTML = "<a href=\"No new grants were imported.\" target=\"_blank\">" + json.newlyAddedUris[i] + "</a>";
|
newLi.innerHTML = "${jobSpecificNoNewDataMessage}";
|
||||||
importedItems.appendChild(newLi);
|
importedItems.appendChild(newLi);
|
||||||
}
|
}
|
||||||
|
|
|
@ -163,8 +163,8 @@ class CsvFileHarvestJob implements FileHarvestJob {
|
||||||
* @return the path to the directory containing the template files
|
* @return the path to the directory containing the template files
|
||||||
*/
|
*/
|
||||||
private String getTemplateFileDirectory() {
|
private String getTemplateFileDirectory() {
|
||||||
String harvesterPath = TestFileController.getHarvesterPath();
|
String harvesterPath = FileHarvestController.getHarvesterPath();
|
||||||
String pathToTemplateFiles = harvesterPath + TestFileController.PATH_TO_TEMPLATE_FILES;
|
String pathToTemplateFiles = harvesterPath + FileHarvestController.PATH_TO_TEMPLATE_FILES;
|
||||||
return pathToTemplateFiles;
|
return pathToTemplateFiles;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -173,8 +173,8 @@ class CsvFileHarvestJob implements FileHarvestJob {
|
||||||
* @return the path to the directory containing the script files
|
* @return the path to the directory containing the script files
|
||||||
*/
|
*/
|
||||||
private String getScriptFileDirectory() {
|
private String getScriptFileDirectory() {
|
||||||
String harvesterPath = TestFileController.getHarvesterPath();
|
String harvesterPath = FileHarvestController.getHarvesterPath();
|
||||||
String pathToScriptFiles = harvesterPath + TestFileController.PATH_TO_HARVESTER_SCRIPTS;
|
String pathToScriptFiles = harvesterPath + FileHarvestController.PATH_TO_HARVESTER_SCRIPTS;
|
||||||
return pathToScriptFiles;
|
return pathToScriptFiles;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -286,13 +286,15 @@ class CsvFileHarvestJob implements FileHarvestJob {
|
||||||
private String performScriptTemplateReplacements(String scriptTemplateContents) {
|
private String performScriptTemplateReplacements(String scriptTemplateContents) {
|
||||||
String replacements = scriptTemplateContents;
|
String replacements = scriptTemplateContents;
|
||||||
|
|
||||||
String workingDirectory = TestFileController.getHarvesterPath();
|
String workingDirectory = FileHarvestController.getHarvesterPath();
|
||||||
String fileDirectory = TestFileController.getUploadPath(vreq);
|
String fileDirectory = FileHarvestController.getUploadPath(vreq);
|
||||||
String harvestedDataPath = getHarvestedDataPath();
|
String harvestedDataPath = getHarvestedDataPath();
|
||||||
|
String globalHarvestedDataRelativePath = FileHarvestController.PATH_TO_HARVESTED_DATA;
|
||||||
|
|
||||||
replacements = replacements.replace("${WORKING_DIRECTORY}", workingDirectory);
|
replacements = replacements.replace("${WORKING_DIRECTORY}", workingDirectory);
|
||||||
replacements = replacements.replace("${UPLOADS_FOLDER}", fileDirectory);
|
replacements = replacements.replace("${UPLOADS_FOLDER}", fileDirectory);
|
||||||
replacements = replacements.replace("${HARVESTED_DATA_PATH}", harvestedDataPath);
|
replacements = replacements.replace("${HARVESTED_DATA_PATH}", harvestedDataPath);
|
||||||
|
replacements = replacements.replace("${GLOBAL_HARVESTED_DATA_RELATIVE_PATH}", globalHarvestedDataRelativePath);
|
||||||
|
|
||||||
return replacements;
|
return replacements;
|
||||||
}
|
}
|
||||||
|
@ -322,7 +324,7 @@ class CsvFileHarvestJob implements FileHarvestJob {
|
||||||
}
|
}
|
||||||
|
|
||||||
private String getHarvestedDataPath() {
|
private String getHarvestedDataPath() {
|
||||||
return TestFileController.getFileHarvestRootPath() + "harvested-data/csv/" + this.sessionId + "/";
|
return FileHarvestController.getHarvesterPath() + FileHarvestController.PATH_TO_HARVESTED_DATA + "csv/" + this.sessionId + "/";
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -45,11 +45,11 @@ import edu.cornell.mannlib.vitro.webapp.controller.freemarker.responsevalues.Tem
|
||||||
import edu.cornell.mannlib.vitro.webapp.filestorage.backend.FileStorageSetup;
|
import edu.cornell.mannlib.vitro.webapp.filestorage.backend.FileStorageSetup;
|
||||||
import edu.cornell.mannlib.vitro.webapp.filestorage.uploadrequest.FileUploadServletRequest;
|
import edu.cornell.mannlib.vitro.webapp.filestorage.uploadrequest.FileUploadServletRequest;
|
||||||
|
|
||||||
public class TestFileController extends FreemarkerHttpServlet {
|
public class FileHarvestController extends FreemarkerHttpServlet {
|
||||||
|
|
||||||
private static final long serialVersionUID = 1L;
|
private static final long serialVersionUID = 1L;
|
||||||
private static final Log log = LogFactory.getLog(TestFileController.class);
|
private static final Log log = LogFactory.getLog(FileHarvestController.class);
|
||||||
private static final String TEMPLATE_DEFAULT = "testfile.ftl";
|
private static final String TEMPLATE_DEFAULT = "fileharvest.ftl";
|
||||||
|
|
||||||
private static final String PARAMETER_FIRST_UPLOAD = "firstUpload";
|
private static final String PARAMETER_FIRST_UPLOAD = "firstUpload";
|
||||||
private static final String PARAMETER_UPLOADED_FILE = "uploadedFile";
|
private static final String PARAMETER_UPLOADED_FILE = "uploadedFile";
|
||||||
|
@ -84,7 +84,8 @@ public class TestFileController extends FreemarkerHttpServlet {
|
||||||
/**
|
/**
|
||||||
* Absolute path on the server of the Harvester root directory. Include final slash.
|
* Absolute path on the server of the Harvester root directory. Include final slash.
|
||||||
*/
|
*/
|
||||||
private static final String PATH_TO_HARVESTER = "/home/mbarbieri/workspace/HarvesterDev/";
|
private static final String PATH_TO_HARVESTER = "/usr/share/vivo/harvester/";
|
||||||
|
// private static final String PATH_TO_HARVESTER = "/home/mbarbieri/workspace/HarvesterDev/";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Relative path from the Harvester root directory to the main area reserved for the VIVO File Harvest feature. Include
|
* Relative path from the Harvester root directory to the main area reserved for the VIVO File Harvest feature. Include
|
||||||
|
@ -102,6 +103,11 @@ public class TestFileController extends FreemarkerHttpServlet {
|
||||||
*/
|
*/
|
||||||
public static final String PATH_TO_HARVESTER_SCRIPTS = PATH_TO_FILE_HARVEST_ROOT + "scripts/";
|
public static final String PATH_TO_HARVESTER_SCRIPTS = PATH_TO_FILE_HARVEST_ROOT + "scripts/";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Relative path from the Harvester root directory to the directory containing the script templates. Include final slash.
|
||||||
|
*/
|
||||||
|
public static final String PATH_TO_HARVESTED_DATA = PATH_TO_FILE_HARVEST_ROOT + "harvested-data/";
|
||||||
|
|
||||||
|
|
||||||
static {
|
static {
|
||||||
fillKnownJobTypesList();
|
fillKnownJobTypesList();
|
||||||
|
@ -132,7 +138,7 @@ public class TestFileController extends FreemarkerHttpServlet {
|
||||||
|
|
||||||
String job = vreq.getParameter(PARAMETER_JOB);
|
String job = vreq.getParameter(PARAMETER_JOB);
|
||||||
String jobKnown = "false";
|
String jobKnown = "false";
|
||||||
if((job != null) && TestFileController.knownJobs.contains(job.toLowerCase()))
|
if((job != null) && FileHarvestController.knownJobs.contains(job.toLowerCase()))
|
||||||
jobKnown = "true";
|
jobKnown = "true";
|
||||||
|
|
||||||
FileHarvestJob jobObject = getJob(vreq, job);
|
FileHarvestJob jobObject = getJob(vreq, job);
|
||||||
|
@ -514,9 +520,19 @@ public class TestFileController extends FreemarkerHttpServlet {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the location in which the ready-to-run scripts, after having template replacements made on them, will be
|
||||||
|
* placed. Final slash included.
|
||||||
|
* @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/";
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
private File createScriptFile(String script) throws IOException {
|
private File createScriptFile(String script) throws IOException {
|
||||||
File scriptDirectory = new File(getHarvesterPath() + "scripts/temp");
|
File scriptDirectory = new File(getScriptFileLocation());
|
||||||
if(!scriptDirectory.exists()) {
|
if(!scriptDirectory.exists()) {
|
||||||
scriptDirectory.mkdirs();
|
scriptDirectory.mkdirs();
|
||||||
}
|
}
|
||||||
|
@ -790,7 +806,7 @@ public class TestFileController extends FreemarkerHttpServlet {
|
||||||
|
|
||||||
File scriptFile = createScriptFile(this.script);
|
File scriptFile = createScriptFile(this.script);
|
||||||
|
|
||||||
String command = "/bin/bash " + getHarvesterPath() + "scripts/temp/" + scriptFile.getName();
|
String command = "/bin/bash " + getScriptFileLocation() + scriptFile.getName();
|
||||||
|
|
||||||
log.info("Running command: " + command);
|
log.info("Running command: " + command);
|
||||||
Process pr = Runtime.getRuntime().exec(command);
|
Process pr = Runtime.getRuntime().exec(command);
|
Loading…
Add table
Reference in a new issue