This is an automated email from the ASF dual-hosted git repository.

kusal pushed a commit to branch WW-5411-delete-deprecated-1
in repository https://gitbox.apache.org/repos/asf/struts.git

commit b73c935a3aa245d087ad4f020e69794d70dbcdb5
Author: Kusal Kithul-Godage <g...@kusal.io>
AuthorDate: Mon Jul 8 18:09:14 2024 +1000

    WW-5411 Delete deprecated Aware marker interfaces
---
 .../struts2/interceptor/ApplicationAware.java      | 32 --------
 .../struts2/interceptor/CookieInterceptor.java     |  5 +-
 .../apache/struts2/interceptor/CookiesAware.java   | 40 ----------
 .../struts2/interceptor/HttpParametersAware.java   | 32 --------
 .../apache/struts2/interceptor/ParameterAware.java | 36 ---------
 .../apache/struts2/interceptor/PrincipalAware.java | 30 --------
 .../apache/struts2/interceptor/RequestAware.java   | 41 ----------
 .../interceptor/ServletConfigInterceptor.java      | 10 +--
 .../struts2/interceptor/ServletRequestAware.java   | 32 --------
 .../struts2/interceptor/ServletResponseAware.java  | 32 --------
 .../apache/struts2/interceptor/SessionAware.java   | 32 --------
 .../struts2/interceptor/CookieInterceptorTest.java | 87 +---------------------
 12 files changed, 10 insertions(+), 399 deletions(-)

diff --git 
a/core/src/main/java/org/apache/struts2/interceptor/ApplicationAware.java 
b/core/src/main/java/org/apache/struts2/interceptor/ApplicationAware.java
deleted file mode 100644
index 166f484c9..000000000
--- a/core/src/main/java/org/apache/struts2/interceptor/ApplicationAware.java
+++ /dev/null
@@ -1,32 +0,0 @@
-/*
- * 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<String, Object> application);
-
-    @Override
-    default void withApplication(Map<String, Object> application) {
-        setApplication(application);
-    }
-}
diff --git 
a/core/src/main/java/org/apache/struts2/interceptor/CookieInterceptor.java 
b/core/src/main/java/org/apache/struts2/interceptor/CookieInterceptor.java
index 650c79f30..9f40efdf1 100644
--- a/core/src/main/java/org/apache/struts2/interceptor/CookieInterceptor.java
+++ b/core/src/main/java/org/apache/struts2/interceptor/CookieInterceptor.java
@@ -26,11 +26,12 @@ import 
com.opensymphony.xwork2.security.AcceptedPatternsChecker;
 import com.opensymphony.xwork2.security.ExcludedPatternsChecker;
 import com.opensymphony.xwork2.util.TextParseUtil;
 import com.opensymphony.xwork2.util.ValueStack;
+import jakarta.servlet.http.Cookie;
 import org.apache.logging.log4j.LogManager;
 import org.apache.logging.log4j.Logger;
 import org.apache.struts2.ServletActionContext;
+import org.apache.struts2.action.CookiesAware;
 
-import jakarta.servlet.http.Cookie;
 import java.util.Collections;
 import java.util.LinkedHashMap;
 import java.util.Map;
@@ -357,7 +358,7 @@ public class CookieInterceptor extends AbstractInterceptor {
     protected void injectIntoCookiesAwareAction(Object action, Map<String, 
String> cookiesMap) {
         if (action instanceof CookiesAware) {
             LOG.debug("Action [{}] implements CookiesAware, injecting cookies 
map [{}]", action, cookiesMap);
-            ((CookiesAware)action).setCookiesMap(cookiesMap);
+            ((CookiesAware)action).withCookies(cookiesMap);
         }
         if (action instanceof org.apache.struts2.action.CookiesAware) {
             LOG.debug("Action [{}] implements CookiesAware, injecting cookies 
map [{}]", action, cookiesMap);
diff --git 
a/core/src/main/java/org/apache/struts2/interceptor/CookiesAware.java 
b/core/src/main/java/org/apache/struts2/interceptor/CookiesAware.java
deleted file mode 100644
index d3a0a02b1..000000000
--- a/core/src/main/java/org/apache/struts2/interceptor/CookiesAware.java
+++ /dev/null
@@ -1,40 +0,0 @@
-/*
- * 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;
-
-/**
- * Actions implementing the CookiesAware interface will receive
- * a Map of filtered cookies via the setCookiesMap method.
- *
- * Please note that the {@link CookieInterceptor} needs to be
- * activated to receive a cookies map.
- *
- * @deprecated please use {@link org.apache.struts2.action.CookiesAware} 
instead
- */
-@Deprecated
-public interface CookiesAware {
-    /**
-     * Sets a map of filtered cookies.
-     * @param cookies the cookies
-     * @deprecated please use {@link 
org.apache.struts2.action.CookiesAware#withCookies(Map)} instead
-     */
-    void setCookiesMap(Map<String, String> cookies);
-}
\ No newline at end of file
diff --git 
a/core/src/main/java/org/apache/struts2/interceptor/HttpParametersAware.java 
b/core/src/main/java/org/apache/struts2/interceptor/HttpParametersAware.java
deleted file mode 100644
index 1c4b758f7..000000000
--- a/core/src/main/java/org/apache/struts2/interceptor/HttpParametersAware.java
+++ /dev/null
@@ -1,32 +0,0 @@
-/*
- * 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
deleted file mode 100644
index 561542376..000000000
--- a/core/src/main/java/org/apache/struts2/interceptor/ParameterAware.java
+++ /dev/null
@@ -1,36 +0,0 @@
-/*
- * 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;
-
-import static java.util.stream.Collectors.toMap;
-
-@Deprecated
-public interface ParameterAware extends 
org.apache.struts2.action.ParametersAware {
-
-    void setParameters(Map<String, String[]> map);
-
-    @Override
-    default void withParameters(HttpParameters parameters) {
-        
setParameters(parameters.entrySet().stream().collect(toMap(Map.Entry::getKey, e 
-> e.getValue().getMultipleValues())));
-    }
-}
diff --git 
a/core/src/main/java/org/apache/struts2/interceptor/PrincipalAware.java 
b/core/src/main/java/org/apache/struts2/interceptor/PrincipalAware.java
deleted file mode 100644
index dfe4203ff..000000000
--- a/core/src/main/java/org/apache/struts2/interceptor/PrincipalAware.java
+++ /dev/null
@@ -1,30 +0,0 @@
-/*
- * 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/RequestAware.java 
b/core/src/main/java/org/apache/struts2/interceptor/RequestAware.java
deleted file mode 100644
index 5e24e8dfb..000000000
--- a/core/src/main/java/org/apache/struts2/interceptor/RequestAware.java
+++ /dev/null
@@ -1,41 +0,0 @@
-/*
- * 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 jakarta.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<String, Object> request);
-}
diff --git 
a/core/src/main/java/org/apache/struts2/interceptor/ServletConfigInterceptor.java
 
b/core/src/main/java/org/apache/struts2/interceptor/ServletConfigInterceptor.java
index e26c1247d..e09e97d67 100644
--- 
a/core/src/main/java/org/apache/struts2/interceptor/ServletConfigInterceptor.java
+++ 
b/core/src/main/java/org/apache/struts2/interceptor/ServletConfigInterceptor.java
@@ -18,10 +18,12 @@
  */
 package org.apache.struts2.interceptor;
 
+import com.opensymphony.xwork2.ActionContext;
+import com.opensymphony.xwork2.ActionInvocation;
+import com.opensymphony.xwork2.interceptor.AbstractInterceptor;
 import jakarta.servlet.ServletContext;
 import jakarta.servlet.http.HttpServletRequest;
 import jakarta.servlet.http.HttpServletResponse;
-
 import org.apache.struts2.StrutsStatics;
 import org.apache.struts2.action.ApplicationAware;
 import org.apache.struts2.action.ParametersAware;
@@ -32,15 +34,11 @@ import org.apache.struts2.action.ServletResponseAware;
 import org.apache.struts2.action.SessionAware;
 import org.apache.struts2.interceptor.servlet.ServletPrincipalProxy;
 
-import com.opensymphony.xwork2.ActionContext;
-import com.opensymphony.xwork2.ActionInvocation;
-import com.opensymphony.xwork2.interceptor.AbstractInterceptor;
-
 /**
  * <!-- START SNIPPET: description -->
  * <p>
  * An interceptor which sets action properties based on the interfaces an 
action implements. For example, if the action
- * implements {@link ParameterAware} then the action context's parameter map 
will be set on it.
+ * implements {@link ParametersAware} then the action context's parameter map 
will be set on it.
  * </p>
  *
  * <p>This interceptor is designed to set all properties an action needs if 
it's aware of servlet parameters, the
diff --git 
a/core/src/main/java/org/apache/struts2/interceptor/ServletRequestAware.java 
b/core/src/main/java/org/apache/struts2/interceptor/ServletRequestAware.java
deleted file mode 100644
index 8f059d479..000000000
--- a/core/src/main/java/org/apache/struts2/interceptor/ServletRequestAware.java
+++ /dev/null
@@ -1,32 +0,0 @@
-/*
- * 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 jakarta.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
deleted file mode 100644
index de054878a..000000000
--- 
a/core/src/main/java/org/apache/struts2/interceptor/ServletResponseAware.java
+++ /dev/null
@@ -1,32 +0,0 @@
-/*
- * 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 jakarta.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
deleted file mode 100644
index 828284d53..000000000
--- a/core/src/main/java/org/apache/struts2/interceptor/SessionAware.java
+++ /dev/null
@@ -1,32 +0,0 @@
-/*
- * 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<String, Object> session);
-
-    @Override
-    default void withSession(Map<String, Object> session) {
-        setSession(session);
-    }
-}
diff --git 
a/core/src/test/java/org/apache/struts2/interceptor/CookieInterceptorTest.java 
b/core/src/test/java/org/apache/struts2/interceptor/CookieInterceptorTest.java
index ab4fdaf84..3cd0e57ab 100644
--- 
a/core/src/test/java/org/apache/struts2/interceptor/CookieInterceptorTest.java
+++ 
b/core/src/test/java/org/apache/struts2/interceptor/CookieInterceptorTest.java
@@ -25,11 +25,12 @@ import com.opensymphony.xwork2.ActionSupport;
 import com.opensymphony.xwork2.mock.MockActionInvocation;
 import com.opensymphony.xwork2.security.DefaultAcceptedPatternsChecker;
 import com.opensymphony.xwork2.security.DefaultExcludedPatternsChecker;
+import jakarta.servlet.http.Cookie;
 import org.apache.struts2.ServletActionContext;
 import org.apache.struts2.StrutsInternalTestCase;
+import org.apache.struts2.action.CookiesAware;
 import org.springframework.mock.web.MockHttpServletRequest;
 
-import jakarta.servlet.http.Cookie;
 import java.util.Collections;
 import java.util.HashMap;
 import java.util.Map;
@@ -451,49 +452,6 @@ public class CookieInterceptorTest extends 
StrutsInternalTestCase {
         assertFalse(excludedName.get(reqCookieName));
     }
 
-    public void testActionCookieAwareWithStrutsInternalsAccess() throws 
Exception {
-        MockHttpServletRequest request = new MockHttpServletRequest();
-        String sessionCookieName = "session.userId";
-        String sessionCookieValue = "session.userId=1";
-        String appCookieName = "application.userId";
-        String appCookieValue = "application.userId=1";
-        String reqCookieName = "request.userId";
-        String reqCookieValue = "request.userId=1";
-
-        request.setCookies(
-            new Cookie(sessionCookieName, "1"),
-            new Cookie("1", sessionCookieValue),
-            new Cookie(appCookieName, "1"),
-            new Cookie("1", appCookieValue),
-            new Cookie(reqCookieName, "1"),
-            new Cookie("1", reqCookieValue)
-        );
-        ServletActionContext.setRequest(request);
-
-        final Map<String, Boolean> excludedName = new HashMap<>();
-
-        CookieInterceptor interceptor = new CookieInterceptor() {
-            @Override
-            protected boolean isAcceptableName(String name) {
-                boolean accepted = super.isAcceptableName(name);
-                excludedName.put(name, accepted);
-                return accepted;
-            }
-        };
-        interceptor.setExcludedPatternsChecker(new 
DefaultExcludedPatternsChecker());
-        interceptor.setAcceptedPatternsChecker(new 
DefaultAcceptedPatternsChecker());
-        interceptor.setCookiesName("*");
-
-        MockActionInvocation invocation = new MockActionInvocation();
-        invocation.setAction(new MockActionWithActionCookieAware());
-
-        interceptor.intercept(invocation);
-
-        assertFalse(excludedName.get(sessionCookieName));
-        assertFalse(excludedName.get(appCookieName));
-        assertFalse(excludedName.get(reqCookieName));
-    }
-
     public static class MockActionWithCookieAware extends ActionSupport 
implements CookiesAware {
 
         private static final long serialVersionUID = -6202290616812813386L;
@@ -503,46 +461,7 @@ public class CookieInterceptorTest extends 
StrutsInternalTestCase {
         private String cookie2;
         private String cookie3;
 
-        public void setCookiesMap(Map<String, String> cookies) {
-            this.cookies = cookies;
-        }
-
-        public Map getCookiesMap() {
-            return this.cookies;
-        }
-
-        public String getCookie1() {
-            return cookie1;
-        }
-
-        public void setCookie1(String cookie1) {
-            this.cookie1 = cookie1;
-        }
-
-        public String getCookie2() {
-            return cookie2;
-        }
-
-        public void setCookie2(String cookie2) {
-            this.cookie2 = cookie2;
-        }
-
-        public String getCookie3() {
-            return cookie3;
-        }
-
-        public void setCookie3(String cookie3) {
-            this.cookie3 = cookie3;
-        }
-    }
-
-    public static class MockActionWithActionCookieAware extends ActionSupport 
implements org.apache.struts2.action.CookiesAware {
-
-        private Map cookies = Collections.EMPTY_MAP;
-        private String cookie1;
-        private String cookie2;
-        private String cookie3;
-
+        @Override
         public void withCookies(Map<String, String> cookies) {
             this.cookies = cookies;
         }

Reply via email to