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

import java.io.FileNotFoundException;
import java.io.IOException;
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.NotFoundException;
import net.yher2.workstyle.manager.TaskManager;

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 LinkAction extends BasicDataBaseAction {
	@Override
	public ActionForward execute(
			Connection con,
			Session session,
			ActionMapping mapping, 
			ActionForm actionForm, 
			HttpServletRequest request, 
			HttpServletResponse response) throws TorqueException, NotFoundException, FileNotFoundException, IOException {

		LinkForm form = (LinkForm)actionForm;
		new TaskManager(con).link(form.getSrcTaskId(), form.getDestTaskId());
		return mapping.findForward("success");
	}
}
