فهرست منبع

fix #1256 check type for searchField

Shinsuke Sugaya 8 سال پیش
والد
کامیت
f9a85005c3
1فایلهای تغییر یافته به همراه16 افزوده شده و 2 حذف شده
  1. 16 2
      src/main/java/org/codelibs/fess/es/log/exbhv/SearchLogBhv.java

+ 16 - 2
src/main/java/org/codelibs/fess/es/log/exbhv/SearchLogBhv.java

@@ -20,6 +20,7 @@ import java.time.LocalDateTime;
 import java.time.ZoneId;
 import java.time.format.DateTimeFormatter;
 import java.time.format.DateTimeParseException;
+import java.util.List;
 import java.util.Map;
 
 import org.codelibs.core.misc.Pair;
@@ -62,8 +63,21 @@ public class SearchLogBhv extends BsSearchLogBhv {
             final RESULT result = super.createEntity(source, entityType);
             final Object searchFieldObj = source.get("searchField");
             if (searchFieldObj instanceof Map) {
-                ((Map<String, String>) searchFieldObj).entrySet().stream()
-                        .forEach(e -> result.getSearchFieldLogList().add(new Pair(e.getKey(), e.getValue())));
+                ((Map<String, ?>) searchFieldObj).entrySet().stream().forEach(e -> {
+                    if (e.getValue() instanceof String[]) {
+                        String[] values = (String[]) e.getValue();
+                        for (final String v : values) {
+                            result.getSearchFieldLogList().add(new Pair<>(e.getKey(), v));
+                        }
+                    } else if (e.getValue() instanceof List) {
+                        List<String> values = (List<String>) e.getValue();
+                        for (final String v : values) {
+                            result.getSearchFieldLogList().add(new Pair<>(e.getKey(), v));
+                        }
+                    } else if (e.getValue() != null) {
+                        result.getSearchFieldLogList().add(new Pair<>(e.getKey(), e.getValue().toString()));
+                    }
+                });
             }
             return result;
         } catch (Exception e) {