log.info("Constructed.");
}
public void listener(UploadEvent event) throws Exception {
log.info("Got: "+event.getUploadItems());
UploadItem item = event.getUploadItem();
String filename = FileUploadBean.sanitizeFilename(item.getFileName());
log.info("File : '" + filename + "' was uploaded");
URI furi = null;
if (item.getFile() != null ) {
File file = item.getFile();
log.info("Absolute Path : '" + file.getAbsolutePath() + "'!");
log.info("Adding file to the Data Registry.");
try {
furi = dh.storeBytestream(new FileInputStream( file ) , filename );
} catch (FileNotFoundException e) {
log.error("File, FileNotFoundException: "+e);
e.printStackTrace();
} catch (IOException e) {
log.error("File, IOException: "+e);
e.printStackTrace();
}
} else if ( item.getData() != null ) {
furi = dh.storeBytearray(item.getData(), filename );
} else {
log.error("Upload failed: both Data and File are null!");
throw new Exception("Upload failed: both Data and File are null!");
}