change order of validations
This commit is contained in:
parent
f564599168
commit
c71dc3272c
5 changed files with 22 additions and 24 deletions
|
@ -138,7 +138,6 @@ public class AdminBadwordAction extends FessAdminAction {
|
|||
}
|
||||
|
||||
@Execute
|
||||
|
||||
public HtmlResponse edit(final EditForm form) {
|
||||
validate(form, messages -> {}, () -> asListHtml());
|
||||
final String id = form.id;
|
||||
|
@ -190,7 +189,7 @@ public class AdminBadwordAction extends FessAdminAction {
|
|||
|
||||
@Execute
|
||||
public HtmlResponse download(final SearchForm form) {
|
||||
verifyTokenKeep(() -> asDownloadHtml());
|
||||
verifyTokenKeep(() -> downloadpage(form));
|
||||
final HttpServletResponse response = LaResponseUtil.getResponse();
|
||||
response.setContentType("application/octet-stream");
|
||||
response.setHeader("Content-Disposition", "attachment; filename=\"" + "badword.csv" + "\"");
|
||||
|
@ -219,8 +218,8 @@ public class AdminBadwordAction extends FessAdminAction {
|
|||
@Execute
|
||||
public HtmlResponse create(final CreateForm form) {
|
||||
verifyCrudMode(form.crudMode, CrudMode.CREATE);
|
||||
verifyToken(() -> asEditHtml());
|
||||
validate(form, messages -> {}, () -> asEditHtml());
|
||||
verifyToken(() -> asEditHtml());
|
||||
getSuggestBadWord(form).ifPresent(entity -> {
|
||||
suggestBadWordService.store(entity);
|
||||
suggestHelper.addBadWord(entity.getSuggestWord());
|
||||
|
@ -234,8 +233,8 @@ public class AdminBadwordAction extends FessAdminAction {
|
|||
@Execute
|
||||
public HtmlResponse update(final EditForm form) {
|
||||
verifyCrudMode(form.crudMode, CrudMode.EDIT);
|
||||
verifyToken(() -> asEditHtml());
|
||||
validate(form, messages -> {}, () -> asEditHtml());
|
||||
verifyToken(() -> asEditHtml());
|
||||
getSuggestBadWord(form).ifPresent(entity -> {
|
||||
suggestBadWordService.store(entity);
|
||||
suggestHelper.storeAllBadWords();
|
||||
|
@ -249,8 +248,8 @@ public class AdminBadwordAction extends FessAdminAction {
|
|||
@Execute
|
||||
public HtmlResponse delete(final EditForm form) {
|
||||
verifyCrudMode(form.crudMode, CrudMode.DETAILS);
|
||||
verifyToken(() -> asDetailsHtml());
|
||||
validate(form, messages -> {}, () -> asDetailsHtml());
|
||||
verifyToken(() -> asDetailsHtml());
|
||||
final String id = form.id;
|
||||
suggestBadWordService.getSuggestBadWord(id).ifPresent(entity -> {
|
||||
suggestBadWordService.delete(entity);
|
||||
|
@ -264,7 +263,7 @@ public class AdminBadwordAction extends FessAdminAction {
|
|||
|
||||
@Execute
|
||||
public HtmlResponse upload(final UploadForm form) {
|
||||
verifyToken(() -> asUploadHtml());
|
||||
verifyToken(() -> uploadpage(form));
|
||||
BufferedInputStream is = null;
|
||||
File tempFile = null;
|
||||
FileOutputStream fos = null;
|
||||
|
@ -380,7 +379,6 @@ public class AdminBadwordAction extends FessAdminAction {
|
|||
});
|
||||
}
|
||||
|
||||
|
||||
private HtmlResponse asEditHtml() {
|
||||
return asHtml(path_AdminBadword_AdminBadwordEditJsp);
|
||||
}
|
||||
|
|
|
@ -162,8 +162,8 @@ public class AdminBoostdocAction extends FessAdminAction {
|
|||
@Execute
|
||||
public HtmlResponse create(final CreateForm form) {
|
||||
verifyCrudMode(form.crudMode, CrudMode.CREATE);
|
||||
verifyToken(() -> asEditHtml());
|
||||
validate(form, messages -> {}, () -> asEditHtml());
|
||||
verifyToken(() -> asEditHtml());
|
||||
getBoostDocumentRule(form).ifPresent(entity -> {
|
||||
boostDocumentRuleService.store(entity);
|
||||
saveInfo(messages -> messages.addSuccessCrudCreateCrudTable(GLOBAL));
|
||||
|
@ -176,8 +176,8 @@ public class AdminBoostdocAction extends FessAdminAction {
|
|||
@Execute
|
||||
public HtmlResponse update(final EditForm form) {
|
||||
verifyCrudMode(form.crudMode, CrudMode.EDIT);
|
||||
verifyToken(() -> asEditHtml());
|
||||
validate(form, messages -> {}, () -> asEditHtml());
|
||||
verifyToken(() -> asEditHtml());
|
||||
getBoostDocumentRule(form).ifPresent(entity -> {
|
||||
boostDocumentRuleService.store(entity);
|
||||
saveInfo(messages -> messages.addSuccessCrudUpdateCrudTable(GLOBAL));
|
||||
|
@ -190,8 +190,8 @@ public class AdminBoostdocAction extends FessAdminAction {
|
|||
@Execute
|
||||
public HtmlResponse delete(final EditForm form) {
|
||||
verifyCrudMode(form.crudMode, CrudMode.DETAILS);
|
||||
verifyToken(() -> asDetailsHtml());
|
||||
validate(form, messages -> {}, () -> asDetailsHtml());
|
||||
verifyToken(() -> asDetailsHtml());
|
||||
final String id = form.id;
|
||||
boostDocumentRuleService.getBoostDocumentRule(id).ifPresent(entity -> {
|
||||
boostDocumentRuleService.delete(entity);
|
||||
|
|
|
@ -143,8 +143,8 @@ public class AdminCrawlinginfoAction extends FessAdminAction {
|
|||
@Execute
|
||||
public HtmlResponse delete(final EditForm form) {
|
||||
verifyCrudMode(form.crudMode, CrudMode.DETAILS);
|
||||
verifyToken(() -> asDetailsHtml());
|
||||
validate(form, messages -> {}, () -> asDetailsHtml());
|
||||
verifyToken(() -> asDetailsHtml());
|
||||
final String id = form.id;
|
||||
crawlingSessionService.getCrawlingSession(id).alwaysPresent(entity -> {
|
||||
crawlingSessionService.delete(entity);
|
||||
|
@ -167,15 +167,15 @@ public class AdminCrawlinginfoAction extends FessAdminAction {
|
|||
}, () -> asListHtml());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// ===================================================================================
|
||||
// JSP
|
||||
// =========
|
||||
|
||||
|
||||
private HtmlResponse asListHtml() {
|
||||
return asHtml(path_AdminCrawlinginfo_AdminCrawlinginfoJsp).renderWith(data -> {
|
||||
data.register("crawlingSessionItems", crawlingSessionService.getCrawlingSessionList(crawlingSessionPager)); // page navi
|
||||
}).useForm(SearchForm.class, setup -> {
|
||||
}).useForm(SearchForm.class, setup -> {
|
||||
setup.setup(form -> {
|
||||
copyBeanToBean(crawlingSessionPager, form, op -> op.include("id"));
|
||||
});
|
||||
|
|
|
@ -158,8 +158,8 @@ public class AdminDataconfigAction extends FessAdminAction {
|
|||
|
||||
@Execute
|
||||
public HtmlResponse createnewjob(final EditForm form) {
|
||||
verifyToken(() -> asDetailsHtml());
|
||||
validate(form, messages -> {}, () -> asDetailsHtml());
|
||||
verifyToken(() -> asDetailsHtml());
|
||||
final ScheduledJob scheduledJob = new ScheduledJob();
|
||||
scheduledJob.setCrawler(true);
|
||||
saveToken();
|
||||
|
@ -212,8 +212,8 @@ public class AdminDataconfigAction extends FessAdminAction {
|
|||
@Execute
|
||||
public HtmlResponse create(final CreateForm form) {
|
||||
verifyCrudMode(form.crudMode, CrudMode.CREATE);
|
||||
verifyToken(() -> asEditHtml());
|
||||
validate(form, messages -> {}, () -> asEditHtml());
|
||||
verifyToken(() -> asEditHtml());
|
||||
getDataConfig(form).ifPresent(entity -> {
|
||||
dataConfigService.store(entity);
|
||||
saveInfo(messages -> messages.addSuccessCrudCreateCrudTable(GLOBAL));
|
||||
|
@ -226,8 +226,8 @@ public class AdminDataconfigAction extends FessAdminAction {
|
|||
@Execute
|
||||
public HtmlResponse update(final EditForm form) {
|
||||
verifyCrudMode(form.crudMode, CrudMode.EDIT);
|
||||
verifyToken(() -> asEditHtml());
|
||||
validate(form, messages -> {}, () -> asEditHtml());
|
||||
verifyToken(() -> asEditHtml());
|
||||
getDataConfig(form).ifPresent(entity -> {
|
||||
dataConfigService.store(entity);
|
||||
saveInfo(messages -> messages.addSuccessCrudUpdateCrudTable(GLOBAL));
|
||||
|
@ -240,8 +240,8 @@ public class AdminDataconfigAction extends FessAdminAction {
|
|||
@Execute
|
||||
public HtmlResponse delete(final EditForm form) {
|
||||
verifyCrudMode(form.crudMode, CrudMode.DETAILS);
|
||||
verifyToken(() -> asDetailsHtml());
|
||||
validate(form, messages -> {}, () -> asDetailsHtml());
|
||||
verifyToken(() -> asDetailsHtml());
|
||||
final String id = form.id;
|
||||
dataConfigService.getDataConfig(id).ifPresent(entity -> {
|
||||
dataConfigService.delete(entity);
|
||||
|
|
|
@ -140,7 +140,7 @@ public class AdminDictKuromojiAction extends FessAdminAction {
|
|||
@Execute
|
||||
public HtmlResponse edit(final EditForm form) {
|
||||
validate(form, messages -> {}, () -> asListHtml(form.dictId));
|
||||
kuromojiService.getKuromojiItem(form.dictId, form.id).ifPresent(entity -> {
|
||||
kuromojiService.getKuromojiItem(form.dictId, form.id).ifPresent(entity -> {
|
||||
copyBeanToBean(entity, form, op -> {});
|
||||
}).orElse(() -> {
|
||||
throwValidationError(messages -> messages.addErrorsCrudCouldNotFindCrudTable(GLOBAL, form.getDisplayId()), () -> asListHtml(form.dictId));
|
||||
|
@ -199,8 +199,8 @@ public class AdminDictKuromojiAction extends FessAdminAction {
|
|||
|
||||
@Execute
|
||||
public ActionResponse download(final DownloadForm form) {
|
||||
verifyTokenKeep(() -> downloadpage(form.dictId));
|
||||
validate(form, messages -> {}, () -> downloadpage(form.dictId));
|
||||
verifyTokenKeep(() -> downloadpage(form.dictId));
|
||||
return kuromojiService.getKuromojiFile(form.dictId).map(file -> {
|
||||
return asStream(new File(file.getPath()).getName()).stream(out -> {
|
||||
try (InputStream inputStream = file.getInputStream()) {
|
||||
|
@ -234,8 +234,8 @@ public class AdminDictKuromojiAction extends FessAdminAction {
|
|||
|
||||
@Execute
|
||||
public HtmlResponse upload(final UploadForm form) {
|
||||
verifyToken(() -> uploadpage(form.dictId));
|
||||
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);
|
||||
|
@ -259,8 +259,8 @@ public class AdminDictKuromojiAction extends FessAdminAction {
|
|||
@Execute
|
||||
public HtmlResponse create(final CreateForm form) {
|
||||
verifyCrudMode(form.crudMode, CrudMode.CREATE, form.dictId);
|
||||
verifyToken(() -> asEditHtml());
|
||||
validate(form, messages -> {}, () -> asEditHtml());
|
||||
verifyToken(() -> asEditHtml());
|
||||
createKuromojiItem(form).ifPresent(entity -> {
|
||||
kuromojiService.store(form.dictId, entity);
|
||||
saveInfo(messages -> messages.addSuccessCrudCreateCrudTable(GLOBAL));
|
||||
|
@ -273,8 +273,8 @@ public class AdminDictKuromojiAction extends FessAdminAction {
|
|||
@Execute
|
||||
public HtmlResponse update(final EditForm form) {
|
||||
verifyCrudMode(form.crudMode, CrudMode.EDIT, form.dictId);
|
||||
verifyToken(() -> asEditHtml());
|
||||
validate(form, messages -> {}, () -> asEditHtml());
|
||||
verifyToken(() -> asEditHtml());
|
||||
createKuromojiItem(form).ifPresent(entity -> {
|
||||
kuromojiService.store(form.dictId, entity);
|
||||
saveInfo(messages -> messages.addSuccessCrudUpdateCrudTable(GLOBAL));
|
||||
|
@ -359,7 +359,7 @@ public class AdminDictKuromojiAction extends FessAdminAction {
|
|||
});
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
private HtmlResponse asEditHtml() {
|
||||
return asHtml(path_AdminDictKuromoji_AdminDictKuromojiEditJsp);
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue