Continue structural port from Spring Boot to Undertow

- Configuration options
- Configuration documentation
This commit is contained in:
Max Dor
2018-12-31 15:07:49 +01:00
parent ace5918342
commit 4185b644b7
48 changed files with 454 additions and 351 deletions

View File

@@ -20,7 +20,6 @@
package io.kamax.mxisd.config;
import javax.annotation.PostConstruct;
import java.util.Objects;
public class BulkLookupConfig {
@@ -35,7 +34,6 @@ public class BulkLookupConfig {
this.enabled = enabled;
}
@PostConstruct
public void build() {
if (Objects.isNull(enabled)) {
enabled = true;

View File

@@ -23,8 +23,6 @@ package io.kamax.mxisd.config;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import javax.annotation.PostConstruct;
public class DirectoryConfig {
private final static Logger log = LoggerFactory.getLogger(DirectoryConfig.class);
@@ -63,7 +61,6 @@ public class DirectoryConfig {
this.exclude = exclude;
}
@PostConstruct
public void build() {
log.info("--- Directory config ---");
log.info("Exclude:");

View File

@@ -25,7 +25,6 @@ import io.kamax.mxisd.util.GsonUtil;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import javax.annotation.PostConstruct;
import java.util.ArrayList;
import java.util.List;
@@ -89,7 +88,6 @@ public class DnsOverwriteConfig {
this.homeserver = homeserver;
}
@PostConstruct
public void build() {
Gson gson = GsonUtil.build();
log.info("--- DNS Overwrite config ---");

View File

@@ -22,7 +22,6 @@ package io.kamax.mxisd.config;
import org.apache.commons.lang3.StringUtils;
import javax.annotation.PostConstruct;
import java.util.*;
public class ExecConfig {
@@ -512,7 +511,6 @@ public class ExecConfig {
this.profile = profile;
}
@PostConstruct
public ExecConfig build() {
if (Objects.isNull(getAuth().isEnabled())) {
getAuth().setEnabled(isEnabled());

View File

@@ -23,8 +23,6 @@ package io.kamax.mxisd.config;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import javax.annotation.PostConstruct;
public class FirebaseConfig {
private transient final Logger log = LoggerFactory.getLogger(FirebaseConfig.class);
@@ -57,7 +55,6 @@ public class FirebaseConfig {
this.database = database;
}
@PostConstruct
public void build() {
log.info("--- Firebase configuration ---");
log.info("Enabled: {}", isEnabled());

View File

@@ -24,8 +24,6 @@ import io.kamax.mxisd.util.GsonUtil;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import javax.annotation.PostConstruct;
public class InvitationConfig {
private transient final Logger log = LoggerFactory.getLogger(InvitationConfig.class);
@@ -63,7 +61,6 @@ public class InvitationConfig {
this.resolution = resolution;
}
@PostConstruct
public void build() {
log.info("--- Invite config ---");
log.info("Resolution: {}", GsonUtil.build().toJson(resolution));

View File

@@ -23,8 +23,6 @@ package io.kamax.mxisd.config;
import io.kamax.mxisd.exception.ConfigurationException;
import org.apache.commons.lang.StringUtils;
import javax.annotation.PostConstruct;
public class KeyConfig {
private String path;
@@ -37,7 +35,6 @@ public class KeyConfig {
return path;
}
@PostConstruct
public void build() {
if (StringUtils.isBlank(getPath())) {
throw new ConfigurationException("key.path");

View File

@@ -20,9 +20,9 @@
package io.kamax.mxisd.config;
import io.kamax.mxisd.exception.ConfigurationException;
import org.apache.commons.lang.StringUtils;
import javax.annotation.PostConstruct;
import java.net.MalformedURLException;
import java.net.URL;
@@ -80,24 +80,27 @@ public class ListenerConfig {
this.token = token;
}
@PostConstruct
public void build() throws MalformedURLException {
if (StringUtils.isBlank(url)) {
return;
}
public void build() {
try {
if (StringUtils.isBlank(url)) {
return;
}
csUrl = new URL(url);
csUrl = new URL(url);
if (StringUtils.isBlank(getLocalpart())) {
throw new IllegalArgumentException("localpart for matrix listener is not set");
}
if (StringUtils.isBlank(getLocalpart())) {
throw new IllegalArgumentException("localpart for matrix listener is not set");
}
if (StringUtils.isBlank(getToken().getAs())) {
throw new IllegalArgumentException("AS token is not set");
}
if (StringUtils.isBlank(getToken().getAs())) {
throw new IllegalArgumentException("AS token is not set");
}
if (StringUtils.isBlank(getToken().getHs())) {
throw new IllegalArgumentException("HS token is not set");
if (StringUtils.isBlank(getToken().getHs())) {
throw new IllegalArgumentException("HS token is not set");
}
} catch (MalformedURLException e) {
throw new ConfigurationException(e);
}
}

View File

@@ -26,7 +26,6 @@ import org.apache.commons.lang.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import javax.annotation.PostConstruct;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
@@ -90,7 +89,6 @@ public class MatrixConfig {
this.listener = listener;
}
@PostConstruct
public void build() {
log.info("--- Matrix config ---");
@@ -101,6 +99,8 @@ public class MatrixConfig {
log.info("Domain: {}", getDomain());
log.info("Identity:");
log.info("\tServers: {}", GsonUtil.get().toJson(identity.getServers()));
listener.build();
}
}

View File

@@ -23,7 +23,6 @@ package io.kamax.mxisd.config;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import javax.annotation.PostConstruct;
import java.util.HashMap;
import java.util.Map;
@@ -68,7 +67,6 @@ public class RecursiveLookupBridgeConfig {
this.mappings = mappings;
}
@PostConstruct
public void build() {
log.info("--- Bridge integration lookups config ---");
log.info("Enabled: {}", getEnabled());

View File

@@ -24,7 +24,6 @@ import org.apache.commons.lang.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import javax.annotation.PostConstruct;
import java.net.MalformedURLException;
import java.net.URL;
@@ -60,7 +59,6 @@ public class ServerConfig {
this.publicUrl = publicUrl;
}
@PostConstruct
public void build() {
log.info("--- Server config ---");

View File

@@ -24,8 +24,6 @@ import io.kamax.matrix.json.GsonUtil;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import javax.annotation.PostConstruct;
public class SessionConfig {
private transient final Logger log = LoggerFactory.getLogger(SessionConfig.class);
@@ -162,7 +160,6 @@ public class SessionConfig {
this.policy = policy;
}
@PostConstruct
public void build() {
log.info("--- Session config ---");
log.info("Global Policy: {}", GsonUtil.get().toJson(policy));

View File

@@ -23,8 +23,6 @@ package io.kamax.mxisd.config;
import io.kamax.mxisd.exception.ConfigurationException;
import org.apache.commons.lang.StringUtils;
import javax.annotation.PostConstruct;
public class StorageConfig {
public static class Provider {
@@ -60,7 +58,6 @@ public class StorageConfig {
this.provider = provider;
}
@PostConstruct
public void build() {
if (StringUtils.isBlank(getBackend())) {
throw new ConfigurationException("storage.backend");

View File

@@ -24,8 +24,6 @@ import io.kamax.matrix.json.GsonUtil;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import javax.annotation.PostConstruct;
public class ViewConfig {
private transient final Logger log = LoggerFactory.getLogger(ViewConfig.class);
@@ -145,7 +143,6 @@ public class ViewConfig {
this.session = session;
}
@PostConstruct
public void build() {
log.info("--- View config ---");
log.info("Session: {}", GsonUtil.get().toJson(session));

View File

@@ -28,7 +28,6 @@ import org.apache.commons.lang.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import javax.annotation.PostConstruct;
import java.util.*;
public abstract class LdapConfig {
@@ -58,12 +57,11 @@ public abstract class LdapConfig {
public static class Attribute {
private UID uid;
private UID uid = new UID();
private String name = "displayName";
private Map<String, List<String>> threepid = new HashMap<>();
public Attribute() {
uid = new UID();
uid.setType("uid");
uid.setValue("saMAccountName");
@@ -358,7 +356,6 @@ public abstract class LdapConfig {
this.profile = profile;
}
@PostConstruct
public void build() {
log.info("--- " + getConfigName() + " Config ---");
log.info("Enabled: {}", isEnabled());

View File

@@ -25,7 +25,6 @@ import org.apache.commons.lang.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import javax.annotation.PostConstruct;
import java.net.MalformedURLException;
import java.net.URL;
import java.util.Objects;
@@ -93,7 +92,7 @@ public class RestBackendConfig {
private String auth = "/_mxisd/backend/api/v1/auth/login";
private String directory = "/_mxisd/backend/api/v1/directory/user/search";
private IdentityEndpoints identity = new IdentityEndpoints();
private ProfileEndpoints profile;
private ProfileEndpoints profile = new ProfileEndpoints();
public String getAuth() {
return auth;
@@ -177,7 +176,6 @@ public class RestBackendConfig {
return getHost() + endpoint;
}
@PostConstruct
public void build() {
log.info("--- REST backend config ---");
log.info("Enabled: {}", isEnabled());

View File

@@ -291,15 +291,15 @@ public abstract class SqlConfig {
protected abstract String getProviderName();
public void build() {
if (getAuth().isEnabled() == null) {
if (Objects.isNull(getAuth().isEnabled())) {
getAuth().setEnabled(isEnabled());
}
if (getDirectory().isEnabled() == null) {
if (Objects.isNull(getDirectory().isEnabled())) {
getDirectory().setEnabled(isEnabled());
}
if (getIdentity().isEnabled() == null) {
if (Objects.isNull(getIdentity().isEnabled())) {
getIdentity().setEnabled(isEnabled());
}

View File

@@ -25,7 +25,6 @@ import org.apache.commons.lang.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import javax.annotation.PostConstruct;
import java.util.HashMap;
import java.util.Map;
@@ -198,12 +197,13 @@ public class EmailSendGridConfig {
this.templates = templates;
}
@PostConstruct
public void build() {
public EmailSendGridConfig build() {
log.info("--- Email SendGrid connector config ---");
log.info("API key configured?: {}", StringUtils.isNotBlank(api.getKey()));
log.info("Identity: {}", GsonUtil.build().toJson(identity));
log.info("Templates: {}", GsonUtil.build().toJson(templates));
return this;
}
}

View File

@@ -27,7 +27,6 @@ import io.kamax.mxisd.threepid.notification.phone.PhoneNotificationHandler;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import javax.annotation.PostConstruct;
import java.util.HashMap;
import java.util.Map;
@@ -59,7 +58,6 @@ public class NotificationConfig {
this.handlers = handlers;
}
@PostConstruct
public void build() {
log.info("--- Notification config ---");
log.info("Handlers:");

View File

@@ -23,7 +23,6 @@ package io.kamax.mxisd.config.wordpress;
import io.kamax.mxisd.exception.ConfigurationException;
import org.apache.commons.lang.StringUtils;
import javax.annotation.PostConstruct;
import java.util.HashMap;
import java.util.Map;
@@ -113,7 +112,7 @@ public class WordpressConfig {
private String type = "mysql";
private String connection;
private String tablePrefix = "wp_";
private Query query;
private Query query = new Query();
public String getType() {
return type;
@@ -177,7 +176,6 @@ public class WordpressConfig {
this.sql = sql;
}
@PostConstruct
public void build() {
if (!isEnabled()) {
return;

View File

@@ -55,7 +55,7 @@ public class EmailSendGridNotificationHandler extends PlaceholderNotificationGen
public EmailSendGridNotificationHandler(MxisdConfig mCfg, EmailSendGridConfig cfg) {
super(mCfg.getMatrix(), mCfg.getServer());
this.cfg = cfg;
this.cfg = cfg.build();
this.sendgrid = new SendGrid(cfg.getApi().getKey());
}

View File

@@ -1,19 +0,0 @@
logging:
level:
org:
springframework: 'WARN'
apache:
catalina: 'WARN'
directory: 'WARN'
io.kamax.mxisd.controller.app.v1.AppServiceController: 'DEBUG'
io.kamax.mxisd.as.AppServiceHandler: 'DEBUG'
pattern:
console: '%d{yyyy-MM-dd HH:mm:ss.SSS} ${LOG_LEVEL_PATTERN:%5p} [%15.15t] %35.35logger{34} : %m%n${LOG_EXCEPTION_CONVERSION_WORD:%wEx}'
---
spring:
profiles: systemd
logging:
pattern:
console: '%d{.SSS} ${LOG_LEVEL_PATTERN:%5p} [%15.15t] %35.35logger{34} : %m%n${LOG_EXCEPTION_CONVERSION_WORD:%wEx}'