package jp.ossc.petstore.action;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;

import jp.ossc.petstore.OpenstandiaConst;
import jp.ossc.petstore.common.Cart;

/**
 * レジアクション
 * @author ossc
 * @version $Revision: 1.2 $
 */
public class RegisterAction extends BaseAction {


	/**
	 * レジアクション実行<br>
	 *
	 * @param mapping ActionMapping
	 * @param form ActionForm
	 * @param request HTTPリクエスト
	 * @param response HTTPレスポンス
	 * @return 画面遷移先
	 * @throws Exception Action実行時エラー
	 */
	public ActionForward execute(ActionMapping mapping, ActionForm form,
			HttpServletRequest request, HttpServletResponse response)
			throws Exception {

		// セッションを取得
		HttpSession session = request.getSession(false);

		// カート情報を取得
		Cart cart = (Cart)session.getAttribute(OpenstandiaConst.ENV_SES_ATRBT_CART);

		// カートチェック
		if (cart == null || cart.isEmpty()) {
			return mapping.findForward(OpenstandiaConst.ENV_FORWARD_CART_EMPTY);
		}

		return mapping.findForward(OpenstandiaConst.ENV_FORWARD_SUCCESS);
	}
}
