# HG changeset patch # User Ingo Weinzierl # Date 1305123788 0 # Node ID 71a7533555d052ce65cd22052a258fdd0ef56d6b # Parent 905daf30221ab1825369c296741193559fb48e38 Added a service to export data from the artifact server. flys-client/trunk@1900 c6561f87-3c4e-4783-a992-168aeb5c3f6f diff -r 905daf30221a -r 71a7533555d0 flys-client/ChangeLog --- a/flys-client/ChangeLog Wed May 11 11:44:23 2011 +0000 +++ b/flys-client/ChangeLog Wed May 11 14:23:08 2011 +0000 @@ -1,3 +1,14 @@ +2011-05-11 Ingo Weinzierl + + * src/main/java/de/intevation/flys/client/server/ExportServiceImpl.java: + New. This service is a "proxy servlet" that enables the GUI to add + download buttons for exporting the computed data of the artifact server. + + * src/main/java/de/intevation/flys/client/client/services/CSVExportService.java: + Changed the URL part to query the CSV export ('export' -> 'csv'). + + * src/main/webapp/WEB-INF/web.xml: Registered the new ExportService. + 2011-05-11 Raimund Renkert ISSUE 34 diff -r 905daf30221a -r 71a7533555d0 flys-client/src/main/java/de/intevation/flys/client/client/services/CSVExportService.java --- a/flys-client/src/main/java/de/intevation/flys/client/client/services/CSVExportService.java Wed May 11 11:44:23 2011 +0000 +++ b/flys-client/src/main/java/de/intevation/flys/client/client/services/CSVExportService.java Wed May 11 14:23:08 2011 +0000 @@ -13,7 +13,7 @@ * * @author Raimund Renkert */ -@RemoteServiceRelativePath("export") +@RemoteServiceRelativePath("csv") public interface CSVExportService extends RemoteService { /** diff -r 905daf30221a -r 71a7533555d0 flys-client/src/main/java/de/intevation/flys/client/server/ExportServiceImpl.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/flys-client/src/main/java/de/intevation/flys/client/server/ExportServiceImpl.java Wed May 11 14:23:08 2011 +0000 @@ -0,0 +1,57 @@ +package de.intevation.flys.client.server; + +import java.io.OutputStream; +import java.io.IOException; + +import org.w3c.dom.Document; + +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 Ingo Weinzierl + */ +public class ExportServiceImpl +extends HttpServlet +{ + public void doGet(HttpServletRequest req, HttpServletResponse resp) { + System.out.println("ExportServiceImpl.doGet"); + + try { + OutputStream out = resp.getOutputStream(); + + String serverUrl = req.getParameter("server"); + 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); + + Document request = ClientProtocolUtils.newOutCollectionDocument( + uuid, mode); + + HttpClient client = new HttpClientImpl(serverUrl, locale); + client.collectionOut(request, uuid, mode, out); + + out.close(); + out.flush(); + } + catch (IOException ioe) { + System.err.println(ioe.getMessage()); + } + } +} +// vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 : diff -r 905daf30221a -r 71a7533555d0 flys-client/src/main/webapp/WEB-INF/web.xml --- a/flys-client/src/main/webapp/WEB-INF/web.xml Wed May 11 11:44:23 2011 +0000 +++ b/flys-client/src/main/webapp/WEB-INF/web.xml Wed May 11 14:23:08 2011 +0000 @@ -138,13 +138,13 @@ - waterlevel_export + csv de.intevation.flys.client.server.CSVExportServiceImpl - waterlevel_export - /flys/export + csv + /flys/csv @@ -157,6 +157,16 @@ /flys/chart + + ExportService + de.intevation.flys.client.server.ExportServiceImpl + + + + ExportService + /flys/export + + FLYS.html