AdminRegistAction.java 2.4 KB
Newer Older
Kim Gyeongeun committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81
package jp.agentec.sinaburocast.action.admin.setting;

import jp.agentec.sinaburocast.action.AbstractAction;
import jp.agentec.sinaburocast.common.util.SinaburoViewUtil;
import jp.agentec.sinaburocast.entity.AdminUser;
import jp.agentec.sinaburocast.form.admin.setting.AdminRegistForm;
import jp.agentec.sinaburocast.service.AdminUserService;

import org.apache.log4j.Logger;
import org.apache.struts.util.TokenProcessor;
import org.seasar.framework.util.StringUtil;
import org.seasar.struts.annotation.ActionForm;
import org.seasar.struts.annotation.Execute;

/**
 * 管理者登録処理
 *
 * @author choi-c
 *
 */
public class AdminRegistAction extends AbstractAction {

	private final Logger logger = Logger.getLogger(getClass());

	@ActionForm
	public AdminRegistForm adminRegistForm;


	public AdminUserService adminUserService;

	/**
	 * 初期表示
	 */
	@Execute(validator = false)
	public String index() {
		//ログインユーザーだけ表示できる。
		if(StringUtil.isNotBlank(adminLoginCheck(super.adminLoginCheckPath))){
			return super.adminLoginCheckPath;
		}
		//修正の場合
		if(StringUtil.isNotBlank(adminRegistForm.adminUserId )){
			adminRegistForm.updateFlag="update";	
		}
		return "/admin/setting/adminRegist.html";
	}

	@Execute(validator = true,input="/admin/setting/adminRegist.html")
	public String confirm() {
		TokenProcessor.getInstance().saveToken(request);

		//新規登録の場合のみ
		AdminUser adminUserList = adminUserService.findByLoginId(adminRegistForm.loginId);
		if(adminUserList != null && !adminRegistForm.clickedLoginId.equals(adminUserList.loginId)){
			addErrorMessage("repetLoginId", "adminRegist.repetLoginId");
			return "/admin/setting/adminRegist.html";
		}

		session.setAttribute("adminRegistForm", adminRegistForm);

		return "/admin/setting/adminRegistConfirm.html";
	}

	@Execute(validator = false)
	public String regist() {
		adminRegistForm = (AdminRegistForm)session.getAttribute("adminRegistForm");
		if (!TokenProcessor.getInstance().isTokenValid(request, true)) {
			addError(SinaburoViewUtil.getMessage("errors.S999"));
			return "/error/admin/doubleAction.html";
		}
		adminUserService.registOrUpdateAdminUser(adminRegistForm,getAdmin());
		return "/admin/setting/adminRegistEnd.html";
	}

	@Execute(validator = false)
	public String back() {
		adminRegistForm = (AdminRegistForm)session.getAttribute("adminRegistForm");
		return "/admin/setting/adminRegist.html";
	}


}