code cleanup
This commit is contained in:
parent
62325bfbe5
commit
f78d99328a
8 changed files with 58 additions and 47 deletions
|
@ -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) {
|
||||
|
|
|
@ -127,22 +127,27 @@ public class SearchApiManager extends BaseApiManager {
|
|||
}
|
||||
// return FormatType.SCROLL;
|
||||
return FormatType.SEARCH;
|
||||
} else if ("labels".equals(type)) {
|
||||
return FormatType.LABEL;
|
||||
} else if ("popular-words".equals(type)) {
|
||||
return FormatType.POPULARWORD;
|
||||
} else if ("favorites".equals(type)) {
|
||||
return FormatType.FAVORITES;
|
||||
} else if ("health".equals(type)) {
|
||||
return FormatType.PING;
|
||||
} else if ("suggest-words".equals(type)) {
|
||||
return FormatType.SUGGEST;
|
||||
} else if ("scroll".equals(type)) {
|
||||
return FormatType.SCROLL;
|
||||
} else {
|
||||
// default
|
||||
return FormatType.OTHER;
|
||||
}
|
||||
if ("labels".equals(type)) {
|
||||
return FormatType.LABEL;
|
||||
}
|
||||
if ("popular-words".equals(type)) {
|
||||
return FormatType.POPULARWORD;
|
||||
}
|
||||
if ("favorites".equals(type)) {
|
||||
return FormatType.FAVORITES;
|
||||
}
|
||||
if ("health".equals(type)) {
|
||||
return FormatType.PING;
|
||||
}
|
||||
if ("suggest-words".equals(type)) {
|
||||
return FormatType.SUGGEST;
|
||||
}
|
||||
if ("scroll".equals(type)) {
|
||||
return FormatType.SCROLL;
|
||||
}
|
||||
// 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;
|
||||
}
|
||||
|
|
|
@ -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 {
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -398,7 +398,7 @@ public class SuggestHelper {
|
|||
}
|
||||
}
|
||||
|
||||
public void setSearchStoreInterval(long searchStoreInterval) {
|
||||
public void setSearchStoreInterval(final long searchStoreInterval) {
|
||||
this.searchStoreInterval = searchStoreInterval;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -543,7 +543,7 @@ public class ThumbnailManager {
|
|||
this.noImageExpired = noImageExpired;
|
||||
}
|
||||
|
||||
public void setSplitHashSize(int splitHashSize) {
|
||||
public void setSplitHashSize(final int splitHashSize) {
|
||||
this.splitHashSize = splitHashSize;
|
||||
}
|
||||
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue