diff options
author | Matti Tahvonen <matti.tahvonen@itmill.com> | 2009-10-29 14:23:29 +0000 |
---|---|---|
committer | Matti Tahvonen <matti.tahvonen@itmill.com> | 2009-10-29 14:23:29 +0000 |
commit | af099b272f010163b179896ada14470528270244 (patch) | |
tree | 81003937bc4cbf9e4f663f9caac55786b2ec4eaa /src/com/vaadin | |
parent | dc5a17060e5c91f6e11a86caea41edd2d6b67508 (diff) | |
download | vaadin-framework-af099b272f010163b179896ada14470528270244.tar.gz vaadin-framework-af099b272f010163b179896ada14470528270244.zip |
merged [9463] to 6.2
svn changeset:9465/svn branch:6.2
Diffstat (limited to 'src/com/vaadin')
-rw-r--r-- | src/com/vaadin/terminal/gwt/server/CommunicationManager.java | 14 | ||||
-rw-r--r-- | src/com/vaadin/ui/Upload.java | 36 |
2 files changed, 40 insertions, 10 deletions
diff --git a/src/com/vaadin/terminal/gwt/server/CommunicationManager.java b/src/com/vaadin/terminal/gwt/server/CommunicationManager.java index 8e73098454..4238aab019 100644 --- a/src/com/vaadin/terminal/gwt/server/CommunicationManager.java +++ b/src/com/vaadin/terminal/gwt/server/CommunicationManager.java @@ -62,6 +62,7 @@ import com.vaadin.ui.AbstractField; import com.vaadin.ui.Component; import com.vaadin.ui.Upload; import com.vaadin.ui.Window; +import com.vaadin.ui.Upload.UploadException; /** * Application manager processes changes and paints for single application @@ -203,7 +204,18 @@ public class CommunicationManager implements Paintable.RepaintRequestListener, // file pl.setUpload(uploadComponent); - uploadComponent.receiveUpload(upstream); + try { + uploadComponent.receiveUpload(upstream); + } catch (UploadException e) { + // error happened while receiving file. Handle the + // error in the same manner as it would have happened in + // variable change. + synchronized (application) { + handleChangeVariablesError(application, + uploadComponent, e, + new HashMap<String, Object>()); + } + } } } } catch (final FileUploadException e) { diff --git a/src/com/vaadin/ui/Upload.java b/src/com/vaadin/ui/Upload.java index 4789641193..dfbbbfc103 100644 --- a/src/com/vaadin/ui/Upload.java +++ b/src/com/vaadin/ui/Upload.java @@ -122,7 +122,7 @@ public class Upload extends AbstractComponent implements Component.Focusable { * * @param upload */ - public void receiveUpload(UploadStream upload) { + public void receiveUpload(UploadStream upload) throws UploadException { if (!isUploading) { throw new IllegalStateException("uploading not started"); } @@ -174,7 +174,7 @@ public class Upload extends AbstractComponent implements Component.Focusable { } } if (interrupted) { - throw new Exception("Upload interrupted by other thread"); + throw new UploadInterruptedException(); } } @@ -188,17 +188,22 @@ public class Upload extends AbstractComponent implements Component.Focusable { } catch (final Exception e) { synchronized (application) { - // Download interrupted - try { - // still try to close output stream - out.close(); - } catch (IOException ignored) { + if (e instanceof UploadInterruptedException) { + // Download interrupted + try { + // still try to close output stream + out.close(); + } catch (IOException e1) { + // NOP + } } fireUploadInterrupted(filename, type, totalBytes, e); endUpload(); interrupted = false; - // throw cause ahead - throw new IllegalStateException("Uploading failed", e); + if (!(e instanceof UploadInterruptedException)) { + // throw exception for terminal to be handled + throw new UploadException(e); + } } } } @@ -296,6 +301,19 @@ public class Upload extends AbstractComponent implements Component.Focusable { } } + private class UploadInterruptedException extends Exception { + public UploadInterruptedException() { + super("Upload interrupted by other thread"); + } + + } + + public class UploadException extends Exception { + public UploadException(Exception e) { + super("Upload failed", e); + } + } + /** * Upload.Received event is sent when the upload receives a file, regardless * of whether the reception was successful or failed. If you wish to |