aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/at/gv/egiz/moazs/preprocess
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/java/at/gv/egiz/moazs/preprocess')
-rw-r--r--src/main/java/at/gv/egiz/moazs/preprocess/ConfigUtil.java62
1 files changed, 52 insertions, 10 deletions
diff --git a/src/main/java/at/gv/egiz/moazs/preprocess/ConfigUtil.java b/src/main/java/at/gv/egiz/moazs/preprocess/ConfigUtil.java
index 68f833e..9cdc07a 100644
--- a/src/main/java/at/gv/egiz/moazs/preprocess/ConfigUtil.java
+++ b/src/main/java/at/gv/egiz/moazs/preprocess/ConfigUtil.java
@@ -1,10 +1,7 @@
package at.gv.egiz.moazs.preprocess;
import at.gv.egiz.moazs.util.StringUtils;
-import at.gv.zustellung.app2mzs.xsd.ClientType;
-import at.gv.zustellung.app2mzs.xsd.ConfigType;
-import at.gv.zustellung.app2mzs.xsd.KeyStoreType;
-import at.gv.zustellung.app2mzs.xsd.SSLType;
+import at.gv.zustellung.app2mzs.xsd.*;
import org.springframework.stereotype.Component;
import java.math.BigInteger;
@@ -13,6 +10,7 @@ import java.util.Map;
import static at.gv.zustellung.app2mzs.xsd.ClientType.clientTypeBuilder;
import static at.gv.zustellung.app2mzs.xsd.ConfigType.configTypeBuilder;
import static at.gv.zustellung.app2mzs.xsd.KeyStoreType.keyStoreTypeBuilder;
+import static at.gv.zustellung.app2mzs.xsd.MsgResponseSinksType.msgResponseSinksTypeBuilder;
import static at.gv.zustellung.app2mzs.xsd.SSLType.SSLTypeBuilder;
import static java.util.stream.Collectors.toMap;
@@ -33,7 +31,9 @@ public class ConfigUtil {
public static final String PASSWORD_KEY = "password";
public static final String RECEIVE_TIMEOUT = "receive-timeout";
public static final String CONNECTION_TIMEOUT_KEY = "connection-timeout";
-
+ public static final String MSG_RESPONSE_SINKS_KEY = "msg-response-sinks";
+ public static final String LOG_RESPONSE_KEY = "log-response";
+ public static final String SAVE_RESPONSE_TO_FILE_KEY = "save-response-to-file";
/**
* Convert a map into a Config object.
@@ -53,10 +53,15 @@ public class ConfigUtil {
ClientType tnvzClient = tnvzClientParams.isEmpty()
? null : buildClient(tnvzClientParams);
+ var msgResponseSinksParams = filterMapByPrefix(values, MSG_RESPONSE_SINKS_KEY);
+ MsgResponseSinksType sinks = msgResponseSinksParams.isEmpty()
+ ? null : buildMsgResponseSinks(msgResponseSinksParams);
+
return ConfigType.configTypeBuilder()
.withPerformQueryPersonRequest(performQueryPersonRequest)
.withMSGClient(msgClient)
.withTNVZClient(tnvzClient)
+ .withMsgResponseSinks(sinks)
.build();
}
@@ -102,11 +107,8 @@ public class ConfigUtil {
KeyStoreType trustStore = trustStoreParams.isEmpty()
? null : buildKeyStore(trustStoreParams);
- var trustAll = sslParams.get(TRUST_ALL_KEY) == null
- ? null : Boolean.getBoolean(sslParams.get(TRUST_ALL_KEY));
-
- var laxHostNameVerification = sslParams.get(LAX_HOSTNAME_VERIFICATION_KEY) == null
- ? null : Boolean.getBoolean(sslParams.get(LAX_HOSTNAME_VERIFICATION_KEY));
+ var trustAll = booleanOrNull(sslParams.get(TRUST_ALL_KEY));
+ var laxHostNameVerification = booleanOrNull(sslParams.get(LAX_HOSTNAME_VERIFICATION_KEY));
return SSLTypeBuilder()
.withKeyStore(keyStore)
@@ -126,6 +128,22 @@ public class ConfigUtil {
.build();
}
+ private MsgResponseSinksType buildMsgResponseSinks(Map<String, String> params) {
+
+ var logResponse = booleanOrNull(params.get(LOG_RESPONSE_KEY));
+ var saveResponse = booleanOrNull(params.get(SAVE_RESPONSE_TO_FILE_KEY));
+
+ return msgResponseSinksTypeBuilder()
+ .withLogResponse(logResponse)
+ .withLogResponse(saveResponse)
+ .build();
+ }
+
+ private Boolean booleanOrNull(String value) {
+ return value == null ? null : Boolean.getBoolean(value);
+ }
+
+
/**
* Combine properties of two Configs; {@code primary} overrides {@code fallback}.
*
@@ -149,6 +167,10 @@ public class ConfigUtil {
builder.withMSGClient(merge(primary.getTNVZClient(), fallback.getTNVZClient()));
}
+ if (primary.getMsgResponseSinks() != null) {
+ builder.withMsgResponseSinks(merge(primary.getMsgResponseSinks(), fallback.getMsgResponseSinks()));
+ }
+
return builder.build();
}
@@ -214,4 +236,24 @@ public class ConfigUtil {
}
+ private MsgResponseSinksType merge(MsgResponseSinksType primary, MsgResponseSinksType fallback) {
+
+ if (fallback == null) {
+ return primary;
+ }
+
+ var builder = msgResponseSinksTypeBuilder(fallback);
+
+ if (primary.isLogResponse() != null) {
+ builder.withLogResponse(primary.isLogResponse());
+ }
+
+ if (primary.isSafeResponseToFile() != null) {
+ builder.withLogResponse(primary.isSafeResponseToFile());
+ }
+
+ return builder.build();
+ }
+
+
}