More cleanups - Javadocs, generics fixes, access controls

WW-1349


git-svn-id: https://svn.apache.org/repos/asf/struts/struts2/trunk@421776 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Donald J. Brown
2006-07-14 00:47:56 +00:00
parent 808abc64a0
commit 2feb96c80b
16 changed files with 313 additions and 97 deletions
@@ -36,7 +36,20 @@ import javax.servlet.http.HttpServletRequest;
* <!-- END SNIPPET: javadoc -->
*/
public interface ActionMapper {
/**
* Gets an action mapping for the current request
*
* @param request The servlet request
* @return The appropriate action mapping
*/
ActionMapping getMapping(HttpServletRequest request);
/**
* Converts an ActionMapping into a URI string
*
* @param mapping The action mapping
* @return The URI string that represents this mapping
*/
String getUriFromActionMapping(ActionMapping mapping);
}
@@ -39,8 +39,13 @@ import java.util.HashMap;
public class ActionMapperFactory {
protected static final Log LOG = LogFactory.getLog(ActionMapperFactory.class);
private static final HashMap classMap = new HashMap();
private static final HashMap<String,ActionMapper> classMap = new HashMap<String,ActionMapper>();
/**
* Gets an instance of the ActionMapper
*
* @return The action mapper
*/
public static ActionMapper getMapper() {
synchronized (classMap) {
String clazz = (String) Configuration.get(StrutsConstants.STRUTS_MAPPER_CLASS);
@@ -36,12 +36,28 @@ public class ActionMapping {
private Map params;
private Result result;
/**
* Constructs an ActionMapping
*/
public ActionMapping() {}
/**
* Constructs an ActionMapping with a default result
*
* @param result The default result
*/
public ActionMapping(Result result) {
this.result = result;
}
/**
* Constructs an ActionMapping with its values
*
* @param name The action name
* @param namespace The action namespace
* @param method The method
* @param params The extra parameters
*/
public ActionMapping(String name, String namespace, String method, Map params) {
this.name = name;
this.namespace = namespace;
@@ -49,18 +65,30 @@ public class ActionMapping {
this.params = params;
}
/**
* @return The action name
*/
public String getName() {
return name;
}
/**
* @return The action namespace
*/
public String getNamespace() {
return namespace;
}
/**
* @return The extra parameters
*/
public Map getParams() {
return params;
}
/**
* @return The method
*/
public String getMethod() {
if (null != method && "".equals(method)) {
return null;
@@ -69,26 +97,44 @@ public class ActionMapping {
}
}
/**
* @return The default result
*/
public Result getResult() {
return result;
}
/**
* @param result The result
*/
public void setResult(Result result) {
this.result = result;
}
/**
* @param name The action name
*/
public void setName(String name) {
this.name = name;
}
/**
* @param namespace The action namespace
*/
public void setNamespace(String namespace) {
this.namespace = namespace;
}
/**
* @param method The method name to call on the action
*/
public void setMethod(String method) {
this.method = method;
}
/**
* @param params The extra parameters for this mapping
*/
public void setParams(Map params) {
this.params = params;
}
@@ -191,6 +191,9 @@ public class DefaultActionMapper implements ActionMapper {
}
};
/* (non-Javadoc)
* @see org.apache.struts2.dispatcher.mapper.ActionMapper#getMapping(javax.servlet.http.HttpServletRequest)
*/
public ActionMapping getMapping(HttpServletRequest request) {
ActionMapping mapping = new ActionMapping();
String uri = getUri(request);
@@ -213,6 +216,13 @@ public class DefaultActionMapper implements ActionMapper {
return mapping;
}
/**
* Special parameters, as described in the class-level comment, are searched for
* and handled.
*
* @param request The request
* @param mapping The action mapping
*/
public static void handleSpecialParameters(HttpServletRequest request, ActionMapping mapping) {
// handle special parameter prefixes.
Map parameterMap = request.getParameterMap();
@@ -226,6 +236,12 @@ public class DefaultActionMapper implements ActionMapper {
}
}
/**
* Parses the name and namespace from the uri
*
* @param uri The uri
* @param mapping The action mapping to populate
*/
void parseNameAndNamespace(String uri, ActionMapping mapping) {
String namespace, name;
int lastSlash = uri.lastIndexOf("/");
@@ -245,6 +261,12 @@ public class DefaultActionMapper implements ActionMapper {
mapping.setName(dropExtension(name));
}
/**
* Drops the extension from the action name
*
* @param name The action name
* @return The action name without its extension
*/
String dropExtension(String name) {
List extensions = getExtensions();
if (extensions == null) {
@@ -286,6 +308,12 @@ public class DefaultActionMapper implements ActionMapper {
}
}
/**
* Gets the uri from the request
*
* @param request The request
* @return The uri
*/
String getUri(HttpServletRequest request) {
// handle http dispatcher includes.
String uri = (String) request.getAttribute("javax.servlet.include.servlet_path");
@@ -302,6 +330,9 @@ public class DefaultActionMapper implements ActionMapper {
return uri.substring(request.getContextPath().length());
}
/* (non-Javadoc)
* @see org.apache.struts2.dispatcher.mapper.ActionMapper#getUriFromActionMapping(org.apache.struts2.dispatcher.mapper.ActionMapping)
*/
public String getUriFromActionMapping(ActionMapping mapping) {
StringBuffer uri = new StringBuffer();
@@ -332,6 +363,9 @@ public class DefaultActionMapper implements ActionMapper {
return uri.toString();
}
/**
* Defines a parameter action prefix
*/
interface ParameterAction {
void execute(String key, ActionMapping mapping);
}
@@ -55,6 +55,9 @@ import java.util.StringTokenizer;
public class RestfulActionMapper implements ActionMapper {
protected static final Log LOG = LogFactory.getLog(RestfulActionMapper.class);
/* (non-Javadoc)
* @see org.apache.struts2.dispatcher.mapper.ActionMapper#getMapping(javax.servlet.http.HttpServletRequest)
*/
public ActionMapping getMapping(HttpServletRequest request) {
String uri = RequestUtils.getServletPath(request);
@@ -64,7 +67,7 @@ public class RestfulActionMapper implements ActionMapper {
}
String actionName = uri.substring(1, nextSlash);
HashMap parameters = new HashMap();
HashMap<String,String> parameters = new HashMap<String,String>();
try {
StringTokenizer st = new StringTokenizer(uri.substring(nextSlash), "/");
boolean isNameTok = true;
@@ -98,6 +101,9 @@ public class RestfulActionMapper implements ActionMapper {
return new ActionMapping(actionName, "", "", parameters);
}
/* (non-Javadoc)
* @see org.apache.struts2.dispatcher.mapper.ActionMapper#getUriFromActionMapping(org.apache.struts2.dispatcher.mapper.ActionMapping)
*/
public String getUriFromActionMapping(ActionMapping mapping) {
String base = mapping.getNamespace() + mapping.getName();
for (Iterator iterator = mapping.getParams().entrySet().iterator(); iterator.hasNext();) {
@@ -29,16 +29,16 @@ import java.io.InputStream;
import java.util.*;
/**
* Multipart form data request adapter for Jakarta's file upload package.
* Multipart form data request adapter for Jakarta Commons Fileupload package.
*
*/
public class JakartaMultiPartRequest extends MultiPartRequest {
// maps parameter name -> List of FileItem objects
private Map files = new HashMap();
private Map<String,List<FileItem>> files = new HashMap<String,List<FileItem>>();
// maps parameter name -> List of param values
private Map params = new HashMap();
private Map<String,List<String>> params = new HashMap<String,List<String>>();
// any errors while processing this request
private List errors = new ArrayList();
private List<String> errors = new ArrayList<String>();
/**
* Creates a new request wrapper to handle multi-part data using methods adapted from Jason Pell's
@@ -67,11 +67,11 @@ public class JakartaMultiPartRequest extends MultiPartRequest {
if (log.isDebugEnabled()) log.debug("Found item " + item.getFieldName());
if (item.isFormField()) {
log.debug("Item is a normal form field");
List values;
List<String> values;
if (params.get(item.getFieldName()) != null) {
values = (List) params.get(item.getFieldName());
values = params.get(item.getFieldName());
} else {
values = new ArrayList();
values = new ArrayList<String>();
}
// note: see http://jira.opensymphony.com/browse/WW-633
@@ -88,11 +88,11 @@ public class JakartaMultiPartRequest extends MultiPartRequest {
} else {
log.debug("Item is a file upload");
List values;
List<FileItem> values;
if (files.get(item.getFieldName()) != null) {
values = (List) files.get(item.getFieldName());
values = files.get(item.getFieldName());
} else {
values = new ArrayList();
values = new ArrayList<FileItem>();
}
values.add(item);
@@ -105,10 +105,16 @@ public class JakartaMultiPartRequest extends MultiPartRequest {
}
}
public Enumeration getFileParameterNames() {
/* (non-Javadoc)
* @see org.apache.struts2.dispatcher.multipart.MultiPartRequest#getFileParameterNames()
*/
public Enumeration<String> getFileParameterNames() {
return Collections.enumeration(files.keySet());
}
/* (non-Javadoc)
* @see org.apache.struts2.dispatcher.multipart.MultiPartRequest#getContentType(java.lang.String)
*/
public String[] getContentType(String fieldName) {
List items = (List) files.get(fieldName);
@@ -116,7 +122,7 @@ public class JakartaMultiPartRequest extends MultiPartRequest {
return null;
}
List contentTypes = new ArrayList(items.size());
List<String> contentTypes = new ArrayList<String>(items.size());
for (int i = 0; i < items.size(); i++) {
FileItem fileItem = (FileItem) items.get(i);
contentTypes.add(fileItem.getContentType());
@@ -125,6 +131,9 @@ public class JakartaMultiPartRequest extends MultiPartRequest {
return (String[]) contentTypes.toArray(new String[contentTypes.size()]);
}
/* (non-Javadoc)
* @see org.apache.struts2.dispatcher.multipart.MultiPartRequest#getFile(java.lang.String)
*/
public File[] getFile(String fieldName) {
List items = (List) files.get(fieldName);
@@ -132,7 +141,7 @@ public class JakartaMultiPartRequest extends MultiPartRequest {
return null;
}
List fileList = new ArrayList(items.size());
List<File> fileList = new ArrayList<File>(items.size());
for (int i = 0; i < items.size(); i++) {
DiskFileItem fileItem = (DiskFileItem) items.get(i);
fileList.add(fileItem.getStoreLocation());
@@ -141,14 +150,17 @@ public class JakartaMultiPartRequest extends MultiPartRequest {
return (File[]) fileList.toArray(new File[fileList.size()]);
}
/* (non-Javadoc)
* @see org.apache.struts2.dispatcher.multipart.MultiPartRequest#getFileNames(java.lang.String)
*/
public String[] getFileNames(String fieldName) {
List items = (List) files.get(fieldName);
List<FileItem> items = files.get(fieldName);
if (items == null) {
return null;
}
List fileNames = new ArrayList(items.size());
List<String> fileNames = new ArrayList<String>(items.size());
for (int i = 0; i < items.size(); i++) {
DiskFileItem fileItem = (DiskFileItem) items.get(i);
fileNames.add(getCanonicalName(fileItem.getName()));
@@ -157,6 +169,9 @@ public class JakartaMultiPartRequest extends MultiPartRequest {
return (String[]) fileNames.toArray(new String[fileNames.size()]);
}
/* (non-Javadoc)
* @see org.apache.struts2.dispatcher.multipart.MultiPartRequest#getFilesystemName(java.lang.String)
*/
public String[] getFilesystemName(String fieldName) {
List items = (List) files.get(fieldName);
@@ -164,7 +179,7 @@ public class JakartaMultiPartRequest extends MultiPartRequest {
return null;
}
List fileNames = new ArrayList(items.size());
List<String> fileNames = new ArrayList<String>(items.size());
for (int i = 0; i < items.size(); i++) {
DiskFileItem fileItem = (DiskFileItem) items.get(i);
fileNames.add(fileItem.getStoreLocation().getName());
@@ -173,6 +188,9 @@ public class JakartaMultiPartRequest extends MultiPartRequest {
return (String[]) fileNames.toArray(new String[fileNames.size()]);
}
/* (non-Javadoc)
* @see org.apache.struts2.dispatcher.multipart.MultiPartRequest#getParameter(java.lang.String)
*/
public String getParameter(String name) {
List v = (List) params.get(name);
if (v != null && v.size() > 0) {
@@ -182,12 +200,18 @@ public class JakartaMultiPartRequest extends MultiPartRequest {
return null;
}
public Enumeration getParameterNames() {
/* (non-Javadoc)
* @see org.apache.struts2.dispatcher.multipart.MultiPartRequest#getParameterNames()
*/
public Enumeration<String> getParameterNames() {
return Collections.enumeration(params.keySet());
}
/* (non-Javadoc)
* @see org.apache.struts2.dispatcher.multipart.MultiPartRequest#getParameterValues(java.lang.String)
*/
public String[] getParameterValues(String name) {
List v = (List) params.get(name);
List<String> v = params.get(name);
if (v != null && v.size() > 0) {
return (String[]) v.toArray(new String[v.size()]);
}
@@ -195,6 +219,9 @@ public class JakartaMultiPartRequest extends MultiPartRequest {
return null;
}
/* (non-Javadoc)
* @see org.apache.struts2.dispatcher.multipart.MultiPartRequest#getErrors()
*/
public List getErrors() {
return errors;
}
@@ -17,14 +17,15 @@
*/
package org.apache.struts2.dispatcher.multipart;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import javax.servlet.http.HttpServletRequest;
import java.io.File;
import java.util.Enumeration;
import java.util.List;
import javax.servlet.http.HttpServletRequest;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
/**
* Abstract wrapper class HTTP requests to handle multi-part data. <p>
@@ -51,7 +52,7 @@ public abstract class MultiPartRequest {
*
* @return an enumeration of the parameter names for uploaded files
*/
public abstract Enumeration getFileParameterNames();
public abstract Enumeration<String> getFileParameterNames();
/**
* Returns the content type(s) of the file(s) associated with the specified field name
@@ -103,7 +104,7 @@ public abstract class MultiPartRequest {
*
* @return an enumeration of String parameter names.
*/
public abstract Enumeration getParameterNames();
public abstract Enumeration<String> getParameterNames();
/**
* Returns a list of all parameter values associated with a parameter name. If there is only
@@ -129,19 +129,12 @@ public class MultiPartRequestWrapper extends StrutsRequestWrapper {
}
}
/**
* @deprecated use {@link #getFileParameterNames()} instead
*/
public Enumeration getFileNames() {
return getFileParameterNames();
}
/**
* Get an enumeration of the parameter names for uploaded files
*
* @return enumeration of parameter names for uploaded files
*/
public Enumeration getFileParameterNames() {
public Enumeration<String> getFileParameterNames() {
if (multi == null) {
return null;
}
@@ -149,19 +142,6 @@ public class MultiPartRequestWrapper extends StrutsRequestWrapper {
return multi.getFileParameterNames();
}
/**
* @deprecated use {@link #getContentTypes(String)} instead
*/
public String getContentType(String fieldName) {
String[] contentTypes = getContentTypes(fieldName);
if (contentTypes != null && contentTypes.length > 0) {
return contentTypes[0];
}
return null;
}
/**
* Get an array of content encoding for the specified input field name or <tt>null</tt> if
* no content type was specified.
@@ -177,18 +157,6 @@ public class MultiPartRequestWrapper extends StrutsRequestWrapper {
return multi.getContentType(name);
}
/**
* @deprecated use {@link #getFiles(String)} instead
*/
public File getFile(String fieldName) {
File[] files = getFiles(fieldName);
if (files != null && files.length > 0) {
return files[0];
}
return null;
}
/**
* Get a {@link java.io.File[]} for the given input field name.
*
@@ -216,18 +184,6 @@ public class MultiPartRequestWrapper extends StrutsRequestWrapper {
return multi.getFileNames(fieldName);
}
/**
* @deprecated use {@link #getFileSystemNames(String)} instead
*/
public String getFilesystemName(String fieldName) {
String[] names = getFileSystemNames(fieldName);
if (names != null && names.length > 0) {
return names[0];
}
return null;
}
/**
* Get the filename(s) of the file(s) uploaded for the given input field name.
* Returns <tt>null</tt> if the file is not found.
@@ -35,6 +35,13 @@ public class BackgroundProcess implements Serializable {
protected Exception exception;
protected boolean done;
/**
* Constructs a background process
*
* @param threadName The thread name
* @param invocation The action invocation
* @param threadPriority The thread priority
*/
public BackgroundProcess(String threadName, final ActionInvocation invocation, int threadPriority) {
this.invocation = invocation;
this.action = invocation.getAction();
@@ -61,7 +68,7 @@ public class BackgroundProcess implements Serializable {
}
/**
* called before the background thread determines the result code
* Called before the background thread determines the result code
* from the ActionInvocation.
*
* @throws Exception any exception thrown will be thrown, in turn, by the ExecuteAndWaitInterceptor
@@ -70,7 +77,7 @@ public class BackgroundProcess implements Serializable {
}
/**
* called after the background thread determines the result code
* Called after the background thread determines the result code
* from the ActionInvocation, but before the background thread is
* marked as done.
*
@@ -80,6 +80,9 @@ public class CreateSessionInterceptor extends AbstractInterceptor {
private static final Log _log = LogFactory.getLog(CreateSessionInterceptor.class);
/* (non-Javadoc)
* @see com.opensymphony.xwork2.interceptor.Interceptor#intercept(com.opensymphony.xwork2.ActionInvocation)
*/
public String intercept(ActionInvocation invocation) throws Exception {
_log.debug("Creating HttpSession");
ServletActionContext.getRequest().getSession(true);
@@ -17,17 +17,17 @@
*/
package org.apache.struts2.interceptor;
import java.util.Collections;
import java.util.Map;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import com.opensymphony.xwork2.ActionContext;
import com.opensymphony.xwork2.ActionInvocation;
import com.opensymphony.xwork2.ActionProxy;
import com.opensymphony.xwork2.config.entities.ResultConfig;
import com.opensymphony.xwork2.interceptor.Interceptor;
import com.opensymphony.xwork2.interceptor.MethodFilterInterceptor;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import java.util.Collections;
import java.util.Map;
/**
@@ -171,13 +171,27 @@ public class ExecuteAndWaitInterceptor extends MethodFilterInterceptor {
private int threadPriority = Thread.NORM_PRIORITY;
/* (non-Javadoc)
* @see com.opensymphony.xwork2.interceptor.Interceptor#init()
*/
public void init() {
}
/**
* Creates a new background process
*
* @param name The process name
* @param actionInvocation The action invocation
* @param threadPriority The thread priority
* @return The new process
*/
protected BackgroundProcess getNewBackgroundProcess(String name, ActionInvocation actionInvocation, int threadPriority) {
return new BackgroundProcess(name + "BackgroundThread", actionInvocation, threadPriority);
}
/* (non-Javadoc)
* @see com.opensymphony.xwork2.interceptor.MethodFilterInterceptor#doIntercept(com.opensymphony.xwork2.ActionInvocation)
*/
protected String doIntercept(ActionInvocation actionInvocation) throws Exception {
ActionProxy proxy = actionInvocation.getProxy();
String name = proxy.getActionName();
@@ -238,6 +252,9 @@ public class ExecuteAndWaitInterceptor extends MethodFilterInterceptor {
}
/* (non-Javadoc)
* @see com.opensymphony.xwork2.interceptor.Interceptor#destroy()
*/
public void destroy() {
}
@@ -17,21 +17,30 @@
*/
package org.apache.struts2.interceptor;
import java.io.File;
import java.util.Collection;
import java.util.Collections;
import java.util.Enumeration;
import java.util.HashSet;
import java.util.Iterator;
import java.util.Locale;
import java.util.Map;
import java.util.Set;
import java.util.StringTokenizer;
import javax.servlet.http.HttpServletRequest;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.struts2.ServletActionContext;
import org.apache.struts2.dispatcher.multipart.MultiPartRequestWrapper;
import com.opensymphony.xwork2.ActionContext;
import com.opensymphony.xwork2.ActionInvocation;
import com.opensymphony.xwork2.ActionProxy;
import com.opensymphony.xwork2.ValidationAware;
import com.opensymphony.xwork2.interceptor.AbstractInterceptor;
import com.opensymphony.xwork2.interceptor.Interceptor;
import com.opensymphony.xwork2.util.LocalizedTextUtil;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import javax.servlet.http.HttpServletRequest;
import java.io.File;
import java.util.*;
/**
* <!-- START SNIPPET: description -->
@@ -158,6 +167,11 @@ public class FileUploadInterceptor extends AbstractInterceptor {
protected String allowedTypes;
protected Set allowedTypesSet = Collections.EMPTY_SET;
/**
* Sets the allowed mimetypes
*
* @param allowedTypes A comma-delimited list of types
*/
public void setAllowedTypes(String allowedTypes) {
this.allowedTypes = allowedTypes;
@@ -165,10 +179,18 @@ public class FileUploadInterceptor extends AbstractInterceptor {
allowedTypesSet = getDelimitedValues(allowedTypes);
}
/**
* Sets the maximum size of an uploaded file
*
* @param maximumSize The maximum size in bytes
*/
public void setMaximumSize(Long maximumSize) {
this.maximumSize = maximumSize;
}
/* (non-Javadoc)
* @see com.opensymphony.xwork2.interceptor.Interceptor#intercept(com.opensymphony.xwork2.ActionInvocation)
*/
public String intercept(ActionInvocation invocation) throws Exception {
ActionContext ac = invocation.getInvocationContext();
HttpServletRequest request = (HttpServletRequest) ac.get(ServletActionContext.HTTP_REQUEST);
@@ -314,7 +336,7 @@ public class FileUploadInterceptor extends AbstractInterceptor {
}
private static Set getDelimitedValues(String delimitedString) {
Set delimitedValues = new HashSet();
Set<String> delimitedValues = new HashSet<String>();
if (delimitedString != null) {
StringTokenizer stringTokenizer = new StringTokenizer(delimitedString, DEFAULT_DELIMITER);
while (stringTokenizer.hasMoreTokens()) {
@@ -28,26 +28,57 @@ import java.security.Principal;
public class PrincipalProxy {
private HttpServletRequest request;
/**
* Constructs a proxy
*
* @param request The underlying request
*/
public PrincipalProxy(HttpServletRequest request) {
this.request = request;
}
/**
* True if the user is in the given role
*
* @param role The role
* @return True if the user is in that role
*/
public boolean isUserInRole(String role) {
return request.isUserInRole(role);
}
/**
* Gets the user principal
*
* @return The principal
*/
public Principal getUserPrincipal() {
return request.getUserPrincipal();
}
/**
* Gets the user id
*
* @return The user id
*/
public String getRemoteUser() {
return request.getRemoteUser();
}
/**
* Is the request using https?
*
* @return True if using https
*/
public boolean isRequestSecure() {
return request.isSecure();
}
/**
* Gets the request
*
* @return The request
*/
public HttpServletRequest getRequest() {
return request;
}
@@ -32,7 +32,7 @@ public interface RequestAware {
/**
* Sets the Map of request attributes in the implementing class.
*
* @param session a Map of HTTP request attribute name/value pairs.
* @param request a Map of HTTP request attribute name/value pairs.
*/
public void setRequest(Map request);
}
@@ -138,28 +138,41 @@ public class ScopeInterceptor extends AbstractInterceptor implements PreResultLi
private static final Log LOG = LogFactory.getLog(ScopeInterceptor.class);
String[] application = null;
String[] session = null;
String key;
String type = null;
boolean autoCreateSession = true;
String sessionReset = "session.reset";
boolean reset = false;
private String[] application = null;
private String[] session = null;
private String key;
private String type = null;
private boolean autoCreateSession = true;
private String sessionReset = "session.reset";
private boolean reset = false;
//list of application scoped properties
/**
* Sets a list of application scoped properties
*
* @param s A comma-delimited list
*/
public void setApplication(String s) {
if (s != null) {
application = s.split(" *, *");
}
}
//list of session scoped properties
/**
* Sets a list of session scoped properties
*
* @param s A comma-delimited list
*/
public void setSession(String s) {
if (s != null) {
session = s.split(" *, *");
}
}
/**
* Sets if the session should be automatically created
*
* @param value True if it should be created
*/
public void setAutoCreateSession(String value) {
if (value != null && value.length() > 0) {
this.autoCreateSession = new Boolean(value).booleanValue();
@@ -176,6 +189,9 @@ public class ScopeInterceptor extends AbstractInterceptor implements PreResultLi
return key;
}
/**
* The constructor
*/
public ScopeInterceptor() {
super();
}
@@ -302,6 +318,9 @@ public class ScopeInterceptor extends AbstractInterceptor implements PreResultLi
this.key = key;
}
/* (non-Javadoc)
* @see com.opensymphony.xwork2.interceptor.PreResultListener#beforeResult(com.opensymphony.xwork2.ActionInvocation, java.lang.String)
*/
public void beforeResult(ActionInvocation invocation, String resultCode) {
String key = getKey(invocation);
Map app = ActionContext.getContext().getApplication();
@@ -351,10 +370,18 @@ public class ScopeInterceptor extends AbstractInterceptor implements PreResultLi
}
}
/**
* @return The type of scope operation, "start" or "end"
*/
public String getType() {
return type;
}
/**
* Sets the type of scope operation
*
* @param type Either "start" or "end"
*/
public void setType(String type) {
type = type.toLowerCase();
if ("start".equals(type) || "end".equals(type)) {
@@ -364,14 +391,23 @@ public class ScopeInterceptor extends AbstractInterceptor implements PreResultLi
}
}
/**
* @return Gets the session reset parameter name
*/
public String getSessionReset() {
return sessionReset;
}
/**
* @param sessionReset The session reset parameter name
*/
public void setSessionReset(String sessionReset) {
this.sessionReset = sessionReset;
}
/* (non-Javadoc)
* @see com.opensymphony.xwork2.interceptor.Interceptor#intercept(com.opensymphony.xwork2.ActionInvocation)
*/
public String intercept(ActionInvocation invocation) throws Exception {
String result = null;
Map ses = ActionContext.getContext().getSession();
@@ -388,10 +424,16 @@ public class ScopeInterceptor extends AbstractInterceptor implements PreResultLi
return result;
}
/**
* @return True if the scope is reset
*/
public boolean isReset() {
return reset;
}
/**
* @param reset True if the scope should be reset
*/
public void setReset(boolean reset) {
this.reset = reset;
}
@@ -98,6 +98,9 @@ public class TokenSessionStoreInterceptor extends TokenInterceptor {
private static final long serialVersionUID = -9032347965469098195L;
/* (non-Javadoc)
* @see org.apache.struts2.interceptor.TokenInterceptor#handleInvalidToken(com.opensymphony.xwork2.ActionInvocation)
*/
protected String handleInvalidToken(ActionInvocation invocation) throws Exception {
ActionContext ac = invocation.getInvocationContext();
@@ -133,6 +136,9 @@ public class TokenSessionStoreInterceptor extends TokenInterceptor {
return INVALID_TOKEN_CODE;
}
/* (non-Javadoc)
* @see org.apache.struts2.interceptor.TokenInterceptor#handleValidToken(com.opensymphony.xwork2.ActionInvocation)
*/
protected String handleValidToken(ActionInvocation invocation) throws Exception {
// we know the token name and token must be there
String key = TokenHelper.getTokenName();