Mercurial > dive4elements > river
view gwt-client/src/main/java/org/dive4elements/river/client/server/ExportServiceImpl.java @ 5948:d7b9b3e3c61a
Make instantiation of saml.User easier.
Most of the parameters of the constructor can be taken from the
Assertion object, so there's no reason to pass them separately.
Also, trying to check the validity dates isn't useful for the single
sign on case. See comments in the hasExpired method.
author | Bernhard Herzog <bh@intevation.de> |
---|---|
date | Wed, 08 May 2013 17:56:14 +0200 |
parents | 172338b1407f |
children | ea9eef426962 |
line wrap: on
line source
/* Copyright (C) 2011, 2012, 2013 by Bundesanstalt für Gewässerkunde * Software engineering by Intevation GmbH * * This file is Free Software under the GNU AGPL (>=v3) * and comes with ABSOLUTELY NO WARRANTY! Check out the * documentation coming with Dive4Elements River for details. */ package org.dive4elements.river.client.server; import java.io.OutputStream; import java.io.IOException; import org.w3c.dom.Document; import org.w3c.dom.Element; import org.apache.log4j.Logger; import javax.servlet.http.HttpServlet; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import org.dive4elements.artifacts.common.utils.ClientProtocolUtils; import org.dive4elements.artifacts.common.utils.XMLUtils; import org.dive4elements.artifacts.httpclient.http.HttpClient; import org.dive4elements.artifacts.httpclient.http.HttpClientImpl; /** * This service is used to request a data export from the artifact server. The * response is directed directly to the output stream, so that a file dialog is * opened. * * @author <a href="mailto:ingo.weinzierl@intevation.de">Ingo Weinzierl</a> */ public class ExportServiceImpl extends HttpServlet { private static final Logger logger = Logger.getLogger(ExportServiceImpl.class); public void doGet(HttpServletRequest req, HttpServletResponse resp) { logger.info("ExportServiceImpl.doGet"); try { OutputStream out = resp.getOutputStream(); String url = getServletContext().getInitParameter("server-url"); String uuid = req.getParameter("uuid"); String name = req.getParameter("name"); String mode = req.getParameter("mode"); String type = req.getParameter("type"); String locale = req.getParameter("locale"); String km = req.getParameter("km"); String fn = name + "." + type; resp.setHeader("Content-Disposition", "attachment;filename=" + fn); if (logger.isDebugEnabled()) { logger.debug("Request " + type + " export."); } Document attr = null; if (km != null && km.length() > 0) { attr = XMLUtils.newDocument(); XMLUtils.ElementCreator ec = new XMLUtils.ElementCreator(attr, null, null); Element e = ec.create("km"); e.setTextContent(km); attr.appendChild(e); } Document request = ClientProtocolUtils.newOutCollectionDocument( uuid, mode, type, attr); HttpClient client = new HttpClientImpl(url, locale); client.collectionOut(request, uuid, mode, out); out.close(); out.flush(); } catch (IOException ioe) { logger.error(ioe, ioe); } } } // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :