Shinsuke Sugaya 2 rokov pred
rodič
commit
f78d99328a

+ 28 - 22
src/main/java/org/codelibs/fess/api/BaseApiManager.java

@@ -68,29 +68,35 @@ public abstract class BaseApiManager implements WebApiManager {
         }
         if (value == null) {
             return FormatType.SEARCH;
-        } else {
-            final String type = value.toUpperCase(Locale.ROOT);
-            if (FormatType.SEARCH.name().equals(type)) {
-                return FormatType.SEARCH;
-            } else if (FormatType.LABEL.name().equals(type)) {
-                return FormatType.LABEL;
-            } else if (FormatType.POPULARWORD.name().equals(type)) {
-                return FormatType.POPULARWORD;
-            } else if (FormatType.FAVORITE.name().equals(type)) {
-                return FormatType.FAVORITE;
-            } else if (FormatType.FAVORITES.name().equals(type)) {
-                return FormatType.FAVORITES;
-            } else if (FormatType.PING.name().equals(type)) {
-                return FormatType.PING;
-            } else if (FormatType.SCROLL.name().equals(type)) {
-                return FormatType.SCROLL;
-            } else if (FormatType.SUGGEST.name().equals(type)) {
-                return FormatType.SUGGEST;
-            } else {
-                // default
-                return FormatType.OTHER;
-            }
         }
+        final String type = value.toUpperCase(Locale.ROOT);
+        if (FormatType.SEARCH.name().equals(type)) {
+            return FormatType.SEARCH;
+        }
+        if (FormatType.LABEL.name().equals(type)) {
+            return FormatType.LABEL;
+        }
+        if (FormatType.POPULARWORD.name().equals(type)) {
+            return FormatType.POPULARWORD;
+        }
+        if (FormatType.FAVORITE.name().equals(type)) {
+            return FormatType.FAVORITE;
+        }
+        if (FormatType.FAVORITES.name().equals(type)) {
+            return FormatType.FAVORITES;
+        }
+        if (FormatType.PING.name().equals(type)) {
+            return FormatType.PING;
+        }
+        if (FormatType.SCROLL.name().equals(type)) {
+            return FormatType.SCROLL;
+        }
+        if (FormatType.SUGGEST.name().equals(type)) {
+            return FormatType.SUGGEST;
+        }
+
+        // default
+        return FormatType.OTHER;
     }
 
     protected void write(final String text, final String contentType, final String encoding) {

+ 15 - 10
src/main/java/org/codelibs/fess/api/json/SearchApiManager.java

@@ -127,22 +127,27 @@ public class SearchApiManager extends BaseApiManager {
             }
             // return FormatType.SCROLL;
             return FormatType.SEARCH;
-        } else if ("labels".equals(type)) {
+        }
+        if ("labels".equals(type)) {
             return FormatType.LABEL;
-        } else if ("popular-words".equals(type)) {
+        }
+        if ("popular-words".equals(type)) {
             return FormatType.POPULARWORD;
-        } else if ("favorites".equals(type)) {
+        }
+        if ("favorites".equals(type)) {
             return FormatType.FAVORITES;
-        } else if ("health".equals(type)) {
+        }
+        if ("health".equals(type)) {
             return FormatType.PING;
-        } else if ("suggest-words".equals(type)) {
+        }
+        if ("suggest-words".equals(type)) {
             return FormatType.SUGGEST;
-        } else if ("scroll".equals(type)) {
+        }
+        if ("scroll".equals(type)) {
             return FormatType.SCROLL;
-        } else {
-            // default
-            return FormatType.OTHER;
         }
+        // default
+        return FormatType.OTHER;
     }
 
     @Override
@@ -192,7 +197,7 @@ public class SearchApiManager extends BaseApiManager {
 
     protected boolean acceptHttpMethod(final HttpServletRequest request, final String... methods) {
         final String method = request.getMethod();
-        for (String m : methods) {
+        for (final String m : methods) {
             if (m.equals(method)) {
                 return true;
             }

+ 1 - 1
src/main/java/org/codelibs/fess/es/client/SearchEngineClient.java

@@ -1211,7 +1211,7 @@ public class SearchEngineClient implements Client {
             throw new SearchEngineClientException(response.buildFailureMessage());
         }
 
-        return Arrays.stream(response.getItems()).map(res -> res.getId()).toArray(n -> new String[n]);
+        return Arrays.stream(response.getItems()).map(BulkItemResponse::getId).toArray(n -> new String[n]);
     }
 
     public static class SearchConditionBuilder {

+ 4 - 4
src/main/java/org/codelibs/fess/helper/ActivityHelper.java

@@ -82,7 +82,7 @@ public class ActivityHelper {
         valueMap.put("action", Action.LOGIN_FAILURE.name());
         credential.ifPresent(c -> {
             valueMap.put("class", c.getClass().getSimpleName());
-            if (c instanceof FessCredential fessCredential) {
+            if (c instanceof final FessCredential fessCredential) {
                 valueMap.put("user", fessCredential.getUserId());
             }
         });
@@ -177,15 +177,15 @@ public class ActivityHelper {
         this.permissionSeparator = permissionSeparator;
     }
 
-    public void setEcsVersion(String ecsVersion) {
+    public void setEcsVersion(final String ecsVersion) {
         this.ecsVersion = ecsVersion;
     }
 
-    public void setEcsServiceName(String ecsServiceName) {
+    public void setEcsServiceName(final String ecsServiceName) {
         this.ecsServiceName = ecsServiceName;
     }
 
-    public void setEcsEventDataset(String ecsEventDataset) {
+    public void setEcsEventDataset(final String ecsEventDataset) {
         this.ecsEventDataset = ecsEventDataset;
     }
 }

+ 1 - 1
src/main/java/org/codelibs/fess/helper/SuggestHelper.java

@@ -398,7 +398,7 @@ public class SuggestHelper {
         }
     }
 
-    public void setSearchStoreInterval(long searchStoreInterval) {
+    public void setSearchStoreInterval(final long searchStoreInterval) {
         this.searchStoreInterval = searchStoreInterval;
     }
 }

+ 1 - 1
src/main/java/org/codelibs/fess/thumbnail/ThumbnailManager.java

@@ -543,7 +543,7 @@ public class ThumbnailManager {
         this.noImageExpired = noImageExpired;
     }
 
-    public void setSplitHashSize(int splitHashSize) {
+    public void setSplitHashSize(final int splitHashSize) {
         this.splitHashSize = splitHashSize;
     }
 

+ 1 - 1
src/main/java/org/codelibs/fess/thumbnail/impl/BaseThumbnailGenerator.java

@@ -84,7 +84,7 @@ public abstract class BaseThumbnailGenerator implements ThumbnailGenerator {
             return false;
         }
         for (final Map.Entry<String, String> entry : conditionMap.entrySet()) {
-            if (docMap.get(entry.getKey()) instanceof String value && value.matches(entry.getValue())) {
+            if (docMap.get(entry.getKey()) instanceof final String value && value.matches(entry.getValue())) {
                 if (logger.isDebugEnabled()) {
                     logger.debug("[{}] match {}:{}", entry.getKey(), name, value);
                 }

+ 1 - 1
src/main/java/org/codelibs/fess/util/SearchEngineUtil.java

@@ -63,7 +63,7 @@ public final class SearchEngineUtil {
     public static String getXContentString(final ToXContent xContent, final XContentType xContentType) {
         try {
             return XContentHelper.toXContent(xContent, xContentType, ToXContent.EMPTY_PARAMS, false).utf8ToString();
-        } catch (IOException e) {
+        } catch (final IOException e) {
             throw new IORuntimeException(e);
         }
     }