@Override protected void onBeforeRemove(Video entity) { super.onBeforeRemove(entity); if (entity.getVideoFile() != null) { FileUtils.deleteQuietly( new File(AppConfig.getFileStorePath() + entity.getVideoFile().getId())); } }
@Override protected void onAfterPersist(Video entity) { super.onAfterPersist(entity); try { saveFile(entity.getVideoFile()); } catch (IOException ex) { getLogger().log(Level.SEVERE, "Error when save video file to the fileStore", ex); throw new EJBException("video.error.videoFile.storefile"); } }
@Override protected void onBeforeUpdate(Video entity) { super.onBeforeUpdate(entity); if (entity.getVideoFile() != null) { if (entity.getVideoFile().isHasFile()) { try { saveFile(entity.getVideoFile()); } catch (Exception e) { getLogger().log(Level.SEVERE, "Error when save video file to the fileStore", e); throw new EJBException("video.error.videoFile.storefile"); } } } }