Mercurial > dive4elements > gnv-client
view gnv/src/main/java/de/intevation/gnv/action/SelectArtifactFactoryAction.java @ 1022:28a0628b11b0
Added license file and license header.
gnv/trunk@1258 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author | Ingo Weinzierl <ingo.weinzierl@intevation.de> |
---|---|
date | Tue, 02 Nov 2010 17:15:08 +0000 |
parents | 0441e78cd900 |
children |
line wrap: on
line source
/* * Copyright (c) 2010 by Intevation GmbH * * This program is free software under the LGPL (>=v2.1) * Read the file LGPL.txt coming with the software for details * or visit http://www.gnu.org/licenses/ if it does not exist. */ 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.ArtifactObject; /** * This controller is called to select a specific fis. * * @author <a href="mailto:tim.englich@intevation.de">Tim Englich</a> */ public class SelectArtifactFactoryAction extends DescribeUIAction { /** * the logger, used to log exceptions and additonaly information */ private static Logger log = Logger .getLogger(SelectArtifactFactoryAction.class); /** * Constructor */ public SelectArtifactFactoryAction() { super(); } @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(); // Removes the Artifactspecific Attributes from the 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(getLocale(request)); ArtifactObject artifact = adc.createNewArtifact(af); sm.setCurrentArtifact(artifact); 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); } } } // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf-8 :