use of io.arlas.server.core.model.response.Hit in project ARLAS-server by gisaia.
the class RawRESTService method getArlasHit.
@Timed
@Path("{collection}/{identifier}")
@GET
@Produces(UTF8JSON)
@Consumes(UTF8JSON)
@ApiOperation(value = "Get an Arlas document", produces = UTF8JSON, notes = "Returns a raw indexed document.", consumes = UTF8JSON, response = Hit.class)
@ApiResponses(value = { @ApiResponse(code = 200, message = "Successful operation", response = Hit.class), @ApiResponse(code = 500, message = "Arlas Server Error.", response = Error.class), @ApiResponse(code = 400, message = "Bad request.", response = Error.class), @ApiResponse(code = 404, message = "Not Found Error.", response = Error.class) })
public Response getArlasHit(// --------------------------------------------------------
@ApiParam(name = "collection", value = "collection", required = true) @PathParam(value = "collection") String collection, @ApiParam(name = "identifier", value = "identifier", required = true) @PathParam(value = "identifier") String identifier, // --------------------------------------------------------
@ApiParam(name = "pretty", value = "Pretty print", defaultValue = "false") @QueryParam(value = "pretty") Boolean pretty, @ApiParam(name = "flat", value = Documentation.FORM_FLAT, defaultValue = "false") @QueryParam(value = "flat") Boolean flat, @ApiParam(hidden = true) @HeaderParam(value = "Column-Filter") Optional<String> columnFilter, // --------------------------------------------------------
@ApiParam(value = "max-age-cache") @QueryParam(value = "max-age-cache") Integer maxagecache) throws ArlasException {
CollectionReference collectionReference = exploreService.getCollectionReferenceService().getCollectionReference(collection);
if (collectionReference == null) {
throw new NotFoundException("Collection " + collection + " not found.");
}
ColumnFilterUtil.assertCollectionsAllowed(columnFilter, Collections.singletonList(collectionReference));
String[] includes = ColumnFilterUtil.cleanColumnFilter(columnFilter).map(cf -> cf + "," + String.join(",", ColumnFilterUtil.getCollectionMandatoryPaths(collectionReference))).map(i -> i.split(",")).orElse(null);
Map<String, Object> source = exploreService.getRawDoc(collectionReference, identifier, includes);
if (source == null || source.isEmpty()) {
throw new NotFoundException("Document " + identifier + " not found.");
}
Hit hit = new Hit(collectionReference, source, Boolean.TRUE.equals(flat), false);
return cache(Response.ok(hit), maxagecache);
}
Aggregations