Configuration management

- Default values
- Compute values
This commit is contained in:
Maxime Dor
2017-09-17 02:03:45 +02:00
parent 0cbf1a83a5
commit 22d8380bce
2 changed files with 29 additions and 10 deletions

View File

@@ -20,7 +20,6 @@
package io.kamax.mxisd.config.rest;
import com.google.gson.Gson;
import io.kamax.mxisd.exception.ConfigurationException;
import org.apache.commons.lang.StringUtils;
import org.slf4j.Logger;
@@ -112,14 +111,9 @@ public class RestBackendConfig {
this.endpoints = endpoints;
}
@PostConstruct
private void postConstruct() {
Gson gson = new Gson();
log.info("--- REST backend config ---");
log.info("Enabled: {}", isEnabled());
if (isEnabled()) {
if (StringUtils.isBlank(host)) {
private String buildEndpointUrl(String endpoint) {
if (StringUtils.startsWith(endpoint, "/")) {
if (StringUtils.isBlank(getHost())) {
throw new ConfigurationException("rest.host");
}
@@ -129,8 +123,26 @@ public class RestBackendConfig {
throw new ConfigurationException("rest.host", e.getMessage());
}
return getHost() + endpoint;
} else {
return endpoint;
}
}
@PostConstruct
private void postConstruct() {
log.info("--- REST backend config ---");
log.info("Enabled: {}", isEnabled());
if (isEnabled()) {
endpoints.setAuth(buildEndpointUrl(endpoints.getAuth()));
endpoints.identity.setSingle(buildEndpointUrl(endpoints.identity.getSingle()));
endpoints.identity.setBulk(buildEndpointUrl(endpoints.identity.getBulk()));
log.info("Host: {}", getHost());
log.info("Endpoints: {}", gson.toJson(endpoints));
log.info("Auth endpoint: {}", endpoints.getAuth());
log.info("Identity Single endpoint: {}", endpoints.identity.getSingle());
log.info("Identity Bulk endpoint: {}", endpoints.identity.getBulk());
}
}

View File

@@ -23,6 +23,13 @@ lookup:
enabled: false
recursiveOnly: true
rest:
endpoints:
auth: "/_mxisd/identity/api/v1/auth"
identity:
single: "/_mxisd/identity/api/v1/lookup/single"
bulk: "/_mxisd/identity/api/v1/lookup/bulk"
ldap:
enabled: false
connection: