Skip to content

Commit

Permalink
Fixes piranhacloud#4470 - Add logging to FileUploadManager for debugg…
Browse files Browse the repository at this point in the history
…ing purposes (piranhacloud#4485)
  • Loading branch information
mnriem authored Jan 9, 2025
1 parent f5c203a commit 6089369
Showing 1 changed file with 23 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -50,10 +50,10 @@
* The ApacheMultiPartManager.
*
* <p>
The FileUploadMultiPartManager implements the MultiPartManager API that delivers
file upload functionality to a web application by delegating to Apache
Commons File Upload.
</p>
* The FileUploadMultiPartManager implements the MultiPartManager API that
* delivers file upload functionality to a web application by delegating to
* Apache Commons File Upload.
* </p>
*
* @author Manfred Riem ([email protected])
*/
Expand All @@ -73,9 +73,14 @@ public FileUploadMultiPartManager() {
@SuppressWarnings("unchecked")
@Override
public Collection<Part> getParts(WebApplication webApplication, WebApplicationRequest request) throws ServletException {
LOGGER.log(TRACE, "Getting parts for request: {0}", request);

if (LOGGER.isLoggable(TRACE)) {
LOGGER.log(TRACE, "Getting parts for request: {0}", request);
}

if (!JakartaServletFileUpload.isMultipartContent(request)) {
if (LOGGER.isLoggable(TRACE)) {
LOGGER.log(TRACE, "Request: {0} is not a multipart/form-date request");
}
throw new ServletException("Not a multipart/form-data request");
}

Expand All @@ -98,15 +103,26 @@ public Collection<Part> getParts(WebApplication webApplication, WebApplicationRe

@Override
public Part getPart(WebApplication webApplication, WebApplicationRequest request, String name) throws ServletException {
LOGGER.log(TRACE, "Getting part: {0} for request: {1}", name, request);
if (LOGGER.isLoggable(TRACE)) {
LOGGER.log(TRACE, "Getting part: {0} for request: {1}", name, request);
}
if (!JakartaServletFileUpload.isMultipartContent(request)) {
if (LOGGER.isLoggable(TRACE)) {
LOGGER.log(TRACE, "Request: {0} is not a multipart/form-date request");
}
throw new ServletException("Not a multipart/form-data request");
}
for (Part part : getParts(webApplication, request)) {
if (part.getName().equals(name)) {
if (LOGGER.isLoggable(TRACE)) {
LOGGER.log(TRACE, "Found part: {0}", part.getName());
}
return part;
}
}
if (LOGGER.isLoggable(TRACE)) {
LOGGER.log(TRACE, "Unable to find part: {0}", name);
}
return null;
}

Expand Down

0 comments on commit 6089369

Please sign in to comment.