You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@sling.apache.org by ie...@apache.org on 2016/09/02 16:09:37 UTC

svn commit: r1758986 - in /sling/trunk/bundles: engine/src/main/java/org/apache/sling/engine/impl/parameters/ servlets/post/src/main/java/org/apache/sling/servlets/post/impl/operations/ servlets/post/src/test/java/org/apache/sling/servlets/post/impl/op...

Author: ieb
Date: Fri Sep  2 16:09:36 2016
New Revision: 1758986

URL: http://svn.apache.org/viewvc?rev=1758986&view=rev
Log:
SLING-6017 Streaming Uploads detection of request parameters is wrong.
Fixed Servlet API conflict with Sling Upload documentation

Modified:
    sling/trunk/bundles/engine/src/main/java/org/apache/sling/engine/impl/parameters/RequestPartsIterator.java
    sling/trunk/bundles/servlets/post/src/main/java/org/apache/sling/servlets/post/impl/operations/StreamedUploadOperation.java
    sling/trunk/bundles/servlets/post/src/test/java/org/apache/sling/servlets/post/impl/operations/StreamingUploadOperationTest.java

Modified: sling/trunk/bundles/engine/src/main/java/org/apache/sling/engine/impl/parameters/RequestPartsIterator.java
URL: http://svn.apache.org/viewvc/sling/trunk/bundles/engine/src/main/java/org/apache/sling/engine/impl/parameters/RequestPartsIterator.java?rev=1758986&r1=1758985&r2=1758986&view=diff
==============================================================================
--- sling/trunk/bundles/engine/src/main/java/org/apache/sling/engine/impl/parameters/RequestPartsIterator.java (original)
+++ sling/trunk/bundles/engine/src/main/java/org/apache/sling/engine/impl/parameters/RequestPartsIterator.java Fri Sep  2 16:09:36 2016
@@ -146,17 +146,7 @@ public class RequestPartsIterator implem
 
         @Override
         public String getSubmittedFileName() {
-            // only return non null if the submitted file name is non null.
-            // the Sling API states that if the field name is '*' then the submitting file name is used,
-            // otherwise the field name is used.
-            String fieldName = fileItem.getFieldName();
-            String fileName = fileItem.getName();
-            if ( fileName == null ) {
-                return null;
-            } else if ("*".equals(fieldName)) {
-                return fileName;
-            }
-            return fieldName;
+            return fileItem.getName();
         }
 
         private <T> Collection<T> toCollection(Iterator<T> i) {

Modified: sling/trunk/bundles/servlets/post/src/main/java/org/apache/sling/servlets/post/impl/operations/StreamedUploadOperation.java
URL: http://svn.apache.org/viewvc/sling/trunk/bundles/servlets/post/src/main/java/org/apache/sling/servlets/post/impl/operations/StreamedUploadOperation.java?rev=1758986&r1=1758985&r2=1758986&view=diff
==============================================================================
--- sling/trunk/bundles/servlets/post/src/main/java/org/apache/sling/servlets/post/impl/operations/StreamedUploadOperation.java (original)
+++ sling/trunk/bundles/servlets/post/src/main/java/org/apache/sling/servlets/post/impl/operations/StreamedUploadOperation.java Fri Sep  2 16:09:36 2016
@@ -211,7 +211,14 @@ public class StreamedUploadOperation ext
      * @return
      */
     private String getUploadName(Part part) {
-        String name = part.getSubmittedFileName();
+        // only return non null if the submitted file name is non null.
+        // the Sling API states that if the field name is '*' then the submitting file name is used,
+        // otherwise the field name is used.
+        String name = part.getName();
+        String fileName = part.getSubmittedFileName();
+        if ("*".equals(name)) {
+            name = fileName;
+        }
         // strip of possible path (some browsers include the entire path)
         name = name.substring(name.lastIndexOf('/') + 1);
         name = name.substring(name.lastIndexOf('\\') + 1);

Modified: sling/trunk/bundles/servlets/post/src/test/java/org/apache/sling/servlets/post/impl/operations/StreamingUploadOperationTest.java
URL: http://svn.apache.org/viewvc/sling/trunk/bundles/servlets/post/src/test/java/org/apache/sling/servlets/post/impl/operations/StreamingUploadOperationTest.java?rev=1758986&r1=1758985&r2=1758986&view=diff
==============================================================================
--- sling/trunk/bundles/servlets/post/src/test/java/org/apache/sling/servlets/post/impl/operations/StreamingUploadOperationTest.java (original)
+++ sling/trunk/bundles/servlets/post/src/test/java/org/apache/sling/servlets/post/impl/operations/StreamingUploadOperationTest.java Fri Sep  2 16:09:36 2016
@@ -93,8 +93,8 @@ public class StreamingUploadOperationTes
         List<Part> partsList = new ArrayList<Part>();
         partsList.add(new MockPart("formfield1", null, null, 0, new ByteArrayInputStream("testformfield1".getBytes("UTF-8"))));
         partsList.add(new MockPart("formfield2", null, null, 0, new ByteArrayInputStream("testformfield2".getBytes("UTF-8"))));
-        partsList.add(new MockPart("body1", "text/plain", "test1.txt", 4, new ByteArrayInputStream("test".getBytes("UTF-8"))));
-        partsList.add(new MockPart("body2", "text/plain2", "test2.txt", 8, new ByteArrayInputStream("test1234".getBytes("UTF-8"))));
+        partsList.add(new MockPart("test1.txt", "text/plain", "test1bad.txt", 4, new ByteArrayInputStream("test".getBytes("UTF-8"))));
+        partsList.add(new MockPart("*", "text/plain2", "test2.txt", 8, new ByteArrayInputStream("test1234".getBytes("UTF-8"))));
         partsList.add(new MockPart("badformfield2", null, null, 0, new ByteArrayInputStream("testbadformfield2".getBytes("UTF-8"))));
         final Iterator<Part> partsIterator = partsList.iterator();
         final Map<String, Resource> repository = new HashMap<String, Resource>();