/** * Check if DLNA service is allowed by Messic configuration * * @return boolean */ public boolean isGenericAllowed() { return this.daoSettings.getSettings().isAllowDLNA(); }
/** * 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(); } }
daoSettings.saveSettings( settings.getMDOSettings( this.daoSettings ) );
/** * Return the messic server name * @return */ public String getMessicServerName() { return daoSettings.getSettings().getMessicServerName(); }
/** * Check if we have a different version at database. Receive the current version of messic * * @param sversion {@link String} current version of messic * @return boolean true->is different */ private boolean isDifferentVersion( String sversion ) { String dbVersion = daoSettings.getSettings().getVersion(); if ( dbVersion != null && dbVersion.equals( sversion ) ) { return false; } else { return true; } } }
/** * Return the list of folders at the author level file system (at the messic music folder of the user scope) * * @param user {@link User} scope * @return {@link List}<{@link String}/> List of folders at the messic music folder */ public List<String> getAuthorFolders( MDOUser user ) { String userPath = user.calculateAbsolutePath( daoSettings.getSettings() ); File fuserPath = new File( userPath ); if ( fuserPath.exists() ) { String[] list = fuserPath.list(); List<String> rlist = new ArrayList<String>(); for ( String string : list ) { rlist.add( string ); } return rlist; } else { return new ArrayList<String>(); } } }
/** * Check if the folders are just the needed folders.. * * @param albumSid * @return */ @Transactional public List<FolderResourceConsistency> checkConsistency( MDOUser user ) { List<FolderResourceConsistency> result = new ArrayList<FolderResourceConsistency>(); String userPath = user.calculateAbsolutePath( daoSettings.getSettings() ); File fuserPath = new File( userPath ); File[] authorFolders = fuserPath.listFiles(); for ( File faufolder : authorFolders ) { List<FolderResourceConsistency> pr = checkConsistencyFolder( user, faufolder ); result.addAll( pr ); } return result; }
@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 File get( User user, Long resourceSid ) throws IOException { MDOAlbumResource resource = this.daoAlbumResource.get( user.getLogin(), resourceSid ); if ( resource != null && resource instanceof MDOPhysicalResource ) { File f = new File( resource.calculateAbsolutePath( daoSettings.getSettings() ) ); if ( f.exists() ) { return f; } } throw new IOException( "Album resource not found!" ); } }
/** * Delete all the files of a certain path, and subpaths, except those files in the list of the parameter * exceptionFiles * * @param basePath {@link String} basePath to start searching * @param exceptionFiles List<File/> Black list we don't want to remove */ private void deleteFiles( String basePath, List<org.messic.server.api.datamodel.File> exceptionFiles ) { File directory = new File( basePath ); char replacementChar = daoSettings.getSettings().getIllegalCharacterReplacement(); // get all the files from a directory File[] fList = directory.listFiles(); for ( File file : fList ) { if ( file.isFile() ) { if ( !isAnExceptionFile( file, exceptionFiles, replacementChar ) && !file.getName().toUpperCase().equals( APIAlbum.INDEX_TMP_PROPERTIES_FILENAME.toUpperCase() ) ) { file.delete(); } } else if ( file.isDirectory() ) { deleteFiles( file.getAbsolutePath(), exceptionFiles ); } } }
public void checkService() { if ( this.daoSettings.getSettings().isAllowMessicDiscovering() ) { if ( this.threadCover != null ) { this.threadCover.interrupt(); } this.stop(); this.stop = false; this.threadCover = new Thread( this ); this.threadCover.start(); } else { this.stop(); } }
public void removeUser( Long sid, boolean removeMusicContent ) throws Exception { MDOUser mdoUserToRemove = daoUser.getUserById( sid ); if ( mdoUserToRemove != null ) { if ( removeMusicContent ) { String absolutePath = mdoUserToRemove.calculateAbsolutePath( daoSettings.getSettings() ); File fabsolutePath = new File( absolutePath ); if ( fabsolutePath.exists() ) { FileUtils.deleteDirectory( new File( absolutePath ) ); } } // first we remove genres of the user // daoGenre.removeAllGenres( mdoUserToRemove.getLogin() ); // daoGenre.flush(); // finally we remove the user daoUser.remove( mdoUserToRemove ); } else { throw new Exception( "User doesn't exist!" ); } }
@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 ); } }
ZipEntry ze = new ZipEntry( entryName ); zos.putNextEntry( ze ); FileInputStream in = new FileInputStream( song.calculateAbsolutePath( daoSettings.getSettings() ) ); int len; byte buffer[] = new byte[1024];
sendDataMessge += "<name>" + daoSettings.getSettings().getMessicServerName() + "</name>"; sendDataMessge += "<port>" + cp.currentPort + "</port>"; sendDataMessge += "<secure>" + cp.secure + "</secure>";
File basePath = new File( mdouser.calculateTmpPath( daoSettings.getSettings(), albumCode ) + ( volume != null ? File.separatorChar + "" + volume : "" ) ); basePath.mkdirs(); f.setFileName( fileName ); f.setVolume( volume ); String secureFileName = f.calculateSecureFileName( daoSettings.getSettings().getIllegalCharacterReplacement() ); FileOutputStream fos = new FileOutputStream( new File( basePath.getAbsolutePath() + File.separatorChar + secureFileName ) );
if ( albumCode != null && albumCode.length() > 0 ) basePath = new File( mdouser.calculateTmpPath( daoSettings.getSettings(), albumCode ) ); basePath = new File( mdouser.calculateTmpPath( daoSettings.getSettings(), "" ) ); File ftmppath = new File( mdouser.calculateTmpPath( daoSettings.getSettings(), "" ) ); if ( ftmppath.exists() )
@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; }
String path = song.calculateAbsolutePath( daoSettings.getSettings() ); File fpath = new File( path ); fpath.delete();
String basePath = mdouser.calculateTmpPath( daoSettings.getSettings(), albumCode ); File tmpPath = new File( basePath );