Merge pull request #227 from sdutry/WW-4792

WW-4792 Removes deprecated XWork constants
This commit is contained in:
Lukasz Lenart
2018-05-28 08:32:08 +02:00
committed by GitHub
25 changed files with 73 additions and 171 deletions
@@ -1,66 +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 com.opensymphony.xwork2;
/**
* Constants used across framework
*/
@Deprecated
public final class XWorkConstants {
@Deprecated
public static final String COLLECTION_CONVERTER = "collectionConverter";
@Deprecated
public static final String DATE_CONVERTER = "dateConverter";
@Deprecated
public static final String NUMBER_CONVERTER = "numberConverter";
@Deprecated
public static final String STRING_CONVERTER = "stringConverter";
@Deprecated
public static final String ARRAY_CONVERTER = "arrayConverter";
@Deprecated
public static final String DEV_MODE = "devMode";
@Deprecated
public static final String LOG_MISSING_PROPERTIES = "logMissingProperties";
@Deprecated
public static final String ENABLE_OGNL_EXPRESSION_CACHE = "enableOGNLExpressionCache";
@Deprecated
public static final String ENABLE_OGNL_EVAL_EXPRESSION = "enableOGNLEvalExpression";
@Deprecated
public static final String RELOAD_XML_CONFIGURATION = "reloadXmlConfiguration";
@Deprecated
public static final String ALLOW_STATIC_METHOD_ACCESS = "allowStaticMethodAccess";
@Deprecated
public static final String XWORK_LOGGER_FACTORY = "xwork.loggerFactory";
@Deprecated
public static final String OGNL_EXCLUDED_CLASSES = "ognlExcludedClasses";
@Deprecated
public static final String OGNL_EXCLUDED_PACKAGE_NAME_PATTERNS = "ognlExcludedPackageNamePatterns";
@Deprecated
public static final String OGNL_EXCLUDED_PACKAGE_NAMES = "ognlExcludedPackageNames";
@Deprecated
public static final String ADDITIONAL_EXCLUDED_PATTERNS = "additionalExcludedPatterns";
@Deprecated
public static final String ADDITIONAL_ACCEPTED_PATTERNS = "additionalAcceptedPatterns";
@Deprecated
public static final String OVERRIDE_EXCLUDED_PATTERNS = "overrideExcludedPatterns";
@Deprecated
public static final String OVERRIDE_ACCEPTED_PATTERNS = "overrideAcceptedPatterns";
}
@@ -18,12 +18,12 @@
*/
package com.opensymphony.xwork2.config;
import com.opensymphony.xwork2.XWorkConstants;
import com.opensymphony.xwork2.config.impl.DefaultConfiguration;
import com.opensymphony.xwork2.config.providers.XWorkConfigurationProvider;
import com.opensymphony.xwork2.config.providers.XmlConfigurationProvider;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.apache.struts2.StrutsConstants;
import java.util.List;
import java.util.concurrent.CopyOnWriteArrayList;
@@ -187,10 +187,10 @@ public class ConfigurationManager {
}
private void updateReloadConfigsFlag() {
reloadConfigs = Boolean.parseBoolean(configuration.getContainer().getInstance(String.class, XWorkConstants.RELOAD_XML_CONFIGURATION));
reloadConfigs = Boolean.parseBoolean(configuration.getContainer().getInstance(String.class, StrutsConstants.STRUTS_CONFIGURATION_XML_RELOAD));
if (LOG.isDebugEnabled()) {
LOG.debug("Updating [{}], current value is [{}], new value [{}]",
XWorkConstants.RELOAD_XML_CONFIGURATION, String.valueOf(reloadConfigs), String.valueOf(reloadConfigs));
StrutsConstants.STRUTS_CONFIGURATION_XML_RELOAD, String.valueOf(reloadConfigs), String.valueOf(reloadConfigs));
}
}
@@ -261,11 +261,11 @@ public class DefaultConfiguration implements Configuration {
builder.factory(TypeConverterHolder.class, DefaultTypeConverterHolder.class, Scope.SINGLETON);
builder.factory(XWorkBasicConverter.class, Scope.SINGLETON);
builder.factory(TypeConverter.class, XWorkConstants.COLLECTION_CONVERTER, CollectionConverter.class, Scope.SINGLETON);
builder.factory(TypeConverter.class, XWorkConstants.ARRAY_CONVERTER, ArrayConverter.class, Scope.SINGLETON);
builder.factory(TypeConverter.class, XWorkConstants.DATE_CONVERTER, DateConverter.class, Scope.SINGLETON);
builder.factory(TypeConverter.class, XWorkConstants.NUMBER_CONVERTER, NumberConverter.class, Scope.SINGLETON);
builder.factory(TypeConverter.class, XWorkConstants.STRING_CONVERTER, StringConverter.class, Scope.SINGLETON);
builder.factory(TypeConverter.class, StrutsConstants.STRUTS_CONVERTER_COLLECTION, CollectionConverter.class, Scope.SINGLETON);
builder.factory(TypeConverter.class, StrutsConstants.STRUTS_CONVERTER_ARRAY, ArrayConverter.class, Scope.SINGLETON);
builder.factory(TypeConverter.class, StrutsConstants.STRUTS_CONVERTER_DATE, DateConverter.class, Scope.SINGLETON);
builder.factory(TypeConverter.class, StrutsConstants.STRUTS_CONVERTER_NUMBER, NumberConverter.class, Scope.SINGLETON);
builder.factory(TypeConverter.class, StrutsConstants.STRUTS_CONVERTER_STRING, StringConverter.class, Scope.SINGLETON);
builder.factory(TextProvider.class, "system", DefaultTextProvider.class, Scope.SINGLETON);
@@ -281,12 +281,11 @@ public class DefaultConfiguration implements Configuration {
builder.factory(ValueSubstitutor.class, EnvsValueSubstitutor.class, Scope.SINGLETON);
builder.constant(XWorkConstants.DEV_MODE, "false");
builder.constant(StrutsConstants.STRUTS_DEVMODE, "false");
builder.constant(XWorkConstants.LOG_MISSING_PROPERTIES, "false");
builder.constant(XWorkConstants.ENABLE_OGNL_EVAL_EXPRESSION, "false");
builder.constant(XWorkConstants.ENABLE_OGNL_EXPRESSION_CACHE, "true");
builder.constant(XWorkConstants.RELOAD_XML_CONFIGURATION, "false");
builder.constant(StrutsConstants.STRUTS_LOG_MISSING_PROPERTIES, "false");
builder.constant(StrutsConstants.STRUTS_ENABLE_OGNL_EVAL_EXPRESSION, "false");
builder.constant(StrutsConstants.STRUTS_ENABLE_OGNL_EXPRESSION_CACHE, "true");
builder.constant(StrutsConstants.STRUTS_CONFIGURATION_XML_RELOAD, "false");
builder.constant(StrutsConstants.STRUTS_I18N_RELOAD, "false");
return builder.create(true);
@@ -18,7 +18,6 @@
*/
package com.opensymphony.xwork2.config.impl;
import com.opensymphony.xwork2.XWorkConstants;
import com.opensymphony.xwork2.config.*;
import com.opensymphony.xwork2.config.entities.PackageConfig;
import com.opensymphony.xwork2.config.entities.UnknownHandlerConfig;
@@ -52,9 +51,9 @@ public class MockConfiguration implements Configuration {
builder.factory(Configuration.class, MockConfiguration.class, Scope.SINGLETON);
LocatableProperties props = new LocatableProperties();
new XWorkConfigurationProvider().register(builder, props);
builder.constant(XWorkConstants.DEV_MODE, "false");
builder.constant(XWorkConstants.RELOAD_XML_CONFIGURATION, "true");
builder.constant(XWorkConstants.ENABLE_OGNL_EXPRESSION_CACHE, "true");
builder.constant(StrutsConstants.STRUTS_DEVMODE, "false");
builder.constant(StrutsConstants.STRUTS_CONFIGURATION_XML_RELOAD, "true");
builder.constant(StrutsConstants.STRUTS_ENABLE_OGNL_EXPRESSION_CACHE, "true");
builder.constant(StrutsConstants.STRUTS_ENABLE_DYNAMIC_METHOD_INVOCATION, "false");
container = builder.create(true);
}
@@ -39,7 +39,6 @@ import com.opensymphony.xwork2.FileManagerFactory;
import com.opensymphony.xwork2.ObjectFactory;
import com.opensymphony.xwork2.TextProvider;
import com.opensymphony.xwork2.UnknownHandlerManager;
import com.opensymphony.xwork2.XWorkConstants;
import com.opensymphony.xwork2.config.Configuration;
import com.opensymphony.xwork2.config.ConfigurationException;
import com.opensymphony.xwork2.config.ConfigurationProvider;
@@ -221,11 +220,10 @@ public class XWorkConfigurationProvider implements ConfigurationProvider {
props.setProperty(StrutsConstants.STRUTS_ENABLE_DYNAMIC_METHOD_INVOCATION, Boolean.FALSE.toString());
props.setProperty(StrutsConstants.STRUTS_I18N_RELOAD, Boolean.FALSE.toString());
props.setProperty(StrutsConstants.STRUTS_DEVMODE, Boolean.FALSE.toString());
props.setProperty(XWorkConstants.DEV_MODE, Boolean.FALSE.toString());
props.setProperty(XWorkConstants.LOG_MISSING_PROPERTIES, Boolean.FALSE.toString());
props.setProperty(XWorkConstants.ENABLE_OGNL_EXPRESSION_CACHE, Boolean.TRUE.toString());
props.setProperty(XWorkConstants.ENABLE_OGNL_EVAL_EXPRESSION, Boolean.FALSE.toString());
props.setProperty(XWorkConstants.RELOAD_XML_CONFIGURATION, Boolean.FALSE.toString());
props.setProperty(StrutsConstants.STRUTS_LOG_MISSING_PROPERTIES, Boolean.FALSE.toString());
props.setProperty(StrutsConstants.STRUTS_ENABLE_OGNL_EXPRESSION_CACHE, Boolean.TRUE.toString());
props.setProperty(StrutsConstants.STRUTS_ENABLE_OGNL_EVAL_EXPRESSION, Boolean.FALSE.toString());
props.setProperty(StrutsConstants.STRUTS_CONFIGURATION_XML_RELOAD, Boolean.FALSE.toString());
}
}
@@ -18,11 +18,11 @@
*/
package com.opensymphony.xwork2.conversion.impl;
import com.opensymphony.xwork2.XWorkConstants;
import com.opensymphony.xwork2.XWorkException;
import com.opensymphony.xwork2.conversion.TypeConverter;
import com.opensymphony.xwork2.inject.Container;
import com.opensymphony.xwork2.inject.Inject;
import org.apache.struts2.StrutsConstants;
import java.lang.reflect.Member;
import java.util.Calendar;
@@ -179,7 +179,7 @@ public class XWorkBasicConverter extends DefaultTypeConverter {
private Object doConvertToCollection(Map<String, Object> context, Object o, Member member, String prop, Object value, Class toType) {
TypeConverter converter = container.getInstance(CollectionConverter.class);
if (converter == null) {
throw new XWorkException("TypeConverter with name [#0] must be registered first!", XWorkConstants.COLLECTION_CONVERTER);
throw new XWorkException("TypeConverter with name [#0] must be registered first!", StrutsConstants.STRUTS_CONVERTER_COLLECTION);
}
return converter.convertValue(context, o, member, prop, value, toType);
}
@@ -187,7 +187,7 @@ public class XWorkBasicConverter extends DefaultTypeConverter {
private Object doConvertToArray(Map<String, Object> context, Object o, Member member, String prop, Object value, Class toType) {
TypeConverter converter = container.getInstance(ArrayConverter.class);
if (converter == null) {
throw new XWorkException("TypeConverter with name [#0] must be registered first!", XWorkConstants.ARRAY_CONVERTER);
throw new XWorkException("TypeConverter with name [#0] must be registered first!", StrutsConstants.STRUTS_CONVERTER_ARRAY);
}
return converter.convertValue(context, o, member, prop, value, toType);
}
@@ -195,7 +195,7 @@ public class XWorkBasicConverter extends DefaultTypeConverter {
private Object doConvertToDate(Map<String, Object> context, Object value, Class toType) {
TypeConverter converter = container.getInstance(DateConverter.class);
if (converter == null) {
throw new XWorkException("TypeConverter with name [#0] must be registered first!", XWorkConstants.DATE_CONVERTER);
throw new XWorkException("TypeConverter with name [#0] must be registered first!", StrutsConstants.STRUTS_CONVERTER_DATE);
}
return converter.convertValue(context, null, null, null, value, toType);
}
@@ -203,7 +203,7 @@ public class XWorkBasicConverter extends DefaultTypeConverter {
private Object doConvertToNumber(Map<String, Object> context, Object value, Class toType) {
TypeConverter converter = container.getInstance(NumberConverter.class);
if (converter == null) {
throw new XWorkException("TypeConverter with name [#0] must be registered first!", XWorkConstants.NUMBER_CONVERTER);
throw new XWorkException("TypeConverter with name [#0] must be registered first!", StrutsConstants.STRUTS_CONVERTER_NUMBER);
}
return converter.convertValue(context, null, null, null, value, toType);
}
@@ -211,7 +211,7 @@ public class XWorkBasicConverter extends DefaultTypeConverter {
private Object doConvertToString(Map<String, Object> context, Object value) {
TypeConverter converter = container.getInstance(StringConverter.class);
if (converter == null) {
throw new XWorkException("TypeConverter with name [#0] must be registered first!", XWorkConstants.STRING_CONVERTER);
throw new XWorkException("TypeConverter with name [#0] must be registered first!", StrutsConstants.STRUTS_CONVERTER_STRING);
}
return converter.convertValue(context, null, null, null, value, null);
}
@@ -28,6 +28,7 @@ import com.opensymphony.xwork2.util.reflection.ReflectionContextState;
import org.apache.commons.lang3.StringUtils;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.apache.struts2.StrutsConstants;
import java.lang.annotation.Annotation;
import java.lang.reflect.Member;
@@ -169,7 +170,7 @@ public class XWorkConverter extends DefaultTypeConverter {
this.fileManager = fileManagerFactory.getFileManager();
}
@Inject(value = XWorkConstants.RELOAD_XML_CONFIGURATION, required = false)
@Inject(value = StrutsConstants.STRUTS_CONFIGURATION_XML_RELOAD, required = false)
public void setReloadingConfigs(String reloadingConfigs) {
this.reloadingConfigs = Boolean.parseBoolean(reloadingConfigs);
}
@@ -20,7 +20,6 @@ package com.opensymphony.xwork2.interceptor;
import com.opensymphony.xwork2.ActionContext;
import com.opensymphony.xwork2.ActionInvocation;
import com.opensymphony.xwork2.XWorkConstants;
import com.opensymphony.xwork2.config.entities.ActionConfig;
import com.opensymphony.xwork2.inject.Inject;
import com.opensymphony.xwork2.util.ClearableValueStack;
@@ -32,6 +31,7 @@ import com.opensymphony.xwork2.util.reflection.ReflectionContextState;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.apache.struts2.dispatcher.HttpParameters;
import org.apache.struts2.StrutsConstants;
import java.util.Map;
@@ -99,7 +99,7 @@ public class AliasInterceptor extends AbstractInterceptor {
protected LocalizedTextProvider localizedTextProvider;
protected boolean devMode = false;
@Inject(XWorkConstants.DEV_MODE)
@Inject(StrutsConstants.STRUTS_DEVMODE)
public void setDevMode(String mode) {
this.devMode = Boolean.parseBoolean(mode);
}
@@ -21,7 +21,6 @@ package com.opensymphony.xwork2.interceptor;
import com.opensymphony.xwork2.ActionContext;
import com.opensymphony.xwork2.ActionInvocation;
import com.opensymphony.xwork2.TextProvider;
import com.opensymphony.xwork2.XWorkConstants;
import com.opensymphony.xwork2.inject.Inject;
import com.opensymphony.xwork2.security.AcceptedPatternsChecker;
import com.opensymphony.xwork2.security.ExcludedPatternsChecker;
@@ -30,6 +29,7 @@ import com.opensymphony.xwork2.util.reflection.ReflectionContextState;
import org.apache.commons.lang3.BooleanUtils;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.apache.struts2.StrutsConstants;
import org.apache.struts2.dispatcher.Parameter;
import org.apache.struts2.dispatcher.HttpParameters;
@@ -61,7 +61,7 @@ public class ParametersInterceptor extends MethodFilterInterceptor {
this.valueStackFactory = valueStackFactory;
}
@Inject(XWorkConstants.DEV_MODE)
@Inject(StrutsConstants.STRUTS_DEVMODE)
public void setDevMode(String mode) {
this.devMode = BooleanUtils.toBoolean(mode);
}
@@ -20,7 +20,6 @@ package com.opensymphony.xwork2.interceptor;
import com.opensymphony.xwork2.ActionContext;
import com.opensymphony.xwork2.ActionInvocation;
import com.opensymphony.xwork2.XWorkConstants;
import com.opensymphony.xwork2.config.entities.ActionConfig;
import com.opensymphony.xwork2.config.entities.Parameterizable;
import com.opensymphony.xwork2.inject.Inject;
@@ -33,6 +32,7 @@ import com.opensymphony.xwork2.util.reflection.ReflectionContextState;
import org.apache.commons.lang3.BooleanUtils;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.apache.struts2.StrutsConstants;
import org.apache.struts2.dispatcher.HttpParameters;
import java.util.Collections;
@@ -102,7 +102,7 @@ public class StaticParametersInterceptor extends AbstractInterceptor {
this.valueStackFactory = valueStackFactory;
}
@Inject(XWorkConstants.DEV_MODE)
@Inject(StrutsConstants.STRUTS_DEVMODE)
public void setDevMode(String mode) {
devMode = BooleanUtils.toBoolean(mode);
}
@@ -18,7 +18,6 @@
*/
package com.opensymphony.xwork2.ognl;
import com.opensymphony.xwork2.XWorkConstants;
import com.opensymphony.xwork2.config.ConfigurationException;
import com.opensymphony.xwork2.conversion.impl.XWorkConverter;
import com.opensymphony.xwork2.inject.Container;
@@ -75,17 +74,17 @@ public class OgnlUtil {
this.defaultConverter = new OgnlTypeConverterWrapper(conv);
}
@Inject(XWorkConstants.DEV_MODE)
@Inject(StrutsConstants.STRUTS_DEVMODE)
public void setDevMode(String mode) {
this.devMode = BooleanUtils.toBoolean(mode);
}
@Inject(XWorkConstants.ENABLE_OGNL_EXPRESSION_CACHE)
@Inject(StrutsConstants.STRUTS_ENABLE_OGNL_EXPRESSION_CACHE)
public void setEnableExpressionCache(String cache) {
enableExpressionCache = BooleanUtils.toBoolean(cache);
}
@Inject(value = XWorkConstants.ENABLE_OGNL_EVAL_EXPRESSION, required = false)
@Inject(value = StrutsConstants.STRUTS_ENABLE_OGNL_EVAL_EXPRESSION, required = false)
public void setEnableEvalExpression(String evalExpression) {
enableEvalExpression = "true".equals(evalExpression);
if(enableEvalExpression){
@@ -94,7 +93,7 @@ public class OgnlUtil {
}
}
@Inject(value = XWorkConstants.OGNL_EXCLUDED_CLASSES, required = false)
@Inject(value = StrutsConstants.STRUTS_EXCLUDED_CLASSES, required = false)
public void setExcludedClasses(String commaDelimitedClasses) {
Set<String> classNames = TextParseUtil.commaDelimitedStringToSet(commaDelimitedClasses);
Set<Class<?>> classes = new HashSet<>();
@@ -110,7 +109,7 @@ public class OgnlUtil {
excludedClasses = Collections.unmodifiableSet(classes);
}
@Inject(value = XWorkConstants.OGNL_EXCLUDED_PACKAGE_NAME_PATTERNS, required = false)
@Inject(value = StrutsConstants.STRUTS_EXCLUDED_PACKAGE_NAME_PATTERNS, required = false)
public void setExcludedPackageNamePatterns(String commaDelimitedPackagePatterns) {
Set<String> packagePatterns = TextParseUtil.commaDelimitedStringToSet(commaDelimitedPackagePatterns);
Set<Pattern> packageNamePatterns = new HashSet<>();
@@ -122,7 +121,7 @@ public class OgnlUtil {
excludedPackageNamePatterns = Collections.unmodifiableSet(packageNamePatterns);
}
@Inject(value = XWorkConstants.OGNL_EXCLUDED_PACKAGE_NAMES, required = false)
@Inject(value = StrutsConstants.STRUTS_EXCLUDED_PACKAGE_NAMES, required = false)
public void setExcludedPackageNames(String commaDelimitedPackageNames) {
excludedPackageNames = Collections.unmodifiableSet(TextParseUtil.commaDelimitedStringToSet(commaDelimitedPackageNames));
}
@@ -144,7 +143,7 @@ public class OgnlUtil {
this.container = container;
}
@Inject(value = XWorkConstants.ALLOW_STATIC_METHOD_ACCESS, required = false)
@Inject(value = StrutsConstants.STRUTS_ALLOW_STATIC_METHOD_ACCESS, required = false)
public void setAllowStaticMethodAccess(String allowStaticMethodAccess) {
this.allowStaticMethodAccess = Boolean.parseBoolean(allowStaticMethodAccess);
}
@@ -20,7 +20,6 @@ package com.opensymphony.xwork2.ognl;
import com.opensymphony.xwork2.ActionContext;
import com.opensymphony.xwork2.TextProvider;
import com.opensymphony.xwork2.XWorkConstants;
import com.opensymphony.xwork2.XWorkException;
import com.opensymphony.xwork2.conversion.impl.XWorkConverter;
import com.opensymphony.xwork2.inject.Container;
@@ -35,6 +34,7 @@ import ognl.*;
import org.apache.commons.lang3.BooleanUtils;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.apache.struts2.StrutsConstants;
import java.io.Serializable;
import java.util.HashMap;
@@ -100,7 +100,7 @@ public class OgnlValueStack implements Serializable, ValueStack, ClearableValueS
((OgnlContext) context).setKeepLastEvaluation(false);
}
@Inject(XWorkConstants.DEV_MODE)
@Inject(StrutsConstants.STRUTS_DEVMODE)
public void setDevMode(String mode) {
this.devMode = BooleanUtils.toBoolean(mode);
}
@@ -450,7 +450,7 @@ public class OgnlValueStack implements Serializable, ValueStack, ClearableValueS
XWorkConverter xworkConverter = cont.getInstance(XWorkConverter.class);
CompoundRootAccessor accessor = (CompoundRootAccessor) cont.getInstance(PropertyAccessor.class, CompoundRoot.class.getName());
TextProvider prov = cont.getInstance(TextProvider.class, "system");
boolean allow = BooleanUtils.toBoolean(cont.getInstance(String.class, XWorkConstants.ALLOW_STATIC_METHOD_ACCESS));
boolean allow = BooleanUtils.toBoolean(cont.getInstance(String.class, StrutsConstants.STRUTS_ALLOW_STATIC_METHOD_ACCESS));
OgnlValueStack aStack = new OgnlValueStack(xworkConverter, accessor, prov, allow);
aStack.setOgnlUtil(cont.getInstance(OgnlUtil.class));
aStack.setRoot(xworkConverter, accessor, this.root, allow);
@@ -18,7 +18,6 @@
*/
package com.opensymphony.xwork2.ognl.accessor;
import com.opensymphony.xwork2.XWorkConstants;
import com.opensymphony.xwork2.XWorkException;
import com.opensymphony.xwork2.inject.Inject;
import com.opensymphony.xwork2.ognl.OgnlValueStack;
@@ -28,6 +27,7 @@ import ognl.*;
import org.apache.commons.lang3.BooleanUtils;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.apache.struts2.StrutsConstants;
import java.beans.IntrospectionException;
import java.beans.PropertyDescriptor;
@@ -65,7 +65,7 @@ public class CompoundRootAccessor implements PropertyAccessor, MethodAccessor, C
private static Map<MethodCall, Boolean> invalidMethods = new ConcurrentHashMap<>();
private boolean devMode = false;
@Inject(XWorkConstants.DEV_MODE)
@Inject(StrutsConstants.STRUTS_DEVMODE)
public void setDevMode(String mode) {
this.devMode = BooleanUtils.toBoolean(mode);
}
@@ -18,11 +18,11 @@
*/
package com.opensymphony.xwork2.security;
import com.opensymphony.xwork2.XWorkConstants;
import com.opensymphony.xwork2.inject.Inject;
import com.opensymphony.xwork2.util.TextParseUtil;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.apache.struts2.StrutsConstants;
import java.util.Arrays;
import java.util.HashSet;
@@ -43,17 +43,17 @@ public class DefaultAcceptedPatternsChecker implements AcceptedPatternsChecker {
setAcceptedPatterns(ACCEPTED_PATTERNS);
}
@Inject(value = XWorkConstants.OVERRIDE_ACCEPTED_PATTERNS, required = false)
@Inject(value = StrutsConstants.STRUTS_OVERRIDE_ACCEPTED_PATTERNS, required = false)
public void setOverrideAcceptedPatterns(String acceptablePatterns) {
LOG.warn("Overriding accepted patterns [{}] with [{}], be aware that this affects all instances and safety of your application!",
XWorkConstants.OVERRIDE_ACCEPTED_PATTERNS, acceptablePatterns);
StrutsConstants.STRUTS_OVERRIDE_ACCEPTED_PATTERNS, acceptablePatterns);
acceptedPatterns = new HashSet<>();
for (String pattern : TextParseUtil.commaDelimitedStringToSet(acceptablePatterns)) {
acceptedPatterns.add(Pattern.compile(pattern, Pattern.CASE_INSENSITIVE));
}
}
@Inject(value = XWorkConstants.ADDITIONAL_ACCEPTED_PATTERNS, required = false)
@Inject(value = StrutsConstants.STRUTS_ADDITIONAL_ACCEPTED_PATTERNS, required = false)
public void setAdditionalAcceptedPatterns(String acceptablePatterns) {
LOG.warn("Adding additional global patterns [{}] to accepted patterns!", acceptablePatterns);
for (String pattern : TextParseUtil.commaDelimitedStringToSet(acceptablePatterns)) {
@@ -18,7 +18,6 @@
*/
package com.opensymphony.xwork2.security;
import com.opensymphony.xwork2.XWorkConstants;
import com.opensymphony.xwork2.inject.Inject;
import com.opensymphony.xwork2.util.TextParseUtil;
import org.apache.commons.lang3.BooleanUtils;
@@ -46,17 +45,17 @@ public class DefaultExcludedPatternsChecker implements ExcludedPatternsChecker {
setExcludedPatterns(EXCLUDED_PATTERNS);
}
@Inject(value = XWorkConstants.OVERRIDE_EXCLUDED_PATTERNS, required = false)
@Inject(value = StrutsConstants.STRUTS_OVERRIDE_EXCLUDED_PATTERNS, required = false)
public void setOverrideExcludePatterns(String excludePatterns) {
LOG.warn("Overriding excluded patterns [{}] with [{}], be aware that this affects all instances and safety of your application!",
XWorkConstants.OVERRIDE_EXCLUDED_PATTERNS, excludePatterns);
StrutsConstants.STRUTS_OVERRIDE_EXCLUDED_PATTERNS, excludePatterns);
excludedPatterns = new HashSet<Pattern>();
for (String pattern : TextParseUtil.commaDelimitedStringToSet(excludePatterns)) {
excludedPatterns.add(Pattern.compile(pattern, Pattern.CASE_INSENSITIVE));
}
}
@Inject(value = XWorkConstants.ADDITIONAL_EXCLUDED_PATTERNS, required = false)
@Inject(value = StrutsConstants.STRUTS_ADDITIONAL_EXCLUDED_PATTERNS, required = false)
public void setAdditionalExcludePatterns(String excludePatterns) {
LOG.debug("Adding additional global patterns [{}] to excluded patterns!", excludePatterns);
for (String pattern : TextParseUtil.commaDelimitedStringToSet(excludePatterns)) {
@@ -26,6 +26,7 @@ import com.opensymphony.xwork2.util.ValueStack;
import org.apache.commons.lang3.StringUtils;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.apache.struts2.StrutsConstants;
import java.io.IOException;
import java.io.InputStream;
@@ -71,7 +72,7 @@ public class AnnotationActionValidatorManager implements ActionValidatorManager
this.fileManager = fileManagerFactory.getFileManager();
}
@Inject(value = XWorkConstants.RELOAD_XML_CONFIGURATION, required = false)
@Inject(value = StrutsConstants.STRUTS_CONFIGURATION_XML_RELOAD, required = false)
public void setReloadingConfigs(String reloadingConfigs) {
this.reloadingConfigs = Boolean.parseBoolean(reloadingConfigs);
}
@@ -22,12 +22,12 @@ import com.opensymphony.xwork2.ActionContext;
import com.opensymphony.xwork2.FileManager;
import com.opensymphony.xwork2.FileManagerFactory;
import com.opensymphony.xwork2.TextProviderFactory;
import com.opensymphony.xwork2.XWorkConstants;
import com.opensymphony.xwork2.inject.Inject;
import com.opensymphony.xwork2.util.ClassLoaderUtil;
import com.opensymphony.xwork2.util.ValueStack;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.apache.struts2.StrutsConstants;
import java.io.IOException;
import java.io.InputStream;
@@ -82,7 +82,7 @@ public class DefaultActionValidatorManager implements ActionValidatorManager {
this.fileManager = fileManagerFactory.getFileManager();
}
@Inject(value = XWorkConstants.RELOAD_XML_CONFIGURATION, required = false)
@Inject(value = StrutsConstants.STRUTS_CONFIGURATION_XML_RELOAD, required = false)
public void setReloadingConfigs(String reloadingConfigs) {
this.reloadingConfigs = Boolean.parseBoolean(reloadingConfigs);
}
@@ -89,12 +89,6 @@ public abstract class AbstractBeanSelectionProvider implements BeanSelectionProv
}
}
protected void convertIfExist(LocatableProperties props, String fromKey, String toKey) {
if (props.containsKey(fromKey)) {
props.setProperty(toKey, props.getProperty(fromKey));
}
}
static class ObjectFactoryDelegateFactory implements Factory {
String name;
@@ -30,7 +30,6 @@ import com.opensymphony.xwork2.FileManagerFactory;
import com.opensymphony.xwork2.ObjectFactory;
import com.opensymphony.xwork2.TextProvider;
import com.opensymphony.xwork2.UnknownHandlerManager;
import com.opensymphony.xwork2.XWorkConstants;
import com.opensymphony.xwork2.conversion.ConversionAnnotationProcessor;
import com.opensymphony.xwork2.conversion.ConversionFileProcessor;
import com.opensymphony.xwork2.conversion.ConversionPropertiesProcessor;
@@ -426,22 +425,6 @@ public class DefaultBeanSelectionProvider extends AbstractBeanSelectionProvider
alias(AcceptedPatternsChecker.class, StrutsConstants.STRUTS_ACCEPTED_PATTERNS_CHECKER, builder, props, Scope.PROTOTYPE);
switchDevMode(props);
// Convert Struts properties into XWork properties
convertIfExist(props, StrutsConstants.STRUTS_LOG_MISSING_PROPERTIES, XWorkConstants.LOG_MISSING_PROPERTIES);
convertIfExist(props, StrutsConstants.STRUTS_ENABLE_OGNL_EXPRESSION_CACHE, XWorkConstants.ENABLE_OGNL_EXPRESSION_CACHE);
convertIfExist(props, StrutsConstants.STRUTS_ENABLE_OGNL_EVAL_EXPRESSION, XWorkConstants.ENABLE_OGNL_EVAL_EXPRESSION);
convertIfExist(props, StrutsConstants.STRUTS_ALLOW_STATIC_METHOD_ACCESS, XWorkConstants.ALLOW_STATIC_METHOD_ACCESS);
convertIfExist(props, StrutsConstants.STRUTS_CONFIGURATION_XML_RELOAD, XWorkConstants.RELOAD_XML_CONFIGURATION);
convertIfExist(props, StrutsConstants.STRUTS_EXCLUDED_CLASSES, XWorkConstants.OGNL_EXCLUDED_CLASSES);
convertIfExist(props, StrutsConstants.STRUTS_EXCLUDED_PACKAGE_NAME_PATTERNS, XWorkConstants.OGNL_EXCLUDED_PACKAGE_NAME_PATTERNS);
convertIfExist(props, StrutsConstants.STRUTS_EXCLUDED_PACKAGE_NAMES, XWorkConstants.OGNL_EXCLUDED_PACKAGE_NAMES);
convertIfExist(props, StrutsConstants.STRUTS_ADDITIONAL_EXCLUDED_PATTERNS, XWorkConstants.ADDITIONAL_EXCLUDED_PATTERNS);
convertIfExist(props, StrutsConstants.STRUTS_ADDITIONAL_ACCEPTED_PATTERNS, XWorkConstants.ADDITIONAL_ACCEPTED_PATTERNS);
convertIfExist(props, StrutsConstants.STRUTS_OVERRIDE_EXCLUDED_PATTERNS, XWorkConstants.OVERRIDE_EXCLUDED_PATTERNS);
convertIfExist(props, StrutsConstants.STRUTS_OVERRIDE_ACCEPTED_PATTERNS, XWorkConstants.OVERRIDE_ACCEPTED_PATTERNS);
}
/**
@@ -460,10 +443,6 @@ public class DefaultBeanSelectionProvider extends AbstractBeanSelectionProvider
if (props.getProperty(StrutsConstants.STRUTS_FREEMARKER_TEMPLATES_CACHE_UPDATE_DELAY) == null) {
props.setProperty(StrutsConstants.STRUTS_FREEMARKER_TEMPLATES_CACHE_UPDATE_DELAY, "0");
}
// Convert struts properties into ones that xwork expects
props.setProperty(XWorkConstants.DEV_MODE, "true");
} else {
props.setProperty(XWorkConstants.DEV_MODE, "false");
}
}
@@ -555,7 +555,7 @@ public class ParametersInterceptorTest extends XWorkTestCase {
XmlConfigurationProvider provider = new XmlConfigurationProvider("xwork-test-beans.xml");
container.inject(provider);
loadConfigurationProviders(provider,
new MockConfigurationProvider(Collections.singletonMap("devMode", "true")));
new MockConfigurationProvider(Collections.singletonMap("struts.devMode", "true")));
Map<String, Object> params = new HashMap<>();
params.put("not_a_property", "There is no action property named like this");
@@ -574,7 +574,7 @@ public class ParametersInterceptorTest extends XWorkTestCase {
XmlConfigurationProvider provider = new XmlConfigurationProvider("xwork-test-beans.xml");
container.inject(provider);
loadConfigurationProviders(provider,
new MockConfigurationProvider(Collections.singletonMap("devMode", "false")));
new MockConfigurationProvider(Collections.singletonMap("struts.devMode", "false")));
Map<String, Object> params = new HashMap<>();
params.put("not_a_property", "There is no action property named like this");
@@ -22,7 +22,6 @@ import com.opensymphony.xwork2.ActionContext;
import com.opensymphony.xwork2.ActionInvocation;
import com.opensymphony.xwork2.ActionSupport;
import com.opensymphony.xwork2.DefaultActionInvocation;
import com.opensymphony.xwork2.XWorkConstants;
import com.opensymphony.xwork2.XWorkTestCase;
import com.opensymphony.xwork2.config.Configuration;
import com.opensymphony.xwork2.config.ConfigurationException;
@@ -50,6 +49,7 @@ import com.opensymphony.xwork2.validator.validators.ShortRangeFieldValidator;
import com.opensymphony.xwork2.validator.validators.StringLengthFieldValidator;
import com.opensymphony.xwork2.validator.validators.URLValidator;
import com.opensymphony.xwork2.validator.validators.VisitorFieldValidator;
import org.apache.struts2.StrutsConstants;
import java.text.ParseException;
import java.text.SimpleDateFormat;
@@ -331,7 +331,7 @@ public class AnnotationValidationConfigurationBuilderTest extends XWorkTestCase
}
public void register(ContainerBuilder builder, LocatableProperties props) throws ConfigurationException {
builder.constant(XWorkConstants.DEV_MODE, true);
builder.constant(StrutsConstants.STRUTS_DEVMODE, true);
}
});
@@ -23,7 +23,6 @@ import com.mockobjects.dynamic.Mock;
import com.opensymphony.xwork2.ActionContext;
import com.opensymphony.xwork2.ObjectFactory;
import com.opensymphony.xwork2.StubValueStack;
import com.opensymphony.xwork2.XWorkConstants;
import com.opensymphony.xwork2.config.Configuration;
import com.opensymphony.xwork2.config.ConfigurationManager;
import com.opensymphony.xwork2.config.entities.InterceptorMapping;
@@ -230,8 +229,8 @@ public class DispatcherTest extends StrutsInternalTestCase {
cm.setConfiguration((Configuration)mockConfiguration.proxy());
Mock mockContainer = new Mock(Container.class);
String reloadConfigs = container.getInstance(String.class, XWorkConstants.RELOAD_XML_CONFIGURATION);
mockContainer.expectAndReturn("getInstance", C.args(C.eq(String.class), C.eq(XWorkConstants.RELOAD_XML_CONFIGURATION)),
String reloadConfigs = container.getInstance(String.class, StrutsConstants.STRUTS_CONFIGURATION_XML_RELOAD);
mockContainer.expectAndReturn("getInstance", C.args(C.eq(String.class), C.eq(StrutsConstants.STRUTS_CONFIGURATION_XML_RELOAD)),
reloadConfigs);
final InnerDestroyableObjectFactory destroyedObjectFactory = new InnerDestroyableObjectFactory();
destroyedObjectFactory.setContainer((Container) mockContainer.proxy());
@@ -266,8 +265,8 @@ public class DispatcherTest extends StrutsInternalTestCase {
Mock mockContainer = new Mock(Container.class);
mockContainer.matchAndReturn("getInstance", C.args(C.eq(ObjectFactory.class)), new ObjectFactory());
String reloadConfigs = container.getInstance(String.class, XWorkConstants.RELOAD_XML_CONFIGURATION);
mockContainer.expectAndReturn("getInstance", C.args(C.eq(String.class), C.eq(XWorkConstants.RELOAD_XML_CONFIGURATION)),
String reloadConfigs = container.getInstance(String.class, StrutsConstants.STRUTS_CONFIGURATION_XML_RELOAD);
mockContainer.expectAndReturn("getInstance", C.args(C.eq(String.class), C.eq(StrutsConstants.STRUTS_CONFIGURATION_XML_RELOAD)),
reloadConfigs);
Mock mockConfiguration = new Mock(Configuration.class);
@@ -25,8 +25,8 @@
<xwork>
<constant name="devMode" value="true" />
<constant name="ognlExcludedClasses" value="java.lang.Object,java.lang.Runtime" />
<constant name="overrideExcludedPatterns" value="not-existing-pattern"/>
<constant name="struts.devMode" value="true" />
<constant name="struts.excludedClasses" value="java.lang.Object,java.lang.Runtime" />
<constant name="struts.override.excludedPatterns" value="not-existing-pattern"/>
</xwork>
</xwork>
+3 -3
View File
@@ -24,7 +24,7 @@
"http://struts.apache.org/dtds/xwork-2.0.dtd">
<xwork>
<constant name="devMode" value="true" />
<constant name="ognlExcludedClasses" value="java.lang.Object,java.lang.Runtime" />
<constant name="additionalExcludedPatterns" value=".*(^|\.|\[|\'|&quot;)class(\.|\[|\'|&quot;).*" />
<constant name="struts.devMode" value="true" />
<constant name="struts.excludedClasses" value="java.lang.Object,java.lang.Runtime" />
<constant name="struts.additional.excludedPatterns" value=".*(^|\.|\[|\'|&quot;)class(\.|\[|\'|&quot;).*" />
</xwork>
+2 -2
View File
@@ -25,6 +25,6 @@
<xwork>
<constant name="ognlExcludedClasses" value="java.lang.Object,java.lang.Runtime,ognl.OgnlContext,ognl.MemberAccess,ognl.ClassResolver,ognl.TypeConverter,com.opensymphony.xwork2.ognl.SecurityMemberAccess" />
<constant name="struts.excludedClasses" value="java.lang.Object,java.lang.Runtime,ognl.OgnlContext,ognl.MemberAccess,ognl.ClassResolver,ognl.TypeConverter,com.opensymphony.xwork2.ognl.SecurityMemberAccess" />
</xwork>
</xwork>