@Transactional public void remove( User user, Long authorSid ) throws IOException { MDOAuthor author = daoAuthor.get( user.getLogin(), authorSid ); if ( author != null ) { String path = author.calculateAbsolutePath( daoSettings.getSettings() ); daoAuthor.remove( author ); FileUtils.deleteDirectory( new File( path ) ); } }
@Transactional public boolean remove( User user, Long albumSid ) throws IOException { MDOAlbum album = this.daoAlbum.getAlbum( albumSid, user.getLogin() ); if ( album != null ) { MDOAuthor author = album.getAuthor(); if ( author.getAlbums().size() <= 1 ) { File fpath = new File( author.calculateAbsolutePath( daoSettings.getSettings() ) ); FileUtils.deleteDirectory( fpath ); // after, removing the author data from database daoAuthor.remove( album.getAuthor() ); return true; } else { // first, removing the album folder File fpath = new File( album.calculateAbsolutePath( daoSettings.getSettings() ) ); FileUtils.deleteDirectory( fpath ); // after, removing the album data from database this.daoAlbum.remove( album ); return false; } } return false; }
daoAuthor.remove( oldAuthor ); String oldAuthorPath = oldAuthor.calculateAbsolutePath( daoSettings.getSettings() ); FileUtils.deleteDirectory( new File( oldAuthorPath ) );