Search in sources :

Example 1 with SettingsService

use of org.finos.waltz.service.settings.SettingsService in project waltz by khartec.

the class Main method enableGZIP.

private void enableGZIP() {
    SettingsService settingsService = ctx.getBean(SettingsService.class);
    Boolean gzipEnabled = settingsService.getValue(GZIP_ENABLED_NAME).map(x -> x.equalsIgnoreCase("true")).orElse(false);
    if (gzipEnabled) {
        // now fetch the minimum size
        int minimumLength = settingsService.getValue(GZIP_MIN_SIZE_NAME).map(Integer::parseInt).orElse(8192);
        after(((request, response) -> {
            if (response.body() != null && response.body().length() >= minimumLength) {
                response.header("Content-Encoding", "gzip");
            }
        }));
        LOG.info("Enabled GZIP (size: " + minimumLength + ")");
    } else {
        LOG.info("GZIP not enabled");
    }
}
Also used : DataAccessException(org.jooq.exception.DataAccessException) Logger(org.slf4j.Logger) UpdateFailedException(org.finos.waltz.common.exception.UpdateFailedException) UTC(org.finos.waltz.common.DateTimeUtilities.UTC) Endpoint(org.finos.waltz.web.endpoints.Endpoint) DataExtractor(org.finos.waltz.web.endpoints.extracts.DataExtractor) TimeZone(java.util.TimeZone) LoggerFactory(org.slf4j.LoggerFactory) LoggingUtilities(org.finos.waltz.common.LoggingUtilities) NotFoundException(org.finos.waltz.common.exception.NotFoundException) WebUtilities.reportException(org.finos.waltz.web.WebUtilities.reportException) DIConfiguration(org.finos.waltz.service.DIConfiguration) AnnotationConfigApplicationContext(org.springframework.context.annotation.AnnotationConfigApplicationContext) InsufficientPrivelegeException(org.finos.waltz.common.exception.InsufficientPrivelegeException) SettingsService(org.finos.waltz.service.settings.SettingsService) DataIntegrityViolationException(org.springframework.dao.DataIntegrityViolationException) Request(spark.Request) Map(java.util.Map) Response(spark.Response) HttpStatus(org.eclipse.jetty.http.HttpStatus) StaticResourcesEndpoint(org.finos.waltz.web.endpoints.api.StaticResourcesEndpoint) DuplicateKeyException(org.finos.waltz.common.exception.DuplicateKeyException) Spark(spark.Spark) EndpointUtilities(org.finos.waltz.web.endpoints.EndpointUtilities) SettingsService(org.finos.waltz.service.settings.SettingsService) Endpoint(org.finos.waltz.web.endpoints.Endpoint) StaticResourcesEndpoint(org.finos.waltz.web.endpoints.api.StaticResourcesEndpoint)

Aggregations

Map (java.util.Map)1 TimeZone (java.util.TimeZone)1 HttpStatus (org.eclipse.jetty.http.HttpStatus)1 UTC (org.finos.waltz.common.DateTimeUtilities.UTC)1 LoggingUtilities (org.finos.waltz.common.LoggingUtilities)1 DuplicateKeyException (org.finos.waltz.common.exception.DuplicateKeyException)1 InsufficientPrivelegeException (org.finos.waltz.common.exception.InsufficientPrivelegeException)1 NotFoundException (org.finos.waltz.common.exception.NotFoundException)1 UpdateFailedException (org.finos.waltz.common.exception.UpdateFailedException)1 DIConfiguration (org.finos.waltz.service.DIConfiguration)1 SettingsService (org.finos.waltz.service.settings.SettingsService)1 WebUtilities.reportException (org.finos.waltz.web.WebUtilities.reportException)1 Endpoint (org.finos.waltz.web.endpoints.Endpoint)1 EndpointUtilities (org.finos.waltz.web.endpoints.EndpointUtilities)1 StaticResourcesEndpoint (org.finos.waltz.web.endpoints.api.StaticResourcesEndpoint)1 DataExtractor (org.finos.waltz.web.endpoints.extracts.DataExtractor)1 DataAccessException (org.jooq.exception.DataAccessException)1 Logger (org.slf4j.Logger)1 LoggerFactory (org.slf4j.LoggerFactory)1 AnnotationConfigApplicationContext (org.springframework.context.annotation.AnnotationConfigApplicationContext)1