view flys-client/src/main/java/de/intevation/flys/client/server/ExportServiceImpl.java @ 2546:2618d5de9ce4

Merged revisions 4533 via svnmerge from svn+ssh://ingo@thoe.intevation.de/home/clients/bsh/bsh-generischer-viewer/Material/SVN/flys-client/trunk ........ r4533 | ingo | 2012-05-27 12:50:38 +0000 (Sun, 27 May 2012) | 1 line Corrected image path to add_wms.png ........ flys-client/tags/2.7@4535 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Ingo Weinzierl <ingo.weinzierl@intevation.de>
date Sun, 27 May 2012 12:58:01 +0000
parents bc06a671ef60
children 17c66d38f095
line wrap: on
line source
package de.intevation.flys.client.server;

import java.io.OutputStream;
import java.io.IOException;

import org.w3c.dom.Document;

import org.apache.log4j.Logger;

import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import de.intevation.artifacts.common.utils.ClientProtocolUtils;

import de.intevation.artifacts.httpclient.http.HttpClient;
import de.intevation.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 mode      = req.getParameter("mode");
            String type      = req.getParameter("type");
            String locale    = req.getParameter("locale");
            String fn        = mode + "." + type;

            resp.setHeader("Content-Disposition", "attachment;filename=" + fn);

            logger.debug("Request " + type + " export.");
            Document request = ClientProtocolUtils.newOutCollectionDocument(
                uuid, mode, type);

            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 :

http://dive4elements.wald.intevation.org