package net.yher2.workstyle.action.tag.rest;

import java.sql.Connection;

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

import net.yher2.workstyle.action.BasicDataBaseAction;
import net.yher2.workstyle.action.Session;
import net.yher2.workstyle.exception.DuplicateException;
import net.yher2.workstyle.manager.TagManager;

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

public class AddAction extends BasicDataBaseAction {
	@Override
	public ActionForward execute(
			Connection con,
			Session session,
			ActionMapping mapping, 
			ActionForm actionForm, 
			HttpServletRequest request, 
			HttpServletResponse response) throws TorqueException, DuplicateException {

		AddForm form = (AddForm)actionForm;
		session.setTag(new TagManager(con).add(form.getName()));
		return mapping.findForward("success");
	}
}
