/*********************************************************************
* All Rights reserved,Copyright (c) K-Opticom
**********************************************************************
*＜プログラム内容＞
*   システム名      ：eo顧客基幹システム
*	モジュール名	：JCCRequestProcessLogic
*	ソースファイル名：JCCRequestProcessLogic.java
*	作成者			：富士通
*	日付			：
*＜機能概要＞
*	リクエスト前処理・後処理クラス
*＜修正履歴＞
*	バージョン	修正日		修正者		修正内容
*
**********************************************************************/

package eo.web.webview.common;

import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.util.ArrayList;
import java.util.HashMap;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;

import com.fujitsu.futurity.model.common.JCMAPLConstMgr;
import com.fujitsu.futurity.web.x00.JCCBusinessException;
import com.fujitsu.futurity.web.x31.X31BRequestProcessBase;
import com.fujitsu.futurity.web.x31.X31CHashMap;
import com.fujitsu.futurity.web.x31.X31CMessageResult;
import com.fujitsu.futurity.web.x31.X31CWebConst;
import com.fujitsu.futurity.web.x31.X31SDataBeanAccess;
import com.fujitsu.futurity.web.x31.X31SDataBeanAccessArray;
import com.fujitsu.futurity.web.x31.X31SSession;
import com.fujitsu.futurity.web.x31.X31SSessionManager;
import com.fujitsu.futurity.web.x33.DispatchContext;
import com.fujitsu.futurity.web.x33.HttpDispatchContext;
import com.fujitsu.futurity.web.x33.X33CUtil;
import com.fujitsu.futurity.web.x33.X33SDataBeanAccessWrapper;
import com.fujitsu.futurity.web.x33.X33SException;
import com.fujitsu.futurity.web.x33.beans.X33VDataTypeList;
import com.fujitsu.futurity.web.x33.beans.X33VViewBaseBean;
import com.fujitsu.futurity.web.x33.beans.X33VViewJSPBean;

import eo.common.util.JCCFrameworkException;
import eo.web.webview.CommonInfoCF.CommonInfoCFBean;
import eo.web.webview.CommonInfoCF.CommonInfoCFConst;

public class JCCRequestProcessLogic extends X31BRequestProcessBase{

	@Override
	public void preprocess(DispatchContext context){
		// 20121220 定期リクエストは初期処理をしない fst)yanagihara start
		if(isKeepAliveEvent(context))
		{
			return;
		}
		// 20121220 定期リクエストは初期処理をしない fst)yanagihara end
		
		// オンライン起動チェックを行います
		// @ オンライン起動チェック有無
		String onlineCheckUm = JCMAPLConstMgr.getString("ONLINE_CHECK");
		
		if(onlineCheckUm == null || "".equals(onlineCheckUm))
		{
			throw new JCCFrameworkException("オンライン起動チェック有無（キー：ONLINE_CHECK）が" +
			"アプリケーションプロパティファイル（AplConst）にて設定されていません。");
		}
		
		// オンライン起動チェック有無が「1(起動チェック有)」の場合、ターゲットシステムの取得を行う
		if("1".equals(onlineCheckUm))
		{
			// バックヤードの場合のみ、Webブラウザーおよび多重ログインチェックを行う。
			// アプリケーションプロパティファイルからターゲットシステムを取得する
			String targetSystem = JCMAPLConstMgr.getString("TARGET_SYSTEM");
			// ターゲットシステム存在チェック
			if(targetSystem == null || "".equals(targetSystem))
			{
				throw new JCCFrameworkException("ターゲットシステム（キー：TARGET_SYSTEM）が" +
				"アプリケーションプロパティファイル（AplConst）にて設定されていません。");
			}
			// バックヤードの場合のみチェックを行う
			if("BACKYARD".equals(targetSystem))
			{
				// A Webブラウザーチェック
				if(!webBrowserCheck(context))
				{
					// オンライン起動チェックエラーメッセージIDを付与
					setOnlineCheckMessageId(context, "EKB6250-CE");
					return;
				}
				// B 多重ログイン判定
				if(!multiLoginCheck(context))
				{
					// オンライン起動チェックエラーメッセージIDを付与
					setOnlineCheckMessageId(context, "EKB6260-CE");
					return;
				}
			}
		}
		
		try {
			// JS格納先のリアルパスを取得する。
			String realPath = context.getSessionProfile().getSession().getServletContext().getRealPath("/js/");
			// JCCMessageCacheへのリアルパスの設定
			JCCMessageCache.setJsPath(realPath);
			
			// メッセージ定義ファイルをHashMapに保存する。
			JCCMessageCache.setMessageCache();
			HttpSession session = context.getSessionProfile().getSession();
			// メッセージのHsahMapをつめる
			session.getServletContext().setAttribute("message", JCCMessageCache.getMessageMap());
			
			// JSPビーンを取得
			X33VViewJSPBean jspbean = (X33VViewJSPBean)context.getRequestBean();
			X33VDataTypeList dataTypeList = jspbean.getCommonInfo();
			
			// 共有フォームビーンをサーチ
			for(int i = 0 ; i < dataTypeList.getSize(); i++)
			{
				if(dataTypeList.getElementAt(i) instanceof CommonInfoCFBean)
				{
					// 共有フォームビーンのリクエストフラグに１を立てる
					Object obj = dataTypeList.getElementAt(i);
					X33VViewBaseBean dataBean = (X33VViewBaseBean)obj;				
					X33SDataBeanAccessWrapper.execDataBeanAccess(null, dataBean, CommonInfoCFConst.MESSAGES_LIST, 
							X33SDataBeanAccessWrapper.REQ_CLEAR, X33SDataBeanAccessWrapper.SUBKEY_VALUE, null);
					X33SDataBeanAccessWrapper.execDataBeanAccess(null, dataBean, "強調フラグ", 
							X33SDataBeanAccessWrapper.REQ_SET_VALUE, X33SDataBeanAccessWrapper.SUBKEY_VALUE, "0");
					
// 2012/07/04 FST)arata イベント対象画面IDおよび画面名を共有フォームビーンに格納する start
					// 画面ID
					String gamenId = ((HttpDispatchContext)context).getParameters().getSingleValue("uji.id");
					// 画面IDがnullの場合は何も行わない
					if(gamenId != null)
					{
						// 遷移先画面IDはuji.idから"0PJP"を削除したID
						String defaultGamenId = gamenId.replaceAll("0PJP", "");
						// 遷移先画面IDを設定
						X33SDataBeanAccessWrapper.execDataBeanAccess(null, dataBean, "遷移先画面ＩＤ", 
								X33SDataBeanAccessWrapper.REQ_SET_VALUE, X33SDataBeanAccessWrapper.SUBKEY_VALUE, defaultGamenId);
						
						// 画面IDに紐づく画面名を取得
						X31CHashMap sessionScreenInfoMap = getSessionObject("sessionScreenInfo");
						if(sessionScreenInfoMap != null){
							HashMap<String, String> readMap = (HashMap<String, String>)sessionScreenInfoMap.get(true);
							String screenNm = readMap.get(defaultGamenId);
							
							if(screenNm != null){
								// 遷移先画面名を設定
								X33SDataBeanAccessWrapper.execDataBeanAccess(null, dataBean, "遷移先画面名", 
										X33SDataBeanAccessWrapper.REQ_SET_VALUE, X33SDataBeanAccessWrapper.SUBKEY_VALUE, screenNm);
							}
						}
					}
// 2012/07/04 FST)arata イベント対象画面IDおよび画面名を共有フォームビーンに格納する end
					break;
				}
			}
		}
		catch(Exception e)
		{
			JCCFrameworkException fe = new JCCFrameworkException();
			fe.initCause(e);
			throw fe;
		}
		
		// メニュー配下の画面情報(画面情報、戻り先画面ID情報、ページリンク情報)を削除する。
		clearScreenInfo(context);
		
		// ページリンクによるリクエストの場合、紐付くページリンク情報を書き換える。
		setPageLinkParameter(context);
		
		// リクエストフラグを立てる
		setReqestFlg(context); 
		
		/*++++++++++ 2011/8/3 追加開始 ++++++++++*/
		if ("FRONT".equals(JCCWebCommon.getApplicationConst("TARGET_SYSTEM")))
		{
			
			try
			{
				Class<?> cls = Class.forName("eo.web.webview.common.JCCFrontRequestFilter");
				Method method = cls.getMethod("filter", DispatchContext.class, X31SDataBeanAccess.class);
				method.invoke(cls, context, getCommonInfoBean());
			} catch (JCCBusinessException e)
			{
				throw e;
			} catch (JCCFrameworkException e)
			{
				throw e;
			} catch (InvocationTargetException ie)
			{
				if (ie.getTargetException() instanceof JCCBusinessException)
				{
					throw (JCCBusinessException)ie.getTargetException();
				} else if (ie.getTargetException() instanceof JCCFrameworkException)
				{
					throw (JCCFrameworkException)ie.getTargetException();
				}
				
				JCCFrameworkException fe = new JCCFrameworkException();
				fe.initCause(ie);
				throw fe;
			} catch (Exception e)
			{
				JCCFrameworkException fe = new JCCFrameworkException();
				fe.initCause(e);
				throw fe;
			}
		}
		/*++++++++++ 2011/8/3 追加開始 ++++++++++*/
	}

	@Override
	public void postprocess(DispatchContext context) {

// 2012/09/25 FST)arata ユーザーIDをセッションに保持 start
		HttpSession session = context.getSessionProfile().getSession();
		String targetSystem = JCMAPLConstMgr.getString("TARGET_SYSTEM");
		String operatorId = "";
		if("BACKYARD".equals(targetSystem))
		{
			//オペレータIDをセット
			X31SDataBeanAccess bean = getCommonInfoBean();
			operatorId = bean.sendMessageString("ユーザーＩＤ", X31CWebConst.DATABEAN_GET_VALUE);
		}
		else if("RYOHAN".equals(targetSystem))
		{
			// オペレータIDをセット
			X31SDataBeanAccess bean = getCommonInfoBean();
			// 共有フォームBeanからＷＥＢ新規情報を取得する。
			X31SDataBeanAccessArray webNewInfo = bean.getDataBeanArray("ＷＥＢ新規情報");
			// ＷＥＢ新規情報からその他情報を取得する。
			X31SDataBeanAccessArray sonota = webNewInfo.getDataBean(0).getDataBeanArray("その他情報");
			// 担当者ＩＤを追加する。
			X31SDataBeanAccess commonSubbean = sonota.getDataBean(0);
			if(commonSubbean != null)
			{
				operatorId = commonSubbean.sendMessageString("担当者ＩＤ", X31CWebConst.DATABEAN_GET_VALUE);
			}
		}
		session.setAttribute("sessionOperatorID", operatorId);
// 2012/09/25 FST)arata ユーザーIDをセッションに保持 end

	}
	
	/**
	 * 画面ID_表番号で紐付くページリンク情報に表示ページ番号を設定します。
	 * 
	 * @param selectedTableIndex ページリンクで押下された表番号
	 * @param selectedPageNum ページリンクで押下された表示ページ番号
	 * @throws X33SException 
	 */
	private void setPageLinkParameter( DispatchContext context ) throws X33SException {
		
		// ページリンクによるリクエストかどうか判定する。
		Object pageLinkFlg = context.getSessionProfile().getServletRequest().getParameter("page_link_flg");
		if ( pageLinkFlg != null && pageLinkFlg.toString().equals("true") ) {
			// セッションID取得
			String sessionId = context.getSessionProfile().getSessionId();
			
			// セッション取得
			HttpSession session = X33CUtil.getSession( sessionId ).getSession();
			
			// セッションからページリンク情報格納Mapを取得
			HashMap pageLinkInfoBaseMap = (HashMap)session.getAttribute("pageLinkInfo");
			
			// ページリンク情報格納Mapが取得できない場合は、何もしない。
			if ( pageLinkInfoBaseMap == null ) {
				return;
			}
			
			// 画面ID
			String gamenId = context.getSessionProfile().getServletRequest().getParameter("uji.id");
			
			// 押された表番号
			String selectedTableIndex = context.getSessionProfile().getServletRequest().getParameter("selected_table_index");
			
			// 押されたページ番号
			String selectedPageNum = context.getSessionProfile().getServletRequest().getParameter("selected_page_num");
			
			// ページリンク情報オブジェクトのキーを生成。
			// キー：画面ID_表番号
			StringBuffer keyBuf = new StringBuffer();
			keyBuf.append( gamenId );
			keyBuf.append("_");
			keyBuf.append( selectedTableIndex );
			
			// メニューID取得
			String menuid = null;
			// メニューからの遷移の場合は、メニューIDはuji.verb
			if ( checkScreenIdFromMenu(context) ) {
				// 20121220 メニューIDの取得先変更（戻るボタンが効かない障害の対応） fst)yanagihara start
				menuid = context.getSessionProfile().getServletRequest().getParameter(JCCWebCommon.MENUID_PARAM_NAME);
				//menuid = context.getSessionProfile().getServletRequest().getParameter("uji.verb");
				// 20121220 メニューIDの取得先変更（戻るボタンが効かない障害の対応） fst)yanagihara end
			} else {
				
				// メニュー以外からの遷移の場合は、menuid_systemパラメータで持ちまわる。
				menuid = context.getSessionProfile().getServletRequest().getParameter("menuid_system");
			}
			
			// アプリケーションプロパティファイルから、プロジェクト種別を取得
			String projectType = JCMAPLConstMgr.getString("TARGET_SYSTEM");
			
			// 表示ページ番号を書きかえるMAP
			HashMap targetPageLinkInfoMap = null;
			// バックヤードで、かつメニューIDが取得できる場合は、メニュー配下となる。
			if (projectType != null && menuid != null && projectType.equals("BACKYARD")) {
				HashMap menuIdMap = (HashMap) pageLinkInfoBaseMap.get(menuid);
				if (menuIdMap == null) {
					return;
				}
				
				// キー：画面ID_表番号で紐付くページリンク情報をメニューIDMAPから取得する。
				targetPageLinkInfoMap = (HashMap) menuIdMap.get( keyBuf.toString() );
			} else {
				// キー：画面ID_表番号で紐付くページリンク情報をページリンクMAPから取得する。
				targetPageLinkInfoMap = (HashMap) pageLinkInfoBaseMap.get( keyBuf.toString() );
			}
			
			if ( targetPageLinkInfoMap == null ) {
				return;
			}
			
			// ページリンク情報オブジェクトの表示ページ番号をリクエストの値に書き換える。
			targetPageLinkInfoMap.put("display_page_num", selectedPageNum);			
			
		}
	}
	
	/**
	 * Webブラウザーチェックを行います。
	 * 
	 * @param context ディスパッチコンテキスト
	 * @return チェック結果（true:利用可能、false:利用不可）
	 */
	private boolean webBrowserCheck(DispatchContext context)
	{
		// アプリケーションプロパティファイルから利用可能なWebブラウザーを取得する。
		String userAgentList = JCMAPLConstMgr.getString("ACCESSIBLE_BROWSER");
		// 利用可能なWebブラウザー存在チェック
		if(userAgentList == null || "".equals(userAgentList))
		{
			throw new JCCFrameworkException("利用可能なWebブラウザー（キー：ACCESSIBLE_BROWSER）が" +
			"アプリケーションプロパティファイル（AplConst）にて設定されていません。");
		}
		// カンマ区切りで利用可能なWebブラウザーの取得
		String[] valueList = userAgentList.split(",");
		// HTTPサーブレットリクエストより、USER_AGENTの取得を行う
		HttpServletRequest req = ((HttpDispatchContext)context).getServletRequest();
		String userAgent = req.getHeader("user-agent");
		// 許可されているWEBブラウザの場合はフラグを設定
		for (int j = 0; j < valueList.length; j++)
		{
			// ブランクの場合は、continueする。
			if("".equals(valueList[j]))
			{
				continue;
			}
			
			// 大文字に変換し、比較。valueListの文字が含まれていればtrue
			if (userAgent.toUpperCase().indexOf(valueList[j].toUpperCase()) != -1)
			{
				return true;
			}
		}
		return false;
	}
	
	/**
	 * 多重ログインチェックを行います。
	 * 
	 * @param context ディスパッチコンテキスト
	 * @return チェック結果（true:多重ログインなし、false:多重ログイン中）
	 */
	private boolean multiLoginCheck(DispatchContext context)
	{	
		// 画面ID
		String gamenId = context.getSessionProfile().getServletRequest().getParameter("uji.id");
		// 画面IDがnull(初期起動時)の場合はチェックを行わない
		if(gamenId == null)
		{
			return true;
		}
		// アプリケーションプロパティファイルからオンライン起動チェック無視イベントIDを取得する
		String checkInit = JCMAPLConstMgr.getString("ONLINE_CHECK_IGNONE_EVENTID");
		if(!(checkInit == null || "".equals(checkInit)))
		{
			// uji.verbよりイベントIDを取得する。等しいものがあればチェックを行わない
			X33VViewJSPBean jspbean = (X33VViewJSPBean)context.getRequestBean();
			String eventId = jspbean.getVerb();
			String[] checkInitList = checkInit.split(",");
			for(int i = 0; i < checkInitList.length; i++)
			{
				if(eventId.equals(checkInitList[i]))
				{
					return true;
				}
			}
		}
		
		// 非同期通信フラグ
		String asyncFlg = context.getSessionProfile().getServletRequest().getParameter("ajax.asyncFlg");
		// 非同期通信の場合はチェックを行わない
		if(asyncFlg != null)
		{
			return true;
		}
		
		// JSPビーンから共有フォームビーンを取得する。
		X33VViewJSPBean jspbean = (X33VViewJSPBean)context.getRequestBean();
		X33VDataTypeList dataTypeList = jspbean.getCommonInfo();
		String userId = null;
		String loginTime = null;
		
		// 共有フォームビーンを探し出す
		for(int i = 0 ; i < dataTypeList.getSize(); i++)
		{
			if(dataTypeList.getElementAt(i) instanceof CommonInfoCFBean)
			{
				// 共有フォームビーンからユーザーＩＤ(USER_ID)とログイン時間(LOGIN_DTM)取得
				Object obj = dataTypeList.getElementAt(i);
				X33VViewBaseBean dataBean = (X33VViewBaseBean)obj;
				
				userId = (String)X33SDataBeanAccessWrapper.execDataBeanAccess(null, dataBean,  "ユーザーＩＤ"
						, X33SDataBeanAccessWrapper.REQ_GET_VALUE, X33SDataBeanAccessWrapper.SUBKEY_VALUE, true);
				loginTime = (String)X33SDataBeanAccessWrapper.execDataBeanAccess(null, dataBean,  "ログイン時間"
						, X33SDataBeanAccessWrapper.REQ_GET_VALUE, X33SDataBeanAccessWrapper.SUBKEY_VALUE, true);
				break;
			}
		}
		
		// フレームIDの取得
		String frameid = context.getSessionProfile().getServletRequest().getParameter("frameid");
		// セッションオブジェクトの取得
		X31SSession sessionX31 = X31SSessionManager.getSession(context.getSessionProfile().getSessionId(), frameid);
		
		try
		{
			// ユースケースID格納用マップ
			HashMap<String, String> paramMap = new HashMap<String, String>();
			// 設定値格納用マップ
			HashMap<String, Object> inputMap = new HashMap<String, Object>();
			// 検索結果格納用マップ
			HashMap<String, Object> outputMap = new HashMap<String, Object>();
			// ユースケースID格納
			paramMap.put(X31CWebConst.TELEGRAM_INFO_USECASE_ID, "CCSV0005");
			// パラメータ設定
			HashMap<String, Object> inputHash = new HashMap<String, Object>();
			inputHash.put("func_code", "1");// 機能コード
			inputHash.put("key_user_id", userId);// ユーザーID
			inputMap.put("CCSV000501SC", inputHash);
			// サービス実行
			X31CMessageResult msgResult = sessionX31.invokeService(paramMap, inputMap, outputMap, JCCRequestProcessLogic.class.getName());
			// 業務エラーの場合はJCCFrameworkExeptionをスローする
			if(msgResult != null)
			{
				throw new JCCFrameworkException("ログイン時間一意照会で業務エラーが発生しました。");
			}
			
			// ログイン管理一意照会マップ取得(キー:"CCSV000501SC")
			HashMap<String, Object> workMap = (HashMap<String, Object>)outputMap.get("CCSV000501SC");
			// ログイン管理一意照会情報取得(キー:"ECC0071A010CBSMsg1List")
			ArrayList<Object> workList = (ArrayList<Object>)workMap.get("ECC0071A010CBSMsg1List");
			// 取得できない場合はJCCFrameworkExeptionをスローする
			if (0 == workList.size()) {
				throw new JCCFrameworkException("ログイン時間一意照会の検索結果が0件です。");
			}
			
			// ユーザーIDに紐づくログイン時間を取得
			HashMap<String, Object> dataMap = (HashMap<String, Object>)workList.get(0);
			// 共有フォームビーンから取得したログイン時間とログイン管理一意照会のログイン時間が異なる場合、エラー画面へ遷移
			if(!loginTime.equals(dataMap.get("login_time")))
			{
				// エラー画面へ遷移
				return false;
			}
			return true;
		}
		catch (Exception e)
		{
			throw new JCCFrameworkException("ログイン時間一意照会情報の取得に失敗しました。", e);
		}
	}

	/**
	 * メニューからの遷移かどうかチェックします。
	 * @return true:メニューから false:メニュー以外から
	 */
	private boolean checkScreenIdFromMenu( DispatchContext context ) {
		X33VViewJSPBean jspbean = (X33VViewJSPBean)context.getRequestBean();
		
		// アプリケーションプロパティファイルのメニュー画面ID定義を取得
		String menuScreenId = JCMAPLConstMgr.getString("MENU_SCREEN_ID");
		if ( menuScreenId == null || menuScreenId.length() == 0 ) {
			return false;
		}
		
		// イベントが発生した画面IDを取得
		String screenId = null;
		try {
			screenId = jspbean.getEventPageId();
		} catch (NullPointerException npe) {
			screenId = null;
		}
		
		// メニュー画面ID定義と、イベントが発生した画面IDが一致したらメニューからの遷移とする。
		if ( screenId != null && screenId.equals( menuScreenId ) ) {
			return true;
		}
		
		return false;
	}
	
	/**
	 * リクエスト元がメニューかどうかを判定し、メニューであった場合、
	 * メニュー配下の画面情報を削除する。
	 * 
	 * @param context
	 */
	private void clearScreenInfo( DispatchContext context ) {
		// メニューからの遷移かどうか調べる
		boolean isFromMenu = checkScreenIdFromMenu(context);
		
		// メニューからの遷移ではない場合、なにもしない。
		if ( !isFromMenu ) {
			return;
		}
		
		// メニューからの遷移だった場合、セッションから、該当メニュー配下の画面情報を削除する。
		// リクエストからメニューID取得
		// 20121220 メニューIDの取得先変更（戻るボタンが効かない障害の対応） fst)yanagihara start
		String menuid = context.getSessionProfile().getServletRequest().getParameter(JCCWebCommon.MENUID_PARAM_NAME);
		//String menuid = context.getSessionProfile().getServletRequest().getParameter("uji.verb");
		// 20121220 メニューIDの取得先変更（戻るボタンが効かない障害の対応） fst)yanagihara end
			
		// 画面情報格納Map取得
		HashMap screenInfoMap = (HashMap) context.getSessionProfile().getSession().getAttribute("screenInfo");
		if ( screenInfoMap != null ) {
			// メニュー配下の画面情報があれば全て消す。
			if ( screenInfoMap.containsKey( menuid ) ) {
				screenInfoMap.remove( menuid );
			}
		}
			
		// 戻り先画面ID格納Map取得
		HashMap screenIdMap = (HashMap) context.getSessionProfile().getSession().getAttribute("screenId");
		if ( screenIdMap != null ) {
			// メニュー配下の戻り先画面ID情報があれば全て消す。
			if ( screenIdMap.containsKey( menuid ) ) {
				screenIdMap.remove( menuid );
			}
		}
			
		// ページリンク情報格納Map取得
		HashMap pageLinkInfoMap = (HashMap) context.getSessionProfile().getSession().getAttribute("pageLinkInfo");
		if ( pageLinkInfoMap != null ) {
			// メニュー配下のページリンク情報があれば全て消す。
			if ( pageLinkInfoMap.containsKey( menuid ) ) {
				pageLinkInfoMap.remove( menuid );
			}
		}
	}
	
	/**
	 * オンライン起動チェックエラーの場合のメッセージIDを設定
	 * 
	 * @param context ディスパッチコンテキスト
	 * @param messageId メッセージID
	 */
	private void setOnlineCheckMessageId(DispatchContext context, String messageId)
	{
		// セッションID取得
		String sessionId = context.getSessionProfile().getSessionId();
		// セッション取得
		HttpSession session = X33CUtil.getSession(sessionId).getSession();
		// オンラインチェックメッセージＩＤをセッションへ格納
		session.setAttribute("オンラインチェックメッセージＩＤ", messageId);
	}

	/**
	 * 共有フォームBeanのリクエストフラグを立てる処理
	 * Viewロジックに実装している業務規制・権限制御機能の起動トリガとなる
	 * 
	 * @param context ディスパッチコンテキスト
	 */
	private void setReqestFlg(DispatchContext context) 
	{
		
// 2012/08/07 FST)arata 量販・モバイルの場合は初期起動時も業務規制を行う start
		String targetSystem = JCMAPLConstMgr.getString("TARGET_SYSTEM");
		if(targetSystem.equals("RYOHAN") || targetSystem.equals("MOBILE"))
		{
			getCommonInfoBean().sendMessageString(CommonInfoCFConst.REQUEST_FLG, X31CWebConst.DATABEAN_SET_VALUE, "1");
			return;
		}
// 2012/08/07 FST)arata 量販・モバイルの場合は初期起動時も業務規制を行う end
		// JSPビーンを取得
		X33VViewJSPBean jspbean = (X33VViewJSPBean)context.getRequestBean();
		X33VDataTypeList dataTypeList = jspbean.getCommonInfo();
		
		// 共有フォームビーンをサーチ
		for(int i = 0 ; i < dataTypeList.getSize(); i++)
		{
			if(dataTypeList.getElementAt(i) instanceof CommonInfoCFBean)
			{
				// 共有フォームビーンのリクエストフラグに１を立てる
				Object obj = dataTypeList.getElementAt(i);
				X33VViewBaseBean dataBean = (X33VViewBaseBean)obj;				
				X33SDataBeanAccessWrapper.execDataBeanAccess(null, dataBean, CommonInfoCFConst.REQUEST_FLG, 
						X33SDataBeanAccessWrapper.REQ_SET_VALUE, X33SDataBeanAccessWrapper.SUBKEY_VALUE, "1");
				break;
			}
		}
	}
	
	// 20121220 定期リクエストは初期処理をしない fst)yanagihara start
	/**
	 * 定期リクエストイベントを判定する。
	 * @param context ディスパッチコンテキスト
	 */
	public static boolean isKeepAliveEvent(DispatchContext context)
	{
		String target_System = JCMAPLConstMgr.getString("TARGET_SYSTEM");
		if(target_System == null || "".equals(target_System))
		{
			throw new JCCFrameworkException("ターゲットシステム（キー：TARGET_SYSTEM）が" +
			"アプリケーションプロパティファイル（APLConst.properties）にて設定されていません。");
		}
		// バックヤードの場合のみチェックを行う
		if("BACKYARD".equals(target_System))
		{
			// アプリケーションプロパティファイルより定期リクエストイベントIDを取得
			String keepAliveEventid = JCMAPLConstMgr.getString("KEEP_ALIVE_EVENTID");
			if(keepAliveEventid == null)
			{
				throw new JCCFrameworkException("定期リクエストイベントID（キー：KEEP_ALIVE_EVENTID）が" +
				"アプリケーションプロパティファイル（APLConst.properties）にて設定されていません。");
			}
			HttpServletRequest request = context.getSessionProfile().getServletRequest();
			String eventid = request.getParameter("uji.verb");
			
			if(keepAliveEventid.equals(eventid))
			{
				return true;
			}
		}
		return false;
	}
	// 20121220 定期リクエストは初期処理をしない fst)yanagihara end
}
