All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.seedstack.seed.rest.RestConfig Maven / Gradle / Ivy

/*
 * Copyright © 2013-2024, The SeedStack authors 
 *
 * This Source Code Form is subject to the terms of the Mozilla Public
 * License, v. 2.0. If a copy of the MPL was not distributed with this
 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
 */
package org.seedstack.seed.rest;

import org.seedstack.coffig.Config;
import org.seedstack.coffig.SingleValue;

import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Map;
import java.util.Set;

@Config("rest")
public class RestConfig {
    @SingleValue
    private String path = "";
    private String jspPath = "/WEB-INF/jsp";
    private String baseRel = "";
    private String baseParam = "";
    private boolean jsonHome = false;
    private boolean diagnosticResource = false;
    private Map jerseyProperties = new HashMap<>();
    private Set> features = new HashSet<>();
    private ExceptionMappingConfig exceptionMapping = new ExceptionMappingConfig();
    private boolean streamSupport = true;

    public String getPath() {
        return path;
    }

    public RestConfig setPath(String path) {
        String normalized = path;
        if (!normalized.startsWith("/")) {
            normalized = "/" + normalized;
        }
        if (normalized.endsWith("/")) {
            normalized = normalized.substring(0, normalized.length() - 1);
        }
        this.path = normalized;
        return this;
    }

    public String getJspPath() {
        return jspPath;
    }

    public RestConfig setJspPath(String jspPath) {
        this.jspPath = jspPath;
        return this;
    }

    public String getBaseRel() {
        return baseRel;
    }

    public RestConfig setBaseRel(String baseRel) {
        this.baseRel = baseRel;
        return this;
    }

    public String getBaseParam() {
        return baseParam;
    }

    public RestConfig setBaseParam(String baseParam) {
        this.baseParam = baseParam;
        return this;
    }

    public boolean isJsonHome() {
        return jsonHome;
    }

    public RestConfig setJsonHome(boolean jsonHome) {
        this.jsonHome = jsonHome;
        return this;
    }

    public boolean isDiagnosticResource() {
        return diagnosticResource;
    }

    public RestConfig setDiagnosticResource(boolean diagnosticResource) {
        this.diagnosticResource = diagnosticResource;
        return this;
    }

    public Map getJerseyProperties() {
        return Collections.unmodifiableMap(jerseyProperties);
    }

    public RestConfig setJerseyProperties(Map jerseyProperties) {
        this.jerseyProperties = jerseyProperties;
        return this;
    }

    public Set> getFeatures() {
        return Collections.unmodifiableSet(features);
    }

    public RestConfig setFeatures(Set> features) {
        this.features = features;
        return this;
    }

    public ExceptionMappingConfig exceptionMapping() {
        return exceptionMapping;
    }

    public boolean isStreamSupport() {
        return streamSupport;
    }

    public RestConfig setStreamSupport(boolean streamSupport) {
        this.streamSupport = streamSupport;
        return this;
    }

    @Config("exceptionMapping")
    public static class ExceptionMappingConfig {
        private boolean security = true;
        private boolean all = true;
        private boolean validation = true;
        private boolean detailedLog = true;
        private boolean detailedUserMessage = true;
        private boolean jackson = true;

        public boolean isSecurity() {
            return security;
        }

        public boolean isAll() {
            return all;
        }

        public boolean isValidation() {
            return validation;
        }

        public boolean isDetailedLog() {
            return detailedLog;
        }

        public boolean isJackson() {
            return jackson;
        }

        public boolean isDetailedUserMessage() {
            return detailedUserMessage;
        }
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy