Skip to content

Commit

Permalink
WW-5411 Delete deprecated code part 4
Browse files Browse the repository at this point in the history
  • Loading branch information
kusalk committed Jul 25, 2024
1 parent 6c6ef44 commit e411f9c
Show file tree
Hide file tree
Showing 17 changed files with 66 additions and 257 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,4 @@ public interface TypeConverter {

Object NO_CONVERSION_POSSIBLE = "ognl.NoConversionPossible";

@Deprecated
String TYPE_CONVERTER_CONTEXT_KEY = "_typeConverter";

}
Original file line number Diff line number Diff line change
Expand Up @@ -226,21 +226,6 @@ public void setDelegatedClassLoader(final ClassLoader classLoader) {
}
}

/**
* 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.
Expand Down Expand Up @@ -491,16 +476,6 @@ public ResourceBundle findResourceBundle(String aBundleName, Locale locale) {
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.
*
Expand All @@ -513,12 +488,7 @@ protected boolean unableToFindTextForKey(GetDefaultMessageReturnArg result) {
}

// did we find it in the bundle, then no problem?
if (result.foundInBundle) {
return false;
}

// not found in bundle
return true;
return !result.foundInBundle;
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -65,49 +74,42 @@ public DelegatingValidatorContext(Object object, TextProviderFactory textProvide
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();
}
Expand All @@ -127,78 +129,97 @@ public Locale toLocale(String localeStr) {
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();
}
Expand Down Expand Up @@ -307,62 +328,73 @@ public LoggingValidationAware(Object obj) {
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;
}
Expand Down
19 changes: 0 additions & 19 deletions core/src/main/java/org/apache/struts2/StrutsConstants.java
Original file line number Diff line number Diff line change
Expand Up @@ -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}.
Expand Down Expand Up @@ -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";

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,16 +68,6 @@ public StrutsXmlConfigurationProvider() {
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
*
Expand Down
Loading

0 comments on commit e411f9c

Please sign in to comment.