Skip to content
Snippets Groups Projects

KOP-3139 ozgcloud abhaengigkeit entfernen

Merged Jan Zickermann requested to merge KOP-3139-ozgcloud-Abhaengigkeit-entfernen into main
2 files
+ 15
24
Compare changes
  • Side-by-side
  • Inline

Files

@@ -22,7 +22,6 @@ import jakarta.mail.util.ByteArrayDataSource;
@@ -22,7 +22,6 @@ import jakarta.mail.util.ByteArrayDataSource;
import jakarta.validation.constraints.NotBlank;
import jakarta.validation.constraints.NotBlank;
import org.apache.commons.codec.Resources;
import org.apache.commons.codec.Resources;
import org.apache.commons.collections4.MapUtils;
import org.apache.commons.io.IOUtils;
import org.apache.commons.io.IOUtils;
import org.yaml.snakeyaml.Yaml;
import org.yaml.snakeyaml.Yaml;
@@ -104,17 +103,12 @@ public class XtaMessageExampleLoader {
@@ -104,17 +103,12 @@ public class XtaMessageExampleLoader {
@Nullable XtaIdentifier reader) {
@Nullable XtaIdentifier reader) {
}
}
@SuppressWarnings("unchecked")
private static Map<String, Object> getChild(Map<String, Object> parent, String key) {
return Objects.requireNonNull((Map<String, Object>) MapUtils.getMap(parent, key), "Missing key: %s".formatted(key));
}
private static XtaFile mapXtaFile(
private static XtaFile mapXtaFile(
Map<String, Object> messageFile,
Map<String, Object> messageFile,
String resourcePrefix,
String resourcePrefix,
MessageFileProcessor messageFileProcessor) {
MessageFileProcessor messageFileProcessor) {
Function<String, String> getString = key -> Objects.requireNonNull(
Function<String, String> getString = key -> Objects.requireNonNull(
MapUtils.getString(messageFile, key), "[Failed mapping for %s] Missing key: %s".formatted(resourcePrefix, key));
getChildString(messageFile, key), "[Failed mapping for %s] Missing key: %s".formatted(resourcePrefix, key));
var name = getString.apply("name");
var name = getString.apply("name");
var path = getMessageResourcePath(resourcePrefix, name);
var path = getMessageResourcePath(resourcePrefix, name);
@@ -126,7 +120,7 @@ public class XtaMessageExampleLoader {
@@ -126,7 +120,7 @@ public class XtaMessageExampleLoader {
.name(name)
.name(name)
.contentType(getString.apply("contentType"))
.contentType(getString.apply("contentType"))
.content(createContentDataHandler(data))
.content(createContentDataHandler(data))
.id(MapUtils.getString(messageFile, "id"))
.id(getChildString(messageFile, "id"))
.build();
.build();
}
}
@@ -138,7 +132,7 @@ public class XtaMessageExampleLoader {
@@ -138,7 +132,7 @@ public class XtaMessageExampleLoader {
private static XtaMessageMetaData mapXtaMessageMetadata(Map<String, Object> metaData, MessageExampleConfig config) {
private static XtaMessageMetaData mapXtaMessageMetadata(Map<String, Object> metaData, MessageExampleConfig config) {
Function<String, String> getString = key -> Objects.requireNonNull(
Function<String, String> getString = key -> Objects.requireNonNull(
MapUtils.getString(metaData, key), "metaData key missing: %s".formatted(key));
getChildString(metaData, key), "metaData key missing: %s".formatted(key));
return XtaMessageMetaData.builder()
return XtaMessageMetaData.builder()
.service(getString.apply("service"))
.service(getString.apply("service"))
.businessScenarioCode(getString.apply("businessScenarioCode"))
.businessScenarioCode(getString.apply("businessScenarioCode"))
@@ -147,7 +141,7 @@ public class XtaMessageExampleLoader {
@@ -147,7 +141,7 @@ public class XtaMessageExampleLoader {
.messageTypeCode(getString.apply("messageTypeCode"))
.messageTypeCode(getString.apply("messageTypeCode"))
.messageTypePayloadSchema(getString.apply("messageTypePayloadSchema"))
.messageTypePayloadSchema(getString.apply("messageTypePayloadSchema"))
.messageId(getIfConfigNull(
.messageId(getIfConfigNull(
config.messageId, () -> MapUtils.getString(metaData, "messageId")))
config.messageId, () -> getChildString(metaData, "messageId")))
.authorIdentifier(getIfConfigNull(
.authorIdentifier(getIfConfigNull(
config.author,
config.author,
() -> mapIdentifier(getChild(metaData, "authorIdentifier"))))
() -> mapIdentifier(getChild(metaData, "authorIdentifier"))))
@@ -157,6 +151,17 @@ public class XtaMessageExampleLoader {
@@ -157,6 +151,17 @@ public class XtaMessageExampleLoader {
.build();
.build();
}
}
 
@SuppressWarnings("unchecked")
 
private static Map<String, Object> getChild(Map<String, Object> parent, String key) {
 
return Objects.requireNonNull((Map<String, Object>) parent.get(key), "Missing key: %s".formatted(key));
 
}
 
 
private static String getChildString(Map<String, Object> parent, String key) {
 
return Optional.ofNullable(parent.get(key))
 
.map(Object::toString)
 
.orElse(null);
 
}
 
private static <T> T getIfConfigNull(T configValue, Supplier<T> supplier) {
private static <T> T getIfConfigNull(T configValue, Supplier<T> supplier) {
return configValue != null ? configValue : supplier.get();
return configValue != null ? configValue : supplier.get();
}
}
Loading