commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From simonetrip...@apache.org
Subject svn commit: r1455855 - in /commons/proper/fileupload/trunk/src/main/java/org/apache/commons/fileupload: FileUploadBase.java RequestContext.java UploadContext.java portlet/PortletRequestContext.java servlet/ServletRequestContext.java
Date Wed, 13 Mar 2013 09:58:59 GMT
Author: simonetripodi
Date: Wed Mar 13 09:58:59 2013
New Revision: 1455855

URL: http://svn.apache.org/r1455855
Log:
fix for Clirr report and keep [FILEUPLOAD-188] [FILEUPLOAD-195] fixed

Added:
    commons/proper/fileupload/trunk/src/main/java/org/apache/commons/fileupload/UploadContext.java
  (with props)
Modified:
    commons/proper/fileupload/trunk/src/main/java/org/apache/commons/fileupload/FileUploadBase.java
    commons/proper/fileupload/trunk/src/main/java/org/apache/commons/fileupload/RequestContext.java
    commons/proper/fileupload/trunk/src/main/java/org/apache/commons/fileupload/portlet/PortletRequestContext.java
    commons/proper/fileupload/trunk/src/main/java/org/apache/commons/fileupload/servlet/ServletRequestContext.java

Modified: commons/proper/fileupload/trunk/src/main/java/org/apache/commons/fileupload/FileUploadBase.java
URL: http://svn.apache.org/viewvc/commons/proper/fileupload/trunk/src/main/java/org/apache/commons/fileupload/FileUploadBase.java?rev=1455855&r1=1455854&r2=1455855&view=diff
==============================================================================
--- commons/proper/fileupload/trunk/src/main/java/org/apache/commons/fileupload/FileUploadBase.java
(original)
+++ commons/proper/fileupload/trunk/src/main/java/org/apache/commons/fileupload/FileUploadBase.java
Wed Mar 13 09:58:59 2013
@@ -952,8 +952,12 @@ public abstract class FileUploadBase {
 
             InputStream input = ctx.getInputStream();
 
+            @SuppressWarnings("deprecation") // still has to be backward compatible
+            final long requestSize = UploadContext.class.isAssignableFrom(ctx.getClass())
+                                     ? ((UploadContext) ctx).contentLength()
+                                     : ctx.getContentLength();
+
             if (sizeMax >= 0) {
-                long requestSize = ctx.contentLength();
                 if (requestSize != -1) {
                     if (requestSize > sizeMax) {
                         throw new SizeLimitExceededException(
@@ -985,8 +989,7 @@ public abstract class FileUploadBase {
                 throw new FileUploadException("the request was rejected because no multipart
boundary was found");
             }
 
-            notifier = new MultipartStream.ProgressNotifier(listener,
-                    ctx.contentLength());
+            notifier = new MultipartStream.ProgressNotifier(listener, requestSize);
             multi = new MultipartStream(input, boundary, notifier);
             multi.setHeaderEncoding(charEncoding);
 

Modified: commons/proper/fileupload/trunk/src/main/java/org/apache/commons/fileupload/RequestContext.java
URL: http://svn.apache.org/viewvc/commons/proper/fileupload/trunk/src/main/java/org/apache/commons/fileupload/RequestContext.java?rev=1455855&r1=1455854&r2=1455855&view=diff
==============================================================================
--- commons/proper/fileupload/trunk/src/main/java/org/apache/commons/fileupload/RequestContext.java
(original)
+++ commons/proper/fileupload/trunk/src/main/java/org/apache/commons/fileupload/RequestContext.java
Wed Mar 13 09:58:59 2013
@@ -50,20 +50,12 @@ public interface RequestContext {
      * Retrieve the content length of the request.
      *
      * @return The content length of the request.
-     * @deprecated 1.3 Use {@link #contentLength()} instead
+     * @deprecated 1.3 Use {@link UploadContext#contentLength()} instead
      */
     @Deprecated
     int getContentLength();
 
     /**
-     * Retrieve the content length of the request.
-     *
-     * @return The content length of the request.
-     * @since 1.3
-     */
-    long contentLength();
-
-    /**
      * Retrieve the input stream for the request.
      *
      * @return The input stream for the request.

Added: commons/proper/fileupload/trunk/src/main/java/org/apache/commons/fileupload/UploadContext.java
URL: http://svn.apache.org/viewvc/commons/proper/fileupload/trunk/src/main/java/org/apache/commons/fileupload/UploadContext.java?rev=1455855&view=auto
==============================================================================
--- commons/proper/fileupload/trunk/src/main/java/org/apache/commons/fileupload/UploadContext.java
(added)
+++ commons/proper/fileupload/trunk/src/main/java/org/apache/commons/fileupload/UploadContext.java
Wed Mar 13 09:58:59 2013
@@ -0,0 +1,35 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.commons.fileupload;
+
+/**
+ * Enhanced access to the request information needed for file uploads,
+ * which fixes the Content Length data access in {@link RequestContext}.
+ *
+ * @since 1.3
+ */
+public interface UploadContext extends RequestContext {
+
+    /**
+     * Retrieve the content length of the request.
+     *
+     * @return The content length of the request.
+     * @since 1.3
+     */
+    long contentLength();
+
+}

Propchange: commons/proper/fileupload/trunk/src/main/java/org/apache/commons/fileupload/UploadContext.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: commons/proper/fileupload/trunk/src/main/java/org/apache/commons/fileupload/UploadContext.java
------------------------------------------------------------------------------
    svn:keywords = Date Author Id Revision HeadURL

Propchange: commons/proper/fileupload/trunk/src/main/java/org/apache/commons/fileupload/UploadContext.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Modified: commons/proper/fileupload/trunk/src/main/java/org/apache/commons/fileupload/portlet/PortletRequestContext.java
URL: http://svn.apache.org/viewvc/commons/proper/fileupload/trunk/src/main/java/org/apache/commons/fileupload/portlet/PortletRequestContext.java?rev=1455855&r1=1455854&r2=1455855&view=diff
==============================================================================
--- commons/proper/fileupload/trunk/src/main/java/org/apache/commons/fileupload/portlet/PortletRequestContext.java
(original)
+++ commons/proper/fileupload/trunk/src/main/java/org/apache/commons/fileupload/portlet/PortletRequestContext.java
Wed Mar 13 09:58:59 2013
@@ -18,12 +18,13 @@ package org.apache.commons.fileupload.po
 
 import static java.lang.String.format;
 
-import java.io.InputStream;
 import java.io.IOException;
+import java.io.InputStream;
+
 import javax.portlet.ActionRequest;
 
 import org.apache.commons.fileupload.FileUploadBase;
-import org.apache.commons.fileupload.RequestContext;
+import org.apache.commons.fileupload.UploadContext;
 
 /**
  * <p>Provides access to the request information needed for a request made to
@@ -33,7 +34,7 @@ import org.apache.commons.fileupload.Req
  *
  * @version $Id$
  */
-public class PortletRequestContext implements RequestContext {
+public class PortletRequestContext implements UploadContext {
 
     // ----------------------------------------------------- Instance Variables
 

Modified: commons/proper/fileupload/trunk/src/main/java/org/apache/commons/fileupload/servlet/ServletRequestContext.java
URL: http://svn.apache.org/viewvc/commons/proper/fileupload/trunk/src/main/java/org/apache/commons/fileupload/servlet/ServletRequestContext.java?rev=1455855&r1=1455854&r2=1455855&view=diff
==============================================================================
--- commons/proper/fileupload/trunk/src/main/java/org/apache/commons/fileupload/servlet/ServletRequestContext.java
(original)
+++ commons/proper/fileupload/trunk/src/main/java/org/apache/commons/fileupload/servlet/ServletRequestContext.java
Wed Mar 13 09:58:59 2013
@@ -24,7 +24,7 @@ import java.io.InputStream;
 import javax.servlet.http.HttpServletRequest;
 
 import org.apache.commons.fileupload.FileUploadBase;
-import org.apache.commons.fileupload.RequestContext;
+import org.apache.commons.fileupload.UploadContext;
 
 /**
  * <p>Provides access to the request information needed for a request made to
@@ -34,7 +34,7 @@ import org.apache.commons.fileupload.Req
  *
  * @version $Id$
  */
-public class ServletRequestContext implements RequestContext {
+public class ServletRequestContext implements UploadContext {
 
     // ----------------------------------------------------- Instance Variables
 



Mime
View raw message