From ea7805e4f6debba318ea0021c9e6cfcefc3db7ee Mon Sep 17 00:00:00 2001 From: Johann Werner Date: Wed, 29 May 2013 10:52:55 +0200 Subject: [PATCH] use long instead of int in AjaxFileUpload classes --- .../er/ajax/AjaxFileUploadRequestHandler.java | 4 ++-- .../Ajax/Ajax/Sources/er/ajax/AjaxProgress.java | 14 ++++++++++++-- .../Ajax/Sources/er/ajax/AjaxUploadProgress.java | 9 +++++++-- 3 files changed, 21 insertions(+), 6 deletions(-) diff --git a/Frameworks/Ajax/Ajax/Sources/er/ajax/AjaxFileUploadRequestHandler.java b/Frameworks/Ajax/Ajax/Sources/er/ajax/AjaxFileUploadRequestHandler.java index 726a091804b..730ae9eed0e 100644 --- a/Frameworks/Ajax/Ajax/Sources/er/ajax/AjaxFileUploadRequestHandler.java +++ b/Frameworks/Ajax/Ajax/Sources/er/ajax/AjaxFileUploadRequestHandler.java @@ -60,7 +60,7 @@ public WOResponse handleRequest(WORequest request) { String uploadIdentifier = null; String uploadFileName = null; InputStream uploadInputStream = null; - int streamLength = -1; + long streamLength = -1L; try { String sessionIdKey = WOApplication.application().sessionIdKey(); @@ -114,7 +114,7 @@ else if (formData.isFileUpload()) { } try { - if (_maxUploadSize >= 0 && streamLength > _maxUploadSize) { + if (_maxUploadSize >= 0L && streamLength > _maxUploadSize) { IOException e = new IOException("You attempted to upload a file larger than the maximum allowed size of " + new ERXUnitAwareDecimalFormat(ERXUnitAwareDecimalFormat.BYTE).format(_maxUploadSize) + "."); progress.setFailure(e); progress.dispose(); diff --git a/Frameworks/Ajax/Ajax/Sources/er/ajax/AjaxProgress.java b/Frameworks/Ajax/Ajax/Sources/er/ajax/AjaxProgress.java index ee73e797678..7d05a1ba7c4 100644 --- a/Frameworks/Ajax/Ajax/Sources/er/ajax/AjaxProgress.java +++ b/Frameworks/Ajax/Ajax/Sources/er/ajax/AjaxProgress.java @@ -33,21 +33,31 @@ public class AjaxProgress { * * @param maximum the maximum value of this progress */ - public AjaxProgress(int maximum) { + public AjaxProgress(long maximum) { this("AjaxProgress" + System.currentTimeMillis(), maximum); } + @Deprecated + public AjaxProgress(int maximum) { + this((long) maximum); + } + /** * Construct an AjaxProgress * * @param id the id of this AjaxProgress (only useful if you're registering it with AjaxProgressBar's registry) * @param maximum the maximum value of this progress */ - public AjaxProgress(String id, int maximum) { + public AjaxProgress(String id, long maximum) { _id = id; _maximum = maximum; } + @Deprecated + public AjaxProgress(String id, int maximum) { + this(id, (long) maximum); + } + /** * Returns the id of this progress model. * diff --git a/Frameworks/Ajax/Ajax/Sources/er/ajax/AjaxUploadProgress.java b/Frameworks/Ajax/Ajax/Sources/er/ajax/AjaxUploadProgress.java index 8672e13d30f..d7a3850c109 100644 --- a/Frameworks/Ajax/Ajax/Sources/er/ajax/AjaxUploadProgress.java +++ b/Frameworks/Ajax/Ajax/Sources/er/ajax/AjaxUploadProgress.java @@ -24,12 +24,17 @@ public static interface Delegate { * @param fileName the name of the file uploaded from the client * @param streamLength the total length of the stream */ - public AjaxUploadProgress(String id, File tempFile, String fileName, int streamLength) { + public AjaxUploadProgress(String id, File tempFile, String fileName, long streamLength) { super(id, streamLength); _tempFile = tempFile; _fileName = fileName; } - + + @Deprecated + public AjaxUploadProgress(String id, File tempFile, String fileName, int streamLength) { + this(id, tempFile, fileName, (long) streamLength); + } + /** * Returns the name of the file the client uploaded. *