|
@@ -35,6 +35,7 @@ import org.codelibs.fess.es.exentity.WebAuthentication;
|
|
import org.codelibs.fess.es.exentity.WebConfig;
|
|
import org.codelibs.fess.es.exentity.WebConfig;
|
|
import org.codelibs.fess.helper.SystemHelper;
|
|
import org.codelibs.fess.helper.SystemHelper;
|
|
import org.codelibs.fess.util.ComponentUtil;
|
|
import org.codelibs.fess.util.ComponentUtil;
|
|
|
|
+import org.dbflute.optional.OptionalEntity;
|
|
import org.lastaflute.web.Execute;
|
|
import org.lastaflute.web.Execute;
|
|
import org.lastaflute.web.callback.ActionRuntime;
|
|
import org.lastaflute.web.callback.ActionRuntime;
|
|
import org.lastaflute.web.response.HtmlResponse;
|
|
import org.lastaflute.web.response.HtmlResponse;
|
|
@@ -74,14 +75,14 @@ public class AdminWebauthenticationAction extends FessAdminAction {
|
|
// Search Execute
|
|
// Search Execute
|
|
// ==============
|
|
// ==============
|
|
@Execute
|
|
@Execute
|
|
- public HtmlResponse index(final WebAuthenticationSearchForm form) {
|
|
|
|
|
|
+ public HtmlResponse index(final SearchForm form) {
|
|
return asHtml(path_AdminWebauthentication_IndexJsp).renderWith(data -> {
|
|
return asHtml(path_AdminWebauthentication_IndexJsp).renderWith(data -> {
|
|
searchPaging(data, form);
|
|
searchPaging(data, form);
|
|
});
|
|
});
|
|
}
|
|
}
|
|
|
|
|
|
@Execute
|
|
@Execute
|
|
- public HtmlResponse list(final Integer pageNumber, final WebAuthenticationSearchForm form) {
|
|
|
|
|
|
+ public HtmlResponse list(final Integer pageNumber, final SearchForm form) {
|
|
webAuthenticationPager.setCurrentPageNumber(pageNumber);
|
|
webAuthenticationPager.setCurrentPageNumber(pageNumber);
|
|
return asHtml(path_AdminWebauthentication_IndexJsp).renderWith(data -> {
|
|
return asHtml(path_AdminWebauthentication_IndexJsp).renderWith(data -> {
|
|
searchPaging(data, form);
|
|
searchPaging(data, form);
|
|
@@ -89,15 +90,15 @@ public class AdminWebauthenticationAction extends FessAdminAction {
|
|
}
|
|
}
|
|
|
|
|
|
@Execute
|
|
@Execute
|
|
- public HtmlResponse search(final WebAuthenticationSearchForm form) {
|
|
|
|
- copyBeanToBean(form.searchParams, webAuthenticationPager, op -> op.exclude(Constants.PAGER_CONVERSION_RULE));
|
|
|
|
|
|
+ public HtmlResponse search(final SearchForm form) {
|
|
|
|
+ copyBeanToBean(form, webAuthenticationPager, op -> op.exclude(Constants.PAGER_CONVERSION_RULE));
|
|
return asHtml(path_AdminWebauthentication_IndexJsp).renderWith(data -> {
|
|
return asHtml(path_AdminWebauthentication_IndexJsp).renderWith(data -> {
|
|
searchPaging(data, form);
|
|
searchPaging(data, form);
|
|
});
|
|
});
|
|
}
|
|
}
|
|
|
|
|
|
@Execute
|
|
@Execute
|
|
- public HtmlResponse reset(final WebAuthenticationSearchForm form) {
|
|
|
|
|
|
+ public HtmlResponse reset(final SearchForm form) {
|
|
webAuthenticationPager.clear();
|
|
webAuthenticationPager.clear();
|
|
return asHtml(path_AdminWebauthentication_IndexJsp).renderWith(data -> {
|
|
return asHtml(path_AdminWebauthentication_IndexJsp).renderWith(data -> {
|
|
searchPaging(data, form);
|
|
searchPaging(data, form);
|
|
@@ -105,17 +106,17 @@ public class AdminWebauthenticationAction extends FessAdminAction {
|
|
}
|
|
}
|
|
|
|
|
|
@Execute
|
|
@Execute
|
|
- public HtmlResponse back(final WebAuthenticationSearchForm form) {
|
|
|
|
|
|
+ public HtmlResponse back(final SearchForm form) {
|
|
return asHtml(path_AdminWebauthentication_IndexJsp).renderWith(data -> {
|
|
return asHtml(path_AdminWebauthentication_IndexJsp).renderWith(data -> {
|
|
searchPaging(data, form);
|
|
searchPaging(data, form);
|
|
});
|
|
});
|
|
}
|
|
}
|
|
|
|
|
|
- protected void searchPaging(final RenderData data, final WebAuthenticationSearchForm form) {
|
|
|
|
|
|
+ protected void searchPaging(final RenderData data, final SearchForm form) {
|
|
data.register("webAuthenticationItems", webAuthenticationService.getWebAuthenticationList(webAuthenticationPager)); // page navi
|
|
data.register("webAuthenticationItems", webAuthenticationService.getWebAuthenticationList(webAuthenticationPager)); // page navi
|
|
data.register("displayCreateLink", !webConfigService.getAllWebConfigList(false, false, false, null).isEmpty());
|
|
data.register("displayCreateLink", !webConfigService.getAllWebConfigList(false, false, false, null).isEmpty());
|
|
// restore from pager
|
|
// restore from pager
|
|
- copyBeanToBean(webAuthenticationPager, form.searchParams, op -> op.exclude(Constants.PAGER_CONVERSION_RULE));
|
|
|
|
|
|
+ copyBeanToBean(webAuthenticationPager, form, op -> op.include("id"));
|
|
}
|
|
}
|
|
|
|
|
|
// ===================================================================================
|
|
// ===================================================================================
|
|
@@ -126,10 +127,33 @@ public class AdminWebauthenticationAction extends FessAdminAction {
|
|
// ----------
|
|
// ----------
|
|
@Token(save = true, validate = false)
|
|
@Token(save = true, validate = false)
|
|
@Execute
|
|
@Execute
|
|
- public HtmlResponse createpage(final WebAuthenticationEditForm form) {
|
|
|
|
- form.initialize();
|
|
|
|
- form.crudMode = CrudMode.CREATE;
|
|
|
|
- return asHtml(path_AdminWebauthentication_EditJsp).renderWith(data -> {
|
|
|
|
|
|
+ public HtmlResponse createpage() {
|
|
|
|
+ return asHtml(path_AdminWebauthentication_EditJsp).useForm(CreateForm.class, op -> {
|
|
|
|
+ op.setup(form -> {
|
|
|
|
+ form.initialize();
|
|
|
|
+ form.crudMode = CrudMode.CREATE;
|
|
|
|
+ });
|
|
|
|
+ }).renderWith(data -> {
|
|
|
|
+ registerProtocolSchemeItems(data);
|
|
|
|
+ registerWebConfigItems(data);
|
|
|
|
+ });
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ @Token(save = true, validate = false)
|
|
|
|
+ @Execute
|
|
|
|
+ public HtmlResponse editpage(final int crudMode, final String id) {
|
|
|
|
+ return asHtml(path_AdminWebauthentication_EditJsp).useForm(EditForm.class, op -> {
|
|
|
|
+ op.setup(form -> {
|
|
|
|
+ webAuthenticationService.getWebAuthentication(id).ifPresent(entity -> {
|
|
|
|
+ copyBeanToBean(entity, form, copyOp -> {
|
|
|
|
+ copyOp.excludeNull();
|
|
|
|
+ });
|
|
|
|
+ }).orElse(() -> {
|
|
|
|
+ throwValidationError(messages -> messages.addErrorsCrudCouldNotFindCrudTable(GLOBAL, id), toEditHtml());
|
|
|
|
+ });
|
|
|
|
+ form.crudMode = crudMode;
|
|
|
|
+ });
|
|
|
|
+ }).renderWith(data -> {
|
|
registerProtocolSchemeItems(data);
|
|
registerProtocolSchemeItems(data);
|
|
registerWebConfigItems(data);
|
|
registerWebConfigItems(data);
|
|
});
|
|
});
|
|
@@ -137,11 +161,9 @@ public class AdminWebauthenticationAction extends FessAdminAction {
|
|
|
|
|
|
@Token(save = true, validate = false)
|
|
@Token(save = true, validate = false)
|
|
@Execute
|
|
@Execute
|
|
- public HtmlResponse editpage(final int crudMode, final String id, final WebAuthenticationEditForm form) {
|
|
|
|
- form.crudMode = crudMode;
|
|
|
|
- form.id = id;
|
|
|
|
- verifyCrudMode(form, CrudMode.EDIT);
|
|
|
|
- loadWebAuthentication(form);
|
|
|
|
|
|
+ public HtmlResponse createagain(final CreateForm form) {
|
|
|
|
+ verifyCrudMode(form.crudMode, CrudMode.CREATE);
|
|
|
|
+ validate(form, messages -> {}, toEditHtml());
|
|
return asHtml(path_AdminWebauthentication_EditJsp).renderWith(data -> {
|
|
return asHtml(path_AdminWebauthentication_EditJsp).renderWith(data -> {
|
|
registerProtocolSchemeItems(data);
|
|
registerProtocolSchemeItems(data);
|
|
registerWebConfigItems(data);
|
|
registerWebConfigItems(data);
|
|
@@ -150,7 +172,9 @@ public class AdminWebauthenticationAction extends FessAdminAction {
|
|
|
|
|
|
@Token(save = true, validate = false)
|
|
@Token(save = true, validate = false)
|
|
@Execute
|
|
@Execute
|
|
- public HtmlResponse editagain(final WebAuthenticationEditForm form) {
|
|
|
|
|
|
+ public HtmlResponse editagain(final EditForm form) {
|
|
|
|
+ verifyCrudMode(form.crudMode, CrudMode.EDIT);
|
|
|
|
+ validate(form, messages -> {}, toEditHtml());
|
|
return asHtml(path_AdminWebauthentication_EditJsp).renderWith(data -> {
|
|
return asHtml(path_AdminWebauthentication_EditJsp).renderWith(data -> {
|
|
registerProtocolSchemeItems(data);
|
|
registerProtocolSchemeItems(data);
|
|
registerWebConfigItems(data);
|
|
registerWebConfigItems(data);
|
|
@@ -159,9 +183,15 @@ public class AdminWebauthenticationAction extends FessAdminAction {
|
|
|
|
|
|
@Token(save = true, validate = false)
|
|
@Token(save = true, validate = false)
|
|
@Execute
|
|
@Execute
|
|
- public HtmlResponse editfromconfirm(final WebAuthenticationEditForm form) {
|
|
|
|
|
|
+ public HtmlResponse editfromconfirm(final EditForm form) {
|
|
|
|
+ validate(form, messages -> {}, toEditHtml());
|
|
form.crudMode = CrudMode.EDIT;
|
|
form.crudMode = CrudMode.EDIT;
|
|
- loadWebAuthentication(form);
|
|
|
|
|
|
+ String id = form.id;
|
|
|
|
+ webAuthenticationService.getWebAuthentication(id).ifPresent(entity -> {
|
|
|
|
+ copyBeanToBean(entity, form, op -> {});
|
|
|
|
+ }).orElse(() -> {
|
|
|
|
+ throwValidationError(messages -> messages.addErrorsCrudCouldNotFindCrudTable(GLOBAL, id), toEditHtml());
|
|
|
|
+ });
|
|
return asHtml(path_AdminWebauthentication_EditJsp).renderWith(data -> {
|
|
return asHtml(path_AdminWebauthentication_EditJsp).renderWith(data -> {
|
|
registerProtocolSchemeItems(data);
|
|
registerProtocolSchemeItems(data);
|
|
registerWebConfigItems(data);
|
|
registerWebConfigItems(data);
|
|
@@ -170,12 +200,20 @@ public class AdminWebauthenticationAction extends FessAdminAction {
|
|
|
|
|
|
@Token(save = true, validate = false)
|
|
@Token(save = true, validate = false)
|
|
@Execute
|
|
@Execute
|
|
- public HtmlResponse deletepage(final int crudMode, final String id, final WebAuthenticationEditForm form) {
|
|
|
|
- form.crudMode = crudMode;
|
|
|
|
- form.id = id;
|
|
|
|
- verifyCrudMode(form, CrudMode.DELETE);
|
|
|
|
- loadWebAuthentication(form);
|
|
|
|
- return asHtml(path_AdminWebauthentication_ConfirmJsp).renderWith(data -> {
|
|
|
|
|
|
+ public HtmlResponse deletepage(final int crudMode, final String id) {
|
|
|
|
+ verifyCrudMode(crudMode, CrudMode.DELETE);
|
|
|
|
+ return asHtml(path_AdminWebauthentication_ConfirmJsp).useForm(EditForm.class, op -> {
|
|
|
|
+ op.setup(form -> {
|
|
|
|
+ webAuthenticationService.getWebAuthentication(id).ifPresent(entity -> {
|
|
|
|
+ copyBeanToBean(entity, form, copyOp -> {
|
|
|
|
+ copyOp.excludeNull();
|
|
|
|
+ });
|
|
|
|
+ }).orElse(() -> {
|
|
|
|
+ throwValidationError(messages -> messages.addErrorsCrudCouldNotFindCrudTable(GLOBAL, id), toEditHtml());
|
|
|
|
+ });
|
|
|
|
+ form.crudMode = crudMode;
|
|
|
|
+ });
|
|
|
|
+ }).renderWith(data -> {
|
|
registerProtocolSchemeItems(data);
|
|
registerProtocolSchemeItems(data);
|
|
registerWebConfigItems(data);
|
|
registerWebConfigItems(data);
|
|
});
|
|
});
|
|
@@ -183,9 +221,15 @@ public class AdminWebauthenticationAction extends FessAdminAction {
|
|
|
|
|
|
@Token(save = true, validate = false)
|
|
@Token(save = true, validate = false)
|
|
@Execute
|
|
@Execute
|
|
- public HtmlResponse deletefromconfirm(final WebAuthenticationEditForm form) {
|
|
|
|
|
|
+ public HtmlResponse deletefromconfirm(final EditForm form) {
|
|
|
|
+ validate(form, messages -> {}, toEditHtml());
|
|
form.crudMode = CrudMode.DELETE;
|
|
form.crudMode = CrudMode.DELETE;
|
|
- loadWebAuthentication(form);
|
|
|
|
|
|
+ String id = form.id;
|
|
|
|
+ webAuthenticationService.getWebAuthentication(id).ifPresent(entity -> {
|
|
|
|
+ copyBeanToBean(entity, form, op -> {});
|
|
|
|
+ }).orElse(() -> {
|
|
|
|
+ throwValidationError(messages -> messages.addErrorsCrudCouldNotFindCrudTable(GLOBAL, id), toEditHtml());
|
|
|
|
+ });
|
|
return asHtml(path_AdminWebauthentication_ConfirmJsp).renderWith(data -> {
|
|
return asHtml(path_AdminWebauthentication_ConfirmJsp).renderWith(data -> {
|
|
registerProtocolSchemeItems(data);
|
|
registerProtocolSchemeItems(data);
|
|
registerWebConfigItems(data);
|
|
registerWebConfigItems(data);
|
|
@@ -196,12 +240,20 @@ public class AdminWebauthenticationAction extends FessAdminAction {
|
|
// Confirm
|
|
// Confirm
|
|
// -------
|
|
// -------
|
|
@Execute
|
|
@Execute
|
|
- public HtmlResponse confirmpage(final int crudMode, final String id, final WebAuthenticationEditForm form) {
|
|
|
|
- form.crudMode = crudMode;
|
|
|
|
- form.id = id;
|
|
|
|
- verifyCrudMode(form, CrudMode.CONFIRM);
|
|
|
|
- loadWebAuthentication(form);
|
|
|
|
- return asHtml(path_AdminWebauthentication_ConfirmJsp).renderWith(data -> {
|
|
|
|
|
|
+ public HtmlResponse confirmpage(final int crudMode, final String id) {
|
|
|
|
+ verifyCrudMode(crudMode, CrudMode.CONFIRM);
|
|
|
|
+ return asHtml(path_AdminWebauthentication_ConfirmJsp).useForm(EditForm.class, op -> {
|
|
|
|
+ op.setup(form -> {
|
|
|
|
+ webAuthenticationService.getWebAuthentication(id).ifPresent(entity -> {
|
|
|
|
+ copyBeanToBean(entity, form, copyOp -> {
|
|
|
|
+ copyOp.excludeNull();
|
|
|
|
+ });
|
|
|
|
+ form.crudMode = crudMode;
|
|
|
|
+ }).orElse(() -> {
|
|
|
|
+ throwValidationError(messages -> messages.addErrorsCrudCouldNotFindCrudTable(GLOBAL, id), toEditHtml());
|
|
|
|
+ });
|
|
|
|
+ });
|
|
|
|
+ }).renderWith(data -> {
|
|
registerProtocolSchemeItems(data);
|
|
registerProtocolSchemeItems(data);
|
|
registerWebConfigItems(data);
|
|
registerWebConfigItems(data);
|
|
});
|
|
});
|
|
@@ -209,8 +261,9 @@ public class AdminWebauthenticationAction extends FessAdminAction {
|
|
|
|
|
|
@Token(save = false, validate = true, keep = true)
|
|
@Token(save = false, validate = true, keep = true)
|
|
@Execute
|
|
@Execute
|
|
- public HtmlResponse confirmfromcreate(final WebAuthenticationEditForm form) {
|
|
|
|
|
|
+ public HtmlResponse confirmfromcreate(final CreateForm form) {
|
|
validate(form, messages -> {}, toEditHtml());
|
|
validate(form, messages -> {}, toEditHtml());
|
|
|
|
+ form.crudMode = CrudMode.CREATE;
|
|
return asHtml(path_AdminWebauthentication_ConfirmJsp).renderWith(data -> {
|
|
return asHtml(path_AdminWebauthentication_ConfirmJsp).renderWith(data -> {
|
|
registerProtocolSchemeItems(data);
|
|
registerProtocolSchemeItems(data);
|
|
registerWebConfigItems(data);
|
|
registerWebConfigItems(data);
|
|
@@ -219,8 +272,9 @@ public class AdminWebauthenticationAction extends FessAdminAction {
|
|
|
|
|
|
@Token(save = false, validate = true, keep = true)
|
|
@Token(save = false, validate = true, keep = true)
|
|
@Execute
|
|
@Execute
|
|
- public HtmlResponse confirmfromupdate(final WebAuthenticationEditForm form) {
|
|
|
|
|
|
+ public HtmlResponse confirmfromupdate(final EditForm form) {
|
|
validate(form, messages -> {}, toEditHtml());
|
|
validate(form, messages -> {}, toEditHtml());
|
|
|
|
+ form.crudMode = CrudMode.EDIT;
|
|
return asHtml(path_AdminWebauthentication_ConfirmJsp).renderWith(data -> {
|
|
return asHtml(path_AdminWebauthentication_ConfirmJsp).renderWith(data -> {
|
|
registerProtocolSchemeItems(data);
|
|
registerProtocolSchemeItems(data);
|
|
registerWebConfigItems(data);
|
|
registerWebConfigItems(data);
|
|
@@ -232,66 +286,78 @@ public class AdminWebauthenticationAction extends FessAdminAction {
|
|
// -------------
|
|
// -------------
|
|
@Token(save = false, validate = true)
|
|
@Token(save = false, validate = true)
|
|
@Execute
|
|
@Execute
|
|
- public HtmlResponse create(final WebAuthenticationEditForm form) {
|
|
|
|
|
|
+ public HtmlResponse create(final CreateForm form) {
|
|
|
|
+ verifyCrudMode(form.crudMode, CrudMode.CREATE);
|
|
validate(form, messages -> {}, toEditHtml());
|
|
validate(form, messages -> {}, toEditHtml());
|
|
- webAuthenticationService.store(createWebAuthentication(form));
|
|
|
|
- saveInfo(messages -> messages.addSuccessCrudCreateCrudTable(GLOBAL));
|
|
|
|
|
|
+ createWebAuthentication(form).ifPresent(entity -> {
|
|
|
|
+ copyBeanToBean(form, entity, op -> op.exclude(Constants.COMMON_CONVERSION_RULE));
|
|
|
|
+ webAuthenticationService.store(entity);
|
|
|
|
+ saveInfo(messages -> messages.addSuccessCrudCreateCrudTable(GLOBAL));
|
|
|
|
+ }).orElse(() -> {
|
|
|
|
+ throwValidationError(messages -> messages.addErrorsCrudFailedToCreateCrudTable(GLOBAL), toEditHtml());
|
|
|
|
+ });
|
|
return redirect(getClass());
|
|
return redirect(getClass());
|
|
}
|
|
}
|
|
|
|
|
|
@Token(save = false, validate = true)
|
|
@Token(save = false, validate = true)
|
|
@Execute
|
|
@Execute
|
|
- public HtmlResponse update(final WebAuthenticationEditForm form) {
|
|
|
|
|
|
+ public HtmlResponse update(final EditForm form) {
|
|
|
|
+ verifyCrudMode(form.crudMode, CrudMode.EDIT);
|
|
validate(form, messages -> {}, toEditHtml());
|
|
validate(form, messages -> {}, toEditHtml());
|
|
- webAuthenticationService.store(createWebAuthentication(form));
|
|
|
|
- saveInfo(messages -> messages.addSuccessCrudUpdateCrudTable(GLOBAL));
|
|
|
|
|
|
+ createWebAuthentication(form).ifPresent(entity -> {
|
|
|
|
+ copyBeanToBean(form, entity, op -> op.exclude(Constants.COMMON_CONVERSION_RULE));
|
|
|
|
+ webAuthenticationService.store(entity);
|
|
|
|
+ saveInfo(messages -> messages.addSuccessCrudUpdateCrudTable(GLOBAL));
|
|
|
|
+ }).orElse(() -> {
|
|
|
|
+ throwValidationError(messages -> messages.addErrorsCrudCouldNotFindCrudTable(GLOBAL, form.id), toEditHtml());
|
|
|
|
+ });
|
|
return redirect(getClass());
|
|
return redirect(getClass());
|
|
}
|
|
}
|
|
|
|
|
|
@Execute
|
|
@Execute
|
|
- public HtmlResponse delete(final WebAuthenticationEditForm form) {
|
|
|
|
- verifyCrudMode(form, CrudMode.DELETE);
|
|
|
|
- webAuthenticationService.delete(getWebAuthentication(form));
|
|
|
|
- saveInfo(messages -> messages.addSuccessCrudDeleteCrudTable(GLOBAL));
|
|
|
|
|
|
+ public HtmlResponse delete(final EditForm form) {
|
|
|
|
+ verifyCrudMode(form.crudMode, CrudMode.DELETE);
|
|
|
|
+ validate(form, messages -> {}, toEditHtml());
|
|
|
|
+ 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());
|
|
|
|
+ });
|
|
return redirect(getClass());
|
|
return redirect(getClass());
|
|
}
|
|
}
|
|
|
|
|
|
//===================================================================================
|
|
//===================================================================================
|
|
// Assist Logic
|
|
// Assist Logic
|
|
// ============
|
|
// ============
|
|
- protected void loadWebAuthentication(final WebAuthenticationEditForm form) {
|
|
|
|
- copyBeanToBean(getWebAuthentication(form), form, op -> op.exclude("crudMode"));
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- protected WebAuthentication getWebAuthentication(final WebAuthenticationEditForm form) {
|
|
|
|
- final WebAuthentication webAuthentication = webAuthenticationService.getWebAuthentication(createKeyMap(form));
|
|
|
|
- if (webAuthentication == null) {
|
|
|
|
- throwValidationError(messages -> messages.addErrorsCrudCouldNotFindCrudTable(GLOBAL, form.id), toEditHtml());
|
|
|
|
- }
|
|
|
|
- return webAuthentication;
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- protected WebAuthentication createWebAuthentication(final WebAuthenticationEditForm form) {
|
|
|
|
- WebAuthentication webAuthentication;
|
|
|
|
|
|
+ protected OptionalEntity<WebAuthentication> createWebAuthentication(final CreateForm form) {
|
|
final String username = systemHelper.getUsername();
|
|
final String username = systemHelper.getUsername();
|
|
final long currentTime = systemHelper.getCurrentTimeAsLong();
|
|
final long currentTime = systemHelper.getCurrentTimeAsLong();
|
|
- if (form.crudMode == CrudMode.EDIT) {
|
|
|
|
- webAuthentication = getWebAuthentication(form);
|
|
|
|
- } else {
|
|
|
|
- webAuthentication = new WebAuthentication();
|
|
|
|
- webAuthentication.setCreatedBy(username);
|
|
|
|
- webAuthentication.setCreatedTime(currentTime);
|
|
|
|
|
|
+ switch (form.crudMode) {
|
|
|
|
+ case CrudMode.CREATE:
|
|
|
|
+ if (form instanceof CreateForm) {
|
|
|
|
+ final WebAuthentication entity = new WebAuthentication();
|
|
|
|
+ entity.setCreatedBy(username);
|
|
|
|
+ entity.setCreatedTime(currentTime);
|
|
|
|
+ entity.setUpdatedBy(username);
|
|
|
|
+ entity.setUpdatedTime(currentTime);
|
|
|
|
+ return OptionalEntity.of(entity);
|
|
|
|
+ }
|
|
|
|
+ break;
|
|
|
|
+ case CrudMode.EDIT:
|
|
|
|
+ if (form instanceof EditForm) {
|
|
|
|
+ return webAuthenticationService.getWebAuthentication(((EditForm) form).id).map(entity -> {
|
|
|
|
+ entity.setUpdatedBy(username);
|
|
|
|
+ entity.setUpdatedTime(currentTime);
|
|
|
|
+ return entity;
|
|
|
|
+ });
|
|
|
|
+ }
|
|
|
|
+ break;
|
|
|
|
+ default:
|
|
|
|
+ break;
|
|
}
|
|
}
|
|
- webAuthentication.setUpdatedBy(username);
|
|
|
|
- webAuthentication.setUpdatedTime(currentTime);
|
|
|
|
- copyBeanToBean(form, webAuthentication, op -> op.exclude(Constants.COMMON_CONVERSION_RULE));
|
|
|
|
- return webAuthentication;
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- protected Map<String, String> createKeyMap(final WebAuthenticationEditForm form) {
|
|
|
|
- final Map<String, String> keys = new HashMap<String, String>();
|
|
|
|
- keys.put("id", form.id);
|
|
|
|
- return keys;
|
|
|
|
|
|
+ return OptionalEntity.empty();
|
|
}
|
|
}
|
|
|
|
|
|
protected void registerProtocolSchemeItems(final RenderData data) {
|
|
protected void registerProtocolSchemeItems(final RenderData data) {
|
|
@@ -325,10 +391,10 @@ public class AdminWebauthenticationAction extends FessAdminAction {
|
|
// ===================================================================================
|
|
// ===================================================================================
|
|
// Small Helper
|
|
// Small Helper
|
|
// ============
|
|
// ============
|
|
- protected void verifyCrudMode(final WebAuthenticationEditForm form, final int expectedMode) {
|
|
|
|
- if (form.crudMode != expectedMode) {
|
|
|
|
|
|
+ protected void verifyCrudMode(final int crudMode, final int expectedMode) {
|
|
|
|
+ if (crudMode != expectedMode) {
|
|
throwValidationError(messages -> {
|
|
throwValidationError(messages -> {
|
|
- messages.addErrorsCrudInvalidMode(GLOBAL, String.valueOf(expectedMode), String.valueOf(form.crudMode));
|
|
|
|
|
|
+ messages.addErrorsCrudInvalidMode(GLOBAL, String.valueOf(expectedMode), String.valueOf(crudMode));
|
|
}, toEditHtml());
|
|
}, toEditHtml());
|
|
}
|
|
}
|
|
}
|
|
}
|