From 4b5ddcdf29e3b35ba9483dbada1502a96c552a7c Mon Sep 17 00:00:00 2001 From: Marc Englund Date: Tue, 8 Sep 2009 11:29:43 +0000 Subject: [PATCH] Upload examples did not serialize; for GAE support svn changeset:8705/svn branch:6.1 --- .../features/upload/UploadBasicExample.java | 24 +++++------ .../UploadWithProgressMonitoringExample.java | 42 +++++++++---------- .../gwt/server/GAEApplicationServlet.java | 13 ++++++ 3 files changed, 44 insertions(+), 35 deletions(-) diff --git a/src/com/vaadin/demo/sampler/features/upload/UploadBasicExample.java b/src/com/vaadin/demo/sampler/features/upload/UploadBasicExample.java index 1b1623ab1a..07a85627e4 100644 --- a/src/com/vaadin/demo/sampler/features/upload/UploadBasicExample.java +++ b/src/com/vaadin/demo/sampler/features/upload/UploadBasicExample.java @@ -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() { diff --git a/src/com/vaadin/demo/sampler/features/upload/UploadWithProgressMonitoringExample.java b/src/com/vaadin/demo/sampler/features/upload/UploadWithProgressMonitoringExample.java index d3954cf320..2c74b7fec7 100644 --- a/src/com/vaadin/demo/sampler/features/upload/UploadWithProgressMonitoringExample.java +++ b/src/com/vaadin/demo/sampler/features/upload/UploadWithProgressMonitoringExample.java @@ -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() { diff --git a/src/com/vaadin/terminal/gwt/server/GAEApplicationServlet.java b/src/com/vaadin/terminal/gwt/server/GAEApplicationServlet.java index e24f405ac1..147fb63f57 100644 --- a/src/com/vaadin/terminal/gwt/server/GAEApplicationServlet.java +++ b/src/com/vaadin/terminal/gwt/server/GAEApplicationServlet.java @@ -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) { -- 2.39.5