code clean-up
This commit is contained in:
parent
234765e873
commit
5357b3a8cb
22 changed files with 54 additions and 53 deletions
|
@ -137,7 +137,7 @@ public class AdminBackupAction extends FessAdminAction {
|
|||
}
|
||||
});
|
||||
} else if (id.endsWith(CSV_EXTENTION)) {
|
||||
String name = id.substring(0, id.length() - CSV_EXTENTION.length());
|
||||
final String name = id.substring(0, id.length() - CSV_EXTENTION.length());
|
||||
if ("search_log".equals(name)) {
|
||||
return writeSearchLogCsvResponse(id);
|
||||
} else if ("search_field_log".equals(name)) {
|
||||
|
@ -222,14 +222,14 @@ public class AdminBackupAction extends FessAdminAction {
|
|||
addToList(entity.getRequestedAt(), list);
|
||||
try {
|
||||
writer.writeValues(list);
|
||||
} catch (IOException e) {
|
||||
} catch (final IOException e) {
|
||||
throw new RuntimeIOException(e);
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
private StreamResponse writeUserInfoCsvResponse(String id) {
|
||||
private StreamResponse writeUserInfoCsvResponse(final String id) {
|
||||
return writeCsvResponse(id, writer -> {
|
||||
final UserInfoBhv bhv = ComponentUtil.getComponent(UserInfoBhv.class);
|
||||
bhv.selectCursor(cb -> {
|
||||
|
@ -241,14 +241,14 @@ public class AdminBackupAction extends FessAdminAction {
|
|||
addToList(entity.getUpdatedAt(), list);
|
||||
try {
|
||||
writer.writeValues(list);
|
||||
} catch (IOException e) {
|
||||
} catch (final IOException e) {
|
||||
throw new RuntimeIOException(e);
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
private StreamResponse writeFavoriteLogCsvResponse(String id) {
|
||||
private StreamResponse writeFavoriteLogCsvResponse(final String id) {
|
||||
return writeCsvResponse(id, writer -> {
|
||||
final FavoriteLogBhv bhv = ComponentUtil.getComponent(FavoriteLogBhv.class);
|
||||
bhv.selectCursor(cb -> {
|
||||
|
@ -263,14 +263,14 @@ public class AdminBackupAction extends FessAdminAction {
|
|||
addToList(entity.getCreatedAt(), list);
|
||||
try {
|
||||
writer.writeValues(list);
|
||||
} catch (IOException e) {
|
||||
} catch (final IOException e) {
|
||||
throw new RuntimeIOException(e);
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
private StreamResponse writeClickLogCsvResponse(String id) {
|
||||
private StreamResponse writeClickLogCsvResponse(final String id) {
|
||||
return writeCsvResponse(id, writer -> {
|
||||
final ClickLogBhv bhv = ComponentUtil.getComponent(ClickLogBhv.class);
|
||||
bhv.selectCursor(cb -> {
|
||||
|
@ -287,14 +287,14 @@ public class AdminBackupAction extends FessAdminAction {
|
|||
addToList(entity.getRequestedAt(), list);
|
||||
try {
|
||||
writer.writeValues(list);
|
||||
} catch (IOException e) {
|
||||
} catch (final IOException e) {
|
||||
throw new RuntimeIOException(e);
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
private StreamResponse writeSearchFieldLogCsvResponse(String id) {
|
||||
private StreamResponse writeSearchFieldLogCsvResponse(final String id) {
|
||||
return writeCsvResponse(id, writer -> {
|
||||
final SearchFieldLogBhv bhv = ComponentUtil.getComponent(SearchFieldLogBhv.class);
|
||||
bhv.selectCursor(cb -> {
|
||||
|
@ -307,7 +307,7 @@ public class AdminBackupAction extends FessAdminAction {
|
|||
addToList(entity.getValue(), list);
|
||||
try {
|
||||
writer.writeValues(list);
|
||||
} catch (IOException e) {
|
||||
} catch (final IOException e) {
|
||||
throw new RuntimeIOException(e);
|
||||
}
|
||||
});
|
||||
|
|
|
@ -242,7 +242,7 @@ public class AdminFileauthAction extends FessAdminAction {
|
|||
//===================================================================================
|
||||
// Assist Logic
|
||||
// ============
|
||||
static public OptionalEntity<FileAuthentication> getEntity(final CreateForm form, final String username, final long currentTime) {
|
||||
public static OptionalEntity<FileAuthentication> getEntity(final CreateForm form, final String username, final long currentTime) {
|
||||
switch (form.crudMode) {
|
||||
case CrudMode.CREATE:
|
||||
return OptionalEntity.of(new FileAuthentication()).map(entity -> {
|
||||
|
@ -261,7 +261,7 @@ public class AdminFileauthAction extends FessAdminAction {
|
|||
return OptionalEntity.empty();
|
||||
}
|
||||
|
||||
static public OptionalEntity<FileAuthentication> getFileAuthentication(final CreateForm form) {
|
||||
public static OptionalEntity<FileAuthentication> getFileAuthentication(final CreateForm form) {
|
||||
final SystemHelper systemHelper = ComponentUtil.getSystemHelper();
|
||||
final String username = systemHelper.getUsername();
|
||||
final long currentTime = systemHelper.getCurrentTimeAsLong();
|
||||
|
|
|
@ -240,7 +240,7 @@ public class AdminReqheaderAction extends FessAdminAction {
|
|||
// ===================================================================================
|
||||
// Assist Logic
|
||||
// ============
|
||||
static public OptionalEntity<RequestHeader> getEntity(final CreateForm form, final String username, final long currentTime) {
|
||||
public static OptionalEntity<RequestHeader> getEntity(final CreateForm form, final String username, final long currentTime) {
|
||||
switch (form.crudMode) {
|
||||
case CrudMode.CREATE:
|
||||
return OptionalEntity.of(new RequestHeader()).map(entity -> {
|
||||
|
@ -259,7 +259,7 @@ public class AdminReqheaderAction extends FessAdminAction {
|
|||
return OptionalEntity.empty();
|
||||
}
|
||||
|
||||
static public OptionalEntity<RequestHeader> getRequestHeader(final CreateForm form) {
|
||||
public static OptionalEntity<RequestHeader> getRequestHeader(final CreateForm form) {
|
||||
final SystemHelper systemHelper = ComponentUtil.getSystemHelper();
|
||||
final String username = systemHelper.getUsername();
|
||||
final long currentTime = systemHelper.getCurrentTimeAsLong();
|
||||
|
|
|
@ -61,8 +61,8 @@ public class ApiAdminCrawlinginfoAction extends FessApiAdminAction {
|
|||
copyBeanToBean(body, pager, op -> op.exclude(Constants.PAGER_CONVERSION_RULE));
|
||||
final List<CrawlingInfo> list = crawlingInfoService.getCrawlingInfoList(pager);
|
||||
return asJson(new ApiResult.ApiLogsResponse<EditBody>()
|
||||
.logs(list.stream().map(entity -> createEditBody(entity)).collect(Collectors.toList()))
|
||||
.total(pager.getAllRecordCount()).status(ApiResult.Status.OK).result());
|
||||
.logs(list.stream().map(entity -> createEditBody(entity)).collect(Collectors.toList())).total(pager.getAllRecordCount())
|
||||
.status(ApiResult.Status.OK).result());
|
||||
}
|
||||
|
||||
// GET /api/admin/crawlinginfo/log/{id}
|
||||
|
|
|
@ -43,7 +43,7 @@ public class ApiAdminDictAction extends FessApiAdminAction {
|
|||
.status(ApiResult.Status.OK).result());
|
||||
}
|
||||
|
||||
protected ListBody createListBody(DictionaryFile<? extends DictionaryItem> dictionaryFile) {
|
||||
protected ListBody createListBody(final DictionaryFile<? extends DictionaryItem> dictionaryFile) {
|
||||
final ListBody body = new ListBody();
|
||||
body.id = dictionaryFile.getId();
|
||||
body.type = dictionaryFile.getType();
|
||||
|
|
|
@ -45,7 +45,7 @@ public class ApiAdminDictKuromojiAction extends FessApiAdminAction {
|
|||
public JsonResponse<ApiResult> get$settings(final String dictId, final SearchBody body) {
|
||||
body.dictId = dictId;
|
||||
validateApi(body, messages -> {});
|
||||
KuromojiPager pager = new KuromojiPager();
|
||||
final KuromojiPager pager = new KuromojiPager();
|
||||
if (body.pageNumber != null) {
|
||||
pager.setCurrentPageNumber(body.pageNumber);
|
||||
}
|
||||
|
|
|
@ -44,7 +44,7 @@ public class ApiAdminDictMappingAction extends FessApiAdminAction {
|
|||
public JsonResponse<ApiResult> get$settings(final String dictId, final SearchBody body) {
|
||||
body.dictId = dictId;
|
||||
validateApi(body, messages -> {});
|
||||
CharMappingPager pager = new CharMappingPager();
|
||||
final CharMappingPager pager = new CharMappingPager();
|
||||
if (body.pageNumber != null) {
|
||||
pager.setCurrentPageNumber(body.pageNumber);
|
||||
}
|
||||
|
|
|
@ -44,7 +44,7 @@ public class ApiAdminDictSeunjeonAction extends FessApiAdminAction {
|
|||
public JsonResponse<ApiResult> get$settings(final String dictId, final SearchBody body) {
|
||||
body.dictId = dictId;
|
||||
validateApi(body, messages -> {});
|
||||
SeunjeonPager pager = new SeunjeonPager();
|
||||
final SeunjeonPager pager = new SeunjeonPager();
|
||||
if (body.pageNumber != null) {
|
||||
pager.setCurrentPageNumber(body.pageNumber);
|
||||
}
|
||||
|
|
|
@ -44,7 +44,7 @@ public class ApiAdminDictSynonymAction extends FessApiAdminAction {
|
|||
public JsonResponse<ApiResult> get$settings(final String dictId, final SearchBody body) {
|
||||
body.dictId = dictId;
|
||||
validateApi(body, messages -> {});
|
||||
SynonymPager pager = new SynonymPager();
|
||||
final SynonymPager pager = new SynonymPager();
|
||||
if (body.pageNumber != null) {
|
||||
pager.setCurrentPageNumber(body.pageNumber);
|
||||
}
|
||||
|
|
|
@ -74,7 +74,7 @@ public class ApiAdminElevatewordAction extends FessApiAdminAction {
|
|||
@Execute
|
||||
public JsonResponse<ApiResult> get$setting(final String id) {
|
||||
|
||||
ElevateWord entity = elevateWordService.getElevateWord(id).orElseGet(() -> {
|
||||
final ElevateWord entity = elevateWordService.getElevateWord(id).orElseGet(() -> {
|
||||
throwValidationErrorApi(messages -> messages.addErrorsCrudCouldNotFindCrudTable(GLOBAL, id));
|
||||
return null;
|
||||
});
|
||||
|
|
|
@ -61,18 +61,17 @@ public class ApiAdminFailureurlAction extends FessApiAdminAction {
|
|||
copyBeanToBean(body, pager, op -> op.exclude(Constants.PAGER_CONVERSION_RULE));
|
||||
final List<FailureUrl> list = failureUrlService.getFailureUrlList(pager);
|
||||
return asJson(new ApiResult.ApiLogsResponse<EditBody>()
|
||||
.logs(list.stream().map(entity -> createEditBody(entity)).collect(Collectors.toList()))
|
||||
.total(pager.getAllRecordCount()).status(ApiResult.Status.OK).result());
|
||||
.logs(list.stream().map(entity -> createEditBody(entity)).collect(Collectors.toList())).total(pager.getAllRecordCount())
|
||||
.status(ApiResult.Status.OK).result());
|
||||
}
|
||||
|
||||
// GET /api/admin/failureurl/log/{id}
|
||||
@Execute
|
||||
public JsonResponse<ApiResult> get$log(final String id) {
|
||||
return asJson(new ApiLogResponse()
|
||||
.log(failureUrlService.getFailureUrl(id).map(entity -> createEditBody(entity)).orElseGet(() -> {
|
||||
throwValidationErrorApi(messages -> messages.addErrorsCrudCouldNotFindCrudTable(GLOBAL, id));
|
||||
return null;
|
||||
})).status(Status.OK).result());
|
||||
return asJson(new ApiLogResponse().log(failureUrlService.getFailureUrl(id).map(entity -> createEditBody(entity)).orElseGet(() -> {
|
||||
throwValidationErrorApi(messages -> messages.addErrorsCrudCouldNotFindCrudTable(GLOBAL, id));
|
||||
return null;
|
||||
})).status(Status.OK).result());
|
||||
}
|
||||
|
||||
// DELETE /api/admin/failureurl/log/{id}
|
||||
|
|
|
@ -145,7 +145,7 @@ public class ApiAdminFileauthAction extends FessApiAdminAction {
|
|||
return body;
|
||||
}
|
||||
|
||||
protected Boolean isValidFileConfigId(String fileconfigId) {
|
||||
protected Boolean isValidFileConfigId(final String fileconfigId) {
|
||||
return fileConfigService.getFileConfig(fileconfigId).isPresent();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -45,7 +45,7 @@ public class ApiAdminLogAction extends FessApiAdminAction {
|
|||
// GET /api/admin/log/logfiles
|
||||
@Execute
|
||||
public JsonResponse<ApiResult> logfiles() {
|
||||
List<Map<String, Object>> list = getLogFileItems();
|
||||
final List<Map<String, Object>> list = getLogFileItems();
|
||||
return asJson(new ApiResult.ApiLogFilesResponse().logfiles(list).total(list.size()).status(ApiResult.Status.OK).result());
|
||||
}
|
||||
|
||||
|
|
|
@ -145,7 +145,7 @@ public class ApiAdminReqheaderAction extends FessApiAdminAction {
|
|||
return body;
|
||||
}
|
||||
|
||||
protected Boolean isValidWebConfigId(String webconfigId) {
|
||||
protected Boolean isValidWebConfigId(final String webconfigId) {
|
||||
return webConfigService.getWebConfig(webconfigId).isPresent();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -145,7 +145,7 @@ public class ApiAdminWebauthAction extends FessApiAdminAction {
|
|||
return body;
|
||||
}
|
||||
|
||||
protected Boolean isValidWebConfigId(String webconfigId) {
|
||||
protected Boolean isValidWebConfigId(final String webconfigId) {
|
||||
return webConfigService.getWebConfig(webconfigId).isPresent();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -96,7 +96,7 @@ public class CommandChain implements AuthenticationChain {
|
|||
logger.info("Command: " + String.join(" ", commands));
|
||||
}
|
||||
|
||||
final ProcessBuilder pb = new ProcessBuilder((String[]) stream(commands).get(stream -> stream.map(s -> {
|
||||
final String[] cmds = stream(commands).get(stream -> stream.map(s -> {
|
||||
if ("$USERNAME".equals(s)) {
|
||||
return username;
|
||||
} else if ("$PASSWORD".equals(s)) {
|
||||
|
@ -104,7 +104,8 @@ public class CommandChain implements AuthenticationChain {
|
|||
} else {
|
||||
return s;
|
||||
}
|
||||
}).toArray(n -> new String[n])));
|
||||
}).toArray(n -> new String[n]));
|
||||
final ProcessBuilder pb = new ProcessBuilder(cmds);
|
||||
if (workingDirectory != null) {
|
||||
pb.directory(workingDirectory);
|
||||
}
|
||||
|
|
|
@ -32,7 +32,7 @@ public class LdapChain implements AuthenticationChain {
|
|||
|
||||
@Override
|
||||
public boolean changePassword(final String username, final String password) {
|
||||
boolean changed = ComponentUtil.getLdapManager().changePassword(username, password);
|
||||
final boolean changed = ComponentUtil.getLdapManager().changePassword(username, password);
|
||||
return !changed || ComponentUtil.getFessConfig().isLdapAdminSyncPassword();
|
||||
}
|
||||
|
||||
|
|
|
@ -19,11 +19,11 @@ public class CommandExecutionException extends FessSystemException {
|
|||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
public CommandExecutionException(String message) {
|
||||
public CommandExecutionException(final String message) {
|
||||
super(message);
|
||||
}
|
||||
|
||||
public CommandExecutionException(String message, Throwable e) {
|
||||
public CommandExecutionException(final String message, final Throwable e) {
|
||||
super(message, e);
|
||||
}
|
||||
|
||||
|
|
|
@ -172,27 +172,27 @@ public class DocumentHelper {
|
|||
}
|
||||
}
|
||||
|
||||
public String decodeSimilarDocHash(String hash) {
|
||||
public String decodeSimilarDocHash(final String hash) {
|
||||
if (hash != null && hash.startsWith(SIMILAR_DOC_HASH_PREFIX) && hash.length() > SIMILAR_DOC_HASH_PREFIX.length()) {
|
||||
byte[] decode = Base64.getUrlDecoder().decode(hash.substring(SIMILAR_DOC_HASH_PREFIX.length()));
|
||||
final byte[] decode = Base64.getUrlDecoder().decode(hash.substring(SIMILAR_DOC_HASH_PREFIX.length()));
|
||||
try (BufferedReader reader =
|
||||
new BufferedReader(new InputStreamReader(new GZIPInputStream(new ByteArrayInputStream(decode)), Constants.UTF_8))) {
|
||||
return ReaderUtil.readText(reader);
|
||||
} catch (IOException e) {
|
||||
} catch (final IOException e) {
|
||||
logger.warn("Failed to decode " + hash, e);
|
||||
}
|
||||
}
|
||||
return hash;
|
||||
}
|
||||
|
||||
public String encodeSimilarDocHash(String hash) {
|
||||
public String encodeSimilarDocHash(final String hash) {
|
||||
if (hash != null && !hash.startsWith(SIMILAR_DOC_HASH_PREFIX)) {
|
||||
try (ByteArrayOutputStream baos = new ByteArrayOutputStream()) {
|
||||
try (GZIPOutputStream gos = new GZIPOutputStream(baos)) {
|
||||
gos.write(hash.getBytes(Constants.UTF_8));
|
||||
}
|
||||
return SIMILAR_DOC_HASH_PREFIX + Base64.getUrlEncoder().withoutPadding().encodeToString(baos.toByteArray());
|
||||
} catch (IOException e) {
|
||||
} catch (final IOException e) {
|
||||
logger.warn("Failed to encode " + hash, e);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -214,27 +214,27 @@ public class UserInfoHelper {
|
|||
return resultDocIdsCache;
|
||||
}
|
||||
|
||||
public void setResultDocIdsCacheSize(int resultDocIdsCacheSize) {
|
||||
public void setResultDocIdsCacheSize(final int resultDocIdsCacheSize) {
|
||||
this.resultDocIdsCacheSize = resultDocIdsCacheSize;
|
||||
}
|
||||
|
||||
public void setCookieName(String cookieName) {
|
||||
public void setCookieName(final String cookieName) {
|
||||
this.cookieName = cookieName;
|
||||
}
|
||||
|
||||
public void setCookieDomain(String cookieDomain) {
|
||||
public void setCookieDomain(final String cookieDomain) {
|
||||
this.cookieDomain = cookieDomain;
|
||||
}
|
||||
|
||||
public void setCookieMaxAge(int cookieMaxAge) {
|
||||
public void setCookieMaxAge(final int cookieMaxAge) {
|
||||
this.cookieMaxAge = cookieMaxAge;
|
||||
}
|
||||
|
||||
public void setCookiePath(String cookiePath) {
|
||||
public void setCookiePath(final String cookiePath) {
|
||||
this.cookiePath = cookiePath;
|
||||
}
|
||||
|
||||
public void setCookieSecure(Boolean cookieSecure) {
|
||||
public void setCookieSecure(final Boolean cookieSecure) {
|
||||
this.cookieSecure = cookieSecure;
|
||||
}
|
||||
}
|
|
@ -1528,11 +1528,11 @@ public interface FessProp {
|
|||
@SuppressWarnings("unchecked")
|
||||
OptionalThing<SortBuilder[]> ot = (OptionalThing<SortBuilder[]>) propMap.get(QUERY_COLLAPSE_INNER_HITS_SORTS);
|
||||
if (ot == null) {
|
||||
String sorts = getQueryCollapseInnerHitsSorts();
|
||||
final String sorts = getQueryCollapseInnerHitsSorts();
|
||||
if (StringUtil.isBlank(sorts)) {
|
||||
ot = OptionalThing.empty();
|
||||
} else {
|
||||
SortBuilder[] sortBuilders =
|
||||
final SortBuilder[] sortBuilders =
|
||||
split(sorts, ",").get(
|
||||
stream -> stream
|
||||
.filter(StringUtil::isNotBlank)
|
||||
|
|
|
@ -108,10 +108,11 @@ public class QueryResponseList implements List<Map<String, Object>> {
|
|||
if (innerHits != null) {
|
||||
final SearchHits innerSearchHits = innerHits.get(fessConfig.getQueryCollapseInnerHitsName());
|
||||
if (innerSearchHits != null) {
|
||||
long totalHits = innerSearchHits.getTotalHits();
|
||||
final long totalHits = innerSearchHits.getTotalHits();
|
||||
if (totalHits > 1) {
|
||||
docMap.put(fessConfig.getQueryCollapseInnerHitsName() + "_count", totalHits);
|
||||
SearchHitField bitsField = searchHit.getFields().get(fessConfig.getIndexFieldContentMinhashBits());
|
||||
final SearchHitField bitsField =
|
||||
searchHit.getFields().get(fessConfig.getIndexFieldContentMinhashBits());
|
||||
if (bitsField != null && !bitsField.getValues().isEmpty()) {
|
||||
docMap.put(fessConfig.getQueryCollapseInnerHitsName() + "_hash", bitsField.getValues().get(0));
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue