Skip to content

Commit

Permalink
#2848 Refactor code: reverted to an if statement.
Browse files Browse the repository at this point in the history
  • Loading branch information
marevol committed Oct 12, 2024
1 parent 62d89fb commit 265bbda
Show file tree
Hide file tree
Showing 10 changed files with 108 additions and 154 deletions.
20 changes: 11 additions & 9 deletions src/main/java/org/codelibs/fess/api/json/SearchApiManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -120,8 +120,7 @@ protected FormatType detectFormatType(final HttpServletRequest request) {
return FormatType.SEARCH;
}
final String type = value.toLowerCase(Locale.ROOT);
switch (type) {
case "documents":
if ("documents".equals(type)) {
if (values.length > 5 && "favorite".equals(values[5])) {
request.setAttribute(DOC_ID_FIELD, values[4]);
return FormatType.FAVORITE;
Expand All @@ -130,18 +129,21 @@ protected FormatType detectFormatType(final HttpServletRequest request) {
return FormatType.SCROLL;
}
return FormatType.SEARCH;
case "labels":
}
if ("labels".equals(type)) {
return FormatType.LABEL;
case "popular-words":
}
if ("popular-words".equals(type)) {
return FormatType.POPULARWORD;
case "favorites":
}
if ("favorites".equals(type)) {
return FormatType.FAVORITES;
case "health":
}
if ("health".equals(type)) {
return FormatType.PING;
case "suggest-words":
}
if ("suggest-words".equals(type)) {
return FormatType.SUGGEST;
default:
break;
}
// default
return FormatType.OTHER;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -319,17 +319,17 @@ public ActionResponse download(final String id) {
}
if (id.endsWith(NDJSON_EXTENTION)) {
final String name = id.substring(0, id.length() - NDJSON_EXTENTION.length());
switch (name) {
case "search_log":
if ("search_log".equals(name)) {
return writeNdjsonResponse(id, getSearchLogNdjsonWriteCall());
case "user_info":
}
if ("user_info".equals(name)) {
return writeNdjsonResponse(id, getUserInfoNdjsonWriteCall());
case "click_log":
}
if ("click_log".equals(name)) {
return writeNdjsonResponse(id, getClickLogNdjsonWriteCall());
case "favorite_log":
}
if ("favorite_log".equals(name)) {
return writeNdjsonResponse(id, getFavoriteLogNdjsonWriteCall());
default:
break;
}
} else if ("fess.json".equals(id)) {
return asStream(id).contentTypeOctetStream().stream(out -> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -144,18 +144,12 @@ public HtmlResponse createnewjob(final String type, final String id, final Strin
final String decodedName = new String(Base64.getUrlDecoder().decode(name), Constants.CHARSET_UTF_8);
scheduledJobForm.name = MessageFormat.format(fessConfig.getJobTemplateTitle(type), decodedName);
final String[] ids = { "", "", "" };
switch (type) {
case Constants.WEB_CRAWLER_TYPE:
if (Constants.WEB_CRAWLER_TYPE.equals(type)) {
ids[0] = "\"" + id + "\"";
break;
case Constants.FILE_CRAWLER_TYPE:
} else if (Constants.FILE_CRAWLER_TYPE.equals(type)) {
ids[1] = "\"" + id + "\"";
break;
case Constants.DATA_CRAWLER_TYPE:
} else if (Constants.DATA_CRAWLER_TYPE.equals(type)) {
ids[2] = "\"" + id + "\"";
break;
default:
break;
}
scheduledJobForm.scriptData =
MessageFormat.format(fessConfig.getJobTemplateScript(), ids[0], ids[1], ids[2], id.replace('-', '_'));
Expand Down
Loading

0 comments on commit 265bbda

Please sign in to comment.