WW-3714 Moves all classes from com.opensymphony.xwork2 into org.apache.struts2

This commit is contained in:
Kusal Kithul-Godage
2024-10-16 14:00:34 +11:00
parent 08d54d2b66
commit 32bc4045ba
1454 changed files with 6073 additions and 10262 deletions
+1 -1
View File
@@ -186,7 +186,7 @@
<artifactId>commons-text</artifactId>
</dependency>
<!-- Optional used in com.opensymphony.xwork2.util.ProxyUtil to detect if object is HibernateProxy -->
<!-- Optional used in org.apache.struts2.util.ProxyUtil to detect if object is HibernateProxy -->
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-core</artifactId>
@@ -1,28 +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;
/**
* {@inheritDoc}
*
* @deprecated since 6.7.0, use {@link org.apache.struts2.Action} instead.
*/
@Deprecated
public interface Action extends org.apache.struts2.Action {
}
@@ -1,276 +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;
import com.opensymphony.xwork2.conversion.impl.ConversionData;
import com.opensymphony.xwork2.inject.Container;
import com.opensymphony.xwork2.util.ValueStack;
import org.apache.struts2.dispatcher.HttpParameters;
import org.apache.struts2.dispatcher.mapper.ActionMapping;
import jakarta.servlet.ServletContext;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;
import jakarta.servlet.jsp.PageContext;
import java.util.Locale;
import java.util.Map;
/**
* {@inheritDoc}
*
* @deprecated since 6.7.0, use {@link org.apache.struts2.ActionContext} instead.
*/
@Deprecated
public class ActionContext extends org.apache.struts2.ActionContext {
private ActionContext(org.apache.struts2.ActionContext actualContext) {
super(actualContext.getContextMap());
}
public static ActionContext adapt(org.apache.struts2.ActionContext actualContext) {
if (actualContext instanceof ActionContext) {
return (ActionContext) actualContext;
}
return actualContext != null ? new ActionContext(actualContext) : null;
}
public static ActionContext of(Map<String, Object> context) {
return adapt(org.apache.struts2.ActionContext.of(context));
}
public static ActionContext of() {
return adapt(org.apache.struts2.ActionContext.of());
}
public static ActionContext bind(ActionContext actionContext) {
return adapt(org.apache.struts2.ActionContext.bind(actionContext));
}
public static boolean containsValueStack(Map<String, Object> context) {
return org.apache.struts2.ActionContext.containsValueStack(context);
}
public static void clear() {
org.apache.struts2.ActionContext.clear();
}
public static ActionContext getContext() {
return adapt(org.apache.struts2.ActionContext.getContext());
}
@Override
public ActionContext bind() {
super.bind();
return this;
}
public ActionContext withActionInvocation(ActionInvocation actionInvocation) {
return withActionInvocation((org.apache.struts2.ActionInvocation) actionInvocation);
}
@Override
public ActionContext withActionInvocation(org.apache.struts2.ActionInvocation actionInvocation) {
super.withActionInvocation(actionInvocation);
return this;
}
@Override
public ActionInvocation getActionInvocation() {
return ActionInvocation.adapt(super.getActionInvocation());
}
@Override
public ActionContext withApplication(Map<String, Object> application) {
super.withApplication(application);
return this;
}
@Override
public Map<String, Object> getApplication() {
return super.getApplication();
}
@Override
public Map<String, Object> getContextMap() {
return super.getContextMap();
}
@Override
public ActionContext withConversionErrors(Map<String, ConversionData> conversionErrors) {
super.withConversionErrors(conversionErrors);
return this;
}
@Override
public Map<String, ConversionData> getConversionErrors() {
return super.getConversionErrors();
}
@Override
public ActionContext withLocale(Locale locale) {
super.withLocale(locale);
return this;
}
@Override
public Locale getLocale() {
return super.getLocale();
}
@Override
public ActionContext withActionName(String actionName) {
super.withActionName(actionName);
return this;
}
@Override
public String getActionName() {
return super.getActionName();
}
@Override
public ActionContext withParameters(HttpParameters parameters) {
super.withParameters(parameters);
return this;
}
@Override
public HttpParameters getParameters() {
return super.getParameters();
}
@Override
public ActionContext withSession(Map<String, Object> session) {
super.withSession(session);
return this;
}
@Override
public Map<String, Object> getSession() {
return super.getSession();
}
public ActionContext withValueStack(ValueStack valueStack) {
return withValueStack((org.apache.struts2.util.ValueStack) valueStack);
}
@Override
public ActionContext withValueStack(org.apache.struts2.util.ValueStack valueStack) {
super.withValueStack(valueStack);
return this;
}
@Override
public ValueStack getValueStack() {
return ValueStack.adapt(super.getValueStack());
}
@Override
public ActionContext withContainer(Container container) {
super.withContainer(container);
return this;
}
@Override
public Container getContainer() {
return super.getContainer();
}
@Override
public <T> T getInstance(Class<T> type) {
return super.getInstance(type);
}
@Override
public Object get(String key) {
return super.get(key);
}
@Override
public void put(String key, Object value) {
super.put(key, value);
}
@Override
public ServletContext getServletContext() {
return super.getServletContext();
}
@Override
public ActionContext withServletContext(ServletContext servletContext) {
super.withServletContext(servletContext);
return this;
}
@Override
public HttpServletRequest getServletRequest() {
return super.getServletRequest();
}
@Override
public ActionContext withServletRequest(HttpServletRequest request) {
super.withServletRequest(request);
return this;
}
@Override
public HttpServletResponse getServletResponse() {
return super.getServletResponse();
}
@Override
public ActionContext withServletResponse(HttpServletResponse response) {
super.withServletResponse(response);
return this;
}
@Override
public PageContext getPageContext() {
return super.getPageContext();
}
@Override
public ActionContext withPageContext(PageContext pageContext) {
super.withPageContext(pageContext);
return this;
}
@Override
public ActionMapping getActionMapping() {
return super.getActionMapping();
}
@Override
public ActionContext withActionMapping(ActionMapping actionMapping) {
super.withActionMapping(actionMapping);
return this;
}
@Override
public ActionContext withExtraContext(Map<String, Object> extraContext) {
super.withExtraContext(extraContext);
return this;
}
@Override
public ActionContext with(String key, Object value) {
super.with(key, value);
return this;
}
}
@@ -1,70 +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;
import com.opensymphony.xwork2.util.ValueStack;
/**
* {@inheritDoc}
*
* @deprecated since 6.7.0, use {@link org.apache.struts2.ActionEventListener} instead.
*/
@Deprecated
public interface ActionEventListener extends org.apache.struts2.ActionEventListener {
@Override
default Object prepare(Object action, org.apache.struts2.util.ValueStack stack) {
return prepare(action, ValueStack.adapt(stack));
}
@Override
default String handleException(Throwable t, org.apache.struts2.util.ValueStack stack) {
return handleException(t, ValueStack.adapt(stack));
}
Object prepare(Object action, ValueStack stack);
String handleException(Throwable t, ValueStack stack);
static ActionEventListener adapt(org.apache.struts2.ActionEventListener actualListener) {
if (actualListener instanceof ActionEventListener) {
return (ActionEventListener) actualListener;
}
return actualListener != null ? new LegacyAdapter(actualListener) : null;
}
class LegacyAdapter implements ActionEventListener {
private final org.apache.struts2.ActionEventListener adaptee;
private LegacyAdapter(org.apache.struts2.ActionEventListener adaptee) {
this.adaptee = adaptee;
}
@Override
public Object prepare(Object action, ValueStack stack) {
return adaptee.prepare(action, stack);
}
@Override
public String handleException(Throwable t, ValueStack stack) {
return adaptee.handleException(t, stack);
}
}
}
@@ -1,146 +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;
import com.opensymphony.xwork2.interceptor.PreResultListener;
import com.opensymphony.xwork2.util.ValueStack;
/**
* {@inheritDoc}
*
* @deprecated since 6.7.0, use {@link org.apache.struts2.ActionInvocation} instead.
*/
@Deprecated
public interface ActionInvocation extends org.apache.struts2.ActionInvocation {
@Override
ActionContext getInvocationContext();
@Override
Result getResult() throws Exception;
@Override
ActionProxy getProxy();
@Override
ValueStack getStack();
@Override
default void addPreResultListener(org.apache.struts2.interceptor.PreResultListener listener) {
addPreResultListener(PreResultListener.adapt(listener));
}
void addPreResultListener(PreResultListener listener);
@Override
default void setActionEventListener(org.apache.struts2.ActionEventListener listener) {
setActionEventListener(ActionEventListener.adapt(listener));
}
void setActionEventListener(ActionEventListener listener);
@Override
default void init(org.apache.struts2.ActionProxy proxy) {
init(ActionProxy.adapt(proxy));
}
void init(ActionProxy proxy);
static ActionInvocation adapt(org.apache.struts2.ActionInvocation actualInvocation) {
if (actualInvocation instanceof ActionInvocation) {
return (ActionInvocation) actualInvocation;
}
return actualInvocation != null ? new LegacyAdapter(actualInvocation) : null;
}
class LegacyAdapter implements ActionInvocation {
private final org.apache.struts2.ActionInvocation adaptee;
private LegacyAdapter(org.apache.struts2.ActionInvocation adaptee) {
this.adaptee = adaptee;
}
@Override
public Object getAction() {
return adaptee.getAction();
}
@Override
public boolean isExecuted() {
return adaptee.isExecuted();
}
@Override
public ActionContext getInvocationContext() {
return ActionContext.adapt(adaptee.getInvocationContext());
}
@Override
public ActionProxy getProxy() {
return ActionProxy.adapt(adaptee.getProxy());
}
@Override
public Result getResult() throws Exception {
return Result.adapt(adaptee.getResult());
}
@Override
public String getResultCode() {
return adaptee.getResultCode();
}
@Override
public void setResultCode(String resultCode) {
adaptee.setResultCode(resultCode);
}
@Override
public ValueStack getStack() {
return ValueStack.adapt(adaptee.getStack());
}
@Override
public void addPreResultListener(PreResultListener listener) {
adaptee.addPreResultListener(listener);
}
@Override
public String invoke() throws Exception {
return adaptee.invoke();
}
@Override
public String invokeActionOnly() throws Exception {
return adaptee.invokeActionOnly();
}
@Override
public void setActionEventListener(ActionEventListener listener) {
adaptee.setActionEventListener(listener);
}
@Override
public void init(ActionProxy proxy) {
adaptee.init(proxy);
}
}
}
@@ -1,94 +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;
import com.opensymphony.xwork2.config.entities.ActionConfig;
@Deprecated
public interface ActionProxy extends org.apache.struts2.ActionProxy {
@Override
ActionInvocation getInvocation();
static ActionProxy adapt(org.apache.struts2.ActionProxy actualProxy) {
if (actualProxy instanceof ActionProxy) {
return (ActionProxy) actualProxy;
}
return actualProxy != null ? new LegacyAdapter(actualProxy) : null;
}
class LegacyAdapter implements ActionProxy {
private final org.apache.struts2.ActionProxy adaptee;
private LegacyAdapter(org.apache.struts2.ActionProxy adaptee) {
this.adaptee = adaptee;
}
@Override
public Object getAction() {
return adaptee.getAction();
}
@Override
public String getActionName() {
return adaptee.getActionName();
}
@Override
public ActionConfig getConfig() {
return adaptee.getConfig();
}
@Override
public void setExecuteResult(boolean executeResult) {
adaptee.setExecuteResult(executeResult);
}
@Override
public boolean getExecuteResult() {
return adaptee.getExecuteResult();
}
@Override
public ActionInvocation getInvocation() {
return ActionInvocation.adapt(adaptee.getInvocation());
}
@Override
public String getNamespace() {
return adaptee.getNamespace();
}
@Override
public String execute() throws Exception {
return adaptee.execute();
}
@Override
public String getMethod() {
return adaptee.getMethod();
}
@Override
public boolean isMethodSpecified() {
return adaptee.isMethodSpecified();
}
}
}
@@ -1,28 +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;
import com.opensymphony.xwork2.interceptor.ValidationAware;
/**
* @deprecated since 6.7.0, use {@link org.apache.struts2.ActionSupport} instead.
*/
@Deprecated
public class ActionSupport extends org.apache.struts2.ActionSupport implements Action, Validateable, ValidationAware {
}
@@ -1,26 +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;
/**
* @deprecated since 6.7.0, use {@link org.apache.struts2.ModelDriven} instead.
*/
@Deprecated
public interface ModelDriven<T> extends org.apache.struts2.ModelDriven<T> {
}
@@ -1,26 +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;
/**
* @deprecated since 6.7.0, use {@link org.apache.struts2.Preparable} instead.
*/
@Deprecated
public interface Preparable extends org.apache.struts2.Preparable {
}
@@ -1,56 +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;
/**
* {@inheritDoc}
*
* @deprecated since 6.7.0, use {@link org.apache.struts2.Result} instead.
*/
@Deprecated
public interface Result extends org.apache.struts2.Result {
@Override
default void execute(org.apache.struts2.ActionInvocation invocation) throws Exception {
execute(ActionInvocation.adapt(invocation));
}
void execute(ActionInvocation invocation) throws Exception;
static Result adapt(org.apache.struts2.Result actualResult) {
if (actualResult instanceof Result) {
return (Result) actualResult;
}
return actualResult != null ? new LegacyAdapter(actualResult) : null;
}
class LegacyAdapter implements Result {
private final org.apache.struts2.Result adaptee;
private LegacyAdapter(org.apache.struts2.Result adaptee) {
this.adaptee = adaptee;
}
@Override
public void execute(ActionInvocation invocation) throws Exception {
adaptee.execute(ActionInvocation.adapt(invocation));
}
}
}
@@ -1,26 +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;
/**
* @deprecated since 6.7.0, use {@link org.apache.struts2.Unchainable} instead.
*/
@Deprecated
public interface Unchainable extends org.apache.struts2.Unchainable {
}
@@ -1,26 +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;
/**
* @deprecated since 6.7.0, use {@link org.apache.struts2.Validateable} instead.
*/
@Deprecated
public interface Validateable extends org.apache.struts2.Validateable {
}
@@ -1,21 +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.
*/
-->
<body>Configuration core classes.</body>
@@ -1,83 +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.factory;
import com.opensymphony.xwork2.ObjectFactory;
import com.opensymphony.xwork2.Result;
import com.opensymphony.xwork2.config.ConfigurationException;
import com.opensymphony.xwork2.config.entities.ResultConfig;
import com.opensymphony.xwork2.inject.Inject;
import com.opensymphony.xwork2.util.reflection.ReflectionException;
import com.opensymphony.xwork2.util.reflection.ReflectionExceptionHandler;
import com.opensymphony.xwork2.util.reflection.ReflectionProvider;
import java.util.Map;
/**
* Default implementation
*/
public class DefaultResultFactory implements ResultFactory {
private ObjectFactory objectFactory;
private ReflectionProvider reflectionProvider;
@Inject
public void setObjectFactory(ObjectFactory objectFactory) {
this.objectFactory = objectFactory;
}
@Inject
public void setReflectionProvider(ReflectionProvider reflectionProvider) {
this.reflectionProvider = reflectionProvider;
}
public Result buildResult(ResultConfig resultConfig, Map<String, Object> extraContext) throws Exception {
String resultClassName = resultConfig.getClassName();
Result result = null;
if (resultClassName != null) {
Object o = objectFactory.buildBean(resultClassName, extraContext);
Map<String, String> params = resultConfig.getParams();
if (params != null) {
for (Map.Entry<String, String> paramEntry : params.entrySet()) {
try {
reflectionProvider.setProperty(paramEntry.getKey(), paramEntry.getValue(), o, extraContext, true);
} catch (ReflectionException ex) {
if (o instanceof ReflectionExceptionHandler) {
((ReflectionExceptionHandler) o).handle(ex);
}
}
}
}
if (o instanceof Result) {
result = (Result) o;
} else if (o instanceof org.apache.struts2.Result) {
result = Result.adapt((org.apache.struts2.Result) o);
}
if (result == null) {
throw new ConfigurationException("Class [" + resultClassName + "] does not implement Result", resultConfig);
}
}
return result;
}
}
@@ -1,43 +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.interceptor;
import com.opensymphony.xwork2.ActionInvocation;
/**
* @deprecated since 6.7.0, use {@link org.apache.struts2.interceptor.AbstractInterceptor} instead.
*/
@Deprecated
public abstract class AbstractInterceptor extends org.apache.struts2.interceptor.AbstractInterceptor implements ConditionalInterceptor {
/**
* Override to handle interception
*/
public abstract String intercept(ActionInvocation invocation) throws Exception;
@Override
public String intercept(org.apache.struts2.ActionInvocation invocation) throws Exception {
return intercept(ActionInvocation.adapt(invocation));
}
@Override
public boolean shouldIntercept(ActionInvocation invocation) {
return shouldIntercept((org.apache.struts2.ActionInvocation) invocation);
}
}
@@ -1,295 +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.interceptor;
import com.opensymphony.xwork2.ActionContext;
import com.opensymphony.xwork2.ActionInvocation;
import com.opensymphony.xwork2.LocalizedTextProvider;
import com.opensymphony.xwork2.config.entities.ActionConfig;
import com.opensymphony.xwork2.inject.Inject;
import com.opensymphony.xwork2.security.AcceptedPatternsChecker;
import com.opensymphony.xwork2.security.ExcludedPatternsChecker;
import com.opensymphony.xwork2.util.ClearableValueStack;
import com.opensymphony.xwork2.util.Evaluated;
import com.opensymphony.xwork2.util.ValueStack;
import com.opensymphony.xwork2.util.ValueStackFactory;
import com.opensymphony.xwork2.util.reflection.ReflectionContextState;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.apache.struts2.StrutsConstants;
import org.apache.struts2.dispatcher.HttpParameters;
import org.apache.struts2.dispatcher.Parameter;
import org.apache.struts2.interceptor.ValidationAware;
import java.util.Map;
/**
* <!-- START SNIPPET: description -->
*
* The aim of this Interceptor is to alias a named parameter to a different named parameter. By acting as the glue
* between actions sharing similar parameters (but with different names), it can help greatly with action chaining.
*
* <p>Action's alias expressions should be in the form of <code>#{ "name1" : "alias1", "name2" : "alias2" }</code>.
* This means that assuming an action (or something else in the stack) has a value for the expression named <i>name1</i> and the
* action this interceptor is applied to has a setter named <i>alias1</i>, <i>alias1</i> will be set with the value from
* <i>name1</i>.
* </p>
*
* <!-- END SNIPPET: description -->
*
* <p><u>Interceptor parameters:</u></p>
*
* <!-- START SNIPPET: parameters -->
*
* <ul>
*
* <li>aliasesKey (optional) - the name of the action parameter to look for the alias map (by default this is
* <i>aliases</i>).</li>
*
* </ul>
*
* <!-- END SNIPPET: parameters -->
*
* <p><u>Extending the interceptor:</u></p>
*
* <!-- START SNIPPET: extending -->
*
* This interceptor does not have any known extension points.
*
* <!-- END SNIPPET: extending -->
*
* <p><u>Example code:</u></p>
*
* <pre>
* <!-- START SNIPPET: example -->
* &lt;action name="someAction" class="com.examples.SomeAction"&gt;
* &lt;!-- The value for the foo parameter will be applied as if it were named bar --&gt;
* &lt;param name="aliases"&gt;#{ 'foo' : 'bar' }&lt;/param&gt;
*
* &lt;interceptor-ref name="alias"/&gt;
* &lt;interceptor-ref name="basicStack"/&gt;
* &lt;result name="success"&gt;good_result.ftl&lt;/result&gt;
* &lt;/action&gt;
* <!-- END SNIPPET: example -->
* </pre>
*
* @author Matthew Payne
*
* @deprecated since 6.7.0, use {@link org.apache.struts2.interceptor.AliasInterceptor} instead.
*/
@Deprecated
public class AliasInterceptor extends AbstractInterceptor {
private static final Logger LOG = LogManager.getLogger(AliasInterceptor.class);
private static final String DEFAULT_ALIAS_KEY = "aliases";
protected String aliasesKey = DEFAULT_ALIAS_KEY;
protected ValueStackFactory valueStackFactory;
protected LocalizedTextProvider localizedTextProvider;
protected boolean devMode = false;
private ExcludedPatternsChecker excludedPatterns;
private AcceptedPatternsChecker acceptedPatterns;
@Inject(StrutsConstants.STRUTS_DEVMODE)
public void setDevMode(String mode) {
this.devMode = Boolean.parseBoolean(mode);
}
@Inject
public void setValueStackFactory(ValueStackFactory valueStackFactory) {
this.valueStackFactory = valueStackFactory;
}
@Inject
public void setLocalizedTextProvider(LocalizedTextProvider localizedTextProvider) {
this.localizedTextProvider = localizedTextProvider;
}
@Inject
public void setExcludedPatterns(ExcludedPatternsChecker excludedPatterns) {
this.excludedPatterns = excludedPatterns;
}
@Inject
public void setAcceptedPatterns(AcceptedPatternsChecker acceptedPatterns) {
this.acceptedPatterns = acceptedPatterns;
}
/**
* <p>
* Sets the name of the action parameter to look for the alias map.
* </p>
*
* <p>
* Default is <code>aliases</code>.
* </p>
*
* @param aliasesKey the name of the action parameter
*/
public void setAliasesKey(String aliasesKey) {
this.aliasesKey = aliasesKey;
}
@Override public String intercept(ActionInvocation invocation) throws Exception {
ActionConfig config = invocation.getProxy().getConfig();
ActionContext ac = invocation.getInvocationContext();
Object action = invocation.getAction();
// get the action's parameters
final Map<String, String> parameters = config.getParams();
if (parameters.containsKey(aliasesKey)) {
String aliasExpression = parameters.get(aliasesKey);
ValueStack stack = ac.getValueStack();
Object obj = stack.findValue(aliasExpression);
if (obj instanceof Map aliases) {
//get secure stack
ValueStack newStack = valueStackFactory.createValueStack(stack);
boolean clearableStack = newStack instanceof ClearableValueStack;
if (clearableStack) {
//if the stack's context can be cleared, do that to prevent OGNL
//from having access to objects in the stack, see XW-641
((ClearableValueStack)newStack).clearContextValues();
Map<String, Object> context = newStack.getContext();
ReflectionContextState.setCreatingNullObjects(context, true);
ReflectionContextState.setDenyMethodExecution(context, true);
ReflectionContextState.setReportingConversionErrors(context, true);
//keep locale from original context
newStack.getActionContext().withLocale(stack.getActionContext().getLocale());
}
// override
for (Object o : aliases.entrySet()) {
Map.Entry entry = (Map.Entry) o;
String name = entry.getKey().toString();
if (isNotAcceptableExpression(name)) {
continue;
}
String alias = (String) entry.getValue();
if (isNotAcceptableExpression(alias)) {
continue;
}
Evaluated value = new Evaluated(stack.findValue(name));
if (!value.isDefined()) {
// workaround
HttpParameters contextParameters = ActionContext.getContext().getParameters();
if (null != contextParameters) {
Parameter param = contextParameters.get(name);
if (param.isDefined()) {
value = new Evaluated(param.getValue());
}
}
}
if (value.isDefined()) {
try {
newStack.setValue(alias, value.get());
} catch (RuntimeException e) {
if (devMode) {
String developerNotification = localizedTextProvider.findText(AliasInterceptor.class, "devmode.notification", ActionContext.getContext().getLocale(), "Developer Notification:\n{0}", new Object[]{
"Unexpected Exception caught setting '" + entry.getKey() + "' on '" + action.getClass() + ": " + e.getMessage()
});
LOG.error(developerNotification);
if (action instanceof ValidationAware) {
((ValidationAware) action).addActionMessage(developerNotification);
}
}
}
}
}
if (clearableStack) {
stack.getActionContext().withConversionErrors(newStack.getActionContext().getConversionErrors());
}
} else {
LOG.debug("invalid alias expression: {}", aliasesKey);
}
}
return invocation.invoke();
}
protected boolean isAccepted(String paramName) {
AcceptedPatternsChecker.IsAccepted result = acceptedPatterns.isAccepted(paramName);
if (result.isAccepted()) {
return true;
}
LOG.warn("Parameter [{}] didn't match accepted pattern [{}]! See Accepted / Excluded patterns at\n" +
"https://struts.apache.org/security/#accepted--excluded-patterns",
paramName, result.getAcceptedPattern());
return false;
}
protected boolean isExcluded(String paramName) {
ExcludedPatternsChecker.IsExcluded result = excludedPatterns.isExcluded(paramName);
if (!result.isExcluded()) {
return false;
}
LOG.warn("Parameter [{}] matches excluded pattern [{}]! See Accepted / Excluded patterns at\n" +
"https://struts.apache.org/security/#accepted--excluded-patterns",
paramName, result.getExcludedPattern());
return true;
}
/**
* Checks if expression contains vulnerable code
*
* @param expression of interceptor
* @return true|false
*/
protected boolean isNotAcceptableExpression(String expression) {
return isExcluded(expression) || !isAccepted(expression);
}
/**
* Sets a comma-delimited list of regular expressions to match
* parameters that are allowed in the parameter map (aka whitelist).
* <p>
* Don't change the default unless you know what you are doing in terms
* of security implications.
* </p>
*
* @param commaDelim A comma-delimited list of regular expressions
*/
public void setAcceptParamNames(String commaDelim) {
acceptedPatterns.setAcceptedPatterns(commaDelim);
}
/**
* Sets a comma-delimited list of regular expressions to match
* parameters that should be removed from the parameter map.
*
* @param commaDelim A comma-delimited list of regular expressions
*/
public void setExcludeParams(String commaDelim) {
excludedPatterns.setExcludedPatterns(commaDelim);
}
}
@@ -1,278 +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.interceptor;
import com.opensymphony.xwork2.ActionChainResult;
import com.opensymphony.xwork2.ActionInvocation;
import com.opensymphony.xwork2.Result;
import com.opensymphony.xwork2.inject.Inject;
import com.opensymphony.xwork2.util.CompoundRoot;
import com.opensymphony.xwork2.util.ProxyUtil;
import com.opensymphony.xwork2.util.TextParseUtil;
import com.opensymphony.xwork2.util.ValueStack;
import com.opensymphony.xwork2.util.reflection.ReflectionProvider;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.apache.struts2.StrutsConstants;
import org.apache.struts2.Unchainable;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
/**
* <!-- START SNIPPET: description -->
* <p>
* An interceptor that copies all the properties of every object in the value stack to the currently executing object,
* except for any object that implements {@link Unchainable}. A collection of optional <i>includes</i> and
* <i>excludes</i> may be provided to control how and which parameters are copied. Only includes or excludes may be
* specified. Specifying both results in undefined behavior. See the javadocs for {@link ReflectionProvider#copy(Object, Object,
* java.util.Map, java.util.Collection, java.util.Collection)} for more information.
* </p>
*
* <p>
* <b>Note:</b> It is important to remember that this interceptor does nothing if there are no objects already on the stack.
* <br>This means two things:
* <br><b>One</b>, you can safely apply it to all your actions without any worry of adverse affects.
* <br><b>Two</b>, it is up to you to ensure an object exists in the stack prior to invoking this action. The most typical way this is done
* is through the use of the <b>chain</b> result type, which combines with this interceptor to make up the action
* chaining feature.
* </p>
*
* <p>
* <b>Note:</b> By default Errors, Field errors and Message aren't copied during chaining, to change the behaviour you can specify
* the below three constants in struts.properties or struts.xml:
* </p>
*
* <ul>
* <li>struts.chaining.copyErrors - set to true to copy Action Errors</li>
* <li>struts.chaining.copyFieldErrors - set to true to copy Field Errors</li>
* <li>struts.chaining.copyMessages - set to true to copy Action Messages</li>
* </ul>
*
* <p>
* <u>Example:</u>
* </p>
*
* <pre>
* &lt;constant name="struts.xwork.chaining.copyErrors" value="true"/&gt;
* </pre>
*
* <p>
* <b>Note:</b> By default actionErrors and actionMessages are excluded when copping object's properties.
* </p>
* <!-- END SNIPPET: description -->
* <u>Interceptor parameters:</u>
* <!-- START SNIPPET: parameters -->
* <ul>
* <li>excludes (optional) - the list of parameter names to exclude from copying (all others will be included).</li>
* <li>includes (optional) - the list of parameter names to include when copying (all others will be excluded).</li>
* </ul>
* <!-- END SNIPPET: parameters -->
* <u>Extending the interceptor:</u>
* <!-- START SNIPPET: extending -->
* <p>
* There are no known extension points to this interceptor.
* </p>
* <!-- END SNIPPET: extending -->
* <u>Example code:</u>
*
* <!-- START SNIPPET: example -->
* <pre>
* &lt;action name="someAction" class="com.examples.SomeAction"&gt;
* &lt;interceptor-ref name="basicStack"/&gt;
* &lt;result name="success" type="chain"&gt;otherAction&lt;/result&gt;
* &lt;/action&gt;
* </pre>
*
* <pre>
* &lt;action name="otherAction" class="com.examples.OtherAction"&gt;
* &lt;interceptor-ref name="chain"/&gt;
* &lt;interceptor-ref name="basicStack"/&gt;
* &lt;result name="success"&gt;good_result.ftl&lt;/result&gt;
* &lt;/action&gt;
* </pre>
* <!-- END SNIPPET: example -->
*
*
* @author mrdon
* @author tm_jee ( tm_jee(at)yahoo.co.uk )
* @see com.opensymphony.xwork2.ActionChainResult
*
* @deprecated since 6.7.0, use {@link org.apache.struts2.interceptor.ChainingInterceptor} instead.
*/
@Deprecated
public class ChainingInterceptor extends AbstractInterceptor {
private static final Logger LOG = LogManager.getLogger(ChainingInterceptor.class);
private static final String ACTION_ERRORS = "actionErrors";
private static final String FIELD_ERRORS = "fieldErrors";
private static final String ACTION_MESSAGES = "actionMessages";
private boolean copyMessages = false;
private boolean copyErrors = false;
private boolean copyFieldErrors = false;
protected Collection<String> excludes;
protected Collection<String> includes;
protected ReflectionProvider reflectionProvider;
@Inject
public void setReflectionProvider(ReflectionProvider prov) {
this.reflectionProvider = prov;
}
@Inject(value = StrutsConstants.STRUTS_CHAINING_COPY_ERRORS, required = false)
public void setCopyErrors(String copyErrors) {
this.copyErrors = "true".equalsIgnoreCase(copyErrors);
}
@Inject(value = StrutsConstants.STRUTS_CHAINING_COPY_FIELD_ERRORS, required = false)
public void setCopyFieldErrors(String copyFieldErrors) {
this.copyFieldErrors = "true".equalsIgnoreCase(copyFieldErrors);
}
@Inject(value = StrutsConstants.STRUTS_CHAINING_COPY_MESSAGES, required = false)
public void setCopyMessages(String copyMessages) {
this.copyMessages = "true".equalsIgnoreCase(copyMessages);
}
@Override
public String intercept(ActionInvocation invocation) throws Exception {
ValueStack stack = invocation.getStack();
CompoundRoot root = stack.getRoot();
if (shouldCopyStack(invocation, root)) {
copyStack(invocation, root);
}
return invocation.invoke();
}
private void copyStack(ActionInvocation invocation, CompoundRoot root) {
List list = prepareList(root);
Map<String, Object> ctxMap = invocation.getInvocationContext().getContextMap();
for (Object object : list) {
if (shouldCopy(object)) {
Object action = invocation.getAction();
Class<?> editable = null;
if(ProxyUtil.isProxy(action)) {
editable = ProxyUtil.ultimateTargetClass(action);
}
reflectionProvider.copy(object, action, ctxMap, prepareExcludes(), includes, editable);
}
}
}
private Collection<String> prepareExcludes() {
Collection<String> localExcludes = excludes;
if (!copyErrors || !copyMessages ||!copyFieldErrors) {
if (localExcludes == null) {
localExcludes = new HashSet<>();
if (!copyErrors) {
localExcludes.add(ACTION_ERRORS);
}
if (!copyMessages) {
localExcludes.add(ACTION_MESSAGES);
}
if (!copyFieldErrors) {
localExcludes.add(FIELD_ERRORS);
}
}
}
return localExcludes;
}
private boolean shouldCopy(Object o) {
return o != null && !(o instanceof Unchainable);
}
@SuppressWarnings("unchecked")
private List prepareList(CompoundRoot root) {
List list = new ArrayList(root);
list.remove(0);
Collections.reverse(list);
return list;
}
private boolean shouldCopyStack(ActionInvocation invocation, CompoundRoot root) throws Exception {
Result result = invocation.getResult();
return root.size() > 1 && (result == null || ActionChainResult.class.isAssignableFrom(result.getClass()));
}
/**
* Gets list of parameter names to exclude
*
* @return the exclude list
*/
public Collection<String> getExcludes() {
return excludes;
}
/**
* Sets the list of parameter names to exclude from copying (all others will be included).
*
* @param excludes the excludes list as comma separated String
*/
public void setExcludes(String excludes) {
this.excludes = TextParseUtil.commaDelimitedStringToSet(excludes);
}
/**
* Sets the list of parameter names to exclude from copying (all others will be included).
*
* @param excludes the excludes list
*/
public void setExcludesCollection(Collection<String> excludes) {
this.excludes = excludes;
}
/**
* Gets list of parameter names to include
*
* @return the include list
*/
public Collection<String> getIncludes() {
return includes;
}
/**
* Sets the list of parameter names to include when copying (all others will be excluded).
*
* @param includes the includes list as comma separated String
*/
public void setIncludes(String includes) {
this.includes = TextParseUtil.commaDelimitedStringToSet(includes);
}
/**
* Sets the list of parameter names to include when copying (all others will be excluded).
*
* @param includes the includes list
*/
public void setIncludesCollection(Collection<String> includes) {
this.includes = includes;
}
}
@@ -1,59 +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.interceptor;
import com.opensymphony.xwork2.ActionInvocation;
/**
* {@inheritDoc}
*
* @deprecated since 6.7.0, use {@link org.apache.struts2.interceptor.Interceptor} instead.
*/
@Deprecated
public interface ConditionalInterceptor extends org.apache.struts2.interceptor.ConditionalInterceptor, Interceptor {
@Override
default boolean shouldIntercept(org.apache.struts2.ActionInvocation invocation) {
return shouldIntercept(ActionInvocation.adapt(invocation));
}
boolean shouldIntercept(ActionInvocation invocation);
static ConditionalInterceptor adapt(org.apache.struts2.interceptor.ConditionalInterceptor actualInterceptor) {
if (actualInterceptor instanceof ConditionalInterceptor) {
return (ConditionalInterceptor) actualInterceptor;
}
return actualInterceptor != null ? new LegacyAdapter(actualInterceptor) : null;
}
class LegacyAdapter extends Interceptor.LegacyAdapter implements ConditionalInterceptor {
private final org.apache.struts2.interceptor.ConditionalInterceptor adaptee;
private LegacyAdapter(org.apache.struts2.interceptor.ConditionalInterceptor adaptee) {
super(adaptee);
this.adaptee = adaptee;
}
@Override
public boolean shouldIntercept(ActionInvocation invocation) {
return adaptee.shouldIntercept(invocation);
}
}
}
@@ -1,150 +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.interceptor;
import com.opensymphony.xwork2.ActionContext;
import com.opensymphony.xwork2.ActionInvocation;
import com.opensymphony.xwork2.conversion.impl.ConversionData;
import com.opensymphony.xwork2.conversion.impl.XWorkConverter;
import com.opensymphony.xwork2.util.ValueStack;
import org.apache.commons.text.StringEscapeUtils;
import org.apache.struts2.interceptor.ValidationAware;
import java.util.HashMap;
import java.util.Map;
/**
* <!-- START SNIPPET: description -->
* ConversionErrorInterceptor adds conversion errors from the ActionContext to the Action's field errors.
*
* <p>
* This interceptor adds any error found in the {@link ActionContext}'s conversionErrors map as a field error (provided
* that the action implements {@link ValidationAware}). In addition, any field that contains a validation error has its
* original value saved such that any subsequent requests for that value return the original value rather than the value
* in the action. This is important because if the value "abc" is submitted and can't be converted to an int, we want to
* display the original string ("abc") again rather than the int value (likely 0, which would make very little sense to
* the user).
* </p>
*
* <p>
* <b>Note:</b> Since 2.5.2, this interceptor extends {@link MethodFilterInterceptor}, therefore being
* able to deal with excludeMethods / includeMethods parameters. See [Workflow Interceptor]
* (class {@link DefaultWorkflowInterceptor}) for documentation and examples on how to use this feature.
* </p>
*
* <!-- END SNIPPET: description -->
*
* <p><u>Interceptor parameters:</u></p>
*
* <!-- START SNIPPET: parameters -->
*
* <ul>
* <li>None</li>
* </ul>
*
* <!-- END SNIPPET: parameters -->
*
* <p> <u>Extending the interceptor:</u></p>
*
* <!-- START SNIPPET: extending -->
*
* Because this interceptor is not web-specific, it abstracts the logic for whether an error should be added. This
* allows for web-specific interceptors to use more complex logic in the {@link #shouldAddError} method for when a value
* has a conversion error but is null or empty or otherwise indicates that the value was never actually entered by the
* user.
*
* <!-- END SNIPPET: extending -->
*
* <p> <u>Example code:</u></p>
*
* <pre>
* <!-- START SNIPPET: example -->
* &lt;action name="someAction" class="com.examples.SomeAction"&gt;
* &lt;interceptor-ref name="params"/&gt;
* &lt;interceptor-ref name="conversionError"/&gt;
* &lt;result name="success"&gt;good_result.ftl&lt;/result&gt;
* &lt;/action&gt;
* <!-- END SNIPPET: example -->
* </pre>
*
* @author Jason Carreira
*
* @deprecated since 6.7.0, use {@link org.apache.struts2.interceptor.ConversionErrorInterceptor} instead.
*/
@Deprecated
public class ConversionErrorInterceptor extends MethodFilterInterceptor {
public static final String ORIGINAL_PROPERTY_OVERRIDE = "original.property.override";
protected Object getOverrideExpr(ActionInvocation invocation, Object value) {
return escape(value);
}
protected String escape(Object value) {
return "\"" + StringEscapeUtils.escapeJava(String.valueOf(value)) + "\"";
}
@Override
public String doIntercept(ActionInvocation invocation) throws Exception {
ActionContext invocationContext = invocation.getInvocationContext();
Map<String, ConversionData> conversionErrors = invocationContext.getConversionErrors();
ValueStack stack = invocationContext.getValueStack();
HashMap<Object, Object> fakie = null;
for (Map.Entry<String, ConversionData> entry : conversionErrors.entrySet()) {
String propertyName = entry.getKey();
ConversionData conversionData = entry.getValue();
if (shouldAddError(propertyName, conversionData.getValue())) {
String message = XWorkConverter.getConversionErrorMessage(propertyName, conversionData.getToClass(), stack);
Object action = invocation.getAction();
if (action instanceof ValidationAware va) {
va.addFieldError(propertyName, message);
}
if (fakie == null) {
fakie = new HashMap<>();
}
fakie.put(propertyName, getOverrideExpr(invocation, conversionData.getValue()));
}
}
if (fakie != null) {
// if there were some errors, put the original (fake) values in place right before the result
stack.getContext().put(ORIGINAL_PROPERTY_OVERRIDE, fakie);
invocation.addPreResultListener((invocation1, resultCode) -> {
var fakie1 = (Map<Object, Object>) invocation1.getInvocationContext().get(ORIGINAL_PROPERTY_OVERRIDE);
if (fakie1 != null) {
invocation1.getStack().setExprOverrides(fakie1);
}
});
}
return invocation.invoke();
}
protected boolean shouldAddError(String propertyName, Object value) {
return true;
}
}
@@ -1,253 +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.interceptor;
import com.opensymphony.xwork2.Action;
import com.opensymphony.xwork2.ActionInvocation;
import com.opensymphony.xwork2.interceptor.annotations.InputConfig;
import org.apache.commons.lang3.StringUtils;
import org.apache.commons.lang3.reflect.MethodUtils;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.apache.struts2.interceptor.ValidationAware;
import org.apache.struts2.interceptor.ValidationErrorAware;
import org.apache.struts2.interceptor.ValidationWorkflowAware;
import java.io.Serial;
/**
* <!-- START SNIPPET: description -->
* <p>
* An interceptor that makes sure there are not validation, conversion or action errors before allowing the interceptor chain to continue.
* If a single FieldError or ActionError (including the ones replicated by the Message Store Interceptor in a redirection) is found, the INPUT result will be triggered.
* <b>This interceptor does not perform any validation</b>.
* </p>
*
* <p>
* This interceptor does nothing if the name of the method being invoked is specified in the <b>excludeMethods</b>
* parameter. <b>excludeMethods</b> accepts a comma-delimited list of method names. For example, requests to
* <b>foo!input.action</b> and <b>foo!back.action</b> will be skipped by this interceptor if you set the
* <b>excludeMethods</b> parameter to "input, back".
* </p>
*
* <p>
* <b>Note:</b> As this method extends off MethodFilterInterceptor, it is capable of
* deciding if it is applicable only to selective methods in the action class. This is done by adding param tags
* for the interceptor element, naming either a list of excluded method names and/or a list of included method
* names, whereby includeMethods overrides excludedMethods. A single * sign is interpreted as wildcard matching
* all methods for both parameters.
* See {@link MethodFilterInterceptor} for more info.
* </p>
*
* <p>
* This interceptor also supports the following interfaces which can implemented by actions:
* </p>
*
* <ul>
* <li>ValidationAware - implemented by ActionSupport class</li>
* <li>ValidationWorkflowAware - allows changing result name programmatically</li>
* <li>ValidationErrorAware - notifies action about errors and also allow change result name</li>
* </ul>
*
* <p>
* You can also use InputConfig annotation to change result name returned when validation errors occurred.
* </p>
*
* <!-- END SNIPPET: description -->
*
* <p><u>Interceptor parameters:</u></p>
*
* <!-- START SNIPPET: parameters -->
* <ul>
* <li>inputResultName - Default to "input". Determine the result name to be returned when
* an action / field error is found.</li>
* </ul>
* <!-- END SNIPPET: parameters -->
*
* <p><u>Extending the interceptor:</u></p>
*
* <!-- START SNIPPET: extending -->
*
* <p>There are no known extension points for this interceptor.</p>
*
* <!-- END SNIPPET: extending -->
*
* <p><u>Example code:</u></p>
*
* <pre>
* <!-- START SNIPPET: example -->
*
* &lt;action name="someAction" class="com.examples.SomeAction"&gt;
* &lt;interceptor-ref name="params"/&gt;
* &lt;interceptor-ref name="validation"/&gt;
* &lt;interceptor-ref name="workflow"/&gt;
* &lt;result name="success"&gt;good_result.ftl&lt;/result&gt;
* &lt;/action&gt;
*
* &lt;-- In this case myMethod as well as mySecondMethod of the action class
* will not pass through the workflow process --&gt;
* &lt;action name="someAction" class="com.examples.SomeAction"&gt;
* &lt;interceptor-ref name="params"/&gt;
* &lt;interceptor-ref name="validation"/&gt;
* &lt;interceptor-ref name="workflow"&gt;
* &lt;param name="excludeMethods"&gt;myMethod,mySecondMethod&lt;/param&gt;
* &lt;/interceptor-ref name="workflow"&gt;
* &lt;result name="success"&gt;good_result.ftl&lt;/result&gt;
* &lt;/action&gt;
*
* &lt;-- In this case, the result named "error" will be used when
* an action / field error is found --&gt;
* &lt;-- The Interceptor will only be applied for myWorkflowMethod method of action
* classes, since this is the only included method while any others are excluded --&gt;
* &lt;action name="someAction" class="com.examples.SomeAction"&gt;
* &lt;interceptor-ref name="params"/&gt;
* &lt;interceptor-ref name="validation"/&gt;
* &lt;interceptor-ref name="workflow"&gt;
* &lt;param name="inputResultName"&gt;error&lt;/param&gt;
* &lt;param name="excludeMethods"&gt;*&lt;/param&gt;
* &lt;param name="includeMethods"&gt;myWorkflowMethod&lt;/param&gt;
* &lt;/interceptor-ref&gt;
* &lt;result name="success"&gt;good_result.ftl&lt;/result&gt;
* &lt;/action&gt;
*
* <!-- END SNIPPET: example -->
* </pre>
*
* @author Jason Carreira
* @author Rainer Hermanns
* @author <a href='mailto:the_mindstorm[at]evolva[dot]ro'>Alexandru Popescu</a>
* @author Philip Luppens
* @author tm_jee
*
* @deprecated since 6.7.0, use {@link org.apache.struts2.interceptor.DefaultWorkflowInterceptor} instead.
*/
@Deprecated
public class DefaultWorkflowInterceptor extends MethodFilterInterceptor {
@Serial
private static final long serialVersionUID = 7563014655616490865L;
private static final Logger LOG = LogManager.getLogger(DefaultWorkflowInterceptor.class);
private static final Class[] EMPTY_CLASS_ARRAY = new Class[0];
private String inputResultName = Action.INPUT;
/**
* Set the <code>inputResultName</code> (result name to be returned when
* a action / field error is found registered). Default to {@link Action#INPUT}
*
* @param inputResultName what result name to use when there was validation error(s).
*/
public void setInputResultName(String inputResultName) {
this.inputResultName = inputResultName;
}
/**
* Intercept {@link ActionInvocation} and returns a <code>inputResultName</code>
* when action / field errors is found registered.
*
* @param invocation the action invocation
* @return String result name
*/
@Override
protected String doIntercept(ActionInvocation invocation) throws Exception {
Object action = invocation.getAction();
if (action instanceof ValidationAware validationAwareAction) {
if (validationAwareAction.hasErrors()) {
LOG.debug("Errors on action [{}], returning result name [{}]", validationAwareAction, inputResultName);
String resultName = inputResultName;
resultName = processValidationWorkflowAware(action, resultName);
resultName = processInputConfig(action, invocation.getProxy().getMethod(), resultName);
resultName = processValidationErrorAware(action, resultName);
return resultName;
}
}
return invocation.invoke();
}
/**
* Process {@link ValidationWorkflowAware} interface
*
* @param action action object
* @param currentResultName current result name
*
* @return result name
*/
private String processValidationWorkflowAware(final Object action, final String currentResultName) {
String resultName = currentResultName;
if (action instanceof ValidationWorkflowAware) {
resultName = ((ValidationWorkflowAware) action).getInputResultName();
LOG.debug("Changing result name from [{}] to [{}] because of processing [{}] interface applied to [{}]",
currentResultName, resultName, ValidationWorkflowAware.class.getSimpleName(), action);
}
return resultName;
}
/**
* Process {@link InputConfig} annotation applied to method
* @param action action object
* @param method method
* @param currentResultName current result name
*
* @return result name
*
* @throws Exception in case of any errors
*/
protected String processInputConfig(final Object action, final String method, final String currentResultName) throws Exception {
String resultName = currentResultName;
InputConfig annotation = MethodUtils.getAnnotation(action.getClass().getMethod(method, EMPTY_CLASS_ARRAY),
InputConfig.class ,true,true);
if (annotation != null) {
if (StringUtils.isNotEmpty(annotation.methodName())) {
resultName = (String) MethodUtils.invokeMethod(action, true, annotation.methodName());
} else {
resultName = annotation.resultName();
}
LOG.debug("Changing result name from [{}] to [{}] because of processing annotation [{}] on action [{}]",
currentResultName, resultName, InputConfig.class.getSimpleName(), action);
}
return resultName;
}
/**
* Notify action if it implements {@link ValidationErrorAware} interface
*
* @param action action object
* @param currentResultName current result name
*
* @return result name
* @see ValidationErrorAware
*/
protected String processValidationErrorAware(final Object action, final String currentResultName) {
String resultName = currentResultName;
if (action instanceof ValidationErrorAware) {
resultName = ((ValidationErrorAware) action).actionErrorOccurred(currentResultName);
LOG.debug("Changing result name from [{}] to [{}] because of processing interface [{}] on action [{}]",
currentResultName, resultName, ValidationErrorAware.class.getSimpleName(), action);
}
return resultName;
}
}
@@ -1,325 +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.interceptor;
import com.opensymphony.xwork2.ActionInvocation;
import com.opensymphony.xwork2.config.entities.ExceptionMappingConfig;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.apache.struts2.dispatcher.HttpParameters;
import java.util.List;
import java.util.Map;
/**
* <!-- START SNIPPET: description -->
* <p>
* This interceptor forms the core functionality of the exception handling feature. Exception handling allows you to map
* an exception to a result code, just as if the action returned a result code instead of throwing an unexpected
* exception. When an exception is encountered, it is wrapped with an {@link ExceptionHolder} and pushed on the stack,
* providing easy access to the exception from within your result.
* </p>
*
* <p>
* <b>Note:</b> While you can configure exception mapping in your configuration file at any point, the configuration
* will not have any effect if this interceptor is not in the interceptor stack for your actions. It is recommended that
* you make this interceptor the first interceptor on the stack, ensuring that it has full access to catch any
* exception, even those caused by other interceptors.
* </p>
*
* <!-- END SNIPPET: description -->
*
* <p><u>Interceptor parameters:</u></p>
*
* <!-- START SNIPPET: parameters -->
*
* <ul>
*
* <li>logEnabled (optional) - Should exceptions also be logged? (boolean true|false)</li>
*
* <li>logLevel (optional) - what log level should we use (<code>trace, debug, info, warn, error, fatal</code>)? - defaut is <code>debug</code></li>
*
* <li>logCategory (optional) - If provided we would use this category (eg. <code>com.mycompany.app</code>).
* Default is to use <code>com.opensymphony.xwork2.interceptor.ExceptionMappingInterceptor</code>.</li>
*
* </ul>
*
* <p>
* The parameters above enables us to log all thrown exceptions with stacktace in our own logfile,
* and present a friendly webpage (with no stacktrace) to the end user.
* </p>
*
* <!-- END SNIPPET: parameters -->
*
* <p><u>Extending the interceptor:</u></p>
*
* <!-- START SNIPPET: extending -->
* <p>
* If you want to add custom handling for publishing the Exception, you may override
* {@link #publishException(com.opensymphony.xwork2.ActionInvocation, ExceptionHolder)}. The default implementation
* pushes the given ExceptionHolder on value stack. A custom implementation could add additional logging etc.
* </p>
* <!-- END SNIPPET: extending -->
*
* <p><u>Example code:</u></p>
*
* <pre>
* <!-- START SNIPPET: example -->
* &lt;xwork&gt;
* &lt;package name="default" extends="xwork-default"&gt;
* &lt;global-results&gt;
* &lt;result name="error" type="freemarker"&gt;error.ftl&lt;/result&gt;
* &lt;/global-results&gt;
*
* &lt;global-exception-mappings&gt;
* &lt;exception-mapping exception="java.lang.Exception" result="error"/&gt;
* &lt;/global-exception-mappings&gt;
*
* &lt;action name="test"&gt;
* &lt;interceptor-ref name="exception"/&gt;
* &lt;interceptor-ref name="basicStack"/&gt;
* &lt;exception-mapping exception="com.acme.CustomException" result="custom_error"/&gt;
* &lt;result name="custom_error"&gt;custom_error.ftl&lt;/result&gt;
* &lt;result name="success" type="freemarker"&gt;test.ftl&lt;/result&gt;
* &lt;/action&gt;
* &lt;/package&gt;
* &lt;/xwork&gt;
* <!-- END SNIPPET: example -->
* </pre>
*
* <p>
* This second example will also log the exceptions using our own category
* <code>com.mycompany.app.unhandled</code> at WARN level.
* </p>
*
* <pre>
* <!-- START SNIPPET: example2 -->
* &lt;xwork&gt;
* &lt;package name="something" extends="xwork-default"&gt;
* &lt;interceptors&gt;
* &lt;interceptor-stack name="exceptionmappingStack"&gt;
* &lt;interceptor-ref name="exception"&gt;
* &lt;param name="logEnabled"&gt;true&lt;/param&gt;
* &lt;param name="logCategory"&gt;com.mycompany.app.unhandled&lt;/param&gt;
* &lt;param name="logLevel"&gt;WARN&lt;/param&gt;
* &lt;/interceptor-ref&gt;
* &lt;interceptor-ref name="i18n"/&gt;
* &lt;interceptor-ref name="staticParams"/&gt;
* &lt;interceptor-ref name="params"/&gt;
* &lt;interceptor-ref name="validation"&gt;
* &lt;param name="excludeMethods"&gt;input,back,cancel,browse&lt;/param&gt;
* &lt;/interceptor-ref&gt;
* &lt;/interceptor-stack&gt;
* &lt;/interceptors&gt;
*
* &lt;default-interceptor-ref name="exceptionmappingStack"/&gt;
*
* &lt;global-results&gt;
* &lt;result name="unhandledException"&gt;/unhandled-exception.jsp&lt;/result&gt;
* &lt;/global-results&gt;
*
* &lt;global-exception-mappings&gt;
* &lt;exception-mapping exception="java.lang.Exception" result="unhandledException"/&gt;
* &lt;/global-exception-mappings&gt;
*
* &lt;action name="exceptionDemo" class="org.apache.struts2.showcase.exceptionmapping.ExceptionMappingAction"&gt;
* &lt;exception-mapping exception="org.apache.struts2.showcase.exceptionmapping.ExceptionMappingException"
* result="damm"/&gt;
* &lt;result name="input"&gt;index.jsp&lt;/result&gt;
* &lt;result name="success"&gt;success.jsp&lt;/result&gt;
* &lt;result name="damm"&gt;damm.jsp&lt;/result&gt;
* &lt;/action&gt;
*
* &lt;/package&gt;
* &lt;/xwork&gt;
* <!-- END SNIPPET: example2 -->
* </pre>
*
* @author Matthew E. Porter (matthew dot porter at metissian dot com)
* @author Claus Ibsen
*
* @deprecated since 6.7.0, use {@link org.apache.struts2.interceptor.ExceptionMappingInterceptor} instead.
*/
@Deprecated
public class ExceptionMappingInterceptor extends AbstractInterceptor {
private static final Logger LOG = LogManager.getLogger(ExceptionMappingInterceptor.class);
protected Logger categoryLogger;
protected boolean logEnabled = false;
protected String logCategory;
protected String logLevel;
public boolean isLogEnabled() {
return logEnabled;
}
public void setLogEnabled(boolean logEnabled) {
this.logEnabled = logEnabled;
}
public String getLogCategory() {
return logCategory;
}
public void setLogCategory(String logCatgory) {
this.logCategory = logCatgory;
}
public String getLogLevel() {
return logLevel;
}
public void setLogLevel(String logLevel) {
this.logLevel = logLevel;
}
@Override
public String intercept(ActionInvocation invocation) throws Exception {
String result;
try {
result = invocation.invoke();
} catch (Exception e) {
if (isLogEnabled()) {
handleLogging(e);
}
List<ExceptionMappingConfig> exceptionMappings = invocation.getProxy().getConfig().getExceptionMappings();
ExceptionMappingConfig mappingConfig = this.findMappingFromExceptions(exceptionMappings, e);
if (mappingConfig != null && mappingConfig.getResult()!=null) {
Map<String, String> mappingParams = mappingConfig.getParams();
// create a mutable HashMap since some interceptors will remove parameters, and parameterMap is immutable
HttpParameters parameters = HttpParameters.create(mappingParams).build();
invocation.getInvocationContext().withParameters(parameters);
result = mappingConfig.getResult();
publishException(invocation, new ExceptionHolder(e));
} else {
throw e;
}
}
return result;
}
/**
* Handles the logging of the exception.
*
* @param e the exception to log.
*/
protected void handleLogging(Exception e) {
if (logCategory != null) {
if (categoryLogger == null) {
// init category logger
categoryLogger = LogManager.getLogger(logCategory);
}
doLog(categoryLogger, e);
} else {
doLog(LOG, e);
}
}
/**
* Performs the actual logging.
*
* @param logger the provided logger to use.
* @param e the exception to log.
*/
protected void doLog(Logger logger, Exception e) {
if (logLevel == null) {
logger.debug(e.getMessage(), e);
return;
}
if ("trace".equalsIgnoreCase(logLevel)) {
logger.trace(e.getMessage(), e);
} else if ("debug".equalsIgnoreCase(logLevel)) {
logger.debug(e.getMessage(), e);
} else if ("info".equalsIgnoreCase(logLevel)) {
logger.info(e.getMessage(), e);
} else if ("warn".equalsIgnoreCase(logLevel)) {
logger.warn(e.getMessage(), e);
} else if ("error".equalsIgnoreCase(logLevel)) {
logger.error(e.getMessage(), e);
} else if ("fatal".equalsIgnoreCase(logLevel)) {
logger.fatal(e.getMessage(), e);
} else {
throw new IllegalArgumentException("LogLevel [" + logLevel + "] is not supported");
}
}
/**
* Try to find appropriate {@link ExceptionMappingConfig} based on provided Throwable
*
* @param exceptionMappings list of defined exception mappings
* @param t caught exception
* @return appropriate mapping or null
*/
protected ExceptionMappingConfig findMappingFromExceptions(List<ExceptionMappingConfig> exceptionMappings, Throwable t) {
ExceptionMappingConfig config = null;
// Check for specific exception mappings.
if (exceptionMappings != null) {
int deepest = Integer.MAX_VALUE;
for (ExceptionMappingConfig exceptionMapping : exceptionMappings) {
int depth = getDepth(exceptionMapping.getExceptionClassName(), t);
if (depth >= 0 && depth < deepest) {
deepest = depth;
config = exceptionMapping;
}
}
}
return config;
}
/**
* Return the depth to the superclass matching. 0 means ex matches exactly. Returns -1 if there's no match.
* Otherwise, returns depth. Lowest depth wins.
*
* @param exceptionMapping the mapping classname
* @param t the cause
* @return the depth, if not found -1 is returned.
*/
public int getDepth(String exceptionMapping, Throwable t) {
return getDepth(exceptionMapping, t.getClass(), 0);
}
private int getDepth(String exceptionMapping, Class exceptionClass, int depth) {
if (exceptionClass.getName().contains(exceptionMapping)) {
// Found it!
return depth;
}
// If we've gone as far as we can go and haven't found it...
if (exceptionClass.equals(Throwable.class)) {
return -1;
}
return getDepth(exceptionMapping, exceptionClass.getSuperclass(), depth + 1);
}
/**
* Default implementation to handle ExceptionHolder publishing. Pushes given ExceptionHolder on the stack.
* Subclasses may override this to customize publishing.
*
* @param invocation The invocation to publish Exception for.
* @param exceptionHolder The exceptionHolder wrapping the Exception to publish.
*/
protected void publishException(ActionInvocation invocation, ExceptionHolder exceptionHolder) {
invocation.getStack().push(exceptionHolder);
}
}
@@ -1,75 +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.interceptor;
import com.opensymphony.xwork2.ActionInvocation;
/**
* {@inheritDoc}
*
* @deprecated since 6.7.0, use {@link org.apache.struts2.interceptor.Interceptor} instead.
*/
@Deprecated
public interface Interceptor extends org.apache.struts2.interceptor.Interceptor {
@Override
default String intercept(org.apache.struts2.ActionInvocation invocation) throws Exception {
return intercept(ActionInvocation.adapt(invocation));
}
String intercept(ActionInvocation invocation) throws Exception;
static Interceptor adapt(org.apache.struts2.interceptor.Interceptor actualInterceptor) {
if (actualInterceptor instanceof org.apache.struts2.interceptor.ConditionalInterceptor) {
return ConditionalInterceptor.adapt((org.apache.struts2.interceptor.ConditionalInterceptor) actualInterceptor);
}
if (actualInterceptor instanceof Interceptor) {
return (Interceptor) actualInterceptor;
}
return actualInterceptor != null ? new LegacyAdapter(actualInterceptor) : null;
}
class LegacyAdapter implements Interceptor {
private final org.apache.struts2.interceptor.Interceptor adaptee;
protected LegacyAdapter(org.apache.struts2.interceptor.Interceptor adaptee) {
this.adaptee = adaptee;
}
public org.apache.struts2.interceptor.Interceptor getAdaptee() {
return adaptee;
}
@Override
public String intercept(ActionInvocation invocation) throws Exception {
return adaptee.intercept(invocation);
}
@Override
public void destroy() {
adaptee.destroy();
}
@Override
public void init() {
adaptee.init();
}
}
}
@@ -1,93 +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.interceptor;
import com.opensymphony.xwork2.ActionInvocation;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
/**
* <!-- START SNIPPET: description -->
* <p>
* This interceptor logs the start and end of the execution an action (in English-only, not internationalized).
* <br>
* <b>Note:</b>: This interceptor will log at <tt>INFO</tt> level.
* </p>
* <!-- END SNIPPET: description -->
*
* <!-- START SNIPPET: parameters -->
* There are no parameters for this interceptor.
* <!-- END SNIPPET: parameters -->
*
* <!-- START SNIPPET: extending -->
* There are no obvious extensions to the existing interceptor.
* <!-- END SNIPPET: extending -->
*
* <pre>
* <!-- START SNIPPET: example -->
* &lt;!-- prints out a message before and after the immediate action execution --&gt;
* &lt;action name=&quot;someAction&quot; class=&quot;com.examples.SomeAction&quot;&gt;
* &lt;interceptor-ref name=&quot;completeStack&quot;/&gt;
* &lt;interceptor-ref name=&quot;logger&quot;/&gt;
* &lt;result name=&quot;success&quot;&gt;good_result.ftl&lt;/result&gt;
* &lt;/action&gt;
*
* &lt;!-- prints out a message before any more interceptors continue and after they have finished --&gt;
* &lt;action name=&quot;someAction&quot; class=&quot;com.examples.SomeAction&quot;&gt;
* &lt;interceptor-ref name=&quot;logger&quot;/&gt;
* &lt;interceptor-ref name=&quot;completeStack&quot;/&gt;
* &lt;result name=&quot;success&quot;&gt;good_result.ftl&lt;/result&gt;
* &lt;/action&gt;
* <!-- END SNIPPET: example -->
* </pre>
*
* @author Jason Carreira
*
* @deprecated since 6.7.0, use {@link org.apache.struts2.interceptor.LoggingInterceptor} instead.
*/
@Deprecated
public class LoggingInterceptor extends AbstractInterceptor {
private static final Logger LOG = LogManager.getLogger(LoggingInterceptor.class);
private static final String FINISH_MESSAGE = "Finishing execution stack for action ";
private static final String START_MESSAGE = "Starting execution stack for action ";
@Override
public String intercept(ActionInvocation invocation) throws Exception {
logMessage(invocation, START_MESSAGE);
String result = invocation.invoke();
logMessage(invocation, FINISH_MESSAGE);
return result;
}
private void logMessage(ActionInvocation invocation, String baseMessage) {
if (LOG.isInfoEnabled()) {
StringBuilder message = new StringBuilder(baseMessage);
String namespace = invocation.getProxy().getNamespace();
if (namespace != null && !namespace.trim().isEmpty()) {
message.append(namespace).append("/");
}
message.append(invocation.getProxy().getActionName());
LOG.info(message.toString());
}
}
}
@@ -1,126 +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.interceptor;
import com.opensymphony.xwork2.ActionInvocation;
import com.opensymphony.xwork2.util.TextParseUtil;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import java.util.Collections;
import java.util.Set;
/**
* <!-- START SNIPPET: javadoc -->
*
* <p>
* MethodFilterInterceptor is an abstract <code>Interceptor</code> used as
* a base class for interceptors that will filter execution based on method
* names according to specified included/excluded method lists.
*
* </p>
*
* Settable parameters are as follows:
*
* <ul>
* <li>excludeMethods - method names to be excluded from interceptor processing</li>
* <li>includeMethods - method names to be included in interceptor processing</li>
* </ul>
*
* <p>
*
* <b>NOTE:</b> If method name are available in both includeMethods and
* excludeMethods, it will be considered as an included method:
* includeMethods takes precedence over excludeMethods.
*
* </p>
*
* Interceptors that extends this capability include:
*
* <ul>
* <li>TokenInterceptor</li>
* <li>TokenSessionStoreInterceptor</li>
* <li>DefaultWorkflowInterceptor</li>
* <li>ValidationInterceptor</li>
* </ul>
*
* <!-- END SNIPPET: javadoc -->
*
* @author <a href='mailto:the_mindstorm[at]evolva[dot]ro'>Alexandru Popescu</a>
* @author Rainer Hermanns
*
* @see org.apache.struts2.interceptor.TokenInterceptor
* @see org.apache.struts2.interceptor.TokenSessionStoreInterceptor
* @see com.opensymphony.xwork2.interceptor.DefaultWorkflowInterceptor
* @see com.opensymphony.xwork2.validator.ValidationInterceptor
*
* @deprecated since 6.7.0, use {@link org.apache.struts2.interceptor.MethodFilterInterceptor} instead.
*/
@Deprecated
public abstract class MethodFilterInterceptor extends AbstractInterceptor {
private static final Logger LOG = LogManager.getLogger(MethodFilterInterceptor.class);
protected Set<String> excludeMethods = Collections.emptySet();
protected Set<String> includeMethods = Collections.emptySet();
public void setExcludeMethods(String excludeMethods) {
this.excludeMethods = TextParseUtil.commaDelimitedStringToSet(excludeMethods);
}
public Set<String> getExcludeMethodsSet() {
return excludeMethods;
}
public void setIncludeMethods(String includeMethods) {
this.includeMethods = TextParseUtil.commaDelimitedStringToSet(includeMethods);
}
public Set<String> getIncludeMethodsSet() {
return includeMethods;
}
@Override
public String intercept(ActionInvocation invocation) throws Exception {
if (applyInterceptor(invocation)) {
return doIntercept(invocation);
}
return invocation.invoke();
}
protected boolean applyInterceptor(ActionInvocation invocation) {
String method = invocation.getProxy().getMethod();
// ValidationInterceptor
boolean applyMethod = MethodFilterInterceptorUtil.applyMethod(excludeMethods, includeMethods, method);
if (!applyMethod) {
LOG.debug("Skipping Interceptor... Method [{}] found in exclude list.", method);
}
return applyMethod;
}
/**
* Subclasses must override to implement the interceptor logic.
*
* @param invocation the action invocation
* @return the result of invocation
* @throws Exception in case of any errors
*/
protected abstract String doIntercept(ActionInvocation invocation) throws Exception;
}
@@ -1,26 +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.interceptor;
/**
* @deprecated since 6.7.0, use {@link org.apache.struts2.interceptor.MethodFilterInterceptorUtil} instead.
*/
@Deprecated
public class MethodFilterInterceptorUtil extends org.apache.struts2.interceptor.MethodFilterInterceptorUtil {
}
@@ -1,150 +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.interceptor;
import com.opensymphony.xwork2.ActionInvocation;
import com.opensymphony.xwork2.util.CompoundRoot;
import com.opensymphony.xwork2.util.ValueStack;
import org.apache.struts2.ModelDriven;
/**
* <!-- START SNIPPET: description -->
*
* Watches for {@link ModelDriven} actions and adds the action's model on to the value stack.
*
* <p> <b>Note:</b> The ModelDrivenInterceptor must come before the both {@link StaticParametersInterceptor} and
* {@link org.apache.struts2.interceptor.parameter.ParametersInterceptor} if you want the parameters to be applied to
* the model.
* </p>
* <p> <b>Note:</b> The ModelDrivenInterceptor will only push the model into the stack when the
* model is not null, else it will be ignored.
* </p>
*
* <!-- END SNIPPET: description -->
*
* <p><u>Interceptor parameters:</u></p>
*
* <!-- START SNIPPET: parameters -->
*
* <ul>
*
* <li>refreshModelBeforeResult - set to true if you want the model to be refreshed on the value stack after action
* execution and before result execution. The setting is useful if you want to change the model instance during the
* action execution phase, like when loading it from the data layer. This will result in getModel() being called at
* least twice.</li>
*
* </ul>
*
* <!-- END SNIPPET: parameters -->
*
* <p><u>Extending the interceptor:</u></p>
*
* <!-- START SNIPPET: extending -->
*
* There are no known extension points to this interceptor.
*
* <!-- END SNIPPET: extending -->
*
* <p><u>Example code:</u></p>
*
* <pre>
* <!-- START SNIPPET: example -->
* &lt;action name=&quot;someAction&quot; class=&quot;com.examples.SomeAction&quot;&gt;
* &lt;interceptor-ref name=&quot;modelDriven&quot;/&gt;
* &lt;interceptor-ref name=&quot;basicStack&quot;/&gt;
* &lt;result name=&quot;success&quot;&gt;good_result.ftl&lt;/result&gt;
* &lt;/action&gt;
* <!-- END SNIPPET: example -->
* </pre>
*
* @author tm_jee
* @version $Date$ $Id$
*
* @deprecated since 6.7.0, use {@link org.apache.struts2.interceptor.ModelDrivenInterceptor} instead.
*/
@Deprecated
public class ModelDrivenInterceptor extends AbstractInterceptor {
protected boolean refreshModelBeforeResult = false;
public void setRefreshModelBeforeResult(boolean val) {
this.refreshModelBeforeResult = val;
}
@Override
public String intercept(ActionInvocation invocation) throws Exception {
Object action = invocation.getAction();
if (action instanceof ModelDriven modelDriven) {
ValueStack stack = invocation.getStack();
Object model = modelDriven.getModel();
if (model != null) {
stack.push(model);
}
if (refreshModelBeforeResult) {
invocation.addPreResultListener(new RefreshModelBeforeResult(modelDriven, model));
}
}
return invocation.invoke();
}
/**
* Refreshes the model instance on the value stack, if it has changed
*/
protected static class RefreshModelBeforeResult implements PreResultListener {
private final Object originalModel;
protected ModelDriven action;
public RefreshModelBeforeResult(ModelDriven action, Object model) {
this.originalModel = model;
this.action = action;
}
public void beforeResult(ActionInvocation invocation, String resultCode) {
ValueStack stack = invocation.getStack();
CompoundRoot root = stack.getRoot();
boolean needsRefresh = true;
Object newModel = action.getModel();
// Check to see if the new model instance is already on the stack
if (newModel != null) {
for (Object item : root) {
if (item == newModel) {
needsRefresh = false;
break;
}
}
}
// Add the new model on the stack
if (needsRefresh) {
// Clear off the old model instance
if (originalModel != null) {
root.remove(originalModel);
}
if (newModel != null) {
stack.push(newModel);
}
}
}
}
}
@@ -1,127 +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.interceptor;
import com.opensymphony.xwork2.ActionContext;
import com.opensymphony.xwork2.ActionInvocation;
import com.opensymphony.xwork2.util.TextParseUtil;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.apache.struts2.action.NoParameters;
import org.apache.struts2.dispatcher.HttpParameters;
import org.apache.struts2.dispatcher.Parameter;
import java.util.Collections;
import java.util.Set;
/**
* This is a simple XWork interceptor that allows parameters (matching
* one of the paramNames attribute csv value) to be
* removed from the parameter map if they match a certain value
* (matching one of the paramValues attribute csv value), before they
* are set on the action. A typical usage would be to want a dropdown/select
* to map onto a boolean value on an action. The select had the options
* none, yes and no with values -1, true and false. The true and false would
* map across correctly. However the -1 would be set to false.
* This was not desired as one might needed the value on the action to stay null.
* This interceptor fixes this by preventing the parameter from ever reaching
* the action.
*
* <ul>
* <li>paramNames - A comma separated value (csv) indicating the parameter name
* whose param value should be considered that if they match any of the
* comma separated value (csv) from paramValues attribute, shall be
* removed from the parameter map such that they will not be applied
* to the action</li>
* <li>paramValues - A comma separated value (csv) indicating the parameter value that if
* matched shall have its parameter be removed from the parameter map
* such that they will not be applied to the action</li>
* </ul>
* <p>
* No intended extension point
*
* <pre>
* &lt;action name="sample" class="org.martingilday.Sample"&gt;
* &lt;interceptor-ref name="paramRemover"&gt;
* &lt;param name="paramNames"&gt;aParam,anotherParam&lt;/param&gt;
* &lt;param name="paramValues"&gt;--,-1&lt;/param&gt;
* &lt;/interceptor-ref&gt;
* &lt;interceptor-ref name="defaultStack" /&gt;
* ...
* &lt;/action&gt;
* </pre>
*
* @deprecated since 6.7.0, use {@link org.apache.struts2.interceptor.ParameterRemoverInterceptor} instead.
*/
@Deprecated
public class ParameterRemoverInterceptor extends AbstractInterceptor {
private static final Logger LOG = LogManager.getLogger(ParameterRemoverInterceptor.class);
private Set<String> paramNames = Collections.emptySet();
private Set<String> paramValues = Collections.emptySet();
/**
* Decide if the parameter should be removed from the parameter map based on
* <code>paramNames</code> and <code>paramValues</code>.
*
* @see com.opensymphony.xwork2.interceptor.AbstractInterceptor
*/
@Override
public String intercept(ActionInvocation invocation) throws Exception {
if (!(invocation.getAction() instanceof NoParameters)
&& (null != this.paramNames)) {
ActionContext ac = invocation.getInvocationContext();
HttpParameters parameters = ac.getParameters();
if (parameters != null) {
for (String removeName : paramNames) {
try {
Parameter parameter = parameters.get(removeName);
if (parameter.isDefined() && this.paramValues.contains(parameter.getValue())) {
parameters.remove(removeName);
}
} catch (Exception e) {
LOG.error("Failed to convert parameter to string", e);
}
}
}
}
return invocation.invoke();
}
/**
* Allows <code>paramNames</code> attribute to be set as comma-separated-values (csv).
*
* @param paramNames the paramNames to set
*/
public void setParamNames(String paramNames) {
this.paramNames = TextParseUtil.commaDelimitedStringToSet(paramNames);
}
/**
* Allows <code>paramValues</code> attribute to be set as a comma-separated-values (csv).
*
* @param paramValues the paramValues to set
*/
public void setParamValues(String paramValues) {
this.paramValues = TextParseUtil.commaDelimitedStringToSet(paramValues);
}
}
@@ -1,58 +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.interceptor;
import com.opensymphony.xwork2.ActionInvocation;
/**
* {@inheritDoc}
*
* @deprecated since 6.7.0, use {@link org.apache.struts2.interceptor.PreResultListener} instead.
*/
@Deprecated
public interface PreResultListener extends org.apache.struts2.interceptor.PreResultListener {
@Override
default void beforeResult(org.apache.struts2.ActionInvocation invocation, String resultCode) {
beforeResult(ActionInvocation.adapt(invocation), resultCode);
}
void beforeResult(ActionInvocation invocation, String resultCode);
static PreResultListener adapt(org.apache.struts2.interceptor.PreResultListener actualListener) {
if (actualListener instanceof PreResultListener) {
return (PreResultListener) actualListener;
}
return actualListener != null ? new LegacyAdapter(actualListener) : null;
}
class LegacyAdapter implements PreResultListener {
private final org.apache.struts2.interceptor.PreResultListener adaptee;
private LegacyAdapter(org.apache.struts2.interceptor.PreResultListener adaptee) {
this.adaptee = adaptee;
}
@Override
public void beforeResult(ActionInvocation invocation, String resultCode) {
adaptee.beforeResult(invocation, resultCode);
}
}
}
@@ -1,181 +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.interceptor;
import com.opensymphony.xwork2.ActionInvocation;
import org.apache.struts2.Preparable;
import java.io.Serial;
import java.lang.reflect.InvocationTargetException;
/**
* <!-- START SNIPPET: description -->
*
* This interceptor calls <code>prepare()</code> on actions which implement
* {@link Preparable}. This interceptor is very useful for any situation where
* you need to ensure some logic runs before the actual execute method runs.
*
* <p>
* A typical use of this is to run some logic to load an object from the
* database so that when parameters are set they can be set on this object. For
* example, suppose you have a User object with two properties: <i>id</i> and
* <i>name</i>. Provided that the params interceptor is called twice (once
* before and once after this interceptor), you can load the User object using
* the id property, and then when the second params interceptor is called the
* parameter <i>user.name</i> will be set, as desired, on the actual object
* loaded from the database. See the example for more info.
* </p>
* <p>
* <b>Note:</b> Since XWork 2.0.2, this interceptor extends {@link MethodFilterInterceptor}, therefore being
* able to deal with excludeMethods / includeMethods parameters. See [Workflow Interceptor]
* (class {@link DefaultWorkflowInterceptor}) for documentation and examples on how to use this feature.
* </p>
*
* <p>
* <b>Update</b>: Added logic to execute a prepare{MethodName} and conditionally
* the a general prepare() Method, depending on the 'alwaysInvokePrepare' parameter/property
* which is by default true. This allows us to run some logic based on the method
* name we specify in the {@link com.opensymphony.xwork2.ActionProxy}. For example, you can specify a
* prepareInput() method that will be run before the invocation of the input method.
* </p>
*
* <!-- END SNIPPET: description -->
*
* <p><u>Interceptor parameters:</u></p>
*
* <!-- START SNIPPET: parameters -->
*
* <ul>
*
* <li>alwaysInvokePrepare - Default to true. If true, prepare will always be invoked,
* otherwise it will not.</li>
*
* </ul>
*
* <!-- END SNIPPET: parameters -->
*
* <p><u>Extending the interceptor:</u></p>
*
* <!-- START SNIPPET: extending -->
*
* There are no known extension points to this interceptor.
*
* <!-- END SNIPPET: extending -->
*
* <p> <u>Example code:</u></p>
*
* <pre>
* <!-- START SNIPPET: example -->
* &lt;!-- Calls the params interceptor twice, allowing you to
* pre-load data for the second time parameters are set --&gt;
* &lt;action name="someAction" class="com.examples.SomeAction"&gt;
* &lt;interceptor-ref name="params"/&gt;
* &lt;interceptor-ref name="prepare"/&gt;
* &lt;interceptor-ref name="basicStack"/&gt;
* &lt;result name="success"&gt;good_result.ftl&lt;/result&gt;
* &lt;/action&gt;
* <!-- END SNIPPET: example -->
* </pre>
*
* @author Jason Carreira
* @author Philip Luppens
* @author tm_jee
* @see com.opensymphony.xwork2.Preparable
*
* @deprecated since 6.7.0, use {@link org.apache.struts2.interceptor.PrepareInterceptor} instead.
*/
@Deprecated
public class PrepareInterceptor extends MethodFilterInterceptor {
@Serial
private static final long serialVersionUID = -5216969014510719786L;
private final static String PREPARE_PREFIX = "prepare";
private final static String ALT_PREPARE_PREFIX = "prepareDo";
private boolean alwaysInvokePrepare = true;
private boolean firstCallPrepareDo = false;
/**
* Sets if the <code>prepare</code> method should always be executed.
* <p>
* Default is <tt>true</tt>.
* </p>
*
* @param alwaysInvokePrepare if <code>prepare</code> should always be executed or not.
*/
public void setAlwaysInvokePrepare(String alwaysInvokePrepare) {
this.alwaysInvokePrepare = Boolean.parseBoolean(alwaysInvokePrepare);
}
/**
* Sets if the <code>prepareDoXXX</code> method should be called first
* <p>
* Default is <tt>false</tt> for backward compatibility
* </p>
* @param firstCallPrepareDo if <code>prepareDoXXX</code> should be called first
*/
public void setFirstCallPrepareDo(String firstCallPrepareDo) {
this.firstCallPrepareDo = Boolean.parseBoolean(firstCallPrepareDo);
}
@Override
public String doIntercept(ActionInvocation invocation) throws Exception {
Object action = invocation.getAction();
if (action instanceof Preparable) {
try {
String[] prefixes;
if (firstCallPrepareDo) {
prefixes = new String[] {ALT_PREPARE_PREFIX, PREPARE_PREFIX};
} else {
prefixes = new String[] {PREPARE_PREFIX, ALT_PREPARE_PREFIX};
}
PrefixMethodInvocationUtil.invokePrefixMethod(invocation, prefixes);
}
catch (InvocationTargetException e) {
/*
* The invoked method threw an exception and reflection wrapped it
* in an InvocationTargetException.
* If possible re-throw the original exception so that normal
* exception handling will take place.
*/
Throwable cause = e.getCause();
if (cause instanceof Exception) {
throw (Exception) cause;
} else if(cause instanceof Error) {
throw (Error) cause;
} else {
/*
* The cause is not an Exception or Error (must be Throwable) so
* just re-throw the wrapped exception.
*/
throw e;
}
}
if (alwaysInvokePrepare) {
((Preparable) action).prepare();
}
}
return invocation.invoke();
}
}
@@ -1,28 +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.interceptor;
import com.opensymphony.xwork2.ModelDriven;
/**
* @deprecated since 6.7.0, use {@link org.apache.struts2.interceptor.ScopedModelDriven} instead.
*/
@Deprecated
public interface ScopedModelDriven<T> extends org.apache.struts2.interceptor.ScopedModelDriven<T>, ModelDriven<T> {
}
@@ -1,168 +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.interceptor;
import com.opensymphony.xwork2.ActionContext;
import com.opensymphony.xwork2.ActionInvocation;
import com.opensymphony.xwork2.ObjectFactory;
import com.opensymphony.xwork2.config.entities.ActionConfig;
import com.opensymphony.xwork2.inject.Inject;
import org.apache.struts2.StrutsException;
import org.apache.struts2.interceptor.ScopedModelDriven;
import java.lang.reflect.Method;
import java.util.Map;
/**
* <!-- START SNIPPET: description -->
*
* An interceptor that enables scoped model-driven actions.
*
* <p>This interceptor only activates on actions that implement the {@link ScopedModelDriven} interface. If
* detected, it will retrieve the model class from the configured scope, then provide it to the Action.</p>
*
* <!-- END SNIPPET: description -->
*
* <p><u>Interceptor parameters:</u></p>
*
* <!-- START SNIPPET: parameters -->
*
* <ul>
*
* <li>className - The model class name. Defaults to the class name of the object returned by the getModel() method.</li>
*
* <li>name - The key to use when storing or retrieving the instance in a scope. Defaults to the model
* class name.</li>
*
* <li>scope - The scope to store and retrieve the model. Defaults to 'request' but can also be 'session'.</li>
* </ul>
*
* <!-- END SNIPPET: parameters -->
*
* <p><u>Extending the interceptor:</u></p>
*
* <!-- START SNIPPET: extending -->
*
* There are no known extension points for this interceptor.
*
* <!-- END SNIPPET: extending -->
*
* <p><u>Example code:</u></p>
*
* <pre>
* <!-- START SNIPPET: example -->
*
* &lt;-- Basic usage --&gt;
* &lt;interceptor name="scopedModelDriven" class="com.opensymphony.interceptor.ScopedModelDrivenInterceptor" /&gt;
*
* &lt;-- Using all available parameters --&gt;
* &lt;interceptor name="gangsterForm" class="com.opensymphony.interceptor.ScopedModelDrivenInterceptor"&gt;
* &lt;param name="scope"&gt;session&lt;/param&gt;
* &lt;param name="name"&gt;gangsterForm&lt;/param&gt;
* &lt;param name="className"&gt;com.opensymphony.example.GangsterForm&lt;/param&gt;
* &lt;/interceptor&gt;
*
* <!-- END SNIPPET: example -->
* </pre>
*
* @deprecated since 6.7.0, use {@link org.apache.struts2.interceptor.ScopedModelDrivenInterceptor} instead.
*/
@Deprecated
public class ScopedModelDrivenInterceptor extends AbstractInterceptor {
private static final Class[] EMPTY_CLASS_ARRAY = new Class[0];
private static final String GET_MODEL = "getModel";
private String scope;
private String name;
private String className;
private ObjectFactory objectFactory;
@Inject
public void setObjectFactory(ObjectFactory factory) {
this.objectFactory = factory;
}
protected Object resolveModel(ObjectFactory factory, ActionContext actionContext, String modelClassName, String modelScope, String modelName) throws Exception {
Object model;
Map<String, Object> scopeMap = actionContext.getContextMap();
if ("session".equals(modelScope)) {
scopeMap = actionContext.getSession();
}
model = scopeMap.get(modelName);
if (model == null) {
model = factory.buildBean(modelClassName, null);
scopeMap.put(modelName, model);
}
return model;
}
@Override
public String intercept(ActionInvocation invocation) throws Exception {
Object action = invocation.getAction();
if (action instanceof ScopedModelDriven modelDriven) {
if (modelDriven.getModel() == null) {
ActionContext ctx = ActionContext.getContext();
ActionConfig config = invocation.getProxy().getConfig();
String cName = className;
if (cName == null) {
try {
Method method = action.getClass().getMethod(GET_MODEL, EMPTY_CLASS_ARRAY);
Class cls = method.getReturnType();
cName = cls.getName();
} catch (NoSuchMethodException e) {
throw new StrutsException("The " + GET_MODEL + "() is not defined in action " + action.getClass(), config);
}
}
String modelName = name;
if (modelName == null) {
modelName = cName;
}
Object model = resolveModel(objectFactory, ctx, cName, scope, modelName);
modelDriven.setModel(model);
modelDriven.setScopeKey(modelName);
}
}
return invocation.invoke();
}
/**
* @param className the className to set
*/
public void setClassName(String className) {
this.className = className;
}
/**
* @param name the name to set
*/
public void setName(String name) {
this.name = name;
}
/**
* @param scope the scope to set
*/
public void setScope(String scope) {
this.scope = scope;
}
}
@@ -1,245 +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.interceptor;
import com.opensymphony.xwork2.ActionContext;
import com.opensymphony.xwork2.ActionInvocation;
import com.opensymphony.xwork2.LocalizedTextProvider;
import com.opensymphony.xwork2.config.entities.ActionConfig;
import com.opensymphony.xwork2.config.entities.Parameterizable;
import com.opensymphony.xwork2.inject.Inject;
import com.opensymphony.xwork2.util.ClearableValueStack;
import com.opensymphony.xwork2.util.TextParseUtil;
import com.opensymphony.xwork2.util.ValueStack;
import com.opensymphony.xwork2.util.ValueStackFactory;
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 org.apache.struts2.interceptor.ValidationAware;
import java.util.Collections;
import java.util.Map;
/**
* <!-- START SNIPPET: description -->
*
* This interceptor populates the action with the static parameters defined in the action configuration. If the action
* implements {@link Parameterizable}, a map of the static parameters will be also be passed directly to the action.
* The static params will be added to the request params map, unless "merge" is set to false.
*
* <p> Parameters are typically defined with &lt;param&gt; elements within xwork.xml.</p>
*
* <!-- END SNIPPET: description -->
*
* <p><u>Interceptor parameters:</u></p>
*
* <!-- START SNIPPET: parameters -->
*
* <ul>
*
* <li>None</li>
*
* </ul>
*
* <!-- END SNIPPET: parameters -->
*
* <p><u>Extending the interceptor:</u></p>
*
* <!-- START SNIPPET: extending -->
*
* <p>There are no extension points to this interceptor.</p>
*
* <!-- END SNIPPET: extending -->
*
* <p> <u>Example code:</u></p>
*
* <pre>
* <!-- START SNIPPET: example -->
* &lt;action name="someAction" class="com.examples.SomeAction"&gt;
* &lt;interceptor-ref name="staticParams"&gt;
* &lt;param name="parse"&gt;true&lt;/param&gt;
* &lt;param name="overwrite"&gt;false&lt;/param&gt;
* &lt;/interceptor-ref&gt;
* &lt;result name="success"&gt;good_result.ftl&lt;/result&gt;
* &lt;/action&gt;
* <!-- END SNIPPET: example -->
* </pre>
*
* @author Patrick Lightbody
*
* @deprecated since 6.7.0, use {@link org.apache.struts2.interceptor.StaticParametersInterceptor} instead.
*/
@Deprecated
public class StaticParametersInterceptor extends AbstractInterceptor {
private boolean parse;
private boolean overwrite;
private boolean merge = true;
private boolean devMode = false;
private static final Logger LOG = LogManager.getLogger(StaticParametersInterceptor.class);
private ValueStackFactory valueStackFactory;
private LocalizedTextProvider localizedTextProvider;
@Inject
public void setValueStackFactory(ValueStackFactory valueStackFactory) {
this.valueStackFactory = valueStackFactory;
}
@Inject(StrutsConstants.STRUTS_DEVMODE)
public void setDevMode(String mode) {
devMode = BooleanUtils.toBoolean(mode);
}
@Inject
public void setLocalizedTextProvider(LocalizedTextProvider localizedTextProvider) {
this.localizedTextProvider = localizedTextProvider;
}
public void setParse(String value) {
this.parse = BooleanUtils.toBoolean(value);
}
public void setMerge(String value) {
this.merge = BooleanUtils.toBoolean(value);
}
/**
* Overwrites already existing parameters from other sources.
* Static parameters are the successor over previously set parameters, if true.
*
* @param value enable overwrites of already existing parameters from other sources
*/
public void setOverwrite(String value) {
this.overwrite = BooleanUtils.toBoolean(value);
}
@Override
public String intercept(ActionInvocation invocation) throws Exception {
ActionConfig config = invocation.getProxy().getConfig();
Object action = invocation.getAction();
final Map<String, String> parameters = config.getParams();
LOG.debug("Setting static parameters: {}", parameters);
// for actions marked as Parameterizable, pass the static parameters directly
if (action instanceof Parameterizable) {
((Parameterizable) action).setParams(parameters);
}
if (parameters != null) {
ActionContext ac = ActionContext.getContext();
Map<String, Object> contextMap = ac.getContextMap();
try {
ReflectionContextState.setCreatingNullObjects(contextMap, true);
ReflectionContextState.setReportingConversionErrors(contextMap, true);
final ValueStack stack = ac.getValueStack();
ValueStack newStack = valueStackFactory.createValueStack(stack);
boolean clearableStack = newStack instanceof ClearableValueStack;
if (clearableStack) {
//if the stack's context can be cleared, do that to prevent OGNL
//from having access to objects in the stack, see XW-641
((ClearableValueStack)newStack).clearContextValues();
Map<String, Object> context = newStack.getContext();
ReflectionContextState.setCreatingNullObjects(context, true);
ReflectionContextState.setDenyMethodExecution(context, true);
ReflectionContextState.setReportingConversionErrors(context, true);
//keep locale from original context
newStack.getActionContext().withLocale(stack.getActionContext().getLocale());
}
for (Map.Entry<String, String> entry : parameters.entrySet()) {
Object val = entry.getValue();
if (parse && val != null) {
val = TextParseUtil.translateVariables(val.toString(), stack);
}
try {
newStack.setValue(entry.getKey(), val);
} catch (RuntimeException e) {
if (devMode) {
String developerNotification = localizedTextProvider.findText(StaticParametersInterceptor.class, "devmode.notification", ActionContext.getContext().getLocale(), "Developer Notification:\n{0}", new Object[]{
"Unexpected Exception caught setting '" + entry.getKey() + "' on '" + action.getClass() + ": " + e.getMessage()
});
LOG.error(developerNotification);
if (action instanceof ValidationAware) {
((ValidationAware) action).addActionMessage(developerNotification);
}
}
}
}
if (clearableStack) {
stack.getActionContext().withConversionErrors(newStack.getActionContext().getConversionErrors());
}
if (merge)
addParametersToContext(ac, parameters);
} finally {
ReflectionContextState.setCreatingNullObjects(contextMap, false);
ReflectionContextState.setReportingConversionErrors(contextMap, false);
}
}
return invocation.invoke();
}
/**
* @param ac The action context
* @return the parameters from the action mapping in the context. If none found, returns
* an empty map.
*/
protected Map<String, String> retrieveParameters(ActionContext ac) {
ActionConfig config = ac.getActionInvocation().getProxy().getConfig();
if (config != null) {
return config.getParams();
} else {
return Collections.emptyMap();
}
}
/**
* Adds the parameters into context's ParameterMap.
* As default, static parameters will not overwrite existing parameters from other sources.
* If you want the static parameters as successor over already existing parameters, set overwrite to <tt>true</tt>.
*
* @param ac The action context
* @param newParams The parameter map to apply
*/
protected void addParametersToContext(ActionContext ac, Map<String, ?> newParams) {
HttpParameters previousParams = ac.getParameters();
HttpParameters.Builder combinedParams;
if (overwrite) {
combinedParams = HttpParameters.create().withParent( previousParams);
combinedParams = combinedParams.withExtraParams(newParams);
} else {
combinedParams = HttpParameters.create(newParams);
combinedParams = combinedParams.withExtraParams(previousParams);
}
ac.withParameters(combinedParams.build());
}
}
@@ -1,106 +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.interceptor;
import java.util.Collection;
import java.util.List;
import java.util.Map;
/**
* @deprecated since 6.7.0, use {@link org.apache.struts2.interceptor.ValidationAware} instead.
*/
@Deprecated
public interface ValidationAware extends org.apache.struts2.interceptor.ValidationAware {
static ValidationAware adapt(org.apache.struts2.interceptor.ValidationAware actualValidation) {
if (actualValidation instanceof ValidationAware) {
return (ValidationAware) actualValidation;
}
return actualValidation != null ? new LegacyAdapter(actualValidation) : null;
}
class LegacyAdapter implements ValidationAware {
private final org.apache.struts2.interceptor.ValidationAware adaptee;
private LegacyAdapter(org.apache.struts2.interceptor.ValidationAware adaptee) {
this.adaptee = adaptee;
}
@Override
public void setActionErrors(Collection<String> errorMessages) {
adaptee.setActionErrors(errorMessages);
}
@Override
public Collection<String> getActionErrors() {
return adaptee.getActionErrors();
}
@Override
public void setActionMessages(Collection<String> messages) {
adaptee.setActionMessages(messages);
}
@Override
public Collection<String> getActionMessages() {
return adaptee.getActionMessages();
}
@Override
public void setFieldErrors(Map<String, List<String>> errorMap) {
adaptee.setFieldErrors(errorMap);
}
@Override
public Map<String, List<String>> getFieldErrors() {
return adaptee.getFieldErrors();
}
@Override
public void addActionError(String anErrorMessage) {
adaptee.addActionError(anErrorMessage);
}
@Override
public void addActionMessage(String aMessage) {
adaptee.addActionMessage(aMessage);
}
@Override
public void addFieldError(String fieldName, String errorMessage) {
adaptee.addFieldError(fieldName, errorMessage);
}
@Override
public boolean hasActionErrors() {
return adaptee.hasActionErrors();
}
@Override
public boolean hasActionMessages() {
return adaptee.hasActionMessages();
}
@Override
public boolean hasFieldErrors() {
return adaptee.hasFieldErrors();
}
}
}
@@ -1,26 +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.interceptor;
/**
* @deprecated since 6.7.0, use {@link org.apache.struts2.interceptor.ValidationErrorAware} instead.
*/
@Deprecated
public interface ValidationErrorAware extends org.apache.struts2.interceptor.ValidationErrorAware {
}
@@ -1,26 +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.interceptor;
/**
* @deprecated since 6.7.0, use {@link org.apache.struts2.interceptor.ValidationWorkflowAware} instead.
*/
@Deprecated
public interface ValidationWorkflowAware extends org.apache.struts2.interceptor.ValidationWorkflowAware {
}
@@ -1,149 +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.util;
import com.opensymphony.xwork2.ActionContext;
import java.util.Map;
/**
* @deprecated since 6.7.0, use {@link org.apache.struts2.util.ValueStack} instead.
*/
@Deprecated
public interface ValueStack extends org.apache.struts2.util.ValueStack {
@Override
ActionContext getActionContext();
static ValueStack adapt(org.apache.struts2.util.ValueStack actualStack) {
if (actualStack instanceof ValueStack) {
return (ValueStack) actualStack;
}
return actualStack != null ? new LegacyAdapter(actualStack) : null;
}
class LegacyAdapter implements ValueStack {
private final org.apache.struts2.util.ValueStack adaptee;
private LegacyAdapter(org.apache.struts2.util.ValueStack adaptee) {
this.adaptee = adaptee;
}
@Override
public Map<String, Object> getContext() {
return adaptee.getContext();
}
@Override
public ActionContext getActionContext() {
return ActionContext.adapt(adaptee.getActionContext());
}
@Override
public void setDefaultType(Class defaultType) {
adaptee.setDefaultType(defaultType);
}
@Override
public void setExprOverrides(Map<Object, Object> overrides) {
adaptee.setExprOverrides(overrides);
}
@Override
public Map<Object, Object> getExprOverrides() {
return adaptee.getExprOverrides();
}
@Override
public CompoundRoot getRoot() {
return adaptee.getRoot();
}
@Override
public void setValue(String expr, Object value) {
adaptee.setValue(expr, value);
}
@Override
public void setParameter(String expr, Object value) {
adaptee.setParameter(expr, value);
}
@Override
public void setValue(String expr, Object value, boolean throwExceptionOnFailure) {
adaptee.setValue(expr, value, throwExceptionOnFailure);
}
@Override
public String findString(String expr) {
return adaptee.findString(expr);
}
@Override
public String findString(String expr, boolean throwExceptionOnFailure) {
return adaptee.findString(expr, throwExceptionOnFailure);
}
@Override
public Object findValue(String expr) {
return adaptee.findValue(expr);
}
@Override
public Object findValue(String expr, boolean throwExceptionOnFailure) {
return adaptee.findValue(expr, throwExceptionOnFailure);
}
@Override
public Object findValue(String expr, Class asType) {
return adaptee.findValue(expr, asType);
}
@Override
public Object findValue(String expr, Class asType, boolean throwExceptionOnFailure) {
return adaptee.findValue(expr, asType, throwExceptionOnFailure);
}
@Override
public Object peek() {
return adaptee.peek();
}
@Override
public Object pop() {
return adaptee.pop();
}
@Override
public void push(Object o) {
adaptee.push(o);
}
@Override
public void set(String key, Object o) {
adaptee.set(key, o);
}
@Override
public int size() {
return adaptee.size();
}
}
}
@@ -16,13 +16,12 @@
* specific language governing permissions and limitations
* under the License.
*/
package com.opensymphony.xwork2;
package org.apache.struts2;
import com.opensymphony.xwork2.inject.Inject;
import com.opensymphony.xwork2.util.TextParseUtil;
import org.apache.struts2.inject.Inject;
import org.apache.struts2.util.TextParseUtil;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.apache.struts2.StrutsException;
import java.util.HashSet;
import java.util.LinkedList;
@@ -18,14 +18,14 @@
*/
package org.apache.struts2;
import com.opensymphony.xwork2.conversion.impl.ConversionData;
import com.opensymphony.xwork2.inject.Container;
import jakarta.servlet.ServletContext;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;
import jakarta.servlet.jsp.PageContext;
import org.apache.struts2.conversion.impl.ConversionData;
import org.apache.struts2.dispatcher.HttpParameters;
import org.apache.struts2.dispatcher.mapper.ActionMapping;
import org.apache.struts2.inject.Container;
import org.apache.struts2.util.ValueStack;
import java.io.Serializable;
@@ -65,7 +65,7 @@ public class ActionContext implements Serializable {
private static final String ACTION_NAME = "org.apache.struts2.ActionContext.name";
/**
* Constant for the {@link ValueStack OGNL value stack}.
* Constant for the {@link org.apache.struts2.util.ValueStack OGNL value stack}.
*/
private static final String VALUE_STACK = ValueStack.VALUE_STACK;
@@ -274,7 +274,7 @@ public class ActionContext implements Serializable {
/**
* Gets the Locale of the current action. If no locale was ever specified the platform's
* {@link Locale#getDefault() default locale} is used.
* {@link java.util.Locale#getDefault() default locale} is used.
*
* @return the Locale of the current action.
*/
@@ -542,11 +542,10 @@ public class ActionContext implements Serializable {
}
@Override
public boolean equals(Object obj) {
if (!(obj instanceof ActionContext)) {
public final boolean equals(Object obj) {
if (!(obj instanceof ActionContext other)) {
return false;
}
ActionContext other = (ActionContext) obj;
return Objects.equals(getContextMap(), other.getContextMap());
}
}
@@ -18,7 +18,6 @@
*/
package org.apache.struts2;
import com.opensymphony.xwork2.ActionChainResult;
import org.apache.struts2.interceptor.PreResultListener;
import org.apache.struts2.util.ValueStack;
@@ -18,7 +18,7 @@
*/
package org.apache.struts2;
import com.opensymphony.xwork2.config.entities.ActionConfig;
import org.apache.struts2.config.entities.ActionConfig;
/**
* ActionProxy is an extra layer between XWork and the action so that different proxies are possible.
@@ -16,7 +16,7 @@
* specific language governing permissions and limitations
* under the License.
*/
package com.opensymphony.xwork2;
package org.apache.struts2;
import java.util.Map;
@@ -81,5 +81,5 @@ public interface ActionProxyFactory {
*/
ActionProxy createActionProxy(ActionInvocation actionInvocation, String namespace, String actionName, String methodName,
boolean executeResult, boolean cleanupContext);
}
@@ -18,18 +18,13 @@
*/
package org.apache.struts2;
import com.opensymphony.xwork2.LocaleProvider;
import com.opensymphony.xwork2.LocaleProviderFactory;
import com.opensymphony.xwork2.TextProvider;
import com.opensymphony.xwork2.TextProviderFactory;
import com.opensymphony.xwork2.ValidationAwareSupport;
import com.opensymphony.xwork2.conversion.impl.ConversionData;
import com.opensymphony.xwork2.inject.Container;
import com.opensymphony.xwork2.inject.Inject;
import com.opensymphony.xwork2.util.ValueStack;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.apache.struts2.conversion.impl.ConversionData;
import org.apache.struts2.inject.Container;
import org.apache.struts2.inject.Inject;
import org.apache.struts2.interceptor.ValidationAware;
import org.apache.struts2.util.ValueStack;
import java.io.Serializable;
import java.util.Collection;
@@ -166,7 +161,7 @@ public class ActionSupport implements Action, Validateable, ValidationAware, Tex
String[] vals = (String[]) conversionErrors.get(expr).getValue();
return vals[0];
} else {
var valueStack = ActionContext.getContext().getValueStack();
final ValueStack valueStack = ActionContext.getContext().getValueStack();
final Object val = valueStack.findValue(expr);
return getText(key, List.of(val));
}
@@ -16,7 +16,7 @@
* specific language governing permissions and limitations
* under the License.
*/
package com.opensymphony.xwork2;
package org.apache.struts2;
import java.util.concurrent.Callable;
@@ -16,9 +16,9 @@
* specific language governing permissions and limitations
* under the License.
*/
package com.opensymphony.xwork2;
package org.apache.struts2;
import com.opensymphony.xwork2.util.ValueStack;
import org.apache.struts2.util.ValueStack;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
@@ -65,7 +65,7 @@ public class CompositeTextProvider implements TextProvider {
* @param key The key to lookup in resource bundles.
* @return <tt>true</tt>, if the requested key is found in one of the resource bundles.
*
* @see com.opensymphony.xwork2.TextProvider#hasKey(String)
* @see TextProvider#hasKey(String)
*
*/
@Override
@@ -85,7 +85,7 @@ public class CompositeTextProvider implements TextProvider {
*
* @param key The key to lookup in resource bundles.
* @return The i18n text for the requested key.
* @see com.opensymphony.xwork2.TextProvider#getText(String)
* @see TextProvider#getText(String)
*/
@Override
public String getText(String key) {
@@ -99,7 +99,7 @@ public class CompositeTextProvider implements TextProvider {
* @param key the message key
* @param defaultValue the default value
* @return the first valid message for the key or default value
* @see com.opensymphony.xwork2.TextProvider#getText(String, String)
* @see TextProvider#getText(String, String)
*/
@Override
public String getText(String key, String defaultValue) {
@@ -115,7 +115,7 @@ public class CompositeTextProvider implements TextProvider {
* @param defaultValue the default value
* @param obj object
* @return the first valid message for the key or default value
* @see com.opensymphony.xwork2.TextProvider#getText(String, String, String)
* @see TextProvider#getText(String, String, String)
*/
@Override
public String getText(String key, String defaultValue, final String obj) {
@@ -129,7 +129,7 @@ public class CompositeTextProvider implements TextProvider {
* @param key the message key
* @param args additional arguments
* @return the first valid message for the key
* @see com.opensymphony.xwork2.TextProvider#getText(String, java.util.List)
* @see TextProvider#getText(String, java.util.List)
*/
@Override
public String getText(String key, List<?> args) {
@@ -143,7 +143,7 @@ public class CompositeTextProvider implements TextProvider {
* @param key the message key
* @param args additional arguments
* @return the first valid message for the key or default value
* @see com.opensymphony.xwork2.TextProvider#getText(String, String[])
* @see TextProvider#getText(String, String[])
*/
@Override
public String getText(String key, String[] args) {
@@ -159,7 +159,7 @@ public class CompositeTextProvider implements TextProvider {
* @param defaultValue the default value
* @param args additional arguments
* @return the first valid message for the key or default value
* @see com.opensymphony.xwork2.TextProvider#getText(String, String, java.util.List)
* @see TextProvider#getText(String, String, java.util.List)
*/
@Override
public String getText(String key, String defaultValue, List<?> args) {
@@ -184,7 +184,7 @@ public class CompositeTextProvider implements TextProvider {
* @param defaultValue the default value
* @param args additional arguments
* @return the first valid message for the key or default value
* @see com.opensymphony.xwork2.TextProvider#getText(String, String, String[])
* @see TextProvider#getText(String, String, String[])
*/
@Override
public String getText(String key, String defaultValue, String[] args) {
@@ -210,7 +210,7 @@ public class CompositeTextProvider implements TextProvider {
* @param args additional arguments
* @param stack the value stack
* @return the first valid message for the key or default value
* @see com.opensymphony.xwork2.TextProvider#getText(String, String, java.util.List, com.opensymphony.xwork2.util.ValueStack)
* @see TextProvider#getText(String, String, java.util.List, org.apache.struts2.util.ValueStack)
*/
@Override
public String getText(String key, String defaultValue, List<?> args, ValueStack stack) {
@@ -235,7 +235,7 @@ public class CompositeTextProvider implements TextProvider {
* @param args additional arguments
* @param stack the value stack
* @return the first valid message for the key or default value
* @see com.opensymphony.xwork2.TextProvider#getText(String, String, String[], com.opensymphony.xwork2.util.ValueStack)
* @see TextProvider#getText(String, String, String[], org.apache.struts2.util.ValueStack)
*/
@Override
public String getText(String key, String defaultValue, String[] args, ValueStack stack) {
@@ -273,7 +273,7 @@ public class CompositeTextProvider implements TextProvider {
}
/**
* It will consult each {@link com.opensymphony.xwork2.TextProvider}s and return the first non-null {@link ResourceBundle}.
* It will consult each {@link TextProvider}s and return the first non-null {@link ResourceBundle}.
*
* @return the resource bundle
* @see TextProvider#getTexts()
@@ -16,26 +16,25 @@
* specific language governing permissions and limitations
* under the License.
*/
package com.opensymphony.xwork2;
package org.apache.struts2;
import com.opensymphony.xwork2.config.ConfigurationException;
import com.opensymphony.xwork2.config.entities.ActionConfig;
import com.opensymphony.xwork2.config.entities.InterceptorMapping;
import com.opensymphony.xwork2.config.entities.ResultConfig;
import com.opensymphony.xwork2.inject.Container;
import com.opensymphony.xwork2.inject.Inject;
import com.opensymphony.xwork2.interceptor.ConditionalInterceptor;
import com.opensymphony.xwork2.interceptor.Interceptor;
import com.opensymphony.xwork2.interceptor.PreResultListener;
import com.opensymphony.xwork2.interceptor.WithLazyParams;
import com.opensymphony.xwork2.ognl.OgnlUtil;
import com.opensymphony.xwork2.util.ValueStack;
import com.opensymphony.xwork2.util.ValueStackFactory;
import ognl.MethodFailedException;
import ognl.NoSuchPropertyException;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.apache.struts2.StrutsException;
import org.apache.struts2.config.ConfigurationException;
import org.apache.struts2.config.entities.ActionConfig;
import org.apache.struts2.config.entities.InterceptorMapping;
import org.apache.struts2.config.entities.ResultConfig;
import org.apache.struts2.inject.Container;
import org.apache.struts2.inject.Inject;
import org.apache.struts2.interceptor.ConditionalInterceptor;
import org.apache.struts2.interceptor.Interceptor;
import org.apache.struts2.interceptor.PreResultListener;
import org.apache.struts2.interceptor.WithLazyParams;
import org.apache.struts2.ognl.OgnlUtil;
import org.apache.struts2.util.ValueStack;
import org.apache.struts2.util.ValueStackFactory;
import java.util.ArrayList;
import java.util.Iterator;
@@ -49,7 +48,7 @@ import java.util.concurrent.Callable;
* @author Rainer Hermanns
* @author tmjee
* @version $Date$ $Id$
* @see com.opensymphony.xwork2.DefaultActionProxy
* @see DefaultActionProxy
*/
public class DefaultActionInvocation implements ActionInvocation {
@@ -190,7 +189,7 @@ public class DefaultActionInvocation implements ActionInvocation {
}
/**
* Register a com.opensymphony.xwork2.interceptor.PreResultListener to be notified after the Action is executed and before the
* Register a org.apache.struts2.interceptor.PreResultListener to be notified after the Action is executed and before the
* Result is executed. The ActionInvocation implementation must guarantee that listeners will be called in the order
* in which they are registered. Listener registration and execution does not need to be thread-safe.
*
@@ -258,12 +257,9 @@ public class DefaultActionInvocation implements ActionInvocation {
Interceptor interceptor = interceptorMapping.getInterceptor();
if (interceptor instanceof WithLazyParams) {
interceptor = lazyParamInjector.injectParams(interceptor, interceptorMapping.getParams(), invocationContext);
} else if (interceptor instanceof Interceptor.LegacyAdapter && ((Interceptor.LegacyAdapter) interceptor).getAdaptee() instanceof WithLazyParams) {
org.apache.struts2.interceptor.Interceptor adaptee = ((Interceptor.LegacyAdapter) interceptor).getAdaptee();
lazyParamInjector.injectParams(adaptee, interceptorMapping.getParams(), invocationContext);
}
if (interceptor instanceof ConditionalInterceptor) {
resultCode = executeConditional((ConditionalInterceptor) interceptor);
if (interceptor instanceof ConditionalInterceptor conditionalInterceptor) {
resultCode = executeConditional(conditionalInterceptor);
} else {
LOG.debug("Executing normal interceptor: {}", interceptorMapping.getName());
resultCode = interceptor.intercept(this);
@@ -16,12 +16,12 @@
* specific language governing permissions and limitations
* under the License.
*/
package com.opensymphony.xwork2;
package org.apache.struts2;
import com.opensymphony.xwork2.config.Configuration;
import com.opensymphony.xwork2.config.ConfigurationException;
import com.opensymphony.xwork2.config.entities.ActionConfig;
import com.opensymphony.xwork2.inject.Inject;
import org.apache.struts2.config.Configuration;
import org.apache.struts2.config.ConfigurationException;
import org.apache.struts2.config.entities.ActionConfig;
import org.apache.struts2.inject.Inject;
import org.apache.commons.lang3.StringUtils;
import org.apache.commons.text.StringEscapeUtils;
import org.apache.logging.log4j.LogManager;
@@ -16,15 +16,15 @@
* specific language governing permissions and limitations
* under the License.
*/
package com.opensymphony.xwork2;
package org.apache.struts2;
import com.opensymphony.xwork2.inject.Container;
import com.opensymphony.xwork2.inject.Inject;
import org.apache.struts2.inject.Container;
import org.apache.struts2.inject.Inject;
import java.util.Map;
/**
* Default factory for {@link com.opensymphony.xwork2.ActionProxyFactory}.
* Default factory for {@link org.apache.struts2.ActionProxyFactory}.
*
* @author Jason Carreira
*/
@@ -16,7 +16,7 @@
* specific language governing permissions and limitations
* under the License.
*/
package com.opensymphony.xwork2;
package org.apache.struts2;
import org.apache.commons.lang3.LocaleUtils;
import org.apache.commons.lang3.StringUtils;
@@ -16,7 +16,7 @@
* specific language governing permissions and limitations
* under the License.
*/
package com.opensymphony.xwork2;
package org.apache.struts2;
public class DefaultLocaleProviderFactory implements LocaleProviderFactory {
@@ -16,10 +16,10 @@
* specific language governing permissions and limitations
* under the License.
*/
package com.opensymphony.xwork2;
package org.apache.struts2;
import com.opensymphony.xwork2.inject.Inject;
import com.opensymphony.xwork2.util.ValueStack;
import org.apache.struts2.inject.Inject;
import org.apache.struts2.util.ValueStack;
import java.io.Serializable;
import java.text.MessageFormat;
@@ -16,14 +16,14 @@
* specific language governing permissions and limitations
* under the License.
*/
package com.opensymphony.xwork2;
package org.apache.struts2;
import com.opensymphony.xwork2.config.Configuration;
import com.opensymphony.xwork2.config.ConfigurationException;
import com.opensymphony.xwork2.config.entities.ActionConfig;
import com.opensymphony.xwork2.config.entities.UnknownHandlerConfig;
import com.opensymphony.xwork2.inject.Container;
import com.opensymphony.xwork2.inject.Inject;
import org.apache.struts2.config.Configuration;
import org.apache.struts2.config.ConfigurationException;
import org.apache.struts2.config.entities.ActionConfig;
import org.apache.struts2.config.entities.UnknownHandlerConfig;
import org.apache.struts2.inject.Container;
import org.apache.struts2.inject.Inject;
import java.util.ArrayList;
import java.util.HashMap;
@@ -33,7 +33,7 @@ import java.util.Set;
/**
* Default implementation of UnknownHandlerManager
*
* @see com.opensymphony.xwork2.UnknownHandlerManager
* @see UnknownHandlerManager
*/
public class DefaultUnknownHandlerManager implements UnknownHandlerManager {
@@ -16,7 +16,7 @@
* specific language governing permissions and limitations
* under the License.
*/
package com.opensymphony.xwork2;
package org.apache.struts2;
import java.io.IOException;
import java.io.InputStream;
@@ -16,10 +16,12 @@
* specific language governing permissions and limitations
* under the License.
*/
package com.opensymphony.xwork2;
package org.apache.struts2;
import org.apache.struts2.util.fs.DefaultFileManager;
/**
* Factory that creates FileManager, default to {@link com.opensymphony.xwork2.util.fs.DefaultFileManager}
* Factory that creates FileManager, default to {@link DefaultFileManager}
*/
public interface FileManagerFactory {
@@ -16,7 +16,7 @@
* specific language governing permissions and limitations
* under the License.
*/
package com.opensymphony.xwork2;
package org.apache.struts2;
import org.apache.commons.lang3.LocaleUtils;
import org.apache.commons.lang3.StringUtils;
@@ -16,7 +16,7 @@
* specific language governing permissions and limitations
* under the License.
*/
package com.opensymphony.xwork2;
package org.apache.struts2;
/**
* Allows delegate creation of {@link LocaleProvider} to another implementation provided
@@ -16,9 +16,9 @@
* specific language governing permissions and limitations
* under the License.
*/
package com.opensymphony.xwork2;
package org.apache.struts2;
import com.opensymphony.xwork2.util.ValueStack;
import org.apache.struts2.util.ValueStack;
import java.io.Serializable;
import java.util.Locale;
@@ -16,32 +16,36 @@
* specific language governing permissions and limitations
* under the License.
*/
package com.opensymphony.xwork2;
package org.apache.struts2;
import com.opensymphony.xwork2.config.ConfigurationException;
import com.opensymphony.xwork2.config.entities.ActionConfig;
import com.opensymphony.xwork2.config.entities.InterceptorConfig;
import com.opensymphony.xwork2.config.entities.ResultConfig;
import com.opensymphony.xwork2.conversion.TypeConverter;
import com.opensymphony.xwork2.factory.*;
import com.opensymphony.xwork2.inject.Container;
import com.opensymphony.xwork2.inject.Inject;
import com.opensymphony.xwork2.interceptor.Interceptor;
import com.opensymphony.xwork2.util.ClassLoaderUtil;
import com.opensymphony.xwork2.validator.Validator;
import org.apache.struts2.config.ConfigurationException;
import org.apache.struts2.config.entities.ActionConfig;
import org.apache.struts2.config.entities.InterceptorConfig;
import org.apache.struts2.config.entities.ResultConfig;
import org.apache.struts2.conversion.TypeConverter;
import org.apache.struts2.inject.Container;
import org.apache.struts2.inject.Inject;
import org.apache.struts2.interceptor.Interceptor;
import org.apache.struts2.util.ClassLoaderUtil;
import org.apache.struts2.validator.Validator;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.apache.struts2.StrutsConstants;
import org.apache.struts2.factory.ActionFactory;
import org.apache.struts2.factory.ConverterFactory;
import org.apache.struts2.factory.InterceptorFactory;
import org.apache.struts2.factory.ResultFactory;
import org.apache.struts2.factory.UnknownHandlerFactory;
import org.apache.struts2.factory.ValidatorFactory;
import java.io.Serializable;
import java.util.Map;
/**
* ObjectFactory is responsible for building the core framework objects. Users may register their
* ObjectFactory is responsible for building the core framework objects. Users may register their
* own implementation of the ObjectFactory to control instantiation of these Objects.
*
* <p>
* This default implementation uses the {@link #buildBean(Class,java.util.Map) buildBean}
* This default implementation uses the {@link #buildBean(Class,java.util.Map) buildBean}
* method to create all classes (interceptors, actions, results, etc).
* </p>
*
@@ -135,7 +139,7 @@ public class ObjectFactory implements Serializable {
* @param actionName the name the action configuration is set up with in the configuration
* @param namespace the namespace the action is configured in
* @param config the action configuration found in the config for the actionName / namespace
* @param extraContext a Map of extra context which uses the same keys as the {@link com.opensymphony.xwork2.ActionContext}
* @param extraContext a Map of extra context which uses the same keys as the {@link org.apache.struts2.ActionContext}
* @return instance of the action class to handle a web request
* @throws Exception in case of any error
*/
@@ -147,7 +151,7 @@ public class ObjectFactory implements Serializable {
* Build a generic Java object of the given type.
*
* @param clazz the type of Object to build
* @param extraContext a Map of extra context which uses the same keys as the {@link com.opensymphony.xwork2.ActionContext}
* @param extraContext a Map of extra context which uses the same keys as the {@link org.apache.struts2.ActionContext}
* @return object for the given type
* @throws Exception in case of any error
*/
@@ -171,19 +175,19 @@ public class ObjectFactory implements Serializable {
* Build a generic Java object of the given type.
*
* @param className the type of Object to build
* @param extraContext a Map of extra context which uses the same keys as the {@link com.opensymphony.xwork2.ActionContext}
* @param extraContext a Map of extra context which uses the same keys as the {@link org.apache.struts2.ActionContext}
* @return object for the given type
* @throws Exception in case of any error
*/
public Object buildBean(String className, Map<String, Object> extraContext) throws Exception {
return buildBean(className, extraContext, true);
}
/**
* Build a generic Java object of the given type.
*
* @param className the type of Object to build
* @param extraContext a Map of extra context which uses the same keys as the {@link com.opensymphony.xwork2.ActionContext}
* @param extraContext a Map of extra context which uses the same keys as the {@link org.apache.struts2.ActionContext}
* @param injectInternal true if inject internal beans
* @return object for the given type
* @throws Exception in case of any error
@@ -214,7 +218,7 @@ public class ObjectFactory implements Serializable {
* Build a Result using the type in the ResultConfig and set the parameters in the ResultConfig.
*
* @param resultConfig the ResultConfig found for the action with the result code returned
* @param extraContext a Map of extra context which uses the same keys as the {@link com.opensymphony.xwork2.ActionContext}
* @param extraContext a Map of extra context which uses the same keys as the {@link org.apache.struts2.ActionContext}
*
* @return result
* @throws Exception in case of any error
@@ -228,7 +232,7 @@ public class ObjectFactory implements Serializable {
*
* @param className the type of Validator to build
* @param params property name -&gt; value Map to set onto the Validator instance
* @param extraContext a Map of extra context which uses the same keys as the {@link com.opensymphony.xwork2.ActionContext}
* @param extraContext a Map of extra context which uses the same keys as the {@link org.apache.struts2.ActionContext}
*
* @return validator of the given type
* @throws Exception in case of any error
@@ -241,7 +245,7 @@ public class ObjectFactory implements Serializable {
* Build converter of given type
*
* @param converterClass to instantiate
* @param extraContext a Map of extra context which uses the same keys as the {@link com.opensymphony.xwork2.ActionContext}
* @param extraContext a Map of extra context which uses the same keys as the {@link org.apache.struts2.ActionContext}
* @return instance of converterClass with inject dependencies
* @throws Exception in case of any error
*/
@@ -260,5 +264,5 @@ public class ObjectFactory implements Serializable {
public UnknownHandler buildUnknownHandler(String unknownHandlerName, Map<String, Object> extraContext) throws Exception {
return unknownHandlerFactory.buildUnknownHandler(unknownHandlerName, extraContext);
}
}
@@ -19,11 +19,11 @@
package org.apache.struts2;
/**
* Preparable Actions will have their <code>prepare()</code> method called if the {@link com.opensymphony.xwork2.interceptor.PrepareInterceptor}
* is applied to the ActionConfig.
* Preparable Actions will have their <code>prepare()</code> method called if the
* {@link org.apache.struts2.interceptor.PrepareInterceptor} is applied to the ActionConfig.
*
* @author Jason Carreira
* @see com.opensymphony.xwork2.interceptor.PrepareInterceptor
* @see org.apache.struts2.interceptor.PrepareInterceptor
*/
public interface Preparable {
@@ -16,7 +16,7 @@
* specific language governing permissions and limitations
* under the License.
*/
package com.opensymphony.xwork2;
package org.apache.struts2;
import java.util.ResourceBundle;
@@ -18,8 +18,8 @@
*/
package org.apache.struts2;
import com.opensymphony.xwork2.ActionContext;
import com.opensymphony.xwork2.util.ValueStack;
import org.apache.struts2.ActionContext;
import org.apache.struts2.util.ValueStack;
import jakarta.servlet.ServletContext;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;
@@ -19,6 +19,7 @@
package org.apache.struts2;
import org.apache.struts2.components.date.DateFormatter;
import org.apache.struts2.conversion.impl.XWorkBasicConverter;
import org.apache.struts2.dispatcher.mapper.CompositeActionMapper;
/**
@@ -73,7 +74,7 @@ public final class StrutsConstants {
public static final String STRUTS_URL_RENDERER = "struts.urlRenderer";
/** The com.opensymphony.xwork2.ObjectFactory implementation class */
/** The org.apache.struts2.ObjectFactory implementation class */
public static final String STRUTS_OBJECTFACTORY = "struts.objectFactory";
public static final String STRUTS_OBJECTFACTORY_ACTIONFACTORY = "struts.objectFactory.actionFactory";
public static final String STRUTS_OBJECTFACTORY_RESULTFACTORY = "struts.objectFactory.resultFactory";
@@ -82,13 +83,13 @@ public final class StrutsConstants {
public static final String STRUTS_OBJECTFACTORY_VALIDATORFACTORY = "struts.objectFactory.validatorFactory";
public static final String STRUTS_OBJECTFACTORY_UNKNOWNHANDLERFACTORY = "struts.objectFactory.unknownHandlerFactory";
/** The com.opensymphony.xwork2.util.FileManager implementation class */
/** The org.apache.struts2.util.FileManager implementation class */
public static final String STRUTS_FILE_MANAGER_FACTORY = "struts.fileManagerFactory";
/** The com.opensymphony.xwork2.util.fs.FileManager implementation class */
/** The org.apache.struts2.util.fs.FileManager implementation class */
public static final String STRUTS_FILE_MANAGER = "struts.fileManager";
/** The com.opensymphony.xwork2.util.ObjectTypeDeterminer implementation class */
/** The org.apache.struts2.util.ObjectTypeDeterminer implementation class */
public static final String STRUTS_OBJECTTYPEDETERMINER = "struts.objectTypeDeterminer";
/** The package containing actions that use Rife continuations */
@@ -240,7 +241,7 @@ public final class StrutsConstants {
/** Fallback to empty namespace when request namespace didn't match any in action configuration */
public static final String STRUTS_ACTION_CONFIG_FALLBACK_TO_EMPTY_NAMESPACE = "struts.actionConfig.fallbackToEmptyNamespace";
/** The {@link com.opensymphony.xwork2.LocaleProviderFactory} implementation class */
/** The {@link org.apache.struts2.LocaleProviderFactory} implementation class */
public static final String STRUTS_LOCALE_PROVIDER_FACTORY = "struts.localeProviderFactory";
/** The name of the parameter to create when mapping an id (used by some action mappers) */
@@ -255,25 +256,25 @@ public final class StrutsConstants {
public static final String STRUTS_OGNL_GUARD = "struts.ognlGuard";
/** The com.opensymphony.xwork2.validator.ActionValidatorManager implementation class */
/** The org.apache.struts2.validator.ActionValidatorManager implementation class */
public static final String STRUTS_ACTIONVALIDATORMANAGER = "struts.actionValidatorManager";
/** The {@link com.opensymphony.xwork2.util.ValueStackFactory} implementation class */
/** The {@link org.apache.struts2.util.ValueStackFactory} implementation class */
public static final String STRUTS_VALUESTACKFACTORY = "struts.valueStackFactory";
/** The {@link com.opensymphony.xwork2.util.reflection.ReflectionProvider} implementation class */
/** The {@link org.apache.struts2.util.reflection.ReflectionProvider} implementation class */
public static final String STRUTS_REFLECTIONPROVIDER = "struts.reflectionProvider";
/** The {@link com.opensymphony.xwork2.util.reflection.ReflectionContextFactory} implementation class */
/** The {@link org.apache.struts2.util.reflection.ReflectionContextFactory} implementation class */
public static final String STRUTS_REFLECTIONCONTEXTFACTORY = "struts.reflectionContextFactory";
/** The {@link com.opensymphony.xwork2.util.PatternMatcher} implementation class */
/** The {@link org.apache.struts2.util.PatternMatcher} implementation class */
public static final String STRUTS_PATTERNMATCHER = "struts.patternMatcher";
/** The {@link org.apache.struts2.dispatcher.StaticContentLoader} implementation class */
public static final String STRUTS_STATIC_CONTENT_LOADER = "struts.staticContentLoader";
/** The {@link com.opensymphony.xwork2.UnknownHandlerManager} implementation class */
/** The {@link org.apache.struts2.UnknownHandlerManager} implementation class */
public static final String STRUTS_UNKNOWN_HANDLER_MANAGER = "struts.unknownHandlerManager";
/** Throw RuntimeException when a property is not found, or the evaluation of the expression fails */
@@ -332,7 +333,7 @@ public final class StrutsConstants {
/**
* Specifies the type of cache to use for parsed OGNL expressions. Valid values defined in
* {@link com.opensymphony.xwork2.ognl.OgnlCacheFactory.CacheType}.
* {@link org.apache.struts2.ognl.OgnlCacheFactory.CacheType}.
* <ul>
* <li>For the W-TinyLfu cache, the eviction policy is detailed
* <a href="https://github.com/ben-manes/caffeine/wiki/Efficiency#window-tinylfu">here.</a></li>
@@ -370,7 +371,7 @@ public final class StrutsConstants {
/** The{@link org.apache.struts2.views.util.UrlHelper} implementation class */
public static final String STRUTS_URL_HELPER = "struts.view.urlHelper";
/** {@link com.opensymphony.xwork2.conversion.impl.XWorkBasicConverter} */
/** {@link XWorkBasicConverter} */
public static final String STRUTS_CONVERTER_COLLECTION = "struts.converter.collection";
public static final String STRUTS_CONVERTER_ARRAY = "struts.converter.array";
public static final String STRUTS_CONVERTER_DATE = "struts.converter.date";
@@ -462,7 +463,7 @@ public final class StrutsConstants {
public static final String STRUTS_OGNL_AUTO_GROWTH_COLLECTION_LIMIT = "struts.ognl.autoGrowthCollectionLimit";
/** See {@link com.opensymphony.xwork2.config.impl.AbstractMatcher#appendNamedParameters */
/** See {@link org.apache.struts2.config.impl.AbstractMatcher#appendNamedParameters */
public static final String STRUTS_MATCHER_APPEND_NAMED_PARAMETERS = "struts.matcher.appendNamedParameters";
public static final String STRUTS_CHAINING_COPY_ERRORS = "struts.chaining.copyErrors";
@@ -18,9 +18,9 @@
*/
package org.apache.struts2;
import com.opensymphony.xwork2.util.location.Locatable;
import com.opensymphony.xwork2.util.location.Location;
import com.opensymphony.xwork2.util.location.LocationUtils;
import org.apache.struts2.util.location.Locatable;
import org.apache.struts2.util.location.Location;
import org.apache.struts2.util.location.LocationUtils;
/**
* A generic runtime exception that optionally contains Location information
@@ -31,27 +31,27 @@ public interface StrutsStatics {
/**
* Constant for the HTTP request object.
*/
String HTTP_REQUEST = "com.opensymphony.xwork2.dispatcher.HttpServletRequest";
String HTTP_REQUEST = "org.apache.struts2.dispatcher.HttpServletRequest";
/**
* Constant for the HTTP response object.
*/
String HTTP_RESPONSE = "com.opensymphony.xwork2.dispatcher.HttpServletResponse";
String HTTP_RESPONSE = "org.apache.struts2.dispatcher.HttpServletResponse";
/**
* Constant for an HTTP {@link jakarta.servlet.RequestDispatcher request dispatcher}.
*/
String SERVLET_DISPATCHER = "com.opensymphony.xwork2.dispatcher.ServletDispatcher";
String SERVLET_DISPATCHER = "org.apache.struts2.dispatcher.ServletDispatcher";
/**
* Constant for the {@link jakarta.servlet.ServletContext servlet context} object.
*/
String SERVLET_CONTEXT = "com.opensymphony.xwork2.dispatcher.ServletContext";
String SERVLET_CONTEXT = "org.apache.struts2.dispatcher.ServletContext";
/**
* Constant for the JSP {@link jakarta.servlet.jsp.PageContext page context}.
*/
String PAGE_CONTEXT = "com.opensymphony.xwork2.dispatcher.PageContext";
String PAGE_CONTEXT = "org.apache.struts2.dispatcher.PageContext";
/**
* Set as an attribute in the request to let other parts of the framework know that the invocation is happening inside an
@@ -16,9 +16,9 @@
* specific language governing permissions and limitations
* under the License.
*/
package com.opensymphony.xwork2;
package org.apache.struts2;
import com.opensymphony.xwork2.inject.Inject;
import org.apache.struts2.inject.Inject;
import java.util.ResourceBundle;
@@ -16,9 +16,9 @@
* specific language governing permissions and limitations
* under the License.
*/
package com.opensymphony.xwork2;
package org.apache.struts2;
import com.opensymphony.xwork2.util.ValueStack;
import org.apache.struts2.util.ValueStack;
import java.util.List;
import java.util.ResourceBundle;
@@ -41,7 +41,7 @@ import java.util.ResourceBundle;
* <p>
* When you want to use your own implementation for Struts 2 project you have to define following
* bean and constant in struts.xml:
* &lt;bean class=&quot;org.demo.MyTextProvider&quot; name=&quot;myTextProvider&quot; type=&quot;com.opensymphony.xwork2.TextProvider&quot; /&gt;
* &lt;bean class=&quot;org.demo.MyTextProvider&quot; name=&quot;myTextProvider&quot; type=&quot;org.apache.struts.TextProvider&quot; /&gt;
* &lt;constant name=&quot;struts.textProvider&quot; value=&quot;myTextProvider&quot; /&gt;
* </p>
*
@@ -52,7 +52,7 @@ import java.util.ResourceBundle;
* </p>
*
* <p>
* Take a look on {@link com.opensymphony.xwork2.ActionSupport} for example TextProvider implementation.
* Take a look on {@link org.apache.struts2.ActionSupport} for example TextProvider implementation.
* </p>
* @author Jason Carreira
* @author Rainer Hermanns
@@ -16,7 +16,7 @@
* specific language governing permissions and limitations
* under the License.
*/
package com.opensymphony.xwork2;
package org.apache.struts2;
import java.util.ResourceBundle;
@@ -16,10 +16,10 @@
* specific language governing permissions and limitations
* under the License.
*/
package com.opensymphony.xwork2;
package org.apache.struts2;
import com.opensymphony.xwork2.inject.Inject;
import com.opensymphony.xwork2.util.ValueStack;
import org.apache.struts2.inject.Inject;
import org.apache.struts2.util.ValueStack;
import java.util.*;
@@ -21,7 +21,7 @@ package org.apache.struts2;
/**
* Simple marker interface to indicate an object should <b>not</b> have its properties copied during chaining.
*
* @see com.opensymphony.xwork2.interceptor.ChainingInterceptor
* @see org.apache.struts2.interceptor.ChainingInterceptor
*/
public interface Unchainable {
}
@@ -16,10 +16,9 @@
* specific language governing permissions and limitations
* under the License.
*/
package com.opensymphony.xwork2;
package org.apache.struts2;
import com.opensymphony.xwork2.config.entities.ActionConfig;
import org.apache.struts2.StrutsException;
import org.apache.struts2.config.entities.ActionConfig;
/**
* Handles cases when the result or action is unknown.
@@ -29,21 +28,21 @@ import org.apache.struts2.StrutsException;
* </p>
*/
public interface UnknownHandler {
/**
* Handles the case when an action configuration is unknown. Implementations can return a new ActionConfig
* to be used to process the request.
*
*
* @param namespace The namespace
* @param actionName The action name
* @return An generated ActionConfig, can return <tt>null</tt>
* @throws StrutsException in case of errors
*/
ActionConfig handleUnknownAction(String namespace, String actionName) throws StrutsException;
/**
* Handles the case when a result cannot be found for an action and result code.
*
* Handles the case when a result cannot be found for an action and result code.
*
* @param actionContext The action context
* @param actionName The action name
* @param actionConfig The action config
@@ -52,10 +51,10 @@ public interface UnknownHandler {
* @throws StrutsException in case of errors
*/
Result handleUnknownResult(ActionContext actionContext, String actionName, ActionConfig actionConfig, String resultCode) throws StrutsException;
/**
* Handles the case when an action method cannot be found. This method is responsible both for finding the method and executing it.
*
*
* @since 2.1
* @param action The action object
* @param methodName The method name to call
@@ -16,16 +16,16 @@
* specific language governing permissions and limitations
* under the License.
*/
package com.opensymphony.xwork2;
package org.apache.struts2;
import com.opensymphony.xwork2.config.entities.ActionConfig;
import org.apache.struts2.config.entities.ActionConfig;
import java.util.List;
/**
* An unknown handler manager contains a list of UnknownHandler and iterates on them by order
*
* @see com.opensymphony.xwork2.DefaultUnknownHandlerManager
* @see org.apache.struts2.DefaultUnknownHandlerManager
*/
public interface UnknownHandlerManager {
@@ -22,8 +22,8 @@ package org.apache.struts2;
* Provides an interface in which a call for a validation check can be done.
*
* @author Jason Carreira
* @see com.opensymphony.xwork2.ActionSupport
* @see com.opensymphony.xwork2.interceptor.DefaultWorkflowInterceptor
* @see ActionSupport
* @see org.apache.struts2.interceptor.DefaultWorkflowInterceptor
*/
public interface Validateable {
@@ -16,9 +16,9 @@
* specific language governing permissions and limitations
* under the License.
*/
package com.opensymphony.xwork2;
package org.apache.struts2;
import com.opensymphony.xwork2.interceptor.ValidationAware;
import org.apache.struts2.interceptor.ValidationAware;
import java.io.Serializable;
import java.util.ArrayList;
@@ -16,20 +16,20 @@
* specific language governing permissions and limitations
* under the License.
*/
package com.opensymphony.xwork2;
package org.apache.struts2;
import com.opensymphony.xwork2.config.Configuration;
import com.opensymphony.xwork2.config.ConfigurationException;
import com.opensymphony.xwork2.config.ConfigurationManager;
import com.opensymphony.xwork2.config.ConfigurationProvider;
import com.opensymphony.xwork2.inject.Container;
import com.opensymphony.xwork2.inject.ContainerBuilder;
import com.opensymphony.xwork2.inject.Context;
import com.opensymphony.xwork2.inject.Factory;
import com.opensymphony.xwork2.inject.Scope;
import com.opensymphony.xwork2.test.StubConfigurationProvider;
import com.opensymphony.xwork2.util.XWorkTestCaseHelper;
import com.opensymphony.xwork2.util.location.LocatableProperties;
import org.apache.struts2.config.Configuration;
import org.apache.struts2.config.ConfigurationException;
import org.apache.struts2.config.ConfigurationManager;
import org.apache.struts2.config.ConfigurationProvider;
import org.apache.struts2.inject.Container;
import org.apache.struts2.inject.ContainerBuilder;
import org.apache.struts2.inject.Context;
import org.apache.struts2.inject.Factory;
import org.apache.struts2.inject.Scope;
import org.apache.struts2.test.StubConfigurationProvider;
import org.apache.struts2.util.XWorkTestCaseHelper;
import org.apache.struts2.util.location.LocatableProperties;
import org.junit.After;
import org.junit.Before;
@@ -16,20 +16,20 @@
* specific language governing permissions and limitations
* under the License.
*/
package com.opensymphony.xwork2;
package org.apache.struts2;
import com.opensymphony.xwork2.config.Configuration;
import com.opensymphony.xwork2.config.ConfigurationException;
import com.opensymphony.xwork2.config.ConfigurationManager;
import com.opensymphony.xwork2.config.ConfigurationProvider;
import com.opensymphony.xwork2.inject.Container;
import com.opensymphony.xwork2.inject.ContainerBuilder;
import com.opensymphony.xwork2.inject.Context;
import com.opensymphony.xwork2.inject.Factory;
import com.opensymphony.xwork2.inject.Scope;
import com.opensymphony.xwork2.test.StubConfigurationProvider;
import com.opensymphony.xwork2.util.XWorkTestCaseHelper;
import com.opensymphony.xwork2.util.location.LocatableProperties;
import org.apache.struts2.config.Configuration;
import org.apache.struts2.config.ConfigurationException;
import org.apache.struts2.config.ConfigurationManager;
import org.apache.struts2.config.ConfigurationProvider;
import org.apache.struts2.inject.Container;
import org.apache.struts2.inject.ContainerBuilder;
import org.apache.struts2.inject.Context;
import org.apache.struts2.inject.Factory;
import org.apache.struts2.inject.Scope;
import org.apache.struts2.test.StubConfigurationProvider;
import org.apache.struts2.util.XWorkTestCaseHelper;
import org.apache.struts2.util.location.LocatableProperties;
import junit.framework.TestCase;
import org.apache.commons.lang3.ClassUtils;
@@ -18,7 +18,7 @@
*/
package org.apache.struts2.action;
import com.opensymphony.xwork2.ActionSupport;
import org.apache.struts2.ActionSupport;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;
@@ -18,13 +18,13 @@
*/
package org.apache.struts2.components;
import com.opensymphony.xwork2.ActionContext;
import com.opensymphony.xwork2.ActionInvocation;
import com.opensymphony.xwork2.ActionProxy;
import com.opensymphony.xwork2.ActionProxyFactory;
import com.opensymphony.xwork2.inject.Inject;
import com.opensymphony.xwork2.util.ValueStack;
import com.opensymphony.xwork2.util.ValueStackFactory;
import org.apache.struts2.ActionContext;
import org.apache.struts2.ActionInvocation;
import org.apache.struts2.ActionProxy;
import org.apache.struts2.ActionProxyFactory;
import org.apache.struts2.inject.Inject;
import org.apache.struts2.util.ValueStack;
import org.apache.struts2.util.ValueStackFactory;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;
import jakarta.servlet.jsp.PageContext;
@@ -18,7 +18,7 @@
*/
package org.apache.struts2.components;
import com.opensymphony.xwork2.util.ValueStack;
import org.apache.struts2.util.ValueStack;
import org.apache.commons.lang3.StringUtils;
import org.apache.struts2.views.annotations.StrutsTag;
import org.apache.struts2.views.annotations.StrutsTagAttribute;
@@ -18,7 +18,7 @@
*/
package org.apache.struts2.components;
import com.opensymphony.xwork2.util.ValueStack;
import org.apache.struts2.util.ValueStack;
import org.apache.commons.lang3.StringUtils;
import org.apache.struts2.views.annotations.StrutsTag;
import org.apache.struts2.views.annotations.StrutsTagAttribute;
@@ -18,8 +18,8 @@
*/
package org.apache.struts2.components;
import com.opensymphony.xwork2.inject.Inject;
import com.opensymphony.xwork2.util.ValueStack;
import org.apache.struts2.inject.Inject;
import org.apache.struts2.util.ValueStack;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;
import org.apache.commons.lang3.StringUtils;
@@ -18,7 +18,7 @@
*/
package org.apache.struts2.components;
import com.opensymphony.xwork2.util.ValueStack;
import org.apache.struts2.util.ValueStack;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.apache.struts2.components.Param.UnnamedParametric;
@@ -18,12 +18,12 @@
*/
package org.apache.struts2.components;
import com.opensymphony.xwork2.ObjectFactory;
import com.opensymphony.xwork2.inject.Inject;
import com.opensymphony.xwork2.util.ValueStack;
import org.apache.struts2.ObjectFactory;
import org.apache.struts2.inject.Inject;
import org.apache.struts2.util.ValueStack;
import org.apache.logging.log4j.Logger;
import org.apache.logging.log4j.LogManager;
import com.opensymphony.xwork2.util.reflection.ReflectionProvider;
import org.apache.struts2.util.reflection.ReflectionProvider;
import org.apache.struts2.views.annotations.StrutsTag;
import org.apache.struts2.views.annotations.StrutsTagAttribute;
@@ -18,8 +18,8 @@
*/
package org.apache.struts2.components;
import com.opensymphony.xwork2.inject.Inject;
import com.opensymphony.xwork2.util.ValueStack;
import org.apache.struts2.inject.Inject;
import org.apache.struts2.util.ValueStack;
import org.apache.struts2.StrutsConstants;
import org.apache.struts2.views.annotations.StrutsTag;
import org.apache.struts2.views.annotations.StrutsTagAttribute;
@@ -23,7 +23,7 @@ import jakarta.servlet.http.HttpServletResponse;
import org.apache.struts2.views.annotations.StrutsTag;
import com.opensymphony.xwork2.util.ValueStack;
import org.apache.struts2.util.ValueStack;
/**
* <!-- START SNIPPET: javadoc -->
@@ -18,7 +18,7 @@
*/
package org.apache.struts2.components;
import com.opensymphony.xwork2.util.ValueStack;
import org.apache.struts2.util.ValueStack;
import org.apache.logging.log4j.Logger;
import org.apache.logging.log4j.LogManager;
import org.apache.struts2.views.annotations.StrutsTagAttribute;
@@ -18,7 +18,7 @@
*/
package org.apache.struts2.components;
import com.opensymphony.xwork2.util.ValueStack;
import org.apache.struts2.util.ValueStack;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;
import org.apache.struts2.util.MakeIterator;
@@ -18,12 +18,12 @@
*/
package org.apache.struts2.components;
import com.opensymphony.xwork2.ActionContext;
import com.opensymphony.xwork2.ActionInvocation;
import com.opensymphony.xwork2.inject.Inject;
import com.opensymphony.xwork2.security.NotExcludedAcceptedPatternsChecker;
import com.opensymphony.xwork2.util.TextParseUtil;
import com.opensymphony.xwork2.util.ValueStack;
import org.apache.struts2.ActionContext;
import org.apache.struts2.ActionInvocation;
import org.apache.struts2.inject.Inject;
import org.apache.struts2.security.NotExcludedAcceptedPatternsChecker;
import org.apache.struts2.util.TextParseUtil;
import org.apache.struts2.util.ValueStack;
import org.apache.commons.lang3.BooleanUtils;
import org.apache.commons.lang3.StringUtils;
import org.apache.commons.lang3.reflect.MethodUtils;
@@ -18,7 +18,7 @@
*/
package org.apache.struts2.components;
import com.opensymphony.xwork2.util.ValueStack;
import org.apache.struts2.util.ValueStack;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;
@@ -18,7 +18,7 @@
*/
package org.apache.struts2.components;
import com.opensymphony.xwork2.util.ValueStack;
import org.apache.struts2.util.ValueStack;
import org.apache.commons.lang3.StringUtils;
import org.apache.struts2.views.annotations.StrutsTagAttribute;
@@ -27,7 +27,7 @@ import org.apache.struts2.views.annotations.StrutsTagAttribute;
*/
public abstract class ContextBean extends Component {
protected String var;
public ContextBean(ValueStack stack) {
super(stack);
}
@@ -37,14 +37,14 @@ public abstract class ContextBean extends Component {
stack.getContext().put(var, value);
}
}
@StrutsTagAttribute(description="Name used to reference the value pushed into the Value Stack (scope: action).")
public void setVar(String var) {
if (var != null) {
this.var = findString(var);
}
}
protected String getVar() {
return this.var;
}
@@ -18,9 +18,9 @@
*/
package org.apache.struts2.components;
import com.opensymphony.xwork2.TextProvider;
import com.opensymphony.xwork2.inject.Inject;
import com.opensymphony.xwork2.util.ValueStack;
import org.apache.struts2.TextProvider;
import org.apache.struts2.inject.Inject;
import org.apache.struts2.util.ValueStack;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.apache.struts2.components.date.DateFormatter;
@@ -18,7 +18,7 @@
*/
package org.apache.struts2.components;
import com.opensymphony.xwork2.util.ValueStack;
import org.apache.struts2.util.ValueStack;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;
import org.apache.struts2.views.annotations.StrutsTag;
@@ -18,9 +18,9 @@
*/
package org.apache.struts2.components;
import com.opensymphony.xwork2.inject.Inject;
import com.opensymphony.xwork2.util.ValueStack;
import com.opensymphony.xwork2.util.reflection.ReflectionProvider;
import org.apache.struts2.inject.Inject;
import org.apache.struts2.util.ValueStack;
import org.apache.struts2.util.reflection.ReflectionProvider;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;
import org.apache.struts2.StrutsException;
@@ -18,7 +18,7 @@
*/
package org.apache.struts2.components;
import com.opensymphony.xwork2.util.ValueStack;
import org.apache.struts2.util.ValueStack;
import org.apache.struts2.views.annotations.StrutsTagAttribute;
import jakarta.servlet.http.HttpServletRequest;
@@ -18,7 +18,7 @@
*/
package org.apache.struts2.components;
import com.opensymphony.xwork2.util.ValueStack;
import org.apache.struts2.util.ValueStack;
import org.apache.commons.lang3.StringUtils;
import org.apache.struts2.views.annotations.StrutsTag;
@@ -18,7 +18,7 @@
*/
package org.apache.struts2.components;
import com.opensymphony.xwork2.util.ValueStack;
import org.apache.struts2.util.ValueStack;
import org.apache.struts2.views.annotations.StrutsTag;
import java.io.Writer;
@@ -18,7 +18,7 @@
*/
package org.apache.struts2.components;
import com.opensymphony.xwork2.util.ValueStack;
import org.apache.struts2.util.ValueStack;
import org.apache.struts2.views.annotations.StrutsTag;
import org.apache.struts2.views.annotations.StrutsTagAttribute;
@@ -18,7 +18,7 @@
*/
package org.apache.struts2.components;
import com.opensymphony.xwork2.util.ValueStack;
import org.apache.struts2.util.ValueStack;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;
import org.apache.struts2.components.Param.UnnamedParametric;
@@ -18,7 +18,7 @@
*/
package org.apache.struts2.components;
import com.opensymphony.xwork2.util.ValueStack;
import org.apache.struts2.util.ValueStack;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;
import org.apache.logging.log4j.LogManager;
@@ -18,21 +18,21 @@
*/
package org.apache.struts2.components;
import com.opensymphony.xwork2.ObjectFactory;
import com.opensymphony.xwork2.config.Configuration;
import com.opensymphony.xwork2.config.RuntimeConfiguration;
import com.opensymphony.xwork2.config.entities.ActionConfig;
import com.opensymphony.xwork2.config.entities.InterceptorMapping;
import com.opensymphony.xwork2.inject.Inject;
import com.opensymphony.xwork2.interceptor.MethodFilterInterceptorUtil;
import com.opensymphony.xwork2.util.ValueStack;
import com.opensymphony.xwork2.validator.ActionValidatorManager;
import com.opensymphony.xwork2.validator.FieldValidator;
import com.opensymphony.xwork2.validator.ValidationException;
import com.opensymphony.xwork2.validator.ValidationInterceptor;
import com.opensymphony.xwork2.validator.Validator;
import com.opensymphony.xwork2.validator.ValidatorContext;
import com.opensymphony.xwork2.validator.validators.VisitorFieldValidator;
import org.apache.struts2.ObjectFactory;
import org.apache.struts2.config.Configuration;
import org.apache.struts2.config.RuntimeConfiguration;
import org.apache.struts2.config.entities.ActionConfig;
import org.apache.struts2.config.entities.InterceptorMapping;
import org.apache.struts2.inject.Inject;
import org.apache.struts2.interceptor.MethodFilterInterceptorUtil;
import org.apache.struts2.util.ValueStack;
import org.apache.struts2.validator.ActionValidatorManager;
import org.apache.struts2.validator.FieldValidator;
import org.apache.struts2.validator.ValidationException;
import org.apache.struts2.validator.ValidationInterceptor;
import org.apache.struts2.validator.Validator;
import org.apache.struts2.validator.ValidatorContext;
import org.apache.struts2.validator.validators.VisitorFieldValidator;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;
import org.apache.commons.lang3.StringUtils;
@@ -18,7 +18,7 @@
*/
package org.apache.struts2.components;
import com.opensymphony.xwork2.util.ValueStack;
import org.apache.struts2.util.ValueStack;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;
import org.apache.struts2.dispatcher.mapper.ActionMapping;
@@ -24,7 +24,7 @@ import jakarta.servlet.http.HttpServletResponse;
import org.apache.struts2.views.annotations.StrutsTag;
import org.apache.struts2.util.ContainUtil;
import com.opensymphony.xwork2.util.ValueStack;
import org.apache.struts2.util.ValueStack;
/**
* <!-- START SNIPPET: javadoc -->

Some files were not shown because too many files have changed in this diff Show More