package com.heckmansoft.surjey.controller.action;

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

import org.apache.log4j.Logger;

/**
 * Action to enable deleting a question.
 */
public class DeleteQuestionAction extends QuestionAction {

    Logger log = Logger.getLogger(DeleteQuestionAction.class);

    public DeleteQuestionAction(Object source) {
        super(source);
    }

    /**
     * @see com.heckmansoft.surjey.controller.action.Action#execute(HttpServletRequest, HttpServletResponse)
     */
    public String execute(
        HttpServletRequest request,
        HttpServletResponse response)
    throws Exception {
        log.debug("execute()");

        // Get the question id from the request
        String id = (String) request.getParameter("questionId");

        // Delete the question
        questionManager.remove(id);

        Action forward = new EditSectionAction(this.source);
        return forward.execute(request,response);
    }

}
