(struts) 01/01: WW-5370 Makes HttpParameters case-insensitive

2023-12-10 Thread lukaszlenart
This is an automated email from the ASF dual-hosted git repository.

lukaszlenart pushed a commit to branch feature/http-params-case
in repository https://gitbox.apache.org/repos/asf/struts.git

commit 13d972d6eeaf998f7199f0d39446aff72fd67423
Author: Lukasz Lenart 
AuthorDate: Sun Dec 10 13:14:55 2023 +0100

WW-5370 Makes HttpParameters case-insensitive
---
 .../apache/struts2/dispatcher/HttpParameters.java  | 31 ---
 .../struts2/dispatcher/HttpParametersTest.java | 65 ++
 2 files changed, 88 insertions(+), 8 deletions(-)

diff --git 
a/core/src/main/java/org/apache/struts2/dispatcher/HttpParameters.java 
b/core/src/main/java/org/apache/struts2/dispatcher/HttpParameters.java
index b0ab784ab..f35d47583 100644
--- a/core/src/main/java/org/apache/struts2/dispatcher/HttpParameters.java
+++ b/core/src/main/java/org/apache/struts2/dispatcher/HttpParameters.java
@@ -29,7 +29,7 @@ import java.util.TreeMap;
 import java.util.TreeSet;
 
 @SuppressWarnings("unchecked")
-public class HttpParameters implements Map, Cloneable {
+public class HttpParameters implements Map {
 
 final private Map parameters;
 
@@ -37,6 +37,7 @@ public class HttpParameters implements Map, Cloneable {
 this.parameters = parameters;
 }
 
+@SuppressWarnings("rawtypes")
 public static Builder create(Map requestParameterMap) {
 return new Builder(requestParameterMap);
 }
@@ -47,7 +48,7 @@ public class HttpParameters implements Map, Cloneable {
 
 public HttpParameters remove(Set paramsToRemove) {
 for (String paramName : paramsToRemove) {
-parameters.remove(paramName);
+parameters.entrySet().removeIf(p -> 
p.getKey().equalsIgnoreCase(paramName));
 }
 return this;
 }
@@ -59,12 +60,15 @@ public class HttpParameters implements Map, Cloneable {
 }
 
 public boolean contains(String name) {
-return parameters.containsKey(name);
+return parameters.keySet().stream().anyMatch(p -> 
p.equalsIgnoreCase(name));
 }
 
 /**
  * Access to this method can be potentially dangerous as it allows access 
to raw parameter values.
+ *
+ * @deprecated since 6.4.0, it will be removed with a new major release
  */
+@Deprecated
 private Map toMap() {
 final Map result = new HashMap<>(parameters.size());
 for (Map.Entry entry : parameters.entrySet()) {
@@ -73,7 +77,14 @@ public class HttpParameters implements Map, Cloneable {
 return result;
 }
 
+/**
+ * Appends all the parameters by overriding any existing params in a 
case-insensitive manner
+ *
+ * @param newParams A new params to append
+ * @return a current instance of {@link HttpParameters}
+ */
 public HttpParameters appendAll(Map newParams) {
+remove(newParams.keySet());
 parameters.putAll(newParams);
 return this;
 }
@@ -100,8 +111,11 @@ public class HttpParameters implements Map, Cloneable {
 
 @Override
 public Parameter get(Object key) {
-if (parameters.containsKey(key)) {
-return parameters.get(key);
+if (key != null && contains(String.valueOf(key))) {
+return parameters.entrySet().stream()
+.filter(p -> p.getKey().equalsIgnoreCase(String.valueOf(key)))
+.findFirst().map(Entry::getValue)
+.orElse(new Parameter.Empty(String.valueOf(key)));
 } else {
 return new Parameter.Empty(String.valueOf(key));
 }
@@ -177,8 +191,8 @@ public class HttpParameters implements Map, Cloneable {
 
 public HttpParameters build() {
 Map parameters = (parent == null)
-? new HashMap<>()
-: new HashMap<>(parent.parameters);
+? new HashMap<>()
+: new HashMap<>(parent.parameters);
 
 for (Map.Entry entry : 
requestParameterMap.entrySet()) {
 String name = entry.getKey();
@@ -197,8 +211,9 @@ public class HttpParameters implements Map, Cloneable {
 * Alternate Builder method which avoids wrapping any parameters that 
are already
 * a {@link Parameter} element within another {@link Parameter} wrapper.
 *
-* @return 
+* @deprecated since 6.4.0, use {@link #build()} instead
  */
+@Deprecated
 public HttpParameters buildNoNestedWrapping() {
 Map parameters = (parent == null)
 ? new HashMap<>()
diff --git 
a/core/src/test/java/org/apache/struts2/dispatcher/HttpParametersTest.java 
b/core/src/test/java/org/apache/struts2/dispatcher/HttpParametersTest.java
new file mode 100644
index 0..7c2efbc12
--- /dev/null
+++ b/core/src/test/java/org/apache/struts2/dispatcher/HttpParametersTest.java
@@ -0,0 +1,65 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * dist

(struts) branch feature/http-params-case created (now 13d972d6e)

2023-12-10 Thread lukaszlenart
This is an automated email from the ASF dual-hosted git repository.

lukaszlenart pushed a change to branch feature/http-params-case
in repository https://gitbox.apache.org/repos/asf/struts.git


  at 13d972d6e WW-5370 Makes HttpParameters case-insensitive

This branch includes the following new commits:

 new 13d972d6e WW-5370 Makes HttpParameters case-insensitive

The 1 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.




[PR] Bump log4j2.version from 2.21.1 to 2.22.0 [struts-examples]

2023-12-10 Thread via GitHub


dependabot[bot] opened a new pull request, #296:
URL: https://github.com/apache/struts-examples/pull/296

   Bumps `log4j2.version` from 2.21.1 to 2.22.0.
   Updates `org.apache.logging.log4j:log4j-core` from 2.21.1 to 2.22.0
   
   Updates `org.apache.logging.log4j:log4j-api` from 2.21.1 to 2.22.0
   
   Updates `org.apache.logging.log4j:log4j-slf4j-impl` from 2.21.1 to 2.22.0
   
   
   Dependabot will resolve any conflicts with this PR as long as you don't 
alter it yourself. You can also trigger a rebase manually by commenting 
`@dependabot rebase`.
   
   [//]: # (dependabot-automerge-start)
   [//]: # (dependabot-automerge-end)
   
   ---
   
   
   Dependabot commands and options
   
   
   You can trigger Dependabot actions by commenting on this PR:
   - `@dependabot rebase` will rebase this PR
   - `@dependabot recreate` will recreate this PR, overwriting any edits that 
have been made to it
   - `@dependabot merge` will merge this PR after your CI passes on it
   - `@dependabot squash and merge` will squash and merge this PR after your CI 
passes on it
   - `@dependabot cancel merge` will cancel a previously requested merge and 
block automerging
   - `@dependabot reopen` will reopen this PR if it is closed
   - `@dependabot close` will close this PR and stop Dependabot recreating it. 
You can achieve the same result by closing it manually
   - `@dependabot show  ignore conditions` will show all of 
the ignore conditions of the specified dependency
   - `@dependabot ignore this major version` will close this PR and stop 
Dependabot creating any more for this major version (unless you reopen the PR 
or upgrade to it yourself)
   - `@dependabot ignore this minor version` will close this PR and stop 
Dependabot creating any more for this minor version (unless you reopen the PR 
or upgrade to it yourself)
   - `@dependabot ignore this dependency` will close this PR and stop 
Dependabot creating any more for this dependency (unless you reopen the PR or 
upgrade to it yourself)
   
   
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscr...@struts.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org



(struts-examples) branch dependabot/maven/log4j2.version-2.22.0 created (now 7b25e13)

2023-12-10 Thread github-bot
This is an automated email from the ASF dual-hosted git repository.

github-bot pushed a change to branch dependabot/maven/log4j2.version-2.22.0
in repository https://gitbox.apache.org/repos/asf/struts-examples.git


  at 7b25e13  Bump log4j2.version from 2.21.1 to 2.22.0

No new revisions were added by this update.



[PR] Bump io.quarkus:quarkus-universe-bom from 3.6.0 to 3.6.1 [struts-examples]

2023-12-10 Thread via GitHub


dependabot[bot] opened a new pull request, #294:
URL: https://github.com/apache/struts-examples/pull/294

   Bumps 
[io.quarkus:quarkus-universe-bom](https://github.com/quarkusio/quarkus-platform)
 from 3.6.0 to 3.6.1.
   
   Commits
   
   https://github.com/quarkusio/quarkus-platform/commit/6d1f521b883deef55a57df461b0f80bba84198e9";>6d1f521
 [maven-release-plugin] prepare release 3.6.1
   https://github.com/quarkusio/quarkus-platform/commit/f1fe9345855a970829ee784705c1f54dc2f48a1f";>f1fe934
 Merge pull request https://redirect.github.com/quarkusio/quarkus-platform/issues/1057";>#1057
 from gsmet/quarkus-3.6.1
   https://github.com/quarkusio/quarkus-platform/commit/5ba0ed14fbb03bc0d7c353cac0d6420107376f28";>5ba0ed1
 Upgrade to Quarkus 3.6.1
   https://github.com/quarkusio/quarkus-platform/commit/a4f5337292f95c9c767708486671c8ca4f2288ee";>a4f5337
 Add a script to update Quarkus version
   https://github.com/quarkusio/quarkus-platform/commit/3ce5495fc724d2581d161357fd62f64f1a61e6ae";>3ce5495
 Revert "Unlist quarkus-resteasy-qute and 
quarkus-resteasy-reactive-qute"
   https://github.com/quarkusio/quarkus-platform/commit/2d35bc26ad83fd1963a9e918e5c3fba1ee8104ec";>2d35bc2
 Merge pull request https://redirect.github.com/quarkusio/quarkus-platform/issues/1053";>#1053
 from quarkusio/dependabot/github_actions/actions/set...
   https://github.com/quarkusio/quarkus-platform/commit/b9a5ba88e66d17ac93c7e0d06dcfead63870a983";>b9a5ba8
 Bump actions/setup-java from 3 to 4
   https://github.com/quarkusio/quarkus-platform/commit/6e596fe88dc0274f980f6ea63f76e67d84f97dcd";>6e596fe
 [maven-release-plugin] prepare for next development iteration
   See full diff in https://github.com/quarkusio/quarkus-platform/compare/3.6.0...3.6.1";>compare
 view
   
   
   
   
   
   [![Dependabot compatibility 
score](https://dependabot-badges.githubapp.com/badges/compatibility_score?dependency-name=io.quarkus:quarkus-universe-bom&package-manager=maven&previous-version=3.6.0&new-version=3.6.1)](https://docs.github.com/en/github/managing-security-vulnerabilities/about-dependabot-security-updates#about-compatibility-scores)
   
   Dependabot will resolve any conflicts with this PR as long as you don't 
alter it yourself. You can also trigger a rebase manually by commenting 
`@dependabot rebase`.
   
   [//]: # (dependabot-automerge-start)
   [//]: # (dependabot-automerge-end)
   
   ---
   
   
   Dependabot commands and options
   
   
   You can trigger Dependabot actions by commenting on this PR:
   - `@dependabot rebase` will rebase this PR
   - `@dependabot recreate` will recreate this PR, overwriting any edits that 
have been made to it
   - `@dependabot merge` will merge this PR after your CI passes on it
   - `@dependabot squash and merge` will squash and merge this PR after your CI 
passes on it
   - `@dependabot cancel merge` will cancel a previously requested merge and 
block automerging
   - `@dependabot reopen` will reopen this PR if it is closed
   - `@dependabot close` will close this PR and stop Dependabot recreating it. 
You can achieve the same result by closing it manually
   - `@dependabot show  ignore conditions` will show all of 
the ignore conditions of the specified dependency
   - `@dependabot ignore this major version` will close this PR and stop 
Dependabot creating any more for this major version (unless you reopen the PR 
or upgrade to it yourself)
   - `@dependabot ignore this minor version` will close this PR and stop 
Dependabot creating any more for this minor version (unless you reopen the PR 
or upgrade to it yourself)
   - `@dependabot ignore this dependency` will close this PR and stop 
Dependabot creating any more for this dependency (unless you reopen the PR or 
upgrade to it yourself)
   
   
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscr...@struts.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org



(struts-examples) branch dependabot/maven/io.quarkus-quarkus-universe-bom-3.6.1 created (now 26e6c92)

2023-12-10 Thread github-bot
This is an automated email from the ASF dual-hosted git repository.

github-bot pushed a change to branch 
dependabot/maven/io.quarkus-quarkus-universe-bom-3.6.1
in repository https://gitbox.apache.org/repos/asf/struts-examples.git


  at 26e6c92  Bump io.quarkus:quarkus-universe-bom from 3.6.0 to 3.6.1

No new revisions were added by this update.



[PR] Bump net.sf.jasperreports:jasperreports from 6.20.6 to 6.21.0 [struts-examples]

2023-12-10 Thread via GitHub


dependabot[bot] opened a new pull request, #295:
URL: https://github.com/apache/struts-examples/pull/295

   Bumps 
[net.sf.jasperreports:jasperreports](https://github.com/TIBCOSoftware/jasperreports)
 from 6.20.6 to 6.21.0.
   
   Commits
   
   See full diff in https://github.com/TIBCOSoftware/jasperreports/commits";>compare 
view
   
   
   
   
   
   [![Dependabot compatibility 
score](https://dependabot-badges.githubapp.com/badges/compatibility_score?dependency-name=net.sf.jasperreports:jasperreports&package-manager=maven&previous-version=6.20.6&new-version=6.21.0)](https://docs.github.com/en/github/managing-security-vulnerabilities/about-dependabot-security-updates#about-compatibility-scores)
   
   Dependabot will resolve any conflicts with this PR as long as you don't 
alter it yourself. You can also trigger a rebase manually by commenting 
`@dependabot rebase`.
   
   [//]: # (dependabot-automerge-start)
   [//]: # (dependabot-automerge-end)
   
   ---
   
   
   Dependabot commands and options
   
   
   You can trigger Dependabot actions by commenting on this PR:
   - `@dependabot rebase` will rebase this PR
   - `@dependabot recreate` will recreate this PR, overwriting any edits that 
have been made to it
   - `@dependabot merge` will merge this PR after your CI passes on it
   - `@dependabot squash and merge` will squash and merge this PR after your CI 
passes on it
   - `@dependabot cancel merge` will cancel a previously requested merge and 
block automerging
   - `@dependabot reopen` will reopen this PR if it is closed
   - `@dependabot close` will close this PR and stop Dependabot recreating it. 
You can achieve the same result by closing it manually
   - `@dependabot show  ignore conditions` will show all of 
the ignore conditions of the specified dependency
   - `@dependabot ignore this major version` will close this PR and stop 
Dependabot creating any more for this major version (unless you reopen the PR 
or upgrade to it yourself)
   - `@dependabot ignore this minor version` will close this PR and stop 
Dependabot creating any more for this minor version (unless you reopen the PR 
or upgrade to it yourself)
   - `@dependabot ignore this dependency` will close this PR and stop 
Dependabot creating any more for this dependency (unless you reopen the PR or 
upgrade to it yourself)
   
   
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscr...@struts.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org



(struts-examples) branch dependabot/maven/net.sf.jasperreports-jasperreports-6.21.0 created (now 29579b6)

2023-12-10 Thread github-bot
This is an automated email from the ASF dual-hosted git repository.

github-bot pushed a change to branch 
dependabot/maven/net.sf.jasperreports-jasperreports-6.21.0
in repository https://gitbox.apache.org/repos/asf/struts-examples.git


  at 29579b6  Bump net.sf.jasperreports:jasperreports from 6.20.6 to 6.21.0

No new revisions were added by this update.



(struts) branch feature/WW-5371-modern-upload created (now dc4103bcb)

2023-12-10 Thread lukaszlenart
This is an automated email from the ASF dual-hosted git repository.

lukaszlenart pushed a change to branch feature/WW-5371-modern-upload
in repository https://gitbox.apache.org/repos/asf/struts.git


  at dc4103bcb WW-5371 Uses the new upload mechanism in Showcase app

This branch includes the following new commits:

 new 0bc0217b9 WW-5371 Implements action based file upload
 new dc4103bcb WW-5371 Uses the new upload mechanism in Showcase app

The 2 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.




(struts) 01/02: WW-5371 Implements action based file upload

2023-12-10 Thread lukaszlenart
This is an automated email from the ASF dual-hosted git repository.

lukaszlenart pushed a commit to branch feature/WW-5371-modern-upload
in repository https://gitbox.apache.org/repos/asf/struts.git

commit 0bc0217b9de49545b8307a98d6ca2cce3a85390f
Author: Lukasz Lenart 
AuthorDate: Mon Dec 11 07:37:38 2023 +0100

WW-5371 Implements action based file upload
---
 .../UploadedFilesAware.java}   |  32 +-
 .../multipart/JakartaMultiPartRequest.java |   6 +-
 .../multipart/JakartaStreamMultiPartRequest.java   |  36 ++-
 .../dispatcher/multipart/StrutsUploadedFile.java   |  51 ++-
 .../struts2/dispatcher/multipart/UploadedFile.java |   4 +
 .../interceptor/AbstractFileUploadInterceptor.java | 247 ++
 .../interceptor/ActionFileUploadInterceptor.java   | 248 ++
 .../struts2/interceptor/FileUploadInterceptor.java | 256 ++-
 core/src/main/resources/struts-default.xml |   9 +
 .../conversion/UploadedFileConverterTest.java  |  19 +-
 ...t.java => ActionFileUploadInterceptorTest.java} | 359 ++---
 .../interceptor/FileUploadInterceptorTest.java | 170 +-
 .../dispatcher/multipart/PellMultiPartRequest.java |  13 +-
 13 files changed, 897 insertions(+), 553 deletions(-)

diff --git 
a/core/src/main/java/org/apache/struts2/dispatcher/multipart/UploadedFile.java 
b/core/src/main/java/org/apache/struts2/action/UploadedFilesAware.java
similarity index 54%
copy from 
core/src/main/java/org/apache/struts2/dispatcher/multipart/UploadedFile.java
copy to core/src/main/java/org/apache/struts2/action/UploadedFilesAware.java
index d4edb5221..635e0b2d4 100644
--- 
a/core/src/main/java/org/apache/struts2/dispatcher/multipart/UploadedFile.java
+++ b/core/src/main/java/org/apache/struts2/action/UploadedFilesAware.java
@@ -16,23 +16,25 @@
  * specific language governing permissions and limitations
  * under the License.
  */
-package org.apache.struts2.dispatcher.multipart;
+package org.apache.struts2.action;
 
-/**
- * Virtual representation of a uploaded file used by {@link MultiPartRequest}
- */
-public interface UploadedFile {
-
-Long length();
-
-String getName();
+import org.apache.struts2.dispatcher.multipart.UploadedFile;
 
-boolean isFile();
+import java.util.List;
 
-boolean delete();
-
-String getAbsolutePath();
-
-Object getContent();
+/**
+ * Actions that want to be aware of all the uploaded file should implement 
this interface.
+ * The {@link org.apache.struts2.interceptor.ActionFileUploadInterceptor} will 
use the interface
+ * to notify action about the multiple uploaded files.
+ */
+public interface UploadedFilesAware {
+
+/**
+ * Notifies action about the multiple uploaded files, when a single file 
is uploaded
+ * the list will have just one element
+ *
+ * @param uploadedFiles a list of {@link UploadedFile}.
+ */
+void withUploadedFiles(List uploadedFiles);
 
 }
diff --git 
a/core/src/main/java/org/apache/struts2/dispatcher/multipart/JakartaMultiPartRequest.java
 
b/core/src/main/java/org/apache/struts2/dispatcher/multipart/JakartaMultiPartRequest.java
index 20b948fd3..1c0f458a0 100644
--- 
a/core/src/main/java/org/apache/struts2/dispatcher/multipart/JakartaMultiPartRequest.java
+++ 
b/core/src/main/java/org/apache/struts2/dispatcher/multipart/JakartaMultiPartRequest.java
@@ -243,7 +243,11 @@ public class JakartaMultiPartRequest extends 
AbstractMultiPartRequest {
 LOG.error("Cannot write uploaded empty file to disk: {}", 
storeLocation.getAbsolutePath(), e);
 }
 }
-fileList.add(new StrutsUploadedFile(storeLocation));
+UploadedFile uploadedFile = 
StrutsUploadedFile.Builder.create(storeLocation)
+.withContentType(fileItem.getContentType())
+.withOriginalName(fileItem.getName())
+.build();
+fileList.add(uploadedFile);
 }
 
 return fileList.toArray(new UploadedFile[0]);
diff --git 
a/core/src/main/java/org/apache/struts2/dispatcher/multipart/JakartaStreamMultiPartRequest.java
 
b/core/src/main/java/org/apache/struts2/dispatcher/multipart/JakartaStreamMultiPartRequest.java
index dec0b6841..2618d6ace 100644
--- 
a/core/src/main/java/org/apache/struts2/dispatcher/multipart/JakartaStreamMultiPartRequest.java
+++ 
b/core/src/main/java/org/apache/struts2/dispatcher/multipart/JakartaStreamMultiPartRequest.java
@@ -22,6 +22,7 @@ import org.apache.commons.fileupload.FileItemIterator;
 import org.apache.commons.fileupload.FileItemStream;
 import org.apache.commons.fileupload.FileUploadBase;
 import 
org.apache.commons.fileupload.FileUploadBase.FileSizeLimitExceededException;
+import org.apache.commons.fileupload.FileUploadException;
 import org.apache.commons.fileupload.servlet.ServletFileUpload;
 import org.apache.commons.fileupload.util.Streams;
 import org.apache.logging.log4j.LogManager;
@@ -110,7 +111,11 @@ public class Jaka

(struts) 02/02: WW-5371 Uses the new upload mechanism in Showcase app

2023-12-10 Thread lukaszlenart
This is an automated email from the ASF dual-hosted git repository.

lukaszlenart pushed a commit to branch feature/WW-5371-modern-upload
in repository https://gitbox.apache.org/repos/asf/struts.git

commit dc4103bcb55fa56176bdf014a3f9551cf57fb350
Author: Lukasz Lenart 
AuthorDate: Mon Dec 11 07:56:38 2023 +0100

WW-5371 Uses the new upload mechanism in Showcase app
---
 .../showcase/fileupload/FileUploadAction.java  | 101 ++---
 .../webapp/WEB-INF/fileupload/upload-success.jsp   |   9 +-
 .../dispatcher/multipart/StrutsUploadedFile.java   |   8 ++
 3 files changed, 61 insertions(+), 57 deletions(-)

diff --git 
a/apps/showcase/src/main/java/org/apache/struts2/showcase/fileupload/FileUploadAction.java
 
b/apps/showcase/src/main/java/org/apache/struts2/showcase/fileupload/FileUploadAction.java
index ed8a11b48..246f8ad70 100644
--- 
a/apps/showcase/src/main/java/org/apache/struts2/showcase/fileupload/FileUploadAction.java
+++ 
b/apps/showcase/src/main/java/org/apache/struts2/showcase/fileupload/FileUploadAction.java
@@ -21,75 +21,70 @@
 package org.apache.struts2.showcase.fileupload;
 
 import com.opensymphony.xwork2.ActionSupport;
+import org.apache.struts2.action.UploadedFilesAware;
+import org.apache.struts2.dispatcher.multipart.UploadedFile;
 
 import java.io.File;
+import java.util.List;
 
 /**
  * Show case File Upload example's action. FileUploadAction
  */
-public class FileUploadAction extends ActionSupport {
+public class FileUploadAction extends ActionSupport implements 
UploadedFilesAware {
 
-   private static final long serialVersionUID = 5156288255337069381L;
+private static final long serialVersionUID = 5156288255337069381L;
 
-   private String contentType;
-   private File upload;
-   private String fileName;
-   private String caption;
+private String contentType;
+private UploadedFile uploadedFile;
+private String fileName;
+private String caption;
+private String originalName;
 
-   public String input() throws Exception {
-   return SUCCESS;
-   }
+public String input() throws Exception {
+return SUCCESS;
+}
 
-   public String upload() throws Exception {
-   return SUCCESS;
-   }
+public String upload() throws Exception {
+return SUCCESS;
+}
 
-   // since we are using  the file name will be
-   // obtained through getter/setter of FileName
-   public String getUploadFileName() {
-   return fileName;
-   }
+public String getContentType() {
+return contentType;
+}
 
-   public void setUploadFileName(String fileName) {
-   this.fileName = fileName;
-   }
+public String getFileName() {
+return fileName;
+}
 
+public String getOriginalName() {
+return originalName;
+}
 
-   // since we are using  the content type 
will be
-   // obtained through getter/setter of ContentType
-   public String getUploadContentType() {
-   return contentType;
-   }
+public Object getUploadedFile() {
+return uploadedFile.getContent();
+}
 
-   public void setUploadContentType(String contentType) {
-   this.contentType = contentType;
-   }
+public String getCaption() {
+return caption;
+}
 
+public void setCaption(String caption) {
+this.caption = caption;
+}
 
-   // since we are using  the File itself will 
be
-   // obtained through getter/setter of 
-   public File getUpload() {
-   return upload;
-   }
-
-   public void setUpload(File upload) {
-   this.upload = upload;
-   }
-
-
-   public String getCaption() {
-   return caption;
-   }
-
-   public void setCaption(String caption) {
-   this.caption = caption;
-   }
-
-public long getUploadSize() {
-if (upload != null) {
-return upload.length();
-} else {
-return 0;
-}
+public long getUploadSize() {
+if (uploadedFile != null) {
+return uploadedFile.length();
+} else {
+return 0;
 }
+}
+
+@Override
+public void withUploadedFiles(List uploadedFiles) {
+this.uploadedFile = uploadedFiles.get(0);
+this.fileName = uploadedFile.getName();
+this.contentType = uploadedFile.getContentType();
+this.originalName = uploadedFile.getOriginalName();
+}
 }
diff --git 
a/apps/showcase/src/main/webapp/WEB-INF/fileupload/upload-success.jsp 
b/apps/showcase/src/main/webapp/WEB-INF/fileupload/upload-success.jsp
index d50b61be0..a1b06277a 100644
--- a/apps/showcase/src/main/webapp/WEB-INF/fileupload/upload-success.jsp
+++ b/apps/showcase/src/main/webapp/WEB-INF/fileupload/upload-success.jsp
@@ -19,7 +19,7 @@
 */
 -->
 <%@ page
-   language="java" 
+   language="java"
contentTyp

(struts) branch feature/WW-5371-modern-upload updated: WW-5371 Simplifies file upload logic and extracts constants

2023-12-10 Thread lukaszlenart
This is an automated email from the ASF dual-hosted git repository.

lukaszlenart pushed a commit to branch feature/WW-5371-modern-upload
in repository https://gitbox.apache.org/repos/asf/struts.git


The following commit(s) were added to refs/heads/feature/WW-5371-modern-upload 
by this push:
 new 3ce3f8264 WW-5371 Simplifies file upload logic and extracts constants
3ce3f8264 is described below

commit 3ce3f82646f667be262fadc1420a2d9251577c17
Author: Lukasz Lenart 
AuthorDate: Mon Dec 11 08:55:20 2023 +0100

WW-5371 Simplifies file upload logic and extracts constants
---
 .../showcase/fileupload/FileUploadAction.java  |  3 --
 .../dispatcher/multipart/StrutsUploadedFile.java   |  5 ++
 .../struts2/dispatcher/multipart/UploadedFile.java |  4 +-
 .../interceptor/AbstractFileUploadInterceptor.java | 20 +---
 .../interceptor/ActionFileUploadInterceptor.java   | 56 +-
 .../struts2/interceptor/FileUploadInterceptor.java |  6 +--
 6 files changed, 47 insertions(+), 47 deletions(-)

diff --git 
a/apps/showcase/src/main/java/org/apache/struts2/showcase/fileupload/FileUploadAction.java
 
b/apps/showcase/src/main/java/org/apache/struts2/showcase/fileupload/FileUploadAction.java
index 246f8ad70..c2ac471f4 100644
--- 
a/apps/showcase/src/main/java/org/apache/struts2/showcase/fileupload/FileUploadAction.java
+++ 
b/apps/showcase/src/main/java/org/apache/struts2/showcase/fileupload/FileUploadAction.java
@@ -24,7 +24,6 @@ import com.opensymphony.xwork2.ActionSupport;
 import org.apache.struts2.action.UploadedFilesAware;
 import org.apache.struts2.dispatcher.multipart.UploadedFile;
 
-import java.io.File;
 import java.util.List;
 
 /**
@@ -32,8 +31,6 @@ import java.util.List;
  */
 public class FileUploadAction extends ActionSupport implements 
UploadedFilesAware {
 
-private static final long serialVersionUID = 5156288255337069381L;
-
 private String contentType;
 private UploadedFile uploadedFile;
 private String fileName;
diff --git 
a/core/src/main/java/org/apache/struts2/dispatcher/multipart/StrutsUploadedFile.java
 
b/core/src/main/java/org/apache/struts2/dispatcher/multipart/StrutsUploadedFile.java
index 55233d7d7..5976f578f 100644
--- 
a/core/src/main/java/org/apache/struts2/dispatcher/multipart/StrutsUploadedFile.java
+++ 
b/core/src/main/java/org/apache/struts2/dispatcher/multipart/StrutsUploadedFile.java
@@ -26,6 +26,11 @@ public class StrutsUploadedFile implements UploadedFile {
 private final String contentType;
 private final String originalName;
 
+/**
+ * Use builder instead of constructor
+ * @param file an uploaded file
+ * @deprecated since Struts 6.4.0
+ */
 @Deprecated
 public StrutsUploadedFile(File file) {
 this.file = file;
diff --git 
a/core/src/main/java/org/apache/struts2/dispatcher/multipart/UploadedFile.java 
b/core/src/main/java/org/apache/struts2/dispatcher/multipart/UploadedFile.java
index 896c681be..ada27ff6c 100644
--- 
a/core/src/main/java/org/apache/struts2/dispatcher/multipart/UploadedFile.java
+++ 
b/core/src/main/java/org/apache/struts2/dispatcher/multipart/UploadedFile.java
@@ -18,10 +18,12 @@
  */
 package org.apache.struts2.dispatcher.multipart;
 
+import java.io.Serializable;
+
 /**
  * Virtual representation of a uploaded file used by {@link MultiPartRequest}
  */
-public interface UploadedFile {
+public interface UploadedFile extends Serializable {
 
 Long length();
 
diff --git 
a/core/src/main/java/org/apache/struts2/interceptor/AbstractFileUploadInterceptor.java
 
b/core/src/main/java/org/apache/struts2/interceptor/AbstractFileUploadInterceptor.java
index 3857a7b4e..c8da384d2 100644
--- 
a/core/src/main/java/org/apache/struts2/interceptor/AbstractFileUploadInterceptor.java
+++ 
b/core/src/main/java/org/apache/struts2/interceptor/AbstractFileUploadInterceptor.java
@@ -45,6 +45,14 @@ public abstract class AbstractFileUploadInterceptor extends 
AbstractInterceptor
 
 private static final Logger LOG = 
LogManager.getLogger(AbstractFileUploadInterceptor.class);
 
+public static final String STRUTS_MESSAGES_BYPASS_REQUEST_KEY = 
"struts.messages.bypass.request";
+public static final String STRUTS_MESSAGES_ERROR_UPLOADING_KEY = 
"struts.messages.error.uploading";
+public static final String STRUTS_MESSAGES_ERROR_FILE_TOO_LARGE_KEY = 
"struts.messages.error.file.too.large";
+public static final String STRUTS_MESSAGES_INVALID_FILE_KEY = 
"struts.messages.invalid.file";
+public static final String STRUTS_MESSAGES_INVALID_CONTENT_TYPE_KEY = 
"struts.messages.invalid.content.type";
+public static final String 
STRUTS_MESSAGES_ERROR_CONTENT_TYPE_NOT_ALLOWED_KEY = 
"struts.messages.error.content.type.not.allowed";
+public static final String 
STRUTS_MESSAGES_ERROR_FILE_EXTENSION_NOT_ALLOWED_KEY = 
"struts.messages.error.file.extension.not.allowed";
+
 protected Long maximumSize;
 protected Set allowedTypesSet = Collections.emptySet();
 protected S