WW-5411 Delete deprecated code part 4

This commit is contained in:
Kusal Kithul-Godage
2024-07-25 20:22:48 +10:00
parent 6c6ef447c9
commit e411f9c175
17 changed files with 66 additions and 257 deletions
@@ -48,7 +48,4 @@ public interface TypeConverter {
Object NO_CONVERSION_POSSIBLE = "ognl.NoConversionPossible";
@Deprecated
String TYPE_CONVERTER_CONTEXT_KEY = "_typeConverter";
}
@@ -226,21 +226,6 @@ abstract class AbstractLocalizedTextProvider implements LocalizedTextProvider {
}
}
/**
* Clear a specific bundle from the <code>bundlesMap</code>.
*
* Warning: This method is <b>now a "no-op"</b>. It <b>was ineffective</b> due
* to the way the <code>bundlesMap</code> is used in combination with locale.
* Descendants should use the method {@link #clearBundle(java.lang.String, java.util.Locale)} instead.
*
* @param bundleName The bundle to remove from the bundle map
*
* @deprecated A "no-op" since 6.0.0. Use {@link #clearBundle(java.lang.String, java.util.Locale)} instead.
*/
public void clearBundle(final String bundleName) {
LOG.debug("No-op. Did NOT clear resource bundle [{}], result: false.", bundleName);
}
/**
* Clear a specific bundle + locale combination from the <code>bundlesMap</code>.
* Intended for descendants to use clear a bundle + locale combination.
@@ -491,16 +476,6 @@ abstract class AbstractLocalizedTextProvider implements LocalizedTextProvider {
return bundle;
}
/**
* Clears all the internal lists.
*
* @deprecated used only in tests
*/
@Deprecated
public void reset() {
// no-op
}
/**
* Determines if we found the text in the bundles.
*
@@ -513,12 +488,7 @@ abstract class AbstractLocalizedTextProvider implements LocalizedTextProvider {
}
// did we find it in the bundle, then no problem?
if (result.foundInBundle) {
return false;
}
// not found in bundle
return true;
return !result.foundInBundle;
}
/**
@@ -18,13 +18,22 @@
*/
package com.opensymphony.xwork2.validator;
import com.opensymphony.xwork2.*;
import com.opensymphony.xwork2.ActionContext;
import com.opensymphony.xwork2.CompositeTextProvider;
import com.opensymphony.xwork2.LocaleProvider;
import com.opensymphony.xwork2.LocaleProviderFactory;
import com.opensymphony.xwork2.TextProvider;
import com.opensymphony.xwork2.TextProviderFactory;
import com.opensymphony.xwork2.interceptor.ValidationAware;
import com.opensymphony.xwork2.util.ValueStack;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import java.util.*;
import java.util.Collection;
import java.util.List;
import java.util.Locale;
import java.util.Map;
import java.util.ResourceBundle;
/**
* A default implementation of the {@link ValidatorContext} interface.
@@ -65,49 +74,42 @@ public class DelegatingValidatorContext implements ValidatorContext {
this.textProvider = makeTextProvider(object, textProviderFactory);
}
/**
* Create a new validation context given a Class definition. The locale provider, text provider and
* the validation context are created based on the class.
*
* @param clazz the class to initialize the context with.
*
* @deprecated will be removed, do not use!
*/
@Deprecated
public DelegatingValidatorContext(Class clazz) {
localeProvider = new ActionContextLocaleProvider();
textProvider = new StrutsTextProviderFactory().createInstance(clazz);
validationAware = new LoggingValidationAware(clazz);
}
@Override
public void setActionErrors(Collection<String> errorMessages) {
validationAware.setActionErrors(errorMessages);
}
@Override
public Collection<String> getActionErrors() {
return validationAware.getActionErrors();
}
@Override
public void setActionMessages(Collection<String> messages) {
validationAware.setActionMessages(messages);
}
@Override
public Collection<String> getActionMessages() {
return validationAware.getActionMessages();
}
@Override
public void setFieldErrors(Map<String, List<String>> errorMap) {
validationAware.setFieldErrors(errorMap);
}
@Override
public Map<String, List<String>> getFieldErrors() {
return validationAware.getFieldErrors();
}
@Override
public String getFullFieldName(String fieldName) {
return fieldName;
}
@Override
public Locale getLocale() {
return localeProvider.getLocale();
}
@@ -127,78 +129,97 @@ public class DelegatingValidatorContext implements ValidatorContext {
return localeProvider.toLocale(localeStr);
}
@Override
public boolean hasKey(String key) {
return textProvider.hasKey(key);
}
@Override
public String getText(String aTextName) {
return textProvider.getText(aTextName);
}
@Override
public String getText(String aTextName, String defaultValue) {
return textProvider.getText(aTextName, defaultValue);
}
@Override
public String getText(String aTextName, String defaultValue, String obj) {
return textProvider.getText(aTextName, defaultValue, obj);
}
@Override
public String getText(String aTextName, List<?> args) {
return textProvider.getText(aTextName, args);
}
@Override
public String getText(String key, String[] args) {
return textProvider.getText(key, args);
}
@Override
public String getText(String aTextName, String defaultValue, List<?> args) {
return textProvider.getText(aTextName, defaultValue, args);
}
@Override
public String getText(String key, String defaultValue, String[] args) {
return textProvider.getText(key, defaultValue, args);
}
@Override
public ResourceBundle getTexts(String aBundleName) {
return textProvider.getTexts(aBundleName);
}
@Override
public String getText(String key, String defaultValue, List<?> args, ValueStack stack) {
return textProvider.getText(key, defaultValue, args, stack);
}
@Override
public String getText(String key, String defaultValue, String[] args, ValueStack stack) {
return textProvider.getText(key, defaultValue, args, stack);
}
@Override
public ResourceBundle getTexts() {
return textProvider.getTexts();
}
@Override
public void addActionError(String anErrorMessage) {
validationAware.addActionError(anErrorMessage);
}
@Override
public void addActionMessage(String aMessage) {
validationAware.addActionMessage(aMessage);
}
@Override
public void addFieldError(String fieldName, String errorMessage) {
validationAware.addFieldError(fieldName, errorMessage);
}
@Override
public boolean hasActionErrors() {
return validationAware.hasActionErrors();
}
@Override
public boolean hasActionMessages() {
return validationAware.hasActionMessages();
}
@Override
public boolean hasErrors() {
return validationAware.hasErrors();
}
@Override
public boolean hasFieldErrors() {
return validationAware.hasFieldErrors();
}
@@ -307,62 +328,73 @@ public class DelegatingValidatorContext implements ValidatorContext {
log = LogManager.getLogger(obj.getClass());
}
@Override
public void setActionErrors(Collection<String> errorMessages) {
for (Object errorMessage : errorMessages) {
String s = (String) errorMessage;
addActionError(s);
for (String errorMessage : errorMessages) {
addActionError(errorMessage);
}
}
@Override
public Collection<String> getActionErrors() {
return null;
}
@Override
public void setActionMessages(Collection<String> messages) {
for (Object message : messages) {
String s = (String) message;
addActionMessage(s);
for (String message : messages) {
addActionMessage(message);
}
}
@Override
public Collection<String> getActionMessages() {
return null;
}
@Override
public void setFieldErrors(Map<String, List<String>> errorMap) {
for (Map.Entry<String, List<String>> entry : errorMap.entrySet()) {
addFieldError(entry.getKey(), entry.getValue().toString());
}
}
@Override
public Map<String, List<String>> getFieldErrors() {
return null;
}
@Override
public void addActionError(String anErrorMessage) {
log.error("Validation error: {}", anErrorMessage);
}
@Override
public void addActionMessage(String aMessage) {
log.info("Validation Message: {}", aMessage);
}
@Override
public void addFieldError(String fieldName, String errorMessage) {
log.error("Validation error for {}:{}", fieldName, errorMessage);
}
@Override
public boolean hasActionErrors() {
return false;
}
@Override
public boolean hasActionMessages() {
return false;
}
@Override
public boolean hasErrors() {
return false;
}
@Override
public boolean hasFieldErrors() {
return false;
}
@@ -324,25 +324,12 @@ public final class StrutsConstants {
*/
public static final String STRUTS_OGNL_VALUE_STACK_FALLBACK_TO_CONTEXT = "struts.ognl.valueStackFallbackToContext";
/**
* Logs properties that are not found (very verbose)
* @deprecated as of 6.0.0. Use {@link #STRUTS_OGNL_LOG_MISSING_PROPERTIES} instead.
*/
@Deprecated
public static final String STRUTS_LOG_MISSING_PROPERTIES = STRUTS_OGNL_LOG_MISSING_PROPERTIES;
/**
* Enables caching of parsed OGNL expressions
* @since 6.0.0
*/
public static final String STRUTS_OGNL_ENABLE_EXPRESSION_CACHE = "struts.ognl.enableExpressionCache";
/**
* Enables caching of parsed OGNL expressions
* @deprecated as of 6.0.0. Use {@link #STRUTS_OGNL_ENABLE_EXPRESSION_CACHE} instead.
*/
public static final String STRUTS_ENABLE_OGNL_EXPRESSION_CACHE = STRUTS_OGNL_ENABLE_EXPRESSION_CACHE;
/**
* Specifies the type of cache to use for parsed OGNL expressions. Valid values defined in
* {@link com.opensymphony.xwork2.ognl.OgnlCacheFactory.CacheType}.
@@ -371,12 +358,6 @@ public final class StrutsConstants {
*/
public static final String STRUTS_OGNL_ENABLE_EVAL_EXPRESSION = "struts.ognl.enableEvalExpression";
/**
* Enables evaluation of OGNL expressions
* @deprecated as of 6.0.0. Use {@link #STRUTS_OGNL_ENABLE_EVAL_EXPRESSION} instead.
*/
public static final String STRUTS_ENABLE_OGNL_EVAL_EXPRESSION = STRUTS_OGNL_ENABLE_EVAL_EXPRESSION;
/** The maximum length of an expression (OGNL) */
public static final String STRUTS_OGNL_EXPRESSION_MAX_LENGTH = "struts.ognl.expressionMaxLength";
@@ -68,16 +68,6 @@ public class StrutsXmlConfigurationProvider extends XmlConfigurationProvider {
this("struts.xml", null);
}
/**
* Constructs the configuration provider
*
* @param errorIfMissing If we should throw an exception if the file can't be found
*/
@Deprecated
public StrutsXmlConfigurationProvider(boolean errorIfMissing) {
this("struts.xml", null);
}
/**
* Constructs the configuration provider based on the provided config file
*
@@ -64,20 +64,6 @@ public class HttpParameters implements Map<String, Parameter> {
return parameters.containsKey(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<String, String[]> toMap() {
final Map<String, String[]> result = new HashMap<>(parameters.size());
for (Map.Entry<String, Parameter> entry : parameters.entrySet()) {
result.put(entry.getKey(), entry.getValue().getMultipleValues());
}
return result;
}
/**
* Appends all the parameters by overriding any existing params in a case-insensitive manner
*
@@ -187,44 +173,9 @@ public class HttpParameters implements Map<String, Parameter> {
}
public HttpParameters build() {
Map<String, Parameter> parameters = (parent == null)
? new HashMap<>()
: new HashMap<>(parent.parameters);
for (Map.Entry<String, Object> entry : requestParameterMap.entrySet()) {
String name = entry.getKey();
Object value = entry.getValue();
if (value instanceof Parameter) {
parameters.put(name, (Parameter) value);
} else {
parameters.put(name, new Parameter.Request(name, value));
}
}
return new HttpParameters(parameters);
}
/**
* Alternate Builder method which avoids wrapping any parameters that are already
* a {@link Parameter} element within another {@link Parameter} wrapper.
*
* @deprecated since 6.4.0, use {@link #build()} instead
*/
@Deprecated
public HttpParameters buildNoNestedWrapping() {
Map<String, Parameter> parameters = (parent == null)
? new HashMap<>()
: new HashMap<>(parent.parameters);
for (Map.Entry<String, Object> entry : requestParameterMap.entrySet()) {
String name = entry.getKey();
Object value = entry.getValue();
Parameter parameterValue = (value instanceof Parameter)
? (Parameter) value
: new Parameter.Request(name, value);
parameters.put(name, parameterValue);
}
Map<String, Parameter> parameters = parent == null ? new HashMap<>() : new HashMap<>(parent.parameters);
requestParameterMap.forEach((name, value) ->
parameters.put(name,value instanceof Parameter ? (Parameter) value : new Parameter.Request(name, value)));
return new HttpParameters(parameters);
}
}
@@ -26,19 +26,6 @@ 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;
this.contentType = null;
this.originalName = null;
}
private StrutsUploadedFile(File file, String contentType, String originalName) {
this.file = file;
this.contentType = contentType;
@@ -83,9 +83,9 @@ public class ActionMappingParametersInterceptor extends ParametersInterceptor {
protected HttpParameters retrieveParameters(ActionContext actionContext) {
ActionMapping mapping = actionContext.getActionMapping();
if (mapping != null) {
return HttpParameters.create(mapping.getParams()).buildNoNestedWrapping();
return HttpParameters.create(mapping.getParams()).build();
} else {
return HttpParameters.create().buildNoNestedWrapping();
return HttpParameters.create().build();
}
}
@@ -101,7 +101,6 @@ public class ActionMappingParametersInterceptor extends ParametersInterceptor {
protected void addParametersToContext(ActionContext ac, Map<String, ?> newParams) {
HttpParameters previousParams = ac.getParameters();
HttpParameters.Builder combinedParams = HttpParameters.create().withParent(previousParams).withExtraParams(newParams);
ac.withParameters(combinedParams.buildNoNestedWrapping());
ac.withParameters(combinedParams.build());
}
}
@@ -44,12 +44,6 @@ public interface CspSettings {
String HTTPS = "https:";
String CSP_REPORT_TYPE = "application/csp-report";
/**
* @deprecated use {@link #addCspHeaders(HttpServletRequest, HttpServletResponse)} instead
*/
@Deprecated
void addCspHeaders(HttpServletResponse response);
void addCspHeaders(HttpServletRequest request, HttpServletResponse response);
/**
@@ -18,12 +18,12 @@
*/
package org.apache.struts2.interceptor.csp;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.apache.struts2.action.CspSettingsAware;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;
import java.security.SecureRandom;
import java.util.Base64;
import java.util.Objects;
@@ -52,11 +52,6 @@ public class DefaultCspSettings implements CspSettings {
// default to reporting mode
protected String cspHeader = CSP_REPORT_HEADER;
@Override
public void addCspHeaders(HttpServletResponse response) {
throw new UnsupportedOperationException("Unsupported implementation, use #addCspHeaders(HttpServletRequest request, HttpServletResponse response)");
}
@Override
public void addCspHeaders(HttpServletRequest request, HttpServletResponse response) {
if (isSessionActive(request)) {
@@ -375,15 +375,6 @@ public class ParametersInterceptor extends MethodFilterInterceptor {
return hasValidAnnotatedField(action, rootProperty, paramDepth);
}
/**
* @deprecated since 6.5.0, use {@link #hasValidAnnotatedPropertyDescriptor(Object, PropertyDescriptor, long)}
* instead.
*/
@Deprecated
protected boolean hasValidAnnotatedPropertyDescriptor(PropertyDescriptor propDesc, long paramDepth) {
return hasValidAnnotatedPropertyDescriptor(null, propDesc, paramDepth);
}
protected boolean hasValidAnnotatedPropertyDescriptor(Object action, PropertyDescriptor propDesc, long paramDepth) {
Method relevantMethod = paramDepth == 0 ? propDesc.getWriteMethod() : propDesc.getReadMethod();
if (relevantMethod == null) {
@@ -18,8 +18,6 @@
*/
package org.apache.struts2.ognl;
import com.opensymphony.xwork2.config.ConfigurationProvider;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Map;
@@ -52,14 +50,6 @@ public class ProviderAllowlist {
this.allowlistClasses.addAll(allowlist);
}
/**
* @deprecated since 6.6.0, use {@link #registerAllowlist(Object, Set)}
*/
@Deprecated
public synchronized void registerAllowlist(ConfigurationProvider configurationProvider, Set<Class<?>> allowlist) {
registerAllowlist((Object) configurationProvider, allowlist);
}
public synchronized void clearAllowlist(Object key) {
Set<Class<?>> allowlist = allowlistMap.get(key);
if (allowlist == null) {
@@ -69,14 +59,6 @@ public class ProviderAllowlist {
reconstructAllowlist();
}
/**
* @deprecated since 6.6.0, use {@link #clearAllowlist(Object)}
*/
@Deprecated
public synchronized void clearAllowlist(ConfigurationProvider configurationProvider) {
clearAllowlist((Object) configurationProvider);
}
public Set<Class<?>> getProviderAllowlist() {
return unmodifiableSet(allowlistClasses);
}
@@ -28,12 +28,6 @@ import java.util.Map;
*/
public interface QueryStringParser extends Serializable {
/**
* @deprecated since Struts 6.2.0, use {@link #parse(String)} instead
*/
@Deprecated
Map<String, Object> parse(String queryString, boolean forceValueArray);
/**
* @param queryString a query string to parse
* @return a {@link Result} of parsing the query string
@@ -41,11 +41,6 @@ public class StrutsQueryStringParser implements QueryStringParser {
this.decoder = decoder;
}
@Override
public Map<String, Object> parse(String queryString, boolean forceValueArray) {
return parse(queryString).getQueryParams();
}
@Override
public Result parse(String queryString) {
if (StringUtils.isEmpty(queryString)) {
@@ -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.util;
import jakarta.servlet.ServletContext;
@Deprecated
public interface ServletContextAware extends org.apache.struts2.action.ServletContextAware {
void setServletContext(ServletContext context);
@Override
default void withServletContext(ServletContext context) {
setServletContext(context);
}
}
@@ -18,11 +18,11 @@
*/
package org.apache.struts2.views.jsp.ui;
import jakarta.servlet.jsp.JspException;
import jakarta.servlet.jsp.tagext.DynamicAttributes;
import org.apache.struts2.components.UIBean;
import org.apache.struts2.views.jsp.ComponentTagSupport;
import jakarta.servlet.jsp.JspException;
import jakarta.servlet.jsp.tagext.DynamicAttributes;
import java.util.HashMap;
import java.util.Map;
@@ -137,14 +137,6 @@ public abstract class AbstractUITag extends ComponentTagSupport implements Dynam
this.cssClass = cssClass;
}
/**
* @deprecated Use {@link #setCssClass(String)} instead
*/
@Deprecated
public void setClass(String cssClass) {
this.cssClass = cssClass;
}
public void setCssStyle(String cssStyle) {
this.cssStyle = cssStyle;
}
@@ -305,11 +305,6 @@ public class StrutsLocalizedTextProviderTest extends XWorkTestCase {
assertEquals("testStrutsLocalizedTextProvider bundle map size not 6 after retrievals ?",
6, testStrutsLocalizedTextProvider.currentBundlesMapSize());
// Expect the call to be ineffective due to deprecation and change to a "no-op" (but shouldn't throw an Exception or cause failure).
testStrutsLocalizedTextProvider.callClearBundleNoLocale("com/opensymphony/xwork2/test");
assertEquals("testStrutsLocalizedTextProvider bundle map size not 6 after non-locale clear call ?",
6, testStrutsLocalizedTextProvider.currentBundlesMapSize());
// Expect the call to function with bundle name + locale. Remove all four of the non-default
// bundles and confirm the bundle map size changes.
testStrutsLocalizedTextProvider.callClearBundleWithLocale("com/opensymphony/xwork2/test", Locale.ENGLISH);
@@ -595,10 +590,6 @@ public class StrutsLocalizedTextProviderTest extends XWorkTestCase {
*/
private static final String RELOADED = "com.opensymphony.xwork2.util.LocalizedTextProvider.reloaded";
public void callClearBundleNoLocale(String bundleName) {
super.clearBundle(bundleName);
}
public void callClearBundleWithLocale(String bundleName, Locale locale) {
super.clearBundle(bundleName, locale);
}