psdi.webclient.system.controller

Class MPFormData

  • java.lang.Object
    • psdi.webclient.system.controller.MPFormData
  • Direct Known Subclasses:
    MPEncodedFormData


    public class MPFormData
    extends java.lang.Object
    • Constructor Summary

      Constructors 
      Constructor and Description
      MPFormData() 
      MPFormData(javax.servlet.http.HttpServletRequest req)
      creates a new MPFormData object and gets the request parameters the MPFormData object is used to retrieve parameters and data from multipart form submissions.
      MPFormData(javax.servlet.http.HttpServletRequest req, int maximumsize)
      Alternate constructor that gets it maximum file size from passed in parameters instead of the doclinks.properties file.
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method and Description
      java.lang.String getFileContentType()
      gets the file content type.
      java.lang.String getFileName()
      gets name of the file contained in the form.
      java.io.ByteArrayOutputStream getFileOutputStream()
      gets the output stream containing the file data
      java.io.ByteArrayOutputStream getFileOutputStreamForFile(java.lang.String fileName)
      gets the output stream containing the file data for a specific file name
      java.util.HashMap getFileParams()
      gets the file parameters of file
      java.util.HashMap getFileParamsForFile(java.lang.String fileName)
      gets the file parameters of file
      java.lang.String getFullFileName()
      gets FULL name (including path) of the file contained in the form.
      java.lang.String getParameter(java.lang.String param)
      gets a request parameter.
      boolean isParam(java.lang.String val)
      Returns true if the specified string is a parameter in the request
      static boolean isRequestMultipart(javax.servlet.http.HttpServletRequest req)
      checks to see if the content type of the request is "multipart/form-data"
      void processRequest() 
      protected void readAndKeep(psdi.webclient.system.controller.MPInputStreamHandler in, java.lang.String boundary, java.lang.String filename, java.lang.String contentType)
      A utility method that reads a single part of the multipart request that represents a file, and saves the data in the outputstream
      protected boolean readNextPart(psdi.webclient.system.controller.MPInputStreamHandler in, java.lang.String boundary)
      A utility method that reads an individual part for parameters.
      protected void readRequest(javax.servlet.http.HttpServletRequest request)
      the workhorse method that actually parses the request.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • MPFormData

        public MPFormData()
      • MPFormData

        public MPFormData(javax.servlet.http.HttpServletRequest req)
                   throws MXException
        creates a new MPFormData object and gets the request parameters the MPFormData object is used to retrieve parameters and data from multipart form submissions. this class MUST be used to retrieve parameters submitted from mutlipart forms since the HttpServletRequest.getParameter() will not work with multipart forms. when this class is constructed with an HttpServletRequest it will load a hashtable with all parameters passed in the multipart form and will fill an outputstream with any binary data (ie a file) contained on the form
        Throws:
        MXException
      • MPFormData

        public MPFormData(javax.servlet.http.HttpServletRequest req,
                          int maximumsize)
                   throws MXException
        Alternate constructor that gets it maximum file size from passed in parameters instead of the doclinks.properties file. Used when we do not want the maximum file size to be overridden. creates a new MPFormData object and gets the request parameters the MPFormData object is used to retrieve parameters and data from multipart form submissions. this class MUST be used to retrieve parameters submitted from mutlipart forms since the HttpServletRequest.getParameter() will not work with multipart forms. when this class is constructed with an HttpServletRequest it will load a hashtable with all parameters passed in the multipart form and will fill an outputstream with any binary data (ie a file) contained on the form
        Parameters:
        req - The HttpServletRequest
        maximumsize - The maximum file size in megabytes
        Throws:
        MXException
    • Method Detail

      • isRequestMultipart

        public static boolean isRequestMultipart(javax.servlet.http.HttpServletRequest req)
        checks to see if the content type of the request is "multipart/form-data"
        Parameters:
        HttpServletRequest - req
        Returns:
        boolean true if it is a multipart form, false otherwise
      • getParameter

        public java.lang.String getParameter(java.lang.String param)
        gets a request parameter. the method first checks to see if the parameter is present in the query string, and if not it checks the list of parameters contained in the multipart/form-data
      • isParam

        public boolean isParam(java.lang.String val)
        Returns true if the specified string is a parameter in the request
      • getFileName

        public java.lang.String getFileName()
        gets name of the file contained in the form. empty if there is no file
      • getFullFileName

        public java.lang.String getFullFileName()
        gets FULL name (including path) of the file contained in the form. empty if there is no file (026094)
      • getFileContentType

        public java.lang.String getFileContentType()
        gets the file content type. empty if there is no file
      • getFileOutputStream

        public java.io.ByteArrayOutputStream getFileOutputStream()
        gets the output stream containing the file data
      • getFileOutputStreamForFile

        public java.io.ByteArrayOutputStream getFileOutputStreamForFile(java.lang.String fileName)
        gets the output stream containing the file data for a specific file name
        Parameters:
        fileName - the name of the file to retrieve the contents
      • getFileParams

        public java.util.HashMap getFileParams()
        gets the file parameters of file
      • getFileParamsForFile

        public java.util.HashMap getFileParamsForFile(java.lang.String fileName)
        gets the file parameters of file
        Parameters:
        fileName - the name of the file to retrieve the parameters
      • readRequest

        protected void readRequest(javax.servlet.http.HttpServletRequest request)
                            throws java.io.IOException,
                                   MXException
        the workhorse method that actually parses the request.
        Throws:
        java.io.IOException - if the uploaded content is larger than maxSize or there's a problem parsing the request
        MXException
      • readNextPart

        protected boolean readNextPart(psdi.webclient.system.controller.MPInputStreamHandler in,
                                       java.lang.String boundary)
                                throws java.io.IOException
        A utility method that reads an individual part for parameters.
        Parameters:
        in - the stream from which to read the part
        boundary - the boundary separating parts
        Returns:
        a flag indicating whether this is the last part
        Throws:
        java.io.IOException - if there's a problem reading or parsing the request
      • readAndKeep

        protected void readAndKeep(psdi.webclient.system.controller.MPInputStreamHandler in,
                                   java.lang.String boundary,
                                   java.lang.String filename,
                                   java.lang.String contentType)
                            throws java.io.IOException
        A utility method that reads a single part of the multipart request that represents a file, and saves the data in the outputstream
        Parameters:
        in - the stream from which to read the file data
        boundary - the boundary signifying the end of this part
        filename - the name of the uploaded file
        contentType - the content type of the file
        Throws:
        java.io.IOException - if there's a problem reading or parsing the request