Author: pbenedict Date: Tue Jun 26 18:59:16 2007 New Revision: 551007 URL: http://svn.apache.org/viewvc?view=rev&rev=551007 Log: STR-2959: Deprecate fileSize; add fileLength
Modified: struts/struts1/trunk/core/src/main/java/org/apache/struts/upload/CommonsMultipartRequestHandler.java struts/struts1/trunk/core/src/main/java/org/apache/struts/upload/FormFile.java Modified: struts/struts1/trunk/core/src/main/java/org/apache/struts/upload/CommonsMultipartRequestHandler.java URL: http://svn.apache.org/viewvc/struts/struts1/trunk/core/src/main/java/org/apache/struts/upload/CommonsMultipartRequestHandler.java?view=diff&rev=551007&r1=551006&r2=551007 ============================================================================== --- struts/struts1/trunk/core/src/main/java/org/apache/struts/upload/CommonsMultipartRequestHandler.java (original) +++ struts/struts1/trunk/core/src/main/java/org/apache/struts/upload/CommonsMultipartRequestHandler.java Tue Jun 26 18:59:16 2007 @@ -523,9 +523,14 @@ * <p> Returns the size, in bytes, of this file. </p> * * @return The size of the file, in bytes. + * @deprecated */ - public long getFileSize() { - return fileItem.getSize(); + public int getFileSize() { + long size = fileItem.getSize(); + if (size > Integer.MAX_VALUE) { + throw new IllegalStateException("Size is greater than 2 GB; use getSize()"); + } + return (int) size; } /** @@ -533,13 +538,35 @@ * is not supported in this implementation. </p> * * @param filesize The size of the file, in bytes. + * @deprecated */ - public void setFileSize(long filesize) { + public void setFileSize(int filesize) { throw new UnsupportedOperationException( "The setFileSize() method is not supported."); } /** + * <p> Returns the length of this file. </p> + * + * @return The length of the file, in bytes. + * @throws IllegalStateException if size is greater than 2GB + */ + public long getFileLength() { + return fileItem.getSize(); + } + + /** + * <p> Sets the length, in bytes, for this file. <p> NOTE: This method + * is not supported in this implementation. </p> + * + * @param fileLength The length of the file, in bytes. + */ + public void setFileLength(long fileLength) { + throw new UnsupportedOperationException( + "The setFileLength() method is not supported."); + } + + /** * <p> Returns the (client-side) file name for this file. </p> * * @return The client-size file name. @@ -588,7 +615,7 @@ throws FileNotFoundException, IOException { return fileItem.getInputStream(); } - + /** * <p> Destroy all content for this form file. Implementations should * remove any temporary files or any temporary file data stored Modified: struts/struts1/trunk/core/src/main/java/org/apache/struts/upload/FormFile.java URL: http://svn.apache.org/viewvc/struts/struts1/trunk/core/src/main/java/org/apache/struts/upload/FormFile.java?view=diff&rev=551007&r1=551006&r2=551007 ============================================================================== --- struts/struts1/trunk/core/src/main/java/org/apache/struts/upload/FormFile.java (original) +++ struts/struts1/trunk/core/src/main/java/org/apache/struts/upload/FormFile.java Tue Jun 26 18:59:16 2007 @@ -48,15 +48,34 @@ * <p> Returns the size of this file. </p> * * @return The size of the file, in bytes. + * @throws IllegalStateException if size is greater than 2GB + * @see #getFileLength() + * @deprecated */ - public long getFileSize(); + public int getFileSize(); /** * <p> Sets the file size. </p> * - * @param fileSize The size of the file, in bytes, + * @param size The size of the file, in bytes, + * @see #setFileLength(long) + * @deprecated */ - public void setFileSize(long fileSize); + public void setFileSize(int size); + + /** + * <p> Returns the length of this file. </p> + * + * @return The length of the file, in bytes. + */ + public long getFileLength(); + + /** + * <p> Sets the file length. </p> + * + * @param fileLength The length of the file, in bytes, + */ + public void setFileLength(long fileLength); /** * <p> Returns the file name of this file. This is the base name of the