com.bowstreet.webapp.util
Class FileUpload

java.lang.Object
  extended by com.bowstreet.webapp.util.FileUpload

public class FileUpload
extends java.lang.Object

This class has a collection of static methods to allow interaction with the File Upload builder.


Field Summary
static java.lang.String ALLOW_EXCEPTION_RESPONSE
          The session key for the allow exception response flag.
static java.lang.String ALLOW_FILE_UPLOAD_TOKEN
          The session key for the allow file uploads flag.
static java.lang.String FILE_UPLOAD_SUBPATH
          The session key for the file upload destination path.
static java.lang.String ORIGINAL_NAME_PREFIX
          The request inputs prefix for the original file name supplied by the client browser.
static java.lang.String ORIGINAL_PATH_PREFIX
          The request inputs prefix for the original file path supplied by the client browser.
static java.lang.String OVERWRITE_EXISTING
          The session key for the overwrite existing flag.
 
Constructor Summary
FileUpload()
           
 
Method Summary
static void allowFileUpload(WebAppAccess webAppAccess)
          Configures the current user's session to allow files to be uploaded.
static void allowFileUpload(WebAppAccess webAppAccess, java.lang.String subPath)
          Configures the current user's session to allow files to be uploaded.
static boolean getAllowExceptionResponse(javax.servlet.http.HttpServletRequest request)
          Returns the setting for the File Upload builder's allow exception response flag.
static java.lang.String getFileUploadSubPath(javax.servlet.http.HttpServletRequest request)
          Returns the destination path where uploaded files should be stored.
static java.lang.String getOriginalName(WebAppAccess webAppAccess, java.lang.String inputName)
          Obtains the original file name for the provided form input.
static java.lang.String getOriginalPath(WebAppAccess webAppAccess, java.lang.String inputName)
          Obtains the original client-side file path for the provided form input.
static boolean getOverwriteExisting(javax.servlet.http.HttpServletRequest request)
          Returns the setting for the File Upload builder's overwrite existing flag.
static boolean isFileUploadAllowed(javax.servlet.http.HttpServletRequest request)
          Check to see if file upload is currently allowed for this request (eg, by the File Upload Builder having put code on the page for the user, which calls the above allowFileUpload for this user.)
static void setAllowExceptionResponse(WebAppAccess webAppAccess, boolean allow)
          Used by MultipartRequest to decide whether to throw exceptions (old) or catch them, execute normal action, and return the Exception in the response.
static void setOverwriteExisting(WebAppAccess webAppAccess, boolean overwriteExisting)
          Used by MultipartRequest to decide whether to overwrite existing files.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

ALLOW_EXCEPTION_RESPONSE

public static final java.lang.String ALLOW_EXCEPTION_RESPONSE
The session key for the allow exception response flag.

See Also:
Constant Field Values

ALLOW_FILE_UPLOAD_TOKEN

public static final java.lang.String ALLOW_FILE_UPLOAD_TOKEN
The session key for the allow file uploads flag.

See Also:
Constant Field Values

FILE_UPLOAD_SUBPATH

public static final java.lang.String FILE_UPLOAD_SUBPATH
The session key for the file upload destination path.

See Also:
Constant Field Values

ORIGINAL_NAME_PREFIX

public static final java.lang.String ORIGINAL_NAME_PREFIX
The request inputs prefix for the original file name supplied by the client browser.

See Also:
Constant Field Values

ORIGINAL_PATH_PREFIX

public static final java.lang.String ORIGINAL_PATH_PREFIX
The request inputs prefix for the original file path supplied by the client browser.

See Also:
Constant Field Values

OVERWRITE_EXISTING

public static final java.lang.String OVERWRITE_EXISTING
The session key for the overwrite existing flag.

See Also:
Constant Field Values
Constructor Detail

FileUpload

public FileUpload()
Method Detail

allowFileUpload

public static void allowFileUpload(WebAppAccess webAppAccess)
Configures the current user's session to allow files to be uploaded.

Parameters:
webAppAccess - the current WebAppAccess

allowFileUpload

public static void allowFileUpload(WebAppAccess webAppAccess,
                                   java.lang.String subPath)
Configures the current user's session to allow files to be uploaded. The File Upload builder inserts code into the file upload page to call this. This uses WebAppAccess to get the request/session, so on JSR-168 it will have the portlet session.

Parameters:
webAppAccess - the current WebAppAccess
subPath - the destination path to upload files to

getAllowExceptionResponse

public static boolean getAllowExceptionResponse(javax.servlet.http.HttpServletRequest request)
Returns the setting for the File Upload builder's allow exception response flag.

Parameters:
request - the current request
Returns:
true if exceptions should be included in the response; false if they should be thrown

getFileUploadSubPath

public static java.lang.String getFileUploadSubPath(javax.servlet.http.HttpServletRequest request)
Returns the destination path where uploaded files should be stored. This may return null if the destination path has not been set, in which case the default upload path will be used.

Parameters:
request - the current request
Returns:
the destination path where uploaded files should be stored

getOriginalName

public static java.lang.String getOriginalName(WebAppAccess webAppAccess,
                                               java.lang.String inputName)
Obtains the original file name for the provided form input.

Parameters:
webAppAccess - the current WebAppAccess
inputName - the name of the file upload input control on the page

getOriginalPath

public static java.lang.String getOriginalPath(WebAppAccess webAppAccess,
                                               java.lang.String inputName)
Obtains the original client-side file path for the provided form input. The value returned by this method is browser dependent. The original client-side path is only sent in the request by some browsers, other browsers simply send the file name without the path information, in which case, this method will behave like the getOriginalName(com.bowstreet.webapp.WebAppAccess, java.lang.String) method.

Parameters:
webAppAccess - the current WebAppAccess
inputName - the name of the file upload input control on the page

getOverwriteExisting

public static boolean getOverwriteExisting(javax.servlet.http.HttpServletRequest request)
Returns the setting for the File Upload builder's overwrite existing flag.

Parameters:
request - the current request
Returns:
true if existing files should be overwritten

isFileUploadAllowed

public static boolean isFileUploadAllowed(javax.servlet.http.HttpServletRequest request)
Check to see if file upload is currently allowed for this request (eg, by the File Upload Builder having put code on the page for the user, which calls the above allowFileUpload for this user.)

Parameters:
request - the current request
Returns:
true if file upload is allowed for the current user

setAllowExceptionResponse

public static void setAllowExceptionResponse(WebAppAccess webAppAccess,
                                             boolean allow)
Used by MultipartRequest to decide whether to throw exceptions (old) or catch them, execute normal action, and return the Exception in the response. The File Upload builder inserts code into the file upload page to call this. This uses WebAppAccess to get the request/session, so on JSR-168 it will have the portlet session.

Parameters:
webAppAccess - the current WebAppAccess
allow - flag indicating how exceptions should be handled (true = in response; false = throw)

setOverwriteExisting

public static void setOverwriteExisting(WebAppAccess webAppAccess,
                                        boolean overwriteExisting)
Used by MultipartRequest to decide whether to overwrite existing files. The File Upload builder inserts code into the file upload page to call this. This uses WebAppAccess to get the request/session, so on JSR-168 it will have the portlet session.

Parameters:
webAppAccess - the current WebAppAccess
overwriteExisting - flag indicating if existing files should be overwritten


Copyright © 2009 IBM. All Rights Reserved.