mirror of
https://github.com/apache/struts.git
synced 2026-08-05 22:56:59 +00:00
Merge remote-tracking branch 'origin/master' into 7.0.x/merge-master-2024-11-02
This commit is contained in:
@@ -548,4 +548,9 @@ public class ActionContext implements Serializable {
|
||||
}
|
||||
return Objects.equals(getContextMap(), other.getContextMap());
|
||||
}
|
||||
|
||||
@Override
|
||||
public final int hashCode() {
|
||||
return Objects.hash(getContextMap());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -30,6 +30,9 @@ public interface ModelDriven<T> {
|
||||
|
||||
/**
|
||||
* Gets the model to be pushed onto the ValueStack instead of the Action itself.
|
||||
* <p>
|
||||
* Please be aware that all setters and getters of every depth on the object returned by this method are available
|
||||
* for user parameter injection!
|
||||
*
|
||||
* @return the model
|
||||
*/
|
||||
|
||||
@@ -39,7 +39,7 @@ import java.util.Objects;
|
||||
*/
|
||||
public class ResultConfig extends Located implements Serializable {
|
||||
|
||||
protected Map<String,String> params;
|
||||
protected Map<String, String> params;
|
||||
protected String className;
|
||||
protected String name;
|
||||
|
||||
@@ -64,7 +64,7 @@ public class ResultConfig extends Located implements Serializable {
|
||||
return name;
|
||||
}
|
||||
|
||||
public Map<String,String> getParams() {
|
||||
public Map<String, String> getParams() {
|
||||
return params;
|
||||
}
|
||||
|
||||
@@ -139,7 +139,7 @@ public class ResultConfig extends Located implements Serializable {
|
||||
return this;
|
||||
}
|
||||
|
||||
public Builder addParams(Map<String,String> params) {
|
||||
public Builder addParams(Map<String, String> params) {
|
||||
target.params.putAll(params);
|
||||
return this;
|
||||
}
|
||||
|
||||
@@ -66,7 +66,6 @@ import org.apache.struts2.factory.ActionFactory;
|
||||
import org.apache.struts2.factory.ConverterFactory;
|
||||
import org.apache.struts2.factory.DefaultActionFactory;
|
||||
import org.apache.struts2.factory.DefaultInterceptorFactory;
|
||||
import org.apache.struts2.factory.DefaultResultFactory;
|
||||
import org.apache.struts2.factory.DefaultUnknownHandlerFactory;
|
||||
import org.apache.struts2.factory.DefaultValidatorFactory;
|
||||
import org.apache.struts2.factory.InterceptorFactory;
|
||||
@@ -109,6 +108,7 @@ import org.apache.struts2.StrutsConstants;
|
||||
import org.apache.struts2.conversion.StrutsConversionPropertiesProcessor;
|
||||
import org.apache.struts2.conversion.StrutsTypeConverterCreator;
|
||||
import org.apache.struts2.conversion.StrutsTypeConverterHolder;
|
||||
import org.apache.struts2.factory.StrutsResultFactory;
|
||||
import org.apache.struts2.ognl.OgnlGuard;
|
||||
import org.apache.struts2.ognl.ProviderAllowlist;
|
||||
import org.apache.struts2.ognl.StrutsOgnlGuard;
|
||||
@@ -364,7 +364,7 @@ public class DefaultConfiguration implements Configuration {
|
||||
// TODO: SpringObjectFactoryTest fails when these are SINGLETON
|
||||
.factory(ObjectFactory.class, Scope.PROTOTYPE)
|
||||
.factory(ActionFactory.class, DefaultActionFactory.class, Scope.PROTOTYPE)
|
||||
.factory(ResultFactory.class, DefaultResultFactory.class, Scope.PROTOTYPE)
|
||||
.factory(ResultFactory.class, StrutsResultFactory.class, Scope.PROTOTYPE)
|
||||
.factory(InterceptorFactory.class, DefaultInterceptorFactory.class, Scope.PROTOTYPE)
|
||||
.factory(ValidatorFactory.class, DefaultValidatorFactory.class, Scope.PROTOTYPE)
|
||||
.factory(ConverterFactory.class, StrutsConverterFactory.class, Scope.PROTOTYPE)
|
||||
|
||||
@@ -31,7 +31,10 @@ import java.util.Map;
|
||||
|
||||
/**
|
||||
* Default implementation
|
||||
*
|
||||
* @deprecated since 6.7.0, use {@link StrutsResultFactory} instead.
|
||||
*/
|
||||
@Deprecated
|
||||
public class DefaultResultFactory implements ResultFactory {
|
||||
|
||||
private ObjectFactory objectFactory;
|
||||
|
||||
+15
-15
@@ -18,11 +18,22 @@
|
||||
*/
|
||||
package org.apache.struts2.interceptor.parameter;
|
||||
|
||||
import org.apache.commons.lang3.BooleanUtils;
|
||||
import org.apache.commons.lang3.ClassUtils;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
import org.apache.struts2.ActionContext;
|
||||
import org.apache.struts2.ActionInvocation;
|
||||
import org.apache.struts2.ModelDriven;
|
||||
import org.apache.struts2.StrutsConstants;
|
||||
import org.apache.struts2.action.NoParameters;
|
||||
import org.apache.struts2.action.ParameterNameAware;
|
||||
import org.apache.struts2.action.ParameterValueAware;
|
||||
import org.apache.struts2.dispatcher.HttpParameters;
|
||||
import org.apache.struts2.dispatcher.Parameter;
|
||||
import org.apache.struts2.inject.Inject;
|
||||
import org.apache.struts2.interceptor.MethodFilterInterceptor;
|
||||
import org.apache.struts2.ognl.ThreadAllowlist;
|
||||
import org.apache.struts2.security.AcceptedPatternsChecker;
|
||||
import org.apache.struts2.security.DefaultAcceptedPatternsChecker;
|
||||
import org.apache.struts2.security.ExcludedPatternsChecker;
|
||||
@@ -32,17 +43,6 @@ import org.apache.struts2.util.TextParseUtil;
|
||||
import org.apache.struts2.util.ValueStack;
|
||||
import org.apache.struts2.util.ValueStackFactory;
|
||||
import org.apache.struts2.util.reflection.ReflectionContextState;
|
||||
import org.apache.commons.lang3.BooleanUtils;
|
||||
import org.apache.commons.lang3.ClassUtils;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
import org.apache.struts2.StrutsConstants;
|
||||
import org.apache.struts2.action.NoParameters;
|
||||
import org.apache.struts2.action.ParameterNameAware;
|
||||
import org.apache.struts2.action.ParameterValueAware;
|
||||
import org.apache.struts2.dispatcher.HttpParameters;
|
||||
import org.apache.struts2.dispatcher.Parameter;
|
||||
import org.apache.struts2.ognl.ThreadAllowlist;
|
||||
|
||||
import java.beans.BeanInfo;
|
||||
import java.beans.IntrospectionException;
|
||||
@@ -63,15 +63,15 @@ import java.util.Set;
|
||||
import java.util.TreeMap;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
import static org.apache.struts2.security.DefaultAcceptedPatternsChecker.NESTING_CHARS;
|
||||
import static org.apache.struts2.security.DefaultAcceptedPatternsChecker.NESTING_CHARS_STR;
|
||||
import static org.apache.struts2.util.DebugUtils.logWarningForFirstOccurrence;
|
||||
import static org.apache.struts2.util.DebugUtils.notifyDeveloperOfError;
|
||||
import static java.lang.String.format;
|
||||
import static java.util.Collections.unmodifiableSet;
|
||||
import static java.util.stream.Collectors.joining;
|
||||
import static org.apache.commons.lang3.StringUtils.indexOfAny;
|
||||
import static org.apache.commons.lang3.StringUtils.normalizeSpace;
|
||||
import static org.apache.struts2.security.DefaultAcceptedPatternsChecker.NESTING_CHARS;
|
||||
import static org.apache.struts2.security.DefaultAcceptedPatternsChecker.NESTING_CHARS_STR;
|
||||
import static org.apache.struts2.util.DebugUtils.logWarningForFirstOccurrence;
|
||||
import static org.apache.struts2.util.DebugUtils.notifyDeveloperOfError;
|
||||
|
||||
/**
|
||||
* This interceptor sets all parameters on the value stack.
|
||||
|
||||
+4
-3
@@ -42,6 +42,7 @@ import org.apache.struts2.config.StrutsXmlConfigurationProvider;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
|
||||
/**
|
||||
@@ -101,11 +102,11 @@ public class ChainingInterceptorWithConfigTest extends XWorkTestCase {
|
||||
HashMap<String, String> interceptorParams = new HashMap<>();
|
||||
interceptorParams.put("excludes", "blah,bar");
|
||||
|
||||
HashMap successParams1 = new HashMap();
|
||||
Map<String, String> successParams1 = new HashMap<>();
|
||||
successParams1.put("propertyName", "baz");
|
||||
successParams1.put("expectedValue", 1);
|
||||
successParams1.put("expectedValue", "1");
|
||||
|
||||
HashMap successParams2 = new HashMap();
|
||||
Map<String, String> successParams2 = new HashMap<>();
|
||||
successParams2.put("propertyName", "blah");
|
||||
successParams2.put("expectedValue", null);
|
||||
|
||||
|
||||
+2
-2
@@ -35,7 +35,6 @@ import org.apache.struts2.config.entities.ResultConfig;
|
||||
import org.apache.struts2.config.entities.ResultTypeConfig;
|
||||
import org.apache.struts2.config.impl.DefaultConfiguration;
|
||||
import org.apache.struts2.factory.DefaultInterceptorFactory;
|
||||
import org.apache.struts2.factory.DefaultResultFactory;
|
||||
import org.apache.struts2.inject.Container;
|
||||
import org.apache.struts2.inject.Scope.Strategy;
|
||||
import org.apache.struts2.ognl.OgnlReflectionProvider;
|
||||
@@ -97,6 +96,7 @@ import org.apache.struts2.convention.actions.transactions.TransNameAction;
|
||||
import org.apache.struts2.convention.annotation.Action;
|
||||
import org.apache.struts2.convention.annotation.Actions;
|
||||
import org.apache.struts2.convention.dontfind.DontFindMeAction;
|
||||
import org.apache.struts2.factory.StrutsResultFactory;
|
||||
import org.apache.struts2.ognl.ProviderAllowlist;
|
||||
import org.apache.struts2.result.ServletDispatcherResult;
|
||||
import org.easymock.EasyMock;
|
||||
@@ -918,7 +918,7 @@ public class PackageBasedActionConfigBuilderTest extends TestCase {
|
||||
dif.setObjectFactory((ObjectFactory) obj);
|
||||
dif.setReflectionProvider(rp);
|
||||
|
||||
DefaultResultFactory drf = new DefaultResultFactory();
|
||||
StrutsResultFactory drf = new StrutsResultFactory();
|
||||
drf.setObjectFactory((ObjectFactory) obj);
|
||||
drf.setReflectionProvider(rp);
|
||||
|
||||
|
||||
@@ -240,11 +240,9 @@ public class RestActionInvocationTest extends TestCase {
|
||||
((MockActionProxy)restActionInvocation.getProxy()).setMethod("index");
|
||||
|
||||
// Define result 'success'
|
||||
ResultConfig resultConfig = new ResultConfig.Builder("success",
|
||||
"org.apache.struts2.result.HttpHeaderResult")
|
||||
ResultConfig resultConfig = new ResultConfig.Builder("success", "org.apache.struts2.result.HttpHeaderResult")
|
||||
.addParam("status", "123").build();
|
||||
ActionConfig actionConfig = new ActionConfig.Builder("org.apache.rest",
|
||||
"RestAction", "org.apache.rest.RestAction")
|
||||
ActionConfig actionConfig = new ActionConfig.Builder("org.apache.rest", "RestAction", "org.apache.rest.RestAction")
|
||||
.addResultConfig(resultConfig)
|
||||
.build();
|
||||
((MockActionProxy)restActionInvocation.getProxy()).setConfig(actionConfig);
|
||||
@@ -264,16 +262,16 @@ public class RestActionInvocationTest extends TestCase {
|
||||
|
||||
class RestActionInvocationTester extends RestActionInvocation {
|
||||
RestActionInvocationTester() {
|
||||
super(new HashMap<String, Object>(), true);
|
||||
List<InterceptorMapping> interceptorMappings = new ArrayList<InterceptorMapping>();
|
||||
super(new HashMap<>(), true);
|
||||
List<InterceptorMapping> interceptorMappings = new ArrayList<>();
|
||||
MockInterceptor mockInterceptor = new MockInterceptor();
|
||||
mockInterceptor.setFoo("interceptor");
|
||||
mockInterceptor.setExpectedFoo("interceptor");
|
||||
interceptorMappings.add(new InterceptorMapping("interceptor", mockInterceptor));
|
||||
interceptors = interceptorMappings.iterator();
|
||||
MockActionProxy actionProxy = new MockActionProxy();
|
||||
ActionConfig actionConfig = new ActionConfig.Builder("org.apache.rest",
|
||||
"RestAction", "org.apache.rest.RestAction").build();
|
||||
ActionConfig actionConfig = new ActionConfig.Builder(
|
||||
"org.apache.rest", "RestAction", "org.apache.rest.RestAction").build();
|
||||
actionProxy.setConfig(actionConfig);
|
||||
proxy = actionProxy;
|
||||
action = new RestAction();
|
||||
|
||||
Reference in New Issue
Block a user