code cleanup
This commit is contained in:
parent
ab12ec8c2c
commit
24cb1db9df
60 changed files with 355 additions and 364 deletions
|
@ -91,9 +91,7 @@ public class FessBoot extends TomcatBoot {
|
|||
if (host instanceof StandardHost) {
|
||||
((StandardHost) host).setErrorReportValveClass(SuppressErrorReportValve.class.getName());
|
||||
}
|
||||
}).useTldDetect(jarName -> {
|
||||
return jarName.contains("jstl") || jarName.contains("lasta-taglib");
|
||||
}).asDevelopment(isNoneEnv()).bootAwait();
|
||||
}).useTldDetect(jarName -> (jarName.contains("jstl") || jarName.contains("lasta-taglib"))).asDevelopment(isNoneEnv()).bootAwait();
|
||||
}
|
||||
|
||||
public static void shutdown(final String[] args) {
|
||||
|
|
|
@ -154,13 +154,13 @@ public abstract class BaseJsonApiManager extends BaseApiManager {
|
|||
}
|
||||
buf.append('}');
|
||||
} else if (obj instanceof Integer) {
|
||||
buf.append(((Integer) obj));
|
||||
buf.append((obj));
|
||||
} else if (obj instanceof Long) {
|
||||
buf.append(((Long) obj));
|
||||
buf.append((obj));
|
||||
} else if (obj instanceof Float) {
|
||||
buf.append(((Float) obj));
|
||||
buf.append((obj));
|
||||
} else if (obj instanceof Double) {
|
||||
buf.append(((Double) obj));
|
||||
buf.append((obj));
|
||||
} else if (obj instanceof Boolean) {
|
||||
buf.append(obj.toString());
|
||||
} else if (obj instanceof Date) {
|
||||
|
|
|
@ -506,7 +506,7 @@ public class GsaApiManager extends BaseApiManager implements WebApiManager {
|
|||
return langs;
|
||||
}
|
||||
if (request.getHeader("Accept-Language") != null) {
|
||||
return Collections.list(request.getLocales()).stream().map(l -> l.getLanguage()).toArray(n -> new String[n]);
|
||||
return Collections.list(request.getLocales()).stream().map(Locale::getLanguage).toArray(n -> new String[n]);
|
||||
}
|
||||
return new String[] { fessConfig.getQueryGsaDefaultLang() };
|
||||
}
|
||||
|
|
|
@ -98,9 +98,8 @@ public class AllJobScheduler implements LaJobScheduler {
|
|||
|
||||
@Override
|
||||
public LaJobRunner createRunner() {
|
||||
return new LaJobRunner().useAccessContext(resource -> {
|
||||
return accessContextLogic.create(resource, () -> OptionalThing.empty(), () -> OptionalThing.empty(), () -> APP_TYPE);
|
||||
});
|
||||
return new LaJobRunner().useAccessContext(resource -> accessContextLogic.create(resource, () -> OptionalThing.empty(),
|
||||
() -> OptionalThing.empty(), () -> APP_TYPE));
|
||||
}
|
||||
|
||||
public void setJobClass(final Class<? extends LaJob> jobClass) {
|
||||
|
|
|
@ -193,7 +193,7 @@ public class CrawlingInfoService {
|
|||
cb.fetchFirst(fessConfig.getPageCrawlingInfoMaxFetchSizeAsInteger());
|
||||
cb.specify().columnId();
|
||||
});
|
||||
final List<String> idList = activeSessionList.stream().map(session -> session.getId()).collect(Collectors.toList());
|
||||
final List<String> idList = activeSessionList.stream().map(CrawlingInfo::getId).collect(Collectors.toList());
|
||||
crawlingInfoParamBhv.queryDelete(cb1 -> cb1.query().filtered((cq, cf) -> {
|
||||
cq.matchAll();
|
||||
if (!idList.isEmpty()) {
|
||||
|
@ -300,7 +300,7 @@ public class CrawlingInfoService {
|
|||
|
||||
public void deleteBefore(final long date) {
|
||||
crawlingInfoBhv.selectBulk(cb -> cb.query().setExpiredTime_LessThan(date), list -> {
|
||||
final List<String> idList = list.stream().map(entity -> entity.getId()).collect(Collectors.toList());
|
||||
final List<String> idList = list.stream().map(CrawlingInfo::getId).collect(Collectors.toList());
|
||||
crawlingInfoParamBhv.queryDelete(cb1 -> cb1.query().setCrawlingInfoId_InScope(idList));
|
||||
crawlingInfoBhv.queryDelete(cb2 -> cb2.query().setExpiredTime_LessThan(date));
|
||||
});
|
||||
|
|
|
@ -40,6 +40,7 @@ import org.codelibs.fess.es.config.exbhv.ElevateWordToLabelBhv;
|
|||
import org.codelibs.fess.es.config.exbhv.LabelTypeBhv;
|
||||
import org.codelibs.fess.es.config.exentity.ElevateWord;
|
||||
import org.codelibs.fess.es.config.exentity.ElevateWordToLabel;
|
||||
import org.codelibs.fess.es.config.exentity.LabelType;
|
||||
import org.codelibs.fess.helper.PermissionHelper;
|
||||
import org.codelibs.fess.mylasta.direction.FessConfig;
|
||||
import org.codelibs.fess.util.ComponentUtil;
|
||||
|
@ -307,7 +308,7 @@ public class ElevateWordService {
|
|||
elevateWordToLabelBhv
|
||||
.selectList(cb -> cb.query().setElevateWordId_Equal(entity.getId()))
|
||||
.stream()
|
||||
.map(e -> labelTypeBhv.selectByPK(e.getLabelTypeId()).map(lt -> lt.getValue())
|
||||
.map(e -> labelTypeBhv.selectByPK(e.getLabelTypeId()).map(LabelType::getValue)
|
||||
.filter(StringUtil::isNotBlank).orElse(null)).distinct().sorted()
|
||||
.collect(Collectors.joining(","));
|
||||
addToList(list, entity.getSuggestWord());
|
||||
|
|
|
@ -136,9 +136,7 @@ public class AdminBackupAction extends FessAdminAction {
|
|||
if (tempFile.exists() && !tempFile.delete()) {
|
||||
logger.warn("Failed to delete {}.", tempFile.getAbsolutePath());
|
||||
}
|
||||
throwValidationError(messages -> messages.addErrorsFileIsNotSupported(GLOBAL, fileName), () -> {
|
||||
return asListHtml();
|
||||
});
|
||||
throwValidationError(messages -> messages.addErrorsFileIsNotSupported(GLOBAL, fileName), () -> asListHtml());
|
||||
}
|
||||
saveInfo(messages -> messages.addSuccessBulkProcessStarted(GLOBAL));
|
||||
return redirect(getClass()); // no-op
|
||||
|
@ -157,9 +155,7 @@ public class AdminBackupAction extends FessAdminAction {
|
|||
} else if (fileName.startsWith("doc") && fileName.endsWith(".json")) {
|
||||
fileType = 5;
|
||||
} else {
|
||||
throwValidationError(messages -> messages.addErrorsFileIsNotSupported(GLOBAL, fileName), () -> {
|
||||
return asListHtml();
|
||||
});
|
||||
throwValidationError(messages -> messages.addErrorsFileIsNotSupported(GLOBAL, fileName), () -> asListHtml());
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
|
@ -134,22 +134,21 @@ public class AdminCrawlinginfoAction extends FessAdminAction {
|
|||
public HtmlResponse details(final int crudMode, final String id) {
|
||||
verifyCrudMode(crudMode, CrudMode.DETAILS);
|
||||
saveToken();
|
||||
return crawlingInfoService.getCrawlingInfo(id).map(entity -> {
|
||||
return asHtml(path_AdminCrawlinginfo_AdminCrawlinginfoDetailsJsp).useForm(EditForm.class, op -> {
|
||||
op.setup(form -> {
|
||||
copyBeanToBean(entity, form, copyOp -> {
|
||||
copyOp.excludeNull();
|
||||
return crawlingInfoService.getCrawlingInfo(id)
|
||||
.map(entity -> asHtml(path_AdminCrawlinginfo_AdminCrawlinginfoDetailsJsp).useForm(EditForm.class, op -> {
|
||||
op.setup(form -> {
|
||||
copyBeanToBean(entity, form, copyOp -> {
|
||||
copyOp.excludeNull();
|
||||
});
|
||||
form.crudMode = crudMode;
|
||||
});
|
||||
form.crudMode = crudMode;
|
||||
}).renderWith(data -> {
|
||||
RenderDataUtil.register(data, "crawlingInfoParamItems", crawlingInfoService.getCrawlingInfoParamList(id));
|
||||
RenderDataUtil.register(data, "running", processHelper.isProcessRunning(entity.getSessionId()));
|
||||
})).orElseGet(() -> {
|
||||
throwValidationError(messages -> messages.addErrorsCrudCouldNotFindCrudTable(GLOBAL, id), () -> asListHtml());
|
||||
return null;
|
||||
});
|
||||
}).renderWith(data -> {
|
||||
RenderDataUtil.register(data, "crawlingInfoParamItems", crawlingInfoService.getCrawlingInfoParamList(id));
|
||||
RenderDataUtil.register(data, "running", processHelper.isProcessRunning(entity.getSessionId()));
|
||||
});
|
||||
}).orElseGet(() -> {
|
||||
throwValidationError(messages -> messages.addErrorsCrudCouldNotFindCrudTable(GLOBAL, id), () -> asListHtml());
|
||||
return null;
|
||||
});
|
||||
}
|
||||
|
||||
@Execute
|
||||
|
|
|
@ -229,14 +229,17 @@ public class AdminDictKuromojiAction extends FessAdminAction {
|
|||
public ActionResponse download(final DownloadForm form) {
|
||||
validate(form, messages -> {}, () -> downloadpage(form.dictId));
|
||||
verifyTokenKeep(() -> downloadpage(form.dictId));
|
||||
return kuromojiService.getKuromojiFile(form.dictId).map(file -> {
|
||||
return asStream(new File(file.getPath()).getName()).contentTypeOctetStream().stream(out -> {
|
||||
file.writeOut(out);
|
||||
});
|
||||
}).orElseGet(() -> {
|
||||
throwValidationError(messages -> messages.addErrorsFailedToDownloadKuromojiFile(GLOBAL), () -> downloadpage(form.dictId));
|
||||
return null;
|
||||
});
|
||||
return kuromojiService
|
||||
.getKuromojiFile(form.dictId)
|
||||
.map(file -> asStream(new File(file.getPath()).getName()).contentTypeOctetStream().stream(out -> {
|
||||
file.writeOut(out);
|
||||
}))
|
||||
.orElseGet(
|
||||
() -> {
|
||||
throwValidationError(messages -> messages.addErrorsFailedToDownloadKuromojiFile(GLOBAL),
|
||||
() -> downloadpage(form.dictId));
|
||||
return null;
|
||||
});
|
||||
}
|
||||
|
||||
// -----------------------------------------------------
|
||||
|
@ -264,20 +267,21 @@ public class AdminDictKuromojiAction extends FessAdminAction {
|
|||
public HtmlResponse upload(final UploadForm form) {
|
||||
validate(form, messages -> {}, () -> uploadpage(form.dictId));
|
||||
verifyToken(() -> uploadpage(form.dictId));
|
||||
return kuromojiService.getKuromojiFile(form.dictId).map(file -> {
|
||||
try (InputStream inputStream = form.kuromojiFile.getInputStream()) {
|
||||
file.update(inputStream);
|
||||
} catch (final IOException e) {
|
||||
throwValidationError(messages -> messages.addErrorsFailedToUploadKuromojiFile(GLOBAL), () -> {
|
||||
return redirectWith(getClass(), moreUrl("uploadpage/" + form.dictId));
|
||||
return kuromojiService
|
||||
.getKuromojiFile(form.dictId)
|
||||
.map(file -> {
|
||||
try (InputStream inputStream = form.kuromojiFile.getInputStream()) {
|
||||
file.update(inputStream);
|
||||
} catch (final IOException e) {
|
||||
throwValidationError(messages -> messages.addErrorsFailedToUploadKuromojiFile(GLOBAL),
|
||||
() -> redirectWith(getClass(), moreUrl("uploadpage/" + form.dictId)));
|
||||
}
|
||||
saveInfo(messages -> messages.addSuccessUploadKuromojiFile(GLOBAL));
|
||||
return redirectWith(getClass(), moreUrl("list/1").params("dictId", form.dictId));
|
||||
}).orElseGet(() -> {
|
||||
throwValidationError(messages -> messages.addErrorsFailedToUploadKuromojiFile(GLOBAL), () -> uploadpage(form.dictId));
|
||||
return null;
|
||||
});
|
||||
}
|
||||
saveInfo(messages -> messages.addSuccessUploadKuromojiFile(GLOBAL));
|
||||
return redirectWith(getClass(), moreUrl("list/1").params("dictId", form.dictId));
|
||||
}).orElseGet(() -> {
|
||||
throwValidationError(messages -> messages.addErrorsFailedToUploadKuromojiFile(GLOBAL), () -> uploadpage(form.dictId));
|
||||
return null;
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -232,14 +232,17 @@ public class AdminDictMappingAction extends FessAdminAction {
|
|||
public ActionResponse download(final DownloadForm form) {
|
||||
validate(form, messages -> {}, () -> downloadpage(form.dictId));
|
||||
verifyTokenKeep(() -> downloadpage(form.dictId));
|
||||
return charMappingService.getCharMappingFile(form.dictId).map(file -> {
|
||||
return asStream(new File(file.getPath()).getName()).contentTypeOctetStream().stream(out -> {
|
||||
file.writeOut(out);
|
||||
});
|
||||
}).orElseGet(() -> {
|
||||
throwValidationError(messages -> messages.addErrorsFailedToDownloadMappingFile(GLOBAL), () -> downloadpage(form.dictId));
|
||||
return null;
|
||||
});
|
||||
return charMappingService
|
||||
.getCharMappingFile(form.dictId)
|
||||
.map(file -> asStream(new File(file.getPath()).getName()).contentTypeOctetStream().stream(out -> {
|
||||
file.writeOut(out);
|
||||
}))
|
||||
.orElseGet(
|
||||
() -> {
|
||||
throwValidationError(messages -> messages.addErrorsFailedToDownloadMappingFile(GLOBAL),
|
||||
() -> downloadpage(form.dictId));
|
||||
return null;
|
||||
});
|
||||
}
|
||||
|
||||
// -----------------------------------------------------
|
||||
|
@ -267,20 +270,21 @@ public class AdminDictMappingAction extends FessAdminAction {
|
|||
public HtmlResponse upload(final UploadForm form) {
|
||||
validate(form, messages -> {}, () -> uploadpage(form.dictId));
|
||||
verifyToken(() -> uploadpage(form.dictId));
|
||||
return charMappingService.getCharMappingFile(form.dictId).map(file -> {
|
||||
try (InputStream inputStream = form.charMappingFile.getInputStream()) {
|
||||
file.update(inputStream);
|
||||
} catch (final IOException e) {
|
||||
throwValidationError(messages -> messages.addErrorsFailedToUploadMappingFile(GLOBAL), () -> {
|
||||
return redirectWith(getClass(), moreUrl("uploadpage/" + form.dictId));
|
||||
return charMappingService
|
||||
.getCharMappingFile(form.dictId)
|
||||
.map(file -> {
|
||||
try (InputStream inputStream = form.charMappingFile.getInputStream()) {
|
||||
file.update(inputStream);
|
||||
} catch (final IOException e) {
|
||||
throwValidationError(messages -> messages.addErrorsFailedToUploadMappingFile(GLOBAL),
|
||||
() -> redirectWith(getClass(), moreUrl("uploadpage/" + form.dictId)));
|
||||
}
|
||||
saveInfo(messages -> messages.addSuccessUploadMappingFile(GLOBAL));
|
||||
return redirectWith(getClass(), moreUrl("list/1").params("dictId", form.dictId));
|
||||
}).orElseGet(() -> {
|
||||
throwValidationError(messages -> messages.addErrorsFailedToUploadMappingFile(GLOBAL), () -> uploadpage(form.dictId));
|
||||
return null;
|
||||
});
|
||||
}
|
||||
saveInfo(messages -> messages.addSuccessUploadMappingFile(GLOBAL));
|
||||
return redirectWith(getClass(), moreUrl("list/1").params("dictId", form.dictId));
|
||||
}).orElseGet(() -> {
|
||||
throwValidationError(messages -> messages.addErrorsFailedToUploadMappingFile(GLOBAL), () -> uploadpage(form.dictId));
|
||||
return null;
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -227,14 +227,17 @@ public class AdminDictProtwordsAction extends FessAdminAction {
|
|||
public ActionResponse download(final DownloadForm form) {
|
||||
validate(form, messages -> {}, () -> downloadpage(form.dictId));
|
||||
verifyTokenKeep(() -> downloadpage(form.dictId));
|
||||
return protwordsService.getProtwordsFile(form.dictId).map(file -> {
|
||||
return asStream(new File(file.getPath()).getName()).contentTypeOctetStream().stream(out -> {
|
||||
file.writeOut(out);
|
||||
});
|
||||
}).orElseGet(() -> {
|
||||
throwValidationError(messages -> messages.addErrorsFailedToDownloadProtwordsFile(GLOBAL), () -> downloadpage(form.dictId));
|
||||
return null;
|
||||
});
|
||||
return protwordsService
|
||||
.getProtwordsFile(form.dictId)
|
||||
.map(file -> asStream(new File(file.getPath()).getName()).contentTypeOctetStream().stream(out -> {
|
||||
file.writeOut(out);
|
||||
}))
|
||||
.orElseGet(
|
||||
() -> {
|
||||
throwValidationError(messages -> messages.addErrorsFailedToDownloadProtwordsFile(GLOBAL),
|
||||
() -> downloadpage(form.dictId));
|
||||
return null;
|
||||
});
|
||||
}
|
||||
|
||||
// -----------------------------------------------------
|
||||
|
@ -262,20 +265,21 @@ public class AdminDictProtwordsAction extends FessAdminAction {
|
|||
public HtmlResponse upload(final UploadForm form) {
|
||||
validate(form, messages -> {}, () -> uploadpage(form.dictId));
|
||||
verifyToken(() -> uploadpage(form.dictId));
|
||||
return protwordsService.getProtwordsFile(form.dictId).map(file -> {
|
||||
try (InputStream inputStream = form.protwordsFile.getInputStream()) {
|
||||
file.update(inputStream);
|
||||
} catch (final IOException e) {
|
||||
throwValidationError(messages -> messages.addErrorsFailedToUploadProtwordsFile(GLOBAL), () -> {
|
||||
return redirectWith(getClass(), moreUrl("uploadpage/" + form.dictId));
|
||||
return protwordsService
|
||||
.getProtwordsFile(form.dictId)
|
||||
.map(file -> {
|
||||
try (InputStream inputStream = form.protwordsFile.getInputStream()) {
|
||||
file.update(inputStream);
|
||||
} catch (final IOException e) {
|
||||
throwValidationError(messages -> messages.addErrorsFailedToUploadProtwordsFile(GLOBAL),
|
||||
() -> redirectWith(getClass(), moreUrl("uploadpage/" + form.dictId)));
|
||||
}
|
||||
saveInfo(messages -> messages.addSuccessUploadProtwordsFile(GLOBAL));
|
||||
return redirectWith(getClass(), moreUrl("list/1").params("dictId", form.dictId));
|
||||
}).orElseGet(() -> {
|
||||
throwValidationError(messages -> messages.addErrorsFailedToUploadProtwordsFile(GLOBAL), () -> uploadpage(form.dictId));
|
||||
return null;
|
||||
});
|
||||
}
|
||||
saveInfo(messages -> messages.addSuccessUploadProtwordsFile(GLOBAL));
|
||||
return redirectWith(getClass(), moreUrl("list/1").params("dictId", form.dictId));
|
||||
}).orElseGet(() -> {
|
||||
throwValidationError(messages -> messages.addErrorsFailedToUploadProtwordsFile(GLOBAL), () -> uploadpage(form.dictId));
|
||||
return null;
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -232,11 +232,9 @@ public class AdminDictStemmeroverrideAction extends FessAdminAction {
|
|||
verifyTokenKeep(() -> downloadpage(form.dictId));
|
||||
return stemmerOverrideService
|
||||
.getStemmerOverrideFile(form.dictId)
|
||||
.map(file -> {
|
||||
return asStream(new File(file.getPath()).getName()).contentTypeOctetStream().stream(out -> {
|
||||
file.writeOut(out);
|
||||
});
|
||||
})
|
||||
.map(file -> asStream(new File(file.getPath()).getName()).contentTypeOctetStream().stream(out -> {
|
||||
file.writeOut(out);
|
||||
}))
|
||||
.orElseGet(
|
||||
() -> {
|
||||
throwValidationError(messages -> messages.addErrorsFailedToDownloadStemmeroverrideFile(GLOBAL),
|
||||
|
@ -270,20 +268,24 @@ public class AdminDictStemmeroverrideAction extends FessAdminAction {
|
|||
public HtmlResponse upload(final UploadForm form) {
|
||||
validate(form, messages -> {}, () -> uploadpage(form.dictId));
|
||||
verifyToken(() -> uploadpage(form.dictId));
|
||||
return stemmerOverrideService.getStemmerOverrideFile(form.dictId).map(file -> {
|
||||
try (InputStream inputStream = form.stemmerOverrideFile.getInputStream()) {
|
||||
file.update(inputStream);
|
||||
} catch (final IOException e) {
|
||||
throwValidationError(messages -> messages.addErrorsFailedToUploadStemmeroverrideFile(GLOBAL), () -> {
|
||||
return redirectWith(getClass(), moreUrl("uploadpage/" + form.dictId));
|
||||
});
|
||||
}
|
||||
saveInfo(messages -> messages.addSuccessUploadStemmeroverrideFile(GLOBAL));
|
||||
return redirectWith(getClass(), moreUrl("list/1").params("dictId", form.dictId));
|
||||
}).orElseGet(() -> {
|
||||
throwValidationError(messages -> messages.addErrorsFailedToUploadStemmeroverrideFile(GLOBAL), () -> uploadpage(form.dictId));
|
||||
return null;
|
||||
});
|
||||
return stemmerOverrideService
|
||||
.getStemmerOverrideFile(form.dictId)
|
||||
.map(file -> {
|
||||
try (InputStream inputStream = form.stemmerOverrideFile.getInputStream()) {
|
||||
file.update(inputStream);
|
||||
} catch (final IOException e) {
|
||||
throwValidationError(messages -> messages.addErrorsFailedToUploadStemmeroverrideFile(GLOBAL),
|
||||
() -> redirectWith(getClass(), moreUrl("uploadpage/" + form.dictId)));
|
||||
}
|
||||
saveInfo(messages -> messages.addSuccessUploadStemmeroverrideFile(GLOBAL));
|
||||
return redirectWith(getClass(), moreUrl("list/1").params("dictId", form.dictId));
|
||||
})
|
||||
.orElseGet(
|
||||
() -> {
|
||||
throwValidationError(messages -> messages.addErrorsFailedToUploadStemmeroverrideFile(GLOBAL),
|
||||
() -> uploadpage(form.dictId));
|
||||
return null;
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -225,14 +225,17 @@ public class AdminDictStopwordsAction extends FessAdminAction {
|
|||
public ActionResponse download(final DownloadForm form) {
|
||||
validate(form, messages -> {}, () -> downloadpage(form.dictId));
|
||||
verifyTokenKeep(() -> downloadpage(form.dictId));
|
||||
return stopwordsService.getStopwordsFile(form.dictId).map(file -> {
|
||||
return asStream(new File(file.getPath()).getName()).contentTypeOctetStream().stream(out -> {
|
||||
file.writeOut(out);
|
||||
});
|
||||
}).orElseGet(() -> {
|
||||
throwValidationError(messages -> messages.addErrorsFailedToDownloadStopwordsFile(GLOBAL), () -> downloadpage(form.dictId));
|
||||
return null;
|
||||
});
|
||||
return stopwordsService
|
||||
.getStopwordsFile(form.dictId)
|
||||
.map(file -> asStream(new File(file.getPath()).getName()).contentTypeOctetStream().stream(out -> {
|
||||
file.writeOut(out);
|
||||
}))
|
||||
.orElseGet(
|
||||
() -> {
|
||||
throwValidationError(messages -> messages.addErrorsFailedToDownloadStopwordsFile(GLOBAL),
|
||||
() -> downloadpage(form.dictId));
|
||||
return null;
|
||||
});
|
||||
}
|
||||
|
||||
// -----------------------------------------------------
|
||||
|
@ -260,20 +263,21 @@ public class AdminDictStopwordsAction extends FessAdminAction {
|
|||
public HtmlResponse upload(final UploadForm form) {
|
||||
validate(form, messages -> {}, () -> uploadpage(form.dictId));
|
||||
verifyToken(() -> uploadpage(form.dictId));
|
||||
return stopwordsService.getStopwordsFile(form.dictId).map(file -> {
|
||||
try (InputStream inputStream = form.stopwordsFile.getInputStream()) {
|
||||
file.update(inputStream);
|
||||
} catch (final IOException e) {
|
||||
throwValidationError(messages -> messages.addErrorsFailedToUploadStopwordsFile(GLOBAL), () -> {
|
||||
return redirectWith(getClass(), moreUrl("uploadpage/" + form.dictId));
|
||||
return stopwordsService
|
||||
.getStopwordsFile(form.dictId)
|
||||
.map(file -> {
|
||||
try (InputStream inputStream = form.stopwordsFile.getInputStream()) {
|
||||
file.update(inputStream);
|
||||
} catch (final IOException e) {
|
||||
throwValidationError(messages -> messages.addErrorsFailedToUploadStopwordsFile(GLOBAL),
|
||||
() -> redirectWith(getClass(), moreUrl("uploadpage/" + form.dictId)));
|
||||
}
|
||||
saveInfo(messages -> messages.addSuccessUploadStopwordsFile(GLOBAL));
|
||||
return redirectWith(getClass(), moreUrl("list/1").params("dictId", form.dictId));
|
||||
}).orElseGet(() -> {
|
||||
throwValidationError(messages -> messages.addErrorsFailedToUploadStopwordsFile(GLOBAL), () -> uploadpage(form.dictId));
|
||||
return null;
|
||||
});
|
||||
}
|
||||
saveInfo(messages -> messages.addSuccessUploadStopwordsFile(GLOBAL));
|
||||
return redirectWith(getClass(), moreUrl("list/1").params("dictId", form.dictId));
|
||||
}).orElseGet(() -> {
|
||||
throwValidationError(messages -> messages.addErrorsFailedToUploadStopwordsFile(GLOBAL), () -> uploadpage(form.dictId));
|
||||
return null;
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -232,14 +232,17 @@ public class AdminDictSynonymAction extends FessAdminAction {
|
|||
public ActionResponse download(final DownloadForm form) {
|
||||
validate(form, messages -> {}, () -> downloadpage(form.dictId));
|
||||
verifyTokenKeep(() -> downloadpage(form.dictId));
|
||||
return synonymService.getSynonymFile(form.dictId).map(file -> {
|
||||
return asStream(new File(file.getPath()).getName()).contentTypeOctetStream().stream(out -> {
|
||||
file.writeOut(out);
|
||||
});
|
||||
}).orElseGet(() -> {
|
||||
throwValidationError(messages -> messages.addErrorsFailedToDownloadSynonymFile(GLOBAL), () -> downloadpage(form.dictId));
|
||||
return null;
|
||||
});
|
||||
return synonymService
|
||||
.getSynonymFile(form.dictId)
|
||||
.map(file -> asStream(new File(file.getPath()).getName()).contentTypeOctetStream().stream(out -> {
|
||||
file.writeOut(out);
|
||||
}))
|
||||
.orElseGet(
|
||||
() -> {
|
||||
throwValidationError(messages -> messages.addErrorsFailedToDownloadSynonymFile(GLOBAL),
|
||||
() -> downloadpage(form.dictId));
|
||||
return null;
|
||||
});
|
||||
}
|
||||
|
||||
// -----------------------------------------------------
|
||||
|
@ -267,20 +270,21 @@ public class AdminDictSynonymAction extends FessAdminAction {
|
|||
public HtmlResponse upload(final UploadForm form) {
|
||||
validate(form, messages -> {}, () -> uploadpage(form.dictId));
|
||||
verifyToken(() -> uploadpage(form.dictId));
|
||||
return synonymService.getSynonymFile(form.dictId).map(file -> {
|
||||
try (InputStream inputStream = form.synonymFile.getInputStream()) {
|
||||
file.update(inputStream);
|
||||
} catch (final IOException e) {
|
||||
throwValidationError(messages -> messages.addErrorsFailedToUploadSynonymFile(GLOBAL), () -> {
|
||||
return redirectWith(getClass(), moreUrl("uploadpage/" + form.dictId));
|
||||
return synonymService
|
||||
.getSynonymFile(form.dictId)
|
||||
.map(file -> {
|
||||
try (InputStream inputStream = form.synonymFile.getInputStream()) {
|
||||
file.update(inputStream);
|
||||
} catch (final IOException e) {
|
||||
throwValidationError(messages -> messages.addErrorsFailedToUploadSynonymFile(GLOBAL),
|
||||
() -> redirectWith(getClass(), moreUrl("uploadpage/" + form.dictId)));
|
||||
}
|
||||
saveInfo(messages -> messages.addSuccessUploadSynonymFile(GLOBAL));
|
||||
return redirectWith(getClass(), moreUrl("list/1").params("dictId", form.dictId));
|
||||
}).orElseGet(() -> {
|
||||
throwValidationError(messages -> messages.addErrorsFailedToUploadSynonymFile(GLOBAL), () -> uploadpage(form.dictId));
|
||||
return null;
|
||||
});
|
||||
}
|
||||
saveInfo(messages -> messages.addSuccessUploadSynonymFile(GLOBAL));
|
||||
return redirectWith(getClass(), moreUrl("list/1").params("dictId", form.dictId));
|
||||
}).orElseGet(() -> {
|
||||
throwValidationError(messages -> messages.addErrorsFailedToUploadSynonymFile(GLOBAL), () -> uploadpage(form.dictId));
|
||||
return null;
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -76,9 +76,8 @@ public class AdminEsreqAction extends FessAdminAction {
|
|||
try (final BufferedReader reader = new BufferedReader(new InputStreamReader(form.requestFile.getInputStream(), Constants.UTF_8))) {
|
||||
header = ReaderUtil.readLine(reader);
|
||||
if (header == null) {
|
||||
throwValidationError(messages -> messages.addErrorsInvalidHeaderForRequestFile(GLOBAL, "no header"), () -> {
|
||||
return asListHtml(() -> saveToken());
|
||||
});
|
||||
throwValidationError(messages -> messages.addErrorsInvalidHeaderForRequestFile(GLOBAL, "no header"),
|
||||
() -> asListHtml(() -> saveToken()));
|
||||
return redirect(getClass()); // no-op
|
||||
}
|
||||
String line;
|
||||
|
@ -86,17 +85,15 @@ public class AdminEsreqAction extends FessAdminAction {
|
|||
buf.append(line);
|
||||
}
|
||||
} catch (final Exception e) {
|
||||
throwValidationError(messages -> messages.addErrorsFailedToReadRequestFile(GLOBAL, e.getMessage()), () -> {
|
||||
return asListHtml(() -> saveToken());
|
||||
});
|
||||
throwValidationError(messages -> messages.addErrorsFailedToReadRequestFile(GLOBAL, e.getMessage()),
|
||||
() -> asListHtml(() -> saveToken()));
|
||||
}
|
||||
|
||||
final CurlRequest curlRequest = getCurlRequest(header);
|
||||
if (curlRequest == null) {
|
||||
final String msg = header;
|
||||
throwValidationError(messages -> messages.addErrorsInvalidHeaderForRequestFile(GLOBAL, msg), () -> {
|
||||
return asListHtml(() -> saveToken());
|
||||
});
|
||||
throwValidationError(messages -> messages.addErrorsInvalidHeaderForRequestFile(GLOBAL, msg),
|
||||
() -> asListHtml(() -> saveToken()));
|
||||
} else {
|
||||
try (final CurlResponse response = curlRequest.body(buf.toString()).execute()) {
|
||||
final File tempFile = ComponentUtil.getSystemHelper().createTempFile("esreq_", ".json");
|
||||
|
@ -119,9 +116,8 @@ public class AdminEsreqAction extends FessAdminAction {
|
|||
});
|
||||
} catch (final Exception e) {
|
||||
logger.warn("Failed to process request file: " + form.requestFile.getFileName(), e);
|
||||
throwValidationError(messages -> messages.addErrorsInvalidHeaderForRequestFile(GLOBAL, e.getMessage()), () -> {
|
||||
return asListHtml(() -> saveToken());
|
||||
});
|
||||
throwValidationError(messages -> messages.addErrorsInvalidHeaderForRequestFile(GLOBAL, e.getMessage()),
|
||||
() -> asListHtml(() -> saveToken()));
|
||||
}
|
||||
}
|
||||
return redirect(getClass()); // no-op
|
||||
|
|
|
@ -91,9 +91,7 @@ public class AdminGeneralAction extends FessAdminAction {
|
|||
@Execute
|
||||
@Secured({ ROLE })
|
||||
public HtmlResponse sendmail(final MailForm form) {
|
||||
validate(form, messages -> {}, () -> {
|
||||
return asHtml(path_AdminGeneral_AdminGeneralJsp);
|
||||
});
|
||||
validate(form, messages -> {}, () -> asHtml(path_AdminGeneral_AdminGeneralJsp));
|
||||
|
||||
final String[] toAddresses = form.notificationTo.split(",");
|
||||
final Map<String, Object> dataMap = new HashMap<>();
|
||||
|
@ -124,12 +122,8 @@ public class AdminGeneralAction extends FessAdminAction {
|
|||
@Execute
|
||||
@Secured({ ROLE })
|
||||
public HtmlResponse update(final EditForm form) {
|
||||
validate(form, messages -> {}, () -> {
|
||||
return asHtml(path_AdminGeneral_AdminGeneralJsp);
|
||||
});
|
||||
verifyToken(() -> {
|
||||
return asHtml(path_AdminGeneral_AdminGeneralJsp);
|
||||
});
|
||||
validate(form, messages -> {}, () -> asHtml(path_AdminGeneral_AdminGeneralJsp));
|
||||
verifyToken(() -> asHtml(path_AdminGeneral_AdminGeneralJsp));
|
||||
|
||||
updateConfig(fessConfig, form);
|
||||
saveInfo(messages -> messages.addSuccessUpdateCrawlerParams(GLOBAL));
|
||||
|
|
|
@ -80,9 +80,7 @@ public class AdminLogAction extends FessAdminAction {
|
|||
}
|
||||
});
|
||||
}
|
||||
throwValidationError(messages -> messages.addErrorsCouldNotFindLogFile(GLOBAL, filename), () -> {
|
||||
return asIndexHtml();
|
||||
});
|
||||
throwValidationError(messages -> messages.addErrorsCouldNotFindLogFile(GLOBAL, filename), () -> asIndexHtml());
|
||||
return redirect(getClass()); // no-op
|
||||
}
|
||||
|
||||
|
|
|
@ -109,9 +109,7 @@ public class AdminWizardAction extends FessAdminAction {
|
|||
@Execute
|
||||
@Secured({ ROLE })
|
||||
public HtmlResponse crawlingConfig(final CrawlingConfigForm form) {
|
||||
validate(form, messages -> {}, () -> {
|
||||
return asHtml(path_AdminWizard_AdminWizardConfigJsp);
|
||||
});
|
||||
validate(form, messages -> {}, () -> asHtml(path_AdminWizard_AdminWizardConfigJsp));
|
||||
verifyTokenKeep(() -> asIndexHtml());
|
||||
final String name = crawlingConfigInternal(form);
|
||||
saveInfo(messages -> messages.addSuccessCreateCrawlingConfigAtWizard(GLOBAL, name));
|
||||
|
@ -121,9 +119,7 @@ public class AdminWizardAction extends FessAdminAction {
|
|||
@Execute
|
||||
@Secured({ ROLE })
|
||||
public HtmlResponse crawlingConfigNext(final CrawlingConfigForm form) {
|
||||
validate(form, messages -> {}, () -> {
|
||||
return asHtml(path_AdminWizard_AdminWizardConfigJsp);
|
||||
});
|
||||
validate(form, messages -> {}, () -> asHtml(path_AdminWizard_AdminWizardConfigJsp));
|
||||
verifyToken(() -> asIndexHtml());
|
||||
final String name = crawlingConfigInternal(form);
|
||||
saveInfo(messages -> messages.addSuccessCreateCrawlingConfigAtWizard(GLOBAL, name));
|
||||
|
@ -220,9 +216,8 @@ public class AdminWizardAction extends FessAdminAction {
|
|||
return configName;
|
||||
} catch (final Exception e) {
|
||||
logger.error("Failed to create crawling config: " + form.crawlingConfigPath, e);
|
||||
throwValidationError(messages -> messages.addErrorsFailedToCreateCrawlingConfigAtWizard(GLOBAL), () -> {
|
||||
return asHtml(path_AdminWizard_AdminWizardConfigJsp);
|
||||
});
|
||||
throwValidationError(messages -> messages.addErrorsFailedToCreateCrawlingConfigAtWizard(GLOBAL),
|
||||
() -> asHtml(path_AdminWizard_AdminWizardConfigJsp));
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -21,6 +21,8 @@ import java.util.Locale;
|
|||
import java.util.Map;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
|
||||
import org.codelibs.fess.entity.SearchRenderData;
|
||||
import org.codelibs.fess.mylasta.action.FessMessages;
|
||||
import org.codelibs.fess.util.ComponentUtil;
|
||||
|
@ -341,9 +343,10 @@ public class ApiResult {
|
|||
final FessMessages messages = new FessMessages();
|
||||
validationMessagesLambda.message(messages);
|
||||
message =
|
||||
ComponentUtil.getMessageManager()
|
||||
.toMessageList(LaRequestUtil.getOptionalRequest().map(r -> r.getLocale()).orElse(Locale.ENGLISH), messages)
|
||||
.stream().collect(Collectors.joining(" "));
|
||||
ComponentUtil
|
||||
.getMessageManager()
|
||||
.toMessageList(LaRequestUtil.getOptionalRequest().map(HttpServletRequest::getLocale).orElse(Locale.ENGLISH),
|
||||
messages).stream().collect(Collectors.joining(" "));
|
||||
return this;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -27,9 +27,8 @@ public abstract class FessApiAdminAction extends FessApiAction {
|
|||
@Override
|
||||
protected boolean isAccessAllowed() {
|
||||
try {
|
||||
return accessTokenService.getPermissions(request).map(permissions -> {
|
||||
return fessConfig.isApiAdminAccessAllowed(permissions);
|
||||
}).orElse(false);
|
||||
return accessTokenService.getPermissions(request).map(permissions -> fessConfig.isApiAdminAccessAllowed(permissions))
|
||||
.orElse(false);
|
||||
} catch (final InvalidAccessTokenException e) {
|
||||
if (logger.isDebugEnabled()) {
|
||||
logger.debug("Invalid access token.", e);
|
||||
|
|
|
@ -22,6 +22,7 @@ import java.util.stream.Collectors;
|
|||
|
||||
import javax.annotation.Resource;
|
||||
|
||||
import org.codelibs.core.beans.util.CopyOptions;
|
||||
import org.codelibs.fess.app.pager.BoostDocPager;
|
||||
import org.codelibs.fess.app.service.BoostDocumentRuleService;
|
||||
import org.codelibs.fess.app.web.CrudMode;
|
||||
|
@ -129,7 +130,7 @@ public class ApiAdminBoostdocAction extends FessApiAdminAction {
|
|||
|
||||
protected EditBody createEditBody(final BoostDocumentRule entity) {
|
||||
final EditBody form = new EditBody();
|
||||
copyBeanToBean(entity, form, copyOp -> copyOp.excludeNull());
|
||||
copyBeanToBean(entity, form, CopyOptions::excludeNull);
|
||||
form.crudMode = null;
|
||||
return form;
|
||||
}
|
||||
|
|
|
@ -134,14 +134,13 @@ public class ApiAdminDictKuromojiAction extends FessApiAdminAction {
|
|||
public StreamResponse get$download(final String dictId, final DownloadBody body) {
|
||||
body.dictId = dictId;
|
||||
validateApi(body, messages -> {});
|
||||
return kuromojiService.getKuromojiFile(body.dictId).map(file -> {
|
||||
return asStream(new File(file.getPath()).getName()).contentTypeOctetStream().stream(out -> {
|
||||
file.writeOut(out);
|
||||
});
|
||||
}).orElseGet(() -> {
|
||||
throwValidationErrorApi(messages -> messages.addErrorsFailedToDownloadProtwordsFile(GLOBAL));
|
||||
return null;
|
||||
});
|
||||
return kuromojiService.getKuromojiFile(body.dictId)
|
||||
.map(file -> asStream(new File(file.getPath()).getName()).contentTypeOctetStream().stream(out -> {
|
||||
file.writeOut(out);
|
||||
})).orElseGet(() -> {
|
||||
throwValidationErrorApi(messages -> messages.addErrorsFailedToDownloadProtwordsFile(GLOBAL));
|
||||
return null;
|
||||
});
|
||||
}
|
||||
|
||||
protected EditBody createEditBody(final KuromojiItem entity, final String dictId) {
|
||||
|
|
|
@ -134,14 +134,13 @@ public class ApiAdminDictMappingAction extends FessApiAdminAction {
|
|||
public StreamResponse get$download(final String dictId, final DownloadBody body) {
|
||||
body.dictId = dictId;
|
||||
validateApi(body, messages -> {});
|
||||
return charMappingService.getCharMappingFile(body.dictId).map(file -> {
|
||||
return asStream(new File(file.getPath()).getName()).contentTypeOctetStream().stream(out -> {
|
||||
file.writeOut(out);
|
||||
});
|
||||
}).orElseGet(() -> {
|
||||
throwValidationErrorApi(messages -> messages.addErrorsFailedToDownloadProtwordsFile(GLOBAL));
|
||||
return null;
|
||||
});
|
||||
return charMappingService.getCharMappingFile(body.dictId)
|
||||
.map(file -> asStream(new File(file.getPath()).getName()).contentTypeOctetStream().stream(out -> {
|
||||
file.writeOut(out);
|
||||
})).orElseGet(() -> {
|
||||
throwValidationErrorApi(messages -> messages.addErrorsFailedToDownloadProtwordsFile(GLOBAL));
|
||||
return null;
|
||||
});
|
||||
}
|
||||
|
||||
protected EditBody createEditBody(final CharMappingItem entity, final String dictId) {
|
||||
|
|
|
@ -133,14 +133,13 @@ public class ApiAdminDictProtwordsAction extends FessApiAdminAction {
|
|||
public StreamResponse get$download(final String dictId, final DownloadBody body) {
|
||||
body.dictId = dictId;
|
||||
validateApi(body, messages -> {});
|
||||
return protwordsService.getProtwordsFile(body.dictId).map(file -> {
|
||||
return asStream(new File(file.getPath()).getName()).contentTypeOctetStream().stream(out -> {
|
||||
file.writeOut(out);
|
||||
});
|
||||
}).orElseGet(() -> {
|
||||
throwValidationErrorApi(messages -> messages.addErrorsFailedToDownloadProtwordsFile(GLOBAL));
|
||||
return null;
|
||||
});
|
||||
return protwordsService.getProtwordsFile(body.dictId)
|
||||
.map(file -> asStream(new File(file.getPath()).getName()).contentTypeOctetStream().stream(out -> {
|
||||
file.writeOut(out);
|
||||
})).orElseGet(() -> {
|
||||
throwValidationErrorApi(messages -> messages.addErrorsFailedToDownloadProtwordsFile(GLOBAL));
|
||||
return null;
|
||||
});
|
||||
}
|
||||
|
||||
protected EditBody createEditBody(final ProtwordsItem entity, final String dictId) {
|
||||
|
|
|
@ -140,14 +140,13 @@ public class ApiAdminDictStemmeroverrideAction extends FessApiAdminAction {
|
|||
public StreamResponse get$download(final String dictId, final DownloadBody body) {
|
||||
body.dictId = dictId;
|
||||
validateApi(body, messages -> {});
|
||||
return stemmerOverrideService.getStemmerOverrideFile(body.dictId).map(file -> {
|
||||
return asStream(new File(file.getPath()).getName()).contentTypeOctetStream().stream(out -> {
|
||||
file.writeOut(out);
|
||||
});
|
||||
}).orElseGet(() -> {
|
||||
throwValidationErrorApi(messages -> messages.addErrorsFailedToDownloadProtwordsFile(GLOBAL));
|
||||
return null;
|
||||
});
|
||||
return stemmerOverrideService.getStemmerOverrideFile(body.dictId)
|
||||
.map(file -> asStream(new File(file.getPath()).getName()).contentTypeOctetStream().stream(out -> {
|
||||
file.writeOut(out);
|
||||
})).orElseGet(() -> {
|
||||
throwValidationErrorApi(messages -> messages.addErrorsFailedToDownloadProtwordsFile(GLOBAL));
|
||||
return null;
|
||||
});
|
||||
}
|
||||
|
||||
protected EditBody createEditBody(final StemmerOverrideItem entity, final String dictId) {
|
||||
|
|
|
@ -133,14 +133,13 @@ public class ApiAdminDictStopwordsAction extends FessApiAdminAction {
|
|||
public StreamResponse get$download(final String dictId, final DownloadBody body) {
|
||||
body.dictId = dictId;
|
||||
validateApi(body, messages -> {});
|
||||
return stopwordsService.getStopwordsFile(body.dictId).map(file -> {
|
||||
return asStream(new File(file.getPath()).getName()).contentTypeOctetStream().stream(out -> {
|
||||
file.writeOut(out);
|
||||
});
|
||||
}).orElseGet(() -> {
|
||||
throwValidationErrorApi(messages -> messages.addErrorsFailedToDownloadStopwordsFile(GLOBAL));
|
||||
return null;
|
||||
});
|
||||
return stopwordsService.getStopwordsFile(body.dictId)
|
||||
.map(file -> asStream(new File(file.getPath()).getName()).contentTypeOctetStream().stream(out -> {
|
||||
file.writeOut(out);
|
||||
})).orElseGet(() -> {
|
||||
throwValidationErrorApi(messages -> messages.addErrorsFailedToDownloadStopwordsFile(GLOBAL));
|
||||
return null;
|
||||
});
|
||||
}
|
||||
|
||||
protected EditBody createEditBody(final StopwordsItem entity, final String dictId) {
|
||||
|
|
|
@ -134,14 +134,13 @@ public class ApiAdminDictSynonymAction extends FessApiAdminAction {
|
|||
public StreamResponse get$download(final String dictId, final DownloadBody body) {
|
||||
body.dictId = dictId;
|
||||
validateApi(body, messages -> {});
|
||||
return synonymService.getSynonymFile(body.dictId).map(file -> {
|
||||
return asStream(new File(file.getPath()).getName()).contentTypeOctetStream().stream(out -> {
|
||||
file.writeOut(out);
|
||||
});
|
||||
}).orElseGet(() -> {
|
||||
throwValidationErrorApi(messages -> messages.addErrorsFailedToDownloadProtwordsFile(GLOBAL));
|
||||
return null;
|
||||
});
|
||||
return synonymService.getSynonymFile(body.dictId)
|
||||
.map(file -> asStream(new File(file.getPath()).getName()).contentTypeOctetStream().stream(out -> {
|
||||
file.writeOut(out);
|
||||
})).orElseGet(() -> {
|
||||
throwValidationErrorApi(messages -> messages.addErrorsFailedToDownloadProtwordsFile(GLOBAL));
|
||||
return null;
|
||||
});
|
||||
}
|
||||
|
||||
protected EditBody createEditBody(final SynonymItem entity, final String dictId) {
|
||||
|
|
|
@ -18,6 +18,7 @@ package org.codelibs.fess.app.web.api.admin.general;
|
|||
import javax.annotation.Resource;
|
||||
|
||||
import org.codelibs.core.beans.util.BeanUtil;
|
||||
import org.codelibs.core.beans.util.CopyOptions;
|
||||
import org.codelibs.core.misc.DynamicProperties;
|
||||
import org.codelibs.fess.app.web.admin.general.AdminGeneralAction;
|
||||
import org.codelibs.fess.app.web.api.ApiResult;
|
||||
|
@ -57,7 +58,7 @@ public class ApiAdminGeneralAction extends FessApiAdminAction {
|
|||
validateApi(body, messages -> {});
|
||||
final EditBody newBody = new EditBody();
|
||||
AdminGeneralAction.updateForm(fessConfig, newBody);
|
||||
BeanUtil.copyBeanToBean(body, newBody, op -> op.excludeNull());
|
||||
BeanUtil.copyBeanToBean(body, newBody, CopyOptions::excludeNull);
|
||||
AdminGeneralAction.updateConfig(fessConfig, newBody);
|
||||
return asJson(new ApiResponse().status(Status.OK).result());
|
||||
}
|
||||
|
|
|
@ -115,28 +115,28 @@ public abstract class FessBaseAction extends TypicalAction // has several interf
|
|||
logger.debug("refresh user info: {}", result);
|
||||
}
|
||||
});
|
||||
return viewHelper.getActionHook().godHandPrologue(runtime, r -> super.godHandPrologue(r));
|
||||
return viewHelper.getActionHook().godHandPrologue(runtime, super::godHandPrologue);
|
||||
}
|
||||
|
||||
@Override
|
||||
public final ActionResponse godHandMonologue(final ActionRuntime runtime) {
|
||||
return viewHelper.getActionHook().godHandMonologue(runtime, r -> super.godHandMonologue(r));
|
||||
return viewHelper.getActionHook().godHandMonologue(runtime, super::godHandMonologue);
|
||||
}
|
||||
|
||||
@Override
|
||||
public final void godHandEpilogue(final ActionRuntime runtime) {
|
||||
viewHelper.getActionHook().godHandEpilogue(runtime, r -> super.godHandEpilogue(r));
|
||||
viewHelper.getActionHook().godHandEpilogue(runtime, super::godHandEpilogue);
|
||||
}
|
||||
|
||||
// #app_customize you can customize the action hook
|
||||
@Override
|
||||
public ActionResponse hookBefore(final ActionRuntime runtime) { // application may override
|
||||
return viewHelper.getActionHook().hookBefore(runtime, r -> super.hookBefore(r));
|
||||
return viewHelper.getActionHook().hookBefore(runtime, super::hookBefore);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void hookFinally(final ActionRuntime runtime) {
|
||||
viewHelper.getActionHook().hookFinally(runtime, r -> super.hookFinally(r));
|
||||
viewHelper.getActionHook().hookFinally(runtime, super::hookFinally);
|
||||
}
|
||||
|
||||
// ===================================================================================
|
||||
|
|
|
@ -40,6 +40,7 @@ import org.codelibs.fess.helper.QueryHelper;
|
|||
import org.codelibs.fess.helper.RoleQueryHelper;
|
||||
import org.codelibs.fess.helper.SearchHelper;
|
||||
import org.codelibs.fess.helper.UserInfoHelper;
|
||||
import org.codelibs.fess.mylasta.action.FessUserBean;
|
||||
import org.codelibs.fess.thumbnail.ThumbnailManager;
|
||||
import org.codelibs.fess.util.ComponentUtil;
|
||||
import org.dbflute.optional.OptionalThing;
|
||||
|
@ -127,7 +128,7 @@ public abstract class FessSearchAction extends FessBaseAction {
|
|||
runtime.registerData("langItems", systemHelper.getLanguageItems(locale));
|
||||
final String username = systemHelper.getUsername();
|
||||
runtime.registerData("username", username);
|
||||
runtime.registerData("editableUser", fessLoginAssist.getSavedUserBean().map(user -> user.isEditable()).orElse(false));
|
||||
runtime.registerData("editableUser", fessLoginAssist.getSavedUserBean().map(FessUserBean::isEditable).orElse(false));
|
||||
runtime.registerData("adminUser", fessConfig.isAdminUser(username));
|
||||
|
||||
runtime.registerData("pageLoginLink", fessConfig.isLoginLinkEnabled());
|
||||
|
|
|
@ -55,7 +55,7 @@ public class OpenIdConnectCredential implements LoginCredential, FessCredential
|
|||
if (StringUtil.isBlank(value)) {
|
||||
return StringUtil.EMPTY_STRINGS;
|
||||
} else {
|
||||
return split(value, ",").get(stream -> stream.filter(StringUtil::isNotBlank).map(s -> s.trim()).toArray(n -> new String[n]));
|
||||
return split(value, ",").get(stream -> stream.filter(StringUtil::isNotBlank).map(String::trim).toArray(n -> new String[n]));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -64,7 +64,7 @@ public class OpenIdConnectCredential implements LoginCredential, FessCredential
|
|||
if (StringUtil.isBlank(value)) {
|
||||
return StringUtil.EMPTY_STRINGS;
|
||||
} else {
|
||||
return split(value, ",").get(stream -> stream.filter(StringUtil::isNotBlank).map(s -> s.trim()).toArray(n -> new String[n]));
|
||||
return split(value, ",").get(stream -> stream.filter(StringUtil::isNotBlank).map(String::trim).toArray(n -> new String[n]));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -17,6 +17,7 @@ package org.codelibs.fess.app.web.logout;
|
|||
|
||||
import org.codelibs.fess.app.web.base.FessSearchAction;
|
||||
import org.codelibs.fess.app.web.login.LoginAction;
|
||||
import org.codelibs.fess.mylasta.action.FessUserBean;
|
||||
import org.lastaflute.web.Execute;
|
||||
import org.lastaflute.web.response.HtmlResponse;
|
||||
|
||||
|
@ -40,7 +41,7 @@ public class LogoutAction extends FessSearchAction {
|
|||
|
||||
@Execute
|
||||
public HtmlResponse index() {
|
||||
getUserBean().map(u -> u.getUserId()).orElse("-");
|
||||
getUserBean().map(FessUserBean::getUserId).orElse("-");
|
||||
activityHelper.logout(getUserBean());
|
||||
fessLoginAssist.logout();
|
||||
userInfoHelper.deleteUserCodeFromCookie(request);
|
||||
|
|
|
@ -27,6 +27,7 @@ import org.codelibs.fess.app.service.UserService;
|
|||
import org.codelibs.fess.app.web.base.FessSearchAction;
|
||||
import org.codelibs.fess.app.web.base.login.LocalUserCredential;
|
||||
import org.codelibs.fess.app.web.login.LoginAction;
|
||||
import org.codelibs.fess.mylasta.action.FessUserBean;
|
||||
import org.lastaflute.web.Execute;
|
||||
import org.lastaflute.web.response.HtmlResponse;
|
||||
import org.lastaflute.web.validation.VaErrorHook;
|
||||
|
@ -65,7 +66,7 @@ public class ProfileAction extends FessSearchAction {
|
|||
return asIndexHtml();
|
||||
};
|
||||
validatePasswordForm(form, toIndexPage);
|
||||
final String username = getUserBean().map(u -> u.getUserId()).get();
|
||||
final String username = getUserBean().map(FessUserBean::getUserId).get();
|
||||
try {
|
||||
userService.changePassword(username, form.newPassword);
|
||||
saveInfo(messages -> messages.addSuccessChangedPassword(GLOBAL));
|
||||
|
|
|
@ -33,6 +33,7 @@ import org.codelibs.fess.Constants;
|
|||
import org.codelibs.fess.crawler.builder.RequestDataBuilder;
|
||||
import org.codelibs.fess.crawler.client.CrawlerClient;
|
||||
import org.codelibs.fess.crawler.client.CrawlerClientFactory;
|
||||
import org.codelibs.fess.crawler.entity.RequestData;
|
||||
import org.codelibs.fess.crawler.entity.ResponseData;
|
||||
import org.codelibs.fess.crawler.entity.ResultData;
|
||||
import org.codelibs.fess.crawler.exception.ChildUrlsException;
|
||||
|
@ -171,7 +172,7 @@ public class FileListIndexUpdateCallbackImpl implements IndexUpdateCallback {
|
|||
} else {
|
||||
ignoreFields = new String[] { Constants.INDEXING_TARGET, Constants.SESSION_ID };
|
||||
}
|
||||
stream(ignoreFields).of(stream -> stream.map(s -> s.trim()).forEach(s -> dataMap.remove(s)));
|
||||
stream(ignoreFields).of(stream -> stream.map(String::trim).forEach(s -> dataMap.remove(s)));
|
||||
|
||||
indexUpdateCallback.store(paramMap, dataMap);
|
||||
} else {
|
||||
|
@ -182,7 +183,7 @@ public class FileListIndexUpdateCallbackImpl implements IndexUpdateCallback {
|
|||
return null;
|
||||
} catch (final ChildUrlsException e) {
|
||||
throw new DataStoreCrawlingException(url, "Redirected to "
|
||||
+ e.getChildUrlList().stream().map(r -> r.getUrl()).collect(Collectors.joining(", ")), e);
|
||||
+ e.getChildUrlList().stream().map(RequestData::getUrl).collect(Collectors.joining(", ")), e);
|
||||
} catch (final Exception e) {
|
||||
throw new DataStoreCrawlingException(url, "Failed to add: " + dataMap, e);
|
||||
}
|
||||
|
|
|
@ -552,18 +552,18 @@ public class FessEsClient implements Client {
|
|||
final Map<String, Map<String, String>> result =
|
||||
mapper.readValue(line, new TypeReference<Map<String, Map<String, String>>>() {
|
||||
});
|
||||
if (result.keySet().contains("index")) {
|
||||
if (result.containsKey("index")) {
|
||||
return line;
|
||||
} else if (result.keySet().contains("update")) {
|
||||
} else if (result.containsKey("update")) {
|
||||
return line;
|
||||
} else if (result.keySet().contains("delete")) {
|
||||
} else if (result.containsKey("delete")) {
|
||||
return StringUtil.EMPTY;
|
||||
}
|
||||
} else {
|
||||
final Map<String, Map<String, String>> result =
|
||||
mapper.readValue(prev, new TypeReference<Map<String, Map<String, String>>>() {
|
||||
});
|
||||
if (result.keySet().contains("index")) {
|
||||
if (result.containsKey("index")) {
|
||||
final IndexRequestBuilder requestBuilder =
|
||||
client.prepareIndex().setIndex(configIndex).setId(result.get("index").get("_id"))
|
||||
.setSource(line, XContentType.JSON);
|
||||
|
|
|
@ -21,6 +21,7 @@ import java.util.Collections;
|
|||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.Properties;
|
||||
import java.util.function.Supplier;
|
||||
import java.util.regex.Pattern;
|
||||
|
@ -312,7 +313,7 @@ public class DataConfig extends BsDataConfig implements CrawlingConfig {
|
|||
final String prefix = CRAWLER_WEB_AUTH + "." + webAuthName + ".";
|
||||
final Map<String, String> parameterMap =
|
||||
paramMap.entrySet().stream().filter(e -> e.getKey().startsWith(prefix))
|
||||
.collect(Collectors.toMap(e -> e.getKey().substring(prefix.length()), e -> e.getValue()));
|
||||
.collect(Collectors.toMap(e -> e.getKey().substring(prefix.length()), Entry::getValue));
|
||||
authScheme = new FormScheme(parameterMap);
|
||||
}
|
||||
return authScheme;
|
||||
|
|
|
@ -20,6 +20,7 @@ import org.codelibs.fess.Constants;
|
|||
import org.codelibs.fess.es.config.bsentity.BsScheduledJob;
|
||||
import org.codelibs.fess.exception.JobNotFoundException;
|
||||
import org.codelibs.fess.util.ComponentUtil;
|
||||
import org.lastaflute.job.LaScheduledJob;
|
||||
import org.lastaflute.job.key.LaJobUnique;
|
||||
|
||||
/**
|
||||
|
@ -51,7 +52,7 @@ public class ScheduledJob extends BsScheduledJob {
|
|||
}
|
||||
|
||||
public boolean isRunning() {
|
||||
return ComponentUtil.getJobManager().findJobByUniqueOf(LaJobUnique.of(getId())).map(job -> job.isExecutingNow()).orElse(false);
|
||||
return ComponentUtil.getJobManager().findJobByUniqueOf(LaJobUnique.of(getId())).map(LaScheduledJob::isExecutingNow).orElse(false);
|
||||
}
|
||||
|
||||
public void start() {
|
||||
|
|
|
@ -47,8 +47,7 @@ public class GroupBhv extends BsGroupBhv {
|
|||
final RESULT result = entityType.newInstance();
|
||||
result.setName(DfTypeUtil.toString(source.get("name")));
|
||||
result.setAttributes(source.entrySet().stream().filter(e -> !"name".equals(e.getKey()))
|
||||
.map(e -> new Pair<>(e.getKey(), (String) e.getValue()))
|
||||
.collect(Collectors.toMap(t -> t.getFirst(), t -> t.getSecond())));
|
||||
.map(e -> new Pair<>(e.getKey(), (String) e.getValue())).collect(Collectors.toMap(Pair::getFirst, Pair::getSecond)));
|
||||
return result;
|
||||
} catch (InstantiationException | IllegalAccessException e) {
|
||||
final String msg = "Cannot create a new instance: " + entityType.getName();
|
||||
|
|
|
@ -47,8 +47,7 @@ public class RoleBhv extends BsRoleBhv {
|
|||
final RESULT result = entityType.newInstance();
|
||||
result.setName(DfTypeUtil.toString(source.get("name")));
|
||||
result.setAttributes(source.entrySet().stream().filter(e -> !"name".equals(e.getKey()))
|
||||
.map(e -> new Pair<>(e.getKey(), (String) e.getValue()))
|
||||
.collect(Collectors.toMap(t -> t.getFirst(), t -> t.getSecond())));
|
||||
.map(e -> new Pair<>(e.getKey(), (String) e.getValue())).collect(Collectors.toMap(Pair::getFirst, Pair::getSecond)));
|
||||
return result;
|
||||
} catch (InstantiationException | IllegalAccessException e) {
|
||||
final String msg = "Cannot create a new instance: " + entityType.getName();
|
||||
|
|
|
@ -56,8 +56,7 @@ public class UserBhv extends BsUserBhv {
|
|||
result.setGroups(toStringArray(source.get(GROUPS)));
|
||||
result.setRoles(toStringArray(source.get(ROLES)));
|
||||
result.setAttributes(source.entrySet().stream().filter(e -> isAttribute(e.getKey()))
|
||||
.map(e -> new Pair<>(e.getKey(), (String) e.getValue()))
|
||||
.collect(Collectors.toMap(t -> t.getFirst(), t -> t.getSecond())));
|
||||
.map(e -> new Pair<>(e.getKey(), (String) e.getValue())).collect(Collectors.toMap(Pair::getFirst, Pair::getSecond)));
|
||||
return result;
|
||||
} catch (InstantiationException | IllegalAccessException e) {
|
||||
final String msg = "Cannot create a new instance: " + entityType.getName();
|
||||
|
|
|
@ -55,7 +55,7 @@ public class ActivityHelper {
|
|||
buf.append(Action.LOGIN);
|
||||
buf.append('\t');
|
||||
buf.append("user:");
|
||||
buf.append(user.map(u -> u.getUserId()).orElse("-"));
|
||||
buf.append(user.map(FessUserBean::getUserId).orElse("-"));
|
||||
buf.append('\t');
|
||||
buf.append("permissions:");
|
||||
buf.append(user.map(u -> stream(u.getPermissions()).get(stream -> stream.collect(Collectors.joining(permissionSeparator))))
|
||||
|
@ -88,7 +88,7 @@ public class ActivityHelper {
|
|||
buf.append(Action.LOGOUT);
|
||||
buf.append('\t');
|
||||
buf.append("user:");
|
||||
buf.append(user.map(u -> u.getUserId()).orElse("-"));
|
||||
buf.append(user.map(FessUserBean::getUserId).orElse("-"));
|
||||
buf.append('\t');
|
||||
buf.append("permissions:");
|
||||
buf.append(user.map(u -> stream(u.getPermissions()).get(stream -> stream.collect(Collectors.joining(permissionSeparator))))
|
||||
|
@ -102,7 +102,7 @@ public class ActivityHelper {
|
|||
buf.append(Action.ACCESS);
|
||||
buf.append('\t');
|
||||
buf.append("user:");
|
||||
buf.append(user.map(u -> u.getUserId()).orElse("-"));
|
||||
buf.append(user.map(FessUserBean::getUserId).orElse("-"));
|
||||
buf.append('\t');
|
||||
buf.append("path:");
|
||||
buf.append(path);
|
||||
|
@ -118,7 +118,7 @@ public class ActivityHelper {
|
|||
buf.append(Action.UPDATE_PERMISSION);
|
||||
buf.append('\t');
|
||||
buf.append("user:");
|
||||
buf.append(user.map(u -> u.getUserId()).orElse("-"));
|
||||
buf.append(user.map(FessUserBean::getUserId).orElse("-"));
|
||||
buf.append('\t');
|
||||
buf.append("permissions:");
|
||||
buf.append(user.map(u -> stream(u.getPermissions()).get(stream -> stream.collect(Collectors.joining(permissionSeparator))))
|
||||
|
|
|
@ -178,8 +178,7 @@ public class DocumentHelper {
|
|||
throw new CrawlingAccessException("sessionId is null.");
|
||||
}
|
||||
|
||||
final CrawlerClientFactory crawlerClientFactory =
|
||||
crawlingConfig.initializeClientFactory(() -> ComponentUtil.getCrawlerClientFactory());
|
||||
final CrawlerClientFactory crawlerClientFactory = crawlingConfig.initializeClientFactory(ComponentUtil::getCrawlerClientFactory);
|
||||
final CrawlerClient client = crawlerClientFactory.getClient(url);
|
||||
if (client == null) {
|
||||
throw new CrawlingAccessException("CrawlerClient is null for " + url);
|
||||
|
|
|
@ -118,12 +118,12 @@ public class KeyMatchHelper {
|
|||
protected List<Map<String, Object>> getDocumentList(final KeyMatch keyMatch) {
|
||||
final FessEsClient fessEsClient = ComponentUtil.getFessEsClient();
|
||||
final FessConfig fessConfig = ComponentUtil.getFessConfig();
|
||||
return fessEsClient.getDocumentList(fessConfig.getIndexDocumentSearchIndex(),
|
||||
searchRequestBuilder -> {
|
||||
return SearchConditionBuilder.builder(searchRequestBuilder.setPreference(Constants.SEARCH_PREFERENCE_LOCAL))
|
||||
.searchRequestType(SearchRequestType.ADMIN_SEARCH).size(keyMatch.getMaxSize()).query(keyMatch.getQuery())
|
||||
.responseFields(new String[] { fessConfig.getIndexFieldDocId() }).build();
|
||||
});
|
||||
return fessEsClient.getDocumentList(
|
||||
fessConfig.getIndexDocumentSearchIndex(),
|
||||
searchRequestBuilder -> SearchConditionBuilder
|
||||
.builder(searchRequestBuilder.setPreference(Constants.SEARCH_PREFERENCE_LOCAL))
|
||||
.searchRequestType(SearchRequestType.ADMIN_SEARCH).size(keyMatch.getMaxSize()).query(keyMatch.getQuery())
|
||||
.responseFields(new String[] { fessConfig.getIndexFieldDocId() }).build());
|
||||
}
|
||||
|
||||
public long getReloadInterval() {
|
||||
|
|
|
@ -321,7 +321,7 @@ public class QueryHelper {
|
|||
fessConfig.getIndexFieldVersion()));
|
||||
}
|
||||
split(fessConfig.getQueryAdditionalAnalyzedFields(), ",").of(
|
||||
stream -> stream.map(s -> s.trim()).filter(StringUtil::isNotBlank).forEach(s -> notAnalyzedFieldSet.remove(s)));
|
||||
stream -> stream.map(String::trim).filter(StringUtil::isNotBlank).forEach(s -> notAnalyzedFieldSet.remove(s)));
|
||||
split(fessConfig.getQueryAdditionalDefaultFields(), ",").of(stream -> stream.filter(StringUtil::isNotBlank).map(s -> {
|
||||
final Pair<String, Float> pair = new Pair<>();
|
||||
final String[] values = s.split(":");
|
||||
|
@ -667,7 +667,7 @@ public class QueryHelper {
|
|||
"Unknown phrase query: " + query);
|
||||
}
|
||||
final String field = terms[0].field();
|
||||
final String[] texts = stream(terms).get(stream -> stream.map(term -> term.text()).toArray(n -> new String[n]));
|
||||
final String[] texts = stream(terms).get(stream -> stream.map(Term::text).toArray(n -> new String[n]));
|
||||
final String text = String.join(" ", texts);
|
||||
context.addFieldLog(field, text);
|
||||
stream(texts).of(stream -> stream.forEach(t -> context.addHighlightedQuery(t)));
|
||||
|
|
|
@ -38,6 +38,7 @@ import org.codelibs.fess.exception.InvalidAccessTokenException;
|
|||
import org.codelibs.fess.mylasta.action.FessUserBean;
|
||||
import org.codelibs.fess.mylasta.direction.FessConfig;
|
||||
import org.codelibs.fess.util.ComponentUtil;
|
||||
import org.lastaflute.web.login.LoginManager;
|
||||
import org.lastaflute.web.servlet.request.RequestManager;
|
||||
import org.lastaflute.web.util.LaRequestUtil;
|
||||
|
||||
|
@ -137,7 +138,7 @@ public class RoleQueryHelper {
|
|||
});
|
||||
} catch (final RuntimeException e) {
|
||||
try {
|
||||
requestManager.findLoginManager(FessUserBean.class).ifPresent(manager -> manager.logout());
|
||||
requestManager.findLoginManager(FessUserBean.class).ifPresent(LoginManager::logout);
|
||||
} catch (final Exception e1) {
|
||||
// ignore
|
||||
}
|
||||
|
|
|
@ -22,6 +22,7 @@ import java.util.HashSet;
|
|||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
import java.util.Map;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.Set;
|
||||
import java.util.concurrent.ExecutionException;
|
||||
import java.util.function.Consumer;
|
||||
|
@ -207,7 +208,7 @@ public class SearchHelper {
|
|||
final Map<String, DocumentField> fields = hit.getFields();
|
||||
if (fields != null) {
|
||||
docMap.putAll(fields.entrySet().stream()
|
||||
.collect(Collectors.toMap(e -> e.getKey(), e -> (Object) e.getValue().getValues())));
|
||||
.collect(Collectors.toMap(Entry::getKey, e -> (Object) e.getValue().getValues())));
|
||||
}
|
||||
|
||||
final ViewHelper viewHelper = ComponentUtil.getViewHelper();
|
||||
|
|
|
@ -127,11 +127,11 @@ public class SuggestHelper {
|
|||
public void storeSearchLog() {
|
||||
final SearchLogBhv searchLogBhv = ComponentUtil.getComponent(SearchLogBhv.class);
|
||||
|
||||
searchLogBhv.selectBulk((cb) -> {
|
||||
searchLogBhv.selectBulk(cb -> {
|
||||
final String from = LocalDateTime.now().minusDays(fessConfig.getPurgeSuggestSearchLogDay()).format(DateTimeFormatter.ISO_DATE);
|
||||
cb.query().addQuery(QueryBuilders.rangeQuery("requestedAt").gte(from));
|
||||
cb.query().addOrderBy_RequestedAt_Asc();
|
||||
}, (searchLogsList) -> indexFromSearchLog(searchLogsList));
|
||||
}, searchLogsList -> indexFromSearchLog(searchLogsList));
|
||||
}
|
||||
|
||||
public void indexFromSearchLog(final List<SearchLog> searchLogList) {
|
||||
|
|
|
@ -151,7 +151,7 @@ public class SystemHelper {
|
|||
}
|
||||
});
|
||||
|
||||
ComponentUtil.doInitProcesses(p -> p.run());
|
||||
ComponentUtil.doInitProcesses(Runnable::run);
|
||||
|
||||
parseProjectProperties();
|
||||
}
|
||||
|
@ -186,9 +186,7 @@ public class SystemHelper {
|
|||
|
||||
public String getUsername() {
|
||||
final RequestManager requestManager = ComponentUtil.getRequestManager();
|
||||
return requestManager.findUserBean(FessUserBean.class).map(user -> {
|
||||
return user.getUserId();
|
||||
}).orElse(Constants.GUEST_USER);
|
||||
return requestManager.findUserBean(FessUserBean.class).map(user -> user.getUserId()).orElse(Constants.GUEST_USER);
|
||||
}
|
||||
|
||||
public Date getCurrentTime() {
|
||||
|
|
|
@ -157,7 +157,7 @@ public class FessFwAssistantDirector extends CachedFwAssistantDirector {
|
|||
direction.directAdjustment(createActionAdjustmentProvider());
|
||||
direction.directMessage(createMessageNameList(), "fess_label");
|
||||
direction.directApiCall(createApiFailureHook());
|
||||
direction.directMultipart(() -> new FessMultipartRequestHandler());
|
||||
direction.directMultipart(FessMultipartRequestHandler::new);
|
||||
direction.directHtmlRendering(new JspHtmlRenderingProvider() {
|
||||
@Override
|
||||
protected String getShowErrorsForwardPath(final ActionRuntime runtime) {
|
||||
|
|
|
@ -287,8 +287,7 @@ public interface FessProp {
|
|||
})
|
||||
.filter(o -> o != null && keySet.add(o.getFirst()))
|
||||
.collect(HashMap<String, List<String>>::new,
|
||||
(m, d) -> m.put(d.getFirst(), Arrays.asList(d.getSecond().split(","))),
|
||||
(m, u) -> m.putAll(u)));
|
||||
(m, d) -> m.put(d.getFirst(), Arrays.asList(d.getSecond().split(","))), HashMap::putAll));
|
||||
}
|
||||
propMap.put(DEFAULT_LABEL_VALUES, map);
|
||||
}
|
||||
|
@ -823,7 +822,7 @@ public interface FessProp {
|
|||
|
||||
default String[] getIndexBackupAllTargets() {
|
||||
return split(getIndexBackupTargets() + "," + getIndexBackupLogTargets(), ",").get(
|
||||
stream -> stream.filter(StringUtil::isNotBlank).map(s -> s.trim()).toArray(n -> new String[n]));
|
||||
stream -> stream.filter(StringUtil::isNotBlank).map(String::trim).toArray(n -> new String[n]));
|
||||
}
|
||||
|
||||
String getJobSystemJobIds();
|
||||
|
@ -852,7 +851,7 @@ public interface FessProp {
|
|||
return new Pair<>(x, y);
|
||||
}
|
||||
return null;
|
||||
}).filter(v -> v != null).collect(Collectors.toMap(e -> e.getFirst(), e -> e.getSecond())));
|
||||
}).filter(v -> v != null).collect(Collectors.toMap(Pair::getFirst, Pair::getSecond)));
|
||||
propMap.put(SMB_AVAILABLE_SID_TYPES, params);
|
||||
}
|
||||
return params.get(sidType);
|
||||
|
@ -1016,7 +1015,7 @@ public interface FessProp {
|
|||
return new Pair<>(values[0], values[1]);
|
||||
}
|
||||
return null;
|
||||
}).collect(Collectors.toMap(Pair::getFirst, d -> d.getSecond())));
|
||||
}).collect(Collectors.toMap(Pair::getFirst, Pair::getSecond)));
|
||||
propMap.put(QUERY_LANGUAGE_MAPPING, params);
|
||||
}
|
||||
final Map<String, String> mapping = params;
|
||||
|
@ -1041,7 +1040,7 @@ public interface FessProp {
|
|||
if (StringUtil.isNotBlank(getQueryDefaultLanguages())) {
|
||||
String[] langs = (String[]) propMap.get(QUERY_DEFAULT_LANGUAGES);
|
||||
if (langs == null) {
|
||||
langs = split(getQueryDefaultLanguages(), ",").get(stream -> stream.map(s -> s.trim()).toArray(n -> new String[n]));
|
||||
langs = split(getQueryDefaultLanguages(), ",").get(stream -> stream.map(String::trim).toArray(n -> new String[n]));
|
||||
propMap.put(QUERY_DEFAULT_LANGUAGES, langs);
|
||||
|
||||
}
|
||||
|
@ -1215,7 +1214,7 @@ public interface FessProp {
|
|||
|
||||
default String[] getQueryGeoFieldsAsArray() {
|
||||
return split(getQueryGeoFields(), ",").get(
|
||||
stream -> stream.map(s -> s.trim()).filter(StringUtil::isNotBlank).toArray(n -> new String[n]));
|
||||
stream -> stream.map(String::trim).filter(StringUtil::isNotBlank).toArray(n -> new String[n]));
|
||||
}
|
||||
|
||||
String getSuggestSearchLogPermissions();
|
||||
|
@ -1265,7 +1264,7 @@ public interface FessProp {
|
|||
if (fieldSet == null) {
|
||||
fieldSet =
|
||||
split(getIndexAdminArrayFields(), ",").get(
|
||||
stream -> stream.filter(StringUtil::isNotBlank).map(s -> s.trim()).collect(Collectors.toSet()));
|
||||
stream -> stream.filter(StringUtil::isNotBlank).map(String::trim).collect(Collectors.toSet()));
|
||||
propMap.put(INDEX_ADMIN_ARRAY_FIELD_SET, fieldSet);
|
||||
}
|
||||
return fieldSet;
|
||||
|
@ -1278,7 +1277,7 @@ public interface FessProp {
|
|||
default List<String> invalidIndexArrayFields(final Map<String, Object> source) {
|
||||
// TODO always returns empty list
|
||||
return split(getIndexAdminArrayFields(), ",").get(
|
||||
stream -> stream.filter(StringUtil::isNotBlank).map(s -> s.trim()).filter(s -> isNonEmptyValue(source.get(s)))
|
||||
stream -> stream.filter(StringUtil::isNotBlank).map(String::trim).filter(s -> isNonEmptyValue(source.get(s)))
|
||||
.filter(s -> false) // TODO
|
||||
.collect(Collectors.toList()));
|
||||
}
|
||||
|
@ -1291,7 +1290,7 @@ public interface FessProp {
|
|||
if (fieldSet == null) {
|
||||
fieldSet =
|
||||
split(getIndexAdminDateFields(), ",").get(
|
||||
stream -> stream.filter(StringUtil::isNotBlank).map(s -> s.trim()).collect(Collectors.toSet()));
|
||||
stream -> stream.filter(StringUtil::isNotBlank).map(String::trim).collect(Collectors.toSet()));
|
||||
propMap.put(INDEX_ADMIN_DATE_FIELD_SET, fieldSet);
|
||||
}
|
||||
return fieldSet;
|
||||
|
@ -1303,7 +1302,7 @@ public interface FessProp {
|
|||
|
||||
default List<String> invalidIndexDateFields(final Map<String, Object> source) {
|
||||
return split(getIndexAdminDateFields(), ",").get(
|
||||
stream -> stream.filter(StringUtil::isNotBlank).map(s -> s.trim()).filter(s -> isNonEmptyValue(source.get(s)))
|
||||
stream -> stream.filter(StringUtil::isNotBlank).map(String::trim).filter(s -> isNonEmptyValue(source.get(s)))
|
||||
.filter(s -> !validateDateTimeString(source.get(s))).collect(Collectors.toList()));
|
||||
}
|
||||
|
||||
|
@ -1322,7 +1321,7 @@ public interface FessProp {
|
|||
if (fieldSet == null) {
|
||||
fieldSet =
|
||||
split(getIndexAdminIntegerFields(), ",").get(
|
||||
stream -> stream.filter(StringUtil::isNotBlank).map(s -> s.trim()).collect(Collectors.toSet()));
|
||||
stream -> stream.filter(StringUtil::isNotBlank).map(String::trim).collect(Collectors.toSet()));
|
||||
propMap.put(INDEX_ADMIN_INTEGER_FIELD_SET, fieldSet);
|
||||
}
|
||||
return fieldSet;
|
||||
|
@ -1335,7 +1334,7 @@ public interface FessProp {
|
|||
default List<String> invalidIndexIntegerFields(final Map<String, Object> source) {
|
||||
final IntegerTypeValidator integerValidator = new IntegerTypeValidator();
|
||||
return split(getIndexAdminIntegerFields(), ",").get(
|
||||
stream -> stream.filter(StringUtil::isNotBlank).map(s -> s.trim()).filter(s -> isNonEmptyValue(source.get(s)))
|
||||
stream -> stream.filter(StringUtil::isNotBlank).map(String::trim).filter(s -> isNonEmptyValue(source.get(s)))
|
||||
.filter(s -> !integerValidator.isValid(source.get(s).toString(), null)).collect(Collectors.toList()));
|
||||
}
|
||||
|
||||
|
@ -1347,7 +1346,7 @@ public interface FessProp {
|
|||
if (fieldSet == null) {
|
||||
fieldSet =
|
||||
split(getIndexAdminLongFields(), ",").get(
|
||||
stream -> stream.filter(StringUtil::isNotBlank).map(s -> s.trim()).collect(Collectors.toSet()));
|
||||
stream -> stream.filter(StringUtil::isNotBlank).map(String::trim).collect(Collectors.toSet()));
|
||||
propMap.put(INDEX_ADMIN_LONG_FIELD_SET, fieldSet);
|
||||
}
|
||||
return fieldSet;
|
||||
|
@ -1360,7 +1359,7 @@ public interface FessProp {
|
|||
default List<String> invalidIndexLongFields(final Map<String, Object> source) {
|
||||
final LongTypeValidator longValidator = new LongTypeValidator();
|
||||
return split(getIndexAdminLongFields(), ",").get(
|
||||
stream -> stream.filter(StringUtil::isNotBlank).map(s -> s.trim()).filter(s -> isNonEmptyValue(source.get(s)))
|
||||
stream -> stream.filter(StringUtil::isNotBlank).map(String::trim).filter(s -> isNonEmptyValue(source.get(s)))
|
||||
.filter(s -> !longValidator.isValid(source.get(s).toString(), null)).collect(Collectors.toList()));
|
||||
}
|
||||
|
||||
|
@ -1372,7 +1371,7 @@ public interface FessProp {
|
|||
if (fieldSet == null) {
|
||||
fieldSet =
|
||||
split(getIndexAdminFloatFields(), ",").get(
|
||||
stream -> stream.filter(StringUtil::isNotBlank).map(s -> s.trim()).collect(Collectors.toSet()));
|
||||
stream -> stream.filter(StringUtil::isNotBlank).map(String::trim).collect(Collectors.toSet()));
|
||||
propMap.put(INDEX_ADMIN_FLOAT_FIELD_SET, fieldSet);
|
||||
}
|
||||
return fieldSet;
|
||||
|
@ -1385,7 +1384,7 @@ public interface FessProp {
|
|||
default List<String> invalidIndexFloatFields(final Map<String, Object> source) {
|
||||
final FloatTypeValidator floatValidator = new FloatTypeValidator();
|
||||
return split(getIndexAdminFloatFields(), ",").get(
|
||||
stream -> stream.filter(StringUtil::isNotBlank).map(s -> s.trim()).filter(s -> isNonEmptyValue(source.get(s)))
|
||||
stream -> stream.filter(StringUtil::isNotBlank).map(String::trim).filter(s -> isNonEmptyValue(source.get(s)))
|
||||
.filter(s -> !floatValidator.isValid(source.get(s).toString(), null)).collect(Collectors.toList()));
|
||||
}
|
||||
|
||||
|
@ -1397,7 +1396,7 @@ public interface FessProp {
|
|||
if (fieldSet == null) {
|
||||
fieldSet =
|
||||
split(getIndexAdminDoubleFields(), ",").get(
|
||||
stream -> stream.filter(StringUtil::isNotBlank).map(s -> s.trim()).collect(Collectors.toSet()));
|
||||
stream -> stream.filter(StringUtil::isNotBlank).map(String::trim).collect(Collectors.toSet()));
|
||||
propMap.put(INDEX_ADMIN_DOUBLE_FIELD_SET, fieldSet);
|
||||
}
|
||||
return fieldSet;
|
||||
|
@ -1410,7 +1409,7 @@ public interface FessProp {
|
|||
default List<String> invalidIndexDoubleFields(final Map<String, Object> source) {
|
||||
final DoubleTypeValidator doubleValidator = new DoubleTypeValidator();
|
||||
return split(getIndexAdminDoubleFields(), ",").get(
|
||||
stream -> stream.filter(StringUtil::isNotBlank).map(s -> s.trim()).filter(s -> isNonEmptyValue(source.get(s)))
|
||||
stream -> stream.filter(StringUtil::isNotBlank).map(String::trim).filter(s -> isNonEmptyValue(source.get(s)))
|
||||
.filter(s -> !doubleValidator.isValid(source.get(s).toString(), null)).collect(Collectors.toList()));
|
||||
}
|
||||
|
||||
|
@ -1474,7 +1473,7 @@ public interface FessProp {
|
|||
if (arrayFieldSet.contains(key)) {
|
||||
value =
|
||||
split(value.toString(), "\n").get(
|
||||
stream -> stream.filter(StringUtil::isNotBlank).map(s -> s.trim()).collect(Collectors.toList()));
|
||||
stream -> stream.filter(StringUtil::isNotBlank).map(String::trim).collect(Collectors.toList()));
|
||||
} else if (dateFieldSet.contains(key)) {
|
||||
// TODO time zone
|
||||
value = FessFunctions.parseDate(value.toString());
|
||||
|
@ -1500,7 +1499,7 @@ public interface FessProp {
|
|||
default List<String> invalidIndexRequiredFields(final Map<String, Object> source) {
|
||||
final RequiredValidator requiredValidator = new RequiredValidator();
|
||||
return split(getIndexAdminRequiredFields(), ",").get(
|
||||
stream -> stream.filter(StringUtil::isNotBlank).map(s -> s.trim())
|
||||
stream -> stream.filter(StringUtil::isNotBlank).map(String::trim)
|
||||
.filter(s -> !requiredValidator.isValid(source.get(s), null)).collect(Collectors.toList()));
|
||||
}
|
||||
|
||||
|
@ -1568,7 +1567,7 @@ public interface FessProp {
|
|||
final List<String> list = new ArrayList<>(fields.length + 10);
|
||||
stream(fields).of(stream -> stream.forEach(list::add));
|
||||
split(getQueryAdditionalResponseFields(), ",").of(
|
||||
stream -> stream.filter(StringUtil::isNotBlank).map(s -> s.trim()).forEach(list::add));
|
||||
stream -> stream.filter(StringUtil::isNotBlank).map(String::trim).forEach(list::add));
|
||||
return list.toArray(new String[list.size()]);
|
||||
}
|
||||
|
||||
|
@ -1578,7 +1577,7 @@ public interface FessProp {
|
|||
final List<String> list = new ArrayList<>(fields.length + 10);
|
||||
stream(fields).of(stream -> stream.forEach(list::add));
|
||||
split(getQueryAdditionalScrollResponseFields(), ",").of(
|
||||
stream -> stream.filter(StringUtil::isNotBlank).map(s -> s.trim()).forEach(list::add));
|
||||
stream -> stream.filter(StringUtil::isNotBlank).map(String::trim).forEach(list::add));
|
||||
return list.toArray(new String[list.size()]);
|
||||
}
|
||||
|
||||
|
@ -1588,7 +1587,7 @@ public interface FessProp {
|
|||
final List<String> list = new ArrayList<>(fields.length + 10);
|
||||
stream(fields).of(stream -> stream.forEach(list::add));
|
||||
split(getQueryAdditionalCacheResponseFields(), ",").of(
|
||||
stream -> stream.filter(StringUtil::isNotBlank).map(s -> s.trim()).forEach(list::add));
|
||||
stream -> stream.filter(StringUtil::isNotBlank).map(String::trim).forEach(list::add));
|
||||
return list.toArray(new String[list.size()]);
|
||||
}
|
||||
|
||||
|
@ -1598,7 +1597,7 @@ public interface FessProp {
|
|||
final List<String> list = new ArrayList<>(fields.length + 10);
|
||||
stream(fields).of(stream -> stream.forEach(list::add));
|
||||
split(getQueryAdditionalHighlightedFields(), ",").of(
|
||||
stream -> stream.filter(StringUtil::isNotBlank).map(s -> s.trim()).forEach(list::add));
|
||||
stream -> stream.filter(StringUtil::isNotBlank).map(String::trim).forEach(list::add));
|
||||
return list.toArray(new String[list.size()]);
|
||||
}
|
||||
|
||||
|
@ -1608,7 +1607,7 @@ public interface FessProp {
|
|||
final List<String> list = new ArrayList<>(fields.length + 10);
|
||||
stream(fields).of(stream -> stream.forEach(list::add));
|
||||
split(getQueryAdditionalSearchFields(), ",").of(
|
||||
stream -> stream.filter(StringUtil::isNotBlank).map(s -> s.trim()).forEach(list::add));
|
||||
stream -> stream.filter(StringUtil::isNotBlank).map(String::trim).forEach(list::add));
|
||||
return list.toArray(new String[list.size()]);
|
||||
}
|
||||
|
||||
|
@ -1617,8 +1616,8 @@ public interface FessProp {
|
|||
default String[] getQueryAdditionalFacetFields(final String... fields) {
|
||||
final List<String> list = new ArrayList<>(fields.length + 10);
|
||||
stream(fields).of(stream -> stream.forEach(list::add));
|
||||
split(getQueryAdditionalFacetFields(), ",").of(
|
||||
stream -> stream.filter(StringUtil::isNotBlank).map(s -> s.trim()).forEach(list::add));
|
||||
split(getQueryAdditionalFacetFields(), ",")
|
||||
.of(stream -> stream.filter(StringUtil::isNotBlank).map(String::trim).forEach(list::add));
|
||||
return list.toArray(new String[list.size()]);
|
||||
}
|
||||
|
||||
|
@ -1627,8 +1626,7 @@ public interface FessProp {
|
|||
default String[] getQueryAdditionalSortFields(final String... fields) {
|
||||
final List<String> list = new ArrayList<>(fields.length + 10);
|
||||
stream(fields).of(stream -> stream.forEach(list::add));
|
||||
split(getQueryAdditionalSortFields(), ",")
|
||||
.of(stream -> stream.filter(StringUtil::isNotBlank).map(s -> s.trim()).forEach(list::add));
|
||||
split(getQueryAdditionalSortFields(), ",").of(stream -> stream.filter(StringUtil::isNotBlank).map(String::trim).forEach(list::add));
|
||||
return list.toArray(new String[list.size()]);
|
||||
}
|
||||
|
||||
|
@ -1638,7 +1636,7 @@ public interface FessProp {
|
|||
final List<String> list = new ArrayList<>(fields.length + 10);
|
||||
stream(fields).of(stream -> stream.forEach(list::add));
|
||||
split(getQueryAdditionalApiResponseFields(), ",").of(
|
||||
stream -> stream.filter(StringUtil::isNotBlank).map(s -> s.trim()).forEach(list::add));
|
||||
stream -> stream.filter(StringUtil::isNotBlank).map(String::trim).forEach(list::add));
|
||||
return list.toArray(new String[list.size()]);
|
||||
}
|
||||
|
||||
|
@ -1648,7 +1646,7 @@ public interface FessProp {
|
|||
final List<String> list = new ArrayList<>(fields.length + 10);
|
||||
stream(fields).of(stream -> stream.forEach(list::add));
|
||||
split(getQueryAdditionalNotAnalyzedFields(), ",").of(
|
||||
stream -> stream.filter(StringUtil::isNotBlank).map(s -> s.trim()).forEach(list::add));
|
||||
stream -> stream.filter(StringUtil::isNotBlank).map(String::trim).forEach(list::add));
|
||||
return list.toArray(new String[list.size()]);
|
||||
}
|
||||
|
||||
|
@ -1667,7 +1665,7 @@ public interface FessProp {
|
|||
if (fieldSet == null) {
|
||||
fieldSet =
|
||||
split(getApiAdminAccessPermissions(), ",").get(
|
||||
stream -> stream.filter(StringUtil::isNotBlank).map(s -> s.trim()).collect(Collectors.toSet()));
|
||||
stream -> stream.filter(StringUtil::isNotBlank).map(String::trim).collect(Collectors.toSet()));
|
||||
propMap.put(API_ADMIN_ACCESS_PERMISSION_SET, fieldSet);
|
||||
}
|
||||
return fieldSet;
|
||||
|
|
|
@ -33,9 +33,8 @@ public class FessActionAdjustmentProvider implements ActionAdjustmentProvider {
|
|||
|
||||
@Override
|
||||
public FormMappingOption adjustFormMapping() {
|
||||
return new FormMappingOption().filterSimpleTextParameter((parameter, meta) -> {
|
||||
return parameter.trim().replace("\r\n", "\n").replace('\r', '\n');
|
||||
});
|
||||
return new FormMappingOption().filterSimpleTextParameter((parameter, meta) -> parameter.trim().replace("\r\n", "\n")
|
||||
.replace('\r', '\n'));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -91,9 +91,7 @@ public class FessMailDeliveryDepartmentCreator {
|
|||
// override createConventionReceptionist() (see the method for the details)
|
||||
@Override
|
||||
protected SMailConventionReceptionist createConventionReceptionist() {
|
||||
return super.createConventionReceptionist().asReceiverLocale(postcard -> {
|
||||
return OptionalThing.empty();
|
||||
});
|
||||
return super.createConventionReceptionist().asReceiverLocale(postcard -> OptionalThing.empty());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -32,6 +32,7 @@ import org.elasticsearch.action.update.UpdateRequestBuilder;
|
|||
import org.elasticsearch.index.query.QueryBuilders;
|
||||
import org.elasticsearch.script.Script;
|
||||
import org.elasticsearch.script.ScriptType;
|
||||
import org.elasticsearch.search.SearchHit;
|
||||
|
||||
public abstract class ScoreBooster {
|
||||
private static final Logger logger = LogManager.getLogger(ScoreBooster.class);
|
||||
|
@ -59,7 +60,7 @@ public abstract class ScoreBooster {
|
|||
final SearchResponse response =
|
||||
client.prepareSearch(index).setQuery(QueryBuilders.termQuery(fessConfig.getIndexFieldUrl(), url)).setFetchSource(false)
|
||||
.setSize(fessConfig.getPageScoreBoosterMaxFetchSizeAsInteger()).execute().actionGet(requestTimeout);
|
||||
return Arrays.stream(response.getHits().getHits()).map(hit -> hit.getId()).toArray(n -> new String[n]);
|
||||
return Arrays.stream(response.getHits().getHits()).map(SearchHit::getId).toArray(n -> new String[n]);
|
||||
};
|
||||
|
||||
protected Function<Map<String, Object>, Long> requestHandler = params -> {
|
||||
|
|
|
@ -513,7 +513,7 @@ public class AzureAdAuthenticator implements SsoAuthenticator {
|
|||
if (StringUtil.isBlank(value)) {
|
||||
return Collections.emptyList();
|
||||
} else {
|
||||
return split(value, ",").get(stream -> stream.filter(StringUtil::isNotBlank).map(s -> s.trim()).collect(Collectors.toList()));
|
||||
return split(value, ",").get(stream -> stream.filter(StringUtil::isNotBlank).map(String::trim).collect(Collectors.toList()));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -522,7 +522,7 @@ public class AzureAdAuthenticator implements SsoAuthenticator {
|
|||
if (StringUtil.isBlank(value)) {
|
||||
return Collections.emptyList();
|
||||
} else {
|
||||
return split(value, ",").get(stream -> stream.filter(StringUtil::isNotBlank).map(s -> s.trim()).collect(Collectors.toList()));
|
||||
return split(value, ",").get(stream -> stream.filter(StringUtil::isNotBlank).map(String::trim).collect(Collectors.toList()));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -579,9 +579,7 @@ public class AzureAdAuthenticator implements SsoAuthenticator {
|
|||
|
||||
@Override
|
||||
public void resolveCredential(final LoginCredentialResolver resolver) {
|
||||
resolver.resolve(AzureAdCredential.class, credential -> {
|
||||
return OptionalEntity.of(credential.getUser());
|
||||
});
|
||||
resolver.resolve(AzureAdCredential.class, credential -> OptionalEntity.of(credential.getUser()));
|
||||
}
|
||||
|
||||
public void setAcquisitionTimeout(final long acquisitionTimeout) {
|
||||
|
|
|
@ -236,8 +236,6 @@ public class OpenIdConnectAuthenticator implements SsoAuthenticator {
|
|||
|
||||
@Override
|
||||
public void resolveCredential(final LoginCredentialResolver resolver) {
|
||||
resolver.resolve(OpenIdConnectCredential.class, credential -> {
|
||||
return OptionalEntity.of(credential.getUser());
|
||||
});
|
||||
resolver.resolve(OpenIdConnectCredential.class, credential -> OptionalEntity.of(credential.getUser()));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -104,7 +104,7 @@ public abstract class BaseThumbnailGenerator implements ThumbnailGenerator {
|
|||
final List<String> pathList = new ArrayList<>();
|
||||
pathList.add("/usr/share/fess/bin");
|
||||
if (path != null) {
|
||||
stream(path.split(File.pathSeparator)).of(stream -> stream.map(s -> s.trim()).forEach(s -> pathList.add(s)));
|
||||
stream(path.split(File.pathSeparator)).of(stream -> stream.map(String::trim).forEach(s -> pathList.add(s)));
|
||||
}
|
||||
available = generatorList.stream().map(s -> {
|
||||
if (s.startsWith("${path}")) {
|
||||
|
|
|
@ -53,9 +53,9 @@ public class SystemMonitorTarget implements TimeoutTarget {
|
|||
if (value == null) {
|
||||
buf.append("null");
|
||||
} else if (value instanceof Integer) {
|
||||
buf.append(((Integer) value));
|
||||
buf.append((value));
|
||||
} else if (value instanceof Long) {
|
||||
buf.append(((Long) value));
|
||||
buf.append((value));
|
||||
} else if (value instanceof Short) {
|
||||
buf.append(((Short) value).shortValue());
|
||||
} else if (value instanceof double[]) {
|
||||
|
@ -81,7 +81,7 @@ public class SystemMonitorTarget implements TimeoutTarget {
|
|||
appendJvmStats(buf);
|
||||
appendElasticsearchStats(buf);
|
||||
|
||||
append(buf, "timestamp", () -> System.currentTimeMillis());
|
||||
append(buf, "timestamp", System::currentTimeMillis);
|
||||
buf.append('}');
|
||||
|
||||
logger.info(buf.toString());
|
||||
|
|
|
@ -22,6 +22,8 @@ import java.util.Date;
|
|||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
|
||||
import org.codelibs.fess.Constants;
|
||||
import org.codelibs.fess.crawler.util.CharUtil;
|
||||
import org.codelibs.fess.taglib.FessFunctions;
|
||||
|
@ -55,7 +57,7 @@ public final class DocumentUtil {
|
|||
if (clazz.isAssignableFrom(List.class)) {
|
||||
return (T) value;
|
||||
} else if (clazz.isAssignableFrom(String[].class)) {
|
||||
return (T) ((List<?>) value).stream().filter(s -> s != null).map(s -> s.toString()).toArray(n -> new String[n]);
|
||||
return (T) ((List<?>) value).stream().filter(s -> s != null).map(Object::toString).toArray(n -> new String[n]);
|
||||
}
|
||||
|
||||
if (((List<?>) value).isEmpty()) {
|
||||
|
@ -134,8 +136,8 @@ public final class DocumentUtil {
|
|||
|
||||
public static String encodeUrl(final String url) {
|
||||
final String enc =
|
||||
LaRequestUtil.getOptionalRequest().filter(req -> req.getCharacterEncoding() != null).map(req -> req.getCharacterEncoding())
|
||||
.orElse(Constants.UTF_8);
|
||||
LaRequestUtil.getOptionalRequest().filter(req -> req.getCharacterEncoding() != null)
|
||||
.map(HttpServletRequest::getCharacterEncoding).orElse(Constants.UTF_8);
|
||||
final StringBuilder buf = new StringBuilder(url.length() + 100);
|
||||
for (final char c : url.toCharArray()) {
|
||||
if (CharUtil.isUrlChar(c)) {
|
||||
|
|
|
@ -230,20 +230,19 @@ public class GsaConfigParser extends DefaultHandler {
|
|||
}
|
||||
|
||||
protected String parseFilterPaths(final String text, final boolean web, final boolean file) {
|
||||
return split(text, "\n").get(stream -> stream.map(String::trim).filter(StringUtil::isNotBlank).map(s -> {
|
||||
return getFilterPath(s);
|
||||
}).filter(s -> {
|
||||
if (StringUtil.isBlank(s)) {
|
||||
return false;
|
||||
}
|
||||
if (Arrays.stream(webProtocols).anyMatch(p -> s.startsWith(p))) {
|
||||
return web;
|
||||
}
|
||||
if (Arrays.stream(fileProtocols).anyMatch(p -> s.startsWith(p))) {
|
||||
return file;
|
||||
}
|
||||
return true;
|
||||
}).collect(Collectors.joining("\n")));
|
||||
return split(text, "\n").get(
|
||||
stream -> stream.map(String::trim).filter(StringUtil::isNotBlank).map(s -> getFilterPath(s)).filter(s -> {
|
||||
if (StringUtil.isBlank(s)) {
|
||||
return false;
|
||||
}
|
||||
if (Arrays.stream(webProtocols).anyMatch(p -> s.startsWith(p))) {
|
||||
return web;
|
||||
}
|
||||
if (Arrays.stream(fileProtocols).anyMatch(p -> s.startsWith(p))) {
|
||||
return file;
|
||||
}
|
||||
return true;
|
||||
}).collect(Collectors.joining("\n")));
|
||||
}
|
||||
|
||||
protected String getFilterPath(final String s) {
|
||||
|
|
|
@ -36,7 +36,7 @@ public class RenderDataUtil {
|
|||
// care performance for List that the most frequent pattern
|
||||
final Object first = coll instanceof List<?> ? ((List<?>) coll).get(0) : coll.iterator().next();
|
||||
if (first instanceof Entity) {
|
||||
data.register(key, coll.stream().map(e -> BeanUtil.copyBeanToNewMap(e)).collect(Collectors.toList()));
|
||||
data.register(key, coll.stream().map(BeanUtil::copyBeanToNewMap).collect(Collectors.toList()));
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue