use of com.odysseusinc.arachne.commons.api.v1.dto.util.JsonResult.ErrorCode.NO_ERROR in project ArachneCentralAPI by OHDSI.
the class BaseAchillesController method getFile.
@ApiOperation("Get file contents")
@RequestMapping(value = { "datasource/{id}/files/{filename:.*}", "datasource/{id}/files/{filepath:.*}/{filename:.*}" }, method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
public JsonResult<JsonNode> getFile(@PathVariable("id") Long datasourceId, @RequestParam(name = "char", required = false) Long characterizationId, @PathVariable(value = "filepath", required = false) String path, @PathVariable("filename") String filename) throws NotExistException, IOException {
final String filepath = StringUtils.isBlank(path) ? filename : path + File.separator + filename;
DS dataSource = checkDataSource(datasourceId);
if (characterizationId == null) {
characterizationId = achillesService.getLatestCharacterizationId(dataSource);
}
AchillesFile file = achillesService.getAchillesFile(characterizationId, filepath).orElseThrow(() -> new NotExistException(String.format("File %s not found", filepath), AchillesFile.class));
JsonObject jsonObject = file.getData();
JsonNode node = objectMapper.readTree(new Gson().toJson(jsonObject));
return new JsonResult<>(NO_ERROR, node);
}
Aggregations