modify validations
This commit is contained in:
parent
b300359423
commit
48f3c59b45
19 changed files with 486 additions and 374 deletions
|
@ -21,13 +21,13 @@ import org.codelibs.fess.Constants;
|
|||
import org.codelibs.fess.app.pager.JobLogPager;
|
||||
import org.codelibs.fess.app.service.JobLogService;
|
||||
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.helper.SystemHelper;
|
||||
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 shinsuke
|
||||
|
@ -59,9 +59,7 @@ public class AdminJoblogAction extends FessAdminAction {
|
|||
// ==============
|
||||
@Execute
|
||||
public HtmlResponse index(final SearchForm form) {
|
||||
return asHtml(path_AdminJoblog_AdminJoblogJsp).renderWith(data -> {
|
||||
searchPaging(data, form);
|
||||
});
|
||||
return asListHtml();
|
||||
}
|
||||
|
||||
@Execute
|
||||
|
@ -108,10 +106,11 @@ public class AdminJoblogAction extends FessAdminAction {
|
|||
// -----------------------------------------------------
|
||||
// Entry Page
|
||||
// ----------
|
||||
// TODO remove?
|
||||
@Execute
|
||||
//(token = TxToken.SAVE)
|
||||
public HtmlResponse deletepage(final int crudMode, final String id) {
|
||||
verifyCrudMode(crudMode, CrudMode.DELETE);
|
||||
saveToken();
|
||||
return asHtml(path_AdminJoblog_AdminJoblogDetailsJsp).useForm(EditForm.class, op -> {
|
||||
op.setup(form -> {
|
||||
jobLogService.getJobLog(id).ifPresent(entity -> {
|
||||
|
@ -119,23 +118,24 @@ public class AdminJoblogAction extends FessAdminAction {
|
|||
copyOp.excludeNull();
|
||||
});
|
||||
}).orElse(() -> {
|
||||
throwValidationError(messages -> messages.addErrorsCrudCouldNotFindCrudTable(GLOBAL, id), toIndexHtml());
|
||||
throwValidationError(messages -> messages.addErrorsCrudCouldNotFindCrudTable(GLOBAL, id), () -> asListHtml());
|
||||
});
|
||||
form.crudMode = crudMode;
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
// TODO remove?
|
||||
@Execute
|
||||
//(token = TxToken.SAVE)
|
||||
public HtmlResponse deletefromconfirm(final EditForm form) {
|
||||
form.crudMode = CrudMode.DELETE;
|
||||
validate(form, messages -> {}, toIndexHtml());
|
||||
validate(form, messages -> {}, () -> asDetailsHtml());
|
||||
verifyTokenKeep(() -> asDetailsHtml());
|
||||
String id = form.id;
|
||||
jobLogService.getJobLog(id).ifPresent(entity -> {
|
||||
copyBeanToBean(entity, form, op -> {});
|
||||
}).orElse(() -> {
|
||||
throwValidationError(messages -> messages.addErrorsCrudCouldNotFindCrudTable(GLOBAL, id), toIndexHtml());
|
||||
throwValidationError(messages -> messages.addErrorsCrudCouldNotFindCrudTable(GLOBAL, id), () -> asDetailsHtml());
|
||||
});
|
||||
return asHtml(path_AdminJoblog_AdminJoblogDetailsJsp);
|
||||
}
|
||||
|
@ -146,6 +146,7 @@ public class AdminJoblogAction extends FessAdminAction {
|
|||
@Execute
|
||||
public HtmlResponse details(final int crudMode, final String id) {
|
||||
verifyCrudMode(crudMode, CrudMode.DETAILS);
|
||||
saveToken();
|
||||
return asHtml(path_AdminJoblog_AdminJoblogDetailsJsp).useForm(EditForm.class, op -> {
|
||||
op.setup(form -> {
|
||||
jobLogService.getJobLog(id).ifPresent(entity -> {
|
||||
|
@ -154,7 +155,7 @@ public class AdminJoblogAction extends FessAdminAction {
|
|||
});
|
||||
form.crudMode = crudMode;
|
||||
}).orElse(() -> {
|
||||
throwValidationError(messages -> messages.addErrorsCrudCouldNotFindCrudTable(GLOBAL, id), toIndexHtml());
|
||||
throwValidationError(messages -> messages.addErrorsCrudCouldNotFindCrudTable(GLOBAL, id), () -> asListHtml());
|
||||
});
|
||||
});
|
||||
});
|
||||
|
@ -166,7 +167,8 @@ public class AdminJoblogAction 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;
|
||||
jobLogService.getJobLog(id).alwaysPresent(entity -> {
|
||||
jobLogService.delete(entity);
|
||||
|
@ -186,13 +188,25 @@ public class AdminJoblogAction 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_AdminJoblog_AdminJoblogJsp);
|
||||
};
|
||||
// ===================================================================================
|
||||
// JSP
|
||||
// =========
|
||||
|
||||
private HtmlResponse asListHtml() {
|
||||
return asHtml(path_AdminJoblog_AdminJoblogJsp).renderWith(data -> {
|
||||
data.register("jobLogItems", jobLogService.getJobLogList(jobLogPager)); // page navi
|
||||
}).useForm(SearchForm.class, setup -> {
|
||||
setup.setup(form -> {
|
||||
copyBeanToBean(jobLogPager, form, op -> op.include("id"));
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
private HtmlResponse asDetailsHtml() {
|
||||
return asHtml(path_AdminJoblog_AdminJoblogDetailsJsp);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -21,6 +21,7 @@ import org.codelibs.fess.Constants;
|
|||
import org.codelibs.fess.app.pager.KeyMatchPager;
|
||||
import org.codelibs.fess.app.service.KeyMatchService;
|
||||
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.KeyMatch;
|
||||
import org.codelibs.fess.helper.SystemHelper;
|
||||
|
@ -30,9 +31,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,9 +63,7 @@ public class AdminKeymatchAction extends FessAdminAction {
|
|||
// ==============
|
||||
@Execute
|
||||
public HtmlResponse index(final SearchForm form) {
|
||||
return asHtml(path_AdminKeymatch_AdminKeymatchJsp).renderWith(data -> {
|
||||
searchPaging(data, form);
|
||||
});
|
||||
return asListHtml();
|
||||
}
|
||||
|
||||
@Execute
|
||||
|
@ -111,8 +108,8 @@ public class AdminKeymatchAction extends FessAdminAction {
|
|||
// Entry Page
|
||||
// ----------
|
||||
@Execute
|
||||
//(token = TxToken.SAVE)
|
||||
public HtmlResponse createnew() {
|
||||
saveToken();
|
||||
return asHtml(path_AdminKeymatch_AdminKeymatchEditJsp).useForm(CreateForm.class, op -> {
|
||||
op.setup(form -> {
|
||||
form.initialize();
|
||||
|
@ -122,27 +119,23 @@ public class AdminKeymatchAction 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_AdminKeymatch_AdminKeymatchDetailsJsp;
|
||||
break;
|
||||
default:
|
||||
form.crudMode = CrudMode.EDIT;
|
||||
next = path_AdminKeymatch_AdminKeymatchEditJsp;
|
||||
break;
|
||||
}
|
||||
validate(form, messages -> {}, () -> asListHtml());
|
||||
final String id = form.id;
|
||||
keyMatchService.getKeyMatch(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();
|
||||
}
|
||||
}
|
||||
|
||||
// -----------------------------------------------------
|
||||
|
@ -151,6 +144,7 @@ public class AdminKeymatchAction extends FessAdminAction {
|
|||
@Execute
|
||||
public HtmlResponse details(final int crudMode, final String id) {
|
||||
verifyCrudMode(crudMode, CrudMode.DETAILS);
|
||||
saveToken();
|
||||
return asHtml(path_AdminKeymatch_AdminKeymatchDetailsJsp).useForm(EditForm.class, op -> {
|
||||
op.setup(form -> {
|
||||
keyMatchService.getKeyMatch(id).ifPresent(entity -> {
|
||||
|
@ -159,7 +153,7 @@ public class AdminKeymatchAction extends FessAdminAction {
|
|||
});
|
||||
form.crudMode = crudMode;
|
||||
}).orElse(() -> {
|
||||
throwValidationError(messages -> messages.addErrorsCrudCouldNotFindCrudTable(GLOBAL, id), toEditHtml());
|
||||
throwValidationError(messages -> messages.addErrorsCrudCouldNotFindCrudTable(GLOBAL, id), () -> asListHtml());
|
||||
});
|
||||
});
|
||||
});
|
||||
|
@ -171,13 +165,14 @@ public class AdminKeymatchAction extends FessAdminAction {
|
|||
@Execute
|
||||
public HtmlResponse create(final CreateForm form) {
|
||||
verifyCrudMode(form.crudMode, CrudMode.CREATE);
|
||||
validate(form, messages -> {}, toEditHtml());
|
||||
validate(form, messages -> {}, () -> asEditHtml());
|
||||
verifyToken(() -> asEditHtml());
|
||||
getKeyMatch(form).ifPresent(entity -> {
|
||||
keyMatchService.store(entity);
|
||||
saveInfo(messages -> messages.addSuccessCrudCreateCrudTable(GLOBAL));
|
||||
ComponentUtil.getKeyMatchHelper().update();
|
||||
}).orElse(() -> {
|
||||
throwValidationError(messages -> messages.addErrorsCrudFailedToCreateCrudTable(GLOBAL), toEditHtml());
|
||||
throwValidationError(messages -> messages.addErrorsCrudFailedToCreateCrudTable(GLOBAL), () -> asEditHtml());
|
||||
});
|
||||
return redirect(getClass());
|
||||
}
|
||||
|
@ -185,13 +180,14 @@ public class AdminKeymatchAction extends FessAdminAction {
|
|||
@Execute
|
||||
public HtmlResponse update(final EditForm form) {
|
||||
verifyCrudMode(form.crudMode, CrudMode.EDIT);
|
||||
validate(form, messages -> {}, toEditHtml());
|
||||
validate(form, messages -> {}, () -> asEditHtml());
|
||||
verifyToken(() -> asEditHtml());
|
||||
getKeyMatch(form).ifPresent(entity -> {
|
||||
keyMatchService.store(entity);
|
||||
saveInfo(messages -> messages.addSuccessCrudUpdateCrudTable(GLOBAL));
|
||||
ComponentUtil.getKeyMatchHelper().update();
|
||||
}).orElse(() -> {
|
||||
throwValidationError(messages -> messages.addErrorsCrudCouldNotFindCrudTable(GLOBAL, form.id), toEditHtml());
|
||||
throwValidationError(messages -> messages.addErrorsCrudCouldNotFindCrudTable(GLOBAL, form.id), () -> asEditHtml());
|
||||
});
|
||||
return redirect(getClass());
|
||||
}
|
||||
|
@ -199,14 +195,15 @@ public class AdminKeymatchAction 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;
|
||||
keyMatchService.getKeyMatch(id).ifPresent(entity -> {
|
||||
keyMatchService.delete(entity);
|
||||
saveInfo(messages -> messages.addSuccessCrudDeleteCrudTable(GLOBAL));
|
||||
ComponentUtil.getKeyMatchHelper().update();
|
||||
}).orElse(() -> {
|
||||
throwValidationError(messages -> messages.addErrorsCrudCouldNotFindCrudTable(GLOBAL, id), toEditHtml());
|
||||
throwValidationError(messages -> messages.addErrorsCrudCouldNotFindCrudTable(GLOBAL, id), () -> asDetailsHtml());
|
||||
});
|
||||
return redirect(getClass());
|
||||
}
|
||||
|
@ -255,13 +252,29 @@ public class AdminKeymatchAction 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_AdminKeymatch_AdminKeymatchEditJsp);
|
||||
};
|
||||
// ===================================================================================
|
||||
// JSP
|
||||
// =========
|
||||
|
||||
private HtmlResponse asListHtml() {
|
||||
return asHtml(path_AdminKeymatch_AdminKeymatchJsp).renderWith(data -> {
|
||||
data.register("keyMatchItems", keyMatchService.getKeyMatchList(keyMatchPager)); // page navi
|
||||
}).useForm(SearchForm.class, setup -> {
|
||||
setup.setup(form -> {
|
||||
copyBeanToBean(keyMatchPager, form, op -> op.include("id"));
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
private HtmlResponse asEditHtml() {
|
||||
return asHtml(path_AdminKeymatch_AdminKeymatchEditJsp);
|
||||
}
|
||||
|
||||
private HtmlResponse asDetailsHtml() {
|
||||
return asHtml(path_AdminKeymatch_AdminKeymatchDetailsJsp);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -34,7 +34,8 @@ public class CreateForm implements Serializable {
|
|||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
public int crudMode;
|
||||
@ValidateTypeFailure
|
||||
public Integer crudMode;
|
||||
|
||||
@Required
|
||||
@Size(max = 100)
|
||||
|
|
|
@ -22,6 +22,7 @@ import org.codelibs.fess.app.pager.LabelTypePager;
|
|||
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.LabelType;
|
||||
import org.codelibs.fess.helper.SystemHelper;
|
||||
|
@ -30,9 +31,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
|
||||
|
@ -67,9 +66,7 @@ public class AdminLabeltypeAction extends FessAdminAction {
|
|||
// ==============
|
||||
@Execute
|
||||
public HtmlResponse index(final SearchForm form) {
|
||||
return asHtml(path_AdminLabeltype_AdminLabeltypeJsp).renderWith(data -> {
|
||||
searchPaging(data, form);
|
||||
});
|
||||
return asListHtml();
|
||||
}
|
||||
|
||||
@Execute
|
||||
|
@ -114,8 +111,8 @@ public class AdminLabeltypeAction extends FessAdminAction {
|
|||
// Entry Page
|
||||
// ----------
|
||||
@Execute
|
||||
//(token = TxToken.SAVE)
|
||||
public HtmlResponse createnew() {
|
||||
saveToken();
|
||||
return asHtml(path_AdminLabeltype_AdminLabeltypeEditJsp).useForm(CreateForm.class, op -> {
|
||||
op.setup(form -> {
|
||||
form.initialize();
|
||||
|
@ -127,29 +124,27 @@ public class AdminLabeltypeAction 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_AdminLabeltype_AdminLabeltypeDetailsJsp;
|
||||
break;
|
||||
default:
|
||||
form.crudMode = CrudMode.EDIT;
|
||||
next = path_AdminLabeltype_AdminLabeltypeEditJsp;
|
||||
break;
|
||||
}
|
||||
validate(form, messages -> {}, () -> asListHtml());
|
||||
final String id = form.id;
|
||||
labelTypeService.getLabelType(id).ifPresent(entity -> {
|
||||
copyBeanToBean(entity, form, op -> {});
|
||||
}).orElse(() -> {
|
||||
throwValidationError(messages -> messages.addErrorsCrudCouldNotFindCrudTable(GLOBAL, id), toEditHtml());
|
||||
});
|
||||
return asHtml(next).renderWith(data -> {
|
||||
registerRoleTypeItems(data);
|
||||
throwValidationError(messages -> messages.addErrorsCrudCouldNotFindCrudTable(GLOBAL, id), () -> asListHtml());
|
||||
});
|
||||
saveToken();
|
||||
if (form.crudMode.intValue() == CrudMode.EDIT) {
|
||||
// back
|
||||
form.crudMode = CrudMode.DETAILS;
|
||||
return asDetailsHtml().renderWith(data -> {
|
||||
registerRoleTypeItems(data);
|
||||
});
|
||||
} else {
|
||||
form.crudMode = CrudMode.EDIT;
|
||||
return asEditHtml().renderWith(data -> {
|
||||
registerRoleTypeItems(data);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
// -----------------------------------------------------
|
||||
|
@ -158,6 +153,7 @@ public class AdminLabeltypeAction extends FessAdminAction {
|
|||
@Execute
|
||||
public HtmlResponse details(final int crudMode, final String id) {
|
||||
verifyCrudMode(crudMode, CrudMode.DETAILS);
|
||||
saveToken();
|
||||
return asHtml(path_AdminLabeltype_AdminLabeltypeDetailsJsp).useForm(EditForm.class, op -> {
|
||||
op.setup(form -> {
|
||||
labelTypeService.getLabelType(id).ifPresent(entity -> {
|
||||
|
@ -166,7 +162,7 @@ public class AdminLabeltypeAction extends FessAdminAction {
|
|||
});
|
||||
form.crudMode = crudMode;
|
||||
}).orElse(() -> {
|
||||
throwValidationError(messages -> messages.addErrorsCrudCouldNotFindCrudTable(GLOBAL, id), toEditHtml());
|
||||
throwValidationError(messages -> messages.addErrorsCrudCouldNotFindCrudTable(GLOBAL, id), () -> asListHtml());
|
||||
});
|
||||
});
|
||||
}).renderWith(data -> {
|
||||
|
@ -180,12 +176,13 @@ public class AdminLabeltypeAction extends FessAdminAction {
|
|||
@Execute
|
||||
public HtmlResponse create(final CreateForm form) {
|
||||
verifyCrudMode(form.crudMode, CrudMode.CREATE);
|
||||
validate(form, messages -> {}, toEditHtml());
|
||||
validate(form, messages -> {}, () -> asEditHtml());
|
||||
verifyToken(() -> asEditHtml());
|
||||
getLabelType(form).ifPresent(entity -> {
|
||||
labelTypeService.store(entity);
|
||||
saveInfo(messages -> messages.addSuccessCrudCreateCrudTable(GLOBAL));
|
||||
}).orElse(() -> {
|
||||
throwValidationError(messages -> messages.addErrorsCrudFailedToCreateCrudTable(GLOBAL), toEditHtml());
|
||||
throwValidationError(messages -> messages.addErrorsCrudFailedToCreateCrudTable(GLOBAL), () -> asEditHtml());
|
||||
});
|
||||
return redirect(getClass());
|
||||
}
|
||||
|
@ -193,12 +190,13 @@ public class AdminLabeltypeAction extends FessAdminAction {
|
|||
@Execute
|
||||
public HtmlResponse update(final EditForm form) {
|
||||
verifyCrudMode(form.crudMode, CrudMode.EDIT);
|
||||
validate(form, messages -> {}, toEditHtml());
|
||||
validate(form, messages -> {}, () -> asEditHtml());
|
||||
verifyToken(() -> asEditHtml());
|
||||
getLabelType(form).ifPresent(entity -> {
|
||||
labelTypeService.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());
|
||||
}
|
||||
|
@ -206,13 +204,14 @@ public class AdminLabeltypeAction 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;
|
||||
labelTypeService.getLabelType(id).ifPresent(entity -> {
|
||||
labelTypeService.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());
|
||||
}
|
||||
|
@ -265,15 +264,29 @@ public class AdminLabeltypeAction 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_AdminLabeltype_AdminLabeltypeEditJsp).renderWith(data -> {
|
||||
registerRoleTypeItems(data);
|
||||
// ===================================================================================
|
||||
// JSP
|
||||
// =========
|
||||
|
||||
private HtmlResponse asListHtml() {
|
||||
return asHtml(path_AdminLabeltype_AdminLabeltypeJsp).renderWith(data -> {
|
||||
data.register("labelTypeItems", labelTypeService.getLabelTypeList(labelTypePager)); // page navi
|
||||
}).useForm(SearchForm.class, setup -> {
|
||||
setup.setup(form -> {
|
||||
copyBeanToBean(labelTypePager, form, op -> op.include("id"));
|
||||
});
|
||||
};
|
||||
});
|
||||
}
|
||||
|
||||
private HtmlResponse asEditHtml() {
|
||||
return asHtml(path_AdminLabeltype_AdminLabeltypeEditJsp);
|
||||
}
|
||||
|
||||
private HtmlResponse asDetailsHtml() {
|
||||
return asHtml(path_AdminLabeltype_AdminLabeltypeDetailsJsp);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -58,7 +58,8 @@ public class AdminLogAction extends FessAdminAction {
|
|||
|
||||
@Execute
|
||||
public HtmlResponse index() {
|
||||
return toIndexPage();
|
||||
saveToken();
|
||||
return asIndexHtml();
|
||||
}
|
||||
|
||||
@Execute
|
||||
|
@ -66,6 +67,7 @@ public class AdminLogAction extends FessAdminAction {
|
|||
String filename = new String(Base64.getDecoder().decode(id), StandardCharsets.UTF_8).replace("..", "").replaceAll("\\s", "");
|
||||
final String logFilePath = systemHelper.getLogFilePath();
|
||||
if (StringUtil.isNotBlank(logFilePath)) {
|
||||
verifyToken(() -> asIndexHtml());
|
||||
Path path = Paths.get(logFilePath, filename);
|
||||
return asStream(filename).contentType("text/plain; charset=UTF-8").stream(out -> {
|
||||
try (InputStream in = Files.newInputStream(path)) {
|
||||
|
@ -74,9 +76,9 @@ public class AdminLogAction extends FessAdminAction {
|
|||
});
|
||||
}
|
||||
throwValidationError(messages -> messages.addErrorsCouldNotFindLogFile(GLOBAL, filename), () -> {
|
||||
return toIndexPage();
|
||||
return asIndexHtml();
|
||||
});
|
||||
return redirect(getClass());
|
||||
return redirect(getClass()); // no-op
|
||||
}
|
||||
|
||||
public List<Map<String, Object>> getLogFileItems() {
|
||||
|
@ -104,7 +106,7 @@ public class AdminLogAction extends FessAdminAction {
|
|||
return logFileItems;
|
||||
}
|
||||
|
||||
private HtmlResponse toIndexPage() {
|
||||
private HtmlResponse asIndexHtml() {
|
||||
return asHtml(path_AdminLog_AdminLogJsp).renderWith(data -> {
|
||||
data.register("logFileItems", getLogFileItems());
|
||||
});
|
||||
|
|
|
@ -21,6 +21,7 @@ import org.codelibs.fess.Constants;
|
|||
import org.codelibs.fess.app.pager.PathMappingPager;
|
||||
import org.codelibs.fess.app.service.PathMappingService;
|
||||
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.PathMapping;
|
||||
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 shinsuke
|
||||
|
@ -64,9 +63,7 @@ public class AdminPathmapAction extends FessAdminAction {
|
|||
// ==============
|
||||
@Execute
|
||||
public HtmlResponse index(final SearchForm form) {
|
||||
return asHtml(path_AdminPathmap_AdminPathmapJsp).renderWith(data -> {
|
||||
searchPaging(data, form);
|
||||
});
|
||||
return asListHtml();
|
||||
}
|
||||
|
||||
@Execute
|
||||
|
@ -111,8 +108,8 @@ public class AdminPathmapAction extends FessAdminAction {
|
|||
// Entry Page
|
||||
// ----------
|
||||
@Execute
|
||||
//(token = TxToken.SAVE)
|
||||
public HtmlResponse createnew() {
|
||||
saveToken();
|
||||
return asHtml(path_AdminPathmap_AdminPathmapEditJsp).useForm(CreateForm.class, op -> {
|
||||
op.setup(form -> {
|
||||
form.initialize();
|
||||
|
@ -122,27 +119,23 @@ public class AdminPathmapAction 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_AdminPathmap_AdminPathmapDetailsJsp;
|
||||
break;
|
||||
default:
|
||||
form.crudMode = CrudMode.EDIT;
|
||||
next = path_AdminPathmap_AdminPathmapEditJsp;
|
||||
break;
|
||||
}
|
||||
validate(form, messages -> {}, () -> asListHtml());
|
||||
final String id = form.id;
|
||||
pathMappingService.getPathMapping(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();
|
||||
}
|
||||
}
|
||||
|
||||
// -----------------------------------------------------
|
||||
|
@ -151,6 +144,7 @@ public class AdminPathmapAction extends FessAdminAction {
|
|||
@Execute
|
||||
public HtmlResponse details(final int crudMode, final String id) {
|
||||
verifyCrudMode(crudMode, CrudMode.DETAILS);
|
||||
saveToken();
|
||||
return asHtml(path_AdminPathmap_AdminPathmapDetailsJsp).useForm(EditForm.class, op -> {
|
||||
op.setup(form -> {
|
||||
pathMappingService.getPathMapping(id).ifPresent(entity -> {
|
||||
|
@ -159,7 +153,7 @@ public class AdminPathmapAction extends FessAdminAction {
|
|||
});
|
||||
form.crudMode = crudMode;
|
||||
}).orElse(() -> {
|
||||
throwValidationError(messages -> messages.addErrorsCrudCouldNotFindCrudTable(GLOBAL, id), toEditHtml());
|
||||
throwValidationError(messages -> messages.addErrorsCrudCouldNotFindCrudTable(GLOBAL, id), () -> asListHtml());
|
||||
});
|
||||
});
|
||||
});
|
||||
|
@ -171,12 +165,13 @@ public class AdminPathmapAction extends FessAdminAction {
|
|||
@Execute
|
||||
public HtmlResponse create(final CreateForm form) {
|
||||
verifyCrudMode(form.crudMode, CrudMode.CREATE);
|
||||
validate(form, messages -> {}, toEditHtml());
|
||||
validate(form, messages -> {}, () -> asEditHtml());
|
||||
verifyToken(() -> asEditHtml());
|
||||
getPathMapping(form).ifPresent(entity -> {
|
||||
pathMappingService.store(entity);
|
||||
saveInfo(messages -> messages.addSuccessCrudCreateCrudTable(GLOBAL));
|
||||
}).orElse(() -> {
|
||||
throwValidationError(messages -> messages.addErrorsCrudFailedToCreateCrudTable(GLOBAL), toEditHtml());
|
||||
throwValidationError(messages -> messages.addErrorsCrudFailedToCreateCrudTable(GLOBAL), () -> asEditHtml());
|
||||
});
|
||||
return redirect(getClass());
|
||||
}
|
||||
|
@ -184,12 +179,13 @@ public class AdminPathmapAction extends FessAdminAction {
|
|||
@Execute
|
||||
public HtmlResponse update(final EditForm form) {
|
||||
verifyCrudMode(form.crudMode, CrudMode.EDIT);
|
||||
validate(form, messages -> {}, toEditHtml());
|
||||
validate(form, messages -> {}, () -> asEditHtml());
|
||||
verifyToken(() -> asEditHtml());
|
||||
getPathMapping(form).ifPresent(entity -> {
|
||||
pathMappingService.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());
|
||||
}
|
||||
|
@ -197,13 +193,14 @@ public class AdminPathmapAction 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;
|
||||
pathMappingService.getPathMapping(id).ifPresent(entity -> {
|
||||
pathMappingService.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());
|
||||
}
|
||||
|
@ -251,13 +248,29 @@ public class AdminPathmapAction 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_AdminPathmap_AdminPathmapEditJsp);
|
||||
};
|
||||
// ===================================================================================
|
||||
// JSP
|
||||
// =========
|
||||
|
||||
private HtmlResponse asListHtml() {
|
||||
return asHtml(path_AdminPathmap_AdminPathmapJsp).renderWith(data -> {
|
||||
data.register("pathMappingItems", pathMappingService.getPathMappingList(pathMappingPager)); // page navi
|
||||
}).useForm(SearchForm.class, setup -> {
|
||||
setup.setup(form -> {
|
||||
copyBeanToBean(pathMappingPager, form, op -> op.include("id"));
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
private HtmlResponse asEditHtml() {
|
||||
return asHtml(path_AdminPathmap_AdminPathmapEditJsp);
|
||||
}
|
||||
|
||||
private HtmlResponse asDetailsHtml() {
|
||||
return asHtml(path_AdminPathmap_AdminPathmapDetailsJsp);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -28,6 +28,7 @@ import org.codelibs.fess.app.pager.RequestHeaderPager;
|
|||
import org.codelibs.fess.app.service.RequestHeaderService;
|
||||
import org.codelibs.fess.app.service.WebConfigService;
|
||||
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.RequestHeader;
|
||||
import org.codelibs.fess.es.config.exentity.WebConfig;
|
||||
|
@ -38,10 +39,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.LaRequestUtil;
|
||||
import org.lastaflute.web.validation.VaErrorHook;
|
||||
|
||||
/**
|
||||
* @author shinsuke
|
||||
|
@ -76,9 +75,7 @@ public class AdminReqheaderAction extends FessAdminAction {
|
|||
// ==============
|
||||
@Execute
|
||||
public HtmlResponse index(final SearchForm form) {
|
||||
return asHtml(path_AdminReqheader_AdminReqheaderJsp).renderWith(data -> {
|
||||
searchPaging(data, form);
|
||||
});
|
||||
return asListHtml();
|
||||
}
|
||||
|
||||
@Execute
|
||||
|
@ -124,8 +121,8 @@ public class AdminReqheaderAction extends FessAdminAction {
|
|||
// Entry Page
|
||||
// ----------
|
||||
@Execute
|
||||
//(token = TxToken.SAVE)
|
||||
public HtmlResponse createnew() {
|
||||
saveToken();
|
||||
return asHtml(path_AdminReqheader_AdminReqheaderEditJsp).useForm(CreateForm.class, op -> {
|
||||
op.setup(form -> {
|
||||
form.initialize();
|
||||
|
@ -138,30 +135,29 @@ public class AdminReqheaderAction 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_AdminReqheader_AdminReqheaderDetailsJsp;
|
||||
break;
|
||||
default:
|
||||
form.crudMode = CrudMode.EDIT;
|
||||
next = path_AdminReqheader_AdminReqheaderEditJsp;
|
||||
break;
|
||||
}
|
||||
validate(form, messages -> {}, () -> asListHtml());
|
||||
final String id = form.id;
|
||||
requestHeaderService.getRequestHeader(id).ifPresent(entity -> {
|
||||
copyBeanToBean(entity, form, op -> {});
|
||||
}).orElse(() -> {
|
||||
throwValidationError(messages -> messages.addErrorsCrudCouldNotFindCrudTable(GLOBAL, id), toEditHtml());
|
||||
});
|
||||
return asHtml(next).renderWith(data -> {
|
||||
registerProtocolSchemeItems(data);
|
||||
registerWebConfigItems(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);
|
||||
registerWebConfigItems(data);
|
||||
});
|
||||
} else {
|
||||
form.crudMode = CrudMode.EDIT;
|
||||
return asEditHtml().renderWith(data -> {
|
||||
registerProtocolSchemeItems(data);
|
||||
registerWebConfigItems(data);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
// -----------------------------------------------------
|
||||
|
@ -170,6 +166,7 @@ public class AdminReqheaderAction extends FessAdminAction {
|
|||
@Execute
|
||||
public HtmlResponse details(final int crudMode, final String id) {
|
||||
verifyCrudMode(crudMode, CrudMode.DETAILS);
|
||||
saveToken();
|
||||
return asHtml(path_AdminReqheader_AdminReqheaderDetailsJsp).useForm(EditForm.class, op -> {
|
||||
op.setup(form -> {
|
||||
requestHeaderService.getRequestHeader(id).ifPresent(entity -> {
|
||||
|
@ -178,7 +175,7 @@ public class AdminReqheaderAction extends FessAdminAction {
|
|||
});
|
||||
form.crudMode = crudMode;
|
||||
}).orElse(() -> {
|
||||
throwValidationError(messages -> messages.addErrorsCrudCouldNotFindCrudTable(GLOBAL, id), toEditHtml());
|
||||
throwValidationError(messages -> messages.addErrorsCrudCouldNotFindCrudTable(GLOBAL, id), () -> asListHtml());
|
||||
});
|
||||
});
|
||||
}).renderWith(data -> {
|
||||
|
@ -193,12 +190,13 @@ public class AdminReqheaderAction extends FessAdminAction {
|
|||
@Execute
|
||||
public HtmlResponse create(final CreateForm form) {
|
||||
verifyCrudMode(form.crudMode, CrudMode.CREATE);
|
||||
validate(form, messages -> {}, toEditHtml());
|
||||
validate(form, messages -> {}, () -> asEditHtml());
|
||||
verifyToken(() -> asEditHtml());
|
||||
getRequestHeader(form).ifPresent(entity -> {
|
||||
requestHeaderService.store(entity);
|
||||
saveInfo(messages -> messages.addSuccessCrudCreateCrudTable(GLOBAL));
|
||||
}).orElse(() -> {
|
||||
throwValidationError(messages -> messages.addErrorsCrudFailedToCreateCrudTable(GLOBAL), toEditHtml());
|
||||
throwValidationError(messages -> messages.addErrorsCrudFailedToCreateCrudTable(GLOBAL), () -> asEditHtml());
|
||||
});
|
||||
return redirect(getClass());
|
||||
}
|
||||
|
@ -206,12 +204,13 @@ public class AdminReqheaderAction extends FessAdminAction {
|
|||
@Execute
|
||||
public HtmlResponse update(final EditForm form) {
|
||||
verifyCrudMode(form.crudMode, CrudMode.EDIT);
|
||||
validate(form, messages -> {}, toEditHtml());
|
||||
validate(form, messages -> {}, () -> asEditHtml());
|
||||
verifyToken(() -> asEditHtml());
|
||||
getRequestHeader(form).ifPresent(entity -> {
|
||||
requestHeaderService.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());
|
||||
}
|
||||
|
@ -219,13 +218,14 @@ public class AdminReqheaderAction 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;
|
||||
requestHeaderService.getRequestHeader(id).ifPresent(entity -> {
|
||||
requestHeaderService.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());
|
||||
}
|
||||
|
@ -301,16 +301,30 @@ public class AdminReqheaderAction 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_AdminReqheader_AdminReqheaderEditJsp).renderWith(data -> {
|
||||
registerProtocolSchemeItems(data);
|
||||
registerWebConfigItems(data);
|
||||
// ===================================================================================
|
||||
// JSP
|
||||
// =========
|
||||
|
||||
private HtmlResponse asListHtml() {
|
||||
return asHtml(path_AdminReqheader_AdminReqheaderJsp).renderWith(data -> {
|
||||
data.register("requestHeaderItems", requestHeaderService.getRequestHeaderList(requestHeaderPager)); // page navi
|
||||
data.register("displayCreateLink", !webConfigService.getAllWebConfigList(false, false, false, null).isEmpty());
|
||||
}).useForm(SearchForm.class, setup -> {
|
||||
setup.setup(form -> {
|
||||
copyBeanToBean(requestHeaderPager, form, op -> op.include("id"));
|
||||
});
|
||||
};
|
||||
});
|
||||
}
|
||||
|
||||
private HtmlResponse asEditHtml() {
|
||||
return asHtml(path_AdminReqheader_AdminReqheaderEditJsp);
|
||||
}
|
||||
|
||||
private HtmlResponse asDetailsHtml() {
|
||||
return asHtml(path_AdminReqheader_AdminReqheaderDetailsJsp);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -23,6 +23,7 @@ import org.codelibs.fess.Constants;
|
|||
import org.codelibs.fess.app.pager.RolePager;
|
||||
import org.codelibs.fess.app.service.RoleService;
|
||||
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.Role;
|
||||
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
|
||||
|
@ -65,9 +64,7 @@ public class AdminRoleAction extends FessAdminAction {
|
|||
// ==============
|
||||
@Execute
|
||||
public HtmlResponse index(final SearchForm form) {
|
||||
return asHtml(path_AdminRole_AdminRoleJsp).renderWith(data -> {
|
||||
searchPaging(data, form);
|
||||
});
|
||||
return asListHtml();
|
||||
}
|
||||
|
||||
@Execute
|
||||
|
@ -112,8 +109,8 @@ public class AdminRoleAction extends FessAdminAction {
|
|||
// Entry Page
|
||||
// ----------
|
||||
@Execute
|
||||
//(token = TxToken.SAVE)
|
||||
public HtmlResponse createnew() {
|
||||
saveToken();
|
||||
return asHtml(path_AdminRole_AdminRoleEditJsp).useForm(CreateForm.class, op -> {
|
||||
op.setup(form -> {
|
||||
form.initialize();
|
||||
|
@ -123,27 +120,23 @@ public class AdminRoleAction 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_AdminRole_AdminRoleDetailsJsp;
|
||||
break;
|
||||
default:
|
||||
form.crudMode = CrudMode.EDIT;
|
||||
next = path_AdminRole_AdminRoleEditJsp;
|
||||
break;
|
||||
}
|
||||
validate(form, messages -> {}, () -> asListHtml());
|
||||
final String id = form.id;
|
||||
roleService.getRole(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 AdminRoleAction extends FessAdminAction {
|
|||
@Execute
|
||||
public HtmlResponse details(final int crudMode, final String id) {
|
||||
verifyCrudMode(crudMode, CrudMode.DETAILS);
|
||||
saveToken();
|
||||
return asHtml(path_AdminRole_AdminRoleDetailsJsp).useForm(EditForm.class, op -> {
|
||||
op.setup(form -> {
|
||||
roleService.getRole(id).ifPresent(entity -> {
|
||||
|
@ -160,7 +154,7 @@ public class AdminRoleAction 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 AdminRoleAction extends FessAdminAction {
|
|||
@Execute
|
||||
public HtmlResponse create(final CreateForm form) {
|
||||
verifyCrudMode(form.crudMode, CrudMode.CREATE);
|
||||
validate(form, messages -> {}, toEditHtml());
|
||||
validate(form, messages -> {}, () -> asEditHtml());
|
||||
verifyToken(() -> asEditHtml());
|
||||
getRole(form).ifPresent(entity -> {
|
||||
roleService.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 AdminRoleAction extends FessAdminAction {
|
|||
@Execute
|
||||
public HtmlResponse update(final EditForm form) {
|
||||
verifyCrudMode(form.crudMode, CrudMode.EDIT);
|
||||
validate(form, messages -> {}, toEditHtml());
|
||||
validate(form, messages -> {}, () -> asEditHtml());
|
||||
verifyToken(() -> asEditHtml());
|
||||
getRole(form).ifPresent(entity -> {
|
||||
roleService.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 AdminRoleAction 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;
|
||||
roleService.getRole(id).ifPresent(entity -> {
|
||||
roleService.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 AdminRoleAction 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_AdminRole_AdminRoleEditJsp);
|
||||
};
|
||||
// ===================================================================================
|
||||
// JSP
|
||||
// =========
|
||||
|
||||
private HtmlResponse asListHtml() {
|
||||
return asHtml(path_AdminRole_AdminRoleJsp).renderWith(data -> {
|
||||
data.register("roleItems", roleService.getRoleList(rolePager)); // page navi
|
||||
}).useForm(SearchForm.class, setup -> {
|
||||
setup.setup(form -> {
|
||||
copyBeanToBean(rolePager, form, op -> op.include("id"));
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
private HtmlResponse asEditHtml() {
|
||||
return asHtml(path_AdminRole_AdminRoleEditJsp);
|
||||
}
|
||||
|
||||
private HtmlResponse asDetailsHtml() {
|
||||
return asHtml(path_AdminRole_AdminRoleDetailsJsp);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -31,7 +31,7 @@ public class CreateForm implements Serializable {
|
|||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@ValidateTypeFailure
|
||||
public int crudMode;
|
||||
public Integer crudMode;
|
||||
|
||||
@Required
|
||||
@Size(max = 100)
|
||||
|
|
|
@ -21,6 +21,7 @@ import org.codelibs.fess.Constants;
|
|||
import org.codelibs.fess.app.pager.RoleTypePager;
|
||||
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.RoleType;
|
||||
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 AdminRoletypeAction extends FessAdminAction {
|
|||
// ==============
|
||||
@Execute
|
||||
public HtmlResponse index(final SearchForm form) {
|
||||
return asHtml(path_AdminRoletype_AdminRoletypeJsp).renderWith(data -> {
|
||||
searchPaging(data, form);
|
||||
});
|
||||
return asListHtml();
|
||||
}
|
||||
|
||||
@Execute
|
||||
|
@ -110,8 +107,8 @@ public class AdminRoletypeAction extends FessAdminAction {
|
|||
// Entry Page
|
||||
// ----------
|
||||
@Execute
|
||||
//(token = TxToken.SAVE)
|
||||
public HtmlResponse createnew() {
|
||||
saveToken();
|
||||
return asHtml(path_AdminRoletype_AdminRoletypeEditJsp).useForm(CreateForm.class, op -> {
|
||||
op.setup(form -> {
|
||||
form.initialize();
|
||||
|
@ -121,27 +118,23 @@ public class AdminRoletypeAction 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_AdminRoletype_AdminRoletypeDetailsJsp;
|
||||
break;
|
||||
default:
|
||||
form.crudMode = CrudMode.EDIT;
|
||||
next = path_AdminRoletype_AdminRoletypeEditJsp;
|
||||
break;
|
||||
}
|
||||
validate(form, messages -> {}, () -> asListHtml());
|
||||
final String id = form.id;
|
||||
roleTypeService.getRoleType(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 AdminRoletypeAction extends FessAdminAction {
|
|||
@Execute
|
||||
public HtmlResponse details(final int crudMode, final String id) {
|
||||
verifyCrudMode(crudMode, CrudMode.DETAILS);
|
||||
saveToken();
|
||||
return asHtml(path_AdminRoletype_AdminRoletypeDetailsJsp).useForm(EditForm.class, op -> {
|
||||
op.setup(form -> {
|
||||
roleTypeService.getRoleType(id).ifPresent(entity -> {
|
||||
|
@ -158,7 +152,7 @@ public class AdminRoletypeAction 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 AdminRoletypeAction extends FessAdminAction {
|
|||
@Execute
|
||||
public HtmlResponse create(final CreateForm form) {
|
||||
verifyCrudMode(form.crudMode, CrudMode.CREATE);
|
||||
validate(form, messages -> {}, toEditHtml());
|
||||
validate(form, messages -> {}, () -> asEditHtml());
|
||||
verifyToken(() -> asEditHtml());
|
||||
getRoleType(form).ifPresent(entity -> {
|
||||
roleTypeService.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 AdminRoletypeAction extends FessAdminAction {
|
|||
@Execute
|
||||
public HtmlResponse update(final EditForm form) {
|
||||
verifyCrudMode(form.crudMode, CrudMode.EDIT);
|
||||
validate(form, messages -> {}, toEditHtml());
|
||||
validate(form, messages -> {}, () -> asEditHtml());
|
||||
verifyToken(() -> asEditHtml());
|
||||
getRoleType(form).ifPresent(entity -> {
|
||||
roleTypeService.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 AdminRoletypeAction 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;
|
||||
roleTypeService.getRoleType(id).ifPresent(entity -> {
|
||||
roleTypeService.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 AdminRoletypeAction 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_AdminRoletype_AdminRoletypeEditJsp);
|
||||
};
|
||||
// ===================================================================================
|
||||
// JSP
|
||||
// =========
|
||||
|
||||
private HtmlResponse asListHtml() {
|
||||
return asHtml(path_AdminRoletype_AdminRoletypeJsp).renderWith(data -> {
|
||||
data.register("roleTypeItems", roleTypeService.getRoleTypeList(roleTypePager)); // page navi
|
||||
}).useForm(SearchForm.class, setup -> {
|
||||
setup.setup(form -> {
|
||||
copyBeanToBean(roleTypePager, form, op -> op.include("id"));
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
private HtmlResponse asEditHtml() {
|
||||
return asHtml(path_AdminRoletype_AdminRoletypeEditJsp);
|
||||
}
|
||||
|
||||
private HtmlResponse asDetailsHtml() {
|
||||
return asHtml(path_AdminRoletype_AdminRoletypeDetailsJsp);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -21,6 +21,7 @@ import org.codelibs.fess.Constants;
|
|||
import org.codelibs.fess.app.pager.ScheduledJobPager;
|
||||
import org.codelibs.fess.app.service.ScheduledJobService;
|
||||
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.ScheduledJob;
|
||||
import org.codelibs.fess.helper.JobHelper;
|
||||
|
@ -31,10 +32,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.LaRequestUtil;
|
||||
import org.lastaflute.web.validation.VaErrorHook;
|
||||
|
||||
/**
|
||||
* @author shinsuke
|
||||
|
@ -68,9 +67,7 @@ public class AdminSchedulerAction extends FessAdminAction {
|
|||
// ==============
|
||||
@Execute
|
||||
public HtmlResponse index(final SearchForm form) {
|
||||
return asHtml(path_AdminScheduler_AdminSchedulerJsp).renderWith(data -> {
|
||||
searchPaging(data, form);
|
||||
});
|
||||
return asListHtml();
|
||||
}
|
||||
|
||||
@Execute
|
||||
|
@ -115,8 +112,8 @@ public class AdminSchedulerAction extends FessAdminAction {
|
|||
// Entry Page
|
||||
// ----------
|
||||
@Execute
|
||||
//(token = TxToken.SAVE)
|
||||
public HtmlResponse createnew() {
|
||||
saveToken();
|
||||
return asHtml(path_AdminScheduler_AdminSchedulerEditJsp).useForm(CreateForm.class, op -> {
|
||||
op.setup(form -> {
|
||||
form.initialize();
|
||||
|
@ -126,27 +123,23 @@ public class AdminSchedulerAction 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_AdminScheduler_AdminSchedulerDetailsJsp;
|
||||
break;
|
||||
default:
|
||||
form.crudMode = CrudMode.EDIT;
|
||||
next = path_AdminScheduler_AdminSchedulerEditJsp;
|
||||
break;
|
||||
}
|
||||
validate(form, messages -> {}, () -> asListHtml());
|
||||
final String id = form.id;
|
||||
scheduledJobService.getScheduledJob(id).ifPresent(entity -> {
|
||||
loadScheduledJob(form, entity);
|
||||
}).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();
|
||||
}
|
||||
}
|
||||
|
||||
// -----------------------------------------------------
|
||||
|
@ -155,6 +148,7 @@ public class AdminSchedulerAction extends FessAdminAction {
|
|||
@Execute
|
||||
public HtmlResponse details(final int crudMode, final String id) {
|
||||
verifyCrudMode(crudMode, CrudMode.DETAILS);
|
||||
saveToken();
|
||||
return asHtml(path_AdminScheduler_AdminSchedulerDetailsJsp).useForm(EditForm.class, op -> {
|
||||
op.setup(form -> {
|
||||
scheduledJobService.getScheduledJob(id).ifPresent(entity -> {
|
||||
|
@ -164,7 +158,7 @@ public class AdminSchedulerAction extends FessAdminAction {
|
|||
request.setAttribute("running", entity.isRunning());
|
||||
});
|
||||
}).orElse(() -> {
|
||||
throwValidationError(messages -> messages.addErrorsCrudCouldNotFindCrudTable(GLOBAL, id), toEditHtml());
|
||||
throwValidationError(messages -> messages.addErrorsCrudCouldNotFindCrudTable(GLOBAL, id), () -> asListHtml());
|
||||
});
|
||||
});
|
||||
});
|
||||
|
@ -176,12 +170,13 @@ public class AdminSchedulerAction extends FessAdminAction {
|
|||
@Execute
|
||||
public HtmlResponse create(final CreateForm form) {
|
||||
verifyCrudMode(form.crudMode, CrudMode.CREATE);
|
||||
validate(form, messages -> {}, toEditHtml());
|
||||
validate(form, messages -> {}, () -> asEditHtml());
|
||||
verifyToken(() -> asEditHtml());
|
||||
getScheduledJob(form).ifPresent(entity -> {
|
||||
scheduledJobService.store(entity);
|
||||
saveInfo(messages -> messages.addSuccessCrudCreateCrudTable(GLOBAL));
|
||||
}).orElse(() -> {
|
||||
throwValidationError(messages -> messages.addErrorsCrudFailedToCreateCrudTable(GLOBAL), toEditHtml());
|
||||
throwValidationError(messages -> messages.addErrorsCrudFailedToCreateCrudTable(GLOBAL), () -> asEditHtml());
|
||||
});
|
||||
return redirect(getClass());
|
||||
}
|
||||
|
@ -189,12 +184,13 @@ public class AdminSchedulerAction extends FessAdminAction {
|
|||
@Execute
|
||||
public HtmlResponse update(final EditForm form) {
|
||||
verifyCrudMode(form.crudMode, CrudMode.EDIT);
|
||||
validate(form, messages -> {}, toEditHtml());
|
||||
validate(form, messages -> {}, () -> asEditHtml());
|
||||
verifyToken(() -> asEditHtml());
|
||||
getScheduledJob(form).ifPresent(entity -> {
|
||||
scheduledJobService.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());
|
||||
}
|
||||
|
@ -202,13 +198,14 @@ public class AdminSchedulerAction 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;
|
||||
scheduledJobService.getScheduledJob(id).ifPresent(entity -> {
|
||||
scheduledJobService.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());
|
||||
}
|
||||
|
@ -216,7 +213,8 @@ public class AdminSchedulerAction extends FessAdminAction {
|
|||
@Execute
|
||||
public HtmlResponse start(final EditForm form) {
|
||||
verifyCrudMode(form.crudMode, CrudMode.DETAILS);
|
||||
validate(form, messages -> {}, toEditHtml());
|
||||
validate(form, messages -> {}, () -> asDetailsHtml());
|
||||
verifyToken(() -> asDetailsHtml());
|
||||
final String id = form.id;
|
||||
scheduledJobService.getScheduledJob(id).ifPresent(entity -> {
|
||||
try {
|
||||
|
@ -225,12 +223,12 @@ public class AdminSchedulerAction extends FessAdminAction {
|
|||
} catch (final Exception e) {
|
||||
throwValidationError(messages -> {
|
||||
messages.addErrorsFailedToStartJob(GLOBAL, entity.getName());
|
||||
}, toEditHtml());
|
||||
}, () -> asDetailsHtml());
|
||||
}
|
||||
}).orElse(() -> {
|
||||
throwValidationError(messages -> {
|
||||
messages.addErrorsFailedToStartJob(GLOBAL, id);
|
||||
}, toEditHtml());
|
||||
}, () -> asDetailsHtml());
|
||||
});
|
||||
return redirect(getClass());
|
||||
}
|
||||
|
@ -238,7 +236,8 @@ public class AdminSchedulerAction extends FessAdminAction {
|
|||
@Execute
|
||||
public HtmlResponse stop(final EditForm form) {
|
||||
verifyCrudMode(form.crudMode, CrudMode.DETAILS);
|
||||
validate(form, messages -> {}, toEditHtml());
|
||||
validate(form, messages -> {}, () -> asDetailsHtml());
|
||||
verifyToken(() -> asDetailsHtml());
|
||||
final String id = form.id;
|
||||
scheduledJobService.getScheduledJob(id).ifPresent(entity -> {
|
||||
try {
|
||||
|
@ -248,12 +247,12 @@ public class AdminSchedulerAction extends FessAdminAction {
|
|||
} catch (final Exception e) {
|
||||
throwValidationError(messages -> {
|
||||
messages.addErrorsFailedToStopJob(GLOBAL, entity.getName());
|
||||
}, toEditHtml());
|
||||
}, () -> asDetailsHtml());
|
||||
}
|
||||
}).orElse(() -> {
|
||||
throwValidationError(messages -> {
|
||||
messages.addErrorsFailedToStartJob(GLOBAL, id);
|
||||
}, toEditHtml());
|
||||
}, () -> asDetailsHtml());
|
||||
});
|
||||
return redirect(getClass());
|
||||
}
|
||||
|
@ -311,13 +310,29 @@ public class AdminSchedulerAction 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_AdminScheduler_AdminSchedulerEditJsp);
|
||||
};
|
||||
// ===================================================================================
|
||||
// JSP
|
||||
// =========
|
||||
|
||||
private HtmlResponse asListHtml() {
|
||||
return asHtml(path_AdminScheduler_AdminSchedulerJsp).renderWith(data -> {
|
||||
data.register("scheduledJobItems", scheduledJobService.getScheduledJobList(scheduledJobPager)); // page navi
|
||||
}).useForm(SearchForm.class, setup -> {
|
||||
setup.setup(form -> {
|
||||
copyBeanToBean(scheduledJobPager, form, op -> op.include("id"));
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
private HtmlResponse asEditHtml() {
|
||||
return asHtml(path_AdminScheduler_AdminSchedulerEditJsp);
|
||||
}
|
||||
|
||||
private HtmlResponse asDetailsHtml() {
|
||||
return asHtml(path_AdminScheduler_AdminSchedulerDetailsJsp);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -35,7 +35,7 @@ public class CreateForm implements Serializable {
|
|||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@ValidateTypeFailure
|
||||
public int crudMode;
|
||||
public Integer crudMode;
|
||||
|
||||
@Required
|
||||
@Size(max = 100)
|
||||
|
|
|
@ -62,7 +62,7 @@ public class AdminSysteminfoAction extends FessAdminAction {
|
|||
// Index
|
||||
// ==============
|
||||
@Execute
|
||||
public HtmlResponse index(final SystemInfoForm form) {
|
||||
public HtmlResponse index() {
|
||||
return asHtml(path_AdminSysteminfo_AdminSysteminfoJsp).renderWith(data -> {
|
||||
registerEnvItems(data);
|
||||
registerPropItems(data);
|
||||
|
|
|
@ -1,28 +0,0 @@
|
|||
/*
|
||||
* 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.systeminfo;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* @author codelibs
|
||||
* @author Keiichi Watanabe
|
||||
*/
|
||||
public class SystemInfoForm implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
}
|
|
@ -28,6 +28,7 @@ import org.codelibs.fess.app.pager.WebAuthenticationPager;
|
|||
import org.codelibs.fess.app.service.WebAuthenticationService;
|
||||
import org.codelibs.fess.app.service.WebConfigService;
|
||||
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.WebAuthentication;
|
||||
import org.codelibs.fess.es.config.exentity.WebConfig;
|
||||
|
@ -38,10 +39,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.LaRequestUtil;
|
||||
import org.lastaflute.web.validation.VaErrorHook;
|
||||
|
||||
/**
|
||||
* @author shinsuke
|
||||
|
@ -76,9 +75,7 @@ public class AdminWebauthAction extends FessAdminAction {
|
|||
// ==============
|
||||
@Execute
|
||||
public HtmlResponse index(final SearchForm form) {
|
||||
return asHtml(path_AdminWebauth_AdminWebauthJsp).renderWith(data -> {
|
||||
searchPaging(data, form);
|
||||
});
|
||||
return asListHtml();
|
||||
}
|
||||
|
||||
@Execute
|
||||
|
@ -123,8 +120,8 @@ public class AdminWebauthAction extends FessAdminAction {
|
|||
// Entry Page
|
||||
// ----------
|
||||
@Execute
|
||||
//(token = TxToken.SAVE)
|
||||
public HtmlResponse createnew() {
|
||||
saveToken();
|
||||
return asHtml(path_AdminWebauth_AdminWebauthEditJsp).useForm(CreateForm.class, op -> {
|
||||
op.setup(form -> {
|
||||
form.initialize();
|
||||
|
@ -137,30 +134,29 @@ public class AdminWebauthAction 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_AdminWebauth_AdminWebauthDetailsJsp;
|
||||
break;
|
||||
default:
|
||||
form.crudMode = CrudMode.EDIT;
|
||||
next = path_AdminWebauth_AdminWebauthEditJsp;
|
||||
break;
|
||||
}
|
||||
validate(form, messages -> {}, () -> asListHtml());
|
||||
final String id = form.id;
|
||||
webAuthenticationService.getWebAuthentication(id).ifPresent(entity -> {
|
||||
copyBeanToBean(entity, form, op -> {});
|
||||
}).orElse(() -> {
|
||||
throwValidationError(messages -> messages.addErrorsCrudCouldNotFindCrudTable(GLOBAL, id), toEditHtml());
|
||||
});
|
||||
return asHtml(next).renderWith(data -> {
|
||||
registerProtocolSchemeItems(data);
|
||||
registerWebConfigItems(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);
|
||||
registerWebConfigItems(data);
|
||||
});
|
||||
} else {
|
||||
form.crudMode = CrudMode.EDIT;
|
||||
return asEditHtml().renderWith(data -> {
|
||||
registerProtocolSchemeItems(data);
|
||||
registerWebConfigItems(data);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
// -----------------------------------------------------
|
||||
|
@ -169,6 +165,7 @@ public class AdminWebauthAction extends FessAdminAction {
|
|||
@Execute
|
||||
public HtmlResponse details(final int crudMode, final String id) {
|
||||
verifyCrudMode(crudMode, CrudMode.DETAILS);
|
||||
saveToken();
|
||||
return asHtml(path_AdminWebauth_AdminWebauthDetailsJsp).useForm(EditForm.class, op -> {
|
||||
op.setup(form -> {
|
||||
webAuthenticationService.getWebAuthentication(id).ifPresent(entity -> {
|
||||
|
@ -177,7 +174,7 @@ public class AdminWebauthAction extends FessAdminAction {
|
|||
});
|
||||
form.crudMode = crudMode;
|
||||
}).orElse(() -> {
|
||||
throwValidationError(messages -> messages.addErrorsCrudCouldNotFindCrudTable(GLOBAL, id), toEditHtml());
|
||||
throwValidationError(messages -> messages.addErrorsCrudCouldNotFindCrudTable(GLOBAL, id), () -> asListHtml());
|
||||
});
|
||||
});
|
||||
}).renderWith(data -> {
|
||||
|
@ -192,12 +189,13 @@ public class AdminWebauthAction extends FessAdminAction {
|
|||
@Execute
|
||||
public HtmlResponse create(final CreateForm form) {
|
||||
verifyCrudMode(form.crudMode, CrudMode.CREATE);
|
||||
validate(form, messages -> {}, toEditHtml());
|
||||
validate(form, messages -> {}, () -> asEditHtml());
|
||||
verifyToken(() -> asEditHtml());
|
||||
getWebAuthentication(form).ifPresent(entity -> {
|
||||
webAuthenticationService.store(entity);
|
||||
saveInfo(messages -> messages.addSuccessCrudCreateCrudTable(GLOBAL));
|
||||
}).orElse(() -> {
|
||||
throwValidationError(messages -> messages.addErrorsCrudFailedToCreateCrudTable(GLOBAL), toEditHtml());
|
||||
throwValidationError(messages -> messages.addErrorsCrudFailedToCreateCrudTable(GLOBAL), () -> asEditHtml());
|
||||
});
|
||||
return redirect(getClass());
|
||||
}
|
||||
|
@ -205,12 +203,13 @@ public class AdminWebauthAction extends FessAdminAction {
|
|||
@Execute
|
||||
public HtmlResponse update(final EditForm form) {
|
||||
verifyCrudMode(form.crudMode, CrudMode.EDIT);
|
||||
validate(form, messages -> {}, toEditHtml());
|
||||
validate(form, messages -> {}, () -> asEditHtml());
|
||||
verifyToken(() -> asEditHtml());
|
||||
getWebAuthentication(form).ifPresent(entity -> {
|
||||
webAuthenticationService.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());
|
||||
}
|
||||
|
@ -218,13 +217,14 @@ public class AdminWebauthAction 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;
|
||||
webAuthenticationService.getWebAuthentication(id).ifPresent(entity -> {
|
||||
webAuthenticationService.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());
|
||||
}
|
||||
|
@ -300,15 +300,30 @@ public class AdminWebauthAction 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_AdminWebauth_AdminWebauthEditJsp).renderWith(data -> {
|
||||
registerWebConfigItems(data);
|
||||
// ===================================================================================
|
||||
// JSP
|
||||
// =========
|
||||
|
||||
private HtmlResponse asListHtml() {
|
||||
return asHtml(path_AdminWebauth_AdminWebauthJsp).renderWith(data -> {
|
||||
data.register("webAuthenticationItems", webAuthenticationService.getWebAuthenticationList(webAuthenticationPager)); // page navi
|
||||
data.register("displayCreateLink", !webConfigService.getAllWebConfigList(false, false, false, null).isEmpty());
|
||||
}).useForm(SearchForm.class, setup -> {
|
||||
setup.setup(form -> {
|
||||
copyBeanToBean(webAuthenticationPager, form, op -> op.include("id"));
|
||||
});
|
||||
};
|
||||
});
|
||||
}
|
||||
|
||||
private HtmlResponse asEditHtml() {
|
||||
return asHtml(path_AdminWebauth_AdminWebauthEditJsp);
|
||||
}
|
||||
|
||||
private HtmlResponse asDetailsHtml() {
|
||||
return asHtml(path_AdminWebauth_AdminWebauthDetailsJsp);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -24,6 +24,7 @@ import org.codelibs.fess.app.service.RoleTypeService;
|
|||
import org.codelibs.fess.app.service.ScheduledJobService;
|
||||
import org.codelibs.fess.app.service.WebConfigService;
|
||||
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.ScheduledJob;
|
||||
import org.codelibs.fess.es.config.exentity.WebConfig;
|
||||
|
@ -34,10 +35,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.LaRequestUtil;
|
||||
import org.lastaflute.web.validation.VaErrorHook;
|
||||
|
||||
/**
|
||||
* @author shinsuke
|
||||
|
@ -76,9 +75,7 @@ public class AdminWebconfigAction extends FessAdminAction {
|
|||
// ==============
|
||||
@Execute
|
||||
public HtmlResponse index(final SearchForm form) {
|
||||
return asHtml(path_AdminWebconfig_AdminWebconfigJsp).renderWith(data -> {
|
||||
searchPaging(data, form);
|
||||
});
|
||||
return asListHtml();
|
||||
}
|
||||
|
||||
@Execute
|
||||
|
@ -123,8 +120,8 @@ public class AdminWebconfigAction extends FessAdminAction {
|
|||
// Entry Page
|
||||
// ----------
|
||||
@Execute
|
||||
//(token = TxToken.SAVE)
|
||||
public HtmlResponse createnew() {
|
||||
saveToken();
|
||||
return asHtml(path_AdminWebconfig_AdminWebconfigEditJsp).useForm(CreateForm.class, op -> {
|
||||
op.setup(form -> {
|
||||
form.initialize();
|
||||
|
@ -136,34 +133,33 @@ public class AdminWebconfigAction 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_AdminWebconfig_AdminWebconfigDetailsJsp;
|
||||
break;
|
||||
default:
|
||||
form.crudMode = CrudMode.EDIT;
|
||||
next = path_AdminWebconfig_AdminWebconfigEditJsp;
|
||||
break;
|
||||
}
|
||||
validate(form, messages -> {}, () -> asListHtml());
|
||||
final String id = form.id;
|
||||
webConfigService.getWebConfig(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 -> {}, () -> asEditHtml());
|
||||
verifyToken(() -> asEditHtml());
|
||||
final ScheduledJob scheduledJob = new ScheduledJob();
|
||||
scheduledJob.setCrawler(true);
|
||||
return asHtml(path_AdminScheduler_AdminSchedulerEditJsp).useForm(
|
||||
|
@ -191,6 +187,7 @@ public class AdminWebconfigAction extends FessAdminAction {
|
|||
@Execute
|
||||
public HtmlResponse details(final int crudMode, final String id) {
|
||||
verifyCrudMode(crudMode, CrudMode.DETAILS);
|
||||
saveToken();
|
||||
return asHtml(path_AdminWebconfig_AdminWebconfigDetailsJsp).useForm(EditForm.class, op -> {
|
||||
op.setup(form -> {
|
||||
webConfigService.getWebConfig(id).ifPresent(entity -> {
|
||||
|
@ -199,7 +196,7 @@ public class AdminWebconfigAction extends FessAdminAction {
|
|||
});
|
||||
form.crudMode = crudMode;
|
||||
}).orElse(() -> {
|
||||
throwValidationError(messages -> messages.addErrorsCrudCouldNotFindCrudTable(GLOBAL, id), toEditHtml());
|
||||
throwValidationError(messages -> messages.addErrorsCrudCouldNotFindCrudTable(GLOBAL, id), () -> asListHtml());
|
||||
});
|
||||
});
|
||||
}).renderWith(data -> {
|
||||
|
@ -213,12 +210,13 @@ public class AdminWebconfigAction extends FessAdminAction {
|
|||
@Execute
|
||||
public HtmlResponse create(final CreateForm form) {
|
||||
verifyCrudMode(form.crudMode, CrudMode.CREATE);
|
||||
validate(form, messages -> {}, toEditHtml());
|
||||
validate(form, messages -> {}, () -> asEditHtml());
|
||||
verifyToken(() -> asEditHtml());
|
||||
getWebConfig(form).ifPresent(entity -> {
|
||||
webConfigService.store(entity);
|
||||
saveInfo(messages -> messages.addSuccessCrudCreateCrudTable(GLOBAL));
|
||||
}).orElse(() -> {
|
||||
throwValidationError(messages -> messages.addErrorsCrudFailedToCreateCrudTable(GLOBAL), toEditHtml());
|
||||
throwValidationError(messages -> messages.addErrorsCrudFailedToCreateCrudTable(GLOBAL), () -> asEditHtml());
|
||||
});
|
||||
return redirect(getClass());
|
||||
}
|
||||
|
@ -226,12 +224,13 @@ public class AdminWebconfigAction extends FessAdminAction {
|
|||
@Execute
|
||||
public HtmlResponse update(final EditForm form) {
|
||||
verifyCrudMode(form.crudMode, CrudMode.EDIT);
|
||||
validate(form, messages -> {}, toEditHtml());
|
||||
validate(form, messages -> {}, () -> asEditHtml());
|
||||
verifyToken(() -> asEditHtml());
|
||||
getWebConfig(form).ifPresent(entity -> {
|
||||
webConfigService.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());
|
||||
}
|
||||
|
@ -239,13 +238,14 @@ public class AdminWebconfigAction 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;
|
||||
webConfigService.getWebConfig(id).ifPresent(entity -> {
|
||||
webConfigService.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());
|
||||
}
|
||||
|
@ -298,15 +298,29 @@ public class AdminWebconfigAction 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_AdminWebconfig_AdminWebconfigEditJsp).renderWith(data -> {
|
||||
registerRolesAndLabels(data);
|
||||
// ===================================================================================
|
||||
// JSP
|
||||
// =========
|
||||
|
||||
private HtmlResponse asListHtml() {
|
||||
return asHtml(path_AdminWebconfig_AdminWebconfigJsp).renderWith(data -> {
|
||||
data.register("webConfigItems", webConfigService.getWebConfigList(webConfigPager)); // page navi
|
||||
}).useForm(SearchForm.class, setup -> {
|
||||
setup.setup(form -> {
|
||||
copyBeanToBean(webConfigPager, form, op -> op.include("id"));
|
||||
});
|
||||
};
|
||||
});
|
||||
}
|
||||
|
||||
private HtmlResponse asEditHtml() {
|
||||
return asHtml(path_AdminWebconfig_AdminWebconfigEditJsp);
|
||||
}
|
||||
|
||||
private HtmlResponse asDetailsHtml() {
|
||||
return asHtml(path_AdminWebconfig_AdminWebconfigDetailsJsp);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -94,7 +94,7 @@ public abstract class EsAbstractBehavior<ENTITY extends Entity, CB extends Condi
|
|||
final int from;
|
||||
final int size;
|
||||
if (cb.isFetchScopeEffective()) {
|
||||
from = cb.getFetchStartIndex();
|
||||
from = cb.getPageStartIndex();
|
||||
size = cb.getFetchSize();
|
||||
} else {
|
||||
from = 0;
|
||||
|
|
|
@ -94,7 +94,7 @@ public abstract class EsAbstractBehavior<ENTITY extends Entity, CB extends Condi
|
|||
final int from;
|
||||
final int size;
|
||||
if (cb.isFetchScopeEffective()) {
|
||||
from = cb.getFetchStartIndex();
|
||||
from = cb.getPageStartIndex();
|
||||
size = cb.getFetchSize();
|
||||
} else {
|
||||
from = 0;
|
||||
|
|
|
@ -94,7 +94,7 @@ public abstract class EsAbstractBehavior<ENTITY extends Entity, CB extends Condi
|
|||
final int from;
|
||||
final int size;
|
||||
if (cb.isFetchScopeEffective()) {
|
||||
from = cb.getFetchStartIndex();
|
||||
from = cb.getPageStartIndex();
|
||||
size = cb.getFetchSize();
|
||||
} else {
|
||||
from = 0;
|
||||
|
|
Loading…
Add table
Reference in a new issue