use of io.arlas.server.core.exceptions.NotFoundException in project ARLAS-server by gisaia.
the class StacCollectionsRESTService method getFeature.
@Timed
@Path("/collections/{collectionId}/items/{featureId}")
@GET
@Produces({ "application/geo+json", MediaType.APPLICATION_JSON })
@ApiOperation(value = "Fetch a single feature", notes = "Fetch the feature with id `featureId` in the feature collection with id `collectionId`.")
@ApiResponses(value = { @ApiResponse(code = 200, message = "Fetch the feature with id `featureId` in the feature collection with id `collectionId`.", response = Item.class, responseContainer = "Item"), @ApiResponse(code = 404, message = "The requested URI was not found.", response = Error.class), @ApiResponse(code = 500, message = "Arlas Server Error.", response = Error.class) })
public Response getFeature(@Context UriInfo uriInfo, @ApiParam(name = "collectionId", value = "Local identifier of a collection", required = true) @PathParam(value = "collectionId") String collectionId, @ApiParam(name = "featureId", value = "Local identifier of a feature", required = true) @PathParam(value = "featureId") String featureId, @ApiParam(hidden = true) @HeaderParam(value = "partition-filter") String partitionFilter, @ApiParam(hidden = true) @HeaderParam(value = "Column-Filter") Optional<String> columnFilter) throws ArlasException {
CollectionReference collectionReference = collectionReferenceService.getCollectionReference(collectionId);
StacFeatureCollection features = getStacFeatureCollection(collectionReference, partitionFilter, columnFilter, null, java.util.Collections.singletonList(getIdFilter(featureId, collectionReference)), uriInfo, "GET", true);
if (features.getFeatures().size() == 1) {
Item response = getItem(features.getFeatures().get(0), collectionReference, uriInfo);
return cache(Response.ok(response), 0);
} else {
throw new NotFoundException("Item not found");
}
}
use of io.arlas.server.core.exceptions.NotFoundException in project ARLAS-server by gisaia.
the class ElasticTool method getCollectionReferenceFromES.
public static CollectionReference getCollectionReferenceFromES(ElasticClient client, String index, ObjectReader reader, String ref) throws ArlasException {
CollectionReference collection = new CollectionReference(ref);
// Exclude old include_fields for support old collection
String[] includes = Strings.EMPTY_ARRAY;
String[] excludes = new String[] { "include_fields" };
String source = client.getHit(index, ref, includes, excludes);
if (source != null) {
try {
collection.params = reader.readValue(source);
} catch (IOException e) {
throw new InternalServerErrorException("Can not fetch collection " + ref, e);
}
} else {
throw new NotFoundException("Collection " + ref + " not found.");
}
return collection;
}
use of io.arlas.server.core.exceptions.NotFoundException 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