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/ui/Upload.java | |
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/ui/Upload.java')
-rw-r--r-- | src/com/vaadin/ui/Upload.java | 36 |
1 files changed, 27 insertions, 9 deletions
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 |