diff flys-client/src/main/java/de/intevation/flys/client/server/FileUploadServiceImpl.java @ 5008:04ccec566689

flys/#657: Shapefile upload now reports success or failure to client.
author Christian Lins <christian.lins@intevation.de>
date Mon, 18 Feb 2013 16:29:37 +0100
parents 02cf2b1dff84
children
line wrap: on
line diff
--- a/flys-client/src/main/java/de/intevation/flys/client/server/FileUploadServiceImpl.java	Fri Feb 15 12:47:15 2013 +0100
+++ b/flys-client/src/main/java/de/intevation/flys/client/server/FileUploadServiceImpl.java	Mon Feb 18 16:29:37 2013 +0100
@@ -7,7 +7,9 @@
 import de.intevation.artifacts.httpclient.http.HttpClientImpl;
 
 import java.io.ByteArrayOutputStream;
+import java.io.IOException;
 import java.io.InputStream;
+import java.io.PrintWriter;
 
 import javax.servlet.http.HttpServlet;
 import javax.servlet.http.HttpServletRequest;
@@ -28,11 +30,6 @@
 
     @Override
     protected void doPost(HttpServletRequest req, HttpServletResponse resp) {
-        processPost(req, resp);
-    }
-
-
-    protected void processPost(HttpServletRequest req, HttpServletResponse resp) {
         logger.debug("handling post request.");
 
         String url  = getServletContext().getInitParameter("server-url");
@@ -47,15 +44,31 @@
         try {
             Document result = client.callService(url, "fileupload", request);
 
+            PrintWriter respWriter = resp.getWriter();
+            respWriter.write("<html><link href='FLYS.css' rel='stylesheet' type='text/css'>");
+            respWriter.write("<body><div style='font-face: Arial,Verdana,sans-serif; font-size: 11px'>");
+
             if (result == null) {
                 logger.warn("FileUpload service returned no result.");
+                respWriter.write("FileUpload service returned no result");
             }
+            else {
+                String status = result.getElementsByTagName("status")
+                        .item(0).getTextContent();
+                respWriter.write(status);
+            }
+
+            respWriter.write("</div></body></html>");
+            respWriter.flush();
 
             return;
         }
         catch (ConnectionException ce) {
             logger.error(ce, ce);
         }
+        catch (IOException e) {
+            logger.error(e, e);
+        }
     }
 
 
@@ -67,8 +80,6 @@
 
             while (iter.hasNext()) {
                 FileItemStream item = iter.next();
-
-                String name = item.getFieldName();
                 InputStream stream = item.openStream();
 
                 // Process the input stream

http://dive4elements.wald.intevation.org