Return-Path: X-Original-To: apmail-struts-commits-archive@minotaur.apache.org Delivered-To: apmail-struts-commits-archive@minotaur.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 45B77D41C for ; Fri, 31 Aug 2012 14:06:52 +0000 (UTC) Received: (qmail 98802 invoked by uid 500); 31 Aug 2012 14:06:52 -0000 Delivered-To: apmail-struts-commits-archive@struts.apache.org Received: (qmail 98668 invoked by uid 500); 31 Aug 2012 14:06:51 -0000 Mailing-List: contact commits-help@struts.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@struts.apache.org Delivered-To: mailing list commits@struts.apache.org Received: (qmail 98659 invoked by uid 99); 31 Aug 2012 14:06:51 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 31 Aug 2012 14:06:51 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=5.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 31 Aug 2012 14:06:46 +0000 Received: from eris.apache.org (localhost [127.0.0.1]) by eris.apache.org (Postfix) with ESMTP id D9D2D2388900 for ; Fri, 31 Aug 2012 14:06:01 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r1379458 - in /struts/struts2/trunk: core/src/main/java/org/apache/struts2/dispatcher/ core/src/main/java/org/apache/struts2/dispatcher/multipart/ core/src/main/java/org/apache/struts2/interceptor/ core/src/main/resources/org/apache/struts2... Date: Fri, 31 Aug 2012 14:06:01 -0000 To: commits@struts.apache.org From: lukaszlenart@apache.org X-Mailer: svnmailer-1.0.8-patched Message-Id: <20120831140601.D9D2D2388900@eris.apache.org> Author: lukaszlenart Date: Fri Aug 31 14:06:00 2012 New Revision: 1379458 URL: http://svn.apache.org/viewvc?rev=1379458&view=rev Log: WW-3177 adds better way to handle error messages when an exception occurs, adds support for I18N to translate exceptions and adds default error messages Modified: struts/struts2/trunk/core/src/main/java/org/apache/struts2/dispatcher/Dispatcher.java struts/struts2/trunk/core/src/main/java/org/apache/struts2/dispatcher/multipart/JakartaMultiPartRequest.java struts/struts2/trunk/core/src/main/java/org/apache/struts2/dispatcher/multipart/MultiPartRequest.java struts/struts2/trunk/core/src/main/java/org/apache/struts2/dispatcher/multipart/MultiPartRequestWrapper.java struts/struts2/trunk/core/src/main/java/org/apache/struts2/interceptor/FileUploadInterceptor.java struts/struts2/trunk/core/src/main/resources/org/apache/struts2/struts-messages.properties struts/struts2/trunk/core/src/main/resources/org/apache/struts2/struts-messages_da.properties struts/struts2/trunk/core/src/main/resources/org/apache/struts2/struts-messages_de.properties struts/struts2/trunk/core/src/main/resources/org/apache/struts2/struts-messages_pl.properties struts/struts2/trunk/core/src/main/resources/org/apache/struts2/struts-messages_pt.properties struts/struts2/trunk/core/src/test/java/org/apache/struts2/interceptor/FileUploadInterceptorTest.java struts/struts2/trunk/plugins/pell-multipart/src/main/java/org/apache/struts2/dispatcher/multipart/PellMultiPartRequest.java Modified: struts/struts2/trunk/core/src/main/java/org/apache/struts2/dispatcher/Dispatcher.java URL: http://svn.apache.org/viewvc/struts/struts2/trunk/core/src/main/java/org/apache/struts2/dispatcher/Dispatcher.java?rev=1379458&r1=1379457&r2=1379458&view=diff ============================================================================== --- struts/struts2/trunk/core/src/main/java/org/apache/struts2/dispatcher/Dispatcher.java (original) +++ struts/struts2/trunk/core/src/main/java/org/apache/struts2/dispatcher/Dispatcher.java Fri Aug 31 14:06:00 2012 @@ -26,6 +26,7 @@ import com.opensymphony.xwork2.ActionPro import com.opensymphony.xwork2.ActionProxyFactory; import com.opensymphony.xwork2.FileManager; import com.opensymphony.xwork2.FileManagerFactory; +import com.opensymphony.xwork2.LocaleProvider; import com.opensymphony.xwork2.ObjectFactory; import com.opensymphony.xwork2.Result; import com.opensymphony.xwork2.config.Configuration; @@ -767,7 +768,8 @@ public class Dispatcher { if (mpr == null ) { mpr = getContainer().getInstance(MultiPartRequest.class); } - request = new MultiPartRequestWrapper(mpr, request, getSaveDir(servletContext)); + LocaleProvider provider = getContainer().getInstance(LocaleProvider.class); + request = new MultiPartRequestWrapper(mpr, request, getSaveDir(servletContext), provider); } else { request = new StrutsRequestWrapper(request); } Modified: struts/struts2/trunk/core/src/main/java/org/apache/struts2/dispatcher/multipart/JakartaMultiPartRequest.java URL: http://svn.apache.org/viewvc/struts/struts2/trunk/core/src/main/java/org/apache/struts2/dispatcher/multipart/JakartaMultiPartRequest.java?rev=1379458&r1=1379457&r2=1379458&view=diff ============================================================================== --- struts/struts2/trunk/core/src/main/java/org/apache/struts2/dispatcher/multipart/JakartaMultiPartRequest.java (original) +++ struts/struts2/trunk/core/src/main/java/org/apache/struts2/dispatcher/multipart/JakartaMultiPartRequest.java Fri Aug 31 14:06:00 2012 @@ -21,11 +21,13 @@ package org.apache.struts2.dispatcher.multipart; +import com.opensymphony.xwork2.LocaleProvider; import com.opensymphony.xwork2.inject.Inject; import com.opensymphony.xwork2.util.LocalizedTextUtil; import com.opensymphony.xwork2.util.logging.Logger; import com.opensymphony.xwork2.util.logging.LoggerFactory; import org.apache.commons.fileupload.FileItem; +import org.apache.commons.fileupload.FileUploadBase; import org.apache.commons.fileupload.FileUploadException; import org.apache.commons.fileupload.RequestContext; import org.apache.commons.fileupload.disk.DiskFileItem; @@ -51,42 +53,74 @@ import java.util.Set; * Multipart form data request adapter for Jakarta Commons Fileupload package. */ public class JakartaMultiPartRequest implements MultiPartRequest { - + static final Logger LOG = LoggerFactory.getLogger(MultiPartRequest.class); - + // maps parameter name -> List of FileItem objects - protected Map> files = new HashMap>(); + protected Map> files = new HashMap>(); // maps parameter name -> List of param values - protected Map> params = new HashMap>(); + protected Map> params = new HashMap>(); // any errors while processing this request protected List errors = new ArrayList(); - + protected long maxSize; + private Locale defaultLocale = Locale.ENGLISH; @Inject(StrutsConstants.STRUTS_MULTIPART_MAXSIZE) public void setMaxSize(String maxSize) { this.maxSize = Long.parseLong(maxSize); } + @Inject + public void setLocaleProvider(LocaleProvider provider) { + defaultLocale = provider.getLocale(); + } + /** * Creates a new request wrapper to handle multi-part data using methods adapted from Jason Pell's * multipart classes (see class description). * - * @param saveDir the directory to save off the file + * @param saveDir the directory to save off the file * @param request the request containing the multipart - * @throws java.io.IOException is thrown if encoding fails. + * @throws java.io.IOException is thrown if encoding fails. */ public void parse(HttpServletRequest request, String saveDir) throws IOException { try { + setLocale(request); processUpload(request, saveDir); - } catch (FileUploadException e) { + } catch (FileUploadBase.SizeLimitExceededException e) { + if (LOG.isWarnEnabled()) { + LOG.warn("Request exceeded size limit!", e); + } + String errorMessage = buildErrorMessage(e, new Object[]{e.getPermittedSize(), e.getActualSize()}); + if (!errors.contains(errorMessage)) { + errors.add(errorMessage); + } + } catch (Exception e) { if (LOG.isWarnEnabled()) { - LOG.warn("Unable to parse request", e); + LOG.warn("Unable to parse request", e); } - errors.add(e.getMessage()); + String errorMessage = buildErrorMessage(e, new Object[]{}); + if (!errors.contains(errorMessage)) { + errors.add(errorMessage); + } + } + } + + protected void setLocale(HttpServletRequest request) { + if (defaultLocale == null) { + defaultLocale = request.getLocale(); + } + } + + protected String buildErrorMessage(Throwable e, Object[] args) { + String errorKey = "struts.messages.upload.error." + e.getClass().getSimpleName(); + if (LOG.isDebugEnabled()) { + LOG.debug("Preparing error message for key: [#0]", errorKey); } + return LocalizedTextUtil.findText(this.getClass(), errorKey, defaultLocale, e.getMessage(), args); } private void processUpload(HttpServletRequest request, String saveDir) throws FileUploadException, UnsupportedEncodingException { @@ -203,12 +237,12 @@ public class JakartaMultiPartRequest imp List fileList = new ArrayList(items.size()); for (FileItem fileItem : items) { File storeLocation = ((DiskFileItem) fileItem).getStoreLocation(); - if(fileItem.isInMemory() && storeLocation!=null && !storeLocation.exists()) { + if (fileItem.isInMemory() && storeLocation != null && !storeLocation.exists()) { try { storeLocation.createNewFile(); } catch (IOException e) { - if(LOG.isErrorEnabled()){ - LOG.error("Cannot write uploaded empty file to disk: " + storeLocation.getAbsolutePath(),e); + if (LOG.isErrorEnabled()) { + LOG.error("Cannot write uploaded empty file to disk: " + storeLocation.getAbsolutePath(), e); } } } @@ -288,14 +322,14 @@ public class JakartaMultiPartRequest imp /* (non-Javadoc) * @see org.apache.struts2.dispatcher.multipart.MultiPartRequest#getErrors() */ - public List getErrors() { + public List getErrors() { return errors; } /** * Returns the canonical name of the given file. * - * @param filename the given file + * @param filename the given file * @return the canonical name of the given file */ private String getCanonicalName(String filename) { @@ -313,7 +347,7 @@ public class JakartaMultiPartRequest imp /** * Creates a RequestContext needed by Jakarta Commons Upload. * - * @param req the request. + * @param req the request. * @return a new request context. */ private RequestContext createRequestContext(final HttpServletRequest req) { Modified: struts/struts2/trunk/core/src/main/java/org/apache/struts2/dispatcher/multipart/MultiPartRequest.java URL: http://svn.apache.org/viewvc/struts/struts2/trunk/core/src/main/java/org/apache/struts2/dispatcher/multipart/MultiPartRequest.java?rev=1379458&r1=1379457&r2=1379458&view=diff ============================================================================== --- struts/struts2/trunk/core/src/main/java/org/apache/struts2/dispatcher/multipart/MultiPartRequest.java (original) +++ struts/struts2/trunk/core/src/main/java/org/apache/struts2/dispatcher/multipart/MultiPartRequest.java Fri Aug 31 14:06:00 2012 @@ -113,7 +113,7 @@ public interface MultiPartRequest { * * @return a list of Strings that represent various errors during parsing */ - public List getErrors(); + public List getErrors(); /** * Cleans up all uploaded file, should be called at the end of request Modified: struts/struts2/trunk/core/src/main/java/org/apache/struts2/dispatcher/multipart/MultiPartRequestWrapper.java URL: http://svn.apache.org/viewvc/struts/struts2/trunk/core/src/main/java/org/apache/struts2/dispatcher/multipart/MultiPartRequestWrapper.java?rev=1379458&r1=1379457&r2=1379458&view=diff ============================================================================== --- struts/struts2/trunk/core/src/main/java/org/apache/struts2/dispatcher/multipart/MultiPartRequestWrapper.java (original) +++ struts/struts2/trunk/core/src/main/java/org/apache/struts2/dispatcher/multipart/MultiPartRequestWrapper.java Fri Aug 31 14:06:00 2012 @@ -21,6 +21,8 @@ package org.apache.struts2.dispatcher.multipart; +import com.opensymphony.xwork2.LocaleProvider; +import com.opensymphony.xwork2.util.LocalizedTextUtil; import com.opensymphony.xwork2.util.logging.Logger; import com.opensymphony.xwork2.util.logging.LoggerFactory; import org.apache.struts2.dispatcher.StrutsRequestWrapper; @@ -32,6 +34,7 @@ import java.util.ArrayList; import java.util.Collection; import java.util.Enumeration; import java.util.HashMap; +import java.util.Locale; import java.util.Map; import java.util.Vector; @@ -53,33 +56,54 @@ import java.util.Vector; * */ public class MultiPartRequestWrapper extends StrutsRequestWrapper { + protected static final Logger LOG = LoggerFactory.getLogger(MultiPartRequestWrapper.class); - Collection errors; - MultiPartRequest multi; + private Collection errors; + private MultiPartRequest multi; + private Locale defaultLocale = Locale.ENGLISH; /** * Process file downloads and log any errors. * + * @param multiPartRequest Our MultiPartRequest object * @param request Our HttpServletRequest object * @param saveDir Target directory for any files that we save - * @param multiPartRequest Our MultiPartRequest object + * @param provider */ - public MultiPartRequestWrapper(MultiPartRequest multiPartRequest, HttpServletRequest request, String saveDir) { + public MultiPartRequestWrapper(MultiPartRequest multiPartRequest, HttpServletRequest request, String saveDir, LocaleProvider provider) { super(request); - + errors = new ArrayList(); multi = multiPartRequest; + defaultLocale = provider.getLocale(); + setLocale(request); try { multi.parse(request, saveDir); - for (Object o : multi.getErrors()) { - String error = (String) o; + for (String error : multi.getErrors()) { addError(error); } } catch (IOException e) { - addError("Cannot parse request: "+e.toString()); + if (LOG.isWarnEnabled()) { + LOG.warn(e.getMessage(), e); + } + addError(buildErrorMessage(e, new Object[] {e.getMessage()})); } } + protected void setLocale(HttpServletRequest request) { + if (defaultLocale == null) { + defaultLocale = request.getLocale(); + } + } + + protected String buildErrorMessage(Throwable e, Object[] args) { + String errorKey = "struts.messages.upload.error." + e.getClass().getSimpleName(); + if (LOG.isDebugEnabled()) { + LOG.debug("Preparing error message for key: [#0]", errorKey); + } + return LocalizedTextUtil.findText(this.getClass(), errorKey, defaultLocale, e.getMessage(), args); + } + /** * Get an enumeration of the parameter names for uploaded files * @@ -198,7 +222,7 @@ public class MultiPartRequestWrapper ext * @return true if any errors occured when parsing the HTTP multipart request, false otherwise. */ public boolean hasErrors() { - return !((errors == null) || errors.isEmpty()); + return !errors.isEmpty(); } /** @@ -211,16 +235,14 @@ public class MultiPartRequestWrapper ext } /** - * Adds an error message. + * Adds an error message when it isn't already added. * * @param anErrorMessage the error message to report. */ protected void addError(String anErrorMessage) { - if (errors == null) { - errors = new ArrayList(); + if (!errors.contains(anErrorMessage)) { + errors.add(anErrorMessage); } - - errors.add(anErrorMessage); } /** Modified: struts/struts2/trunk/core/src/main/java/org/apache/struts2/interceptor/FileUploadInterceptor.java URL: http://svn.apache.org/viewvc/struts/struts2/trunk/core/src/main/java/org/apache/struts2/interceptor/FileUploadInterceptor.java?rev=1379458&r1=1379457&r2=1379458&view=diff ============================================================================== --- struts/struts2/trunk/core/src/main/java/org/apache/struts2/interceptor/FileUploadInterceptor.java (original) +++ struts/struts2/trunk/core/src/main/java/org/apache/struts2/interceptor/FileUploadInterceptor.java Fri Aug 31 14:06:00 2012 @@ -267,10 +267,6 @@ public class FileUploadInterceptor exten if (validation != null) { validation.addActionError(error); } - - if (LOG.isWarnEnabled()) { - LOG.warn(error); - } } } Modified: struts/struts2/trunk/core/src/main/resources/org/apache/struts2/struts-messages.properties URL: http://svn.apache.org/viewvc/struts/struts2/trunk/core/src/main/resources/org/apache/struts2/struts-messages.properties?rev=1379458&r1=1379457&r2=1379458&view=diff ============================================================================== --- struts/struts2/trunk/core/src/main/resources/org/apache/struts2/struts-messages.properties (original) +++ struts/struts2/trunk/core/src/main/resources/org/apache/struts2/struts-messages.properties Fri Aug 31 14:06:00 2012 @@ -31,6 +31,10 @@ struts.messages.error.file.too.large=The 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} +# dedicated messages used to handle various problems with file upload - check {@link JakartaMultiPartRequest#parse(HttpServletRequest, String)} +struts.messages.upload.error.SizeLimitExceededException=Request exceeded allowed size limit! Max size allowed is: {0} but request was: {1}! +struts.messages.upload.error.IOException=Error uploading: {0}! + devmode.notification=Developer Notification (set struts.devMode to false to disable this message):\n{0} struts.exception.missing-package-action.with-context = There is no Action mapped for namespace [{0}] and action name [{1}] associated with context path [{2}]. Modified: struts/struts2/trunk/core/src/main/resources/org/apache/struts2/struts-messages_da.properties URL: http://svn.apache.org/viewvc/struts/struts2/trunk/core/src/main/resources/org/apache/struts2/struts-messages_da.properties?rev=1379458&r1=1379457&r2=1379458&view=diff ============================================================================== --- struts/struts2/trunk/core/src/main/resources/org/apache/struts2/struts-messages_da.properties (original) +++ struts/struts2/trunk/core/src/main/resources/org/apache/struts2/struts-messages_da.properties Fri Aug 31 14:06:00 2012 @@ -30,4 +30,8 @@ struts.messages.error.uploading=Fejl ved struts.messages.error.file.too.large=Filen er for stor: {0} "{1}" {2} struts.messages.error.content.type.not.allowed=Content-Type er ikke tilladt: {0} "{1}" {2} +# dedicated messages used to handle various problems with file upload - check {@link JakartaMultiPartRequest#parse(HttpServletRequest, String)} +struts.messages.upload.error.SizeLimitExceededException=Request overskredet tilladte st\u00F8rrelse gr\u00E6nse! Max tilladte st\u00F8rrelse er: {0}, men anmodning var: {1}! +struts.messages.upload.error.IOException=Fejl ved upload: {0}! + devmode.notification=Note til udvikler (ret struts.devMode til 'false' for at deaktivere denne meddelse):\n{0} Modified: struts/struts2/trunk/core/src/main/resources/org/apache/struts2/struts-messages_de.properties URL: http://svn.apache.org/viewvc/struts/struts2/trunk/core/src/main/resources/org/apache/struts2/struts-messages_de.properties?rev=1379458&r1=1379457&r2=1379458&view=diff ============================================================================== --- struts/struts2/trunk/core/src/main/resources/org/apache/struts2/struts-messages_de.properties (original) +++ struts/struts2/trunk/core/src/main/resources/org/apache/struts2/struts-messages_de.properties Fri Aug 31 14:06:00 2012 @@ -19,16 +19,20 @@ # under the License. # struts.messages.invalid.token=Das Formular wurde bereits verarbeitet oder es wurde kein Token angegeben, bitte versuchen Sie es erneut. -struts.internal.invalid.token=Das Formular Token {0} stimmt nicht mit dem Session Token {1} \u00fcberein. +struts.internal.invalid.token=Das Formular Token {0} stimmt nicht mit dem Session Token {1} \u00FCberein. -struts.messages.bypass.request=\u00dcberspringe {0}/{1} +struts.messages.bypass.request=\u00DCberspringe {0}/{1} struts.messages.current.file=Datei {0} {1} {2} {3} -struts.messages.invalid.file=Es konnte kein Dateiname f\u00fcr {0} ermittelt werden. \u00dcberpr\u00fcfen Sie ob eine g\u00fcltige Datei \u00fcbermittelt wurde. -struts.messages.invalid.content.type=Es konnte kein Content-Type f\u00fcr {0} ermittelt werden. \u00dcberpr\u00fcfen Sie ob eine g\u00fcltige Datei \u00fcbermittelt wurde. +struts.messages.invalid.file=Es konnte kein Dateiname f\u00FCr {0} ermittelt werden. \u00DCberpr\u00FCfen Sie ob eine g\u00FCltige Datei \u00FCbermittelt wurde. +struts.messages.invalid.content.type=Es konnte kein Content-Type f\u00FCr {0} ermittelt werden. \u00DCberpr\u00FCfen Sie ob eine g\u00FCltige Datei \u00FCbermittelt wurde. struts.messages.removing.file=Entferne Datei {0} {1} struts.messages.error.uploading=Fehler beim Upload: {0} struts.messages.error.file.too.large=Datei zu gross: {0} "{1}" "{2}" {3} struts.messages.error.content.type.not.allowed=Content-Type nicht erlaubt: {0} "{1}" "{2}" {3} struts.messages.error.file.extension.not.allowed=File extension nicht erlaubt: {0} "{1}" "{2}" {3} +# dedicated messages used to handle various problems with file upload - check {@link JakartaMultiPartRequest#parse(HttpServletRequest, String)} +struts.messages.upload.error.SizeLimitExceededException=Request \u00FCberschritten werden darf Gr\u00F6\u00DFenbeschr\u00E4nkung! Max zul\u00E4ssige Gr\u00F6\u00DFe ist: {0}, aber Anfrage war: {1}! +struts.messages.upload.error.IOException=Fehler beim Upload: {0}! + devmode.notification=Entwickler Hinweis (Setzen Sie struts.devMode auf false um diese Nachricht zu deaktivieren):\n{0} Modified: struts/struts2/trunk/core/src/main/resources/org/apache/struts2/struts-messages_pl.properties URL: http://svn.apache.org/viewvc/struts/struts2/trunk/core/src/main/resources/org/apache/struts2/struts-messages_pl.properties?rev=1379458&r1=1379457&r2=1379458&view=diff ============================================================================== --- struts/struts2/trunk/core/src/main/resources/org/apache/struts2/struts-messages_pl.properties (original) +++ struts/struts2/trunk/core/src/main/resources/org/apache/struts2/struts-messages_pl.properties Fri Aug 31 14:06:00 2012 @@ -18,17 +18,21 @@ # specific language governing permissions and limitations # under the License. # -struts.messages.invalid.token=Formularz zosta\u0142 ju\u017c przetworzony lub nie za\u0142\u0105czono tokena, spr\u00f3buj ponownie. +struts.messages.invalid.token=Formularz zosta\u0142 ju\u017C przetworzony lub nie za\u0142\u0105czono tokena, spr\u00F3buj ponownie. struts.internal.invalid.token=Token formularza {0} nie pasuje do tokena sesji {1}. struts.messages.bypass.request=Omijanie {0}/{1} struts.messages.current.file=Plik {0} {1} {2} {3} -struts.messages.invalid.file=Nie odnaleziono nazwy pliku dla {0}. Upewnij si\u0119 \u017ce wys\u0142ano w\u0142a\u015bciwy plik. -struts.messages.invalid.content.type=Nie odnaleziono Content-Type dla {0}. Upewnij si\u0119 \u017ce wys\u0142ano w\u0142a\u015bciwy plik. +struts.messages.invalid.file=Nie odnaleziono nazwy pliku dla {0}. Upewnij si\u0119 \u017Ce wys\u0142ano w\u0142a\u015Bciwy plik. +struts.messages.invalid.content.type=Nie odnaleziono Content-Type dla {0}. Upewnij si\u0119 \u017Ce wys\u0142ano w\u0142a\u015Bciwy plik. struts.messages.removing.file=Usuwanie pliku {0} {1} struts.messages.error.uploading=B\u0142\u0105d podczas wysy\u0142ania pliku: {0} -struts.messages.error.file.too.large=Plik jest za du\u017cy: {0} "{1}" "{2}" {3} +struts.messages.error.file.too.large=Plik jest za du\u017Cy: {0} "{1}" "{2}" {3} struts.messages.error.content.type.not.allowed=Niedozwolony Content-Type: {0} "{1}" "{2}" {3} struts.messages.error.file.extension.not.allowed=Niedozwolony File extension: {0} "{1}" "{2}" {3} -devmode.notification=Powiadmienie Developera (ustaw struts.devMode na false by wy\u0142\u0105czy\u0107 t\u0119 wiadomo\u015b\u0107):\n{0} +# dedicated messages used to handle various problems with file upload - check {@link JakartaMultiPartRequest#parse(HttpServletRequest, String)} +struts.messages.upload.error.SizeLimitExceededException=Zapytanie przekroczy\u0142o dozwolony limit rozmiaru! Maksymalny rozmiar to: {0} ale \u017C\u0105danie mia\u0142o: {1}! +struts.messages.upload.error.IOException=B\u0142\u0105d podczas wysy\u0142ania pliku: {0}! + +devmode.notification=Powiadmienie Developera (ustaw struts.devMode na false by wy\u0142\u0105czy\u0107 t\u0119 wiadomo\u015B\u0107):\n{0} Modified: struts/struts2/trunk/core/src/main/resources/org/apache/struts2/struts-messages_pt.properties URL: http://svn.apache.org/viewvc/struts/struts2/trunk/core/src/main/resources/org/apache/struts2/struts-messages_pt.properties?rev=1379458&r1=1379457&r2=1379458&view=diff ============================================================================== --- struts/struts2/trunk/core/src/main/resources/org/apache/struts2/struts-messages_pt.properties (original) +++ struts/struts2/trunk/core/src/main/resources/org/apache/struts2/struts-messages_pt.properties Fri Aug 31 14:06:00 2012 @@ -30,4 +30,8 @@ struts.messages.error.uploading=Erro de struts.messages.error.file.too.large=Arquivo muito grande: {0} "{1}" {2} struts.messages.error.content.type.not.allowed=Content-Type n\u00E3o permitido: {0} "{1}" {2} +# dedicated messages used to handle various problems with file upload - check {@link JakartaMultiPartRequest#parse(HttpServletRequest, String)} +struts.messages.upload.error.SizeLimitExceededException=Pedido excedeu o limite de tamanho permitido! Tamanho m\u00E1ximo permitido \u00E9: {0} mas foi pedido: {1}! +struts.messages.upload.error.IOException=Erro de uploading: {0}! + devmode.notification=Notifica\u00E7\u00E3o para o Desenvolvedor (altere o param\u00EAtro struts.devMode para false para desabilitar esta mensagem):\n{0} Modified: struts/struts2/trunk/core/src/test/java/org/apache/struts2/interceptor/FileUploadInterceptorTest.java URL: http://svn.apache.org/viewvc/struts/struts2/trunk/core/src/test/java/org/apache/struts2/interceptor/FileUploadInterceptorTest.java?rev=1379458&r1=1379457&r2=1379458&view=diff ============================================================================== --- struts/struts2/trunk/core/src/test/java/org/apache/struts2/interceptor/FileUploadInterceptorTest.java (original) +++ struts/struts2/trunk/core/src/test/java/org/apache/struts2/interceptor/FileUploadInterceptorTest.java Fri Aug 31 14:06:00 2012 @@ -23,6 +23,7 @@ package org.apache.struts2.interceptor; import com.opensymphony.xwork2.ActionContext; import com.opensymphony.xwork2.ActionSupport; +import com.opensymphony.xwork2.DefaultLocaleProvider; import com.opensymphony.xwork2.ValidationAwareSupport; import com.opensymphony.xwork2.mock.MockActionInvocation; import com.opensymphony.xwork2.util.ClassLoaderUtil; @@ -357,7 +358,7 @@ public class FileUploadInterceptorTest e private MultiPartRequestWrapper createMultipartRequest(HttpServletRequest req, int maxsize) throws IOException { JakartaMultiPartRequest jak = new JakartaMultiPartRequest(); jak.setMaxSize(String.valueOf(maxsize)); - return new MultiPartRequestWrapper(jak, req, tempDir.getAbsolutePath()); + return new MultiPartRequestWrapper(jak, req, tempDir.getAbsolutePath(), new DefaultLocaleProvider()); } protected void setUp() throws Exception { Modified: struts/struts2/trunk/plugins/pell-multipart/src/main/java/org/apache/struts2/dispatcher/multipart/PellMultiPartRequest.java URL: http://svn.apache.org/viewvc/struts/struts2/trunk/plugins/pell-multipart/src/main/java/org/apache/struts2/dispatcher/multipart/PellMultiPartRequest.java?rev=1379458&r1=1379457&r2=1379458&view=diff ============================================================================== --- struts/struts2/trunk/plugins/pell-multipart/src/main/java/org/apache/struts2/dispatcher/multipart/PellMultiPartRequest.java (original) +++ struts/struts2/trunk/plugins/pell-multipart/src/main/java/org/apache/struts2/dispatcher/multipart/PellMultiPartRequest.java Fri Aug 31 14:06:00 2012 @@ -111,7 +111,7 @@ public class PellMultiPartRequest implem return multi.getURLParameter(name); } - public Enumeration getParameterNames() { + public Enumeration getParameterNames() { return multi.getParameterNames(); } @@ -122,17 +122,17 @@ public class PellMultiPartRequest implem return null; } - List values = new ArrayList(); + List values = new ArrayList(); while (enumeration.hasMoreElements()) { - values.add(enumeration.nextElement()); + values.add((String) enumeration.nextElement()); } - return (String[]) values.toArray(new String[values.size()]); + return values.toArray(new String[values.size()]); } - public List getErrors() { - return Collections.EMPTY_LIST; + public List getErrors() { + return Collections.emptyList(); } /**