package com.heckmansoft.surjey.controller.action;

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

import org.apache.log4j.Logger;

import com.heckmansoft.surjey.model.datastore.DatastoreException;

/**
 * Action to enable searching for surveys.
 */
public class ListSurveysAction extends SurveyAction {

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

    public ListSurveysAction(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()");

        // Lookup a list of all surveys and store in the request
        request.setAttribute("surveys", surveyManager.findAll());

        // Forward to view
        return "ListSurveys";
    }

}
