@Override public void uploadSucceeded(SucceededEvent event) { boolean succeeded = true; try { processCertificateFile(); log.info("=============== Upload certificate succeeded"); repaintUpload(); } catch (Exception ex) { succeeded = false; log.error("=============== Failed to upload certificate", ex); ViewUtil.iscNotification("SSL certificate upload failed. " + ex.getMessage() + " Please use a valid certificate file", Notification.Type.ERROR_MESSAGE); repaintUpload(); } if(this.uploadNotifier != null){ this.uploadNotifier.finishedUpload(succeeded); } }
@SuppressWarnings("serial") private SucceededListener getUploadSucceededListener() { return new SucceededListener() { @Override public void uploadSucceeded(SucceededEvent event) { log.info("Upload Successful! Analyzing Uploaded Image....."); final ProgressIndicatorWindow progressIndicatorWindow = new ProgressIndicatorWindow(); progressIndicatorWindow.setWidth("200px"); progressIndicatorWindow.setHeight("100px"); progressIndicatorWindow.setCaption("Processing image ..."); UI.getCurrent().addWindow(progressIndicatorWindow); progressIndicatorWindow.bringToFront(); Runnable serviceCall = uploadValidationService(progressIndicatorWindow, event); ScheduledExecutorService exec = Executors.newScheduledThreadPool(1); exec.schedule(serviceCall, 1, TimeUnit.MILLISECONDS); } }; }
@Test public void test() { FUpload upload = new FUpload().withButtonCaption("file") .withImmediateMode(false) .withFailedListener(event -> System.out.println("failed")) .withFinishedListener(event -> System.out.println("finished")) .withChangeListener(event -> System.out.println("changed")) .withSucceededListener(event -> System.out.println("succeeded")) .withProgressListener((readBytes, contentLength) -> System.out.println("progress")); assertEquals("file", upload.getButtonCaption()); assertFalse(upload.isImmediateMode()); assertEquals(1, upload.getListeners(FailedEvent.class).size()); assertTrue(upload.getListeners(FinishedEvent.class).size() > 0); assertEquals(1, upload.getListeners(ChangeEvent.class).size()); assertEquals(1, upload.getListeners(SucceededEvent.class).size()); assertEquals(1, upload.getListeners(StreamingProgressEvent.class).size()); }
@Override public void uploadSucceeded(SucceededEvent event) { try { /* Close the stream and save the file information */ rfos.close(); uploadedFiles.addItem(filename); fileNames.add(filename); mimeTypes.add(mimeType); remove.setEnabled(true); } catch (IOException e) { e.printStackTrace(); } finally { R.releaseRConnection(); rc = null; } }
@Override public void uploadSucceeded(SucceededEvent event) { if (logger.isDebugEnabled()) { logger.debug("upload succeeded"); } this.succeeded = true; this.close(); }
@Override public void uploadSucceeded(SucceededEvent event) { image = baos.toByteArray(); StreamResource.StreamSource imagesource = new UserImageSource(image); StreamResource resource = new StreamResource(imagesource, filename); userImage.setSource(resource); }
/** * * Upload sucessfull for {@link Upload} variant. * * @see com.vaadin.ui.Upload.SucceededListener#uploadSucceeded(com.vaadin.ui.Upload.SucceededEvent) */ @Override public void uploadSucceeded(final SucceededEvent event) { LOG.debug("Streaming finished for file :{}", event.getFilename()); eventBus.publish(this, new UploadStatusEvent(UploadStatusEventType.UPLOAD_SUCCESSFUL, new UploadFileStatus(event.getFilename(), 0, event.getLength(), selectedSwForUpload))); }
private void initComponents() { uploadLabel = new Label("<b>Upload Logo", ContentMode.HTML); System.out.println(controller.getFolderPath()); uploadComponent = new UploadComponent("Upload logo", sessionId, 1000000, controller.getFolderPath()) { @Override public void uploadSucceeded(SucceededEvent event) { invoiceBean.getBean().setLogoImageFilePath(getFile().getAbsolutePath()); } }; }
public void uploadSucceeded(SucceededEvent event) { // transform file to byte array fileArray = getFile(file); try { // save the new file in database attachmentService.save(new Attachment(entityName, entityId, fileName, textAreaFile.getValue().toString(), fileArray)); // refresh getEntities(); } catch (Exception e) { throw new RuntimeException("¡No se pudo adjuntar el fichero seleccionado!", e); } }
public void uploadSucceeded(SucceededEvent event) { // Is this the right way to test if it's a zip file?? if (ZIP_MIMETYPES.contains(event.getMIMEType())) { ui.uploadProject(file); } else { Notification.show("Not a zip file. The mimetype is " +event.getMIMEType()); } }
public void uploadSucceeded(SucceededEvent event) { this.customFile = fileController.createFileFromUpload(file,event.getMIMEType(),event.getFilename(),event.getLength(),this.typeFichier, this.prefixe, this.candidature, this.commune); }
private Runnable uploadValidationService(final ProgressIndicatorWindow progressIndicatorWindow, final SucceededEvent event) { return new Runnable() { @Override public void run() { // Make service calls in the UI thread, since the calls will update the UI components UI.getCurrent().access(new Runnable() { @Override public void run() { String zipfile = ImportApplianceSoftwareVersionWindow.this.uploader.getUploadPath() + event.getFilename(); try { // Do the unzip only if there is enough disc space if (!ImportApplianceSoftwareVersionWindow.this.server.isEnoughSpace()) { throw new VmidcException(VmidcMessages.getString("upload.appliance.nospace")); } if (!FilenameUtils.getExtension(event.getFilename()).equals("zip")) { throw new VmidcException(VmidcMessages .getString(VmidcMessages_.UPLOAD_APPLIANCE_FAILED)); } ImportApplianceSoftwareVersionWindow.this.archiver.unzip(zipfile, ImportApplianceSoftwareVersionWindow.this.uploader.getUploadPath()); // After extraction, we don't need the zip file. Delete the zip file log.info("Delete temporary uploaded zip file after extraction " + zipfile); new File(zipfile).delete(); addApplianceImage(); ViewUtil.iscNotification( VmidcMessages.getString(VmidcMessages_.UPLOAD_APPLIANCE_SUCCESSFUL), null, Notification.Type.TRAY_NOTIFICATION); close(); } catch (Exception e) { log.error("Failed to process uploaded zip file", e); try { FileUtils.deleteDirectory(new File(ImportApplianceSoftwareVersionWindow.this.uploader .getUploadPath())); } catch (IOException ex) { log.error("Failed to cleanup the tmp directory", ex); } ViewUtil.iscNotification(e.getMessage(), Notification.Type.ERROR_MESSAGE); } finally { log.info("Deleting file " + zipfile); new File(zipfile).delete(); progressIndicatorWindow.close(); } } }); } }; }
@Override public void uploadSucceeded(final SucceededEvent event) { close(); }
@Override public void uploadSucceeded(final SucceededEvent event) { result.setValue(counter.getLineBreakCount() + " (total)"); }
@Override public void uploadSucceeded(SucceededEvent event) { this.filename = event.getFilename(); this.close(); }
@Override public void uploadSucceeded(final SucceededEvent event) { uiExecutor.execute(new UploadAsync()); }
public void uploadSucceeded(SucceededEvent event) { jImage.updateImage(stream.toByteArray(), event.getFilename()); super.uploadSucceeded(event); }
public void uploadSucceeded(SucceededEvent event) { pi.setVisible(false); upload.setVisible(true); }
@Override public void uploadSucceeded(SucceededEvent event) { importXml(new String(uploadedData.toByteArray())); }
public void uploadSucceeded(SucceededEvent event) { // transform file to byte array groupDateFile = getFile(file); }
public void uploadSucceeded(SucceededEvent event) { embeddedImage.setSource(new FileResource(file, application)); image = getImage(file); }
public void uploadSucceeded(SucceededEvent event) { // transform file to byte array groupDateFile = getFileArray(file); getParent().removeWindow(UploadViewForm.this); }
@Override public void uploadSucceeded(SucceededEvent event) { // From upload. addImage(targetFile); }
public CanvasImport(){ VerticalLayout canvasImportLayout = new VerticalLayout(); canvasImportLayout.setMargin(true); setContent(canvasImportLayout); uploader=new NavigatorFileUpload("Upload"){ @Override public void uploadFailed(FailedEvent failedEvent){ reportMessage("Upload failed"); } @Override public void uploadSucceeded(SucceededEvent succeededEvent){ File file=getUploadedFile(); String format=theCanvas.getImportFormatShortFormat((String)importTypes.getValue()); try{ theCanvas.theDoc.importFrom(file.getPath(), format); }catch(Exception ex){ reportMessage("Wrong format or invalid content"); } if(LogUtils.hasLastError()){ reportMessage("Wrong format or invalid content"); } LogUtils.clearLastError(); if(file.delete()==false){ reportException(new Exception("Unable to delete file: "+file.getPath())); } removeLocalResource(file); } @Override public void uploadFailed(Message msg){ reportMessage(msg.getMessage()); } }; uploader.setLocalResourceWatchers(localResourceWatchers); List<String> importTypeList=theCanvas.getImportFormats(); importTypes=new ListSelect("Format", importTypeList); importTypes.setNullSelectionAllowed(false); importTypes.setValue(importTypeList.get(0)); canvasImportLayout.addComponent(importTypes); canvasImportLayout.addComponent(uploader.getUploadComponent()); }
public void uploadSucceeded(SucceededEvent event) { UI.getCurrent().removeWindow(this); }
@Override public void uploadSucceeded(SucceededEvent event) { long initTime = System.currentTimeMillis(); log.debug("Comienza a guardar el archivo: " + this.fileName); CoreParametroAplicacion coreParam = new CoreParametroAplicacion(); String PATH_NOMINA = coreParam.findParametroAplicacion("PATH_NOMINA"); try { File archivo = new File(PATH_NOMINA + this.fileName); FileOutputStream fileOut = new FileOutputStream(archivo); for (Iterator iterator = archivoLeido.iterator(); iterator .hasNext();) { Character character = (Character) iterator.next(); fileOut.write(character); } fileOut.flush(); fileOut.close(); } catch (IOException e) { log.error(e.getMessage() + " - " + e.getLocalizedMessage(), e); } log.info("finaliza metodo uploadSucceeded en " + (System.currentTimeMillis() - initTime)+ " ms"); }
public abstract void uploadSucceeded(SucceededEvent succeededEvent);