This is an automated email from the ASF dual-hosted git repository. jleroux pushed a commit to branch trunk in repository https://gitbox.apache.org/repos/asf/ofbiz-framework.git
commit c9d516d367d4c06d99adae002273540b13511d32 Author: Jacques Le Roux <jacques.le.r...@les7arts.com> AuthorDate: Fri Mar 27 10:55:59 2020 +0100 Fixed: The createTaskContent request does not work (OFBIZ-11246) It seems that same request can not be parsed multiple times if it has multi part object in it as the parse method remove it after that. Found one stackoverflow link around the same: https://stackoverflow.com/questions/13881272/ servletfileuploadparserequestrequest-returns-an-empty-list I believe that all places/uploads using this workflow should resulting the same issue. One possible solution I could think of without going with new approach is to set list of file Items into the request attribute and use it if parse method remove it and unable to retrieve on 2nd call. Thanks: Ankush Upadhyay for the analysis and initial patch. I only slightly modified it. --- .../src/main/java/org/apache/ofbiz/content/layout/LayoutWorker.java | 4 ++++ framework/base/src/main/java/org/apache/ofbiz/base/util/UtilHttp.java | 2 ++ 2 files changed, 6 insertions(+) diff --git a/applications/content/src/main/java/org/apache/ofbiz/content/layout/LayoutWorker.java b/applications/content/src/main/java/org/apache/ofbiz/content/layout/LayoutWorker.java index 07e3e79..dad4217 100644 --- a/applications/content/src/main/java/org/apache/ofbiz/content/layout/LayoutWorker.java +++ b/applications/content/src/main/java/org/apache/ofbiz/content/layout/LayoutWorker.java @@ -35,6 +35,7 @@ import org.apache.ofbiz.base.util.UtilGenerics; import org.apache.ofbiz.base.util.UtilHttp; import org.apache.ofbiz.base.util.UtilMisc; import org.apache.ofbiz.base.util.UtilProperties; +import org.apache.ofbiz.base.util.UtilValidate; import org.apache.ofbiz.service.ServiceUtil; /** @@ -66,6 +67,9 @@ public final class LayoutWorker { return ServiceUtil.returnError(e4.getMessage()); } + if(lst.size() == 0 && UtilValidate.isNotEmpty(request.getAttribute("fileItems"))) { + lst = UtilGenerics.cast(request.getAttribute("fileItems")); + } if (lst.size() == 0) { String errMsg = UtilProperties.getMessage(err_resource, "layoutEvents.no_files_uploaded", locale); diff --git a/framework/base/src/main/java/org/apache/ofbiz/base/util/UtilHttp.java b/framework/base/src/main/java/org/apache/ofbiz/base/util/UtilHttp.java index 169ed10..5452a19 100644 --- a/framework/base/src/main/java/org/apache/ofbiz/base/util/UtilHttp.java +++ b/framework/base/src/main/java/org/apache/ofbiz/base/util/UtilHttp.java @@ -66,6 +66,7 @@ import org.apache.commons.fileupload.FileItem; import org.apache.commons.fileupload.FileUploadException; import org.apache.commons.fileupload.disk.DiskFileItemFactory; import org.apache.commons.fileupload.servlet.ServletFileUpload; +import org.apache.commons.fileupload.servlet.ServletRequestContext; import org.apache.commons.lang.RandomStringUtils; import org.apache.http.conn.ssl.NoopHostnameVerifier; import org.apache.http.conn.ssl.SSLConnectionSocketFactory; @@ -225,6 +226,7 @@ public final class UtilHttp { Debug.logError("File upload error" + e, module); } if (uploadedItems != null) { + request.setAttribute("fileItems", uploadedItems); for (FileItem item: uploadedItems) { String fieldName = item.getFieldName(); //byte[] itemBytes = item.get();