modify validations
This commit is contained in:
parent
deb920bfcf
commit
4d099d5b68
12 changed files with 376 additions and 217 deletions
|
@ -182,14 +182,16 @@ public class AdminBadwordAction extends FessAdminAction {
|
|||
// Download
|
||||
// -------
|
||||
@Execute
|
||||
public HtmlResponse downloadpage(final SearchForm form) {
|
||||
public HtmlResponse downloadpage() {
|
||||
saveToken();
|
||||
return asDownloadHtml();
|
||||
}
|
||||
|
||||
// TODO refactoring
|
||||
@Execute
|
||||
public HtmlResponse download(final SearchForm form) {
|
||||
verifyTokenKeep(() -> downloadpage(form));
|
||||
public HtmlResponse download(final DownloadForm form) {
|
||||
validate(form, messages -> {}, () -> asDownloadHtml());
|
||||
verifyToken(() -> asDownloadHtml());
|
||||
final HttpServletResponse response = LaResponseUtil.getResponse();
|
||||
response.setContentType("application/octet-stream");
|
||||
response.setHeader("Content-Disposition", "attachment; filename=\"" + "badword.csv" + "\"");
|
||||
|
@ -198,7 +200,7 @@ public class AdminBadwordAction extends FessAdminAction {
|
|||
Constants.CSV_FILE_ENCODING_PROPERTY, Constants.UTF_8)))) {
|
||||
suggestBadWordService.exportCsv(writer);
|
||||
} catch (final Exception e) {
|
||||
e.printStackTrace();
|
||||
e.printStackTrace(); // TODO
|
||||
}
|
||||
return redirect(getClass());
|
||||
}
|
||||
|
@ -207,7 +209,7 @@ public class AdminBadwordAction extends FessAdminAction {
|
|||
// Upload
|
||||
// -------
|
||||
@Execute
|
||||
public HtmlResponse uploadpage(final UploadForm form) {
|
||||
public HtmlResponse uploadpage() {
|
||||
saveToken();
|
||||
return asUploadHtml();
|
||||
}
|
||||
|
@ -263,7 +265,8 @@ public class AdminBadwordAction extends FessAdminAction {
|
|||
|
||||
@Execute
|
||||
public HtmlResponse upload(final UploadForm form) {
|
||||
verifyToken(() -> uploadpage(form));
|
||||
validate(form, messages -> {}, () -> asUploadHtml());
|
||||
verifyToken(() -> asUploadHtml());
|
||||
BufferedInputStream is = null;
|
||||
File tempFile = null;
|
||||
FileOutputStream fos = null;
|
||||
|
@ -315,7 +318,6 @@ public class AdminBadwordAction extends FessAdminAction {
|
|||
}
|
||||
}
|
||||
saveInfo(messages -> messages.addSuccessUploadSuggestBadWord(GLOBAL));
|
||||
saveToken();
|
||||
return redirect(getClass());
|
||||
}
|
||||
|
||||
|
@ -388,11 +390,11 @@ public class AdminBadwordAction extends FessAdminAction {
|
|||
}
|
||||
|
||||
private HtmlResponse asUploadHtml() {
|
||||
return asHtml(path_AdminBadword_AdminBadwordUploadJsp);
|
||||
return asHtml(path_AdminBadword_AdminBadwordUploadJsp).useForm(UploadForm.class);
|
||||
}
|
||||
|
||||
private HtmlResponse asDownloadHtml() {
|
||||
return asHtml(path_AdminBadword_AdminBadwordDownloadJsp);
|
||||
return asHtml(path_AdminBadword_AdminBadwordDownloadJsp).useForm(DownloadForm.class);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -0,0 +1,31 @@
|
|||
/*
|
||||
* Copyright 2012-2015 CodeLibs Project and the Others.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
|
||||
* either express or implied. See the License for the specific language
|
||||
* governing permissions and limitations under the License.
|
||||
*/
|
||||
package org.codelibs.fess.app.web.admin.badword;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
import org.lastaflute.web.validation.Required;
|
||||
|
||||
/**
|
||||
* @author shinsuke
|
||||
*/
|
||||
public class DownloadForm implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@Required
|
||||
public String id;
|
||||
}
|
|
@ -18,6 +18,7 @@ package org.codelibs.fess.app.web.admin.badword;
|
|||
import java.io.Serializable;
|
||||
|
||||
import org.lastaflute.web.ruts.multipart.MultipartFormFile;
|
||||
import org.lastaflute.web.validation.Required;
|
||||
|
||||
/**
|
||||
* @author codelibs
|
||||
|
@ -27,6 +28,7 @@ public class UploadForm implements Serializable {
|
|||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@Required
|
||||
public MultipartFormFile suggestBadWordFile;
|
||||
|
||||
}
|
||||
|
|
|
@ -21,6 +21,7 @@ import org.codelibs.fess.Constants;
|
|||
import org.codelibs.fess.app.pager.DuplicateHostPager;
|
||||
import org.codelibs.fess.app.service.DuplicateHostService;
|
||||
import org.codelibs.fess.app.web.CrudMode;
|
||||
import org.codelibs.fess.app.web.admin.boostdoc.SearchForm;
|
||||
import org.codelibs.fess.app.web.base.FessAdminAction;
|
||||
import org.codelibs.fess.es.config.exentity.DuplicateHost;
|
||||
import org.codelibs.fess.helper.SystemHelper;
|
||||
|
@ -29,9 +30,7 @@ import org.dbflute.optional.OptionalThing;
|
|||
import org.lastaflute.web.Execute;
|
||||
import org.lastaflute.web.callback.ActionRuntime;
|
||||
import org.lastaflute.web.response.HtmlResponse;
|
||||
import org.lastaflute.web.response.next.HtmlNext;
|
||||
import org.lastaflute.web.response.render.RenderData;
|
||||
import org.lastaflute.web.validation.VaErrorHook;
|
||||
|
||||
/**
|
||||
* @author codelibs
|
||||
|
@ -63,9 +62,7 @@ public class AdminDuplicatehostAction extends FessAdminAction {
|
|||
// ==============
|
||||
@Execute
|
||||
public HtmlResponse index(final SearchForm form) {
|
||||
return asHtml(path_AdminDuplicatehost_AdminDuplicatehostJsp).renderWith(data -> {
|
||||
searchPaging(data, form);
|
||||
});
|
||||
return asListHtml();
|
||||
}
|
||||
|
||||
@Execute
|
||||
|
@ -110,8 +107,8 @@ public class AdminDuplicatehostAction extends FessAdminAction {
|
|||
// Entry Page
|
||||
// ----------
|
||||
@Execute
|
||||
//(token = TxToken.SAVE)
|
||||
public HtmlResponse createnew() {
|
||||
saveToken();
|
||||
return asHtml(path_AdminDuplicatehost_AdminDuplicatehostEditJsp).useForm(CreateForm.class, op -> {
|
||||
op.setup(form -> {
|
||||
form.initialize();
|
||||
|
@ -121,27 +118,23 @@ public class AdminDuplicatehostAction extends FessAdminAction {
|
|||
}
|
||||
|
||||
@Execute
|
||||
//(token = TxToken.SAVE)
|
||||
public HtmlResponse edit(final EditForm form) {
|
||||
validate(form, messages -> {}, toEditHtml());
|
||||
HtmlNext next;
|
||||
switch (form.crudMode) {
|
||||
case CrudMode.EDIT: // back
|
||||
form.crudMode = CrudMode.DETAILS;
|
||||
next = path_AdminDuplicatehost_AdminDuplicatehostEditJsp;
|
||||
break;
|
||||
default:
|
||||
form.crudMode = CrudMode.EDIT;
|
||||
next = path_AdminDuplicatehost_AdminDuplicatehostEditJsp;
|
||||
break;
|
||||
}
|
||||
validate(form, messages -> {}, () -> asListHtml());
|
||||
final String id = form.id;
|
||||
duplicateHostService.getDuplicateHost(id).ifPresent(entity -> {
|
||||
copyBeanToBean(entity, form, op -> {});
|
||||
}).orElse(() -> {
|
||||
throwValidationError(messages -> messages.addErrorsCrudCouldNotFindCrudTable(GLOBAL, id), toEditHtml());
|
||||
throwValidationError(messages -> messages.addErrorsCrudCouldNotFindCrudTable(GLOBAL, id), () -> asListHtml());
|
||||
});
|
||||
return asHtml(next);
|
||||
saveToken();
|
||||
if (form.crudMode.intValue() == CrudMode.EDIT) {
|
||||
// back
|
||||
form.crudMode = CrudMode.DETAILS;
|
||||
return asDetailsHtml();
|
||||
} else {
|
||||
form.crudMode = CrudMode.EDIT;
|
||||
return asEditHtml();
|
||||
}
|
||||
}
|
||||
|
||||
// -----------------------------------------------------
|
||||
|
@ -150,6 +143,7 @@ public class AdminDuplicatehostAction extends FessAdminAction {
|
|||
@Execute
|
||||
public HtmlResponse details(final int crudMode, final String id) {
|
||||
verifyCrudMode(crudMode, CrudMode.DETAILS);
|
||||
saveToken();
|
||||
return asHtml(path_AdminDuplicatehost_AdminDuplicatehostDetailsJsp).useForm(EditForm.class, op -> {
|
||||
op.setup(form -> {
|
||||
duplicateHostService.getDuplicateHost(id).ifPresent(entity -> {
|
||||
|
@ -158,7 +152,7 @@ public class AdminDuplicatehostAction extends FessAdminAction {
|
|||
});
|
||||
form.crudMode = crudMode;
|
||||
}).orElse(() -> {
|
||||
throwValidationError(messages -> messages.addErrorsCrudCouldNotFindCrudTable(GLOBAL, id), toEditHtml());
|
||||
throwValidationError(messages -> messages.addErrorsCrudCouldNotFindCrudTable(GLOBAL, id), () -> asListHtml());
|
||||
});
|
||||
});
|
||||
});
|
||||
|
@ -170,12 +164,13 @@ public class AdminDuplicatehostAction extends FessAdminAction {
|
|||
@Execute
|
||||
public HtmlResponse create(final CreateForm form) {
|
||||
verifyCrudMode(form.crudMode, CrudMode.CREATE);
|
||||
validate(form, messages -> {}, toEditHtml());
|
||||
validate(form, messages -> {}, () -> asEditHtml());
|
||||
verifyToken(() -> asEditHtml());
|
||||
getDuplicateHost(form).ifPresent(entity -> {
|
||||
duplicateHostService.store(entity);
|
||||
saveInfo(messages -> messages.addSuccessCrudCreateCrudTable(GLOBAL));
|
||||
}).orElse(() -> {
|
||||
throwValidationError(messages -> messages.addErrorsCrudFailedToCreateCrudTable(GLOBAL), toEditHtml());
|
||||
throwValidationError(messages -> messages.addErrorsCrudFailedToCreateCrudTable(GLOBAL), () -> asEditHtml());
|
||||
});
|
||||
return redirect(getClass());
|
||||
}
|
||||
|
@ -183,12 +178,13 @@ public class AdminDuplicatehostAction extends FessAdminAction {
|
|||
@Execute
|
||||
public HtmlResponse update(final EditForm form) {
|
||||
verifyCrudMode(form.crudMode, CrudMode.EDIT);
|
||||
validate(form, messages -> {}, toEditHtml());
|
||||
validate(form, messages -> {}, () -> asEditHtml());
|
||||
verifyToken(() -> asEditHtml());
|
||||
getDuplicateHost(form).ifPresent(entity -> {
|
||||
duplicateHostService.store(entity);
|
||||
saveInfo(messages -> messages.addSuccessCrudUpdateCrudTable(GLOBAL));
|
||||
}).orElse(() -> {
|
||||
throwValidationError(messages -> messages.addErrorsCrudCouldNotFindCrudTable(GLOBAL, form.id), toEditHtml());
|
||||
throwValidationError(messages -> messages.addErrorsCrudCouldNotFindCrudTable(GLOBAL, form.id), () -> asEditHtml());
|
||||
});
|
||||
return redirect(getClass());
|
||||
}
|
||||
|
@ -196,13 +192,14 @@ public class AdminDuplicatehostAction extends FessAdminAction {
|
|||
@Execute
|
||||
public HtmlResponse delete(final EditForm form) {
|
||||
verifyCrudMode(form.crudMode, CrudMode.DETAILS);
|
||||
validate(form, messages -> {}, toEditHtml());
|
||||
validate(form, messages -> {}, () -> asDetailsHtml());
|
||||
verifyToken(() -> asDetailsHtml());
|
||||
final String id = form.id;
|
||||
duplicateHostService.getDuplicateHost(id).ifPresent(entity -> {
|
||||
duplicateHostService.delete(entity);
|
||||
saveInfo(messages -> messages.addSuccessCrudDeleteCrudTable(GLOBAL));
|
||||
}).orElse(() -> {
|
||||
throwValidationError(messages -> messages.addErrorsCrudCouldNotFindCrudTable(GLOBAL, id), toEditHtml());
|
||||
throwValidationError(messages -> messages.addErrorsCrudCouldNotFindCrudTable(GLOBAL, id), () -> asDetailsHtml());
|
||||
});
|
||||
return redirect(getClass());
|
||||
}
|
||||
|
@ -250,13 +247,29 @@ public class AdminDuplicatehostAction extends FessAdminAction {
|
|||
if (crudMode != expectedMode) {
|
||||
throwValidationError(messages -> {
|
||||
messages.addErrorsCrudInvalidMode(GLOBAL, String.valueOf(expectedMode), String.valueOf(crudMode));
|
||||
}, toEditHtml());
|
||||
}, () -> asListHtml());
|
||||
}
|
||||
}
|
||||
|
||||
protected VaErrorHook toEditHtml() {
|
||||
return () -> {
|
||||
return asHtml(path_AdminDuplicatehost_AdminDuplicatehostEditJsp);
|
||||
};
|
||||
// ===================================================================================
|
||||
// JSP
|
||||
// =========
|
||||
|
||||
private HtmlResponse asListHtml() {
|
||||
return asHtml(path_AdminDuplicatehost_AdminDuplicatehostJsp).renderWith(data -> {
|
||||
data.register("duplicateHostItems", duplicateHostService.getDuplicateHostList(duplicateHostPager)); // page navi
|
||||
}).useForm(SearchForm.class, setup -> {
|
||||
setup.setup(form -> {
|
||||
copyBeanToBean(duplicateHostPager, form, op -> op.include("id"));
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
private HtmlResponse asEditHtml() {
|
||||
return asHtml(path_AdminDuplicatehost_AdminDuplicatehostEditJsp);
|
||||
}
|
||||
|
||||
private HtmlResponse asDetailsHtml() {
|
||||
return asHtml(path_AdminDuplicatehost_AdminDuplicatehostDetailsJsp);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -37,6 +37,7 @@ import org.codelibs.fess.app.pager.SuggestElevateWordPager;
|
|||
import org.codelibs.fess.app.service.LabelTypeService;
|
||||
import org.codelibs.fess.app.service.SuggestElevateWordService;
|
||||
import org.codelibs.fess.app.web.CrudMode;
|
||||
import org.codelibs.fess.app.web.admin.badword.SearchForm;
|
||||
import org.codelibs.fess.app.web.base.FessAdminAction;
|
||||
import org.codelibs.fess.es.config.exentity.SuggestElevateWord;
|
||||
import org.codelibs.fess.exception.FessSystemException;
|
||||
|
@ -47,10 +48,8 @@ import org.dbflute.optional.OptionalThing;
|
|||
import org.lastaflute.web.Execute;
|
||||
import org.lastaflute.web.callback.ActionRuntime;
|
||||
import org.lastaflute.web.response.HtmlResponse;
|
||||
import org.lastaflute.web.response.next.HtmlNext;
|
||||
import org.lastaflute.web.response.render.RenderData;
|
||||
import org.lastaflute.web.util.LaResponseUtil;
|
||||
import org.lastaflute.web.validation.VaErrorHook;
|
||||
|
||||
/**
|
||||
* @author Keiichi Watanabe
|
||||
|
@ -86,10 +85,8 @@ public class AdminElevatewordAction extends FessAdminAction {
|
|||
// Search Execute
|
||||
// ==============
|
||||
@Execute
|
||||
public HtmlResponse index(final SearchForm form) {
|
||||
return asHtml(path_AdminElevateword_AdminElevatewordJsp).renderWith(data -> {
|
||||
searchPaging(data, form);
|
||||
});
|
||||
public HtmlResponse index() {
|
||||
return asListHtml();
|
||||
}
|
||||
|
||||
@Execute
|
||||
|
@ -134,8 +131,8 @@ public class AdminElevatewordAction extends FessAdminAction {
|
|||
// Entry Page
|
||||
// ----------
|
||||
@Execute
|
||||
//(token = TxToken.SAVE)
|
||||
public HtmlResponse createnew() {
|
||||
saveToken();
|
||||
return asHtml(path_AdminElevateword_AdminElevatewordEditJsp).useForm(CreateForm.class, op -> {
|
||||
op.setup(form -> {
|
||||
form.initialize();
|
||||
|
@ -147,29 +144,27 @@ public class AdminElevatewordAction extends FessAdminAction {
|
|||
}
|
||||
|
||||
@Execute
|
||||
//(token = TxToken.SAVE)
|
||||
public HtmlResponse edit(final EditForm form) {
|
||||
validate(form, messages -> {}, toEditHtml());
|
||||
HtmlNext next;
|
||||
switch (form.crudMode) {
|
||||
case CrudMode.EDIT: // back
|
||||
form.crudMode = CrudMode.DETAILS;
|
||||
next = path_AdminElevateword_AdminElevatewordDetailsJsp;
|
||||
break;
|
||||
default:
|
||||
form.crudMode = CrudMode.EDIT;
|
||||
next = path_AdminElevateword_AdminElevatewordEditJsp;
|
||||
break;
|
||||
}
|
||||
validate(form, messages -> {}, () -> asListHtml());
|
||||
final String id = form.id;
|
||||
suggestElevateWordService.getSuggestElevateWord(id).ifPresent(entity -> {
|
||||
copyBeanToBean(entity, form, op -> {});
|
||||
}).orElse(() -> {
|
||||
throwValidationError(messages -> messages.addErrorsCrudCouldNotFindCrudTable(GLOBAL, id), toEditHtml());
|
||||
});
|
||||
return asHtml(next).renderWith(data -> {
|
||||
registerLabels(data);
|
||||
throwValidationError(messages -> messages.addErrorsCrudCouldNotFindCrudTable(GLOBAL, id), () -> asListHtml());
|
||||
});
|
||||
saveToken();
|
||||
if (form.crudMode.intValue() == CrudMode.EDIT) {
|
||||
// back
|
||||
form.crudMode = CrudMode.DETAILS;
|
||||
return asDetailsHtml().renderWith(data -> {
|
||||
registerLabels(data);
|
||||
});
|
||||
} else {
|
||||
form.crudMode = CrudMode.EDIT;
|
||||
return asEditHtml().renderWith(data -> {
|
||||
registerLabels(data);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
// -----------------------------------------------------
|
||||
|
@ -178,6 +173,7 @@ public class AdminElevatewordAction extends FessAdminAction {
|
|||
@Execute
|
||||
public HtmlResponse details(final int crudMode, final String id) {
|
||||
verifyCrudMode(crudMode, CrudMode.DETAILS);
|
||||
saveToken();
|
||||
return asHtml(path_AdminElevateword_AdminElevatewordDetailsJsp).useForm(EditForm.class, op -> {
|
||||
op.setup(form -> {
|
||||
suggestElevateWordService.getSuggestElevateWord(id).ifPresent(entity -> {
|
||||
|
@ -186,7 +182,7 @@ public class AdminElevatewordAction extends FessAdminAction {
|
|||
});
|
||||
form.crudMode = crudMode;
|
||||
}).orElse(() -> {
|
||||
throwValidationError(messages -> messages.addErrorsCrudCouldNotFindCrudTable(GLOBAL, id), toEditHtml());
|
||||
throwValidationError(messages -> messages.addErrorsCrudCouldNotFindCrudTable(GLOBAL, id), () -> asListHtml());
|
||||
});
|
||||
});
|
||||
}).renderWith(data -> {
|
||||
|
@ -198,14 +194,16 @@ public class AdminElevatewordAction extends FessAdminAction {
|
|||
// Download
|
||||
// -------
|
||||
@Execute
|
||||
//(token = TxToken.SAVE)
|
||||
public HtmlResponse downloadpage(final SearchForm form) {
|
||||
return asHtml(path_AdminElevateword_AdminElevatewordDownloadJsp);
|
||||
public HtmlResponse downloadpage() {
|
||||
saveToken();
|
||||
return asDownloadHtml();
|
||||
}
|
||||
|
||||
// TODO refactoring
|
||||
@Execute
|
||||
//(token = TxToken.VALIDATE)
|
||||
public HtmlResponse download(final SearchForm form) {
|
||||
public HtmlResponse download(final DownloadForm form) {
|
||||
validate(form, messages -> {}, () -> asDownloadHtml());
|
||||
verifyToken(() -> asDownloadHtml());
|
||||
final HttpServletResponse response = LaResponseUtil.getResponse();
|
||||
response.setContentType("application/octet-stream");
|
||||
response.setHeader("Content-Disposition", "attachment; filename=\"" + "elevateword.csv" + "\"");
|
||||
|
@ -214,7 +212,7 @@ public class AdminElevatewordAction extends FessAdminAction {
|
|||
Constants.CSV_FILE_ENCODING_PROPERTY, Constants.UTF_8)))) {
|
||||
suggestElevateWordService.exportCsv(writer);
|
||||
} catch (final Exception e) {
|
||||
e.printStackTrace();
|
||||
e.printStackTrace(); // TODO
|
||||
}
|
||||
return asHtml(path_AdminElevateword_AdminElevatewordDownloadJsp);
|
||||
}
|
||||
|
@ -223,9 +221,9 @@ public class AdminElevatewordAction extends FessAdminAction {
|
|||
// Upload
|
||||
// -------
|
||||
@Execute
|
||||
//(token = TxToken.SAVE)
|
||||
public HtmlResponse uploadpage(final UploadForm form) {
|
||||
return asHtml(path_AdminElevateword_AdminElevatewordUploadJsp);
|
||||
public HtmlResponse uploadpage() {
|
||||
saveToken();
|
||||
return asUploadHtml();
|
||||
}
|
||||
|
||||
// -----------------------------------------------------
|
||||
|
@ -234,7 +232,8 @@ public class AdminElevatewordAction extends FessAdminAction {
|
|||
@Execute
|
||||
public HtmlResponse create(final CreateForm form) {
|
||||
verifyCrudMode(form.crudMode, CrudMode.CREATE);
|
||||
validate(form, messages -> {}, toEditHtml());
|
||||
validate(form, messages -> {}, () -> asEditHtml());
|
||||
verifyToken(() -> asEditHtml());
|
||||
getSuggestElevateWord(form).ifPresent(
|
||||
entity -> {
|
||||
suggestElevateWordService.store(entity);
|
||||
|
@ -242,7 +241,7 @@ public class AdminElevatewordAction extends FessAdminAction {
|
|||
entity.getTargetRole(), entity.getBoost());
|
||||
saveInfo(messages -> messages.addSuccessCrudCreateCrudTable(GLOBAL));
|
||||
}).orElse(() -> {
|
||||
throwValidationError(messages -> messages.addErrorsCrudFailedToCreateCrudTable(GLOBAL), toEditHtml());
|
||||
throwValidationError(messages -> messages.addErrorsCrudFailedToCreateCrudTable(GLOBAL), () -> asEditHtml());
|
||||
});
|
||||
return redirect(getClass());
|
||||
}
|
||||
|
@ -250,14 +249,15 @@ public class AdminElevatewordAction extends FessAdminAction {
|
|||
@Execute
|
||||
public HtmlResponse update(final EditForm form) {
|
||||
verifyCrudMode(form.crudMode, CrudMode.EDIT);
|
||||
validate(form, messages -> {}, toEditHtml());
|
||||
validate(form, messages -> {}, () -> asEditHtml());
|
||||
verifyToken(() -> asEditHtml());
|
||||
getSuggestElevateWord(form).ifPresent(entity -> {
|
||||
suggestElevateWordService.store(entity);
|
||||
suggestHelper.deleteAllElevateWord();
|
||||
suggestHelper.storeAllElevateWords();
|
||||
saveInfo(messages -> messages.addSuccessCrudUpdateCrudTable(GLOBAL));
|
||||
}).orElse(() -> {
|
||||
throwValidationError(messages -> messages.addErrorsCrudCouldNotFindCrudTable(GLOBAL, form.id), toEditHtml());
|
||||
throwValidationError(messages -> messages.addErrorsCrudCouldNotFindCrudTable(GLOBAL, form.id), () -> asEditHtml());
|
||||
});
|
||||
return redirect(getClass());
|
||||
}
|
||||
|
@ -265,21 +265,23 @@ public class AdminElevatewordAction extends FessAdminAction {
|
|||
@Execute
|
||||
public HtmlResponse delete(final EditForm form) {
|
||||
verifyCrudMode(form.crudMode, CrudMode.DETAILS);
|
||||
validate(form, messages -> {}, toEditHtml());
|
||||
validate(form, messages -> {}, () -> asDetailsHtml());
|
||||
verifyToken(() -> asDetailsHtml());
|
||||
final String id = form.id;
|
||||
suggestElevateWordService.getSuggestElevateWord(id).ifPresent(entity -> {
|
||||
suggestElevateWordService.delete(entity);
|
||||
suggestHelper.deleteElevateWord(entity.getSuggestWord());
|
||||
saveInfo(messages -> messages.addSuccessCrudDeleteCrudTable(GLOBAL));
|
||||
}).orElse(() -> {
|
||||
throwValidationError(messages -> messages.addErrorsCrudCouldNotFindCrudTable(GLOBAL, id), toEditHtml());
|
||||
throwValidationError(messages -> messages.addErrorsCrudCouldNotFindCrudTable(GLOBAL, id), () -> asDetailsHtml());
|
||||
});
|
||||
return redirect(getClass());
|
||||
}
|
||||
|
||||
@Execute
|
||||
//(token = TxToken.VALIDATE)
|
||||
public HtmlResponse upload(final UploadForm form) {
|
||||
validate(form, messages -> {}, () -> asUploadHtml());
|
||||
verifyToken(() -> asUploadHtml());
|
||||
BufferedInputStream is = null;
|
||||
File tempFile = null;
|
||||
FileOutputStream fos = null;
|
||||
|
@ -380,13 +382,36 @@ public class AdminElevatewordAction extends FessAdminAction {
|
|||
if (crudMode != expectedMode) {
|
||||
throwValidationError(messages -> {
|
||||
messages.addErrorsCrudInvalidMode(GLOBAL, String.valueOf(expectedMode), String.valueOf(crudMode));
|
||||
}, toEditHtml());
|
||||
}, () -> asListHtml());
|
||||
}
|
||||
}
|
||||
|
||||
protected VaErrorHook toEditHtml() {
|
||||
return () -> {
|
||||
return asHtml(path_AdminElevateword_AdminElevatewordEditJsp);
|
||||
};
|
||||
// ===================================================================================
|
||||
// JSP
|
||||
// =========
|
||||
private HtmlResponse asListHtml() {
|
||||
return asHtml(path_AdminElevateword_AdminElevatewordJsp).renderWith(data -> {
|
||||
data.register("suggestElevateWordItems", suggestElevateWordService.getSuggestElevateWordList(suggestElevateWordPager)); // page navi
|
||||
}).useForm(SearchForm.class, setup -> {
|
||||
setup.setup(form -> {
|
||||
copyBeanToBean(suggestElevateWordPager, form, op -> op.include("id"));
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
private HtmlResponse asEditHtml() {
|
||||
return asHtml(path_AdminElevateword_AdminElevatewordEditJsp);
|
||||
}
|
||||
|
||||
private HtmlResponse asDetailsHtml() {
|
||||
return asHtml(path_AdminElevateword_AdminElevatewordDetailsJsp);
|
||||
}
|
||||
|
||||
private HtmlResponse asUploadHtml() {
|
||||
return asHtml(path_AdminElevateword_AdminElevatewordUploadJsp).useForm(UploadForm.class);
|
||||
}
|
||||
|
||||
private HtmlResponse asDownloadHtml() {
|
||||
return asHtml(path_AdminElevateword_AdminElevatewordDownloadJsp);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,31 @@
|
|||
/*
|
||||
* Copyright 2012-2015 CodeLibs Project and the Others.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
|
||||
* either express or implied. See the License for the specific language
|
||||
* governing permissions and limitations under the License.
|
||||
*/
|
||||
package org.codelibs.fess.app.web.admin.elevateword;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
import org.lastaflute.web.validation.Required;
|
||||
|
||||
/**
|
||||
* @author shinsuke
|
||||
*/
|
||||
public class DownloadForm implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@Required
|
||||
public String id;
|
||||
}
|
|
@ -18,6 +18,7 @@ package org.codelibs.fess.app.web.admin.elevateword;
|
|||
import java.io.Serializable;
|
||||
|
||||
import org.lastaflute.web.ruts.multipart.MultipartFormFile;
|
||||
import org.lastaflute.web.validation.Required;
|
||||
|
||||
/**
|
||||
* @author codelibs
|
||||
|
@ -27,6 +28,7 @@ public class UploadForm implements Serializable {
|
|||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@Required
|
||||
public MultipartFormFile suggestElevateWordFile;
|
||||
|
||||
}
|
||||
|
|
|
@ -27,10 +27,9 @@ import org.lastaflute.web.Execute;
|
|||
import org.lastaflute.web.callback.ActionRuntime;
|
||||
import org.lastaflute.web.response.HtmlResponse;
|
||||
import org.lastaflute.web.response.render.RenderData;
|
||||
import org.lastaflute.web.validation.VaErrorHook;
|
||||
|
||||
/**
|
||||
* @author codelibs
|
||||
* @author shinsuke
|
||||
* @author Keiichi Watanabe
|
||||
*/
|
||||
public class AdminFailureurlAction extends FessAdminAction {
|
||||
|
@ -58,10 +57,8 @@ public class AdminFailureurlAction extends FessAdminAction {
|
|||
// Search Execute
|
||||
// ==============
|
||||
@Execute
|
||||
public HtmlResponse index(final SearchForm form) {
|
||||
return asHtml(path_AdminFailureurl_AdminFailureurlJsp).renderWith(data -> {
|
||||
searchPaging(data, form);
|
||||
});
|
||||
public HtmlResponse index() {
|
||||
return asListHtml();
|
||||
}
|
||||
|
||||
@Execute
|
||||
|
@ -116,7 +113,7 @@ public class AdminFailureurlAction extends FessAdminAction {
|
|||
});
|
||||
form.crudMode = crudMode;
|
||||
}).orElse(() -> {
|
||||
throwValidationError(messages -> messages.addErrorsCrudCouldNotFindCrudTable(GLOBAL, id), toIndexHtml());
|
||||
throwValidationError(messages -> messages.addErrorsCrudCouldNotFindCrudTable(GLOBAL, id), () -> asListHtml());
|
||||
});
|
||||
});
|
||||
});
|
||||
|
@ -129,7 +126,8 @@ public class AdminFailureurlAction extends FessAdminAction {
|
|||
@Execute
|
||||
public HtmlResponse delete(final EditForm form) {
|
||||
verifyCrudMode(form.crudMode, CrudMode.DETAILS);
|
||||
validate(form, messages -> {}, toIndexHtml());
|
||||
validate(form, messages -> {}, () -> asDetailsHtml());
|
||||
verifyToken(() -> asDetailsHtml());
|
||||
String id = form.id;
|
||||
failureUrlService.getFailureUrl(id).alwaysPresent(entity -> {
|
||||
failureUrlService.delete(entity);
|
||||
|
@ -140,7 +138,7 @@ public class AdminFailureurlAction extends FessAdminAction {
|
|||
|
||||
@Execute
|
||||
public HtmlResponse deleteall(final EditForm form) {
|
||||
validate(form, messages -> {}, toIndexHtml());
|
||||
validate(form, messages -> {}, () -> asListHtml());
|
||||
failureUrlService.deleteAll(failureUrlPager);
|
||||
saveInfo(messages -> messages.addSuccessFailureUrlDeleteAll(GLOBAL));
|
||||
return redirect(getClass());
|
||||
|
@ -153,13 +151,25 @@ public class AdminFailureurlAction extends FessAdminAction {
|
|||
if (crudMode != expectedMode) {
|
||||
throwValidationError(messages -> {
|
||||
messages.addErrorsCrudInvalidMode(GLOBAL, String.valueOf(expectedMode), String.valueOf(crudMode));
|
||||
}, toIndexHtml());
|
||||
}, () -> asListHtml());
|
||||
}
|
||||
}
|
||||
|
||||
protected VaErrorHook toIndexHtml() {
|
||||
return () -> {
|
||||
return asHtml(path_AdminFailureurl_AdminFailureurlJsp);
|
||||
};
|
||||
// ===================================================================================
|
||||
// JSP
|
||||
// =========
|
||||
|
||||
private HtmlResponse asListHtml() {
|
||||
return asHtml(path_AdminFailureurl_AdminFailureurlJsp).renderWith(data -> {
|
||||
data.register("failureUrlItems", failureUrlService.getFailureUrlList(failureUrlPager)); // page navi
|
||||
}).useForm(SearchForm.class, setup -> {
|
||||
setup.setup(form -> {
|
||||
copyBeanToBean(failureUrlPager, form, op -> op.include("url", "errorCountMin", "errorCountMax", "errorName"));
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
private HtmlResponse asDetailsHtml() {
|
||||
return asHtml(path_AdminFailureurl_AdminFailureurlDetailsJsp);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -28,6 +28,7 @@ import org.codelibs.fess.app.pager.FileAuthenticationPager;
|
|||
import org.codelibs.fess.app.service.FileAuthenticationService;
|
||||
import org.codelibs.fess.app.service.FileConfigService;
|
||||
import org.codelibs.fess.app.web.CrudMode;
|
||||
import org.codelibs.fess.app.web.admin.boostdoc.SearchForm;
|
||||
import org.codelibs.fess.app.web.base.FessAdminAction;
|
||||
import org.codelibs.fess.es.config.exentity.FileAuthentication;
|
||||
import org.codelibs.fess.es.config.exentity.FileConfig;
|
||||
|
@ -38,12 +39,11 @@ import org.dbflute.optional.OptionalThing;
|
|||
import org.lastaflute.web.Execute;
|
||||
import org.lastaflute.web.callback.ActionRuntime;
|
||||
import org.lastaflute.web.response.HtmlResponse;
|
||||
import org.lastaflute.web.response.next.HtmlNext;
|
||||
import org.lastaflute.web.response.render.RenderData;
|
||||
import org.lastaflute.web.util.LaRequestUtil;
|
||||
import org.lastaflute.web.validation.VaErrorHook;
|
||||
|
||||
/**
|
||||
* @author shinsuke
|
||||
* @author Keiichi Watanabe
|
||||
*/
|
||||
public class AdminFileauthAction extends FessAdminAction {
|
||||
|
@ -74,10 +74,8 @@ public class AdminFileauthAction extends FessAdminAction {
|
|||
// Search Execute
|
||||
// ==============
|
||||
@Execute
|
||||
public HtmlResponse index(final SearchForm form) {
|
||||
return asHtml(path_AdminFileauth_AdminFileauthJsp).renderWith(data -> {
|
||||
searchPaging(data, form);
|
||||
});
|
||||
public HtmlResponse index() {
|
||||
return asListHtml();
|
||||
}
|
||||
|
||||
@Execute
|
||||
|
@ -122,8 +120,8 @@ public class AdminFileauthAction extends FessAdminAction {
|
|||
// Entry Page
|
||||
// ----------
|
||||
@Execute
|
||||
//(token = TxToken.SAVE)
|
||||
public HtmlResponse createnew() {
|
||||
saveToken();
|
||||
return asHtml(path_AdminFileauth_AdminFileauthEditJsp).useForm(CreateForm.class, op -> {
|
||||
op.setup(form -> {
|
||||
form.initialize();
|
||||
|
@ -136,30 +134,29 @@ public class AdminFileauthAction extends FessAdminAction {
|
|||
}
|
||||
|
||||
@Execute
|
||||
//(token = TxToken.SAVE)
|
||||
public HtmlResponse edit(final EditForm form) {
|
||||
validate(form, messages -> {}, toEditHtml());
|
||||
HtmlNext next;
|
||||
switch (form.crudMode) {
|
||||
case CrudMode.EDIT: // back
|
||||
form.crudMode = CrudMode.DETAILS;
|
||||
next = path_AdminFileauth_AdminFileauthDetailsJsp;
|
||||
break;
|
||||
default:
|
||||
form.crudMode = CrudMode.EDIT;
|
||||
next = path_AdminFileauth_AdminFileauthEditJsp;
|
||||
break;
|
||||
}
|
||||
validate(form, messages -> {}, () -> asListHtml());
|
||||
final String id = form.id;
|
||||
fileAuthenticationService.getFileAuthentication(id).ifPresent(entity -> {
|
||||
copyBeanToBean(entity, form, op -> {});
|
||||
}).orElse(() -> {
|
||||
throwValidationError(messages -> messages.addErrorsCrudCouldNotFindCrudTable(GLOBAL, id), toEditHtml());
|
||||
});
|
||||
return asHtml(next).renderWith(data -> {
|
||||
registerProtocolSchemeItems(data);
|
||||
registerFileConfigItems(data);
|
||||
throwValidationError(messages -> messages.addErrorsCrudCouldNotFindCrudTable(GLOBAL, id), () -> asListHtml());
|
||||
});
|
||||
saveToken();
|
||||
if (form.crudMode.intValue() == CrudMode.EDIT) {
|
||||
// back
|
||||
form.crudMode = CrudMode.DETAILS;
|
||||
return asDetailsHtml().renderWith(data -> {
|
||||
registerProtocolSchemeItems(data);
|
||||
registerFileConfigItems(data);
|
||||
});
|
||||
} else {
|
||||
form.crudMode = CrudMode.EDIT;
|
||||
return asEditHtml().renderWith(data -> {
|
||||
registerProtocolSchemeItems(data);
|
||||
registerFileConfigItems(data);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
// -----------------------------------------------------
|
||||
|
@ -168,7 +165,8 @@ public class AdminFileauthAction extends FessAdminAction {
|
|||
@Execute
|
||||
public HtmlResponse details(final int crudMode, final String id) {
|
||||
verifyCrudMode(crudMode, CrudMode.DETAILS);
|
||||
return asHtml(path_AdminFileauth_AdminFileauthDetailsJsp).useForm(EditForm.class, op -> {
|
||||
saveToken();
|
||||
return asDetailsHtml().useForm(EditForm.class, op -> {
|
||||
op.setup(form -> {
|
||||
fileAuthenticationService.getFileAuthentication(id).ifPresent(entity -> {
|
||||
copyBeanToBean(entity, form, copyOp -> {
|
||||
|
@ -176,7 +174,7 @@ public class AdminFileauthAction extends FessAdminAction {
|
|||
});
|
||||
form.crudMode = crudMode;
|
||||
}).orElse(() -> {
|
||||
throwValidationError(messages -> messages.addErrorsCrudCouldNotFindCrudTable(GLOBAL, id), toEditHtml());
|
||||
throwValidationError(messages -> messages.addErrorsCrudCouldNotFindCrudTable(GLOBAL, id), () -> asListHtml());
|
||||
});
|
||||
});
|
||||
}).renderWith(data -> {
|
||||
|
@ -191,12 +189,13 @@ public class AdminFileauthAction extends FessAdminAction {
|
|||
@Execute
|
||||
public HtmlResponse create(final CreateForm form) {
|
||||
verifyCrudMode(form.crudMode, CrudMode.CREATE);
|
||||
validate(form, messages -> {}, toEditHtml());
|
||||
validate(form, messages -> {}, () -> asEditHtml());
|
||||
verifyToken(() -> asEditHtml());
|
||||
getFileAuthentication(form).ifPresent(entity -> {
|
||||
fileAuthenticationService.store(entity);
|
||||
saveInfo(messages -> messages.addSuccessCrudCreateCrudTable(GLOBAL));
|
||||
}).orElse(() -> {
|
||||
throwValidationError(messages -> messages.addErrorsCrudFailedToCreateCrudTable(GLOBAL), toEditHtml());
|
||||
throwValidationError(messages -> messages.addErrorsCrudFailedToCreateCrudTable(GLOBAL), () -> asEditHtml());
|
||||
});
|
||||
return redirect(getClass());
|
||||
}
|
||||
|
@ -204,12 +203,13 @@ public class AdminFileauthAction extends FessAdminAction {
|
|||
@Execute
|
||||
public HtmlResponse update(final EditForm form) {
|
||||
verifyCrudMode(form.crudMode, CrudMode.EDIT);
|
||||
validate(form, messages -> {}, toEditHtml());
|
||||
validate(form, messages -> {}, () -> asEditHtml());
|
||||
verifyToken(() -> asEditHtml());
|
||||
getFileAuthentication(form).ifPresent(entity -> {
|
||||
fileAuthenticationService.store(entity);
|
||||
saveInfo(messages -> messages.addSuccessCrudUpdateCrudTable(GLOBAL));
|
||||
}).orElse(() -> {
|
||||
throwValidationError(messages -> messages.addErrorsCrudCouldNotFindCrudTable(GLOBAL, form.id), toEditHtml());
|
||||
throwValidationError(messages -> messages.addErrorsCrudCouldNotFindCrudTable(GLOBAL, form.id), () -> asEditHtml());
|
||||
});
|
||||
return redirect(getClass());
|
||||
}
|
||||
|
@ -217,13 +217,14 @@ public class AdminFileauthAction extends FessAdminAction {
|
|||
@Execute
|
||||
public HtmlResponse delete(final EditForm form) {
|
||||
verifyCrudMode(form.crudMode, CrudMode.DETAILS);
|
||||
validate(form, messages -> {}, toEditHtml());
|
||||
validate(form, messages -> {}, () -> asDetailsHtml());
|
||||
verifyToken(() -> asDetailsHtml());
|
||||
final String id = form.id;
|
||||
fileAuthenticationService.getFileAuthentication(id).ifPresent(entity -> {
|
||||
fileAuthenticationService.delete(entity);
|
||||
saveInfo(messages -> messages.addSuccessCrudDeleteCrudTable(GLOBAL));
|
||||
}).orElse(() -> {
|
||||
throwValidationError(messages -> messages.addErrorsCrudCouldNotFindCrudTable(GLOBAL, id), toEditHtml());
|
||||
throwValidationError(messages -> messages.addErrorsCrudCouldNotFindCrudTable(GLOBAL, id), () -> asDetailsHtml());
|
||||
});
|
||||
return redirect(getClass());
|
||||
}
|
||||
|
@ -295,16 +296,30 @@ public class AdminFileauthAction extends FessAdminAction {
|
|||
if (crudMode != expectedMode) {
|
||||
throwValidationError(messages -> {
|
||||
messages.addErrorsCrudInvalidMode(GLOBAL, String.valueOf(expectedMode), String.valueOf(crudMode));
|
||||
}, toEditHtml());
|
||||
}, () -> asListHtml());
|
||||
}
|
||||
}
|
||||
|
||||
protected VaErrorHook toEditHtml() {
|
||||
return () -> {
|
||||
return asHtml(path_AdminFileauth_AdminFileauthEditJsp).renderWith(data -> {
|
||||
registerProtocolSchemeItems(data);
|
||||
registerFileConfigItems(data);
|
||||
// ===================================================================================
|
||||
// JSP
|
||||
// =========
|
||||
|
||||
private HtmlResponse asListHtml() {
|
||||
return asHtml(path_AdminFileauth_AdminFileauthJsp).renderWith(data -> {
|
||||
data.register("fileAuthenticationItems", fileAuthenticationService.getFileAuthenticationList(fileAuthenticationPager)); // page navi
|
||||
data.register("displayCreateLink", !fileConfigService.getAllFileConfigList(false, false, false, null).isEmpty());
|
||||
}).useForm(SearchForm.class, setup -> {
|
||||
setup.setup(form -> {
|
||||
copyBeanToBean(fileAuthenticationPager, form, op -> op.include("id"));
|
||||
});
|
||||
};
|
||||
});
|
||||
}
|
||||
|
||||
private HtmlResponse asEditHtml() {
|
||||
return asHtml(path_AdminFileauth_AdminFileauthEditJsp);
|
||||
}
|
||||
|
||||
private HtmlResponse asDetailsHtml() {
|
||||
return asHtml(path_AdminFileauth_AdminFileauthDetailsJsp);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -23,6 +23,7 @@ import org.codelibs.fess.app.service.FileConfigService;
|
|||
import org.codelibs.fess.app.service.LabelTypeService;
|
||||
import org.codelibs.fess.app.service.RoleTypeService;
|
||||
import org.codelibs.fess.app.web.CrudMode;
|
||||
import org.codelibs.fess.app.web.admin.boostdoc.SearchForm;
|
||||
import org.codelibs.fess.app.web.base.FessAdminAction;
|
||||
import org.codelibs.fess.es.config.exentity.FileConfig;
|
||||
import org.codelibs.fess.es.config.exentity.ScheduledJob;
|
||||
|
@ -33,13 +34,11 @@ import org.dbflute.optional.OptionalThing;
|
|||
import org.lastaflute.web.Execute;
|
||||
import org.lastaflute.web.callback.ActionRuntime;
|
||||
import org.lastaflute.web.response.HtmlResponse;
|
||||
import org.lastaflute.web.response.next.HtmlNext;
|
||||
import org.lastaflute.web.response.render.RenderData;
|
||||
import org.lastaflute.web.util.LaRequestUtil;
|
||||
import org.lastaflute.web.validation.VaErrorHook;
|
||||
|
||||
/**
|
||||
* @author codelibs
|
||||
* @author shinsuke
|
||||
* @author Keiichi Watanabe
|
||||
*/
|
||||
public class AdminFileconfigAction extends FessAdminAction {
|
||||
|
@ -71,10 +70,8 @@ public class AdminFileconfigAction extends FessAdminAction {
|
|||
// Search Execute
|
||||
// ==============
|
||||
@Execute
|
||||
public HtmlResponse index(final SearchForm form) {
|
||||
return asHtml(path_AdminFileconfig_AdminFileconfigJsp).renderWith(data -> {
|
||||
searchPaging(data, form);
|
||||
});
|
||||
public HtmlResponse index() {
|
||||
return asListHtml();
|
||||
}
|
||||
|
||||
@Execute
|
||||
|
@ -119,8 +116,8 @@ public class AdminFileconfigAction extends FessAdminAction {
|
|||
// Entry Page
|
||||
// ----------
|
||||
@Execute
|
||||
//(token = TxToken.SAVE)
|
||||
public HtmlResponse createnew() {
|
||||
saveToken();
|
||||
return asHtml(path_AdminFileconfig_AdminFileconfigEditJsp).useForm(CreateForm.class, op -> {
|
||||
op.setup(form -> {
|
||||
form.initialize();
|
||||
|
@ -132,34 +129,32 @@ public class AdminFileconfigAction extends FessAdminAction {
|
|||
}
|
||||
|
||||
@Execute
|
||||
//(token = TxToken.SAVE)
|
||||
public HtmlResponse edit(final EditForm form) {
|
||||
validate(form, messages -> {}, toEditHtml());
|
||||
HtmlNext next;
|
||||
switch (form.crudMode) {
|
||||
case CrudMode.EDIT: // back
|
||||
form.crudMode = CrudMode.DETAILS;
|
||||
next = path_AdminFileconfig_AdminFileconfigDetailsJsp;
|
||||
break;
|
||||
default:
|
||||
form.crudMode = CrudMode.EDIT;
|
||||
next = path_AdminFileconfig_AdminFileconfigEditJsp;
|
||||
break;
|
||||
}
|
||||
validate(form, messages -> {}, () -> asListHtml());
|
||||
final String id = form.id;
|
||||
fileConfigService.getFileConfig(id).ifPresent(entity -> {
|
||||
copyBeanToBean(entity, form, op -> {});
|
||||
}).orElse(() -> {
|
||||
throwValidationError(messages -> messages.addErrorsCrudCouldNotFindCrudTable(GLOBAL, id), toEditHtml());
|
||||
});
|
||||
return asHtml(next).renderWith(data -> {
|
||||
registerRolesAndLabels(data);
|
||||
throwValidationError(messages -> messages.addErrorsCrudCouldNotFindCrudTable(GLOBAL, id), () -> asListHtml());
|
||||
});
|
||||
saveToken();
|
||||
if (form.crudMode.intValue() == CrudMode.EDIT) {
|
||||
// back
|
||||
form.crudMode = CrudMode.DETAILS;
|
||||
return asDetailsHtml().renderWith(data -> {
|
||||
registerRolesAndLabels(data);
|
||||
});
|
||||
} else {
|
||||
form.crudMode = CrudMode.EDIT;
|
||||
return asEditHtml().renderWith(data -> {
|
||||
registerRolesAndLabels(data);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@Execute
|
||||
public HtmlResponse createnewjob(final EditForm form) {
|
||||
validate(form, messages -> {}, toEditHtml());
|
||||
validate(form, messages -> {}, () -> asListHtml());
|
||||
final ScheduledJob scheduledJob = new ScheduledJob();
|
||||
scheduledJob.setCrawler(true);
|
||||
return asHtml(path_AdminScheduler_AdminSchedulerEditJsp).useForm(
|
||||
|
@ -187,6 +182,7 @@ public class AdminFileconfigAction extends FessAdminAction {
|
|||
@Execute
|
||||
public HtmlResponse details(final int crudMode, final String id) {
|
||||
verifyCrudMode(crudMode, CrudMode.DETAILS);
|
||||
saveToken();
|
||||
return asHtml(path_AdminFileconfig_AdminFileconfigDetailsJsp).useForm(EditForm.class, op -> {
|
||||
op.setup(form -> {
|
||||
fileConfigService.getFileConfig(id).ifPresent(entity -> {
|
||||
|
@ -195,7 +191,7 @@ public class AdminFileconfigAction extends FessAdminAction {
|
|||
});
|
||||
form.crudMode = crudMode;
|
||||
}).orElse(() -> {
|
||||
throwValidationError(messages -> messages.addErrorsCrudCouldNotFindCrudTable(GLOBAL, id), toEditHtml());
|
||||
throwValidationError(messages -> messages.addErrorsCrudCouldNotFindCrudTable(GLOBAL, id), () -> asListHtml());
|
||||
});
|
||||
});
|
||||
}).renderWith(data -> {
|
||||
|
@ -209,12 +205,13 @@ public class AdminFileconfigAction extends FessAdminAction {
|
|||
@Execute
|
||||
public HtmlResponse create(final CreateForm form) {
|
||||
verifyCrudMode(form.crudMode, CrudMode.CREATE);
|
||||
validate(form, messages -> {}, toEditHtml());
|
||||
validate(form, messages -> {}, () -> asEditHtml());
|
||||
verifyToken(() -> asEditHtml());
|
||||
getFileConfig(form).ifPresent(entity -> {
|
||||
fileConfigService.store(entity);
|
||||
saveInfo(messages -> messages.addSuccessCrudCreateCrudTable(GLOBAL));
|
||||
}).orElse(() -> {
|
||||
throwValidationError(messages -> messages.addErrorsCrudFailedToCreateCrudTable(GLOBAL), toEditHtml());
|
||||
throwValidationError(messages -> messages.addErrorsCrudFailedToCreateCrudTable(GLOBAL), () -> asEditHtml());
|
||||
});
|
||||
return redirect(getClass());
|
||||
}
|
||||
|
@ -222,12 +219,13 @@ public class AdminFileconfigAction extends FessAdminAction {
|
|||
@Execute
|
||||
public HtmlResponse update(final EditForm form) {
|
||||
verifyCrudMode(form.crudMode, CrudMode.EDIT);
|
||||
validate(form, messages -> {}, toEditHtml());
|
||||
validate(form, messages -> {}, () -> asEditHtml());
|
||||
verifyToken(() -> asEditHtml());
|
||||
getFileConfig(form).ifPresent(entity -> {
|
||||
fileConfigService.store(entity);
|
||||
saveInfo(messages -> messages.addSuccessCrudUpdateCrudTable(GLOBAL));
|
||||
}).orElse(() -> {
|
||||
throwValidationError(messages -> messages.addErrorsCrudCouldNotFindCrudTable(GLOBAL, form.id), toEditHtml());
|
||||
throwValidationError(messages -> messages.addErrorsCrudCouldNotFindCrudTable(GLOBAL, form.id), () -> asEditHtml());
|
||||
});
|
||||
return redirect(getClass());
|
||||
}
|
||||
|
@ -235,13 +233,14 @@ public class AdminFileconfigAction extends FessAdminAction {
|
|||
@Execute
|
||||
public HtmlResponse delete(final EditForm form) {
|
||||
verifyCrudMode(form.crudMode, CrudMode.DETAILS);
|
||||
validate(form, messages -> {}, toEditHtml());
|
||||
validate(form, messages -> {}, () -> asDetailsHtml());
|
||||
verifyToken(() -> asDetailsHtml());
|
||||
final String id = form.id;
|
||||
fileConfigService.getFileConfig(id).ifPresent(entity -> {
|
||||
fileConfigService.delete(entity);
|
||||
saveInfo(messages -> messages.addSuccessCrudDeleteCrudTable(GLOBAL));
|
||||
}).orElse(() -> {
|
||||
throwValidationError(messages -> messages.addErrorsCrudCouldNotFindCrudTable(GLOBAL, id), toEditHtml());
|
||||
throwValidationError(messages -> messages.addErrorsCrudCouldNotFindCrudTable(GLOBAL, id), () -> asDetailsHtml());
|
||||
});
|
||||
return redirect(getClass());
|
||||
}
|
||||
|
@ -294,15 +293,29 @@ public class AdminFileconfigAction extends FessAdminAction {
|
|||
if (crudMode != expectedMode) {
|
||||
throwValidationError(messages -> {
|
||||
messages.addErrorsCrudInvalidMode(GLOBAL, String.valueOf(expectedMode), String.valueOf(crudMode));
|
||||
}, toEditHtml());
|
||||
}, () -> asListHtml());
|
||||
}
|
||||
}
|
||||
|
||||
protected VaErrorHook toEditHtml() {
|
||||
return () -> {
|
||||
return asHtml(path_AdminFileconfig_AdminFileconfigEditJsp).renderWith(data -> {
|
||||
registerRolesAndLabels(data);
|
||||
// ===================================================================================
|
||||
// JSP
|
||||
// =========
|
||||
|
||||
private HtmlResponse asListHtml() {
|
||||
return asHtml(path_AdminFileconfig_AdminFileconfigJsp).renderWith(data -> {
|
||||
data.register("fileConfigItems", fileConfigService.getFileConfigList(fileConfigPager)); // page navi
|
||||
}).useForm(SearchForm.class, setup -> {
|
||||
setup.setup(form -> {
|
||||
copyBeanToBean(fileConfigPager, form, op -> op.include("id"));
|
||||
});
|
||||
};
|
||||
});
|
||||
}
|
||||
|
||||
private HtmlResponse asEditHtml() {
|
||||
return asHtml(path_AdminFileconfig_AdminFileconfigEditJsp);
|
||||
}
|
||||
|
||||
private HtmlResponse asDetailsHtml() {
|
||||
return asHtml(path_AdminFileconfig_AdminFileconfigDetailsJsp);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -62,8 +62,8 @@ public class AdminGeneralAction extends FessAdminAction {
|
|||
//
|
||||
|
||||
@Execute
|
||||
//(token = TxToken.SAVE)
|
||||
public HtmlResponse index() {
|
||||
saveToken();
|
||||
return asHtml(path_AdminGeneral_AdminGeneralJsp).useForm(EditForm.class, setup -> {
|
||||
setup.setup(form -> {
|
||||
updateForm(form);
|
||||
|
@ -72,11 +72,13 @@ public class AdminGeneralAction extends FessAdminAction {
|
|||
}
|
||||
|
||||
@Execute
|
||||
//(token = TxToken.VALIDATE)
|
||||
public HtmlResponse update(final EditForm form) {
|
||||
validate(form, messages -> {}, () -> {
|
||||
return asHtml(path_AdminGeneral_AdminGeneralJsp);
|
||||
});
|
||||
verifyToken(() -> {
|
||||
return asHtml(path_AdminGeneral_AdminGeneralJsp);
|
||||
});
|
||||
|
||||
updateProperty(Constants.DIFF_CRAWLING_PROPERTY,
|
||||
form.diffCrawling != null && Constants.ON.equalsIgnoreCase(form.diffCrawling) ? Constants.TRUE : Constants.FALSE);
|
||||
|
|
|
@ -23,6 +23,7 @@ import org.codelibs.fess.Constants;
|
|||
import org.codelibs.fess.app.pager.GroupPager;
|
||||
import org.codelibs.fess.app.service.GroupService;
|
||||
import org.codelibs.fess.app.web.CrudMode;
|
||||
import org.codelibs.fess.app.web.admin.boostdoc.SearchForm;
|
||||
import org.codelibs.fess.app.web.base.FessAdminAction;
|
||||
import org.codelibs.fess.es.user.exentity.Group;
|
||||
import org.codelibs.fess.helper.SystemHelper;
|
||||
|
@ -31,9 +32,7 @@ import org.dbflute.optional.OptionalThing;
|
|||
import org.lastaflute.web.Execute;
|
||||
import org.lastaflute.web.callback.ActionRuntime;
|
||||
import org.lastaflute.web.response.HtmlResponse;
|
||||
import org.lastaflute.web.response.next.HtmlNext;
|
||||
import org.lastaflute.web.response.render.RenderData;
|
||||
import org.lastaflute.web.validation.VaErrorHook;
|
||||
|
||||
/**
|
||||
* @author shinsuke
|
||||
|
@ -64,10 +63,8 @@ public class AdminGroupAction extends FessAdminAction {
|
|||
// Search Execute
|
||||
// ==============
|
||||
@Execute
|
||||
public HtmlResponse index(final SearchForm form) {
|
||||
return asHtml(path_AdminGroup_AdminGroupJsp).renderWith(data -> {
|
||||
searchPaging(data, form);
|
||||
});
|
||||
public HtmlResponse index() {
|
||||
return asListHtml();
|
||||
}
|
||||
|
||||
@Execute
|
||||
|
@ -112,8 +109,8 @@ public class AdminGroupAction extends FessAdminAction {
|
|||
// Entry Page
|
||||
// ----------
|
||||
@Execute
|
||||
//(token = TxToken.SAVE)
|
||||
public HtmlResponse createnew() {
|
||||
saveToken();
|
||||
return asHtml(path_AdminGroup_AdminGroupEditJsp).useForm(CreateForm.class, op -> {
|
||||
op.setup(form -> {
|
||||
form.initialize();
|
||||
|
@ -123,27 +120,23 @@ public class AdminGroupAction extends FessAdminAction {
|
|||
}
|
||||
|
||||
@Execute
|
||||
//(token = TxToken.SAVE)
|
||||
public HtmlResponse edit(final EditForm form) {
|
||||
validate(form, messages -> {}, toEditHtml());
|
||||
HtmlNext next;
|
||||
switch (form.crudMode) {
|
||||
case CrudMode.EDIT: // back
|
||||
form.crudMode = CrudMode.DETAILS;
|
||||
next = path_AdminGroup_AdminGroupDetailsJsp;
|
||||
break;
|
||||
default:
|
||||
form.crudMode = CrudMode.EDIT;
|
||||
next = path_AdminGroup_AdminGroupEditJsp;
|
||||
break;
|
||||
}
|
||||
validate(form, messages -> {}, () -> asListHtml());
|
||||
final String id = form.id;
|
||||
groupService.getGroup(id).ifPresent(entity -> {
|
||||
copyBeanToBean(entity, form, op -> {});
|
||||
}).orElse(() -> {
|
||||
throwValidationError(messages -> messages.addErrorsCrudCouldNotFindCrudTable(GLOBAL, id), toEditHtml());
|
||||
throwValidationError(messages -> messages.addErrorsCrudCouldNotFindCrudTable(GLOBAL, id), () -> asListHtml());
|
||||
});
|
||||
return asHtml(next);
|
||||
saveToken();
|
||||
if (form.crudMode.intValue() == CrudMode.EDIT) {
|
||||
// back
|
||||
form.crudMode = CrudMode.DETAILS;
|
||||
return asDetailsHtml();
|
||||
} else {
|
||||
form.crudMode = CrudMode.EDIT;
|
||||
return asEditHtml();
|
||||
}
|
||||
}
|
||||
|
||||
// -----------------------------------------------------
|
||||
|
@ -152,6 +145,7 @@ public class AdminGroupAction extends FessAdminAction {
|
|||
@Execute
|
||||
public HtmlResponse details(final int crudMode, final String id) {
|
||||
verifyCrudMode(crudMode, CrudMode.DETAILS);
|
||||
saveToken();
|
||||
return asHtml(path_AdminGroup_AdminGroupDetailsJsp).useForm(EditForm.class, op -> {
|
||||
op.setup(form -> {
|
||||
groupService.getGroup(id).ifPresent(entity -> {
|
||||
|
@ -160,7 +154,7 @@ public class AdminGroupAction extends FessAdminAction {
|
|||
});
|
||||
form.crudMode = crudMode;
|
||||
}).orElse(() -> {
|
||||
throwValidationError(messages -> messages.addErrorsCrudCouldNotFindCrudTable(GLOBAL, id), toEditHtml());
|
||||
throwValidationError(messages -> messages.addErrorsCrudCouldNotFindCrudTable(GLOBAL, id), () -> asListHtml());
|
||||
});
|
||||
});
|
||||
});
|
||||
|
@ -172,12 +166,13 @@ public class AdminGroupAction extends FessAdminAction {
|
|||
@Execute
|
||||
public HtmlResponse create(final CreateForm form) {
|
||||
verifyCrudMode(form.crudMode, CrudMode.CREATE);
|
||||
validate(form, messages -> {}, toEditHtml());
|
||||
validate(form, messages -> {}, () -> asEditHtml());
|
||||
verifyToken(() -> asEditHtml());
|
||||
getGroup(form).ifPresent(entity -> {
|
||||
groupService.store(entity);
|
||||
saveInfo(messages -> messages.addSuccessCrudCreateCrudTable(GLOBAL));
|
||||
}).orElse(() -> {
|
||||
throwValidationError(messages -> messages.addErrorsCrudFailedToCreateCrudTable(GLOBAL), toEditHtml());
|
||||
throwValidationError(messages -> messages.addErrorsCrudFailedToCreateCrudTable(GLOBAL), () -> asEditHtml());
|
||||
});
|
||||
return redirect(getClass());
|
||||
}
|
||||
|
@ -185,12 +180,13 @@ public class AdminGroupAction extends FessAdminAction {
|
|||
@Execute
|
||||
public HtmlResponse update(final EditForm form) {
|
||||
verifyCrudMode(form.crudMode, CrudMode.EDIT);
|
||||
validate(form, messages -> {}, toEditHtml());
|
||||
validate(form, messages -> {}, () -> asEditHtml());
|
||||
verifyToken(() -> asEditHtml());
|
||||
getGroup(form).ifPresent(entity -> {
|
||||
groupService.store(entity);
|
||||
saveInfo(messages -> messages.addSuccessCrudUpdateCrudTable(GLOBAL));
|
||||
}).orElse(() -> {
|
||||
throwValidationError(messages -> messages.addErrorsCrudCouldNotFindCrudTable(GLOBAL, form.id), toEditHtml());
|
||||
throwValidationError(messages -> messages.addErrorsCrudCouldNotFindCrudTable(GLOBAL, form.id), () -> asEditHtml());
|
||||
});
|
||||
return redirect(getClass());
|
||||
}
|
||||
|
@ -198,13 +194,14 @@ public class AdminGroupAction extends FessAdminAction {
|
|||
@Execute
|
||||
public HtmlResponse delete(final EditForm form) {
|
||||
verifyCrudMode(form.crudMode, CrudMode.DETAILS);
|
||||
validate(form, messages -> {}, toEditHtml());
|
||||
validate(form, messages -> {}, () -> asDetailsHtml());
|
||||
verifyToken(() -> asDetailsHtml());
|
||||
final String id = form.id;
|
||||
groupService.getGroup(id).ifPresent(entity -> {
|
||||
groupService.delete(entity);
|
||||
saveInfo(messages -> messages.addSuccessCrudDeleteCrudTable(GLOBAL));
|
||||
}).orElse(() -> {
|
||||
throwValidationError(messages -> messages.addErrorsCrudCouldNotFindCrudTable(GLOBAL, id), toEditHtml());
|
||||
throwValidationError(messages -> messages.addErrorsCrudCouldNotFindCrudTable(GLOBAL, id), () -> asDetailsHtml());
|
||||
});
|
||||
return redirect(getClass());
|
||||
}
|
||||
|
@ -247,13 +244,29 @@ public class AdminGroupAction extends FessAdminAction {
|
|||
if (crudMode != expectedMode) {
|
||||
throwValidationError(messages -> {
|
||||
messages.addErrorsCrudInvalidMode(GLOBAL, String.valueOf(expectedMode), String.valueOf(crudMode));
|
||||
}, toEditHtml());
|
||||
}, () -> asListHtml());
|
||||
}
|
||||
}
|
||||
|
||||
protected VaErrorHook toEditHtml() {
|
||||
return () -> {
|
||||
return asHtml(path_AdminGroup_AdminGroupEditJsp);
|
||||
};
|
||||
// ===================================================================================
|
||||
// JSP
|
||||
// =========
|
||||
|
||||
private HtmlResponse asListHtml() {
|
||||
return asHtml(path_AdminGroup_AdminGroupJsp).renderWith(data -> {
|
||||
data.register("groupItems", groupService.getGroupList(groupPager)); // page navi
|
||||
}).useForm(SearchForm.class, setup -> {
|
||||
setup.setup(form -> {
|
||||
copyBeanToBean(groupPager, form, op -> op.include("id"));
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
private HtmlResponse asEditHtml() {
|
||||
return asHtml(path_AdminGroup_AdminGroupEditJsp);
|
||||
}
|
||||
|
||||
private HtmlResponse asDetailsHtml() {
|
||||
return asHtml(path_AdminGroup_AdminGroupDetailsJsp);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue