|
@@ -16,20 +16,318 @@
|
|
|
|
|
|
package org.codelibs.fess.action.admin;
|
|
package org.codelibs.fess.action.admin;
|
|
|
|
|
|
|
|
+import java.util.HashMap;
|
|
|
|
+import java.util.List;
|
|
|
|
+import java.util.Map;
|
|
|
|
+
|
|
import javax.annotation.Resource;
|
|
import javax.annotation.Resource;
|
|
|
|
|
|
-import org.codelibs.fess.crud.action.admin.BsUserInfoAction;
|
|
|
|
|
|
+import org.codelibs.fess.Constants;
|
|
|
|
+import org.codelibs.fess.action.base.FessAdminAction;
|
|
|
|
+import org.codelibs.fess.crud.CommonConstants;
|
|
|
|
+import org.codelibs.fess.crud.CrudMessageException;
|
|
import org.codelibs.fess.crud.util.SAStrutsUtil;
|
|
import org.codelibs.fess.crud.util.SAStrutsUtil;
|
|
|
|
+import org.codelibs.fess.db.exentity.UserInfo;
|
|
|
|
+import org.codelibs.fess.form.admin.UserInfoForm;
|
|
import org.codelibs.fess.helper.SystemHelper;
|
|
import org.codelibs.fess.helper.SystemHelper;
|
|
|
|
+import org.codelibs.fess.pager.UserInfoPager;
|
|
|
|
+import org.codelibs.fess.service.UserInfoService;
|
|
|
|
+import org.codelibs.sastruts.core.annotation.Token;
|
|
|
|
+import org.seasar.framework.beans.util.Beans;
|
|
|
|
+import org.seasar.framework.util.StringUtil;
|
|
|
|
+import org.seasar.struts.annotation.ActionForm;
|
|
import org.seasar.struts.annotation.Execute;
|
|
import org.seasar.struts.annotation.Execute;
|
|
|
|
+import org.seasar.struts.exception.ActionMessagesException;
|
|
|
|
+import org.slf4j.Logger;
|
|
|
|
+import org.slf4j.LoggerFactory;
|
|
|
|
+
|
|
|
|
+public class UserInfoAction extends FessAdminAction {
|
|
|
|
+
|
|
|
|
+ private static final Logger logger = LoggerFactory.getLogger(UserInfoAction.class);
|
|
|
|
+
|
|
|
|
+ // for list
|
|
|
|
|
|
-public class UserInfoAction extends BsUserInfoAction {
|
|
|
|
|
|
+ public List<UserInfo> userInfoItems;
|
|
|
|
|
|
- private static final long serialVersionUID = 1L;
|
|
|
|
|
|
+ // for edit/confirm/delete
|
|
|
|
+
|
|
|
|
+ @ActionForm
|
|
|
|
+ @Resource
|
|
|
|
+ protected UserInfoForm userInfoForm;
|
|
|
|
+
|
|
|
|
+ @Resource
|
|
|
|
+ protected UserInfoService userInfoService;
|
|
|
|
+
|
|
|
|
+ @Resource
|
|
|
|
+ protected UserInfoPager userInfoPager;
|
|
|
|
|
|
@Resource
|
|
@Resource
|
|
protected SystemHelper systemHelper;
|
|
protected SystemHelper systemHelper;
|
|
|
|
|
|
|
|
+ protected String displayList(final boolean redirect) {
|
|
|
|
+ // page navi
|
|
|
|
+ userInfoItems = userInfoService.getUserInfoList(userInfoPager);
|
|
|
|
+
|
|
|
|
+ // restore from pager
|
|
|
|
+ Beans.copy(userInfoPager, userInfoForm.searchParams).excludes(CommonConstants.PAGER_CONVERSION_RULE)
|
|
|
|
+
|
|
|
|
+ .execute();
|
|
|
|
+
|
|
|
|
+ if (redirect) {
|
|
|
|
+ return "index?redirect=true";
|
|
|
|
+ } else {
|
|
|
|
+ return "index.jsp";
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ @Execute(validator = false, input = "error.jsp")
|
|
|
|
+ public String index() {
|
|
|
|
+ return displayList(false);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ @Execute(validator = false, input = "error.jsp", urlPattern = "list/{pageNumber}")
|
|
|
|
+ public String list() {
|
|
|
|
+ // page navi
|
|
|
|
+ if (StringUtil.isNotBlank(userInfoForm.pageNumber)) {
|
|
|
|
+ try {
|
|
|
|
+ userInfoPager.setCurrentPageNumber(Integer.parseInt(userInfoForm.pageNumber));
|
|
|
|
+ } catch (final NumberFormatException e) {
|
|
|
|
+ if (logger.isDebugEnabled()) {
|
|
|
|
+ logger.debug("Invalid value: " + userInfoForm.pageNumber, e);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ return displayList(false);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ @Execute(validator = false, input = "error.jsp")
|
|
|
|
+ public String search() {
|
|
|
|
+ Beans.copy(userInfoForm.searchParams, userInfoPager).excludes(CommonConstants.PAGER_CONVERSION_RULE)
|
|
|
|
+
|
|
|
|
+ .execute();
|
|
|
|
+
|
|
|
|
+ return displayList(false);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ @Execute(validator = false, input = "error.jsp")
|
|
|
|
+ public String reset() {
|
|
|
|
+ userInfoPager.clear();
|
|
|
|
+
|
|
|
|
+ return displayList(false);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ @Execute(validator = false, input = "error.jsp")
|
|
|
|
+ public String back() {
|
|
|
|
+ return displayList(false);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ @Token(save = true, validate = false)
|
|
|
|
+ @Execute(validator = false, input = "error.jsp")
|
|
|
|
+ public String editagain() {
|
|
|
|
+ return "edit.jsp";
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ @Execute(validator = false, input = "error.jsp", urlPattern = "confirmpage/{crudMode}/{id}")
|
|
|
|
+ public String confirmpage() {
|
|
|
|
+ if (userInfoForm.crudMode != CommonConstants.CONFIRM_MODE) {
|
|
|
|
+ throw new ActionMessagesException("errors.crud_invalid_mode", new Object[] { CommonConstants.CONFIRM_MODE,
|
|
|
|
+ userInfoForm.crudMode });
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ loadUserInfo();
|
|
|
|
+
|
|
|
|
+ return "confirm.jsp";
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ @Token(save = true, validate = false)
|
|
|
|
+ @Execute(validator = false, input = "error.jsp")
|
|
|
|
+ public String createpage() {
|
|
|
|
+ // page navi
|
|
|
|
+ userInfoForm.initialize();
|
|
|
|
+ userInfoForm.crudMode = CommonConstants.CREATE_MODE;
|
|
|
|
+
|
|
|
|
+ return "edit.jsp";
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ @Token(save = true, validate = false)
|
|
|
|
+ @Execute(validator = false, input = "error.jsp", urlPattern = "editpage/{crudMode}/{id}")
|
|
|
|
+ public String editpage() {
|
|
|
|
+ if (userInfoForm.crudMode != CommonConstants.EDIT_MODE) {
|
|
|
|
+ throw new ActionMessagesException("errors.crud_invalid_mode", new Object[] { CommonConstants.EDIT_MODE, userInfoForm.crudMode });
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ loadUserInfo();
|
|
|
|
+
|
|
|
|
+ return "edit.jsp";
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ @Token(save = true, validate = false)
|
|
|
|
+ @Execute(validator = false, input = "error.jsp")
|
|
|
|
+ public String editfromconfirm() {
|
|
|
|
+ userInfoForm.crudMode = CommonConstants.EDIT_MODE;
|
|
|
|
+
|
|
|
|
+ loadUserInfo();
|
|
|
|
+
|
|
|
|
+ return "edit.jsp";
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ @Token(save = false, validate = true, keep = true)
|
|
|
|
+ @Execute(validator = true, input = "edit.jsp")
|
|
|
|
+ public String confirmfromcreate() {
|
|
|
|
+ return "confirm.jsp";
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ @Token(save = false, validate = true, keep = true)
|
|
|
|
+ @Execute(validator = true, input = "edit.jsp")
|
|
|
|
+ public String confirmfromupdate() {
|
|
|
|
+ return "confirm.jsp";
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ @Token(save = true, validate = false)
|
|
|
|
+ @Execute(validator = false, input = "error.jsp", urlPattern = "deletepage/{crudMode}/{id}")
|
|
|
|
+ public String deletepage() {
|
|
|
|
+ if (userInfoForm.crudMode != CommonConstants.DELETE_MODE) {
|
|
|
|
+ throw new ActionMessagesException("errors.crud_invalid_mode",
|
|
|
|
+ new Object[] { CommonConstants.DELETE_MODE, userInfoForm.crudMode });
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ loadUserInfo();
|
|
|
|
+
|
|
|
|
+ return "confirm.jsp";
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ @Token(save = true, validate = false)
|
|
|
|
+ @Execute(validator = false, input = "error.jsp")
|
|
|
|
+ public String deletefromconfirm() {
|
|
|
|
+ userInfoForm.crudMode = CommonConstants.DELETE_MODE;
|
|
|
|
+
|
|
|
|
+ loadUserInfo();
|
|
|
|
+
|
|
|
|
+ return "confirm.jsp";
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ @Token(save = false, validate = true)
|
|
|
|
+ @Execute(validator = true, input = "edit.jsp")
|
|
|
|
+ public String create() {
|
|
|
|
+ try {
|
|
|
|
+ final UserInfo userInfo = createUserInfo();
|
|
|
|
+ userInfoService.store(userInfo);
|
|
|
|
+ SAStrutsUtil.addSessionMessage("success.crud_create_crud_table");
|
|
|
|
+
|
|
|
|
+ return displayList(true);
|
|
|
|
+ } catch (final ActionMessagesException e) {
|
|
|
|
+ logger.error(e.getMessage(), e);
|
|
|
|
+ throw e;
|
|
|
|
+ } catch (final CrudMessageException e) {
|
|
|
|
+ logger.error(e.getMessage(), e);
|
|
|
|
+ throw new ActionMessagesException(e.getMessageId(), e.getArgs());
|
|
|
|
+ } catch (final Exception e) {
|
|
|
|
+ logger.error(e.getMessage(), e);
|
|
|
|
+ throw new ActionMessagesException("errors.crud_failed_to_create_crud_table");
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ @Token(save = false, validate = true)
|
|
|
|
+ @Execute(validator = true, input = "edit.jsp")
|
|
|
|
+ public String update() {
|
|
|
|
+ try {
|
|
|
|
+ final UserInfo userInfo = createUserInfo();
|
|
|
|
+ userInfoService.store(userInfo);
|
|
|
|
+ SAStrutsUtil.addSessionMessage("success.crud_update_crud_table");
|
|
|
|
+
|
|
|
|
+ return displayList(true);
|
|
|
|
+ } catch (final ActionMessagesException e) {
|
|
|
|
+ logger.error(e.getMessage(), e);
|
|
|
|
+ throw e;
|
|
|
|
+ } catch (final CrudMessageException e) {
|
|
|
|
+ logger.error(e.getMessage(), e);
|
|
|
|
+ throw new ActionMessagesException(e.getMessageId(), e.getArgs());
|
|
|
|
+ } catch (final Exception e) {
|
|
|
|
+ logger.error(e.getMessage(), e);
|
|
|
|
+ throw new ActionMessagesException("errors.crud_failed_to_update_crud_table");
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ @Token(save = false, validate = true)
|
|
|
|
+ @Execute(validator = false, input = "error.jsp")
|
|
|
|
+ public String delete() {
|
|
|
|
+ if (userInfoForm.crudMode != CommonConstants.DELETE_MODE) {
|
|
|
|
+ throw new ActionMessagesException("errors.crud_invalid_mode",
|
|
|
|
+ new Object[] { CommonConstants.DELETE_MODE, userInfoForm.crudMode });
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ try {
|
|
|
|
+ final UserInfo userInfo = userInfoService.getUserInfo(createKeyMap());
|
|
|
|
+ if (userInfo == null) {
|
|
|
|
+ // throw an exception
|
|
|
|
+ throw new ActionMessagesException("errors.crud_could_not_find_crud_table",
|
|
|
|
+
|
|
|
|
+ new Object[] { userInfoForm.id });
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ userInfoService.delete(userInfo);
|
|
|
|
+ SAStrutsUtil.addSessionMessage("success.crud_delete_crud_table");
|
|
|
|
+
|
|
|
|
+ return displayList(true);
|
|
|
|
+ } catch (final ActionMessagesException e) {
|
|
|
|
+ logger.error(e.getMessage(), e);
|
|
|
|
+ throw e;
|
|
|
|
+ } catch (final CrudMessageException e) {
|
|
|
|
+ logger.error(e.getMessage(), e);
|
|
|
|
+ throw new ActionMessagesException(e.getMessageId(), e.getArgs());
|
|
|
|
+ } catch (final Exception e) {
|
|
|
|
+ logger.error(e.getMessage(), e);
|
|
|
|
+ throw new ActionMessagesException("errors.crud_failed_to_delete_crud_table");
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ protected void loadUserInfo() {
|
|
|
|
+
|
|
|
|
+ final UserInfo userInfo = userInfoService.getUserInfo(createKeyMap());
|
|
|
|
+ if (userInfo == null) {
|
|
|
|
+ // throw an exception
|
|
|
|
+ throw new ActionMessagesException("errors.crud_could_not_find_crud_table",
|
|
|
|
+
|
|
|
|
+ new Object[] { userInfoForm.id });
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ Beans.copy(userInfo, userInfoForm).excludes("searchParams", "mode")
|
|
|
|
+
|
|
|
|
+ .timestampConverter(Constants.DEFAULT_DATETIME_FORMAT, "createdTime", "updatedTime").execute();
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ protected UserInfo createUserInfo() {
|
|
|
|
+ UserInfo userInfo;
|
|
|
|
+ if (userInfoForm.crudMode == CommonConstants.EDIT_MODE) {
|
|
|
|
+ userInfo = userInfoService.getUserInfo(createKeyMap());
|
|
|
|
+ if (userInfo == null) {
|
|
|
|
+ // throw an exception
|
|
|
|
+ throw new ActionMessagesException("errors.crud_could_not_find_crud_table",
|
|
|
|
+
|
|
|
|
+ new Object[] { userInfoForm.id });
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+ } else {
|
|
|
|
+ userInfo = new UserInfo();
|
|
|
|
+ }
|
|
|
|
+ Beans.copy(userInfoForm, userInfo).excludes("searchParams", "mode")
|
|
|
|
+
|
|
|
|
+ .timestampConverter(Constants.DEFAULT_DATETIME_FORMAT, "createdTime", "updatedTime").execute();
|
|
|
|
+
|
|
|
|
+ return userInfo;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ protected Map<String, String> createKeyMap() {
|
|
|
|
+ final Map<String, String> keys = new HashMap<String, String>();
|
|
|
|
+
|
|
|
|
+ keys.put("id", userInfoForm.id);
|
|
|
|
+
|
|
|
|
+ return keys;
|
|
|
|
+ }
|
|
|
|
+
|
|
public String getHelpLink() {
|
|
public String getHelpLink() {
|
|
return systemHelper.getHelpLink("userInfo");
|
|
return systemHelper.getHelpLink("userInfo");
|
|
}
|
|
}
|