Search in sources :

Example 1 with CSWService

use of io.arlas.server.ogc.csw.CSWService in project ARLAS-server by gisaia.

the class ArlasServer method run.

@Override
public void run(ArlasServerConfiguration configuration, Environment environment) throws Exception {
    configuration.check();
    LOGGER.info("Checked configuration: " + (new ObjectMapper()).writer().writeValueAsString(configuration));
    CacheFactory cacheFactory = (CacheFactory) Class.forName(configuration.arlasCacheFactoryClass).getConstructor(ArlasServerConfiguration.class).newInstance(configuration);
    DatabaseToolsFactory dbToolFactory = (DatabaseToolsFactory) Class.forName(configuration.arlasDatabaseFactoryClass).getConstructor(Environment.class, ArlasServerConfiguration.class, CacheManager.class).newInstance(environment, configuration, cacheFactory.getCacheManager());
    CollectionReferenceManager.getInstance().init(dbToolFactory.getCollectionReferenceService(), cacheFactory.getCacheManager());
    if (configuration.zipkinConfiguration != null) {
        Optional<HttpTracing> tracing = configuration.zipkinConfiguration.build(environment);
    }
    ExploreService exploration = dbToolFactory.getExploreService();
    environment.getObjectMapper().setSerializationInclusion(Include.NON_NULL);
    environment.jersey().register(MultiPartFeature.class);
    environment.jersey().register(new ArlasExceptionMapper());
    environment.jersey().register(new IllegalArgumentExceptionMapper());
    environment.jersey().register(new JsonProcessingExceptionMapper());
    environment.jersey().register(new ConstraintViolationExceptionMapper());
    environment.jersey().register(new AtomHitsMessageBodyWriter(exploration));
    environment.jersey().register(new AtomGetRecordsMessageBodyWriter(configuration));
    environment.jersey().register(new XmlGetRecordsMessageBodyWriter());
    environment.jersey().register(new XmlMDMetadataMessageBodyWriter());
    environment.jersey().register(new XmlRecordMessageBodyBuilder());
    environment.jersey().register(new AtomRecordMessageBodyWriter());
    if (configuration.arlasServiceExploreEnabled) {
        environment.jersey().register(new CountRESTService(exploration));
        environment.jersey().register(new SearchRESTService(exploration));
        environment.jersey().register(new AggregateRESTService(exploration));
        environment.jersey().register(new GeoSearchRESTService(exploration));
        environment.jersey().register(new GeoAggregateRESTService(exploration));
        environment.jersey().register(new SuggestRESTService(exploration));
        environment.jersey().register(new DescribeRESTService(exploration));
        environment.jersey().register(new RawRESTService(exploration));
        environment.jersey().register(new DescribeCollectionRESTService(exploration));
        environment.jersey().register(new ComputeRESTService(exploration));
        LOGGER.info("Explore API enabled");
    } else {
        LOGGER.info("Explore API disabled");
    }
    // Auth
    if (configuration.arlasAuthConfiguration.enabled) {
        environment.jersey().register(new AuthenticationFilter(configuration.arlasAuthConfiguration));
        environment.jersey().register(new AuthorizationFilter(configuration.arlasAuthConfiguration));
    }
    if (configuration.arlasServiceCollectionsEnabled) {
        LOGGER.info("Collection API enabled");
        environment.jersey().register(new CollectionService(configuration, dbToolFactory.getCollectionReferenceService()));
    } else {
        LOGGER.info("Collection API disabled");
    }
    if (configuration.arlasServiceWFSEnabled) {
        LOGGER.info("WFS Service enabled");
        WFSHandler wfsHandler = new WFSHandler(configuration.wfsConfiguration, configuration.ogcConfiguration, configuration.inspireConfiguration, configuration.arlasBaseUri);
        environment.jersey().register(new WFSService(dbToolFactory.getCollectionReferenceService(), dbToolFactory.getWFSToolService(), wfsHandler));
    } else {
        LOGGER.info("WFS Service disabled");
    }
    if (configuration.arlasServiceOPENSEARCHEnabled) {
        LOGGER.info("OPENSEARCH Service enabled");
        environment.jersey().register(new OpenSearchDescriptorService(exploration));
    } else {
        LOGGER.info("OPENSEARCH Service disabled");
    }
    if (configuration.arlasServiceCSWEnabled) {
        LOGGER.info("CSW Service enabled");
        CSWHandler cswHandler = new CSWHandler(configuration.ogcConfiguration, configuration.cswConfiguration, configuration.inspireConfiguration, configuration.arlasBaseUri);
        environment.jersey().register(new CSWService(dbToolFactory.getCollectionReferenceService(), dbToolFactory.getOGCCollectionReferenceDao(), cswHandler, configuration));
    } else {
        LOGGER.info("CSW Service disabled");
    }
    if (configuration.arlasServiceRasterTileEnabled) {
        LOGGER.info("Raster Tile Service enabled");
        environment.jersey().register(new TileRESTService(exploration));
    } else {
        LOGGER.info("Raster Tile Service disabled");
    }
    if (configuration.arlasServiceSTACEnabled) {
        LOGGER.info("STAC Service enabled");
        // Add OpenAPI v3 endpoint
        String baseUri = configuration.arlasBaseUri;
        if (baseUri.endsWith("/")) {
            baseUri = baseUri.substring(0, baseUri.length() - 1);
        }
        Info info = new Info().title("ARLAS STAC API").version("1.0.0");
        SwaggerConfiguration oasConfig = new SwaggerConfiguration().openAPI(new OpenAPI().info(info).servers(Collections.singletonList(new Server().url(baseUri)))).prettyPrint(true).resourceClasses(Stream.of("io.arlas.server.stac.api.StacCoreRESTService", "io.arlas.server.stac.api.StacCollectionsRESTService", "io.arlas.server.stac.api.StacConformanceRESTService", "io.arlas.server.stac.api.StacSearchRESTService").collect(Collectors.toSet()));
        environment.jersey().register(new OpenApiResource().openApiConfiguration(oasConfig));
        // 
        environment.jersey().register(new StacCoreRESTService(configuration.stacConfiguration, configuration.arlasRestCacheTimeout, dbToolFactory.getCollectionReferenceService(), dbToolFactory.getExploreService()));
        environment.jersey().register(new StacCollectionsRESTService(configuration.stacConfiguration, configuration.arlasRestCacheTimeout, dbToolFactory.getCollectionReferenceService(), dbToolFactory.getExploreService()));
        environment.jersey().register(new StacConformanceRESTService(configuration.stacConfiguration, configuration.arlasRestCacheTimeout, dbToolFactory.getCollectionReferenceService(), dbToolFactory.getExploreService()));
        environment.jersey().register(new StacSearchRESTService(configuration.stacConfiguration, configuration.arlasRestCacheTimeout, dbToolFactory.getCollectionReferenceService(), dbToolFactory.getExploreService()));
    } else {
        LOGGER.info("STAC Service disabled");
    }
    // filters
    environment.jersey().register(PrettyPrintFilter.class);
    environment.jersey().register(InsensitiveCaseFilter.class);
    // tasks
    environment.admin().addTask(new CollectionAutoDiscover(dbToolFactory.getCollectionReferenceService(), configuration));
    int scheduleAutoDiscover = configuration.collectionAutoDiscoverConfiguration.schedule;
    if (scheduleAutoDiscover > 0) {
        String nameFormat = "collection-auto-discover-%d";
        ScheduledExecutorServiceBuilder sesBuilder = environment.lifecycle().scheduledExecutorService(nameFormat);
        ScheduledExecutorService ses = sesBuilder.build();
        Runnable autoDiscoverTask = new CollectionAutoDiscover(dbToolFactory.getCollectionReferenceService(), configuration);
        ses.scheduleWithFixedDelay(autoDiscoverTask, 10, scheduleAutoDiscover, TimeUnit.SECONDS);
    }
    // healthchecks
    dbToolFactory.getHealthChecks().forEach((name, check) -> environment.healthChecks().register(name, check));
    // cors
    if (configuration.arlarsCorsConfiguration.enabled) {
        configureCors(environment, configuration.arlarsCorsConfiguration);
    } else {
        CrossOriginFilter filter = new CrossOriginFilter();
        final FilterRegistration.Dynamic cors = environment.servlets().addFilter("CrossOriginFilter", filter);
        // Expose always HttpHeaders.WWW_AUTHENTICATE to authentify on client side a non public uri call
        cors.setInitParameter(CrossOriginFilter.EXPOSED_HEADERS_PARAM, HttpHeaders.WWW_AUTHENTICATE);
    }
}
Also used : SearchRESTService(io.arlas.server.rest.explore.search.SearchRESTService) StacSearchRESTService(io.arlas.server.stac.api.StacSearchRESTService) GeoSearchRESTService(io.arlas.server.rest.explore.search.GeoSearchRESTService) StacCollectionsRESTService(io.arlas.server.stac.api.StacCollectionsRESTService) SuggestRESTService(io.arlas.server.rest.explore.suggest.SuggestRESTService) Server(io.swagger.v3.oas.models.servers.Server) DescribeCollectionRESTService(io.arlas.server.rest.explore.describe.DescribeCollectionRESTService) SwaggerConfiguration(io.swagger.v3.oas.integration.SwaggerConfiguration) CSWHandler(io.arlas.server.ogc.csw.CSWHandler) XmlRecordMessageBodyBuilder(io.arlas.server.ogc.csw.writer.record.XmlRecordMessageBodyBuilder) XmlGetRecordsMessageBodyWriter(io.arlas.server.ogc.csw.writer.getrecords.XmlGetRecordsMessageBodyWriter) ComputeRESTService(io.arlas.server.rest.explore.compute.ComputeRESTService) WFSService(io.arlas.server.ogc.wfs.WFSService) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper) StacCoreRESTService(io.arlas.server.stac.api.StacCoreRESTService) ScheduledExecutorService(java.util.concurrent.ScheduledExecutorService) CSWService(io.arlas.server.ogc.csw.CSWService) IllegalArgumentExceptionMapper(io.arlas.server.core.exceptions.IllegalArgumentExceptionMapper) AggregateRESTService(io.arlas.server.rest.explore.aggregate.AggregateRESTService) GeoAggregateRESTService(io.arlas.server.rest.explore.aggregate.GeoAggregateRESTService) StacSearchRESTService(io.arlas.server.stac.api.StacSearchRESTService) ArlasExceptionMapper(io.arlas.server.core.exceptions.ArlasExceptionMapper) ConstraintViolationExceptionMapper(io.arlas.server.core.exceptions.ConstraintViolationExceptionMapper) GeoAggregateRESTService(io.arlas.server.rest.explore.aggregate.GeoAggregateRESTService) GeoSearchRESTService(io.arlas.server.rest.explore.search.GeoSearchRESTService) OpenAPI(io.swagger.v3.oas.models.OpenAPI) HttpTracing(brave.http.HttpTracing) AuthorizationFilter(io.arlas.server.admin.auth.AuthorizationFilter) AtomHitsMessageBodyWriter(io.arlas.server.opensearch.rest.explore.AtomHitsMessageBodyWriter) ExploreService(io.arlas.server.core.services.ExploreService) JsonProcessingExceptionMapper(io.arlas.server.core.exceptions.JsonProcessingExceptionMapper) TileRESTService(io.arlas.server.rest.plugins.eo.TileRESTService) FilterRegistration(javax.servlet.FilterRegistration) ScheduledExecutorServiceBuilder(io.dropwizard.lifecycle.setup.ScheduledExecutorServiceBuilder) AtomGetRecordsMessageBodyWriter(io.arlas.server.ogc.csw.writer.getrecords.AtomGetRecordsMessageBodyWriter) StacConformanceRESTService(io.arlas.server.stac.api.StacConformanceRESTService) AtomRecordMessageBodyWriter(io.arlas.server.ogc.csw.writer.record.AtomRecordMessageBodyWriter) AuthenticationFilter(io.arlas.server.admin.auth.AuthenticationFilter) CountRESTService(io.arlas.server.rest.explore.count.CountRESTService) RawRESTService(io.arlas.server.rest.explore.raw.RawRESTService) OpenSearchDescriptorService(io.arlas.server.opensearch.rest.explore.OpenSearchDescriptorService) CollectionAutoDiscover(io.arlas.server.admin.task.CollectionAutoDiscover) Info(io.swagger.v3.oas.models.info.Info) CrossOriginFilter(org.eclipse.jetty.servlets.CrossOriginFilter) OpenApiResource(io.swagger.v3.jaxrs2.integration.resources.OpenApiResource) CollectionService(io.arlas.server.rest.collections.CollectionService) WFSHandler(io.arlas.server.ogc.wfs.WFSHandler) DescribeRESTService(io.arlas.server.rest.explore.describe.DescribeRESTService) XmlMDMetadataMessageBodyWriter(io.arlas.server.ogc.csw.writer.record.XmlMDMetadataMessageBodyWriter)

Aggregations

HttpTracing (brave.http.HttpTracing)1 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)1 AuthenticationFilter (io.arlas.server.admin.auth.AuthenticationFilter)1 AuthorizationFilter (io.arlas.server.admin.auth.AuthorizationFilter)1 CollectionAutoDiscover (io.arlas.server.admin.task.CollectionAutoDiscover)1 ArlasExceptionMapper (io.arlas.server.core.exceptions.ArlasExceptionMapper)1 ConstraintViolationExceptionMapper (io.arlas.server.core.exceptions.ConstraintViolationExceptionMapper)1 IllegalArgumentExceptionMapper (io.arlas.server.core.exceptions.IllegalArgumentExceptionMapper)1 JsonProcessingExceptionMapper (io.arlas.server.core.exceptions.JsonProcessingExceptionMapper)1 ExploreService (io.arlas.server.core.services.ExploreService)1 CSWHandler (io.arlas.server.ogc.csw.CSWHandler)1 CSWService (io.arlas.server.ogc.csw.CSWService)1 AtomGetRecordsMessageBodyWriter (io.arlas.server.ogc.csw.writer.getrecords.AtomGetRecordsMessageBodyWriter)1 XmlGetRecordsMessageBodyWriter (io.arlas.server.ogc.csw.writer.getrecords.XmlGetRecordsMessageBodyWriter)1 AtomRecordMessageBodyWriter (io.arlas.server.ogc.csw.writer.record.AtomRecordMessageBodyWriter)1 XmlMDMetadataMessageBodyWriter (io.arlas.server.ogc.csw.writer.record.XmlMDMetadataMessageBodyWriter)1 XmlRecordMessageBodyBuilder (io.arlas.server.ogc.csw.writer.record.XmlRecordMessageBodyBuilder)1 WFSHandler (io.arlas.server.ogc.wfs.WFSHandler)1 WFSService (io.arlas.server.ogc.wfs.WFSService)1 AtomHitsMessageBodyWriter (io.arlas.server.opensearch.rest.explore.AtomHitsMessageBodyWriter)1