/*
̃t@C̒ǵANTT I[v\[XCZX@o[W 1.0iu{
_vƂj̓Kp󂯂܂B
{_炵ȂÃt@CgpĂ͂Ȃ܂B
{_̃Rs[́Âtqkł܂B
yzzTCgURLz http://www.oss.ecl.ntt.co.jp/lms/

{_ɊÂЕz\tgEFÁÂ܂܁Âَ͖
ނ̕ۏ؂ȂŁAЕz܂B{_ɊÂyѐ𗥂
̕ɂẮA{_QƂĂB

uIWiR[hv́A NTT Cyber Space Laboratories Code łB 
uIWiR[hv́uJҁv́A{dMdbЂłB  
{dMdbЂɂn삳ꂽ́ACopyright (C) 2004 
{dMdb łB
SĂ̌ۂ܂B 
uRgr[^vF_____________________________________ 


The contents of this file are subject to the NTT Opensource License
Version 1.0 (the License); you may not use this file except in
compliance with the License. You may obtain a copy of the License at
yzzTCgURLz http://www.oss.ecl.ntt.co.jp/lms/

Software distributed under the License is distributed on an AS IS
basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
License for the specific language governing rights and limitations
under the License.

The Original Code is NTT Cyber Space Laboratories Code .

The Initial Developer of the Original Code is NIPPON TELEGRAPH AND 
TELEPHONE CORPORATION.
Portions created by the NIPPON TELEGRAPH AND TELEPHONE CORPORATION 
are Copyright (C) 2004 NIPPON TELEGRAPH AND TELEPHONE CORPORATION. 
All Rights Reserved.

Contributor(s) ______________________________________.
*/

//
// [Uo^@͉ʕ\rWlXAction
// 
// 
//
//	ύX
//	2004.01.08  VK쐬 M.Seko
//

package jp.co.ntt.lms.xms.people;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;
import jp.co.ntt.lms.xmo.Mail.MailConst;
import jp.co.ntt.lms.xms.common.util.CommonUtil;
import jp.co.ntt.lms.xms.framework.XmsBusinessAction;
import jp.co.ntt.lms.xms.framework.XmsException;
import jp.co.ntt.lms.xms.framework.XmsInnerException;
import jp.co.ntt.lms.xms.framework.XmsRequest;
import jp.co.ntt.lms.xms.framework.XmsResponse;
import jp.co.ntt.lms.xms.framework.XmsSystemException;

/**
 * [UXV@͉ʕ\rWlXActionB<br>
 * j[烆[UXVIۂɁA
 * ʕ\s߂ɎgpB
 * 
 *  @author M.Seko
 */
public class PeopleUpdateInputFramesetDisplayBusinessAction extends XmsBusinessAction {

	/**
	 * @see jp.co.ntt.lms.xms.framework.XmsBusinessAction#initProcessRequest(XmsRequest)
	 */
	protected void initProcessRequest(XmsRequest xmsRequest) throws XmsException {
		//ZbVL[ǗNX̃CX^XɃZbVɑ݂Ă΁A
		//ZbV̏폜B

		// HTTPZbV擾p
		HttpServletRequest request = null;
		// HTTPZbV
		HttpSession session = null;
		//ZbVL[ێNX̃ZbV̎擾sp
		SKeyKeep skeyKeep = null;
		try {
			request = xmsRequest.getRequest();
			session = request.getSession(false);
			if (session == null) {
				//sessionłꍇAsłȂ̂ŗOf
				throw new XmsSystemException("This session is invalid.");
			}

			skeyKeep = (SKeyKeep) session.getAttribute(PeopleConst.SKeyKeepSessionKey);

			if (skeyKeep != null) {
				//ZbVL[ێNXɃZbVɑ݂ĂB
				//āAZbVL[ێNXێĂZbVL[ɌтĂf[^폜
				CommonUtil.removeSessionData(xmsRequest, skeyKeep.getSkeyStringArray());
			}

			//̉ʂւ̕AɕKvȏZbVɊi[B
			PeopleUpdateComebackInfoBean peopleUpdateComeBackInfoBean = null;
			peopleUpdateComeBackInfoBean = new PeopleUpdateComebackInfoBean();
			peopleUpdateComeBackInfoBean.setReturnURL(request.getParameter("returnURL"));
			session.setAttribute(PeopleConst.ComebackInfoSessionKey, peopleUpdateComeBackInfoBean);
		} catch (XmsException e) {
			throw e;
		} catch (Exception e) {
			throw new XmsInnerException(e);
		}

	}

	/**
	 * [̎gp\Es\ɉďU蕪B<br>
	 * ܂Aform͂郆[U̓ei[ꂽZbVNAɂB<br>
	 * @see jp.co.ntt.lms.xms.framework.XmsBusinessAction#processRequest(XmsRequest, XmsResponse)
	 */
	protected void processRequest(XmsRequest xmsRequest, XmsResponse xmsResponse)
		throws XmsException {
		// HTTPZbV擾p
		HttpServletRequest request = null;
		// HTTPZbV
		HttpSession session = null;

		try {
			request = xmsRequest.getRequest();
			session = request.getSession(false);
			if (session == null) {
				//sessionłꍇAsłȂ̂ŗOf
				throw new XmsSystemException("This session is invalid.");
			}

			if (CommonUtil.checkMailAuthority(xmsRequest) == true) {
				//OC[ÚA[gp\ł
				//[ev[gt̉ʂ\Xe[^XZbg
				xmsResponse.setBusinessStatus("mailAuthorityOK");

				//[ʏZbVɓo^
				session.setAttribute("XMM_MT_MailType", MailConst.TYPE_REGIST);

			} else {
				//OC[ÚA[gps\łB
				//[ev[g̉ʂ\Xe[^XZbg
				xmsResponse.setBusinessStatus("mailAuthorityNG");

			}

			//ZbVL[ێNX̃ZbV̎擾syсAZbVւ̓o^p
			SKeyKeep skeyKeep = null;

			skeyKeep = (SKeyKeep) session.getAttribute(PeopleConst.SKeyKeepSessionKey);
			if (skeyKeep == null) {
				//܂AZbVL[ێNX̃CX^XZbVɑ݂ĂȂ
				//Vɐ
				skeyKeep = new SKeyKeep();
			}
			//ZbVL[ێNX̃CX^XZbVɓo^
			session.setAttribute(PeopleConst.SKeyKeepSessionKey, skeyKeep);
		} catch (XmsException e) {
			throw e;
		} catch (Exception e) {
			throw new XmsInnerException(e);
		}

	}

}
