Exemplo n.º 1
0
 @CommitAfter
 public void onSuccess() {
   File copied = new File(worksheetDirectory + file.getFileName());
   file.write(copied);
   bib.setWorksheet(file.getFileName());
   bib.setWorksheetExists(true);
   session.saveOrUpdate(bib);
   message = "Done.  Uploaded : " + file.getFileName() + " in BIB: " + bib.getName();
 }
Exemplo n.º 2
0
  public void onSuccessFromUploadFile() {

    File tempFile = new File(System.getProperty("user.dir"), file.getFileName());

    file.write(tempFile);

    tempFile = new File(System.getProperty("user.dir"), file2.getFileName());
    file2.write(tempFile);
  }
Exemplo n.º 3
0
  @SuppressWarnings({"unchecked"})
  @Override
  protected void processSubmission(String controlName) {
    UploadedFile uploaded = decoder.getFileUpload(controlName);

    if (uploaded != null
        && (uploaded.getFileName() == null || uploaded.getFileName().length() == 0)) {
      uploaded = null;
    }

    try {
      fieldValidationSupport.validate(uploaded, resources, validate);
    } catch (ValidationException ex) {
      validationTracker.recordError(this, ex.getMessage());
    }

    value = uploaded;
  }
Exemplo n.º 4
0
 /**
  * @param uploadedFile
  * @return
  * @throws IOException
  */
 private byte[] generateBytesFromUploadedFile(UploadedFile uploadedFile) throws IOException {
   InputStream is = uploadedFile.getStream();
   ByteArrayOutputStream bos = new ByteArrayOutputStream();
   byte[] b = new byte[1024];
   int bytesRead = 0;
   while ((bytesRead = is.read(b)) != -1) {
     bos.write(b, 0, bytesRead);
   }
   byte[] bytes = bos.toByteArray();
   logger.info("Bytes : " + bytes.length);
   return bytes;
 }