mirror of
https://github.com/apache/struts.git
synced 2026-08-06 23:27:07 +00:00
WW-5411 Delete deprecated code part 3
This commit is contained in:
@@ -74,17 +74,6 @@ public abstract class AbstractMatcher<E> implements Serializable {
|
||||
this.appendNamedParameters = appendNamedParameters;
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a matcher with {@link #appendNamedParameters} set to true to keep backward compatibility
|
||||
*
|
||||
* @param helper an instance of {@link PatternMatcher}
|
||||
* @deprecated use @{link {@link AbstractMatcher(PatternMatcher, boolean)} instead
|
||||
*/
|
||||
@Deprecated
|
||||
public AbstractMatcher(PatternMatcher<?> helper) {
|
||||
this(helper, true);
|
||||
}
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* Finds and precompiles the wildcard patterns. Patterns will be evaluated
|
||||
@@ -108,7 +97,7 @@ public abstract class AbstractMatcher<E> implements Serializable {
|
||||
Object pattern;
|
||||
|
||||
if (!wildcard.isLiteral(name)) {
|
||||
if (looseMatch && (name.length() > 0) && (name.charAt(0) == '/')) {
|
||||
if (looseMatch && (!name.isEmpty()) && (name.charAt(0) == '/')) {
|
||||
name = name.substring(1);
|
||||
}
|
||||
|
||||
@@ -142,14 +131,14 @@ public abstract class AbstractMatcher<E> implements Serializable {
|
||||
public E match(String potentialMatch) {
|
||||
E config = null;
|
||||
|
||||
if (compiledPatterns.size() > 0) {
|
||||
if (!compiledPatterns.isEmpty()) {
|
||||
LOG.debug("Attempting to match '{}' to a wildcard pattern, {} available", potentialMatch, compiledPatterns.size());
|
||||
|
||||
Map<String, String> vars = new LinkedHashMap<>();
|
||||
for (Mapping<E> m : compiledPatterns) {
|
||||
if (wildcard.match(vars, potentialMatch, m.getPattern())) {
|
||||
LOG.debug("Value matches pattern '{}'", m.getOriginalPattern());
|
||||
config = convert(potentialMatch, m.getTarget(), vars);
|
||||
if (wildcard.match(vars, potentialMatch, m.pattern())) {
|
||||
LOG.debug("Value matches pattern '{}'", m.originalPattern());
|
||||
config = convert(potentialMatch, m.target(), vars);
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -216,7 +205,7 @@ public abstract class AbstractMatcher<E> implements Serializable {
|
||||
|
||||
Matcher wildcardMatcher = WILDCARD_PATTERN.matcher(val);
|
||||
|
||||
StringBuffer result = new StringBuffer();
|
||||
StringBuilder result = new StringBuilder();
|
||||
while (wildcardMatcher.find()) {
|
||||
wildcardMatcher.appendReplacement(result, vars.getOrDefault(wildcardMatcher.group(1), ""));
|
||||
}
|
||||
@@ -228,62 +217,11 @@ public abstract class AbstractMatcher<E> implements Serializable {
|
||||
/**
|
||||
* <p> Stores a compiled wildcard pattern and the object it came
|
||||
* from. </p>
|
||||
*
|
||||
* @param originalPattern <p> The original pattern. </p>
|
||||
* @param pattern <p> The compiled pattern. </p>
|
||||
* @param target <p> The original object. </p>
|
||||
*/
|
||||
private static class Mapping<E> implements Serializable {
|
||||
/**
|
||||
* <p> The original pattern. </p>
|
||||
*/
|
||||
private final String original;
|
||||
|
||||
|
||||
/**
|
||||
* <p> The compiled pattern. </p>
|
||||
*/
|
||||
private final Object pattern;
|
||||
|
||||
/**
|
||||
* <p> The original object. </p>
|
||||
*/
|
||||
private final E config;
|
||||
|
||||
/**
|
||||
* <p> Contructs a read-only Mapping instance. </p>
|
||||
*
|
||||
* @param original The original pattern
|
||||
* @param pattern The compiled pattern
|
||||
* @param config The original object
|
||||
*/
|
||||
public Mapping(String original, Object pattern, E config) {
|
||||
this.original = original;
|
||||
this.pattern = pattern;
|
||||
this.config = config;
|
||||
}
|
||||
|
||||
/**
|
||||
* <p> Gets the compiled wildcard pattern. </p>
|
||||
*
|
||||
* @return The compiled pattern
|
||||
*/
|
||||
public Object getPattern() {
|
||||
return this.pattern;
|
||||
}
|
||||
|
||||
/**
|
||||
* <p> Gets the object that contains the pattern. </p>
|
||||
*
|
||||
* @return The associated object
|
||||
*/
|
||||
public E getTarget() {
|
||||
return this.config;
|
||||
}
|
||||
|
||||
/**
|
||||
* <p> Gets the original wildcard pattern. </p>
|
||||
*
|
||||
* @return The original pattern
|
||||
*/
|
||||
public String getOriginalPattern() {
|
||||
return this.original;
|
||||
}
|
||||
private record Mapping<E>(String originalPattern, Object pattern, E target) implements Serializable {
|
||||
}
|
||||
}
|
||||
|
||||
@@ -124,7 +124,7 @@ public class NamedVariablePatternMatcher implements PatternMatcher<NamedVariable
|
||||
*/
|
||||
public boolean match(Map<String, String> map, String data, CompiledPattern expr) {
|
||||
|
||||
if (data != null && data.length() > 0) {
|
||||
if (data != null && !data.isEmpty()) {
|
||||
Matcher matcher = expr.getPattern().matcher(data);
|
||||
if (matcher.matches()) {
|
||||
for (int x = 0; x < expr.getVariableNames().size(); x++) {
|
||||
|
||||
@@ -22,10 +22,10 @@ import java.util.Map;
|
||||
|
||||
/**
|
||||
* Compiles and matches a pattern against a value
|
||||
*
|
||||
*
|
||||
* @since 2.1
|
||||
*/
|
||||
public interface PatternMatcher<E extends Object> {
|
||||
public interface PatternMatcher<E> {
|
||||
|
||||
/**
|
||||
* Determines if the pattern is a simple literal string or contains wildcards that will need to be processed
|
||||
@@ -36,16 +36,16 @@ public interface PatternMatcher<E extends Object> {
|
||||
|
||||
/**
|
||||
* <p> Translate the given <code>String</code> into an object
|
||||
* representing the pattern matchable by this class.
|
||||
* representing the pattern matchable by this class.
|
||||
*
|
||||
* @param data The string to translate.
|
||||
* @return The encoded string
|
||||
* @return The encoded string
|
||||
* @throws NullPointerException If data is null.
|
||||
*/
|
||||
E compilePattern(String data);
|
||||
|
||||
/**
|
||||
* Match a pattern against a string
|
||||
* Match a pattern against a string
|
||||
*
|
||||
* @param map The map to store matched values
|
||||
* @param data The string to match
|
||||
@@ -54,5 +54,5 @@ public interface PatternMatcher<E extends Object> {
|
||||
* @throws NullPointerException If any parameters are null
|
||||
*/
|
||||
boolean match(Map<String,String> map, String data, E expr);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -38,65 +38,11 @@ public class StrutsLocalizedTextProvider extends AbstractLocalizedTextProvider {
|
||||
|
||||
private static final Logger LOG = LogManager.getLogger(StrutsLocalizedTextProvider.class);
|
||||
|
||||
/**
|
||||
* Clears the internal list of resource bundles.
|
||||
*
|
||||
* @deprecated used only in tests
|
||||
*/
|
||||
@Deprecated
|
||||
public static void clearDefaultResourceBundles() {
|
||||
// no-op
|
||||
}
|
||||
|
||||
public StrutsLocalizedTextProvider() {
|
||||
addDefaultResourceBundle(XWORK_MESSAGES_BUNDLE);
|
||||
addDefaultResourceBundle(STRUTS_MESSAGES_BUNDLE);
|
||||
}
|
||||
|
||||
/**
|
||||
* Builds a {@link java.util.Locale} from a String of the form en_US_foo into a Locale
|
||||
* with language "en", country "US" and variant "foo". This will parse the output of
|
||||
* {@link java.util.Locale#toString()}.
|
||||
*
|
||||
* @param localeStr The locale String to parse.
|
||||
* @param defaultLocale The locale to use if localeStr is <tt>null</tt>.
|
||||
* @return requested Locale
|
||||
* @deprecated please use {@link org.apache.commons.lang3.LocaleUtils#toLocale(String)}
|
||||
*/
|
||||
@Deprecated
|
||||
public static Locale localeFromString(String localeStr, Locale defaultLocale) {
|
||||
if ((localeStr == null) || (localeStr.trim().length() == 0) || ("_".equals(localeStr))) {
|
||||
if (defaultLocale != null) {
|
||||
return defaultLocale;
|
||||
}
|
||||
return Locale.getDefault();
|
||||
}
|
||||
|
||||
int index = localeStr.indexOf('_');
|
||||
if (index < 0) {
|
||||
return new Locale(localeStr);
|
||||
}
|
||||
|
||||
String language = localeStr.substring(0, index);
|
||||
if (index == localeStr.length()) {
|
||||
return new Locale(language);
|
||||
}
|
||||
|
||||
localeStr = localeStr.substring(index + 1);
|
||||
index = localeStr.indexOf('_');
|
||||
if (index < 0) {
|
||||
return new Locale(language, localeStr);
|
||||
}
|
||||
|
||||
String country = localeStr.substring(0, index);
|
||||
if (index == localeStr.length()) {
|
||||
return new Locale(language, country);
|
||||
}
|
||||
|
||||
localeStr = localeStr.substring(index + 1);
|
||||
return new Locale(language, country, localeStr);
|
||||
}
|
||||
|
||||
/**
|
||||
* Calls {@link #findText(Class aClass, String aTextName, Locale locale, String defaultMessage, Object[] args)}
|
||||
* with aTextName as the default message.
|
||||
@@ -135,7 +81,7 @@ public class StrutsLocalizedTextProvider extends AbstractLocalizedTextProvider {
|
||||
* object. If so, repeat the entire process from the beginning with the object's class as
|
||||
* aClass and "address.state" as the message key.</li>
|
||||
* <li>If not found, look for the message in aClass' package hierarchy.</li>
|
||||
* <li>If still not found, look for the message in the default resource bundles
|
||||
* <li>If still not found, look for the message in the default resource bundles
|
||||
* (Note: the lookup is not repeated again if {@link #searchDefaultBundlesFirst} was <code>true</code>).</li>
|
||||
* <li>Return defaultMessage</li>
|
||||
* </ol>
|
||||
@@ -190,7 +136,7 @@ public class StrutsLocalizedTextProvider extends AbstractLocalizedTextProvider {
|
||||
* object. If so, repeat the entire process from the beginning with the object's class as
|
||||
* aClass and "address.state" as the message key.</li>
|
||||
* <li>If not found, look for the message in aClass' package hierarchy.</li>
|
||||
* <li>If still not found, look for the message in the default resource bundles
|
||||
* <li>If still not found, look for the message in the default resource bundles
|
||||
* (Note: the lookup is not repeated again if {@link #searchDefaultBundlesFirst} was <code>true</code>).</li>
|
||||
* <li>Return defaultMessage</li>
|
||||
* </ol>
|
||||
|
||||
@@ -28,7 +28,6 @@ import freemarker.cache.ClassTemplateLoader;
|
||||
import freemarker.cache.FileTemplateLoader;
|
||||
import freemarker.cache.MultiTemplateLoader;
|
||||
import freemarker.cache.TemplateLoader;
|
||||
import freemarker.ext.jakarta.servlet.WebappTemplateLoader;
|
||||
import freemarker.core.HTMLOutputFormat;
|
||||
import freemarker.core.TemplateClassResolver;
|
||||
import freemarker.ext.jakarta.jsp.TaglibFactory;
|
||||
@@ -36,6 +35,7 @@ import freemarker.ext.jakarta.servlet.HttpRequestHashModel;
|
||||
import freemarker.ext.jakarta.servlet.HttpRequestParametersHashModel;
|
||||
import freemarker.ext.jakarta.servlet.HttpSessionHashModel;
|
||||
import freemarker.ext.jakarta.servlet.ServletContextHashModel;
|
||||
import freemarker.ext.jakarta.servlet.WebappTemplateLoader;
|
||||
import freemarker.template.Configuration;
|
||||
import freemarker.template.ObjectWrapper;
|
||||
import freemarker.template.TemplateException;
|
||||
@@ -43,6 +43,11 @@ import freemarker.template.TemplateExceptionHandler;
|
||||
import freemarker.template.TemplateModel;
|
||||
import freemarker.template.Version;
|
||||
import freemarker.template.utility.StringUtil;
|
||||
import jakarta.servlet.GenericServlet;
|
||||
import jakarta.servlet.ServletContext;
|
||||
import jakarta.servlet.http.HttpServletRequest;
|
||||
import jakarta.servlet.http.HttpServletResponse;
|
||||
import jakarta.servlet.http.HttpSession;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
import org.apache.struts2.StrutsConstants;
|
||||
@@ -50,11 +55,6 @@ import org.apache.struts2.views.JspSupportServlet;
|
||||
import org.apache.struts2.views.TagLibraryModelProvider;
|
||||
import org.apache.struts2.views.util.ContextUtil;
|
||||
|
||||
import jakarta.servlet.GenericServlet;
|
||||
import jakarta.servlet.ServletContext;
|
||||
import jakarta.servlet.http.HttpServletRequest;
|
||||
import jakarta.servlet.http.HttpServletResponse;
|
||||
import jakarta.servlet.http.HttpSession;
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
@@ -137,27 +137,6 @@ public class FreemarkerManager {
|
||||
|
||||
public static final String EXPIRATION_DATE;
|
||||
|
||||
/**
|
||||
* @deprecated since Struts 6.5.0, do not use as it will be removed in Struts 7.0.0
|
||||
*/
|
||||
@Deprecated
|
||||
public static final String KEY_INCLUDE = "include_page";
|
||||
/**
|
||||
* @deprecated since Struts 6.5.0, do not use as it will be removed in Struts 7.0.0
|
||||
*/
|
||||
@Deprecated
|
||||
public static final String KEY_REQUEST_PRIVATE = "__FreeMarkerServlet.Request__";
|
||||
/**
|
||||
* @deprecated since Struts 6.5.0, do not use as it will be removed in Struts 7.0.0
|
||||
*/
|
||||
@Deprecated
|
||||
public static final String KEY_REQUEST_PARAMETERS = "RequestParameters";
|
||||
/**
|
||||
* @deprecated since Struts 6.5.0, do not use as it will be removed in Struts 7.0.0
|
||||
*/
|
||||
@Deprecated
|
||||
public static final String KEY_HASHMODEL_PRIVATE = "__FreeMarkerManager.Request__";
|
||||
|
||||
/**
|
||||
* Adds individual settings.
|
||||
*
|
||||
|
||||
@@ -178,16 +178,6 @@
|
||||
<bean type="com.opensymphony.xwork2.ognl.accessor.RootAccessor" name="struts"
|
||||
class="com.opensymphony.xwork2.ognl.accessor.CompoundRootAccessor"/>
|
||||
|
||||
<!-- DEPRECATED since 6.4.0 - The following 3 beans are retained for backwards compatibility
|
||||
with custom beans that may expect them to be present. Inject the DEFAULT bean of type
|
||||
'com.opensymphony.xwork2.ognl.accessor.RootAccessor' above instead. -->
|
||||
<bean type="ognl.ClassResolver" name="com.opensymphony.xwork2.util.CompoundRoot"
|
||||
class="com.opensymphony.xwork2.ognl.accessor.CompoundRootAccessor"/>
|
||||
<bean type="ognl.PropertyAccessor" name="com.opensymphony.xwork2.util.CompoundRoot"
|
||||
class="com.opensymphony.xwork2.ognl.accessor.CompoundRootAccessor"/>
|
||||
<bean type="ognl.MethodAccessor" name="com.opensymphony.xwork2.util.CompoundRoot"
|
||||
class="com.opensymphony.xwork2.ognl.accessor.CompoundRootAccessor"/>
|
||||
|
||||
<bean type="ognl.PropertyAccessor" name="java.lang.Object"
|
||||
class="com.opensymphony.xwork2.ognl.accessor.ObjectAccessor"/>
|
||||
<bean type="ognl.PropertyAccessor" name="java.util.Iterator"
|
||||
@@ -212,11 +202,6 @@
|
||||
<bean type="ognl.MethodAccessor" name="struts"
|
||||
class="com.opensymphony.xwork2.ognl.accessor.XWorkMethodAccessor"/>
|
||||
|
||||
<!-- DEPRECATED since 6.4.0 - Retained for backwards compatibility with custom beans
|
||||
that may expect it to be present. Inject the DEFAULT bean of 'ognl.MethodAccessor' above instead. -->
|
||||
<bean type="ognl.MethodAccessor" name="java.lang.Object"
|
||||
class="com.opensymphony.xwork2.ognl.accessor.XWorkMethodAccessor"/>
|
||||
|
||||
<bean type="org.apache.struts2.dispatcher.StaticContentLoader"
|
||||
class="org.apache.struts2.dispatcher.DefaultStaticContentLoader" name="struts"/>
|
||||
<bean type="com.opensymphony.xwork2.UnknownHandlerManager"
|
||||
|
||||
-32
@@ -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.portlet.interceptor;
|
||||
|
||||
import javax.portlet.PortletContext;
|
||||
|
||||
@Deprecated
|
||||
public interface PortletContextAware extends org.apache.struts2.portlet.action.PortletContextAware {
|
||||
|
||||
void setPortletContext(PortletContext portletContext);
|
||||
|
||||
@Override
|
||||
default void withPortletContext(PortletContext context) {
|
||||
setPortletContext(context);
|
||||
}
|
||||
}
|
||||
-32
@@ -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.portlet.interceptor;
|
||||
|
||||
import javax.portlet.PortletPreferences;
|
||||
|
||||
@Deprecated
|
||||
public interface PortletPreferencesAware extends org.apache.struts2.portlet.action.PortletPreferencesAware {
|
||||
|
||||
void setPortletPreferences(PortletPreferences prefs);
|
||||
|
||||
@Override
|
||||
default void withPortletPreferences(PortletPreferences prefs) {
|
||||
setPortletPreferences(prefs);
|
||||
}
|
||||
}
|
||||
-32
@@ -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.portlet.interceptor;
|
||||
|
||||
import javax.portlet.PortletRequest;
|
||||
|
||||
@Deprecated
|
||||
public interface PortletRequestAware extends org.apache.struts2.portlet.action.PortletRequestAware {
|
||||
|
||||
void setPortletRequest(PortletRequest request);
|
||||
|
||||
@Override
|
||||
default void withPortletRequest(PortletRequest request) {
|
||||
setPortletRequest(request);
|
||||
}
|
||||
}
|
||||
-32
@@ -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.portlet.interceptor;
|
||||
|
||||
import javax.portlet.PortletResponse;
|
||||
|
||||
@Deprecated
|
||||
public interface PortletResponseAware extends org.apache.struts2.portlet.action.PortletResponseAware {
|
||||
|
||||
void setPortletResponse(PortletResponse response);
|
||||
|
||||
@Override
|
||||
default void withPortletResponse(PortletResponse response) {
|
||||
setPortletResponse(response);
|
||||
}
|
||||
}
|
||||
@@ -19,12 +19,9 @@
|
||||
package org.apache.struts2.rest;
|
||||
|
||||
import com.opensymphony.xwork2.ActionInvocation;
|
||||
import org.apache.struts2.rest.handler.ContentTypeHandler;
|
||||
|
||||
import jakarta.servlet.http.HttpServletRequest;
|
||||
import jakarta.servlet.http.HttpServletResponse;
|
||||
|
||||
import com.opensymphony.xwork2.config.entities.ActionConfig;
|
||||
import org.apache.struts2.rest.handler.ContentTypeHandler;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
@@ -52,24 +49,17 @@ public interface ContentTypeHandlerManager {
|
||||
/**
|
||||
* Handles the result using handlers to generate content type-specific content
|
||||
*
|
||||
* @param actionConfig The action config for the current request
|
||||
* @param methodResult The object returned from the action method
|
||||
* @param target The object to return, usually the action object
|
||||
* @param actionInvocation The action invocation for the current request
|
||||
* @param methodResult The object returned from the action method
|
||||
* @param target The object to return, usually the action object
|
||||
* @return The new result code to process
|
||||
* @throws IOException If unable to write to the response
|
||||
*
|
||||
* @deprecated use version which requires {@link ActionInvocation}
|
||||
*/
|
||||
@Deprecated
|
||||
String handleResult(ActionConfig actionConfig, Object methodResult, Object target)
|
||||
throws IOException;
|
||||
|
||||
String handleResult(ActionInvocation actionInvocation, Object methodResult, Object target)
|
||||
throws IOException;
|
||||
String handleResult(ActionInvocation actionInvocation, Object methodResult, Object target) throws IOException;
|
||||
|
||||
/**
|
||||
* Finds the extension in the url
|
||||
*
|
||||
*
|
||||
* @param url The url
|
||||
* @return The extension
|
||||
*/
|
||||
|
||||
+8
-10
@@ -22,13 +22,13 @@ import com.opensymphony.xwork2.ActionInvocation;
|
||||
import com.opensymphony.xwork2.config.entities.ActionConfig;
|
||||
import com.opensymphony.xwork2.inject.Container;
|
||||
import com.opensymphony.xwork2.inject.Inject;
|
||||
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.ServletActionContext;
|
||||
import org.apache.struts2.rest.handler.ContentTypeHandler;
|
||||
|
||||
import jakarta.servlet.http.HttpServletRequest;
|
||||
import jakarta.servlet.http.HttpServletResponse;
|
||||
import java.io.IOException;
|
||||
import java.io.StringWriter;
|
||||
import java.util.HashMap;
|
||||
@@ -94,6 +94,7 @@ public class DefaultContentTypeHandlerManager implements ContentTypeHandlerManag
|
||||
* @param request The request
|
||||
* @return The appropriate handler
|
||||
*/
|
||||
@Override
|
||||
public ContentTypeHandler getHandlerForRequest(HttpServletRequest request) {
|
||||
ContentTypeHandler handler = null;
|
||||
String contentType = request.getContentType();
|
||||
@@ -124,6 +125,7 @@ public class DefaultContentTypeHandlerManager implements ContentTypeHandlerManag
|
||||
* from the Accept: header
|
||||
*
|
||||
*/
|
||||
@Override
|
||||
public ContentTypeHandler getHandlerForResponse(HttpServletRequest request, HttpServletResponse res) {
|
||||
|
||||
String extension = getExtensionIfPresent(request.getRequestURI());
|
||||
@@ -155,21 +157,16 @@ public class DefaultContentTypeHandlerManager implements ContentTypeHandlerManag
|
||||
return handler;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String handleResult(ActionConfig actionConfig, Object methodResult, Object target) throws IOException {
|
||||
LOG.warn("This method is deprecated!");
|
||||
return readResultCode(methodResult);
|
||||
}
|
||||
|
||||
/**
|
||||
* Handles the result using handlers to generate content type-specific content
|
||||
*
|
||||
*
|
||||
* @param invocation The action invocation for the current request
|
||||
* @param methodResult The object returned from the action method
|
||||
* @param target The object to return, usually the action object
|
||||
* @return The new result code to process
|
||||
* @throws IOException If unable to write to the response
|
||||
*/
|
||||
@Override
|
||||
public String handleResult(ActionInvocation invocation, Object methodResult, Object target) throws IOException {
|
||||
String resultCode = readResultCode(methodResult);
|
||||
Integer statusCode = readStatusCode(methodResult);
|
||||
@@ -239,10 +236,11 @@ public class DefaultContentTypeHandlerManager implements ContentTypeHandlerManag
|
||||
|
||||
/**
|
||||
* Finds the extension in the url
|
||||
*
|
||||
*
|
||||
* @param url The url
|
||||
* @return The extension, or the default extension if there is none
|
||||
*/
|
||||
@Override
|
||||
public String findExtension(String url) {
|
||||
int dotPos = url.lastIndexOf('.');
|
||||
int slashPos = url.lastIndexOf('/');
|
||||
|
||||
Reference in New Issue
Block a user