Search in sources :

Example 1 with MultipartExceededException

use of org.lastaflute.web.ruts.multipart.exception.MultipartExceededException in project fess by codelibs.

the class FessMultipartRequestHandler method handleSizeLimitExceededException.

protected void handleSizeLimitExceededException(final HttpServletRequest request, final SizeLimitExceededException e) {
    final long actual = e.getActualSize();
    final long permitted = e.getPermittedSize();
    final String msg = "Exceeded size of the multipart request: actual=" + actual + " permitted=" + permitted;
    request.setAttribute(MAX_LENGTH_EXCEEDED_KEY, new MultipartExceededException(msg, actual, permitted, e));
    try {
        final InputStream is = request.getInputStream();
        try {
            final byte[] buf = new byte[1024];
            while ((is.read(buf)) != -1) {
            }
        } catch (final Exception ignored) {
        } finally {
            try {
                is.close();
            } catch (final Exception ignored) {
            }
        }
    } catch (final Exception ignored) {
    }
}
Also used : InputStream(java.io.InputStream) MultipartExceededException(org.lastaflute.web.ruts.multipart.exception.MultipartExceededException) ServletException(javax.servlet.ServletException) MultipartExceededException(org.lastaflute.web.ruts.multipart.exception.MultipartExceededException) SizeLimitExceededException(org.apache.commons.fileupload.FileUploadBase.SizeLimitExceededException) Forced404NotFoundException(org.lastaflute.web.exception.Forced404NotFoundException) IOException(java.io.IOException) FileUploadException(org.apache.commons.fileupload.FileUploadException)

Aggregations

IOException (java.io.IOException)1 InputStream (java.io.InputStream)1 ServletException (javax.servlet.ServletException)1 SizeLimitExceededException (org.apache.commons.fileupload.FileUploadBase.SizeLimitExceededException)1 FileUploadException (org.apache.commons.fileupload.FileUploadException)1 Forced404NotFoundException (org.lastaflute.web.exception.Forced404NotFoundException)1 MultipartExceededException (org.lastaflute.web.ruts.multipart.exception.MultipartExceededException)1