Mercurial > dive4elements > gnv-client
view gnv/src/main/java/de/intevation/gnv/action/PreviousArtifactStepAction.java @ 963:0441e78cd900
Add more Javadocs
gnv/trunk@1107 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author | Tim Englich <tim.englich@intevation.de> |
---|---|
date | Tue, 18 May 2010 11:09:33 +0000 |
parents | af22fa5567a6 |
children | 33198e55371c |
line wrap: on
line source
package de.intevation.gnv.action; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import org.apache.log4j.Logger; import org.apache.struts.action.ActionForm; import org.apache.struts.action.ActionForward; import org.apache.struts.action.ActionMapping; import de.intevation.gnv.action.sessionmodel.SessionModel; import de.intevation.gnv.action.sessionmodel.SessionModelFactory; import de.intevation.gnv.artifactdatabase.client.ArtifactDatabaseClient; import de.intevation.gnv.artifactdatabase.client.ArtifactDatabaseClientFactory; import de.intevation.gnv.artifactdatabase.objects.ArtifactDescription; import de.intevation.gnv.artifactdatabase.objects.ArtifactObject; /** * This controller is used to step back to a previous state of the current * artifact. After calling the advance operation of the artifact server have * been called successfully, the describe document of the current artifact is * fetched and a new gui is rendered. * * @author <a href="mailto:ingo.weinzierl@intevation.de">Ingo Weinzierl</a> */ public class PreviousArtifactStepAction extends DescribeUIAction { public static final String URL_STATE_KEY = "target"; /** * the logger, used to log exceptions and additonaly information */ private static Logger logger = Logger.getLogger(PreviousArtifactStepAction.class); /** * Constructor */ public PreviousArtifactStepAction() { super(); } @Override public ActionForward execute( ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response ) throws Exception { SessionModel session = SessionModelFactory.getInstance().getSessionModel( request); ArtifactDescription ad = session.getArtifactDescription(); if (ad == null) { logger.warn("Session timed out."); request.setAttribute( CommunicationKeys.REQUEST_EXCEPTION_MESSAGE_ID, "SessionTimeout has occured"); new FetchArtifactFactoriesAction().execute( mapping, form, request, response); return super.execute(mapping, form, request, response); } // TODO check if target is reachable ArtifactDatabaseClientFactory f = ArtifactDatabaseClientFactory.getInstance(); ArtifactDatabaseClient client = f.getArtifactDatabaseClient(getLocale(request)); ArtifactObject artifactFactory = session.getSelectedArtifactFactory(); ArtifactObject currentArtifact = session.getCurrentArtifact(); String target = (String) request.getParameter(URL_STATE_KEY); logger.debug("Step back to previous state: " + target); try { client.doAdvance( artifactFactory, currentArtifact, target ); } catch (Exception e) { logger.error(e, e); request.setAttribute( CommunicationKeys.REQUEST_EXCEPTION_MESSAGE_ID, e.getMessage()); } return super.execute(mapping, form, request, response); } } // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf-8 :