org.musicontroller.service
Class FileUtils

java.lang.Object
  extended by org.musicontroller.service.FileUtils
All Implemented Interfaces:
MusicDirProvider

public class FileUtils
extends java.lang.Object
implements MusicDirProvider

This class implements utilities for (MP3) file manipulation. This class knows about the conventions MusiController uses for the storage of its MP3 files.

Version:
$Id: FileUtils.java,v 1.1 2010/03/16 18:55:42 varienaja Exp $
Author:
drexler

Constructor Summary
FileUtils()
          No arguments constructor.
 
Method Summary
static java.lang.String getArchivedir()
          Getter for the music archive directory.
static java.lang.String getCoverdir()
          Getter for the directory containing the coverart.
static java.lang.String getIndexdir()
          Getter for the directory containing the lucene-index.
 java.lang.String getMusicDirectory()
          Getter for the music archive directory.
static java.lang.String getMyAccountdir()
          Getter for the directory containing the myAccount settings.
static java.lang.String[] getNewSongDestination(MusicArchiveEntryBean song)
          Returns the location of the MP3 file of a new song.
static java.lang.String getReviewdir()
          Getter for the directory containing the reviews.
protected static java.lang.String getStorageHashname(MusicArchiveEntryBean song)
          Determine the storage hash (directory) name where this MP3 file will be written to.
static java.lang.String getUnpackdir()
          Returns the location of the directory where uploaded music archives get unpacked.
static java.lang.String getUploaddir()
           
 void setBasedir(java.lang.String basedir)
          Setter for the music archive directory.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

FileUtils

public FileUtils()
No arguments constructor.

Method Detail

setBasedir

public void setBasedir(java.lang.String basedir)
                throws java.lang.Exception
Setter for the music archive directory.

Parameters:
basedir - The base directory
Throws:
java.lang.Exception

getArchivedir

public static java.lang.String getArchivedir()
Getter for the music archive directory. Returns the set basedir with "/songs" appended. If the basedir is null then just returns "songs".

Returns:
The music archive directory.

getMusicDirectory

public java.lang.String getMusicDirectory()
Description copied from interface: MusicDirProvider
Getter for the music archive directory.

Specified by:
getMusicDirectory in interface MusicDirProvider
Returns:
The music archive directory.

getMyAccountdir

public static java.lang.String getMyAccountdir()
Getter for the directory containing the myAccount settings.

Returns:
The directory containing the myaccount settings.

getCoverdir

public static java.lang.String getCoverdir()
Getter for the directory containing the coverart.

Returns:
The directory containing the coverart.

getReviewdir

public static java.lang.String getReviewdir()
Getter for the directory containing the reviews.

Returns:
The directory containing the reviews.

getIndexdir

public static java.lang.String getIndexdir()
Getter for the directory containing the lucene-index.

Returns:
The directory containing the lucene-index.

getUploaddir

public static java.lang.String getUploaddir()

getUnpackdir

public static java.lang.String getUnpackdir()
Returns the location of the directory where uploaded music archives get unpacked. The returned name does not end in a file separator character.

Returns:

getStorageHashname

protected static java.lang.String getStorageHashname(MusicArchiveEntryBean song)
Determine the storage hash (directory) name where this MP3 file will be written to. This method returns the first letter of the band name as the storage hash name. This is consistent with older versions of MusiController.

Parameters:
song - The music archive entry to find the storage hash name for.
Returns:
The name of the storage hash (directory) where the song should be written to, or "_" if the song has a null or empty bandname.

getNewSongDestination

public static java.lang.String[] getNewSongDestination(MusicArchiveEntryBean song)
Returns the location of the MP3 file of a new song. The location is splitted into three parts:
  1. Songs-directory of MusiController
  2. Relative part of the filename for this song
  3. filename

Parameters:
song -
Returns:
The location for the new Song. In order to use it, join them together with File.separator-characters.
Throws:
ImporterException - If the song is null.


Copyright © 2010 A.J.V.. All Rights Reserved.