You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@struts.apache.org by lu...@apache.org on 2014/08/21 15:53:42 UTC

git commit: WW-4389 Solves typo in error message and introduces new message variable

Repository: struts
Updated Branches:
  refs/heads/develop bd56838f4 -> 91225ce17


WW-4389 Solves typo in error message and introduces new message variable


Project: http://git-wip-us.apache.org/repos/asf/struts/repo
Commit: http://git-wip-us.apache.org/repos/asf/struts/commit/91225ce1
Tree: http://git-wip-us.apache.org/repos/asf/struts/tree/91225ce1
Diff: http://git-wip-us.apache.org/repos/asf/struts/diff/91225ce1

Branch: refs/heads/develop
Commit: 91225ce17a5e135c303c55a6c92694e5ebed7f8e
Parents: bd56838
Author: Lukasz Lenart <lu...@apache.org>
Authored: Thu Aug 21 15:53:30 2014 +0200
Committer: Lukasz Lenart <lu...@apache.org>
Committed: Thu Aug 21 15:53:30 2014 +0200

----------------------------------------------------------------------
 .../org/apache/struts2/interceptor/FileUploadInterceptor.java | 7 ++++++-
 .../resources/org/apache/struts2/struts-messages.properties   | 2 +-
 2 files changed, 7 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/struts/blob/91225ce1/core/src/main/java/org/apache/struts2/interceptor/FileUploadInterceptor.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/struts2/interceptor/FileUploadInterceptor.java b/core/src/main/java/org/apache/struts2/interceptor/FileUploadInterceptor.java
index 05f4946..0ce91bc 100644
--- a/core/src/main/java/org/apache/struts2/interceptor/FileUploadInterceptor.java
+++ b/core/src/main/java/org/apache/struts2/interceptor/FileUploadInterceptor.java
@@ -40,6 +40,7 @@ import org.apache.struts2.dispatcher.multipart.MultiPartRequestWrapper;
 
 import javax.servlet.http.HttpServletRequest;
 import java.io.File;
+import java.text.NumberFormat;
 import java.util.ArrayList;
 import java.util.Collection;
 import java.util.Collections;
@@ -350,7 +351,7 @@ public class FileUploadInterceptor extends AbstractInterceptor {
                 LOG.warn(errMsg);
             }
         } else if (maximumSize != null && maximumSize < file.length()) {
-            String errMsg = getTextMessage(action, "struts.messages.error.file.too.large", new String[]{inputName, filename, file.getName(), "" + file.length()});
+            String errMsg = getTextMessage(action, "struts.messages.error.file.too.large", new String[]{inputName, filename, file.getName(), "" + file.length(), getMaximumSizeStr(action)});
             if (validation != null) {
                 validation.addFieldError(inputName, errMsg);
             }
@@ -383,6 +384,10 @@ public class FileUploadInterceptor extends AbstractInterceptor {
         return fileIsAcceptable;
     }
 
+    private String getMaximumSizeStr(Object action) {
+        return NumberFormat.getNumberInstance(getLocaleProvider(action).getLocale()).format(maximumSize);
+    }
+
     /**
      * @param extensionCollection - Collection of extensions (all lowercase).
      * @param filename            - filename to check.

http://git-wip-us.apache.org/repos/asf/struts/blob/91225ce1/core/src/main/resources/org/apache/struts2/struts-messages.properties
----------------------------------------------------------------------
diff --git a/core/src/main/resources/org/apache/struts2/struts-messages.properties b/core/src/main/resources/org/apache/struts2/struts-messages.properties
index 43d76a6..b25cefb 100644
--- a/core/src/main/resources/org/apache/struts2/struts-messages.properties
+++ b/core/src/main/resources/org/apache/struts2/struts-messages.properties
@@ -27,7 +27,7 @@ struts.messages.invalid.file=Could not find a Filename for {0}. Verify that a va
 struts.messages.invalid.content.type=Could not find a Content-Type for {0}. Verify that a valid file was submitted.
 struts.messages.removing.file=Removing file {0} {1}
 struts.messages.error.uploading=Error uploading: {0}
-struts.messages.error.file.too.large=The file is to large to be uploaded: {0} "{1}" "{2}" {3}
+struts.messages.error.file.too.large=File {0} is too large to be uploaded. Maximum allowed size is {4} bytes?
 struts.messages.error.content.type.not.allowed=Content-Type not allowed: {0} "{1}" "{2}" {3}
 struts.messages.error.file.extension.not.allowed=File extension not allowed: {0} "{1}" "{2}" {3}