Basically I have been using Vaadin Designer to design my UI. One of my use cases asks me to upload an iCalendar file, I use a grammar (ANTLR) to get from it what I need. I came across my issue when after seeing the Vaadin Upload documentation and applying it to my use case when running it, nothing would happen and no exception would be thrown. After a bit of research and debugging I believe this is due to the Thread for the upload being shutdown for some reason.
Here is my code, any help?
private void uploadLogic() {
class IcalendarUploader implements Upload.Receiver, Upload.SucceededListener, Upload.FinishedListener, Upload.FailedListener {
@Override
public OutputStream receiveUpload(String filename, String mimeType) {
try {
//We'll store the uploadad file as temporary file.
tempFile = File.createTempFile("temp", ".ics");
fos = new FileOutputStream(tempFile);
} catch (IOException e) {
Notification.show(e.getMessage(), Notification.Type.WARNING_MESSAGE);
return null;
}
}
@Override
public void uploadFinished(Upload.FinishedEvent event) {
try {
controller.importIcalendar(tempFile);
tempFile.delete();
Notification.show("Uploaded iCalendar file with :\n" + controller.iCalendarDetails(),
Notification.Type.HUMANIZED_MESSAGE);
} catch (IOException e) {
Notification.show(e.getMessage(), Notification.Type.WARNING_MESSAGE);
}
}
@Override
public void uploadSucceeded(Upload.SucceededEvent event) {
try {
if(controller.saveTimeSlot()){
Notification.show("Uploaded iCalendar file with :\n" + controller.iCalendarDetails()
+"\nSaved time slot with success",
Notification.Type.HUMANIZED_MESSAGE);
}else {
Notification.show("Uploaded iCalendar file with :\n" + controller.iCalendarDetails()
+ "\nTime slot has an overlapp!",
Notification.Type.WARNING_MESSAGE);
}
} catch (DataConcurrencyException e) {
Notification.show(e.getMessage(), Notification.Type.WARNING_MESSAGE);
} catch (DataIntegrityViolationException e) {
Notification.show(e.getMessage(), Notification.Type.WARNING_MESSAGE);
}
}
@Override
public void uploadFailed(Upload.FailedEvent event) {
Notification.show("Upload failed", Notification.Type.ERROR_MESSAGE);
}
}
IcalendarUploader receiver = new IcalendarUploader();
upload.setReceiver(receiver);
}