Mercurial > dive4elements > gnv-client
view gnv/src/main/java/de/intevation/gnv/action/StoreAction.java @ 699:af22fa5567a6
Removed trailing whitespace.
gnv/trunk@935 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author | Sascha L. Teichmann <sascha.teichmann@intevation.de> |
---|---|
date | Sat, 17 Apr 2010 09:31:48 +0000 |
parents | 254f062e334b |
children | 0441e78cd900 |
line wrap: on
line source
package de.intevation.gnv.action; 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; import java.io.OutputStream; 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; /** * This controller is used to save the current artifact to an xml file. A file * dialog is opened to save the file to the local disk. * * @author <a href="mailto:ingo.weinzierl@intevation.de">Ingo Weinzierl</a> */ public class StoreAction extends ArtifactDatabaseActionBase { public static final String RESOURCE_DOWNLOAD_FAILURE = "no.artifact.chosen"; private static Logger logger = Logger.getLogger(StoreAction.class); public StoreAction() { super(); } public ActionForward execute( ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception { SessionModelFactory sf = SessionModelFactory.getInstance(); SessionModel sm = sf.getSessionModel(request); ArtifactDatabaseClientFactory adcf = ArtifactDatabaseClientFactory.getInstance(); ArtifactDatabaseClient adc = adcf.getArtifactDatabaseClient(getLocale(request)); ArtifactObject artifact = sm.getCurrentArtifact(); // no artifact set at the moment (which means, the user didn't select a // fis yet. if (artifact == null) { logger.warn("No artifact/fis selected yet."); request.setAttribute( CommunicationKeys.REQUEST_EXCEPTION_PROJECT, RESOURCE_DOWNLOAD_FAILURE); return super.execute(mapping, form, request, response); } logger.info("Export artifact " + artifact.getId()); setHeaders(response, artifact.getId()); OutputStream out = response.getOutputStream(); adc.doExport( sm.getSelectedArtifactFactory(), artifact, out); out.flush(); out.close(); return null; } protected void setHeaders(HttpServletResponse response, String uuid) { String filename = "GNVArtefakt_" + uuid + ".xml"; response.setHeader("Content-Type", "application/xml"); response.setHeader( "Content-Disposition", "attachment;filename=" + filename); } } // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf-8 :