[PATCH 6 of 8] issue971: Let ExportServiceImpl handle encoding parameter,

Wald Commits scm-commit at wald.intevation.org
Wed Sep 25 12:16:59 CEST 2013


# HG changeset patch
# User Felix Wolfsteller <felix.wolfsteller at intevation.de>
# Date 1380104505 -7200
# Node ID 6efa25f97f7e12c8c3ca012488106144cb21e919
# Parent  2098ac94bebced1881c5b4fbb0c22bec2bf96606
issue971: Let ExportServiceImpl handle encoding parameter,
configure http-client accordingly.

diff -r 2098ac94bebc -r 6efa25f97f7e gwt-client/src/main/java/org/dive4elements/river/client/server/ExportServiceImpl.java
--- a/gwt-client/src/main/java/org/dive4elements/river/client/server/ExportServiceImpl.java	Wed Sep 25 12:20:49 2013 +0200
+++ b/gwt-client/src/main/java/org/dive4elements/river/client/server/ExportServiceImpl.java	Wed Sep 25 12:21:45 2013 +0200
@@ -55,6 +55,7 @@
             String locale = req.getParameter("locale");
             String km     = req.getParameter("km");
             String fn     = name + "." + type;
+            String enc    = req.getParameter("encoding");
 
             resp.setHeader("Content-Disposition", "attachment;filename=" + fn);
 
@@ -74,6 +75,18 @@
             Document request = ClientProtocolUtils.newOutCollectionDocument(
                 uuid, mode, type, attr);
             HttpClient client = new HttpClientImpl(url, locale);
+
+            // Set out encoding if specified.
+            if (enc != null) {
+                try {
+                client.setOutEncoding(
+                    java.nio.charset.Charset.forName(enc));
+                }
+                catch(java.nio.charset.UnsupportedCharsetException e) {
+                    logger.warn("Unsupported encoding: " + enc);
+                }
+            }
+
             client.collectionOut(request, uuid, mode, out);
 
             out.close();


More information about the Dive4elements-commits mailing list