@GET
@Path("start")
@Produces("text/plain")
public String doIngest(@QueryParam("taskId") String ingestTaskId) {
IngestionTask task = this.taskList.getIngestionTaskById(ingestTaskId);
if (task == null) {
String errorMsg = "Task with ID [" + ingestTaskId
+ "] is not being managed by this Ingestion Resource!";
LOG.log(Level.WARNING, errorMsg);
return this.encodeIngestResponseAsJSON(false, errorMsg);
}
Ingester ingest = this.configureIngester();
MetadataResource metService = new MetadataResource();
for (String file : task.getFileList()) {
Metadata fileMet = null;
try {
String vFilePath = this.getVirtualPath(CurationService.config
.getStagingAreaPath(), file);
LOG.log(Level.FINE,
"IngestionResource: getting staging metadata for virtual path: ["
+ vFilePath + "]");
fileMet = metService.getStagingMetadata(vFilePath, task.getExtConf()
.getIdentifier(), false);
} catch (Exception e) {
e.printStackTrace();
return this.encodeIngestResponseAsHTML(false, e.getMessage());
}
try {
ingest.ingest(safeGetUrl(CurationService.config.getFileMgrURL()),
new File(file), fileMet);
} catch (IngestException e) {
e.printStackTrace();
return this.encodeIngestResponseAsHTML(false, e.getMessage());
}
// set task status to success
task.setStatus(IngestionTask.FINISHED);
}
return this.encodeIngestResponseAsHTML(true, null);
}