Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -172,9 +172,6 @@ public static Map<String, Object> getParameterMap(HttpServletRequest req, Predic
throw new RuntimeException(e);
}
params.putAll(multiPartMap);
if (req.getAttribute("multiPartMap") == null) {
req.setAttribute("multiPartMap", multiPartMap);
}
if (Debug.verboseOn()) {
Debug.logVerbose("Made Request Parameter Map with [" + params.size() + "] Entries", MODULE);
}
Expand Down Expand Up @@ -222,8 +219,23 @@ public static JakartaServletFileUpload<DiskFileItem, DiskFileItemFactory> getSer
return upload;
}

/**
* Lazy getter for parameters of requests with multipart encoding.
* <p>
* Sets the multipart data as request attribute "multiPartMap" when called the first time but will refer to that request attribute
* for subsequent times.
*
* @param request
* @return
*/
public static Map<String, Object> getMultiPartParameterMap(HttpServletRequest request) throws FileUploadException {
Map<String, Object> multiPartMap = new HashMap<>();
Map<String, Object> multiPartMap = UtilGenerics.checkMap(request.getAttribute("multiPartMap"), String.class, Object.class);

if (multiPartMap != null) {
return multiPartMap;
}
multiPartMap = new HashMap<>();

Delegator delegator = (Delegator) request.getAttribute("delegator");
HttpSession session = request.getSession();
boolean isMultiPart = JakartaServletFileUpload.isMultipartContent(request);
Expand Down Expand Up @@ -304,7 +316,7 @@ public static Map<String, Object> getMultiPartParameterMap(HttpServletRequest re
}
}
}

request.setAttribute("multiPartMap", multiPartMap);
return multiPartMap;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,9 @@ public String invoke(Event event, RequestMap requestMap, HttpServletRequest requ
value = paramList;
} else {
// first check the multi-part map
value = multiPartMap.get(name);
if (UtilValidate.isNotEmpty(multiPartMap)) {
value = multiPartMap.get(name);
}

// next check attributes; do this before parameters so that attribute which can
// be changed by code can override parameters which can't
Expand Down
Loading