001: /* *************************************************************************
002:
003: Millstone(TM)
004: Open Sourced User Interface Library for
005: Internet Development with Java
006:
007: Millstone is a registered trademark of IT Mill Ltd
008: Copyright (C) 2000-2005 IT Mill Ltd
009:
010: *************************************************************************
011:
012: This library is free software; you can redistribute it and/or
013: modify it under the terms of the GNU Lesser General Public
014: license version 2.1 as published by the Free Software Foundation.
015:
016: This library is distributed in the hope that it will be useful,
017: but WITHOUT ANY WARRANTY; without even the implied warranty of
018: MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
019: Lesser General Public License for more details.
020:
021: You should have received a copy of the GNU Lesser General Public
022: License along with this library; if not, write to the Free Software
023: Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
024:
025: *************************************************************************
026:
027: For more information, contact:
028:
029: IT Mill Ltd phone: +358 2 4802 7180
030: Ruukinkatu 2-4 fax: +358 2 4802 7181
031: 20540, Turku email: info@itmill.com
032: Finland company www: www.itmill.com
033:
034: Primary source for MillStone information and releases: www.millstone.org
035:
036: ********************************************************************** */
037:
038: package org.millstone.webadapter;
039:
040: import java.io.IOException;
041:
042: import javax.servlet.http.HttpServletRequest;
043:
044: /** This class wraps the MultipartRequest class by Jason Pell
045: * for the Servlet environment.
046: *
047: * @author IT Mill Ltd
048: * @version 3.1.1
049: * @since 3.0
050: */
051: public class ServletMultipartRequest extends MultipartRequest {
052: /**
053: * Constructor wrapper, unwraps the InputStream,
054: * content type and content lenght from the servlet request object.
055: *
056: * @param request The HttpServletRequest will be used to initialise the MultipartRequest super class.
057: * @param strSaveDirectory The temporary directory to save the file from where they can then be moved to wherever by the
058: * calling process. <b>If you specify <u>null</u> for this parameter, then any files uploaded
059: * will be silently ignored.</B>
060: *
061: * @exception IllegalArgumentException If the request.getContentType() does not contain a Content-Type of "multipart/form-data" or the boundary is not found.
062: * @exception IOException If the request.getContentLength() is higher than MAX_READ_BYTES or strSaveDirectory is invalid or cannot be written to.
063: *
064: * @see MultipartRequest#MAX_READ_BYTES
065: */
066: public ServletMultipartRequest(HttpServletRequest request,
067: String strSaveDirectory) throws IllegalArgumentException,
068: IOException {
069: super (null, request.getContentType(), request
070: .getContentLength(), request.getInputStream(),
071: strSaveDirectory, MultipartRequest.MAX_READ_BYTES);
072: }
073:
074: /**
075: * Constructor wrapper, unwraps the InputStream,
076: * content type and content lenght from the servlet request object.
077: * Also allow to explicitly set the max permissable lenght of the request.
078: *
079: * @param request The HttpServletRequest will be used to initialise the MultipartRequest super class.
080: * @param strSaveDirectory The temporary directory to save the file from where they can then be moved to wherever by the
081: * calling process. <b>If you specify <u>null</u> for this parameter, then any files uploaded
082: * will be silently ignored.</B>
083: * @param intMaxReadBytes Overrides the MAX_BYTES_READ value, to allow arbitrarily long files.
084: *
085: * @exception IllegalArgumentException If the request.getContentType() does not contain a Content-Type of "multipart/form-data" or the boundary is not found.
086: * @exception IOException If the request.getContentLength() is higher than MAX_READ_BYTES or strSaveDirectory is invalid or cannot be written to.
087: *
088: * @see MultipartRequest#MAX_READ_BYTES
089: */
090: public ServletMultipartRequest(HttpServletRequest request,
091: String strSaveDirectory, int intMaxReadBytes)
092: throws IllegalArgumentException, IOException {
093: super (null, request.getContentType(), request
094: .getContentLength(), request.getInputStream(),
095: strSaveDirectory, intMaxReadBytes);
096: }
097:
098: /**
099: * Constructor wrapper for loading the request into memory rather than temp-file.
100: *
101: * @param request The HttpServletRequest will be used to initialise the MultipartRequest super class.
102: * @param intMaxReadBytes Overrides the MAX_BYTES_READ value, to allow arbitrarily long files.
103: *
104: * @exception IllegalArgumentException If the request.getContentType() does not contain a Content-Type of "multipart/form-data" or the boundary is not found.
105: * @exception IOException If the request.getContentLength() is higher than MAX_READ_BYTES or strSaveDirectory is invalid or cannot be written to.
106: *
107: * @see MultipartRequest#MAX_READ_BYTES
108: */
109: public ServletMultipartRequest(HttpServletRequest request,
110: int intMaxReadBytes) throws IllegalArgumentException,
111: IOException {
112: super(null, request.getContentType(), request
113: .getContentLength(), request.getInputStream(),
114: intMaxReadBytes);
115: }
116: }
|