modify validations
This commit is contained in:
parent
fc6306e0a4
commit
32622c816b
10 changed files with 219 additions and 212 deletions
|
@ -127,9 +127,6 @@ public class AdminDataconfigAction extends FessAdminAction {
|
|||
form.initialize();
|
||||
form.crudMode = CrudMode.CREATE;
|
||||
});
|
||||
}).renderWith(data -> {
|
||||
registerRolesAndLabels(data);
|
||||
registerHandlerNames(data);
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -146,16 +143,10 @@ public class AdminDataconfigAction extends FessAdminAction {
|
|||
if (form.crudMode.intValue() == CrudMode.EDIT) {
|
||||
// back
|
||||
form.crudMode = CrudMode.DETAILS;
|
||||
return asDetailsHtml().renderWith(data -> {
|
||||
registerRolesAndLabels(data);
|
||||
registerHandlerNames(data);
|
||||
});
|
||||
return asDetailsHtml();
|
||||
} else {
|
||||
form.crudMode = CrudMode.EDIT;
|
||||
return asEditHtml().renderWith(data -> {
|
||||
registerRolesAndLabels(data);
|
||||
registerHandlerNames(data);
|
||||
});
|
||||
return asEditHtml();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -177,9 +168,6 @@ public class AdminDataconfigAction extends FessAdminAction {
|
|||
throwValidationError(messages -> messages.addErrorsCrudCouldNotFindCrudTable(GLOBAL, id), () -> asListHtml());
|
||||
});
|
||||
});
|
||||
}).renderWith(data -> {
|
||||
registerRolesAndLabels(data);
|
||||
registerHandlerNames(data);
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -308,11 +296,17 @@ public class AdminDataconfigAction extends FessAdminAction {
|
|||
}
|
||||
|
||||
private HtmlResponse asEditHtml() {
|
||||
return asHtml(path_AdminDataconfig_AdminDataconfigEditJsp);
|
||||
return asHtml(path_AdminDataconfig_AdminDataconfigEditJsp).renderWith(data -> {
|
||||
registerRolesAndLabels(data);
|
||||
registerHandlerNames(data);
|
||||
});
|
||||
}
|
||||
|
||||
private HtmlResponse asDetailsHtml() {
|
||||
return asHtml(path_AdminDataconfig_AdminDataconfigDetailsJsp);
|
||||
return asHtml(path_AdminDataconfig_AdminDataconfigDetailsJsp).renderWith(data -> {
|
||||
registerRolesAndLabels(data);
|
||||
registerHandlerNames(data);
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -39,7 +39,6 @@ import org.dbflute.optional.OptionalThing;
|
|||
import org.lastaflute.web.Execute;
|
||||
import org.lastaflute.web.response.ActionResponse;
|
||||
import org.lastaflute.web.response.HtmlResponse;
|
||||
import org.lastaflute.web.response.next.HtmlNext;
|
||||
import org.lastaflute.web.response.render.RenderData;
|
||||
import org.lastaflute.web.ruts.process.ActionRuntime;
|
||||
import org.lastaflute.web.validation.VaErrorHook;
|
||||
|
@ -76,7 +75,7 @@ public class AdminDictSynonymAction extends FessAdminAction {
|
|||
// ==============
|
||||
@Execute
|
||||
public HtmlResponse index(final SearchForm form) {
|
||||
validate(form, messages -> {}, toIndexHtml());
|
||||
validate(form, messages -> {}, () -> asDictIndexHtml());
|
||||
return asHtml(path_AdminDictSynonym_AdminDictSynonymJsp).renderWith(data -> {
|
||||
searchPaging(data, form);
|
||||
});
|
||||
|
@ -84,7 +83,7 @@ public class AdminDictSynonymAction extends FessAdminAction {
|
|||
|
||||
@Execute
|
||||
public HtmlResponse list(final OptionalThing<Integer> pageNumber, final SearchForm form) {
|
||||
validate(form, messages -> {}, toIndexHtml());
|
||||
validate(form, messages -> {}, () -> asDictIndexHtml());
|
||||
pageNumber.ifPresent(num -> {
|
||||
synonymPager.setCurrentPageNumber(pageNumber.get());
|
||||
}).orElse(() -> {
|
||||
|
@ -97,7 +96,7 @@ public class AdminDictSynonymAction extends FessAdminAction {
|
|||
|
||||
@Execute
|
||||
public HtmlResponse search(final SearchForm form) {
|
||||
validate(form, messages -> {}, toIndexHtml());
|
||||
validate(form, messages -> {}, () -> asDictIndexHtml());
|
||||
copyBeanToBean(form, synonymPager, op -> op.exclude(Constants.PAGER_CONVERSION_RULE));
|
||||
return asHtml(path_AdminDictSynonym_AdminDictSynonymJsp).renderWith(data -> {
|
||||
searchPaging(data, form);
|
||||
|
@ -106,7 +105,7 @@ public class AdminDictSynonymAction extends FessAdminAction {
|
|||
|
||||
@Execute
|
||||
public HtmlResponse reset(final SearchForm form) {
|
||||
validate(form, messages -> {}, toIndexHtml());
|
||||
validate(form, messages -> {}, () -> asDictIndexHtml());
|
||||
synonymPager.clear();
|
||||
return asHtml(path_AdminDictSynonym_AdminDictSynonymJsp).renderWith(data -> {
|
||||
searchPaging(data, form);
|
||||
|
@ -130,8 +129,8 @@ public class AdminDictSynonymAction extends FessAdminAction {
|
|||
// Entry Page
|
||||
// ----------
|
||||
@Execute
|
||||
//(token = TxToken.SAVE)
|
||||
public HtmlResponse createnew(final String dictId) {
|
||||
saveToken();
|
||||
return asHtml(path_AdminDictSynonym_AdminDictSynonymEditJsp).useForm(CreateForm.class, op -> {
|
||||
op.setup(form -> {
|
||||
form.initialize();
|
||||
|
@ -142,27 +141,27 @@ public class AdminDictSynonymAction 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
|
||||
validate(form, messages -> {}, () -> asListHtml(form.dictId));
|
||||
synonymService
|
||||
.getSynonymItem(form.dictId, form.id)
|
||||
.ifPresent(entity -> {
|
||||
form.inputs = entity.getInputsValue();
|
||||
form.outputs = entity.getOutputsValue();
|
||||
})
|
||||
.orElse(() -> {
|
||||
throwValidationError(messages -> messages.addErrorsCrudCouldNotFindCrudTable(GLOBAL, form.getDisplayId()),
|
||||
() -> asListHtml(form.dictId));
|
||||
});
|
||||
saveToken();
|
||||
if (form.crudMode.intValue() == CrudMode.EDIT) {
|
||||
// back
|
||||
form.crudMode = CrudMode.DETAILS;
|
||||
next = path_AdminDictSynonym_AdminDictSynonymDetailsJsp;
|
||||
break;
|
||||
default:
|
||||
return asDetailsHtml();
|
||||
} else {
|
||||
form.crudMode = CrudMode.EDIT;
|
||||
next = path_AdminDictSynonym_AdminDictSynonymEditJsp;
|
||||
break;
|
||||
return asEditHtml();
|
||||
}
|
||||
synonymService.getSynonymItem(form.dictId, form.id).ifPresent(entity -> {
|
||||
form.inputs = entity.getInputsValue();
|
||||
form.outputs = entity.getOutputsValue();
|
||||
}).orElse(() -> {
|
||||
throwValidationError(messages -> messages.addErrorsCrudCouldNotFindCrudTable(GLOBAL, form.getDisplayId()), toEditHtml());
|
||||
});
|
||||
return asHtml(next);
|
||||
}
|
||||
|
||||
// -----------------------------------------------------
|
||||
|
@ -170,56 +169,36 @@ public class AdminDictSynonymAction extends FessAdminAction {
|
|||
// -------
|
||||
@Execute
|
||||
public HtmlResponse details(final String dictId, final int crudMode, final long id) {
|
||||
verifyCrudMode(crudMode, CrudMode.DETAILS);
|
||||
return asHtml(path_AdminDictSynonym_AdminDictSynonymDetailsJsp).useForm(EditForm.class, op -> {
|
||||
op.setup(form -> {
|
||||
synonymService.getSynonymItem(dictId, id).ifPresent(entity -> {
|
||||
form.inputs = entity.getInputsValue();
|
||||
form.outputs = entity.getOutputsValue();
|
||||
}).orElse(() -> {
|
||||
throwValidationError(messages -> messages.addErrorsCrudCouldNotFindCrudTable(GLOBAL, dictId + ":" + id), toEditHtml());
|
||||
verifyCrudMode(crudMode, CrudMode.DETAILS, dictId);
|
||||
saveToken();
|
||||
return asDetailsHtml().useForm(
|
||||
EditForm.class,
|
||||
op -> {
|
||||
op.setup(form -> {
|
||||
synonymService
|
||||
.getSynonymItem(dictId, id)
|
||||
.ifPresent(entity -> {
|
||||
form.inputs = entity.getInputsValue();
|
||||
form.outputs = entity.getOutputsValue();
|
||||
})
|
||||
.orElse(() -> {
|
||||
throwValidationError(
|
||||
messages -> messages.addErrorsCrudCouldNotFindCrudTable(GLOBAL, dictId + ":" + id),
|
||||
() -> asListHtml(dictId));
|
||||
});
|
||||
form.id = id;
|
||||
form.crudMode = crudMode;
|
||||
form.dictId = dictId;
|
||||
});
|
||||
});
|
||||
form.id = id;
|
||||
form.crudMode = crudMode;
|
||||
form.dictId = dictId;
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
// -----------------------------------------------------
|
||||
// Confirm
|
||||
// -------
|
||||
|
||||
@Execute
|
||||
//(token = TxToken.VALIDATE_KEEP)
|
||||
public HtmlResponse confirmfromcreate(final CreateForm form) {
|
||||
validate(form, messages -> {}, toEditHtml());
|
||||
form.crudMode = CrudMode.CREATE;
|
||||
final String[] newInputs = splitLine(form.inputs);
|
||||
validateSynonymString(newInputs, () -> createnew(form.dictId));
|
||||
final String[] newOutputs = splitLine(form.outputs);
|
||||
validateSynonymString(newOutputs, () -> createnew(form.dictId));
|
||||
return asHtml(path_AdminDictSynonym_AdminDictSynonymDetailsJsp);
|
||||
}
|
||||
|
||||
@Execute
|
||||
//(token = TxToken.VALIDATE_KEEP)
|
||||
public HtmlResponse confirmfromupdate(final EditForm form) {
|
||||
validate(form, messages -> {}, toEditHtml());
|
||||
form.crudMode = CrudMode.EDIT;
|
||||
final String[] newInputs = splitLine(form.inputs);
|
||||
validateSynonymString(newInputs, () -> edit(form));
|
||||
final String[] newOutputs = splitLine(form.outputs);
|
||||
validateSynonymString(newOutputs, () -> edit(form));
|
||||
return asHtml(path_AdminDictSynonym_AdminDictSynonymDetailsJsp);
|
||||
}
|
||||
|
||||
// -----------------------------------------------------
|
||||
// Download
|
||||
// -------
|
||||
@Execute
|
||||
//(token = TxToken.VALIDATE)
|
||||
public HtmlResponse downloadpage(final String dictId) {
|
||||
saveToken();
|
||||
return asHtml(path_AdminDictSynonym_AdminDictSynonymDownloadJsp).useForm(DownloadForm.class, op -> {
|
||||
op.setup(form -> {
|
||||
form.dictId = dictId;
|
||||
|
@ -228,15 +207,15 @@ public class AdminDictSynonymAction extends FessAdminAction {
|
|||
synonymService.getSynonymFile(dictId).ifPresent(file -> {
|
||||
data.register("path", file.getPath());
|
||||
}).orElse(() -> {
|
||||
throwValidationError(messages -> messages.addErrorsFailedToDownloadSynonymFile(GLOBAL), toIndexHtml());
|
||||
throwValidationError(messages -> messages.addErrorsFailedToDownloadSynonymFile(GLOBAL), () -> asDictIndexHtml());
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
@Execute
|
||||
//(token = TxToken.VALIDATE)
|
||||
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()).stream(out -> {
|
||||
try (InputStream inputStream = file.getInputStream()) {
|
||||
|
@ -253,8 +232,8 @@ public class AdminDictSynonymAction extends FessAdminAction {
|
|||
// Upload
|
||||
// -------
|
||||
@Execute
|
||||
//(token = TxToken.VALIDATE)
|
||||
public HtmlResponse uploadpage(final String dictId) {
|
||||
saveToken();
|
||||
return asHtml(path_AdminDictSynonym_AdminDictSynonymUploadJsp).useForm(UploadForm.class, op -> {
|
||||
op.setup(form -> {
|
||||
form.dictId = dictId;
|
||||
|
@ -263,15 +242,15 @@ public class AdminDictSynonymAction extends FessAdminAction {
|
|||
synonymService.getSynonymFile(dictId).ifPresent(file -> {
|
||||
data.register("path", file.getPath());
|
||||
}).orElse(() -> {
|
||||
throwValidationError(messages -> messages.addErrorsFailedToDownloadSynonymFile(GLOBAL), toIndexHtml());
|
||||
throwValidationError(messages -> messages.addErrorsFailedToDownloadSynonymFile(GLOBAL), () -> asDictIndexHtml());
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
@Execute
|
||||
//(token = TxToken.VALIDATE)
|
||||
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);
|
||||
|
@ -294,40 +273,47 @@ public class AdminDictSynonymAction extends FessAdminAction {
|
|||
// -------------
|
||||
@Execute
|
||||
public HtmlResponse create(final CreateForm form) {
|
||||
verifyCrudMode(form.crudMode, CrudMode.CREATE);
|
||||
validate(form, messages -> {}, toEditHtml());
|
||||
createSynonymItem(form).ifPresent(entity -> {
|
||||
verifyCrudMode(form.crudMode, CrudMode.CREATE, form.dictId);
|
||||
validate(form, messages -> {}, () -> asEditHtml());
|
||||
verifyToken(() -> asEditHtml());
|
||||
createSynonymItem(form, () -> asEditHtml()).ifPresent(entity -> {
|
||||
synonymService.store(form.dictId, entity);
|
||||
saveInfo(messages -> messages.addSuccessCrudCreateCrudTable(GLOBAL));
|
||||
}).orElse(() -> {
|
||||
throwValidationError(messages -> messages.addErrorsCrudFailedToCreateCrudTable(GLOBAL), toEditHtml());
|
||||
throwValidationError(messages -> messages.addErrorsCrudFailedToCreateCrudTable(GLOBAL), () -> asEditHtml());
|
||||
});
|
||||
return redirectWith(getClass(), moreUrl("list/1").params("dictId", form.dictId));
|
||||
}
|
||||
|
||||
@Execute
|
||||
public HtmlResponse update(final EditForm form) {
|
||||
verifyCrudMode(form.crudMode, CrudMode.EDIT);
|
||||
validate(form, messages -> {}, toEditHtml());
|
||||
createSynonymItem(form).ifPresent(entity -> {
|
||||
verifyCrudMode(form.crudMode, CrudMode.EDIT, form.dictId);
|
||||
validate(form, messages -> {}, () -> asEditHtml());
|
||||
verifyToken(() -> asEditHtml());
|
||||
createSynonymItem(form, () -> asEditHtml()).ifPresent(entity -> {
|
||||
synonymService.store(form.dictId, entity);
|
||||
saveInfo(messages -> messages.addSuccessCrudUpdateCrudTable(GLOBAL));
|
||||
}).orElse(() -> {
|
||||
throwValidationError(messages -> messages.addErrorsCrudCouldNotFindCrudTable(GLOBAL, form.getDisplayId()), toEditHtml());
|
||||
throwValidationError(messages -> messages.addErrorsCrudCouldNotFindCrudTable(GLOBAL, form.getDisplayId()), () -> asEditHtml());
|
||||
});
|
||||
return redirectWith(getClass(), moreUrl("list/1").params("dictId", form.dictId));
|
||||
}
|
||||
|
||||
@Execute
|
||||
public HtmlResponse delete(final EditForm form) {
|
||||
verifyCrudMode(form.crudMode, CrudMode.DETAILS);
|
||||
validate(form, messages -> {}, toEditHtml());
|
||||
synonymService.getSynonymItem(form.dictId, form.id).ifPresent(entity -> {
|
||||
synonymService.delete(form.dictId, entity);
|
||||
saveInfo(messages -> messages.addSuccessCrudDeleteCrudTable(GLOBAL));
|
||||
}).orElse(() -> {
|
||||
throwValidationError(messages -> messages.addErrorsCrudCouldNotFindCrudTable(GLOBAL, form.getDisplayId()), toEditHtml());
|
||||
});
|
||||
verifyCrudMode(form.crudMode, CrudMode.DETAILS, form.dictId);
|
||||
verifyToken(() -> asDetailsHtml());
|
||||
validate(form, messages -> {}, () -> asDetailsHtml());
|
||||
synonymService
|
||||
.getSynonymItem(form.dictId, form.id)
|
||||
.ifPresent(entity -> {
|
||||
synonymService.delete(form.dictId, entity);
|
||||
saveInfo(messages -> messages.addSuccessCrudDeleteCrudTable(GLOBAL));
|
||||
})
|
||||
.orElse(() -> {
|
||||
throwValidationError(messages -> messages.addErrorsCrudCouldNotFindCrudTable(GLOBAL, form.getDisplayId()),
|
||||
() -> asDetailsHtml());
|
||||
});
|
||||
return redirectWith(getClass(), moreUrl("list/1").params("dictId", form.dictId));
|
||||
}
|
||||
|
||||
|
@ -354,13 +340,13 @@ public class AdminDictSynonymAction extends FessAdminAction {
|
|||
return OptionalEntity.empty();
|
||||
}
|
||||
|
||||
protected OptionalEntity<SynonymItem> createSynonymItem(final CreateForm form) {
|
||||
protected OptionalEntity<SynonymItem> createSynonymItem(final CreateForm form, final VaErrorHook hook) {
|
||||
return getEntity(form).map(entity -> {
|
||||
final String[] newInputs = splitLine(form.inputs);
|
||||
validateSynonymString(newInputs, () -> confirmfromcreate(form));
|
||||
validateSynonymString(newInputs, hook);
|
||||
entity.setNewInputs(newInputs);
|
||||
final String[] newOutputs = splitLine(form.outputs);
|
||||
validateSynonymString(newOutputs, () -> confirmfromcreate(form));
|
||||
validateSynonymString(newOutputs, hook);
|
||||
entity.setNewOutputs(newOutputs);
|
||||
return entity;
|
||||
});
|
||||
|
@ -369,26 +355,14 @@ public class AdminDictSynonymAction extends FessAdminAction {
|
|||
// ===================================================================================
|
||||
// Small Helper
|
||||
// ============
|
||||
protected void verifyCrudMode(final int crudMode, final int expectedMode) {
|
||||
protected void verifyCrudMode(final int crudMode, final int expectedMode, final String dictId) {
|
||||
if (crudMode != expectedMode) {
|
||||
throwValidationError(messages -> {
|
||||
messages.addErrorsCrudInvalidMode(GLOBAL, String.valueOf(expectedMode), String.valueOf(crudMode));
|
||||
}, toEditHtml());
|
||||
}, () -> asListHtml(dictId));
|
||||
}
|
||||
}
|
||||
|
||||
protected VaErrorHook toIndexHtml() {
|
||||
return () -> {
|
||||
return redirect(AdminDictAction.class);
|
||||
};
|
||||
}
|
||||
|
||||
protected VaErrorHook toEditHtml() {
|
||||
return () -> {
|
||||
return asHtml(path_AdminDictSynonym_AdminDictSynonymEditJsp);
|
||||
};
|
||||
}
|
||||
|
||||
private void validateSynonymString(final String[] values, final VaErrorHook hook) {
|
||||
if (values.length == 0) {
|
||||
return;
|
||||
|
@ -421,4 +395,30 @@ public class AdminDictSynonymAction extends FessAdminAction {
|
|||
return list.toArray(new String[list.size()]);
|
||||
}
|
||||
|
||||
// ===================================================================================
|
||||
// JSP
|
||||
// =========
|
||||
|
||||
protected HtmlResponse asDictIndexHtml() {
|
||||
return redirect(AdminDictAction.class);
|
||||
}
|
||||
|
||||
private HtmlResponse asListHtml(final String dictId) {
|
||||
return asHtml(path_AdminDictSynonym_AdminDictSynonymJsp).renderWith(data -> {
|
||||
data.register("synonymItemItems", synonymService.getSynonymList(dictId, synonymPager));
|
||||
}).useForm(SearchForm.class, setup -> {
|
||||
setup.setup(form -> {
|
||||
copyBeanToBean(synonymPager, form, op -> op.include("id"));
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
private HtmlResponse asEditHtml() {
|
||||
return asHtml(path_AdminDictSynonym_AdminDictSynonymEditJsp);
|
||||
}
|
||||
|
||||
private HtmlResponse asDetailsHtml() {
|
||||
return asHtml(path_AdminDictSynonym_AdminDictSynonymDetailsJsp);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -152,14 +152,10 @@ public class AdminElevatewordAction extends FessAdminAction {
|
|||
if (form.crudMode.intValue() == CrudMode.EDIT) {
|
||||
// back
|
||||
form.crudMode = CrudMode.DETAILS;
|
||||
return asDetailsHtml().renderWith(data -> {
|
||||
registerLabels(data);
|
||||
});
|
||||
return asDetailsHtml();
|
||||
} else {
|
||||
form.crudMode = CrudMode.EDIT;
|
||||
return asEditHtml().renderWith(data -> {
|
||||
registerLabels(data);
|
||||
});
|
||||
return asEditHtml();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -363,11 +359,15 @@ public class AdminElevatewordAction extends FessAdminAction {
|
|||
}
|
||||
|
||||
private HtmlResponse asEditHtml() {
|
||||
return asHtml(path_AdminElevateword_AdminElevatewordEditJsp);
|
||||
return asHtml(path_AdminElevateword_AdminElevatewordEditJsp).renderWith(data -> {
|
||||
registerLabels(data);
|
||||
});
|
||||
}
|
||||
|
||||
private HtmlResponse asDetailsHtml() {
|
||||
return asHtml(path_AdminElevateword_AdminElevatewordDetailsJsp);
|
||||
return asHtml(path_AdminElevateword_AdminElevatewordDetailsJsp).renderWith(data -> {
|
||||
registerLabels(data);
|
||||
});
|
||||
}
|
||||
|
||||
private HtmlResponse asUploadHtml() {
|
||||
|
|
|
@ -138,14 +138,10 @@ public class AdminFileconfigAction extends FessAdminAction {
|
|||
if (form.crudMode.intValue() == CrudMode.EDIT) {
|
||||
// back
|
||||
form.crudMode = CrudMode.DETAILS;
|
||||
return asDetailsHtml().renderWith(data -> {
|
||||
registerRolesAndLabels(data);
|
||||
});
|
||||
return asDetailsHtml();
|
||||
} else {
|
||||
form.crudMode = CrudMode.EDIT;
|
||||
return asEditHtml().renderWith(data -> {
|
||||
registerRolesAndLabels(data);
|
||||
});
|
||||
return asEditHtml();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -285,10 +281,14 @@ public class AdminFileconfigAction extends FessAdminAction {
|
|||
}
|
||||
|
||||
private HtmlResponse asEditHtml() {
|
||||
return asHtml(path_AdminFileconfig_AdminFileconfigEditJsp);
|
||||
return asHtml(path_AdminFileconfig_AdminFileconfigEditJsp).renderWith(data -> {
|
||||
registerRolesAndLabels(data);
|
||||
});
|
||||
}
|
||||
|
||||
private HtmlResponse asDetailsHtml() {
|
||||
return asHtml(path_AdminFileconfig_AdminFileconfigDetailsJsp);
|
||||
return asHtml(path_AdminFileconfig_AdminFileconfigDetailsJsp).renderWith(data -> {
|
||||
registerRolesAndLabels(data);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
|
@ -136,14 +136,10 @@ public class AdminLabeltypeAction extends FessAdminAction {
|
|||
if (form.crudMode.intValue() == CrudMode.EDIT) {
|
||||
// back
|
||||
form.crudMode = CrudMode.DETAILS;
|
||||
return asDetailsHtml().renderWith(data -> {
|
||||
registerRoleTypeItems(data);
|
||||
});
|
||||
return asDetailsHtml();
|
||||
} else {
|
||||
form.crudMode = CrudMode.EDIT;
|
||||
return asEditHtml().renderWith(data -> {
|
||||
registerRoleTypeItems(data);
|
||||
});
|
||||
return asEditHtml();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -283,10 +279,14 @@ public class AdminLabeltypeAction extends FessAdminAction {
|
|||
}
|
||||
|
||||
private HtmlResponse asEditHtml() {
|
||||
return asHtml(path_AdminLabeltype_AdminLabeltypeEditJsp);
|
||||
return asHtml(path_AdminLabeltype_AdminLabeltypeEditJsp).renderWith(data -> {
|
||||
registerRoleTypeItems(data);
|
||||
});
|
||||
}
|
||||
|
||||
private HtmlResponse asDetailsHtml() {
|
||||
return asHtml(path_AdminLabeltype_AdminLabeltypeDetailsJsp);
|
||||
return asHtml(path_AdminLabeltype_AdminLabeltypeDetailsJsp).renderWith(data -> {
|
||||
registerRoleTypeItems(data);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
|
@ -29,6 +29,7 @@ import org.codelibs.fess.app.service.GroupService;
|
|||
import org.codelibs.fess.app.service.RoleService;
|
||||
import org.codelibs.fess.app.service.UserService;
|
||||
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.User;
|
||||
import org.codelibs.fess.helper.SystemHelper;
|
||||
|
@ -36,7 +37,6 @@ import org.dbflute.optional.OptionalEntity;
|
|||
import org.dbflute.optional.OptionalThing;
|
||||
import org.lastaflute.web.Execute;
|
||||
import org.lastaflute.web.response.HtmlResponse;
|
||||
import org.lastaflute.web.response.next.HtmlNext;
|
||||
import org.lastaflute.web.response.render.RenderData;
|
||||
import org.lastaflute.web.ruts.process.ActionRuntime;
|
||||
import org.lastaflute.web.validation.VaErrorHook;
|
||||
|
@ -74,10 +74,8 @@ public class AdminUserAction extends FessAdminAction {
|
|||
// Search Execute
|
||||
// ==============
|
||||
@Execute
|
||||
public HtmlResponse index(final SearchForm form) {
|
||||
return asHtml(path_AdminUser_AdminUserJsp).renderWith(data -> {
|
||||
searchPaging(data, form);
|
||||
});
|
||||
public HtmlResponse index() {
|
||||
return asListHtml();
|
||||
}
|
||||
|
||||
@Execute
|
||||
|
@ -126,8 +124,8 @@ public class AdminUserAction extends FessAdminAction {
|
|||
// Entry Page
|
||||
// ----------
|
||||
@Execute
|
||||
//(token = TxToken.SAVE)
|
||||
public HtmlResponse createnew() {
|
||||
saveToken();
|
||||
return asHtml(path_AdminUser_AdminUserEditJsp).useForm(CreateForm.class, op -> {
|
||||
op.setup(form -> {
|
||||
form.initialize();
|
||||
|
@ -139,30 +137,24 @@ public class AdminUserAction extends FessAdminAction {
|
|||
}
|
||||
|
||||
@Execute
|
||||
//(token = TxToken.SAVE)
|
||||
public HtmlResponse edit(final EditForm form) {
|
||||
HtmlNext next;
|
||||
switch (form.crudMode) {
|
||||
case CrudMode.EDIT: // back
|
||||
form.crudMode = CrudMode.DETAILS;
|
||||
next = path_AdminUser_AdminUserDetailsJsp;
|
||||
break;
|
||||
default:
|
||||
form.crudMode = CrudMode.EDIT;
|
||||
next = path_AdminUser_AdminUserEditJsp;
|
||||
break;
|
||||
}
|
||||
validate(form, messages -> {}, () -> asListHtml());
|
||||
final String id = form.id;
|
||||
userService.getUser(id).ifPresent(entity -> {
|
||||
copyBeanToBean(entity, form, op -> {});
|
||||
}).orElse(() -> {
|
||||
throwValidationError(messages -> messages.addErrorsCrudCouldNotFindCrudTable(GLOBAL, id), toEditHtml());
|
||||
throwValidationError(messages -> messages.addErrorsCrudCouldNotFindCrudTable(GLOBAL, id), () -> asListHtml());
|
||||
});
|
||||
resetPassword(form);
|
||||
validate(form, messages -> {}, toEditHtml());
|
||||
return asHtml(next).renderWith(data -> {
|
||||
registerForms(data);
|
||||
});
|
||||
saveToken();
|
||||
if (form.crudMode.intValue() == CrudMode.EDIT) {
|
||||
// back
|
||||
form.crudMode = CrudMode.DETAILS;
|
||||
return asDetailsHtml();
|
||||
} else {
|
||||
form.crudMode = CrudMode.EDIT;
|
||||
return asEditHtml();
|
||||
}
|
||||
}
|
||||
|
||||
// -----------------------------------------------------
|
||||
|
@ -171,6 +163,7 @@ public class AdminUserAction extends FessAdminAction {
|
|||
@Execute
|
||||
public HtmlResponse details(final int crudMode, final String id) {
|
||||
verifyCrudMode(crudMode, CrudMode.DETAILS);
|
||||
saveToken();
|
||||
return asHtml(path_AdminUser_AdminUserDetailsJsp).useForm(EditForm.class, op -> {
|
||||
op.setup(form -> {
|
||||
userService.getUser(id).ifPresent(entity -> {
|
||||
|
@ -179,7 +172,7 @@ public class AdminUserAction extends FessAdminAction {
|
|||
});
|
||||
form.crudMode = crudMode;
|
||||
}).orElse(() -> {
|
||||
throwValidationError(messages -> messages.addErrorsCrudCouldNotFindCrudTable(GLOBAL, id), toEditHtml());
|
||||
throwValidationError(messages -> messages.addErrorsCrudCouldNotFindCrudTable(GLOBAL, id), () -> asListHtml());
|
||||
});
|
||||
resetPassword(form);
|
||||
});
|
||||
|
@ -194,13 +187,14 @@ public class AdminUserAction extends FessAdminAction {
|
|||
@Execute
|
||||
public HtmlResponse create(final CreateForm form) {
|
||||
verifyCrudMode(form.crudMode, CrudMode.CREATE);
|
||||
validate(form, messages -> {}, toEditHtml());
|
||||
verifyPassword(form);
|
||||
validate(form, messages -> {}, () -> asEditHtml());
|
||||
verifyPassword(form, () -> asEditHtml());
|
||||
verifyToken(() -> asEditHtml());
|
||||
getUser(form).ifPresent(entity -> {
|
||||
userService.store(entity);
|
||||
saveInfo(messages -> messages.addSuccessCrudCreateCrudTable(GLOBAL));
|
||||
}).orElse(() -> {
|
||||
throwValidationError(messages -> messages.addErrorsCrudFailedToCreateCrudTable(GLOBAL), toEditHtml());
|
||||
throwValidationError(messages -> messages.addErrorsCrudFailedToCreateCrudTable(GLOBAL), () -> asEditHtml());
|
||||
});
|
||||
return redirect(getClass());
|
||||
}
|
||||
|
@ -208,13 +202,14 @@ public class AdminUserAction extends FessAdminAction {
|
|||
@Execute
|
||||
public HtmlResponse update(final EditForm form) {
|
||||
verifyCrudMode(form.crudMode, CrudMode.EDIT);
|
||||
validate(form, messages -> {}, toEditHtml());
|
||||
verifyPassword(form);
|
||||
validate(form, messages -> {}, () -> asEditHtml());
|
||||
verifyPassword(form, () -> asEditHtml());
|
||||
verifyToken(() -> asEditHtml());
|
||||
getUser(form).ifPresent(entity -> {
|
||||
userService.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());
|
||||
}
|
||||
|
@ -222,13 +217,13 @@ public class AdminUserAction extends FessAdminAction {
|
|||
@Execute
|
||||
public HtmlResponse delete(final EditForm form) {
|
||||
verifyCrudMode(form.crudMode, CrudMode.DETAILS);
|
||||
validate(form, messages -> {}, toEditHtml());
|
||||
validate(form, messages -> {}, () -> asDetailsHtml());
|
||||
final String id = form.id;
|
||||
userService.getUser(id).ifPresent(entity -> {
|
||||
userService.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());
|
||||
}
|
||||
|
@ -283,22 +278,22 @@ public class AdminUserAction extends FessAdminAction {
|
|||
if (crudMode != expectedMode) {
|
||||
throwValidationError(messages -> {
|
||||
messages.addErrorsCrudInvalidMode(GLOBAL, String.valueOf(expectedMode), String.valueOf(crudMode));
|
||||
}, toEditHtml());
|
||||
}, () -> asListHtml());
|
||||
}
|
||||
}
|
||||
|
||||
protected void verifyPassword(final CreateForm form) {
|
||||
protected void verifyPassword(final CreateForm form, VaErrorHook validationErrorLambda) {
|
||||
if (form.crudMode == CrudMode.CREATE && StringUtil.isBlank(form.password)) {
|
||||
resetPassword(form);
|
||||
throwValidationError(messages -> {
|
||||
messages.addErrorsBlankPassword(GLOBAL);
|
||||
}, toEditHtml());
|
||||
}, validationErrorLambda);
|
||||
}
|
||||
if (form.password != null && !form.password.equals(form.confirmPassword)) {
|
||||
resetPassword(form);
|
||||
throwValidationError(messages -> {
|
||||
messages.addErrorsInvalidConfirmPassword(GLOBAL);
|
||||
}, toEditHtml());
|
||||
}, validationErrorLambda);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -307,11 +302,29 @@ public class AdminUserAction extends FessAdminAction {
|
|||
form.confirmPassword = null;
|
||||
}
|
||||
|
||||
protected VaErrorHook toEditHtml() {
|
||||
return () -> {
|
||||
return asHtml(path_AdminUser_AdminUserEditJsp).renderWith(data -> {
|
||||
registerForms(data);
|
||||
// ===================================================================================
|
||||
// JSP
|
||||
// =========
|
||||
|
||||
private HtmlResponse asListHtml() {
|
||||
return asHtml(path_AdminUser_AdminUserJsp).renderWith(data -> {
|
||||
data.register("userItems", userService.getUserList(userPager)); // page navi
|
||||
}).useForm(SearchForm.class, setup -> {
|
||||
setup.setup(form -> {
|
||||
copyBeanToBean(userPager, form, op -> op.include("id"));
|
||||
});
|
||||
};
|
||||
});
|
||||
}
|
||||
|
||||
private HtmlResponse asEditHtml() {
|
||||
return asHtml(path_AdminUser_AdminUserEditJsp).renderWith(data -> {
|
||||
registerForms(data);
|
||||
});
|
||||
}
|
||||
|
||||
private HtmlResponse asDetailsHtml() {
|
||||
return asHtml(path_AdminUser_AdminUserDetailsJsp).renderWith(data -> {
|
||||
registerForms(data);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
|
@ -119,13 +119,11 @@ public class AdminWebconfigAction extends FessAdminAction {
|
|||
@Execute
|
||||
public HtmlResponse createnew() {
|
||||
saveToken();
|
||||
return asHtml(path_AdminWebconfig_AdminWebconfigEditJsp).useForm(CreateForm.class, op -> {
|
||||
return asEditHtml().useForm(CreateForm.class, op -> {
|
||||
op.setup(form -> {
|
||||
form.initialize();
|
||||
form.crudMode = CrudMode.CREATE;
|
||||
});
|
||||
}).renderWith(data -> {
|
||||
registerRolesAndLabels(data);
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -142,14 +140,10 @@ public class AdminWebconfigAction extends FessAdminAction {
|
|||
if (form.crudMode.intValue() == CrudMode.EDIT) {
|
||||
// back
|
||||
form.crudMode = CrudMode.DETAILS;
|
||||
return asDetailsHtml().renderWith(data -> {
|
||||
registerRolesAndLabels(data);
|
||||
});
|
||||
return asDetailsHtml();
|
||||
} else {
|
||||
form.crudMode = CrudMode.EDIT;
|
||||
return asEditHtml().renderWith(data -> {
|
||||
registerRolesAndLabels(data);
|
||||
});
|
||||
return asEditHtml();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -160,7 +154,7 @@ public class AdminWebconfigAction extends FessAdminAction {
|
|||
public HtmlResponse details(final int crudMode, final String id) {
|
||||
verifyCrudMode(crudMode, CrudMode.DETAILS);
|
||||
saveToken();
|
||||
return asHtml(path_AdminWebconfig_AdminWebconfigDetailsJsp).useForm(EditForm.class, op -> {
|
||||
return asDetailsHtml().useForm(EditForm.class, op -> {
|
||||
op.setup(form -> {
|
||||
webConfigService.getWebConfig(id).ifPresent(entity -> {
|
||||
copyBeanToBean(entity, form, copyOp -> {
|
||||
|
@ -171,8 +165,6 @@ public class AdminWebconfigAction extends FessAdminAction {
|
|||
throwValidationError(messages -> messages.addErrorsCrudCouldNotFindCrudTable(GLOBAL, id), () -> asListHtml());
|
||||
});
|
||||
});
|
||||
}).renderWith(data -> {
|
||||
registerRolesAndLabels(data);
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -289,10 +281,14 @@ public class AdminWebconfigAction extends FessAdminAction {
|
|||
}
|
||||
|
||||
private HtmlResponse asEditHtml() {
|
||||
return asHtml(path_AdminWebconfig_AdminWebconfigEditJsp);
|
||||
return asHtml(path_AdminWebconfig_AdminWebconfigEditJsp).renderWith(data -> {
|
||||
registerRolesAndLabels(data);
|
||||
});
|
||||
}
|
||||
|
||||
private HtmlResponse asDetailsHtml() {
|
||||
return asHtml(path_AdminWebconfig_AdminWebconfigDetailsJsp);
|
||||
return asHtml(path_AdminWebconfig_AdminWebconfigDetailsJsp).renderWith(data -> {
|
||||
registerRolesAndLabels(data);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
|
@ -87,32 +87,36 @@ public class AdminWizardAction extends FessAdminAction {
|
|||
|
||||
@Execute
|
||||
public HtmlResponse index() {
|
||||
return asIndexHtml();
|
||||
}
|
||||
|
||||
private HtmlResponse asIndexHtml() {
|
||||
return asHtml(path_AdminWizard_AdminWizardJsp).useForm(IndexForm.class);
|
||||
}
|
||||
|
||||
@Execute
|
||||
//(token = TxToken.SAVE)
|
||||
public HtmlResponse crawlingConfigForm() {
|
||||
saveToken();
|
||||
return asHtml(path_AdminWizard_AdminWizardConfigJsp).useForm(CrawlingConfigForm.class);
|
||||
}
|
||||
|
||||
@Execute
|
||||
//(token = TxToken.VALIDATE)
|
||||
public HtmlResponse crawlingConfig(final CrawlingConfigForm form) {
|
||||
validate(form, messages -> {}, () -> {
|
||||
return asHtml(path_AdminWizard_AdminWizardConfigJsp);
|
||||
});
|
||||
verifyTokenKeep(() -> asIndexHtml());
|
||||
final String name = crawlingConfigInternal(form);
|
||||
saveInfo(messages -> messages.addSuccessCreateCrawlingConfigAtWizard(GLOBAL, name));
|
||||
return redirectWith(getClass(), moreUrl("crawlingConfigForm"));
|
||||
}
|
||||
|
||||
@Execute
|
||||
//(token = TxToken.VALIDATE)
|
||||
public HtmlResponse crawlingConfigNext(final CrawlingConfigForm form) {
|
||||
validate(form, messages -> {}, () -> {
|
||||
return asHtml(path_AdminWizard_AdminWizardConfigJsp);
|
||||
});
|
||||
verifyToken(() -> asIndexHtml());
|
||||
final String name = crawlingConfigInternal(form);
|
||||
saveInfo(messages -> messages.addSuccessCreateCrawlingConfigAtWizard(GLOBAL, name));
|
||||
return redirectWith(getClass(), moreUrl("startCrawlingForm"));
|
||||
|
@ -269,14 +273,14 @@ public class AdminWizardAction extends FessAdminAction {
|
|||
}
|
||||
|
||||
@Execute
|
||||
//(token = TxToken.SAVE)
|
||||
public HtmlResponse startCrawlingForm() {
|
||||
saveToken();
|
||||
return asHtml(path_AdminWizard_AdminWizardStartJsp).useForm(StartCrawlingForm.class);
|
||||
}
|
||||
|
||||
@Execute
|
||||
//(token = TxToken.VALIDATE)
|
||||
public HtmlResponse startCrawling(final StartCrawlingForm form) {
|
||||
verifyToken(() -> asIndexHtml());
|
||||
if (!jobHelper.isCrawlProcessRunning()) {
|
||||
final List<ScheduledJob> scheduledJobList = scheduledJobService.getCrawlerJobList();
|
||||
for (final ScheduledJob scheduledJob : scheduledJobList) {
|
||||
|
|
|
@ -140,10 +140,10 @@ public class FessMessages extends FessLabels {
|
|||
/** The key of the message: {item} cannot convert as {propertyType}. */
|
||||
public static final String CONSTRAINTS_TypeAny_MESSAGE = "{constraints.TypeAny.message}";
|
||||
|
||||
/** The key of the message: could not login. */
|
||||
/** The key of the message: Login failed. */
|
||||
public static final String ERRORS_LOGIN_FAILURE = "{errors.login.failure}";
|
||||
|
||||
/** The key of the message: retry because of illegal transition. */
|
||||
/** The key of the message: Please retry because of illegal transition. */
|
||||
public static final String ERRORS_APP_ILLEGAL_TRANSITION = "{errors.app.illegal.transition}";
|
||||
|
||||
/** The key of the message: others might be updated, so retry. */
|
||||
|
@ -155,7 +155,7 @@ public class FessMessages extends FessLabels {
|
|||
/** The key of the message: already existing data, so retry. */
|
||||
public static final String ERRORS_APP_DB_ALREADY_EXISTS = "{errors.app.db.already.exists}";
|
||||
|
||||
/** The key of the message: double submit might be requested. */
|
||||
/** The key of the message: Your request might have been processed before this request. Please check and retry it. */
|
||||
public static final String ERRORS_APP_DOUBLE_SUBMIT_REQUEST = "{errors.app.double.submit.request}";
|
||||
|
||||
/** The key of the message: Username or Password is not correct. */
|
||||
|
@ -929,7 +929,7 @@ public class FessMessages extends FessLabels {
|
|||
/**
|
||||
* Add the created action message for the key 'errors.login.failure' with parameters.
|
||||
* <pre>
|
||||
* message: could not login.
|
||||
* message: Login failed.
|
||||
* comment: - - - - - - - - - -/
|
||||
* </pre>
|
||||
* @param property The property name for the message. (NotNull)
|
||||
|
@ -944,7 +944,7 @@ public class FessMessages extends FessLabels {
|
|||
/**
|
||||
* Add the created action message for the key 'errors.app.illegal.transition' with parameters.
|
||||
* <pre>
|
||||
* message: retry because of illegal transition.
|
||||
* message: Please retry because of illegal transition.
|
||||
* </pre>
|
||||
* @param property The property name for the message. (NotNull)
|
||||
* @return this. (NotNull)
|
||||
|
@ -1000,7 +1000,7 @@ public class FessMessages extends FessLabels {
|
|||
/**
|
||||
* Add the created action message for the key 'errors.app.double.submit.request' with parameters.
|
||||
* <pre>
|
||||
* message: double submit might be requested.
|
||||
* message: Your request might have been processed before this request. Please check and retry it.
|
||||
* </pre>
|
||||
* @param property The property name for the message. (NotNull)
|
||||
* @return this. (NotNull)
|
||||
|
|
|
@ -58,12 +58,12 @@ constraints.TypeAny.message = {item} cannot convert as {property
|
|||
# /- - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
# five framework-embedded messages (don't change key names)
|
||||
# - - - - - - - - - -/
|
||||
errors.login.failure=could not login.
|
||||
errors.app.illegal.transition=retry because of illegal transition.
|
||||
errors.login.failure=Login failed.
|
||||
errors.app.illegal.transition=Please retry because of illegal transition.
|
||||
errors.app.db.already.deleted=others might be updated, so retry.
|
||||
errors.app.db.already.updated=others might be updated, so retry.
|
||||
errors.app.db.already.exists=already existing data, so retry.
|
||||
errors.app.double.submit.request=double submit might be requested.
|
||||
errors.app.double.submit.request=Your request might have been processed before this request. Please check and retry it.
|
||||
|
||||
# _/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/
|
||||
# you can define your messages here:
|
||||
|
|
Loading…
Add table
Reference in a new issue