Package org.apache.commons.fileupload

Examples of org.apache.commons.fileupload.FileUploadException


            } else {
                /*
                 * For whatever reason we cannot write the
                 * file to disk.
                 */
                throw new FileUploadException(
                    "Cannot write uploaded file to disk!");
            }
        }
    }
View Full Code Here


        {
            throw (FileUploadException) e.getCause();
        }
        catch (IOException e)
        {
            throw new FileUploadException(e.getMessage(), e);
        }
    }
View Full Code Here

        {
            throw (FileUploadException) e.getCause();
        }
        catch (IOException e)
        {
            throw new FileUploadException(e.getMessage(), e);
        }
    }
View Full Code Here

            } else {
                /*
                 * For whatever reason we cannot write the
                 * file to disk.
                 */
                throw new FileUploadException(
                    "Cannot write uploaded file to disk!");
            }
        }
    }
View Full Code Here

            }
            String ext = fileExt(filename);
            if( !ICON_FORMATS.containsKey(ext)){
                String msg = "Icon "+filename+" format "+ext+" unsupported - try:"+ICON_FORMATS.keySet();
                LOG.warning(msg);
                throw new FileUploadException(msg);
            }
            try {
                InputStream data = file.getInputStream();               
                Resources.copy(data, styles, filename);

                icon(created.addObject(), ws, styles.get(filename), request);
            } catch (Exception e) {
                throw new FileUploadException("Unable to write "+filename,e);
            }
        }

        return created;
    }
View Full Code Here

        if (!(exception instanceof FileUploadException)) {
            return;
        }

        FileUploadException fue = (FileUploadException) exception;

        String key = null;
        Object args[] = null;

        if (fue instanceof SizeLimitExceededException) {
            SizeLimitExceededException se =
                (SizeLimitExceededException) fue;

            key = "post-size-limit-exceeded-error";

            args = new Object[2];
            args[0] = se.getPermittedSize();
            args[1] = se.getActualSize();
            setError(getMessage(key, args));

        } else if (fue instanceof FileSizeLimitExceededException) {
            FileSizeLimitExceededException fse =
                (FileSizeLimitExceededException) fue;

            key = "file-size-limit-exceeded-error";

            // Parse the FileField name from the message
            String msg = fue.getMessage();
            int start = 10;
            int end = msg.indexOf(' ', start);
            String fieldName = fue.getMessage().substring(start, end);

            args = new Object[3];
            args[0] = ClickUtils.toLabel(fieldName);
            args[1] = fse.getPermittedSize();
            args[2] = fse.getActualSize();
View Full Code Here

                }
            } else {
                /*
                 * For whatever reason we cannot write the file to disk.
                 */
                throw new FileUploadException("Cannot write uploaded file to disk!");
            }
        }
    }
View Full Code Here

                }
            } else {
                /*
                 * For whatever reason we cannot write the file to disk.
                 */
                throw new FileUploadException("Cannot write uploaded file to disk!");
            }
        }
    }
View Full Code Here

  @Override
  public UploadedFile getUploadedFile(Exception e) {

    UploadedFile uploadedFile = null;
    FileUploadException fileUploadException = null;

    if (e instanceof FileUploadException) {
      fileUploadException = (FileUploadException) e;
    }

    if (e instanceof FileUploadIOException) {
      Throwable causeThrowable = e.getCause();

      if (causeThrowable instanceof FileUploadException) {
        fileUploadException = (FileUploadException) causeThrowable;
      }
    }

    if (fileUploadException != null) {

      if (fileUploadException instanceof SizeLimitExceededException) {
        uploadedFile = new UploadedFileErrorImpl(fileUploadException.getMessage(),
            UploadedFile.Status.REQUEST_SIZE_LIMIT_EXCEEDED);
      }
      else if (fileUploadException instanceof FileSizeLimitExceededException) {
        uploadedFile = new UploadedFileErrorImpl(fileUploadException.getMessage(),
            UploadedFile.Status.FILE_SIZE_LIMIT_EXCEEDED);
      }
      else {
        uploadedFile = new UploadedFileErrorImpl(fileUploadException.getMessage());
      }
    }
    else {
      uploadedFile = new UploadedFileErrorImpl(e.getMessage());
    }
View Full Code Here

  @Test
  public void doNothingWhenFileUploadExceptionOccurs() throws Exception {
    when(event.getMethod()).thenReturn(uploadMethodController);

    when(observer.createServletFileUpload(config)).thenReturn(servletFileUpload);
    when(servletFileUpload.parseRequest(request)).thenThrow(new FileUploadException());

    observer.upload(event, request, config, validator);
  }
View Full Code Here

TOP

Related Classes of org.apache.commons.fileupload.FileUploadException

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.