You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@struts.apache.org by mr...@apache.org on 2006/07/14 02:47:58 UTC
svn commit: r421776 - in
/struts/struts2/trunk/core/src/main/java/org/apache/struts2:
dispatcher/client/ dispatcher/mapper/ dispatcher/multipart/ interceptor/
Author: mrdon
Date: Thu Jul 13 17:47:56 2006
New Revision: 421776
URL: http://svn.apache.org/viewvc?rev=421776&view=rev
Log:
More cleanups - Javadocs, generics fixes, access controls
WW-1349
Removed:
struts/struts2/trunk/core/src/main/java/org/apache/struts2/dispatcher/client/
Modified:
struts/struts2/trunk/core/src/main/java/org/apache/struts2/dispatcher/mapper/ActionMapper.java
struts/struts2/trunk/core/src/main/java/org/apache/struts2/dispatcher/mapper/ActionMapperFactory.java
struts/struts2/trunk/core/src/main/java/org/apache/struts2/dispatcher/mapper/ActionMapping.java
struts/struts2/trunk/core/src/main/java/org/apache/struts2/dispatcher/mapper/DefaultActionMapper.java
struts/struts2/trunk/core/src/main/java/org/apache/struts2/dispatcher/mapper/RestfulActionMapper.java
struts/struts2/trunk/core/src/main/java/org/apache/struts2/dispatcher/multipart/JakartaMultiPartRequest.java
struts/struts2/trunk/core/src/main/java/org/apache/struts2/dispatcher/multipart/MultiPartRequest.java
struts/struts2/trunk/core/src/main/java/org/apache/struts2/dispatcher/multipart/MultiPartRequestWrapper.java
struts/struts2/trunk/core/src/main/java/org/apache/struts2/interceptor/BackgroundProcess.java
struts/struts2/trunk/core/src/main/java/org/apache/struts2/interceptor/CreateSessionInterceptor.java
struts/struts2/trunk/core/src/main/java/org/apache/struts2/interceptor/ExecuteAndWaitInterceptor.java
struts/struts2/trunk/core/src/main/java/org/apache/struts2/interceptor/FileUploadInterceptor.java
struts/struts2/trunk/core/src/main/java/org/apache/struts2/interceptor/PrincipalProxy.java
struts/struts2/trunk/core/src/main/java/org/apache/struts2/interceptor/RequestAware.java
struts/struts2/trunk/core/src/main/java/org/apache/struts2/interceptor/ScopeInterceptor.java
struts/struts2/trunk/core/src/main/java/org/apache/struts2/interceptor/TokenSessionStoreInterceptor.java
Modified: struts/struts2/trunk/core/src/main/java/org/apache/struts2/dispatcher/mapper/ActionMapper.java
URL: http://svn.apache.org/viewvc/struts/struts2/trunk/core/src/main/java/org/apache/struts2/dispatcher/mapper/ActionMapper.java?rev=421776&r1=421775&r2=421776&view=diff
==============================================================================
--- struts/struts2/trunk/core/src/main/java/org/apache/struts2/dispatcher/mapper/ActionMapper.java (original)
+++ struts/struts2/trunk/core/src/main/java/org/apache/struts2/dispatcher/mapper/ActionMapper.java Thu Jul 13 17:47:56 2006
@@ -36,7 +36,20 @@
* <!-- 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);
}
Modified: struts/struts2/trunk/core/src/main/java/org/apache/struts2/dispatcher/mapper/ActionMapperFactory.java
URL: http://svn.apache.org/viewvc/struts/struts2/trunk/core/src/main/java/org/apache/struts2/dispatcher/mapper/ActionMapperFactory.java?rev=421776&r1=421775&r2=421776&view=diff
==============================================================================
--- struts/struts2/trunk/core/src/main/java/org/apache/struts2/dispatcher/mapper/ActionMapperFactory.java (original)
+++ struts/struts2/trunk/core/src/main/java/org/apache/struts2/dispatcher/mapper/ActionMapperFactory.java Thu Jul 13 17:47:56 2006
@@ -39,8 +39,13 @@
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);
Modified: struts/struts2/trunk/core/src/main/java/org/apache/struts2/dispatcher/mapper/ActionMapping.java
URL: http://svn.apache.org/viewvc/struts/struts2/trunk/core/src/main/java/org/apache/struts2/dispatcher/mapper/ActionMapping.java?rev=421776&r1=421775&r2=421776&view=diff
==============================================================================
--- struts/struts2/trunk/core/src/main/java/org/apache/struts2/dispatcher/mapper/ActionMapping.java (original)
+++ struts/struts2/trunk/core/src/main/java/org/apache/struts2/dispatcher/mapper/ActionMapping.java Thu Jul 13 17:47:56 2006
@@ -36,12 +36,28 @@
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 @@
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 @@
}
}
+ /**
+ * @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;
}
Modified: struts/struts2/trunk/core/src/main/java/org/apache/struts2/dispatcher/mapper/DefaultActionMapper.java
URL: http://svn.apache.org/viewvc/struts/struts2/trunk/core/src/main/java/org/apache/struts2/dispatcher/mapper/DefaultActionMapper.java?rev=421776&r1=421775&r2=421776&view=diff
==============================================================================
--- struts/struts2/trunk/core/src/main/java/org/apache/struts2/dispatcher/mapper/DefaultActionMapper.java (original)
+++ struts/struts2/trunk/core/src/main/java/org/apache/struts2/dispatcher/mapper/DefaultActionMapper.java Thu Jul 13 17:47:56 2006
@@ -191,6 +191,9 @@
}
};
+ /* (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 @@
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 @@
}
}
+ /**
+ * 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 @@
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 @@
}
}
+ /**
+ * 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 @@
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 @@
return uri.toString();
}
+ /**
+ * Defines a parameter action prefix
+ */
interface ParameterAction {
void execute(String key, ActionMapping mapping);
}
Modified: struts/struts2/trunk/core/src/main/java/org/apache/struts2/dispatcher/mapper/RestfulActionMapper.java
URL: http://svn.apache.org/viewvc/struts/struts2/trunk/core/src/main/java/org/apache/struts2/dispatcher/mapper/RestfulActionMapper.java?rev=421776&r1=421775&r2=421776&view=diff
==============================================================================
--- struts/struts2/trunk/core/src/main/java/org/apache/struts2/dispatcher/mapper/RestfulActionMapper.java (original)
+++ struts/struts2/trunk/core/src/main/java/org/apache/struts2/dispatcher/mapper/RestfulActionMapper.java Thu Jul 13 17:47:56 2006
@@ -55,6 +55,9 @@
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 @@
}
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 @@
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();) {
Modified: struts/struts2/trunk/core/src/main/java/org/apache/struts2/dispatcher/multipart/JakartaMultiPartRequest.java
URL: http://svn.apache.org/viewvc/struts/struts2/trunk/core/src/main/java/org/apache/struts2/dispatcher/multipart/JakartaMultiPartRequest.java?rev=421776&r1=421775&r2=421776&view=diff
==============================================================================
--- struts/struts2/trunk/core/src/main/java/org/apache/struts2/dispatcher/multipart/JakartaMultiPartRequest.java (original)
+++ struts/struts2/trunk/core/src/main/java/org/apache/struts2/dispatcher/multipart/JakartaMultiPartRequest.java Thu Jul 13 17:47:56 2006
@@ -29,16 +29,16 @@
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 @@
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 @@
} 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 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 @@
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 @@
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 @@
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 @@
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 @@
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 @@
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 @@
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 @@
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 @@
return null;
}
+ /* (non-Javadoc)
+ * @see org.apache.struts2.dispatcher.multipart.MultiPartRequest#getErrors()
+ */
public List getErrors() {
return errors;
}
Modified: struts/struts2/trunk/core/src/main/java/org/apache/struts2/dispatcher/multipart/MultiPartRequest.java
URL: http://svn.apache.org/viewvc/struts/struts2/trunk/core/src/main/java/org/apache/struts2/dispatcher/multipart/MultiPartRequest.java?rev=421776&r1=421775&r2=421776&view=diff
==============================================================================
--- struts/struts2/trunk/core/src/main/java/org/apache/struts2/dispatcher/multipart/MultiPartRequest.java (original)
+++ struts/struts2/trunk/core/src/main/java/org/apache/struts2/dispatcher/multipart/MultiPartRequest.java Thu Jul 13 17:47:56 2006
@@ -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 @@
*
* @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 @@
*
* @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
Modified: struts/struts2/trunk/core/src/main/java/org/apache/struts2/dispatcher/multipart/MultiPartRequestWrapper.java
URL: http://svn.apache.org/viewvc/struts/struts2/trunk/core/src/main/java/org/apache/struts2/dispatcher/multipart/MultiPartRequestWrapper.java?rev=421776&r1=421775&r2=421776&view=diff
==============================================================================
--- struts/struts2/trunk/core/src/main/java/org/apache/struts2/dispatcher/multipart/MultiPartRequestWrapper.java (original)
+++ struts/struts2/trunk/core/src/main/java/org/apache/struts2/dispatcher/multipart/MultiPartRequestWrapper.java Thu Jul 13 17:47:56 2006
@@ -130,18 +130,11 @@
}
/**
- * @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;
}
@@ -150,19 +143,6 @@
}
/**
- * @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.
*
@@ -178,18 +158,6 @@
}
/**
- * @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.
*
* @param fieldName input field name
@@ -214,18 +182,6 @@
}
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;
}
/**
Modified: struts/struts2/trunk/core/src/main/java/org/apache/struts2/interceptor/BackgroundProcess.java
URL: http://svn.apache.org/viewvc/struts/struts2/trunk/core/src/main/java/org/apache/struts2/interceptor/BackgroundProcess.java?rev=421776&r1=421775&r2=421776&view=diff
==============================================================================
--- struts/struts2/trunk/core/src/main/java/org/apache/struts2/interceptor/BackgroundProcess.java (original)
+++ struts/struts2/trunk/core/src/main/java/org/apache/struts2/interceptor/BackgroundProcess.java Thu Jul 13 17:47:56 2006
@@ -35,6 +35,13 @@
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 @@
}
/**
- * 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 @@
}
/**
- * 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.
*
Modified: struts/struts2/trunk/core/src/main/java/org/apache/struts2/interceptor/CreateSessionInterceptor.java
URL: http://svn.apache.org/viewvc/struts/struts2/trunk/core/src/main/java/org/apache/struts2/interceptor/CreateSessionInterceptor.java?rev=421776&r1=421775&r2=421776&view=diff
==============================================================================
--- struts/struts2/trunk/core/src/main/java/org/apache/struts2/interceptor/CreateSessionInterceptor.java (original)
+++ struts/struts2/trunk/core/src/main/java/org/apache/struts2/interceptor/CreateSessionInterceptor.java Thu Jul 13 17:47:56 2006
@@ -80,6 +80,9 @@
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);
Modified: struts/struts2/trunk/core/src/main/java/org/apache/struts2/interceptor/ExecuteAndWaitInterceptor.java
URL: http://svn.apache.org/viewvc/struts/struts2/trunk/core/src/main/java/org/apache/struts2/interceptor/ExecuteAndWaitInterceptor.java?rev=421776&r1=421775&r2=421776&view=diff
==============================================================================
--- struts/struts2/trunk/core/src/main/java/org/apache/struts2/interceptor/ExecuteAndWaitInterceptor.java (original)
+++ struts/struts2/trunk/core/src/main/java/org/apache/struts2/interceptor/ExecuteAndWaitInterceptor.java Thu Jul 13 17:47:56 2006
@@ -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 @@
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 @@
}
+ /* (non-Javadoc)
+ * @see com.opensymphony.xwork2.interceptor.Interceptor#destroy()
+ */
public void destroy() {
}
Modified: struts/struts2/trunk/core/src/main/java/org/apache/struts2/interceptor/FileUploadInterceptor.java
URL: http://svn.apache.org/viewvc/struts/struts2/trunk/core/src/main/java/org/apache/struts2/interceptor/FileUploadInterceptor.java?rev=421776&r1=421775&r2=421776&view=diff
==============================================================================
--- struts/struts2/trunk/core/src/main/java/org/apache/struts2/interceptor/FileUploadInterceptor.java (original)
+++ struts/struts2/trunk/core/src/main/java/org/apache/struts2/interceptor/FileUploadInterceptor.java Thu Jul 13 17:47:56 2006
@@ -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 @@
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 @@
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 @@
}
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()) {
Modified: struts/struts2/trunk/core/src/main/java/org/apache/struts2/interceptor/PrincipalProxy.java
URL: http://svn.apache.org/viewvc/struts/struts2/trunk/core/src/main/java/org/apache/struts2/interceptor/PrincipalProxy.java?rev=421776&r1=421775&r2=421776&view=diff
==============================================================================
--- struts/struts2/trunk/core/src/main/java/org/apache/struts2/interceptor/PrincipalProxy.java (original)
+++ struts/struts2/trunk/core/src/main/java/org/apache/struts2/interceptor/PrincipalProxy.java Thu Jul 13 17:47:56 2006
@@ -28,26 +28,57 @@
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;
}
Modified: struts/struts2/trunk/core/src/main/java/org/apache/struts2/interceptor/RequestAware.java
URL: http://svn.apache.org/viewvc/struts/struts2/trunk/core/src/main/java/org/apache/struts2/interceptor/RequestAware.java?rev=421776&r1=421775&r2=421776&view=diff
==============================================================================
--- struts/struts2/trunk/core/src/main/java/org/apache/struts2/interceptor/RequestAware.java (original)
+++ struts/struts2/trunk/core/src/main/java/org/apache/struts2/interceptor/RequestAware.java Thu Jul 13 17:47:56 2006
@@ -32,7 +32,7 @@
/**
* 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);
}
Modified: struts/struts2/trunk/core/src/main/java/org/apache/struts2/interceptor/ScopeInterceptor.java
URL: http://svn.apache.org/viewvc/struts/struts2/trunk/core/src/main/java/org/apache/struts2/interceptor/ScopeInterceptor.java?rev=421776&r1=421775&r2=421776&view=diff
==============================================================================
--- struts/struts2/trunk/core/src/main/java/org/apache/struts2/interceptor/ScopeInterceptor.java (original)
+++ struts/struts2/trunk/core/src/main/java/org/apache/struts2/interceptor/ScopeInterceptor.java Thu Jul 13 17:47:56 2006
@@ -138,28 +138,41 @@
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;
-
- //list of application scoped properties
+ 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;
+
+ /**
+ * 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 @@
return key;
}
+ /**
+ * The constructor
+ */
public ScopeInterceptor() {
super();
}
@@ -302,6 +318,9 @@
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 @@
}
}
+ /**
+ * @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 @@
}
}
+ /**
+ * @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 @@
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;
}
Modified: struts/struts2/trunk/core/src/main/java/org/apache/struts2/interceptor/TokenSessionStoreInterceptor.java
URL: http://svn.apache.org/viewvc/struts/struts2/trunk/core/src/main/java/org/apache/struts2/interceptor/TokenSessionStoreInterceptor.java?rev=421776&r1=421775&r2=421776&view=diff
==============================================================================
--- struts/struts2/trunk/core/src/main/java/org/apache/struts2/interceptor/TokenSessionStoreInterceptor.java (original)
+++ struts/struts2/trunk/core/src/main/java/org/apache/struts2/interceptor/TokenSessionStoreInterceptor.java Thu Jul 13 17:47:56 2006
@@ -98,6 +98,9 @@
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 @@
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();