]> source.dussan.org Git - vaadin-framework.git/commitdiff
Upload examples did not serialize; for GAE support
authorMarc Englund <marc.englund@itmill.com>
Tue, 8 Sep 2009 11:29:43 +0000 (11:29 +0000)
committerMarc Englund <marc.englund@itmill.com>
Tue, 8 Sep 2009 11:29:43 +0000 (11:29 +0000)
svn changeset:8705/svn branch:6.1

src/com/vaadin/demo/sampler/features/upload/UploadBasicExample.java
src/com/vaadin/demo/sampler/features/upload/UploadWithProgressMonitoringExample.java
src/com/vaadin/terminal/gwt/server/GAEApplicationServlet.java

index 1b1623ab1a74181bec6918d9e12ae729e8b68c10..07a85627e413be05ea190ca50ff1e0d0a534a28e 100644 (file)
@@ -37,24 +37,22 @@ public class UploadBasicExample extends VerticalLayout {
         private int counter;
 
         /**
-         * OutputStream that simply counts lineends
+         * return an OutputStream that simply counts lineends
          */
-        private OutputStream stream = new OutputStream() {
-            private static final int searchedByte = '\n';
-
-            @Override
-            public void write(int b) throws IOException {
-                if (b == searchedByte) {
-                    counter++;
-                }
-            }
-        };
-
         public OutputStream receiveUpload(String filename, String MIMEType) {
             counter = 0;
             fileName = filename;
             mtype = MIMEType;
-            return stream;
+            return new OutputStream() {
+                private static final int searchedByte = '\n';
+
+                @Override
+                public void write(int b) throws IOException {
+                    if (b == searchedByte) {
+                        counter++;
+                    }
+                }
+            };
         }
 
         public String getFileName() {
index d3954cf32092c49a42df3dd253d7e1bb7aef50f8..2c74b7fec7775f076cdfc136567b5e8fefee5830 100644 (file)
@@ -151,34 +151,32 @@ public class UploadWithProgressMonitoringExample extends VerticalLayout {
         private boolean sleep;
 
         /**
-         * OutputStream that simply counts lineends
+         * return an OutputStream that simply counts lineends
          */
-        private OutputStream stream = new OutputStream() {
-            private static final int searchedByte = '\n';
-
-            @Override
-            public void write(int b) throws IOException {
-                total++;
-                if (b == searchedByte) {
-                    counter++;
-                }
-                if (sleep && total % 1000 == 0) {
-                    try {
-                        Thread.sleep(100);
-                    } catch (InterruptedException e) {
-                        // TODO Auto-generated catch block
-                        e.printStackTrace();
-                    }
-                }
-            }
-        };
-
         public OutputStream receiveUpload(String filename, String MIMEType) {
             counter = 0;
             total = 0;
             fileName = filename;
             mtype = MIMEType;
-            return stream;
+            return new OutputStream() {
+                private static final int searchedByte = '\n';
+
+                @Override
+                public void write(int b) throws IOException {
+                    total++;
+                    if (b == searchedByte) {
+                        counter++;
+                    }
+                    if (sleep && total % 1000 == 0) {
+                        try {
+                            Thread.sleep(100);
+                        } catch (InterruptedException e) {
+                            // TODO Auto-generated catch block
+                            e.printStackTrace();
+                        }
+                    }
+                }
+            };
         }
 
         public String getFileName() {
index e24f405ac19938f73583fbe47ece785f3a608841..147fb63f579bbfcb4c5590a638cd125a8c7c41fe 100644 (file)
@@ -3,6 +3,7 @@ package com.vaadin.terminal.gwt.server;
 import java.io.ByteArrayInputStream;
 import java.io.ByteArrayOutputStream;
 import java.io.IOException;
+import java.io.NotSerializableException;
 import java.io.ObjectInputStream;
 import java.io.ObjectOutputStream;
 import java.util.Date;
@@ -148,6 +149,18 @@ public class GAEApplicationServlet extends ApplicationServlet {
                     "Deadline Exceeded",
                     "I'm sorry, but the operation took too long to complete. We'll try reloading to see where we're at, please take note of any unsaved data...",
                     "", null);
+        } catch (NotSerializableException e) {
+            // TODO i18n?
+            // TODO this notification is not shown - solve this in some other
+            // way...
+            criticalNotification(
+                    request,
+                    response,
+                    "NotSerializableException",
+                    "I'm sorry, but there seems to be a serious problem, please contact the administrator. And please take note of any unsaved data...",
+                    "", getApplicationUrl(request).toString()
+                            + "?restartApplication");
+            e.printStackTrace(System.err);
         } finally {
             // "Next, please!"
             if (locked) {