/** * Return the list of names of users that allow DLNA share content * * @return */ public List<MDOUser> getDLNAUsers() { List<MDOUser> users = this.daoUsers.getDLNAUsers(); return users; }
/** * Check if DLNA service is allowed by any users. * * @return true->yes, its allowed at least by one user */ public boolean isAnyUserAllowed() { return ( this.daoUsers.countAllowedDLNAUsers() > 0 ); }
/** * Check if the userName is valid to create a new user... it must be unique, so the username must not exist * * @param userName {@link String} username to check * @return boolean true->is valid, false->not valid! */ public boolean validateNewUserName( String userName ) { MDOUser mdoUser = daoUser.getUserByLogin( userName ); if ( mdoUser == null ) { return true; } else { return false; } }
public long fuseGenres( User user, List<Long> genreSids, String newGenreName ) { MDOUser mdouser = daoUser.getUserByLogin( user.getLogin() ); // 1st, creating the new genre MDOGenre newGenre = new MDOGenre( newGenreName, mdouser ); daoGenre.save( newGenre ); for ( int i = 0; i < genreSids.size(); i++ ) { // second, replacing current genre by the new one MDOGenre genre = this.daoGenre.getGenre( user.getLogin(), genreSids.get( i ) ); List<MDOAlbum> albums = this.daoAlbum.getAll( user.getLogin(), genre ); for ( MDOAlbum mdoAlbum : albums ) { mdoAlbum.setGenre( newGenre ); daoAlbum.save( mdoAlbum ); } // third, removing all olds genres daoGenre.remove( genre ); } return daoGenre.getByName( user.getLogin(), newGenreName ).getSid(); } }
@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 ) ); } }
/** * update the current database to the new version * * @param sversion {@link String} version like "1.0.0-snapshot" * @param version int the vesrion number (first number) * @param revision int the revision number (second number) * @param compile int the compilation number (third number) * @param semantic String the semantic number (snapshot). This could not be present */ @Transactional public void update( String sversion, int version, int revision, int compile, String semantic ) { if ( isDifferentVersion( sversion ) ) { updateToVersion( version, revision, compile, semantic ); MDOMessicSettings mms = daoSettings.getSettings(); mms.setVersion( sversion ); daoSettings.saveSettings( mms ); daoUser.usersNotifyMessicUpdate(); } }
@Transactional public void remove( User user, Long resourceSid ) throws IOException { MDOAlbumResource resource = this.daoAlbumResource.get( user.getLogin(), resourceSid ); if ( resource != null ) { // first, removing the resource file String path = resource.calculateAbsolutePath( daoSettings.getSettings() ); File fpath = new File( path ); fpath.delete(); // after, removing the album data from database this.daoAlbumResource.remove( resource ); } }
@Transactional public List<MDOAuthor> getUserAuthors( Long userSid ) { MDOUser user = this.daoUsers.getUserById( userSid ); List<MDOAuthor> authors = new ArrayList<MDOAuthor>(); if ( user != null ) { authors = this.daoauthor.getAll( user.getLogin() ); } return authors; }
/** * Check if DLNA service is allowed by Messic configuration * * @return boolean */ public boolean isGenericAllowed() { return this.daoSettings.getSettings().isAllowDLNA(); }
@Transactional public void removeGenre( User user, Long genreSid ) { MDOGenre genre = daoGenre.getGenre( user.getLogin(), genreSid ); // First, putting all ablums to null genre daoAlbum.setNullGenre( genre ); daoGenre.remove( genre ); }
public void resetPassword( Long sid ) { MDOUser mdoUserToReset = daoUser.getUserById( sid ); mdoUserToReset.setPassword( "123456" ); daoUser.saveUser( mdoUserToReset, true, mdoUserToReset.getPassword() ); }
@Transactional public MDOUser getUser( Long userSid ) { return this.daoUsers.getUserById( userSid ); }
public void setAlbumCover( User user, Long albumSid, Long resourceSid ) { MDOUser mdouser = daoUser.getUserByLogin( user.getLogin() ); this.daoAlbum.setAlbumCover( resourceSid, albumSid, mdouser.getSid() ); }
@Transactional public List<Author> getAll( User user, boolean copyAlbums, boolean copySongs ) { List<MDOAuthor> authors = daoAuthor.getAll( user.getLogin() ); return Author.transform( authors, copyAlbums, copySongs ); }
@Transactional public List<Author> findSimilar( User user, String authorName, boolean contains, boolean copyAlbums, boolean copySongs ) { List<MDOAuthor> authors = daoAuthor.findSimilarAuthors( authorName, contains, user.getLogin() ); return Author.transform( authors, copyAlbums, copySongs ); }
@Transactional public List<Album> getAllOfGenre( MDOUser user, long genreSid, boolean authorInfo, boolean songsInfo, boolean resourcesInfo, int fromResult, int maxResults, boolean orderDesc, boolean orderByAuthor ) { List<MDOAlbum> albums = daoAlbum.getAllOfGenre( genreSid, user.getLogin(), fromResult, maxResults, orderDesc, orderByAuthor ); return Album.transform( albums, authorInfo, songsInfo, resourcesInfo ); }
/** * Return the messic server name * @return */ public String getMessicServerName() { return daoSettings.getSettings().getMessicServerName(); }
public User getUserById( Long userId ) { MDOUser mdoUser = daoUser.getUserById( userId ); return new User( mdoUser ); }
public User getUserByLogin( String user ) { MDOUser mdoUser = daoUser.getUserByLogin( user ); if ( mdoUser != null ) { return new User( mdoUser ); } else { return null; } }