Class MultipartRequestWrapper

  • All Implemented Interfaces:
    javax.servlet.http.HttpServletRequest, javax.servlet.ServletRequest

    public class MultipartRequestWrapper
    extends javax.servlet.http.HttpServletRequestWrapper
    Wraps a multipart HTTP request, and pre-parses it for file uploads, without losing the request parameters. Parsing through the request with an Apache ServletFileUpload builds a list of FileItems that includes the parameters and the file parts. After that, however, the parameters are no longer accessible from the request. This wrapper will see that they don't get lost. The List of FileItems includes both "formField" items and "file" items. As with the usual parameters on a request, we can have more than one value with the same name. So this creates a map of <String, List<String>> to hold the parameters, and a map of <String, List<FileItem>> to hold the files. The parameters will be available to the wrapper through the normal methods. The files will be available as an attribute that holds the map. Also, a separate attribute will hold a Boolean to indicate that this was indeed a multipart request. Conveninence methods in VitroRequest will make these easy to handle, without actually touching the attributes.
    • Constructor Summary

      Constructors 
      Constructor Description
      MultipartRequestWrapper​(javax.servlet.http.HttpServletRequest req, edu.cornell.mannlib.vitro.webapp.controller.MultipartRequestWrapper.ListsMap<String> parameters, edu.cornell.mannlib.vitro.webapp.controller.MultipartRequestWrapper.ListsMap<org.apache.commons.fileupload.FileItem> files)  
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      String getParameter​(String name)
      Look in the map of parsed parameters.
      Map<String,​String[]> getParameterMap()
      Make a copy of the map of parsed parameters;
      Enumeration<String> getParameterNames()
      Look in the map of parsed parameters.
      String[] getParameterValues​(String name)
      Look in the map of parsed parameters.
      static javax.servlet.http.HttpServletRequest parse​(javax.servlet.http.HttpServletRequest req, MultipartRequestWrapper.ParsingStrategy strategy)
      If this is a multipart request, wrap it.
      • Methods inherited from class javax.servlet.http.HttpServletRequestWrapper

        getAuthType, getContextPath, getCookies, getDateHeader, getHeader, getHeaderNames, getHeaders, getIntHeader, getMethod, getPathInfo, getPathTranslated, getQueryString, getRemoteUser, getRequestedSessionId, getRequestURI, getRequestURL, getServletPath, getSession, getSession, getUserPrincipal, isRequestedSessionIdFromCookie, isRequestedSessionIdFromUrl, isRequestedSessionIdFromURL, isRequestedSessionIdValid, isUserInRole
      • Methods inherited from class javax.servlet.ServletRequestWrapper

        getAttribute, getAttributeNames, getCharacterEncoding, getContentLength, getContentType, getInputStream, getLocalAddr, getLocale, getLocales, getLocalName, getLocalPort, getProtocol, getReader, getRealPath, getRemoteAddr, getRemoteHost, getRemotePort, getRequest, getRequestDispatcher, getScheme, getServerName, getServerPort, isSecure, removeAttribute, setAttribute, setCharacterEncoding, setRequest
      • Methods inherited from interface javax.servlet.ServletRequest

        getAttribute, getAttributeNames, getCharacterEncoding, getContentLength, getContentType, getInputStream, getLocalAddr, getLocale, getLocales, getLocalName, getLocalPort, getProtocol, getReader, getRealPath, getRemoteAddr, getRemoteHost, getRemotePort, getRequestDispatcher, getScheme, getServerName, getServerPort, isSecure, removeAttribute, setAttribute, setCharacterEncoding
    • Field Detail

      • ATTRIBUTE_IS_MULTIPART

        public static final String ATTRIBUTE_IS_MULTIPART
      • ATTRIBUTE_FILE_ITEM_MAP

        public static final String ATTRIBUTE_FILE_ITEM_MAP
      • ATTRIBUTE_FILE_SIZE_EXCEPTION

        public static final String ATTRIBUTE_FILE_SIZE_EXCEPTION
    • Constructor Detail

      • MultipartRequestWrapper

        public MultipartRequestWrapper​(javax.servlet.http.HttpServletRequest req,
                                       edu.cornell.mannlib.vitro.webapp.controller.MultipartRequestWrapper.ListsMap<String> parameters,
                                       edu.cornell.mannlib.vitro.webapp.controller.MultipartRequestWrapper.ListsMap<org.apache.commons.fileupload.FileItem> files)
    • Method Detail

      • getParameter

        public String getParameter​(String name)
        Look in the map of parsed parameters.
        Specified by:
        getParameter in interface javax.servlet.ServletRequest
        Overrides:
        getParameter in class javax.servlet.ServletRequestWrapper
      • getParameterNames

        public Enumeration<String> getParameterNames()
        Look in the map of parsed parameters. Make a protective copy.
        Specified by:
        getParameterNames in interface javax.servlet.ServletRequest
        Overrides:
        getParameterNames in class javax.servlet.ServletRequestWrapper
      • getParameterValues

        public String[] getParameterValues​(String name)
        Look in the map of parsed parameters.
        Specified by:
        getParameterValues in interface javax.servlet.ServletRequest
        Overrides:
        getParameterValues in class javax.servlet.ServletRequestWrapper
      • getParameterMap

        public Map<String,​String[]> getParameterMap()
        Make a copy of the map of parsed parameters;
        Specified by:
        getParameterMap in interface javax.servlet.ServletRequest
        Overrides:
        getParameterMap in class javax.servlet.ServletRequestWrapper