@Transactional(propagation=Propagation.REQUIRED)
private void update() {
debug();
this.thumbnailFolder.mkdirs();
final FileDomain fd = this.fsDao.getFile(this.fileId);
final DidlDomain dd = fd.getDidl();
File screenshot = new File(this.tempFolder, "00000001.jpg");
long max_size = 0l;
final File[] fileList = this.tempFolder.listFiles();
if (fileList != null) {
for (final File sf : this.tempFolder.listFiles()) {
if (sf.length() > max_size) {
screenshot = sf;
max_size = sf.length();
}
}
} else {
logger.error("for soem reason the tempfolder " + this.tempFolder.getAbsolutePath() + " does not exist anymore, this is odd!");
}
try {
if (screenshot.exists()) {
final String type = "jpg";
final File thumbnailFile = new File(this.thumbnailFolder,dd.getId().concat(".").concat(type) );
if (thumbnailFile.exists()) {
// replace it
FileUtils.forceDelete(thumbnailFile);
}
// ThumbnailDomain thumb = resizeImageTo(160f, type, thumbnailFile, screenshot);
final ThumbnailDomain thumb = moveImageTo(type, thumbnailFile, screenshot);
logger.info("update add thumb for [" + dd.getId() + "]");
dd.setThumbnail(thumb);
dd.increaseUpdateId();
dd.setGenerateThumbnail(false);
this.fsDao.store(fd);
} else {
if (this.out.toString().contains("Stream not seekable!") && ((dd.getSeekable() == null) || dd.getSeekable().booleanValue())) {
dd.setSeekable(false);
this.didlDao.store(dd);
} else {
dd.setGenerateThumbnail(false);
this.didlDao.store(dd);
logger.error("update add thumb for [" + dd.getId() + "] failed, no thumbnail created in " + this.tempFolder.getAbsolutePath());
logger.error("errors : \n" + this.err.toString());
logger.error("console : \n" + this.out.toString());
}
}
} catch (final IOException e) {