From 0a326977c7d1530e3b9c39591d058ff31830efec Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=CC=88rg=20Prante?= Date: Mon, 25 May 2020 10:26:52 +0200 Subject: [PATCH] add method for simple string/string settings, work around fragile settings.put() method in ES 2.2 --- .../org/xbib/elx/common/ClientBuilder.java | 20 +++++++++++++++++++ gradle.properties | 2 +- 2 files changed, 21 insertions(+), 1 deletion(-) diff --git a/elx-common/src/main/java/org/xbib/elx/common/ClientBuilder.java b/elx-common/src/main/java/org/xbib/elx/common/ClientBuilder.java index 6e4fca4..6816713 100644 --- a/elx-common/src/main/java/org/xbib/elx/common/ClientBuilder.java +++ b/elx-common/src/main/java/org/xbib/elx/common/ClientBuilder.java @@ -14,6 +14,7 @@ import org.xbib.elx.api.BasicClient; import org.xbib.elx.api.SearchClientProvider; import java.io.IOException; +import java.util.Map; import java.util.ServiceLoader; @SuppressWarnings("rawtypes") @@ -106,6 +107,25 @@ public class ClientBuilder { return this; } + public ClientBuilder put(Map map) { + for (Map.Entry entry : map.entrySet()) { + if (entry.getValue() == null) { + continue; + } + if (entry.getValue() instanceof String || + entry.getValue() instanceof Integer || + entry.getValue() instanceof Long || + entry.getValue() instanceof Float || + entry.getValue() instanceof TimeValue) { + settingsBuilder.put(entry.getKey(), entry.getValue().toString()); + } else { + logger.log(Level.WARN, "skipping " + entry.getValue() + + " because invalid class type " + entry.getValue().getClass().getName()); + } + } + return this; + } + @SuppressWarnings("unchecked") public C build() throws IOException { Settings settings = settingsBuilder.build(); diff --git a/gradle.properties b/gradle.properties index ee6d2fb..8df8c01 100644 --- a/gradle.properties +++ b/gradle.properties @@ -10,7 +10,7 @@ xbib-netty-http.version = 4.1.49.0 elasticsearch.version = 2.2.1 jackson.version = 2.9.10 jna.version = 4.5.2 -log4j.version = 2.12.1 +log4j.version = 2.13.1 mustache.version = 0.9.5 jts.version = 1.13 junit.version = 5.6.2