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
@@ -18,9 +18,9 @@
*/
package org.demo.rest.example;
import com.opensymphony.xwork2.ModelDriven;
import com.opensymphony.xwork2.Validateable;
import com.opensymphony.xwork2.ValidationAwareSupport;
import org.apache.struts2.ModelDriven;
import org.apache.struts2.Validateable;
import org.apache.struts2.ValidationAwareSupport;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.apache.struts2.convention.annotation.Result;
@@ -26,7 +26,6 @@
</Console>
</Appenders>
<Loggers>
<Logger name="com.opensymphony.xwork2" level="info"/>
<Logger name="org.apache.struts2" level="info"/>
<Logger name="org.demo.rest" level="debug"/>
<Root level="warn">
-1
View File
@@ -248,7 +248,6 @@
<port>8090</port>
</httpConnector>
<scan>10</scan>
<webAppSourceDirectory>${basedir}/src/main/webapp/</webAppSourceDirectory>
<webApp>
<extraClasspath>
${project.build.directory}/extraclasspath/struts2-velocity-tools-view-jakarta.jar,
@@ -20,7 +20,7 @@
*/
package org.apache.struts2.showcase;
import com.opensymphony.xwork2.ActionSupport;
import org.apache.struts2.ActionSupport;
import java.text.DateFormat;
import java.util.Calendar;
@@ -20,7 +20,7 @@
*/
package org.apache.struts2.showcase;
import com.opensymphony.xwork2.ActionSupport;
import org.apache.struts2.ActionSupport;
import org.apache.struts2.interceptor.parameter.StrutsParameter;
import org.apache.struts2.showcase.ajax.tree.Category;
@@ -20,7 +20,7 @@
*/
package org.apache.struts2.showcase;
import com.opensymphony.xwork2.ActionSupport;
import org.apache.struts2.ActionSupport;
import org.apache.struts2.interceptor.parameter.StrutsParameter;
import java.util.ArrayList;
@@ -20,7 +20,7 @@
*/
package org.apache.struts2.showcase;
import com.opensymphony.xwork2.ActionSupport;
import org.apache.struts2.ActionSupport;
import org.apache.struts2.interceptor.parameter.StrutsParameter;
/**
@@ -20,7 +20,7 @@
*/
package org.apache.struts2.showcase;
import com.opensymphony.xwork2.ActionSupport;
import org.apache.struts2.ActionSupport;
import org.apache.struts2.interceptor.parameter.StrutsParameter;
import java.util.ArrayList;
@@ -20,7 +20,7 @@
*/
package org.apache.struts2.showcase;
import com.opensymphony.xwork2.ActionSupport;
import org.apache.struts2.ActionSupport;
import org.apache.struts2.interceptor.parameter.StrutsParameter;
import org.apache.struts2.showcase.ajax.tree.Category;
@@ -20,7 +20,7 @@
*/
package org.apache.struts2.showcase;
import com.opensymphony.xwork2.ActionSupport;
import org.apache.struts2.ActionSupport;
import org.apache.struts2.showcase.ajax.tree.Category;
// START SNIPPET: treeExampleDynamicJavaShow
@@ -20,9 +20,9 @@
*/
package org.apache.struts2.showcase;
import com.opensymphony.xwork2.ActionSupport;
import com.opensymphony.xwork2.Validateable;
import com.opensymphony.xwork2.util.ValueStack;
import org.apache.struts2.ActionSupport;
import org.apache.struts2.Validateable;
import org.apache.struts2.util.ValueStack;
import org.apache.struts2.ServletActionContext;
import org.apache.struts2.interceptor.parameter.StrutsParameter;
@@ -18,7 +18,7 @@
*/
package org.apache.struts2.showcase.action;
import com.opensymphony.xwork2.ActionSupport;
import org.apache.struts2.ActionSupport;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.apache.struts2.interceptor.parameter.StrutsParameter;
@@ -18,7 +18,7 @@
*/
package org.apache.struts2.showcase.action;
import com.opensymphony.xwork2.Preparable;
import org.apache.struts2.Preparable;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.apache.struts2.interceptor.parameter.StrutsParameter;
@@ -18,7 +18,7 @@
*/
package org.apache.struts2.showcase.action;
import com.opensymphony.xwork2.ActionSupport;
import org.apache.struts2.ActionSupport;
import java.util.Arrays;
import java.util.Date;
@@ -18,8 +18,8 @@
*/
package org.apache.struts2.showcase.action;
import com.opensymphony.xwork2.Action;
import com.opensymphony.xwork2.interceptor.annotations.After;
import org.apache.struts2.Action;
import org.apache.struts2.interceptor.annotations.After;
import org.apache.struts2.ServletActionContext;
import org.apache.struts2.interceptor.parameter.StrutsParameter;
@@ -18,7 +18,7 @@
*/
package org.apache.struts2.showcase.action;
import com.opensymphony.xwork2.ActionSupport;
import org.apache.struts2.ActionSupport;
import org.apache.struts2.interceptor.parameter.StrutsParameter;
import org.apache.struts2.showcase.model.MyDto;
@@ -18,7 +18,7 @@
*/
package org.apache.struts2.showcase.action;
import com.opensymphony.xwork2.Preparable;
import org.apache.struts2.Preparable;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.apache.struts2.interceptor.parameter.StrutsParameter;
@@ -18,7 +18,7 @@
*/
package org.apache.struts2.showcase.actionchaining;
import com.opensymphony.xwork2.ActionSupport;
import org.apache.struts2.ActionSupport;
import org.apache.struts2.interceptor.parameter.StrutsParameter;
public class ActionChain1 extends ActionSupport {
@@ -18,7 +18,7 @@
*/
package org.apache.struts2.showcase.actionchaining;
import com.opensymphony.xwork2.ActionSupport;
import org.apache.struts2.ActionSupport;
import org.apache.struts2.interceptor.parameter.StrutsParameter;
public class ActionChain2 extends ActionSupport {
@@ -18,7 +18,7 @@
*/
package org.apache.struts2.showcase.actionchaining;
import com.opensymphony.xwork2.ActionSupport;
import org.apache.struts2.ActionSupport;
import org.apache.struts2.interceptor.parameter.StrutsParameter;
public class ActionChain3 extends ActionSupport {
@@ -20,7 +20,7 @@
*/
package org.apache.struts2.showcase.ajax;
import com.opensymphony.xwork2.Action;
import org.apache.struts2.Action;
import org.apache.struts2.interceptor.parameter.StrutsParameter;
import java.io.Serializable;
@@ -20,7 +20,7 @@
*/
package org.apache.struts2.showcase.ajax;
import com.opensymphony.xwork2.ActionSupport;
import org.apache.struts2.ActionSupport;
import org.apache.struts2.interceptor.parameter.StrutsParameter;
import java.util.ArrayList;
@@ -20,7 +20,7 @@
*/
package org.apache.struts2.showcase.ajax;
import com.opensymphony.xwork2.ActionSupport;
import org.apache.struts2.ActionSupport;
import org.apache.struts2.interceptor.parameter.StrutsParameter;
import java.text.SimpleDateFormat;
@@ -20,7 +20,7 @@
*/
package org.apache.struts2.showcase.ajax;
import com.opensymphony.xwork2.ActionSupport;
import org.apache.struts2.ActionSupport;
import org.apache.struts2.interceptor.parameter.StrutsParameter;
public class Example5Action extends ActionSupport {
@@ -20,7 +20,7 @@
*/
package org.apache.struts2.showcase.ajax.tree;
import com.opensymphony.xwork2.ActionSupport;
import org.apache.struts2.ActionSupport;
import org.apache.struts2.interceptor.parameter.StrutsParameter;
/**
@@ -18,7 +18,7 @@
*/
package org.apache.struts2.showcase.async;
import com.opensymphony.xwork2.ActionSupport;
import org.apache.struts2.ActionSupport;
import org.apache.struts2.interceptor.parameter.StrutsParameter;
import java.util.ArrayList;
@@ -21,10 +21,10 @@
package org.apache.struts2.showcase.chat;
import com.opensymphony.xwork2.Action;
import com.opensymphony.xwork2.ActionContext;
import com.opensymphony.xwork2.ActionInvocation;
import com.opensymphony.xwork2.interceptor.AbstractInterceptor;
import org.apache.struts2.Action;
import org.apache.struts2.ActionContext;
import org.apache.struts2.ActionInvocation;
import org.apache.struts2.interceptor.AbstractInterceptor;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
@@ -20,10 +20,10 @@
*/
package org.apache.struts2.showcase.chat;
import com.opensymphony.xwork2.Action;
import com.opensymphony.xwork2.ActionContext;
import com.opensymphony.xwork2.ActionInvocation;
import com.opensymphony.xwork2.interceptor.AbstractInterceptor;
import org.apache.struts2.Action;
import org.apache.struts2.ActionContext;
import org.apache.struts2.ActionInvocation;
import org.apache.struts2.interceptor.AbstractInterceptor;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
@@ -20,7 +20,7 @@
*/
package org.apache.struts2.showcase.chat;
import com.opensymphony.xwork2.ActionSupport;
import org.apache.struts2.ActionSupport;
import org.apache.struts2.action.SessionAware;
import org.apache.struts2.interceptor.parameter.StrutsParameter;
@@ -20,7 +20,7 @@
*/
package org.apache.struts2.showcase.chat;
import com.opensymphony.xwork2.ActionSupport;
import org.apache.struts2.ActionSupport;
import java.util.Map;
@@ -20,7 +20,7 @@
*/
package org.apache.struts2.showcase.chat;
import com.opensymphony.xwork2.ActionSupport;
import org.apache.struts2.ActionSupport;
import org.apache.struts2.interceptor.parameter.StrutsParameter;
public class CrudRoomAction extends ActionSupport {
@@ -20,8 +20,8 @@
*/
package org.apache.struts2.showcase.chat;
import com.opensymphony.xwork2.conversion.impl.XWorkConverter;
import com.opensymphony.xwork2.inject.Inject;
import org.apache.struts2.conversion.impl.XWorkConverter;
import org.apache.struts2.inject.Inject;
import org.apache.logging.log4j.Logger;
import org.apache.logging.log4j.LogManager;
import org.apache.struts2.util.StrutsTypeConverter;
@@ -20,7 +20,7 @@
*/
package org.apache.struts2.showcase.chat;
import com.opensymphony.xwork2.ActionSupport;
import org.apache.struts2.ActionSupport;
import org.apache.struts2.action.SessionAware;
import org.apache.struts2.interceptor.parameter.StrutsParameter;
@@ -20,7 +20,7 @@
*/
package org.apache.struts2.showcase.chat;
import com.opensymphony.xwork2.ActionSupport;
import org.apache.struts2.ActionSupport;
import org.apache.struts2.action.SessionAware;
import org.apache.struts2.interceptor.parameter.StrutsParameter;
@@ -20,7 +20,7 @@
*/
package org.apache.struts2.showcase.chat;
import com.opensymphony.xwork2.ActionSupport;
import org.apache.struts2.ActionSupport;
import org.apache.struts2.interceptor.parameter.StrutsParameter;
import java.util.ArrayList;
@@ -20,7 +20,7 @@
*/
package org.apache.struts2.showcase.chat;
import com.opensymphony.xwork2.ActionSupport;
import org.apache.struts2.ActionSupport;
import java.util.ArrayList;
import java.util.List;
@@ -20,7 +20,7 @@
*/
package org.apache.struts2.showcase.chat;
import com.opensymphony.xwork2.ActionSupport;
import org.apache.struts2.ActionSupport;
import org.apache.struts2.action.SessionAware;
import org.apache.struts2.interceptor.parameter.StrutsParameter;
@@ -20,7 +20,7 @@
*/
package org.apache.struts2.showcase.chat;
import com.opensymphony.xwork2.ActionSupport;
import org.apache.struts2.ActionSupport;
import java.util.ArrayList;
import java.util.List;
@@ -20,7 +20,7 @@
*/
package org.apache.struts2.showcase.chat;
import com.opensymphony.xwork2.ActionSupport;
import org.apache.struts2.ActionSupport;
import org.apache.struts2.interceptor.parameter.StrutsParameter;
import java.util.ArrayList;
@@ -20,7 +20,7 @@
*/
package org.apache.struts2.showcase.conversion;
import com.opensymphony.xwork2.ActionSupport;
import org.apache.struts2.ActionSupport;
import org.apache.struts2.interceptor.parameter.StrutsParameter;
import java.util.LinkedHashSet;
@@ -20,7 +20,7 @@
*/
package org.apache.struts2.showcase.conversion;
import com.opensymphony.xwork2.ActionSupport;
import org.apache.struts2.ActionSupport;
import org.apache.struts2.interceptor.parameter.StrutsParameter;
import java.util.Arrays;
@@ -20,7 +20,7 @@
*/
package org.apache.struts2.showcase.conversion;
import com.opensymphony.xwork2.ActionSupport;
import org.apache.struts2.ActionSupport;
import org.apache.struts2.interceptor.parameter.StrutsParameter;
import java.util.List;
@@ -20,7 +20,7 @@
*/
package org.apache.struts2.showcase.filedownload;
import com.opensymphony.xwork2.Action;
import org.apache.struts2.Action;
import org.apache.struts2.ServletActionContext;
import org.apache.struts2.interceptor.parameter.StrutsParameter;
@@ -20,7 +20,7 @@
*/
package org.apache.struts2.showcase.fileupload;
import com.opensymphony.xwork2.ActionSupport;
import org.apache.struts2.ActionSupport;
import org.apache.struts2.action.UploadedFilesAware;
import org.apache.struts2.dispatcher.multipart.UploadedFile;
import org.apache.struts2.interceptor.parameter.StrutsParameter;
@@ -21,7 +21,7 @@
// START SNIPPET: entire-file
package org.apache.struts2.showcase.fileupload;
import com.opensymphony.xwork2.ActionSupport;
import org.apache.struts2.ActionSupport;
import org.apache.struts2.action.UploadedFilesAware;
import org.apache.struts2.dispatcher.multipart.UploadedFile;
@@ -21,7 +21,7 @@
// START SNIPPET: entire-file
package org.apache.struts2.showcase.fileupload;
import com.opensymphony.xwork2.ActionSupport;
import org.apache.struts2.ActionSupport;
import org.apache.struts2.action.UploadedFilesAware;
import org.apache.struts2.dispatcher.multipart.UploadedFile;
@@ -20,7 +20,7 @@
*/
package org.apache.struts2.showcase.freemarker;
import com.opensymphony.xwork2.util.ValueStack;
import org.apache.struts2.util.ValueStack;
import org.apache.struts2.views.freemarker.FreemarkerManager;
import org.apache.struts2.views.freemarker.ScopesHashModel;
@@ -20,8 +20,8 @@
*/
package org.apache.struts2.showcase.freemarker;
import com.opensymphony.xwork2.ActionSupport;
import com.opensymphony.xwork2.Preparable;
import org.apache.struts2.ActionSupport;
import org.apache.struts2.Preparable;
import org.apache.struts2.interceptor.parameter.StrutsParameter;
import java.text.DateFormatSymbols;
@@ -20,7 +20,7 @@
*/
package org.apache.struts2.showcase.hangman;
import com.opensymphony.xwork2.ActionSupport;
import org.apache.struts2.ActionSupport;
import java.util.Map;
@@ -20,7 +20,7 @@
*/
package org.apache.struts2.showcase.hangman;
import com.opensymphony.xwork2.ActionSupport;
import org.apache.struts2.ActionSupport;
import org.apache.struts2.action.SessionAware;
import org.apache.struts2.interceptor.parameter.StrutsParameter;
@@ -20,7 +20,7 @@
*/
package org.apache.struts2.showcase.hangman;
import com.opensymphony.xwork2.ActionSupport;
import org.apache.struts2.ActionSupport;
import java.util.Map;
@@ -20,8 +20,8 @@
*/
package org.apache.struts2.showcase.modelDriven;
import com.opensymphony.xwork2.ActionSupport;
import com.opensymphony.xwork2.ModelDriven;
import org.apache.struts2.ActionSupport;
import org.apache.struts2.ModelDriven;
import org.apache.struts2.showcase.modelDriven.model.Gangster;
/**
@@ -20,7 +20,7 @@
*/
package org.apache.struts2.showcase.person;
import com.opensymphony.xwork2.ActionSupport;
import org.apache.struts2.ActionSupport;
import org.apache.struts2.convention.annotation.Result;
import org.apache.struts2.convention.annotation.Results;
import org.apache.struts2.interceptor.parameter.StrutsParameter;
@@ -20,7 +20,7 @@
*/
package org.apache.struts2.showcase.person;
import com.opensymphony.xwork2.ActionSupport;
import org.apache.struts2.ActionSupport;
import org.apache.struts2.convention.annotation.Result;
import org.springframework.beans.factory.annotation.Autowired;
@@ -20,7 +20,7 @@
*/
package org.apache.struts2.showcase.person;
import com.opensymphony.xwork2.ActionSupport;
import org.apache.struts2.ActionSupport;
import org.apache.struts2.convention.annotation.Result;
import org.apache.struts2.convention.annotation.Results;
import org.apache.struts2.interceptor.parameter.StrutsParameter;
@@ -20,8 +20,8 @@
*/
package org.apache.struts2.showcase.source;
import com.opensymphony.xwork2.ActionSupport;
import com.opensymphony.xwork2.util.ClassLoaderUtil;
import org.apache.struts2.ActionSupport;
import org.apache.struts2.util.ClassLoaderUtil;
import org.apache.struts2.action.ServletContextAware;
import org.apache.struts2.interceptor.parameter.StrutsParameter;
@@ -20,7 +20,7 @@
*/
package org.apache.struts2.showcase.tag.nonui.actionPrefix;
import com.opensymphony.xwork2.ActionSupport;
import org.apache.struts2.ActionSupport;
import org.apache.struts2.interceptor.parameter.StrutsParameter;
public class SubmitAction extends ActionSupport {
@@ -20,7 +20,7 @@
*/
package org.apache.struts2.showcase.tag.nonui.actiontag;
import com.opensymphony.xwork2.ActionSupport;
import org.apache.struts2.ActionSupport;
/**
*/
@@ -18,7 +18,7 @@
*/
package org.apache.struts2.showcase.tag.nonui.debugtag;
import com.opensymphony.xwork2.ActionSupport;
import org.apache.struts2.ActionSupport;
import org.apache.struts2.dispatcher.PrepareOperations;
public class DebugTagAction extends ActionSupport {
@@ -20,8 +20,8 @@
*/
package org.apache.struts2.showcase.tag.nonui.iteratortag;
import com.opensymphony.xwork2.ActionSupport;
import com.opensymphony.xwork2.Validateable;
import org.apache.struts2.ActionSupport;
import org.apache.struts2.Validateable;
import org.apache.struts2.interceptor.parameter.StrutsParameter;
/**
@@ -20,7 +20,7 @@
*/
package org.apache.struts2.showcase.tag.nonui.iteratortag;
import com.opensymphony.xwork2.ActionSupport;
import org.apache.struts2.ActionSupport;
import org.apache.struts2.interceptor.parameter.StrutsParameter;
/**
@@ -20,8 +20,8 @@
*/
package org.apache.struts2.showcase.tag.nonui.iteratortag;
import com.opensymphony.xwork2.ActionSupport;
import com.opensymphony.xwork2.Validateable;
import org.apache.struts2.ActionSupport;
import org.apache.struts2.Validateable;
import org.apache.struts2.interceptor.parameter.StrutsParameter;
@@ -20,8 +20,8 @@
*/
package org.apache.struts2.showcase.tag.nonui.iteratortag;
import com.opensymphony.xwork2.ActionSupport;
import com.opensymphony.xwork2.Validateable;
import org.apache.struts2.ActionSupport;
import org.apache.struts2.Validateable;
import org.apache.struts2.interceptor.parameter.StrutsParameter;
/**
@@ -24,7 +24,7 @@ import org.apache.struts2.convention.annotation.Result;
import org.apache.struts2.tiles.annotation.TilesDefinition;
import org.apache.struts2.tiles.annotation.TilesPutAttribute;
import com.opensymphony.xwork2.ActionSupport;
import org.apache.struts2.ActionSupport;
@Namespace("/tiles")
@ParentPackage("tiles")
@@ -20,8 +20,8 @@
*/
package org.apache.struts2.showcase.token;
import com.opensymphony.xwork2.ActionContext;
import com.opensymphony.xwork2.ActionSupport;
import org.apache.struts2.ActionContext;
import org.apache.struts2.ActionSupport;
import org.apache.struts2.interceptor.parameter.StrutsParameter;
import java.util.Date;
@@ -20,7 +20,7 @@
*/
package org.apache.struts2.showcase.validation;
import com.opensymphony.xwork2.ActionSupport;
import org.apache.struts2.ActionSupport;
/**
*/
@@ -18,15 +18,15 @@
*/
package org.apache.struts2.showcase.validation;
import com.opensymphony.xwork2.validator.annotations.DateRangeFieldValidator;
import com.opensymphony.xwork2.validator.annotations.EmailValidator;
import com.opensymphony.xwork2.validator.annotations.FieldExpressionValidator;
import com.opensymphony.xwork2.validator.annotations.IntRangeFieldValidator;
import com.opensymphony.xwork2.validator.annotations.RegexFieldValidator;
import com.opensymphony.xwork2.validator.annotations.RequiredFieldValidator;
import com.opensymphony.xwork2.validator.annotations.RequiredStringValidator;
import com.opensymphony.xwork2.validator.annotations.StringLengthFieldValidator;
import com.opensymphony.xwork2.validator.annotations.UrlValidator;
import org.apache.struts2.validator.annotations.DateRangeFieldValidator;
import org.apache.struts2.validator.annotations.EmailValidator;
import org.apache.struts2.validator.annotations.FieldExpressionValidator;
import org.apache.struts2.validator.annotations.IntRangeFieldValidator;
import org.apache.struts2.validator.annotations.RegexFieldValidator;
import org.apache.struts2.validator.annotations.RequiredFieldValidator;
import org.apache.struts2.validator.annotations.RequiredStringValidator;
import org.apache.struts2.validator.annotations.StringLengthFieldValidator;
import org.apache.struts2.validator.annotations.UrlValidator;
import org.apache.struts2.interceptor.parameter.StrutsParameter;
import java.sql.Date;
@@ -20,7 +20,7 @@
*/
package org.apache.struts2.showcase.validation;
import com.opensymphony.xwork2.ActionSupport;
import org.apache.struts2.ActionSupport;
import org.apache.struts.beanvalidation.constraints.FieldMatch;
import org.apache.struts2.convention.annotation.Action;
import org.apache.struts2.convention.annotation.Namespace;
@@ -20,7 +20,7 @@
*/
package org.apache.struts2.showcase.validation;
import com.opensymphony.xwork2.ActionSupport;
import org.apache.struts2.ActionSupport;
import org.apache.struts2.interceptor.parameter.StrutsParameter;
/**
@@ -20,7 +20,7 @@
*/
package org.apache.struts2.showcase.validation;
import com.opensymphony.xwork2.ActionSupport;
import org.apache.struts2.ActionSupport;
import org.apache.struts2.interceptor.parameter.StrutsParameter;
/**
@@ -20,7 +20,7 @@
*/
package org.apache.struts2.showcase.wait;
import com.opensymphony.xwork2.ActionSupport;
import org.apache.struts2.ActionSupport;
import org.apache.struts2.interceptor.parameter.StrutsParameter;
/**
@@ -20,7 +20,7 @@
*/
package org.apache.struts2.showcase.xslt;
import com.opensymphony.xwork2.ActionSupport;
import org.apache.struts2.ActionSupport;
import jakarta.servlet.http.HttpServletRequest;
@@ -30,6 +30,5 @@
<AppenderRef ref="STDOUT"/>
</Root>
<Logger name="org.apache.struts2" level="info"/>
<Logger name="com.opensymphony.xwork2" level="info"/>
</Loggers>
</Configuration>
@@ -20,7 +20,7 @@ package org.apache.struts2.showcase.conversion;
import java.util.LinkedHashSet;
import java.util.Set;
import com.opensymphony.xwork2.ActionSupport;
import org.apache.struts2.ActionSupport;
/**
* @version $Date$ $Id$
@@ -28,15 +28,15 @@ import com.opensymphony.xwork2.ActionSupport;
public class AddressAction extends ActionSupport {
private Set addresses = new LinkedHashSet();
public Set getAddresses() { return addresses; }
public void setAddresses(Set addresses) { this.addresses = addresses; }
public String input() throws Exception {
return SUCCESS;
}
public String submit() throws Exception {
System.out.println(addresses);
return SUCCESS;
@@ -21,28 +21,28 @@ import java.util.Arrays;
import java.util.LinkedList;
import java.util.List;
import com.opensymphony.xwork2.ActionSupport;
import org.apache.struts2.ActionSupport;
/**
*
*
* @version $Date$ $Id$
*/
public class OperationsEnumAction extends ActionSupport {
private static final long serialVersionUID = -2229489704988870318L;
private List<OperationsEnum> selectedOperations = new LinkedList<OperationsEnum>();
public List<OperationsEnum> getSelectedOperations() { return this.selectedOperations; }
public void setSelectedOperations(List<OperationsEnum> selectedOperations) {
this.selectedOperations = selectedOperations;
}
public List<OperationsEnum> getAvailableOperations() {
return Arrays.asList(OperationsEnum.values());
}
public String input() throws Exception {
return SUCCESS;
}
@@ -19,24 +19,24 @@ package org.apache.struts2.showcase.conversion;
import java.util.List;
import com.opensymphony.xwork2.ActionSupport;
import org.apache.struts2.ActionSupport;
/**
*
*
*/
public class PersonAction extends ActionSupport {
private List persons;
public List getPersons() { return persons; }
public void setPersons(List persons) { this.persons = persons; }
public String input() throws Exception {
return SUCCESS;
}
public String submit() throws Exception {
return SUCCESS;
}
@@ -31,11 +31,11 @@
// Calculate the view sources url
String sourceUrl = request.getContextPath() + "/viewSource.action";
com.opensymphony.xwork2.ActionInvocation inv = com.opensymphony.xwork2.ActionContext.getContext().getActionInvocation();
org.apache.struts2.ActionInvocation inv = org.apache.struts2.ActionContext.getContext().getActionInvocation();
org.apache.struts2.dispatcher.mapper.ActionMapping mapping = org.apache.struts2.ServletActionContext.getActionMapping();
if (inv != null) {
try {
com.opensymphony.xwork2.util.location.Location loc = inv.getProxy().getConfig().getLocation();
org.apache.struts2.util.location.Location loc = inv.getProxy().getConfig().getLocation();
sourceUrl += "?config=" + (loc != null ? loc.getURI() + ":" + loc.getLineNumber() : "");
} catch (Exception e) {
sourceUrl += "?config=";
@@ -86,7 +86,7 @@
<!-- Le HTML5 shim, for IE6-8 support of HTML5 elements -->
<!--[if lt IE 9]>
<s:script src="http://html5shim.googlecode.com/svn/trunk/html5.js"/>
<s:script src="https://html5shim.googlecode.com/svn/trunk/html5.js"/>
<![endif]-->
<s:script>
@@ -20,8 +20,8 @@
*/
-->
<!-- START SNIPPET: dwr -->
<!DOCTYPE dwr PUBLIC
"-//GetAhead Limited//DTD Direct Web Remoting 1.0//EN"
<!DOCTYPE dwr PUBLIC
"-//GetAhead Limited//DTD Direct Web Remoting 1.0//EN"
"http://www.getahead.ltd.uk/dwr/dwr10.dtd">
<dwr>
@@ -29,7 +29,7 @@
<create creator="new" javascript="validator">
<param name="class" value="org.apache.struts2.validators.DWRValidator"/>
</create>
<convert converter="bean" match="com.opensymphony.xwork2.ValidationAwareSupport"/>
<convert converter="bean" match="org.apache.struts2.ValidationAwareSupport"/>
</allow>
<signatures>
+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();
}
}
}

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