From ceb0a9a737b86844aa449da35b871dc76710ad7b Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 15 Jan 2024 01:39:27 +0000 Subject: [PATCH 01/22] Bump net.sf.jasperreports:jasperreports from 6.20.6 to 6.21.0 Bumps [net.sf.jasperreports:jasperreports](https://github.com/TIBCOSoftware/jasperreports) from 6.20.6 to 6.21.0. - [Release notes](https://github.com/TIBCOSoftware/jasperreports/releases) - [Commits](https://github.com/TIBCOSoftware/jasperreports/commits) --- updated-dependencies: - dependency-name: net.sf.jasperreports:jasperreports dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- plugins/jasperreports/pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/jasperreports/pom.xml b/plugins/jasperreports/pom.xml index a81eef617..59549ec7b 100644 --- a/plugins/jasperreports/pom.xml +++ b/plugins/jasperreports/pom.xml @@ -35,7 +35,7 @@ net.sf.jasperreports jasperreports - 6.20.6 + 6.21.0 provided From 9d2a7649c57c5b1ec7819628a772e1a5b8880e98 Mon Sep 17 00:00:00 2001 From: Lukasz Lenart Date: Sat, 17 Feb 2024 08:31:57 +0100 Subject: [PATCH 02/22] Updates link to build status on Jenkins --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index ca6366563..cdabef1fc 100644 --- a/README.md +++ b/README.md @@ -17,7 +17,7 @@ The Apache Struts web framework ------------------------------- -[![Jenkins Build](https://builds.apache.org/buildStatus/icon?job=Struts%2FStruts+Core%2Fmaster)](https://ci-builds.apache.org/job/Struts/job/Struts%20Core/job/master/) +[![Build Status](https://ci-builds.apache.org/buildStatus/icon?job=Struts%2FStruts+Core%2Fmaster)](https://ci-builds.apache.org/job/Struts/job/Struts%20Core/job/master/) [![Java Build](https://github.com/apache/struts/actions/workflows/maven.yml/badge.svg)](https://github.com/apache/struts/actions/workflows/maven.yml) [![Maven Central](https://maven-badges.herokuapp.com/maven-central/org.apache.struts/struts2-core/badge.svg)](https://maven-badges.herokuapp.com/maven-central/org.apache.struts/struts2-core/) [![Javadocs](https://javadoc.io/badge/org.apache.struts/struts2-core.svg)](https://javadoc.io/doc/org.apache.struts/struts2-core) From 43d180f362671abf06abce2186fb579d060a4c00 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 19 Feb 2024 01:44:05 +0000 Subject: [PATCH 03/22] Bump org.apache.maven.doxia:doxia-core from 1.9.1 to 1.12.0 Bumps [org.apache.maven.doxia:doxia-core](https://github.com/apache/maven-doxia) from 1.9.1 to 1.12.0. - [Release notes](https://github.com/apache/maven-doxia/releases) - [Commits](https://github.com/apache/maven-doxia/compare/doxia-1.9.1...doxia-1.12.0) --- updated-dependencies: - dependency-name: org.apache.maven.doxia:doxia-core dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 80bb602a6..5ca1cfd13 100644 --- a/pom.xml +++ b/pom.xml @@ -427,7 +427,7 @@ org.apache.maven.doxia doxia-core - 1.9.1 + 1.12.0 org.apache.maven.doxia From 94b2ee7ce59d8990cff2e98b5a619420bdf9668f Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 19 Feb 2024 01:44:27 +0000 Subject: [PATCH 04/22] Bump slf4j.version from 2.0.11 to 2.0.12 Bumps `slf4j.version` from 2.0.11 to 2.0.12. Updates `org.slf4j:slf4j-api` from 2.0.11 to 2.0.12 Updates `org.slf4j:slf4j-simple` from 2.0.11 to 2.0.12 --- updated-dependencies: - dependency-name: org.slf4j:slf4j-api dependency-type: direct:production update-type: version-update:semver-patch - dependency-name: org.slf4j:slf4j-simple dependency-type: direct:development update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 80bb602a6..f6c691838 100644 --- a/pom.xml +++ b/pom.xml @@ -113,7 +113,7 @@ 2.16.1 2.21.1 3.3.4 - 2.0.11 + 2.0.12 5.3.31 3.0.8 1.0.7 From 1ddf446f78a19b02455d856a37401ec243ee4950 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 19 Feb 2024 01:46:43 +0000 Subject: [PATCH 05/22] Bump commons-validator:commons-validator from 1.6 to 1.8.0 Bumps commons-validator:commons-validator from 1.6 to 1.8.0. --- updated-dependencies: - dependency-name: commons-validator:commons-validator dependency-type: direct:development update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 80bb602a6..b74480a08 100644 --- a/pom.xml +++ b/pom.xml @@ -897,7 +897,7 @@ commons-validator commons-validator - 1.6 + 1.8.0 From 8283ded5e2a8ceee301b41cd6be2c21161a389ae Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 19 Feb 2024 01:46:51 +0000 Subject: [PATCH 06/22] Bump org.apache.maven.doxia:doxia-module-markdown from 1.9.1 to 1.12.0 Bumps org.apache.maven.doxia:doxia-module-markdown from 1.9.1 to 1.12.0. --- updated-dependencies: - dependency-name: org.apache.maven.doxia:doxia-module-markdown dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 80bb602a6..b5a904bbe 100644 --- a/pom.xml +++ b/pom.xml @@ -432,7 +432,7 @@ org.apache.maven.doxia doxia-module-markdown - 1.9.1 + 1.12.0 From 43f1197961211555f9e26bedb238ce7bf7aa2120 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 21 Feb 2024 00:18:54 +0000 Subject: [PATCH 07/22] Bump org.apache.commons:commons-compress from 1.25.0 to 1.26.0 Bumps org.apache.commons:commons-compress from 1.25.0 to 1.26.0. --- updated-dependencies: - dependency-name: org.apache.commons:commons-compress dependency-type: direct:development ... Signed-off-by: dependabot[bot] --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index f6c882311..600acfb83 100644 --- a/pom.xml +++ b/pom.xml @@ -1042,7 +1042,7 @@ org.apache.commons commons-compress - 1.25.0 + 1.26.0 From ac6095d1aec08bcd23423908d6094f9caee75454 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 26 Feb 2024 01:35:59 +0000 Subject: [PATCH 08/22] Bump maven-surefire-plugin.version from 3.0.0-M7 to 3.2.5 Bumps `maven-surefire-plugin.version` from 3.0.0-M7 to 3.2.5. Updates `org.apache.maven.surefire:surefire-junit47` from 3.0.0-M7 to 3.2.5 Updates `org.apache.maven.plugins:maven-surefire-plugin` from 3.0.0-M7 to 3.2.5 - [Release notes](https://github.com/apache/maven-surefire/releases) - [Commits](https://github.com/apache/maven-surefire/compare/surefire-3.0.0-M7...surefire-3.2.5) --- updated-dependencies: - dependency-name: org.apache.maven.surefire:surefire-junit47 dependency-type: direct:production update-type: version-update:semver-minor - dependency-name: org.apache.maven.plugins:maven-surefire-plugin dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 600acfb83..a09266870 100644 --- a/pom.xml +++ b/pom.xml @@ -117,7 +117,7 @@ 5.3.31 3.0.8 1.0.7 - 3.0.0-M7 + 3.2.5 6.2.4.Final 2.3.32 From f459981022677b58e65191c5256a16a1cd1114d3 Mon Sep 17 00:00:00 2001 From: Lukasz Lenart Date: Wed, 6 Mar 2024 08:09:09 +0100 Subject: [PATCH 09/22] WW-5401 Improves logging around wrapping request and detecting multipart request --- .../org/apache/struts2/dispatcher/Dispatcher.java | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/core/src/main/java/org/apache/struts2/dispatcher/Dispatcher.java b/core/src/main/java/org/apache/struts2/dispatcher/Dispatcher.java index 70b85e1b7..fadbc1bd9 100644 --- a/core/src/main/java/org/apache/struts2/dispatcher/Dispatcher.java +++ b/core/src/main/java/org/apache/struts2/dispatcher/Dispatcher.java @@ -986,10 +986,12 @@ public class Dispatcher { public HttpServletRequest wrapRequest(HttpServletRequest request) throws IOException { // don't wrap more than once if (request instanceof StrutsRequestWrapper) { + LOG.debug("Request already wrapped with {}", StrutsRequestWrapper.class.getSimpleName()); return request; } if (isMultipartSupportEnabled(request) && isMultipartRequest(request)) { + LOG.debug("Wrapping multipart request with: {}", MultiPartRequestWrapper.class.getSimpleName()); request = new MultiPartRequestWrapper( getMultiPartRequest(), request, @@ -998,6 +1000,7 @@ public class Dispatcher { disableRequestAttributeValueStackLookup ); } else { + LOG.debug("Wrapping request using: {}", StrutsRequestWrapper.class.getSimpleName()); request = new StrutsRequestWrapper(request, disableRequestAttributeValueStackLookup); } @@ -1012,6 +1015,7 @@ public class Dispatcher { * @since 2.5.11 */ protected boolean isMultipartSupportEnabled(HttpServletRequest request) { + LOG.debug("Support for multipart request is enabled: {}", multipartSupportEnabled); return multipartSupportEnabled; } @@ -1026,9 +1030,12 @@ public class Dispatcher { String httpMethod = request.getMethod(); String contentType = request.getContentType(); - return REQUEST_POST_METHOD.equalsIgnoreCase(httpMethod) && - contentType != null && - multipartValidationPattern.matcher(contentType.toLowerCase(Locale.ENGLISH)).matches(); + boolean isPostRequest = REQUEST_POST_METHOD.equalsIgnoreCase(httpMethod); + boolean isProperContentType = contentType != null && multipartValidationPattern.matcher(contentType.toLowerCase(Locale.ENGLISH)).matches(); + + LOG.debug("Validating if this is proper Multipart request. Request is POST: {} and ContentType matches pattern ({}): {}", + isPostRequest, multipartValidationPattern, isProperContentType); + return isPostRequest && isProperContentType; } /** From c3201812754a1426c43ef2b55ff142dc954939c7 Mon Sep 17 00:00:00 2001 From: Lukasz Lenart Date: Wed, 6 Mar 2024 14:35:53 +0100 Subject: [PATCH 10/22] WW-5401 Fixes typo Co-authored-by: Sebastian Peters --- .../src/main/java/org/apache/struts2/dispatcher/Dispatcher.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/src/main/java/org/apache/struts2/dispatcher/Dispatcher.java b/core/src/main/java/org/apache/struts2/dispatcher/Dispatcher.java index fadbc1bd9..b879dad5a 100644 --- a/core/src/main/java/org/apache/struts2/dispatcher/Dispatcher.java +++ b/core/src/main/java/org/apache/struts2/dispatcher/Dispatcher.java @@ -1033,7 +1033,7 @@ public class Dispatcher { boolean isPostRequest = REQUEST_POST_METHOD.equalsIgnoreCase(httpMethod); boolean isProperContentType = contentType != null && multipartValidationPattern.matcher(contentType.toLowerCase(Locale.ENGLISH)).matches(); - LOG.debug("Validating if this is proper Multipart request. Request is POST: {} and ContentType matches pattern ({}): {}", + LOG.debug("Validating if this is a proper Multipart request. Request is POST: {} and ContentType matches pattern ({}): {}", isPostRequest, multipartValidationPattern, isProperContentType); return isPostRequest && isProperContentType; } From ac6c88ad4b63cc874000c711afeb9a638ab03f81 Mon Sep 17 00:00:00 2001 From: Lukasz Lenart Date: Wed, 6 Mar 2024 14:36:11 +0100 Subject: [PATCH 11/22] WW-5401 Uses same message approach Co-authored-by: Sebastian Peters --- .../src/main/java/org/apache/struts2/dispatcher/Dispatcher.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/src/main/java/org/apache/struts2/dispatcher/Dispatcher.java b/core/src/main/java/org/apache/struts2/dispatcher/Dispatcher.java index b879dad5a..5bad0b4fe 100644 --- a/core/src/main/java/org/apache/struts2/dispatcher/Dispatcher.java +++ b/core/src/main/java/org/apache/struts2/dispatcher/Dispatcher.java @@ -986,7 +986,7 @@ public class Dispatcher { public HttpServletRequest wrapRequest(HttpServletRequest request) throws IOException { // don't wrap more than once if (request instanceof StrutsRequestWrapper) { - LOG.debug("Request already wrapped with {}", StrutsRequestWrapper.class.getSimpleName()); + LOG.debug("Request already wrapped with: {}", StrutsRequestWrapper.class.getSimpleName()); return request; } From 29422e47fe9a4aa85edf3c02836de847a3f62ea9 Mon Sep 17 00:00:00 2001 From: Kusal Kithul-Godage Date: Wed, 13 Mar 2024 21:49:27 +1100 Subject: [PATCH 12/22] WW-5364 Fix potential NPE in XmlDocConfigurationProvider --- .../xwork2/config/providers/XmlDocConfigurationProvider.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/core/src/main/java/com/opensymphony/xwork2/config/providers/XmlDocConfigurationProvider.java b/core/src/main/java/com/opensymphony/xwork2/config/providers/XmlDocConfigurationProvider.java index bae553789..cad52fb79 100644 --- a/core/src/main/java/com/opensymphony/xwork2/config/providers/XmlDocConfigurationProvider.java +++ b/core/src/main/java/com/opensymphony/xwork2/config/providers/XmlDocConfigurationProvider.java @@ -142,7 +142,9 @@ public abstract class XmlDocConfigurationProvider implements ConfigurationProvid @Override public void destroy() { - providerAllowlist.clearAllowlist(this); + if (providerAllowlist != null) { + providerAllowlist.clearAllowlist(this); + } } protected Class allowAndLoadClass(String className) throws ClassNotFoundException { From db0bd438551b8c646ede133bebdb5eae899b3cb3 Mon Sep 17 00:00:00 2001 From: Lukasz Lenart Date: Sun, 17 Mar 2024 17:45:32 +0100 Subject: [PATCH 13/22] Converts multiple file uploads example to use Action based upload --- .../MultipleFileUploadUsingArrayAction.java | 82 ++++++++--------- .../MultipleFileUploadUsingListAction.java | 88 +++++++++---------- 2 files changed, 76 insertions(+), 94 deletions(-) diff --git a/apps/showcase/src/main/java/org/apache/struts2/showcase/fileupload/MultipleFileUploadUsingArrayAction.java b/apps/showcase/src/main/java/org/apache/struts2/showcase/fileupload/MultipleFileUploadUsingArrayAction.java index dcf671e5e..59ea954e2 100644 --- a/apps/showcase/src/main/java/org/apache/struts2/showcase/fileupload/MultipleFileUploadUsingArrayAction.java +++ b/apps/showcase/src/main/java/org/apache/struts2/showcase/fileupload/MultipleFileUploadUsingArrayAction.java @@ -22,61 +22,51 @@ 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; /** * Showcase action - mutiple file upload using array. - * - * @version $Date$ $Id$ */ -public class MultipleFileUploadUsingArrayAction extends ActionSupport { +public class MultipleFileUploadUsingArrayAction extends ActionSupport implements UploadedFilesAware { - private File[] uploads = new File[0]; - private String[] uploadFileNames = new String[0]; - private String[] uploadContentTypes = new String[0]; + private List uploadedFiles; + public String upload() throws Exception { + System.out.println("\n\n upload2"); + System.out.println("files:"); + for (UploadedFile u : uploadedFiles) { + System.out.println("*** " + u + "\t" + u.length()); + } + System.out.println("filenames:"); + for (String n : getUploadFileNames()) { + System.out.println("*** " + n); + } + System.out.println("content types:"); + for (String c : getUploadContentTypes()) { + System.out.println("*** " + c); + } + System.out.println("\n\n"); + return SUCCESS; + } - public String upload() throws Exception { - System.out.println("\n\n upload2"); - System.out.println("files:"); - for (File u : uploads) { - System.out.println("*** " + u + "\t" + u.length()); - } - System.out.println("filenames:"); - for (String n : uploadFileNames) { - System.out.println("*** " + n); - } - System.out.println("content types:"); - for (String c : uploadContentTypes) { - System.out.println("*** " + c); - } - System.out.println("\n\n"); - return SUCCESS; - } + @Override + public void withUploadedFiles(List uploadedFiles) { + this.uploadedFiles = uploadedFiles; + } - public File[] getUpload() { - return this.uploads; - } + private String[] getUploadFileNames() { + return this.uploadedFiles.stream() + .map(UploadedFile::getOriginalName) + .toArray(String[]::new); + } - public void setUpload(File[] upload) { - this.uploads = upload; - } + private String[] getUploadContentTypes() { + return this.uploadedFiles.stream() + .map(UploadedFile::getContentType) + .toArray(String[]::new); + } - public String[] getUploadFileName() { - return this.uploadFileNames; - } - - public void setUploadFileName(String[] uploadFileName) { - this.uploadFileNames = uploadFileName; - } - - public String[] getUploadContentType() { - return this.uploadContentTypes; - } - - public void setUploadContentType(String[] uploadContentType) { - this.uploadContentTypes = uploadContentType; - } } -// END SNIPPET: entire-file \ No newline at end of file diff --git a/apps/showcase/src/main/java/org/apache/struts2/showcase/fileupload/MultipleFileUploadUsingListAction.java b/apps/showcase/src/main/java/org/apache/struts2/showcase/fileupload/MultipleFileUploadUsingListAction.java index 7b4325e98..e60b0df3e 100644 --- a/apps/showcase/src/main/java/org/apache/struts2/showcase/fileupload/MultipleFileUploadUsingListAction.java +++ b/apps/showcase/src/main/java/org/apache/struts2/showcase/fileupload/MultipleFileUploadUsingListAction.java @@ -22,64 +22,56 @@ 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.ArrayList; import java.util.List; +import java.util.stream.Collectors; /** * Showcase action - multiple file upload using List - * - * @version $Date$ $Id$ */ -public class MultipleFileUploadUsingListAction extends ActionSupport { +public class MultipleFileUploadUsingListAction extends ActionSupport implements UploadedFilesAware { - private List uploads = new ArrayList<>(); - private List uploadFileNames = new ArrayList<>(); - private List uploadContentTypes = new ArrayList<>(); + private List uploads = new ArrayList<>(); + public List getUpload() { + return this.uploads; + } - public List getUpload() { - return this.uploads; - } + @Override + public void withUploadedFiles(List uploads) { + this.uploads = uploads; + } - public void setUpload(List uploads) { - this.uploads = uploads; - } + private List getUploadFileNames() { + return this.uploads.stream() + .map(UploadedFile::getOriginalName) + .collect(Collectors.toList()); + } - public List getUploadFileName() { - return this.uploadFileNames; - } + private List getUploadContentTypes() { + return this.uploads.stream() + .map(UploadedFile::getContentType) + .collect(Collectors.toList()); + } - public void setUploadFileName(List uploadFileNames) { - this.uploadFileNames = uploadFileNames; - } - - public List getUploadContentType() { - return this.uploadContentTypes; - } - - public void setUploadContentType(List contentTypes) { - this.uploadContentTypes = contentTypes; - } - - public String upload() throws Exception { - - System.out.println("\n\n upload1"); - System.out.println("files:"); - for (File u : uploads) { - System.out.println("*** " + u + "\t" + u.length()); - } - System.out.println("filenames:"); - for (String n : uploadFileNames) { - System.out.println("*** " + n); - } - System.out.println("content types:"); - for (String c : uploadContentTypes) { - System.out.println("*** " + c); - } - System.out.println("\n\n"); - return SUCCESS; - } -} -// END SNIPPET: entire-file \ No newline at end of file + public String upload() throws Exception { + System.out.println("\n\n upload1"); + System.out.println("files:"); + for (UploadedFile u : uploads) { + System.out.println("*** " + u + "\t" + u.length()); + } + System.out.println("filenames:"); + for (String n : getUploadFileNames()) { + System.out.println("*** " + n); + } + System.out.println("content types:"); + for (String c : getUploadContentTypes()) { + System.out.println("*** " + c); + } + System.out.println("\n\n"); + return SUCCESS; + } +} \ No newline at end of file From cda2a2b2310c72913f626cb3ecd14014cb4e378b Mon Sep 17 00:00:00 2001 From: Kusal Kithul-Godage Date: Wed, 27 Mar 2024 18:41:24 +1100 Subject: [PATCH 14/22] WW-5251 Reinstate deleted interfaces with transparent compat --- .../struts2/interceptor/ApplicationAware.java | 32 +++++++++++++++++ .../interceptor/HttpParametersAware.java | 32 +++++++++++++++++ .../struts2/interceptor/ParameterAware.java | 34 +++++++++++++++++++ .../struts2/interceptor/PrincipalAware.java | 30 ++++++++++++++++ .../interceptor/ServletRequestAware.java | 32 +++++++++++++++++ .../interceptor/ServletResponseAware.java | 32 +++++++++++++++++ .../struts2/interceptor/SessionAware.java | 32 +++++++++++++++++ .../struts2/util/ServletContextAware.java | 32 +++++++++++++++++ .../interceptor/PortletContextAware.java | 32 +++++++++++++++++ .../interceptor/PortletPreferencesAware.java | 32 +++++++++++++++++ .../interceptor/PortletRequestAware.java | 32 +++++++++++++++++ .../interceptor/PortletResponseAware.java | 32 +++++++++++++++++ 12 files changed, 384 insertions(+) create mode 100644 core/src/main/java/org/apache/struts2/interceptor/ApplicationAware.java create mode 100644 core/src/main/java/org/apache/struts2/interceptor/HttpParametersAware.java create mode 100644 core/src/main/java/org/apache/struts2/interceptor/ParameterAware.java create mode 100644 core/src/main/java/org/apache/struts2/interceptor/PrincipalAware.java create mode 100644 core/src/main/java/org/apache/struts2/interceptor/ServletRequestAware.java create mode 100644 core/src/main/java/org/apache/struts2/interceptor/ServletResponseAware.java create mode 100644 core/src/main/java/org/apache/struts2/interceptor/SessionAware.java create mode 100644 core/src/main/java/org/apache/struts2/util/ServletContextAware.java create mode 100644 plugins/portlet/src/main/java/org/apache/struts2/portlet/interceptor/PortletContextAware.java create mode 100644 plugins/portlet/src/main/java/org/apache/struts2/portlet/interceptor/PortletPreferencesAware.java create mode 100644 plugins/portlet/src/main/java/org/apache/struts2/portlet/interceptor/PortletRequestAware.java create mode 100644 plugins/portlet/src/main/java/org/apache/struts2/portlet/interceptor/PortletResponseAware.java diff --git a/core/src/main/java/org/apache/struts2/interceptor/ApplicationAware.java b/core/src/main/java/org/apache/struts2/interceptor/ApplicationAware.java new file mode 100644 index 000000000..166f484c9 --- /dev/null +++ b/core/src/main/java/org/apache/struts2/interceptor/ApplicationAware.java @@ -0,0 +1,32 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.struts2.interceptor; + +import java.util.Map; + +@Deprecated +public interface ApplicationAware extends org.apache.struts2.action.ApplicationAware { + + void setApplication(Map application); + + @Override + default void withApplication(Map application) { + setApplication(application); + } +} diff --git a/core/src/main/java/org/apache/struts2/interceptor/HttpParametersAware.java b/core/src/main/java/org/apache/struts2/interceptor/HttpParametersAware.java new file mode 100644 index 000000000..1c4b758f7 --- /dev/null +++ b/core/src/main/java/org/apache/struts2/interceptor/HttpParametersAware.java @@ -0,0 +1,32 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.struts2.interceptor; + +import org.apache.struts2.dispatcher.HttpParameters; + +@Deprecated +public interface HttpParametersAware extends org.apache.struts2.action.ParametersAware { + + void setParameters(HttpParameters parameters); + + @Override + default void withParameters(HttpParameters parameters) { + setParameters(parameters); + } +} diff --git a/core/src/main/java/org/apache/struts2/interceptor/ParameterAware.java b/core/src/main/java/org/apache/struts2/interceptor/ParameterAware.java new file mode 100644 index 000000000..13656436b --- /dev/null +++ b/core/src/main/java/org/apache/struts2/interceptor/ParameterAware.java @@ -0,0 +1,34 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.struts2.interceptor; + +import org.apache.struts2.dispatcher.HttpParameters; + +import java.util.Map; + +@Deprecated +public interface ParameterAware extends org.apache.struts2.action.ParametersAware { + + void setParameters(Map map); + + @Override + default void withParameters(HttpParameters parameters) { + setParameters(parameters); + } +} diff --git a/core/src/main/java/org/apache/struts2/interceptor/PrincipalAware.java b/core/src/main/java/org/apache/struts2/interceptor/PrincipalAware.java new file mode 100644 index 000000000..dfe4203ff --- /dev/null +++ b/core/src/main/java/org/apache/struts2/interceptor/PrincipalAware.java @@ -0,0 +1,30 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.struts2.interceptor; + +@Deprecated +public interface PrincipalAware extends org.apache.struts2.action.PrincipalAware { + + void setPrincipalProxy(PrincipalProxy principalProxy); + + @Override + default void withPrincipalProxy(PrincipalProxy principalProxy) { + setPrincipalProxy(principalProxy); + } +} diff --git a/core/src/main/java/org/apache/struts2/interceptor/ServletRequestAware.java b/core/src/main/java/org/apache/struts2/interceptor/ServletRequestAware.java new file mode 100644 index 000000000..f02ac90d1 --- /dev/null +++ b/core/src/main/java/org/apache/struts2/interceptor/ServletRequestAware.java @@ -0,0 +1,32 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.struts2.interceptor; + +import javax.servlet.http.HttpServletRequest; + +@Deprecated +public interface ServletRequestAware extends org.apache.struts2.action.ServletRequestAware { + + void setServletRequest(HttpServletRequest httpServletRequest); + + @Override + default void withServletRequest(HttpServletRequest request) { + setServletRequest(request); + } +} diff --git a/core/src/main/java/org/apache/struts2/interceptor/ServletResponseAware.java b/core/src/main/java/org/apache/struts2/interceptor/ServletResponseAware.java new file mode 100644 index 000000000..d252621fe --- /dev/null +++ b/core/src/main/java/org/apache/struts2/interceptor/ServletResponseAware.java @@ -0,0 +1,32 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.struts2.interceptor; + +import javax.servlet.http.HttpServletResponse; + +@Deprecated +public interface ServletResponseAware extends org.apache.struts2.action.ServletResponseAware { + + void setServletResponse(HttpServletResponse httpServletResponse); + + @Override + default void withServletResponse(HttpServletResponse response) { + setServletResponse(response); + } +} diff --git a/core/src/main/java/org/apache/struts2/interceptor/SessionAware.java b/core/src/main/java/org/apache/struts2/interceptor/SessionAware.java new file mode 100644 index 000000000..828284d53 --- /dev/null +++ b/core/src/main/java/org/apache/struts2/interceptor/SessionAware.java @@ -0,0 +1,32 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.struts2.interceptor; + +import java.util.Map; + +@Deprecated +public interface SessionAware extends org.apache.struts2.action.SessionAware { + + void setSession(Map session); + + @Override + default void withSession(Map session) { + setSession(session); + } +} diff --git a/core/src/main/java/org/apache/struts2/util/ServletContextAware.java b/core/src/main/java/org/apache/struts2/util/ServletContextAware.java new file mode 100644 index 000000000..c17bd9a7e --- /dev/null +++ b/core/src/main/java/org/apache/struts2/util/ServletContextAware.java @@ -0,0 +1,32 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.struts2.util; + +import javax.servlet.ServletContext; + +@Deprecated +public interface ServletContextAware extends org.apache.struts2.action.ServletContextAware { + + void setServletContext(ServletContext context); + + @Override + default void withServletContext(ServletContext context) { + setServletContext(context); + } +} diff --git a/plugins/portlet/src/main/java/org/apache/struts2/portlet/interceptor/PortletContextAware.java b/plugins/portlet/src/main/java/org/apache/struts2/portlet/interceptor/PortletContextAware.java new file mode 100644 index 000000000..67e360a39 --- /dev/null +++ b/plugins/portlet/src/main/java/org/apache/struts2/portlet/interceptor/PortletContextAware.java @@ -0,0 +1,32 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.struts2.portlet.interceptor; + +import javax.portlet.PortletContext; + +@Deprecated +public interface PortletContextAware extends org.apache.struts2.portlet.action.PortletContextAware { + + void setPortletContext(PortletContext portletContext); + + @Override + default void withPortletContext(PortletContext context) { + setPortletContext(context); + } +} diff --git a/plugins/portlet/src/main/java/org/apache/struts2/portlet/interceptor/PortletPreferencesAware.java b/plugins/portlet/src/main/java/org/apache/struts2/portlet/interceptor/PortletPreferencesAware.java new file mode 100644 index 000000000..fae552c91 --- /dev/null +++ b/plugins/portlet/src/main/java/org/apache/struts2/portlet/interceptor/PortletPreferencesAware.java @@ -0,0 +1,32 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.struts2.portlet.interceptor; + +import javax.portlet.PortletPreferences; + +@Deprecated +public interface PortletPreferencesAware extends org.apache.struts2.portlet.action.PortletPreferencesAware { + + void setPortletPreferences(PortletPreferences prefs); + + @Override + default void withPortletPreferences(PortletPreferences prefs) { + setPortletPreferences(prefs); + } +} diff --git a/plugins/portlet/src/main/java/org/apache/struts2/portlet/interceptor/PortletRequestAware.java b/plugins/portlet/src/main/java/org/apache/struts2/portlet/interceptor/PortletRequestAware.java new file mode 100644 index 000000000..5565ecf70 --- /dev/null +++ b/plugins/portlet/src/main/java/org/apache/struts2/portlet/interceptor/PortletRequestAware.java @@ -0,0 +1,32 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.struts2.portlet.interceptor; + +import javax.portlet.PortletRequest; + +@Deprecated +public interface PortletRequestAware extends org.apache.struts2.portlet.action.PortletRequestAware { + + void setPortletRequest(PortletRequest request); + + @Override + default void withPortletRequest(PortletRequest request) { + setPortletRequest(request); + } +} diff --git a/plugins/portlet/src/main/java/org/apache/struts2/portlet/interceptor/PortletResponseAware.java b/plugins/portlet/src/main/java/org/apache/struts2/portlet/interceptor/PortletResponseAware.java new file mode 100644 index 000000000..8f9641936 --- /dev/null +++ b/plugins/portlet/src/main/java/org/apache/struts2/portlet/interceptor/PortletResponseAware.java @@ -0,0 +1,32 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.struts2.portlet.interceptor; + +import javax.portlet.PortletResponse; + +@Deprecated +public interface PortletResponseAware extends org.apache.struts2.portlet.action.PortletResponseAware { + + void setPortletResponse(PortletResponse response); + + @Override + default void withPortletResponse(PortletResponse response) { + setPortletResponse(response); + } +} From 19698e1fd2d0f1052a4d7fc3f45641d6c6cf9e05 Mon Sep 17 00:00:00 2001 From: Kusal Kithul-Godage Date: Fri, 29 Mar 2024 21:01:35 +1100 Subject: [PATCH 15/22] WW-5251 Fix ParameterAware --- .../java/org/apache/struts2/interceptor/ParameterAware.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/core/src/main/java/org/apache/struts2/interceptor/ParameterAware.java b/core/src/main/java/org/apache/struts2/interceptor/ParameterAware.java index 13656436b..576950126 100644 --- a/core/src/main/java/org/apache/struts2/interceptor/ParameterAware.java +++ b/core/src/main/java/org/apache/struts2/interceptor/ParameterAware.java @@ -22,6 +22,8 @@ import org.apache.struts2.dispatcher.HttpParameters; import java.util.Map; +import static java.util.stream.Collectors.toMap; + @Deprecated public interface ParameterAware extends org.apache.struts2.action.ParametersAware { @@ -29,6 +31,6 @@ public interface ParameterAware extends org.apache.struts2.action.ParametersAwar @Override default void withParameters(HttpParameters parameters) { - setParameters(parameters); + setParameters(parameters.entrySet().stream().collect(toMap(Map.Entry::getKey, e -> e.getValue().getMultipleValues()))); } } From dc774c484f1434c91905e3f0c8f34ad0205ce45e Mon Sep 17 00:00:00 2001 From: Kusal Kithul-Godage Date: Fri, 29 Mar 2024 21:35:08 +1100 Subject: [PATCH 16/22] WW-5251 Reinstate RequestAware --- .../struts2/interceptor/RequestAware.java | 41 +++++++++++++++++++ 1 file changed, 41 insertions(+) create mode 100644 core/src/main/java/org/apache/struts2/interceptor/RequestAware.java diff --git a/core/src/main/java/org/apache/struts2/interceptor/RequestAware.java b/core/src/main/java/org/apache/struts2/interceptor/RequestAware.java new file mode 100644 index 000000000..822f9ca45 --- /dev/null +++ b/core/src/main/java/org/apache/struts2/interceptor/RequestAware.java @@ -0,0 +1,41 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.struts2.interceptor; + +import org.apache.struts2.dispatcher.RequestMap; + +import javax.servlet.http.HttpServletRequest; +import java.util.Map; + +@Deprecated +public interface RequestAware extends ServletRequestAware { + + @Override + default void setServletRequest(HttpServletRequest httpServletRequest) { + // default no-op + } + + @Override + default void withServletRequest(HttpServletRequest request) { + ServletRequestAware.super.withServletRequest(request); + setRequest(new RequestMap(request)); + } + + void setRequest(Map request); +} From 6950fcb75f68834fc913cba78c427f10a31cc402 Mon Sep 17 00:00:00 2001 From: Lukasz Lenart Date: Sat, 30 Mar 2024 08:36:50 +0100 Subject: [PATCH 17/22] Enables required review by codeowners --- .asf.yaml | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/.asf.yaml b/.asf.yaml index 673c6e25c..ed31174c3 100644 --- a/.asf.yaml +++ b/.asf.yaml @@ -13,7 +13,13 @@ notifications: github: del_branch_on_merge: true protected_branches: - master: { } + master: + # contexts are the names of checks that must pass. + contexts: + - Java Maven / Build and Test + required_pull_request_reviews: + require_code_owner_reviews: true + required_approving_review_count: 1 autolink_jira: - WW dependabot_alerts: true From 93c11aaf6208da460d1a393e6feb998a18e13e3c Mon Sep 17 00:00:00 2001 From: Kusal Kithul-Godage Date: Sun, 31 Mar 2024 00:10:39 +1100 Subject: [PATCH 18/22] WW-5251 Fix deprecated interface method signature --- .../java/org/apache/struts2/interceptor/ParameterAware.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/src/main/java/org/apache/struts2/interceptor/ParameterAware.java b/core/src/main/java/org/apache/struts2/interceptor/ParameterAware.java index 576950126..561542376 100644 --- a/core/src/main/java/org/apache/struts2/interceptor/ParameterAware.java +++ b/core/src/main/java/org/apache/struts2/interceptor/ParameterAware.java @@ -27,7 +27,7 @@ import static java.util.stream.Collectors.toMap; @Deprecated public interface ParameterAware extends org.apache.struts2.action.ParametersAware { - void setParameters(Map map); + void setParameters(Map map); @Override default void withParameters(HttpParameters parameters) { From 273c3a1a998c5933370cb3346a72c9935c2063db Mon Sep 17 00:00:00 2001 From: Lukasz Lenart Date: Sun, 31 Mar 2024 11:36:49 +0200 Subject: [PATCH 19/22] Uses proper context name in branch protection rule --- .asf.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.asf.yaml b/.asf.yaml index ed31174c3..87706aa57 100644 --- a/.asf.yaml +++ b/.asf.yaml @@ -16,7 +16,7 @@ github: master: # contexts are the names of checks that must pass. contexts: - - Java Maven / Build and Test + - build required_pull_request_reviews: require_code_owner_reviews: true required_approving_review_count: 1 From c7ae614824b4c158b9998575294d94fe9a746c41 Mon Sep 17 00:00:00 2001 From: Lukasz Lenart Date: Sun, 24 Mar 2024 11:29:12 +0100 Subject: [PATCH 20/22] WW-5402 Auto loads Tiles definitions from classpath --- plugins/tiles/pom.xml | 3 - .../tiles/StrutsTilesContainerFactory.java | 28 +++- .../StrutsTilesContainerFactoryTest.java | 128 ++++++++++++++++++ 3 files changed, 149 insertions(+), 10 deletions(-) create mode 100644 plugins/tiles/src/test/java/org/apache/struts2/tiles/StrutsTilesContainerFactoryTest.java diff --git a/plugins/tiles/pom.xml b/plugins/tiles/pom.xml index 440f6ee79..1a6caf2c1 100644 --- a/plugins/tiles/pom.xml +++ b/plugins/tiles/pom.xml @@ -35,9 +35,6 @@ build-autotags - - true - diff --git a/plugins/tiles/src/main/java/org/apache/struts2/tiles/StrutsTilesContainerFactory.java b/plugins/tiles/src/main/java/org/apache/struts2/tiles/StrutsTilesContainerFactory.java index 205476467..ed03f8268 100644 --- a/plugins/tiles/src/main/java/org/apache/struts2/tiles/StrutsTilesContainerFactory.java +++ b/plugins/tiles/src/main/java/org/apache/struts2/tiles/StrutsTilesContainerFactory.java @@ -25,11 +25,6 @@ import ognl.PropertyAccessor; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; import org.apache.tiles.api.TilesContainer; -import org.apache.tiles.request.ApplicationContext; -import org.apache.tiles.request.ApplicationResource; -import org.apache.tiles.request.Request; -import org.apache.tiles.request.render.BasicRendererFactory; -import org.apache.tiles.request.render.ChainedDelegateRenderer; import org.apache.tiles.core.definition.DefinitionsFactory; import org.apache.tiles.core.definition.pattern.DefinitionPatternMatcherFactory; import org.apache.tiles.core.definition.pattern.PatternDefinitionResolver; @@ -57,6 +52,11 @@ import org.apache.tiles.ognl.PropertyAccessorDelegateFactory; import org.apache.tiles.ognl.ScopePropertyAccessor; import org.apache.tiles.ognl.TilesApplicationContextNestedObjectExtractor; import org.apache.tiles.ognl.TilesContextPropertyAccessorDelegateFactory; +import org.apache.tiles.request.ApplicationContext; +import org.apache.tiles.request.ApplicationResource; +import org.apache.tiles.request.Request; +import org.apache.tiles.request.render.BasicRendererFactory; +import org.apache.tiles.request.render.ChainedDelegateRenderer; import org.apache.tiles.request.render.Renderer; import javax.el.ArrayELResolver; @@ -68,7 +68,10 @@ import javax.el.MapELResolver; import javax.el.ResourceBundleELResolver; import javax.servlet.jsp.JspFactory; import java.util.ArrayList; +import java.util.Arrays; import java.util.Collection; +import java.util.Collections; +import java.util.HashSet; import java.util.List; import java.util.Locale; import java.util.Map; @@ -102,8 +105,19 @@ public class StrutsTilesContainerFactory extends BasicTilesContainerFactory { /** * Default pattern to be used to collect Tiles definitions if user didn't configure any + * + * @deprecated since Struts 6.4.0, use {@link #TILES_DEFAULT_PATTERNS} instead */ - public static final String TILES_DEFAULT_PATTERN = "tiles*.xml"; + @Deprecated + public static final String TILES_DEFAULT_PATTERN = "/WEB-INF/**/tiles*.xml,classpath*:META-INF/**/tiles*.xml"; + + /** + * Default pattern to be used to collect Tiles definitions if user didn't configure any + */ + public static final Set TILES_DEFAULT_PATTERNS = Collections.unmodifiableSet(new HashSet<>(Arrays.asList( + "/WEB-INF/**/tiles*.xml", + "classpath*:META-INF/**/tiles*.xml" + ))); /** * Supported expression languages @@ -213,7 +227,7 @@ public class StrutsTilesContainerFactory extends BasicTilesContainerFactory { if (params.containsKey(DefinitionsFactory.DEFINITIONS_CONFIG)) { return TextParseUtil.commaDelimitedStringToSet(params.get(DefinitionsFactory.DEFINITIONS_CONFIG)); } - return TextParseUtil.commaDelimitedStringToSet(TILES_DEFAULT_PATTERN); + return TILES_DEFAULT_PATTERNS; } protected ELAttributeEvaluator createELEvaluator(ApplicationContext applicationContext) { diff --git a/plugins/tiles/src/test/java/org/apache/struts2/tiles/StrutsTilesContainerFactoryTest.java b/plugins/tiles/src/test/java/org/apache/struts2/tiles/StrutsTilesContainerFactoryTest.java new file mode 100644 index 000000000..122bfe51d --- /dev/null +++ b/plugins/tiles/src/test/java/org/apache/struts2/tiles/StrutsTilesContainerFactoryTest.java @@ -0,0 +1,128 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.struts2.tiles; + +import org.apache.tiles.api.TilesContainer; +import org.apache.tiles.core.evaluator.AttributeEvaluatorFactory; +import org.apache.tiles.core.evaluator.impl.DirectAttributeEvaluator; +import org.apache.tiles.core.locale.LocaleResolver; +import org.apache.tiles.core.prepare.factory.BasicPreparerFactory; +import org.apache.tiles.core.prepare.factory.PreparerFactory; +import org.apache.tiles.ognl.OGNLAttributeEvaluator; +import org.apache.tiles.request.ApplicationContext; +import org.apache.tiles.request.ApplicationResource; +import org.apache.tiles.request.locale.URLApplicationResource; +import org.apache.tiles.request.render.BasicRendererFactory; +import org.apache.tiles.request.render.ChainedDelegateRenderer; +import org.apache.tiles.request.render.Renderer; +import org.junit.Before; +import org.junit.Test; + +import javax.servlet.ServletContext; +import javax.servlet.jsp.JspFactory; +import java.util.Collections; +import java.util.List; +import java.util.Objects; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; +import static org.mockito.Mockito.mock; +import static org.mockito.Mockito.verify; +import static org.mockito.Mockito.when; + +public class StrutsTilesContainerFactoryTest { + + private StrutsTilesContainerFactory factory; + private ApplicationContext applicationContext; + + @Before + public void setUp() throws Exception { + applicationContext = mock(ApplicationContext.class); + factory = new StrutsTilesContainerFactory(); + } + + @Test + public void getSources() { + ApplicationResource pathResource = new URLApplicationResource( + "/org/apache/tiles/core/config/tiles-defs.xml", + Objects.requireNonNull(getClass().getResource("/org/apache/tiles/core/config/tiles-defs.xml")) + ); + ApplicationResource classpathResource = new URLApplicationResource( + "/org/apache/tiles/core/config/defs1.xml", + Objects.requireNonNull(getClass().getResource("/org/apache/tiles/core/config/defs1.xml")) + ); + when(applicationContext.getInitParams()).thenReturn(Collections.emptyMap()); + when(applicationContext.getResources("/WEB-INF/**/tiles*.xml")).thenReturn(Collections.singleton(pathResource)); + when(applicationContext.getResources("classpath*:META-INF/**/tiles*.xml")).thenReturn(Collections.singleton(classpathResource)); + + List resources = factory.getSources(applicationContext); + assertEquals("The urls list is not two-sized", 2, resources.size()); + assertEquals("The URL is not correct", pathResource, resources.get(0)); + assertEquals("The URL is not correct", classpathResource, resources.get(1)); + } + + @Test + public void createAttributeEvaluatorFactory() { + LocaleResolver resolver = factory.createLocaleResolver(applicationContext); + // explicitly disables support for EL + JspFactory.setDefaultFactory(null); + + AttributeEvaluatorFactory attributeEvaluatorFactory = factory.createAttributeEvaluatorFactory(applicationContext, resolver); + assertTrue("The class of the evaluator is not correct", + attributeEvaluatorFactory.getAttributeEvaluator((String) null) instanceof DirectAttributeEvaluator); + assertTrue("The class of the evaluator is not correct", + attributeEvaluatorFactory.getAttributeEvaluator("S2") instanceof StrutsAttributeEvaluator); + assertTrue("The class of the evaluator is not correct", + attributeEvaluatorFactory.getAttributeEvaluator("OGNL") instanceof OGNLAttributeEvaluator); + assertTrue("The class of the evaluator is not correct", + attributeEvaluatorFactory.getAttributeEvaluator("I18N") instanceof I18NAttributeEvaluator); + assertTrue("The class of the evaluator is not correct", + attributeEvaluatorFactory.getAttributeEvaluator("EL") instanceof DirectAttributeEvaluator); + } + + @Test + public void createPreparerFactory() { + PreparerFactory preparerFactory = factory.createPreparerFactory(applicationContext); + assertTrue("The class of the preparer factory is not correct", preparerFactory instanceof BasicPreparerFactory); + } + + @Test + public void createDefaultAttributeRenderer() { + TilesContainer container = mock(TilesContainer.class); + AttributeEvaluatorFactory attributeEvaluatorFactory = mock(AttributeEvaluatorFactory.class); + BasicRendererFactory rendererFactory = mock(BasicRendererFactory.class); + Renderer stringRenderer = mock(Renderer.class); + Renderer templateRenderer = mock(Renderer.class); + Renderer definitionRenderer = mock(Renderer.class); + + when(rendererFactory.getRenderer("string")).thenReturn(stringRenderer); + when(rendererFactory.getRenderer("template")).thenReturn(templateRenderer); + when(rendererFactory.getRenderer("definition")).thenReturn(definitionRenderer); + when(rendererFactory.getRenderer("freemarker")).thenReturn(definitionRenderer); + + Renderer renderer = factory.createDefaultAttributeRenderer(rendererFactory, applicationContext, container, attributeEvaluatorFactory); + + assertTrue("The default renderer class is not correct", renderer instanceof ChainedDelegateRenderer); + verify(rendererFactory).getRenderer("string"); + verify(rendererFactory).getRenderer("template"); + verify(rendererFactory).getRenderer("definition"); + verify(rendererFactory).getRenderer("freemarker"); + } + +} \ No newline at end of file From 7a79576bb3228a80c709791b0a737899675ba0fd Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Thu, 4 Apr 2024 10:01:09 +0000 Subject: [PATCH 21/22] Bump log4j2.version from 2.21.1 to 2.23.1 Bumps `log4j2.version` from 2.21.1 to 2.23.1. Updates `org.apache.logging.log4j:log4j-api` from 2.21.1 to 2.23.1 Updates `org.apache.logging.log4j:log4j-core` from 2.21.1 to 2.23.1 Updates `org.apache.logging.log4j:log4j-jcl` from 2.21.1 to 2.23.1 Updates `org.apache.logging.log4j:log4j-slf4j-impl` from 2.21.1 to 2.23.1 --- updated-dependencies: - dependency-name: org.apache.logging.log4j:log4j-api dependency-type: direct:production update-type: version-update:semver-minor - dependency-name: org.apache.logging.log4j:log4j-core dependency-type: direct:production update-type: version-update:semver-minor - dependency-name: org.apache.logging.log4j:log4j-jcl dependency-type: direct:development update-type: version-update:semver-minor - dependency-name: org.apache.logging.log4j:log4j-slf4j-impl dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index a09266870..418017057 100644 --- a/pom.xml +++ b/pom.xml @@ -111,7 +111,7 @@ 9.6 2.16.1 - 2.21.1 + 2.23.1 3.3.4 2.0.12 5.3.31 From db725518ee82158acb422bee414d0b6fd2bac540 Mon Sep 17 00:00:00 2001 From: Lukasz Lenart Date: Sat, 6 Apr 2024 19:36:14 +0200 Subject: [PATCH 22/22] WW-5390 Fixes creating assembly and attaching sources when preparing a new release --- pom.xml | 25 ++++++++++++------------- 1 file changed, 12 insertions(+), 13 deletions(-) diff --git a/pom.xml b/pom.xml index 418017057..79824373b 100644 --- a/pom.xml +++ b/pom.xml @@ -296,14 +296,7 @@ org.apache.maven.plugins maven-source-plugin - - - attach-sources - - jar - - - + 3.3.0 org.apache.rat @@ -358,6 +351,17 @@ true + + org.apache.maven.plugins + maven-assembly-plugin + 3.6.0 + + true + true + assembly/out + assembly/work + + org.apache.maven.plugins maven-enforcer-plugin @@ -388,7 +392,6 @@ org.apache.maven.plugins maven-release-plugin - 3.0.1 @@ -412,10 +415,6 @@ - - org.apache.maven.plugins - maven-source-plugin - org.apache.maven.plugins maven-site-plugin