Mercurial > dive4elements > gnv-client
view gnv/src/main/java/de/intevation/gnv/action/SelectArtifactFactoryAction.java @ 34:25fdec8b4c69
Added Global Errorhandling to the GNV-Client
gnv/trunk@170 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author | Tim Englich <tim.englich@intevation.de> |
---|---|
date | Fri, 02 Oct 2009 08:38:57 +0000 |
parents | 07e9c137a2f1 |
children | 4405f31bbc30 |
line wrap: on
line source
/** * */ package de.intevation.gnv.action; import java.util.Collection; 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.ArtifactFactory; import de.intevation.gnv.artifactdatabase.objects.ArtifactObject; import de.intevation.gnv.util.XSLTransformer; /** * @author Tim Englich <tim.englich@intevation.de> * */ public class SelectArtifactFactoryAction extends ArtifactDatabaseActionBase { /** * the logger, used to log exceptions and additonaly information */ private static Logger log = Logger.getLogger(SelectArtifactFactoryAction.class); /** * @see de.intevation.gnv.action.ArtifactDatabaseActionBase#execute(org.apache.struts.action.ActionMapping, org.apache.struts.action.ActionForm, javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse) */ @Override public ActionForward execute(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception { log.debug("SelectArtifactFactoryAction.execute"); String selectedArtifactFactoryID = request.getParameter("artifactFactory"); log.debug("Selected ArtifactFactory ==> "+selectedArtifactFactoryID); try { SessionModel sm = SessionModelFactory.getInstance().getSessionModel(request); Collection<ArtifactObject> artifactFactories = sm.getArtifactFactories(); // L�scht die Artifactspezifischen Attribute am Sessionmodel sm.resetModel(); if (artifactFactories == null || artifactFactories.isEmpty()){ new FetchArtifactFactoriesAction().execute(mapping, form, request, response); } sm.selectArtifactFactory(selectedArtifactFactoryID); ArtifactObject af = sm.getSelectedArtifactFactory();; ArtifactDatabaseClient adc = ArtifactDatabaseClientFactory.getInstance().getArtifactDatabaseClient(); ArtifactObject artifact = adc.createNewArtifact(af); sm.setCurrentArtifact(artifact); ArtifactDescription artifactdescription = adc.getCurrentStepDescription(af, artifact); XSLTransformer transformer = new XSLTransformer(); String ui = transformer.transform(artifactdescription.getCurrentUI(), "UTF-8", request.getRealPath("WEB-INF/config/templates/describe-ui.xsl")); request.setAttribute("ui", ui); // return succsess return super.execute(mapping, form, request, response); } catch (Exception e) { log.error(e,e); request.setAttribute(CommunicationKeys.REQUEST_EXCEPTION_MESSAGE_ID, e.getMessage()); return super.getExceptionForward(mapping); } } /** * Constructor */ public SelectArtifactFactoryAction() { } }