use of edu.harvard.iq.dataverse.externaltools.ExternalTool in project dataverse by IQSS.
the class ExternalTools method addExternalTool.
@POST
public Response addExternalTool(String manifest) {
try {
ExternalTool externalTool = ExternalToolServiceBean.parseAddExternalToolManifest(manifest);
ExternalTool saved = externalToolService.save(externalTool);
Long toolId = saved.getId();
actionLogSvc.log(new ActionLogRecord(ActionLogRecord.ActionType.ExternalTool, "addExternalTool").setInfo("External tool added with id " + toolId + "."));
return ok(saved.toJson());
} catch (Exception ex) {
return error(BAD_REQUEST, ex.getMessage());
}
}
use of edu.harvard.iq.dataverse.externaltools.ExternalTool in project dataverse by IQSS.
the class ExternalTools method getExternalToolsByFile.
@GET
@Path("file/{id}")
public Response getExternalToolsByFile(@PathParam("id") Long fileIdFromUser) {
DataFile dataFile = fileSvc.find(fileIdFromUser);
if (dataFile == null) {
return error(BAD_REQUEST, "Could not find datafile with id " + fileIdFromUser);
}
JsonArrayBuilder tools = Json.createArrayBuilder();
List<ExternalTool> allExternalTools = externalToolService.findAll();
List<ExternalTool> toolsByFile = ExternalToolServiceBean.findExternalToolsByFile(allExternalTools, dataFile);
for (ExternalTool tool : toolsByFile) {
tools.add(tool.toJson());
}
return ok(tools);
}
Aggregations