Search in sources :

Example 26 with CollectionReference

use of io.arlas.server.core.model.CollectionReference in project ARLAS-server by gisaia.

the class CollectionReferenceService method describeAllCollections.

public List<CollectionReferenceDescription> describeAllCollections(List<CollectionReference> collectionReferenceList, Optional<String> columnFilter) throws ArlasException {
    // Can't use lambdas because of the need to throw the exception of describeCollection()
    List<CollectionReferenceDescription> res = new ArrayList<>();
    for (CollectionReference collection : collectionReferenceList) {
        if (!ColumnFilterUtil.cleanColumnFilter(columnFilter).isPresent() || ColumnFilterUtil.getCollectionRelatedColumnFilter(columnFilter, collection).isPresent()) {
            try {
                CollectionReferenceDescription describe = describeCollection(collection, columnFilter);
                res.add(describe);
            } catch (ArlasException e) {
            }
        }
    }
    return res;
}
Also used : ArlasException(io.arlas.server.core.exceptions.ArlasException) CollectionReferenceDescription(io.arlas.server.core.model.response.CollectionReferenceDescription) CollectionReference(io.arlas.server.core.model.CollectionReference)

Example 27 with CollectionReference

use of io.arlas.server.core.model.CollectionReference in project ARLAS-server by gisaia.

the class StacCollectionsRESTService method getCollections.

@Timed
@Path("/collections")
@GET
@Produces(MediaType.APPLICATION_JSON)
@ApiOperation(value = "The feature collections in the dataset", notes = "A body of Feature Collections that belong or are used together with additional links.\n" + "Request may not return the full set of metadata per Feature Collection.")
@ApiResponses(value = { @ApiResponse(code = 200, message = "The feature collections shared by this API.\n" + "The dataset is organized as one or more feature collections.\n" + "This resource provides information about and access to the collections.\n" + "The response contains the list of collections.\n" + "For each collection, a link to the items in the collection (path `/collections/{collectionId}/items`, " + "link relation `items`) as well as key information about the collection.\n" + "This information includes:\n" + "  * A local identifier for the collection that is unique for the dataset;\n" + "  * A list of coordinate reference systems (CRS) in which geometries may be returned by the server. " + "The first CRS is the default coordinate reference system (the default is always WGS 84 with axis order longitude/latitude);\n" + "  * An optional title and description for the collection;\n" + "  * An optional extent that can be used to provide an indication of the spatial and temporal " + "extent of the collection - typically derived from the data;\n" + "  * An optional indicator about the type of the items in the collection (the default value, " + "if the indicator is not provided, is 'feature').", response = CollectionList.class, responseContainer = "CollectionList"), @ApiResponse(code = 500, message = "Arlas Server Error.", response = Error.class) })
public Response getCollections(@Context UriInfo uriInfo, @ApiParam(hidden = true) @HeaderParam(value = "Column-Filter") Optional<String> columnFilter) throws ArlasException {
    // TODO what do we put in there?
    List<StacLink> links = new ArrayList<>();
    links.add(getSelfLink(uriInfo));
    List<Collection> collectionList = new ArrayList<>();
    for (CollectionReference c : collectionReferenceService.getAllCollectionReferences(columnFilter).stream().filter(c -> !c.collectionName.equals("metacollection")).collect(Collectors.toList())) {
        collectionList.add(getCollection(c, uriInfo));
    }
    return cache(Response.ok(new CollectionList().collections(collectionList).links(links)), 0);
}
Also used : ApiParam(io.swagger.annotations.ApiParam) ApiResponses(io.swagger.annotations.ApiResponses) ArrayList(java.util.ArrayList) ApiOperation(io.swagger.annotations.ApiOperation) MediaType(javax.ws.rs.core.MediaType) ArlasException(io.arlas.server.core.exceptions.ArlasException) ExploreService(io.arlas.server.core.services.ExploreService) IntParam(io.dropwizard.jersey.params.IntParam) Max(javax.validation.constraints.Max) Schema(io.swagger.v3.oas.annotations.media.Schema) CollectionReference(io.arlas.server.core.model.CollectionReference) Context(javax.ws.rs.core.Context) CollectionReferenceService(io.arlas.server.core.services.CollectionReferenceService) Documentation(io.arlas.server.core.app.Documentation) NotFoundException(io.arlas.server.core.exceptions.NotFoundException) Explode(io.swagger.v3.oas.annotations.enums.Explode) io.arlas.server.stac.model(io.arlas.server.stac.model) Collectors(java.util.stream.Collectors) Parameter(io.swagger.v3.oas.annotations.Parameter) ParameterStyle(io.swagger.v3.oas.annotations.enums.ParameterStyle) Timed(com.codahale.metrics.annotation.Timed) ArraySchema(io.swagger.v3.oas.annotations.media.ArraySchema) List(java.util.List) javax.ws.rs(javax.ws.rs) Response(javax.ws.rs.core.Response) ApiResponse(io.swagger.annotations.ApiResponse) STACConfiguration(io.arlas.server.core.app.STACConfiguration) Optional(java.util.Optional) UriInfo(javax.ws.rs.core.UriInfo) Error(io.arlas.server.core.model.response.Error) ArrayList(java.util.ArrayList) CollectionReference(io.arlas.server.core.model.CollectionReference) Timed(com.codahale.metrics.annotation.Timed) ApiOperation(io.swagger.annotations.ApiOperation) ApiResponses(io.swagger.annotations.ApiResponses)

Example 28 with CollectionReference

use of io.arlas.server.core.model.CollectionReference in project ARLAS-server by gisaia.

the class StacCollectionsRESTService method getFeatures.

@Timed
@Path("/collections/{collectionId}/items")
@GET
@Produces({ "application/geo+json", MediaType.APPLICATION_JSON })
@ApiOperation(value = "Fetch features", notes = "Fetch features of the feature collection with id `collectionId`.\n" + "Every feature in a dataset belongs to a collection. A dataset may consist of multiple feature collections.\n" + "A feature collection is often a collection of features of a similar type, based on a common schema.")
@ApiResponses(value = { @ApiResponse(code = 200, message = "The response is a document consisting of features in the collection.\n" + "The features included in the response are determined by the server based on the query parameters of the request.\n" + "To support access to larger collections without overloading the client, the API supports paged " + "access with links to the next page, if more features are selected than the page size.\n" + "The `bbox` and `datetime` parameter can be used to select only a subset of the features in the " + "collection (the features that are in the bounding box or time interval).\n" + "The `bbox` parameter matches all features in the collection that are not associated with a location, too.\n" + "The `datetime` parameter matches all features in the collection that are not associated with a time stamp or interval, too.\n" + "The `limit` parameter may be used to control the subset of the selected features that should be " + "returned in the response, the page size.\n" + "Each page may include information about the number of selected and returned features " + "(`numberMatched` and `numberReturned`) as well as links to support paging (link relation `next`).", response = StacFeatureCollection.class, responseContainer = "StacFeatureCollection"), @ApiResponse(code = 400, message = "A query parameter has an invalid value.", response = Error.class), @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 getFeatures(@Context UriInfo uriInfo, @ApiParam(name = "collectionId", value = "Local identifier of a collection", required = true) @PathParam(value = "collectionId") String collectionId, @Parameter(name = "limit", style = ParameterStyle.FORM, schema = @Schema(maximum = "10000", defaultValue = "10", minimum = "1", type = "integer")) @ApiParam(name = "limit", defaultValue = "10", allowableValues = "range[1,10000]", value = "The optional limit parameter limits the number of items that are presented in the response document.\n" + "Only items are counted that are on the first level of the collection in the response document.\n" + "Nested objects contained within the explicitly requested items shall not be counted.\n" + "Minimum &#x3D; 1. Maximum &#x3D; 10000. Default &#x3D; 10.") @DefaultValue("10") @QueryParam(value = "limit") IntParam limit, @Parameter(name = "bbox", style = ParameterStyle.FORM, explode = Explode.FALSE, array = @ArraySchema(schema = @Schema(type = "number"), maxItems = 6, minItems = 4)) @ApiParam(name = "bbox", value = "Only features that have a geometry that intersects the bounding box are selected. " + "The bounding box is provided as four or six numbers, depending on whether the coordinate reference system includes a vertical axis (height or depth):\n" + "  * Lower left corner, coordinate axis 1\n" + "  * Lower left corner, coordinate axis 2\n" + "  * Minimum value, coordinate axis 3 (optional)\n" + "  * Upper right corner, coordinate axis 1\n" + "  * Upper right corner, coordinate axis 2\n" + "  * Maximum value, coordinate axis 3 (optional)\n\n" + "The coordinate reference system of the values is WGS 84 longitude/latitude (http://www.opengis.net/def/crs/OGC/1.3/CRS84).\n" + "For WGS 84 longitude/latitude the values are in most cases the sequence of minimum longitude, minimum latitude, maximum longitude and maximum latitude.\n" + "However, in cases where the box spans the antimeridian the first value (west-most box edge) is larger than the third value (east-most box edge).\n" + "If the vertical axis is included, the third and the sixth number are the bottom and the top of the 3-dimensional bounding box.\n" + "If a feature has multiple spatial geometry properties, it is the decision of the server whether only a single spatial geometry property is used to determine the extent or all relevant geometries.") @QueryParam(value = "bbox") String bbox, @Parameter(name = "datetime", style = ParameterStyle.FORM) @ApiParam(name = "datetime", value = "Either a date-time or an interval, open or closed. Date and time expressions adhere to RFC 3339. Open intervals are expressed using double-dots.  Examples:\n" + "  * A date-time: \"2018-02-12T23:20:50Z\"\n" + "  * A closed interval: \"2018-02-12T00:00:00Z/2018-03-18T12:31:12Z\"\n" + "  * Open intervals: \"2018-02-12T00:00:00Z/..\" or \"../2018-03-18T12:31:12Z\"\n\n" + "Only features that have a temporal property that intersects the value of &#x60;datetime&#x60; are selected.\n" + "If a feature has multiple temporal properties, it is the decision of the server whether only a single temporal property is used to determine the extent or all relevant temporal properties.") @QueryParam(value = "datetime") String datetime, @ApiParam(name = "sortby", value = "**Optional Extension:** Sort  An array of property names, prefixed by either \"+\" for ascending " + "or \"-\" for descending. If no prefix is provided, \"+\" is assumed.") @QueryParam(value = "sortby") String sortBy, @ApiParam(name = "from", value = Documentation.PAGE_PARAM_FROM, defaultValue = "0", allowableValues = "range[0, infinity]", type = "integer") @DefaultValue("0") @QueryParam(value = "from") IntParam from, @ApiParam(name = "after", value = Documentation.PAGE_PARAM_AFTER) @QueryParam(value = "after") String after, @ApiParam(name = "before", value = Documentation.PAGE_PARAM_BEFORE) @QueryParam(value = "before") String before, @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);
    String dateFilter = getDateFilter(datetime, collectionReference);
    String geoFilter = getGeoFilter(getBboxAsList(bbox), collectionReference);
    List<String> f = new ArrayList<>();
    if (dateFilter != null) {
        f.add(dateFilter);
    }
    if (geoFilter != null) {
        f.add(geoFilter);
    }
    SearchBody searchBody = new SearchBody().limit(limit.get()).from(from.get()).sortBy(sortBy).after(after).before(before);
    return cache(Response.ok(getStacFeatureCollection(collectionReference, partitionFilter, columnFilter, searchBody, f, uriInfo, "GET", true)), 0);
}
Also used : ArrayList(java.util.ArrayList) CollectionReference(io.arlas.server.core.model.CollectionReference) Timed(com.codahale.metrics.annotation.Timed) ApiOperation(io.swagger.annotations.ApiOperation) ApiResponses(io.swagger.annotations.ApiResponses)

Example 29 with CollectionReference

use of io.arlas.server.core.model.CollectionReference in project ARLAS-server by gisaia.

the class CSWRESTService method doKVP.

@Timed
@Path("/csw")
@GET
@Produces({ MediaType.APPLICATION_XML, MediaType.TEXT_XML, ATOM.APPLICATION_ATOM_XML, MIME_TYPE__OPENSEARCH_XML })
@ApiOperation(value = "CSW", produces = MediaType.APPLICATION_XML + "," + MediaType.TEXT_XML + "," + ATOM.APPLICATION_ATOM_XML + "," + MIME_TYPE__OPENSEARCH_XML, notes = "CSW")
@ApiResponses(value = { @ApiResponse(code = 200, message = "Successful operation"), @ApiResponse(code = 500, message = "Arlas Server Error.", response = Error.class) })
public Response doKVP(@ApiParam(name = "version", value = "version", allowMultiple = false, required = true) @QueryParam(value = "version") String version, @ApiParam(name = "acceptversions", value = "acceptversions", allowMultiple = false, required = true) @QueryParam(value = "acceptversions") String acceptVersions, @ApiParam(name = "service", value = "service", allowMultiple = false, required = true) @QueryParam(value = "service") String service, @ApiParam(name = "request", value = "request", allowMultiple = false, required = true) @QueryParam(value = "request") String request, @ApiParam(name = "elementname", value = "elementname", allowMultiple = false, required = true) @QueryParam(value = "elementname") String elementName, @ApiParam(name = "elementsetname", value = "elementsetname", allowMultiple = false, required = true) @QueryParam(value = "elementsetname") String elementSetName, @ApiParam(name = "filter", value = "filter", allowMultiple = false, required = true) @QueryParam(value = "filter") String filter, @ApiParam(name = "constraint", value = "constraint", allowMultiple = false, required = true) @QueryParam(value = "constraint") String constraint, @ApiParam(name = "constraintLanguage", value = "constraintLanguage", allowMultiple = false, required = true) @QueryParam(value = "constraintLanguage") String constraintLanguage, @ApiParam(name = "startposition", value = "startposition", allowMultiple = false, required = false) @QueryParam(value = "startposition") Integer startPosition, @ApiParam(name = "maxrecords", value = "maxrecords", allowMultiple = false, required = false) @QueryParam(value = "maxrecords") Integer maxRecords, @ApiParam(name = "sections", value = "sections", allowMultiple = false, required = false) @QueryParam(value = "sections") String sections, @ApiParam(name = "acceptformats", value = "acceptformats", allowMultiple = false, required = false) @QueryParam(value = "acceptformats") String acceptFormats, @ApiParam(name = "q", value = "q", allowMultiple = false, required = false) @QueryParam(value = "q") String query, @ApiParam(name = "bbox", value = "bbox", allowMultiple = false, required = false) @QueryParam(value = "bbox") String bbox, @ApiParam(name = "outputformat", value = "outputformat", allowMultiple = false, required = false) @QueryParam(value = "outputformat") String outputFormat, @ApiParam(name = "outputschema", value = "outputschema", allowMultiple = false, required = false) @QueryParam(value = "outputschema") String outputSchema, @ApiParam(name = "typenames", value = "typenames", allowMultiple = false, required = false) @QueryParam(value = "typenames") String typeNames, @ApiParam(name = "recordids", value = "recordids", allowMultiple = false, required = false) @QueryParam(value = "recordids") String recordIds, @ApiParam(name = "id", value = "id", allowMultiple = false, required = false) @QueryParam(value = "id") String id, @ApiParam(name = "language", value = "language", allowMultiple = false, required = false) @QueryParam(value = "language") String language, @ApiParam(hidden = true) @HeaderParam(value = "Column-Filter") Optional<String> columnFilter, // --------------------------------------------------------
@ApiParam(name = "pretty", value = Documentation.FORM_PRETTY, allowMultiple = false, defaultValue = "false", required = false) @QueryParam(value = "pretty") Boolean pretty, @Context HttpHeaders headers) throws ArlasException, DatatypeConfigurationException, IOException {
    String acceptFormatMediaType = MediaType.APPLICATION_XML;
    String outputFormatMediaType = MediaType.APPLICATION_XML;
    for (MediaType mediaType : headers.getAcceptableMediaTypes()) {
        if (mediaType.getSubtype().contains("opensearchdescription")) {
            OpenSearchHandler openSearchHandler = cswHandler.openSearchHandler;
            OpenSearchDescription description = openSearchHandler.getOpenSearchDescription(serverBaseUri);
            return Response.ok(description).build();
        } else if (mediaType.getSubtype().contains("atom")) {
            outputFormatMediaType = MediaType.APPLICATION_ATOM_XML;
        }
    }
    if (request == null & version == null & service == null) {
        request = "GetCapabilities";
        version = CSWConstant.SUPPORTED_CSW_VERSION;
        service = CSWConstant.CSW;
    }
    String[] sectionList;
    if (sections == null) {
        sectionList = new String[] { "All" };
    } else {
        sectionList = sections.split(",");
        for (String section : sectionList) {
            if (!Arrays.asList(CSWConstant.SECTION_NAMES).contains(section)) {
                throw new OGCException(OGCExceptionCode.INVALID_PARAMETER_VALUE, "Invalid sections", "sections", Service.CSW);
            }
        }
    }
    if (acceptFormats != null) {
        if (acceptFormats.equals("text/xml")) {
            acceptFormatMediaType = MediaType.TEXT_XML;
        } else if (acceptFormats.equals("application/xml")) {
            acceptFormatMediaType = MediaType.APPLICATION_XML;
        } else {
            throw new OGCException(OGCExceptionCode.INVALID_PARAMETER_VALUE, "Invalid acceptFormats", "acceptFormats", Service.CSW);
        }
    }
    if (outputFormat != null) {
        if (outputFormat.equals("application/xml")) {
            outputFormatMediaType = MediaType.APPLICATION_XML;
        } else if (outputFormat.equals("application/atom+xml")) {
            outputFormatMediaType = MediaType.APPLICATION_ATOM_XML;
        } else {
            throw new OGCException(OGCExceptionCode.INVALID_PARAMETER_VALUE, "Invalid outputFormat", "outputFormat", Service.CSW);
        }
    }
    RequestUtils.checkRequestTypeByName(request, CSWConstant.SUPPORTED_CSW_REQUESTYPE, Service.CSW);
    CSWRequestType requestType = CSWRequestType.valueOf(request);
    CSWCheckParam.checkQuerySyntax(requestType, elementName, elementSetName, acceptVersions, version, service, outputSchema, typeNames, bbox, recordIds, query, id, constraintLanguage);
    String[] ids = null;
    if (recordIds != null && recordIds.length() > 0) {
        ids = recordIds.split(",");
    } else if (id != null) {
        ids = new String[] { id };
    }
    BoundingBox boundingBox = null;
    if (bbox != null && bbox.length() > 0) {
        // west, south, east, north CSW spec
        double[] bboxList = GeoFormat.toDoubles(bbox, Service.CSW);
        if (!(isBboxLatLonInCorrectRanges(bboxList) && bboxList[3] > bboxList[1]) && bboxList[0] != bboxList[2]) {
            throw new OGCException(OGCExceptionCode.INVALID_PARAMETER_VALUE, FluidSearchService.INVALID_BBOX, "bbox", Service.CSW);
        }
        boundingBox = new BoundingBox(bboxList[3], bboxList[1], bboxList[0], bboxList[2]);
    }
    startPosition = Optional.ofNullable(startPosition).orElse(1);
    maxRecords = Optional.ofNullable(maxRecords).orElse(cswHandler.ogcConfiguration.queryMaxFeature.intValue());
    elementSetName = Optional.ofNullable(elementSetName).orElse("summary");
    String[] elements = new String[] {};
    if (elementName != null) {
        elements = new String[elementName.split(",").length];
        int i = 0;
        for (String element : elementName.split(",")) {
            if (element.contains(":")) {
                elements[i] = elementName.split(":")[1];
                element = elements[i];
            } else {
                elements[i] = element;
            }
            if (!Arrays.asList(CSWConstant.DC_FIELDS).contains(element.toLowerCase()))
                throw new OGCException(OGCExceptionCode.INVALID_PARAMETER_VALUE, "Invalid elementName", "elementName", Service.CSW);
            i++;
        }
    }
    List<CollectionReference> collections;
    switch(requestType) {
        case GetCapabilities:
            GetCapabilitiesHandler getCapabilitiesHandler = cswHandler.getCapabilitiesHandler;
            List<String> responseSections = Arrays.asList(sectionList);
            String serviceUrl = serverBaseUri + "ogc/csw/?";
            getCapabilitiesHandler.setCapabilitiesType(responseSections, serviceUrl, serverBaseUri + "ogc/csw/opensearch");
            if (cswHandler.inspireConfiguration.enabled) {
                collections = collectionReferenceService.getAllCollectionReferences(columnFilter);
                collections.removeIf(collectionReference -> collectionReference.collectionName.equals(getMetacollectionName()));
                filterCollectionsByColumnFilter(columnFilter, collections);
                if (CollectionUtils.isNotEmpty(collections)) {
                    getCapabilitiesHandler.addINSPIRECompliantElements(collections, responseSections, serviceUrl, language);
                }
            }
            JAXBElement<CapabilitiesType> getCapabilitiesResponse = getCapabilitiesHandler.getCSWCapabilitiesResponse();
            return Response.ok(getCapabilitiesResponse).type(acceptFormatMediaType).build();
        case GetRecords:
            GetRecordsHandler getRecordsHandler = cswHandler.getRecordsHandler;
            CollectionReferences collectionReferences = getCollectionReferencesForGetRecords(elements, null, maxRecords, startPosition, ids, query, constraint, boundingBox);
            collections = new ArrayList<>(collectionReferences.collectionReferences);
            filterCollectionsByColumnFilter(columnFilter, collections);
            long recordsMatched = collectionReferences.totalCollectionReferences;
            if (recordIds != null && recordIds.length() > 0) {
                if (collections.size() == 0) {
                    throw new OGCException(OGCExceptionCode.NOT_FOUND, "Document not Found", "id", Service.CSW);
                }
            }
            GetRecordsResponseType getRecordsResponse = getRecordsHandler.getCSWGetRecordsResponse(collections, ElementSetName.valueOf(elementSetName), startPosition - 1, recordsMatched, elements, outputSchema);
            return Response.ok(getRecordsResponse).type(outputFormatMediaType).build();
        case GetRecordById:
            GetRecordsByIdHandler getRecordsByIdHandler = cswHandler.getRecordsByIdHandler;
            CollectionReferences recordCollectionReferences = ogcDao.getCollectionReferences(elements, null, maxRecords, startPosition - 1, ids, query, constraint, boundingBox);
            collections = new ArrayList<>(recordCollectionReferences.collectionReferences);
            ColumnFilterUtil.assertCollectionsAllowed(columnFilter, collections);
            if (outputSchema != null && outputSchema.equals(CSWConstant.SUPPORTED_CSW_OUTPUT_SCHEMA[2])) {
                GetRecordByIdResponse getRecordByIdResponse = getRecordsByIdHandler.getMDMetadaTypeResponse(collections, ElementSetName.valueOf(elementSetName));
                return Response.ok(getRecordByIdResponse).type(outputFormatMediaType).build();
            } else {
                AbstractRecordType abstractRecordType = getRecordsByIdHandler.getAbstractRecordTypeResponse(collections, ElementSetName.valueOf(elementSetName));
                return Response.ok(abstractRecordType).type(outputFormatMediaType).build();
            }
        default:
            throw new OGCException(OGCExceptionCode.INTERNAL_SERVER_ERROR, "Internal error: Unhandled request '" + request + "'.", Service.CSW);
    }
}
Also used : GetCapabilitiesHandler(io.arlas.server.ogc.csw.operation.getcapabilities.GetCapabilitiesHandler) GetRecordByIdResponse(io.arlas.server.ogc.csw.operation.getrecordbyid.GetRecordByIdResponse) GetRecordsByIdHandler(io.arlas.server.ogc.csw.operation.getrecordbyid.GetRecordsByIdHandler) OpenSearchHandler(io.arlas.server.ogc.csw.operation.opensearch.OpenSearchHandler) AbstractRecordType(net.opengis.cat.csw._3.AbstractRecordType) CollectionReference(io.arlas.server.core.model.CollectionReference) OpenSearchDescription(com.a9.opensearch.OpenSearchDescription) CapabilitiesType(net.opengis.cat.csw._3.CapabilitiesType) GetRecordsHandler(io.arlas.server.ogc.csw.operation.getrecords.GetRecordsHandler) BoundingBox(io.arlas.server.core.utils.BoundingBox) CollectionReferences(io.arlas.server.core.model.CollectionReferences) GetRecordsResponseType(net.opengis.cat.csw._3.GetRecordsResponseType) OGCException(io.arlas.server.ogc.common.exceptions.OGC.OGCException) CSWRequestType(io.arlas.server.ogc.csw.utils.CSWRequestType) Timed(com.codahale.metrics.annotation.Timed)

Example 30 with CollectionReference

use of io.arlas.server.core.model.CollectionReference in project ARLAS-server by gisaia.

the class GetCapabilitiesHandler method addECMetadataDate.

private void addECMetadataDate(List<CollectionReference> collections) throws INSPIREException {
    /* The latest date of all the collections is returned*/
    Date metadataDate = null;
    if (collections != null) {
        for (CollectionReference collectionReference : collections) {
            Date collectionDate = CSWParamsParser.getMetadataDate(collectionReference.params.dublinCoreElementName.getDate());
            if (metadataDate == null || metadataDate.compareTo(collectionDate) < 0) {
                metadataDate = collectionDate;
            }
        }
    }
    if (metadataDate == null) {
        throw new INSPIREException(INSPIREExceptionCode.MISSING_INSPIRE_METADATA, "Metadata date is missing", Service.CSW);
    } else {
        DateFormat df = new SimpleDateFormat(InspireConstants.CSW_METADATA_DATE_FORMAT);
        inspireExtendedCapabilitiesType.setMetadataDate(df.format(metadataDate));
    }
}
Also used : INSPIREException(io.arlas.server.ogc.common.exceptions.INSPIRE.INSPIREException) SimpleDateFormat(java.text.SimpleDateFormat) DateFormat(java.text.DateFormat) SimpleDateFormat(java.text.SimpleDateFormat) CollectionReference(io.arlas.server.core.model.CollectionReference)

Aggregations

CollectionReference (io.arlas.server.core.model.CollectionReference)40 Timed (com.codahale.metrics.annotation.Timed)23 ApiOperation (io.swagger.annotations.ApiOperation)21 ApiResponses (io.swagger.annotations.ApiResponses)21 ArlasException (io.arlas.server.core.exceptions.ArlasException)14 MixedRequest (io.arlas.server.core.model.request.MixedRequest)13 Search (io.arlas.server.core.model.request.Search)7 Collectors (java.util.stream.Collectors)7 FeatureCollection (org.geojson.FeatureCollection)7 NotFoundException (io.arlas.server.core.exceptions.NotFoundException)6 CollectionReferenceService (io.arlas.server.core.services.CollectionReferenceService)6 ExploreService (io.arlas.server.core.services.ExploreService)6 IOException (java.io.IOException)6 java.util (java.util)5 Response (javax.ws.rs.core.Response)5 JsonProcessingException (com.fasterxml.jackson.core.JsonProcessingException)4 CollectionReferenceParameters (io.arlas.server.core.model.CollectionReferenceParameters)4 AggregationResponse (io.arlas.server.core.model.response.AggregationResponse)4 CollectionReferenceDescription (io.arlas.server.core.model.response.CollectionReferenceDescription)4 io.arlas.server.core.utils (io.arlas.server.core.utils)4