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
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.
static String KEY_KUALI_FORM_IN_SESSION
           
 
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 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
static String getFullyMaskedValue(String className, String fieldName, Object formObject, String propertyName)
           
static int getIndexOfCoordinateExtension(String parameter)
           
static ConfigurationService 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)
           
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)
           
static boolean isPropertyEditable(Set<String> editableProperties, String propertyName)
           
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
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 String preserveWhitespace(String startingString)
          Takes a string an converts the whitespace which would be ignored in an HTML document into HTML elements so the whitespace is preserved
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

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

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

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 -

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)

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:

  • 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

    getKualiConfigurationService

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

    preserveWhitespace

    public static String preserveWhitespace(String startingString)
    Takes a string an converts the whitespace which would be ignored in an HTML document into HTML elements so the whitespace is preserved

    Parameters:
    startingString - The string to preserve whitespace in
    Returns:
    A string whose whitespace has been converted to HTML elements to preserve the whitespace in an HTML document


    Copyright © 2005-2012 The Kuali Foundation. All Rights Reserved.