org.kuali.rice.kns.util
Class WebUtils

java.lang.Object
  extended by org.kuali.rice.kns.util.WebUtils

public class WebUtils
extends Object

General helper methods for handling requests.


Field Summary
private static String APPLICATION_IMAGE_URL_PROPERTY_PREFIX
           
private static KualiConfigurationService configurationService
           
private static String DEFAULT_IMAGE_URL_PROPERTY_NAME
           
static String FILE_UPLOAD_LIMIT_EXCEEDED_EXCEPTION_ALREADY_THROWN
          A request attribute name that indicates that a FileUploadLimitExceededException has already been thrown for the request.
private static String IMAGE_COORDINATE_CLICKED_X_EXTENSION
           
private static String IMAGE_COORDINATE_CLICKED_Y_EXTENSION
           
static String KEY_KUALI_FORM_IN_SESSION
           
private static org.apache.log4j.Logger LOG
           
 
Constructor Summary
WebUtils()
           
 
Method Summary
static boolean canAddNoteAttachment(Document document)
           
static boolean canDeleteNoteAttachment(Document document, String attachmentTypeCode, String authorUniversalIdentifier)
           
static boolean canFullyUnmaskField(String businessObjectClassName, String fieldName, KualiForm form)
           
static boolean canPartiallyUnmaskField(String businessObjectClassName, String fieldName, KualiForm form)
           
static boolean canViewNoteAttachment(Document document, String attachmentTypeCode)
           
static boolean containsSensitiveDataPatternMatch(String fieldValue)
           
static boolean endsWithCoordinates(String parameter)
           
static String filterHtmlAndReplaceRiceMarkup(String inputString)
          Excapes out HTML to prevent XSS attacks, and replaces the following strings to allow for a limited set of HTML tags [X] and [/X], where X represents any 1 or 2 letter string may be used to specify the equivalent tag in HTML (i.e.
static String generateTabKey(String tabTitle)
          Generates a String from the title that can be used as a Map key.
static String getButtonImageUrl(String imageName)
          Determines and returns the URL for question button images; looks first for a property "application.custom.image.url", and if that is missing, uses the image url returned by getDefaultButtonImageUrl()
static String getDefaultButtonImageUrl(String imageName)
          Generates a default button image URL, in the form of: ${kr.externalizable.images.url}buttonsmall_${imageName}.gif
private static Map getFileParametersForMultipartRequest(javax.servlet.http.HttpServletRequest request, org.apache.struts.upload.MultipartRequestHandler multipartHandler)
           
static String getFullyMaskedValue(String className, String fieldName, Object formObject, String propertyName)
           
static int getIndexOfCoordinateExtension(String parameter)
           
static KualiConfigurationService getKualiConfigurationService()
           
static org.apache.struts.action.ActionForm getKualiForm(javax.servlet.http.HttpServletRequest request)
           
static org.apache.struts.action.ActionForm getKualiForm(javax.servlet.jsp.PageContext pageContext)
           
static long getMaxUploadSize(org.apache.struts.action.ActionForm form)
           
private static String getMethodToCallSettingAttribute(org.apache.struts.action.ActionForm form, javax.servlet.http.HttpServletRequest request, String string)
          Parses out the methodToCall command and also sets the request attribute for the methodToCall.
private static KualiMultipartRequestHandler getMultipartHandler(javax.servlet.http.HttpServletRequest request, org.apache.struts.action.ActionForm form)
           
static void getMultipartParameters(javax.servlet.http.HttpServletRequest request, org.apache.struts.action.ActionServletWrapper servletWrapper, org.apache.struts.action.ActionForm form, org.apache.struts.action.ActionMapping mapping)
           
static String getPartiallyMaskedValue(String className, String fieldName, Object formObject, String propertyName)
           
static String getTabState(KualiForm form, String tabKey)
          JSTL function to return the tab state of the tab from the form.
static void incrementTabIndex(KualiForm form, String tabKey)
           
static boolean isDocumentSession(Document document, PojoFormBase docForm)
           
static boolean isFormSessionDocument(PojoFormBase form)
           
static boolean isHiddenKimObjectType(String type, String configParameter)
           
static boolean isInquiryHiddenField(String className, String fieldName, Object formObject, String propertyName)
           
private static boolean isMethodToCall(String string)
          Checks if a string signifies a methodToCall string
static boolean isProductionEnvironment()
           
static boolean isPropertyEditable(Set<String> editableProperties, String propertyName)
           
private static void logArray(org.apache.log4j.Logger logger, org.apache.log4j.Level level, String arrayName, Object[] array)
           
private static void logCollection(org.apache.log4j.Logger logger, org.apache.log4j.Level level, String collectionName, Collection c)
           
private static void logMap(org.apache.log4j.Logger logger, org.apache.log4j.Level level, String mapName, Map m)
           
private static void logObject(org.apache.log4j.Logger logger, org.apache.log4j.Level level, String objectName, Object o)
           
static void logRequestContents(org.apache.log4j.Logger logger, org.apache.log4j.Level level, javax.servlet.http.HttpServletRequest request)
          Iterates through and logs (at the given level) all attributes and parameters of the given request onto the given Logger
private static void logThing(org.apache.log4j.Logger logger, org.apache.log4j.Level level, String thingName, Object thing)
           
static String parseMethodToCall(org.apache.struts.action.ActionForm form, javax.servlet.http.HttpServletRequest request)
          Checks for methodToCall parameter, and picks off the value using set dot notation.
static void registerEditableProperty(PojoFormBase form, String editablePropertyName)
           
static void reuseErrorMapFromPreviousRequest(KualiDocumentFormBase kualiDocumentFormBase)
           
static void saveMimeInputStreamAsFile(javax.servlet.http.HttpServletResponse response, String contentType, InputStream inStream, String fileName, int fileSize)
          A file that is not of type text/plain or text/html can be output through the response using this method.
static void saveMimeOutputStreamAsFile(javax.servlet.http.HttpServletResponse response, String contentType, ByteArrayOutputStream byteArrayOutputStream, String fileName)
          A file that is not of type text/plain or text/html can be output through the response using this method.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

LOG

private static final org.apache.log4j.Logger LOG

IMAGE_COORDINATE_CLICKED_X_EXTENSION

private static final String IMAGE_COORDINATE_CLICKED_X_EXTENSION
See Also:
Constant Field Values

IMAGE_COORDINATE_CLICKED_Y_EXTENSION

private static final String IMAGE_COORDINATE_CLICKED_Y_EXTENSION
See Also:
Constant Field Values

APPLICATION_IMAGE_URL_PROPERTY_PREFIX

private static final String APPLICATION_IMAGE_URL_PROPERTY_PREFIX
See Also:
Constant Field Values

DEFAULT_IMAGE_URL_PROPERTY_NAME

private static final String DEFAULT_IMAGE_URL_PROPERTY_NAME
See Also:
Constant Field Values

FILE_UPLOAD_LIMIT_EXCEEDED_EXCEPTION_ALREADY_THROWN

public static final String FILE_UPLOAD_LIMIT_EXCEEDED_EXCEPTION_ALREADY_THROWN
A request attribute name that indicates that a FileUploadLimitExceededException has already been thrown for the request.

See Also:
Constant Field Values

configurationService

private static KualiConfigurationService configurationService

KEY_KUALI_FORM_IN_SESSION

public static String KEY_KUALI_FORM_IN_SESSION
Constructor Detail

WebUtils

public WebUtils()
Method Detail

parseMethodToCall

public static String parseMethodToCall(org.apache.struts.action.ActionForm form,
                                       javax.servlet.http.HttpServletRequest request)
Checks for methodToCall parameter, and picks off the value using set dot notation. Handles the problem of image submits.

Parameters:
request -
Returns:
methodToCall String

isMethodToCall

private static boolean isMethodToCall(String string)
Checks if a string signifies a methodToCall string

Parameters:
string - the string to check
Returns:
true if is a methodToCall

getMethodToCallSettingAttribute

private static String getMethodToCallSettingAttribute(org.apache.struts.action.ActionForm form,
                                                      javax.servlet.http.HttpServletRequest request,
                                                      String string)
Parses out the methodToCall command and also sets the request attribute for the methodToCall.

Parameters:
form - the ActionForm
request - the request to set the attribute on
string - the methodToCall string
Returns:
the methodToCall command

logRequestContents

public static void logRequestContents(org.apache.log4j.Logger logger,
                                      org.apache.log4j.Level level,
                                      javax.servlet.http.HttpServletRequest request)
Iterates through and logs (at the given level) all attributes and parameters of the given request onto the given Logger

Parameters:
request -
logger -

logArray

private static void logArray(org.apache.log4j.Logger logger,
                             org.apache.log4j.Level level,
                             String arrayName,
                             Object[] array)

logCollection

private static void logCollection(org.apache.log4j.Logger logger,
                                  org.apache.log4j.Level level,
                                  String collectionName,
                                  Collection c)

logMap

private static void logMap(org.apache.log4j.Logger logger,
                           org.apache.log4j.Level level,
                           String mapName,
                           Map m)

logObject

private static void logObject(org.apache.log4j.Logger logger,
                              org.apache.log4j.Level level,
                              String objectName,
                              Object o)

logThing

private static void logThing(org.apache.log4j.Logger logger,
                             org.apache.log4j.Level level,
                             String thingName,
                             Object thing)

saveMimeOutputStreamAsFile

public static void saveMimeOutputStreamAsFile(javax.servlet.http.HttpServletResponse response,
                                              String contentType,
                                              ByteArrayOutputStream byteArrayOutputStream,
                                              String fileName)
                                       throws IOException
A file that is not of type text/plain or text/html can be output through the response using this method.

Parameters:
response -
contentType -
outStream -
fileName -
Throws:
IOException

saveMimeInputStreamAsFile

public static void saveMimeInputStreamAsFile(javax.servlet.http.HttpServletResponse response,
                                             String contentType,
                                             InputStream inStream,
                                             String fileName,
                                             int fileSize)
                                      throws IOException
A file that is not of type text/plain or text/html can be output through the response using this method.

Parameters:
response -
contentType -
outStream -
fileName -
Throws:
IOException

getTabState

public static String getTabState(KualiForm form,
                                 String tabKey)
JSTL function to return the tab state of the tab from the form.

Parameters:
form -
tabKey -
Returns:

incrementTabIndex

public static void incrementTabIndex(KualiForm form,
                                     String tabKey)

generateTabKey

public static String generateTabKey(String tabTitle)
Generates a String from the title that can be used as a Map key.

Parameters:
tabTitle -
Returns:

getMultipartParameters

public static void getMultipartParameters(javax.servlet.http.HttpServletRequest request,
                                          org.apache.struts.action.ActionServletWrapper servletWrapper,
                                          org.apache.struts.action.ActionForm form,
                                          org.apache.struts.action.ActionMapping mapping)

getMaxUploadSize

public static long getMaxUploadSize(org.apache.struts.action.ActionForm form)

getMultipartHandler

private static KualiMultipartRequestHandler getMultipartHandler(javax.servlet.http.HttpServletRequest request,
                                                                org.apache.struts.action.ActionForm form)
                                                         throws javax.servlet.ServletException
Throws:
javax.servlet.ServletException

getFileParametersForMultipartRequest

private static Map getFileParametersForMultipartRequest(javax.servlet.http.HttpServletRequest request,
                                                        org.apache.struts.upload.MultipartRequestHandler multipartHandler)

registerEditableProperty

public static void registerEditableProperty(PojoFormBase form,
                                            String editablePropertyName)

isDocumentSession

public static boolean isDocumentSession(Document document,
                                        PojoFormBase docForm)

isFormSessionDocument

public static boolean isFormSessionDocument(PojoFormBase form)

getKualiForm

public static org.apache.struts.action.ActionForm getKualiForm(javax.servlet.jsp.PageContext pageContext)

getKualiForm

public static org.apache.struts.action.ActionForm getKualiForm(javax.servlet.http.HttpServletRequest request)

isPropertyEditable

public static boolean isPropertyEditable(Set<String> editableProperties,
                                         String propertyName)

endsWithCoordinates

public static boolean endsWithCoordinates(String parameter)

getIndexOfCoordinateExtension

public static int getIndexOfCoordinateExtension(String parameter)

isInquiryHiddenField

public static boolean isInquiryHiddenField(String className,
                                           String fieldName,
                                           Object formObject,
                                           String propertyName)

isHiddenKimObjectType

public static boolean isHiddenKimObjectType(String type,
                                            String configParameter)

getFullyMaskedValue

public static String getFullyMaskedValue(String className,
                                         String fieldName,
                                         Object formObject,
                                         String propertyName)

getPartiallyMaskedValue

public static String getPartiallyMaskedValue(String className,
                                             String fieldName,
                                             Object formObject,
                                             String propertyName)

canFullyUnmaskField

public static boolean canFullyUnmaskField(String businessObjectClassName,
                                          String fieldName,
                                          KualiForm form)

canPartiallyUnmaskField

public static boolean canPartiallyUnmaskField(String businessObjectClassName,
                                              String fieldName,
                                              KualiForm form)

canAddNoteAttachment

public static boolean canAddNoteAttachment(Document document)

canViewNoteAttachment

public static boolean canViewNoteAttachment(Document document,
                                            String attachmentTypeCode)

canDeleteNoteAttachment

public static boolean canDeleteNoteAttachment(Document document,
                                              String attachmentTypeCode,
                                              String authorUniversalIdentifier)

reuseErrorMapFromPreviousRequest

public static void reuseErrorMapFromPreviousRequest(KualiDocumentFormBase kualiDocumentFormBase)

filterHtmlAndReplaceRiceMarkup

public static String filterHtmlAndReplaceRiceMarkup(String inputString)
Excapes out HTML to prevent XSS attacks, and replaces the following strings to allow for a limited set of HTML tags
  • [X] and [/X], where X represents any 1 or 2 letter string may be used to specify the equivalent tag in HTML (i.e. <X> and </X>)
  • [font COLOR], where COLOR represents any valid html color (i.e. color name or hexcode preceeded by #) will be filtered into <font color="COLOR"/>
  • [/font] will be filtered into </font>
  • [table CLASS], where CLASS gives the style class to use, will be filter into <table class="CLASS"/>
  • [/table] will be filtered into </table>
  • [td CLASS], where CLASS gives the style class to use, will be filter into <td class="CLASS"/>

    Parameters:
    inputString -
    Returns:

  • containsSensitiveDataPatternMatch

    public static boolean containsSensitiveDataPatternMatch(String fieldValue)

    getButtonImageUrl

    public static String getButtonImageUrl(String imageName)
    Determines and returns the URL for question button images; looks first for a property "application.custom.image.url", and if that is missing, uses the image url returned by getDefaultButtonImageUrl()

    Parameters:
    imageName - the name of the image to find a button for
    Returns:
    the URL where question button images are located

    getDefaultButtonImageUrl

    public static String getDefaultButtonImageUrl(String imageName)
    Generates a default button image URL, in the form of: ${kr.externalizable.images.url}buttonsmall_${imageName}.gif

    Parameters:
    imageName - the image name to generate a default button name for
    Returns:
    the default button image url

    isProductionEnvironment

    public static boolean isProductionEnvironment()
    Returns:
    whether the deploy environment is production

    getKualiConfigurationService

    public static KualiConfigurationService getKualiConfigurationService()
    Returns:
    an implementation of the KualiConfigurationService


    Copyright © 2007-2011 The Kuali Foundation. All Rights Reserved.