sk.baka.ambient.collection.ampache
Class AmpacheClient

java.lang.Object
  extended by sk.baka.ambient.collection.ampache.AmpacheClient

public final class AmpacheClient
extends Object

Contains utility methods to communicate with Ampache.

Author:
Martin Vysny

Nested Class Summary
protected static class AmpacheClient.ErrorHandlingHandler
          Superclass for all handlers handling Ampache output.
 
Field Summary
 String serverURL
          Holds the server URL.
 
Constructor Summary
AmpacheClient(String serverURL)
          Creates new object instance.
 
Method Summary
static String computePassphrase(String password, String time)
          Computes Ampache passphrase for given time and password.
 AmpacheInfo connect(String user, String password)
          Connects to the Ampache server.
 List<CategoryItem> getAlbums(String substring)
          Returns albums from Ampache.
 List<TrackMetadataBean> getAlbumSongs(String albumId)
          Returns tracks for given album.
 List<CategoryItem> getArtistAlbums(String artistId, String substring)
          Returns albums for given artist.
 List<CategoryItem> getArtists(String substring)
          Returns artists from Ampache.
 List<TrackMetadataBean> getArtistSongs(String artistId)
          Returns songs for given artist.
 List<CategoryItem> getGenreAlbums(String genreId, String substring)
          Returns albums for given genre.
 List<CategoryItem> getGenreArtists(String genreId, String substring)
          Returns artists for given genre.
 List<CategoryItem> getGenres(String substring)
          Returns albums from Ampache.
 List<TrackMetadataBean> getGenreSongs(String genreId)
          Returns songs for given genre.
 AmpacheInfo getInfo()
          Returns server information.
 List<TrackMetadataBean> searchTracks(String substring)
          Search song which Song Title, Artist Name, Album Name or Genre Name contains given substring.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

serverURL

public final String serverURL
Holds the server URL.

Constructor Detail

AmpacheClient

public AmpacheClient(String serverURL)
Creates new object instance.

Parameters:
serverURL - the URL where Ampache is running, for example http://localhost/ampache. The object will automatically add /server/xml.server.php to the URL.
Method Detail

connect

public AmpacheInfo connect(String user,
                           String password)
                    throws AmpacheException,
                           IOException,
                           SAXException
Connects to the Ampache server.

Parameters:
user - optional user
password - required password.
Returns:
the server information object. Must not be modified.
Throws:
AmpacheException - if Ampache rejects to process the request.
IOException - if i/o error occurs.
SAXException

computePassphrase

public static String computePassphrase(String password,
                                       String time)
Computes Ampache passphrase for given time and password.

Parameters:
password - the password
time - the time
Returns:
the passphrase, a MD5 hash.

getInfo

public AmpacheInfo getInfo()
Returns server information.

Returns:
server information object. Must not be modified. null if not connected.

getArtists

public List<CategoryItem> getArtists(String substring)
                              throws IOException,
                                     SAXException,
                                     AmpacheException
Returns artists from Ampache.

Parameters:
substring - optional substring which the album name must contain.
Returns:
list of artists.
Throws:
AmpacheException
SAXException
IOException

getArtistSongs

public List<TrackMetadataBean> getArtistSongs(String artistId)
                                       throws IOException,
                                              SAXException,
                                              AmpacheException
Returns songs for given artist.

Parameters:
artistId - the artist ID.
Returns:
list of tracks.
Throws:
AmpacheException
SAXException
IOException

getArtistAlbums

public List<CategoryItem> getArtistAlbums(String artistId,
                                          String substring)
                                   throws IOException,
                                          SAXException,
                                          AmpacheException
Returns albums for given artist.

Parameters:
artistId - the artist ID.
substring - optional substring which the album name must contain.
Returns:
list of albums.
Throws:
AmpacheException
SAXException
IOException

getAlbums

public List<CategoryItem> getAlbums(String substring)
                             throws IOException,
                                    SAXException,
                                    AmpacheException
Returns albums from Ampache.

Parameters:
substring - optional substring which the album name must contain.
Returns:
list of albums.
Throws:
AmpacheException
SAXException
IOException

getAlbumSongs

public List<TrackMetadataBean> getAlbumSongs(String albumId)
                                      throws IOException,
                                             SAXException,
                                             AmpacheException
Returns tracks for given album.

Parameters:
albumId - the album ID.
Returns:
list of tracks.
Throws:
AmpacheException
SAXException
IOException

getGenres

public List<CategoryItem> getGenres(String substring)
                             throws IOException,
                                    SAXException,
                                    AmpacheException
Returns albums from Ampache.

Parameters:
substring - optional substring which the album name must contain.
Returns:
list of albums.
Throws:
AmpacheException
SAXException
IOException

getGenreArtists

public List<CategoryItem> getGenreArtists(String genreId,
                                          String substring)
                                   throws IOException,
                                          SAXException,
                                          AmpacheException
Returns artists for given genre.

Parameters:
genreId - the genre id.
substring - optional substring which the album name must contain.
Returns:
list of artists.
Throws:
AmpacheException
SAXException
IOException

getGenreAlbums

public List<CategoryItem> getGenreAlbums(String genreId,
                                         String substring)
                                  throws IOException,
                                         SAXException,
                                         AmpacheException
Returns albums for given genre.

Parameters:
genreId - the genre id.
substring - optional substring which the album name must contain.
Returns:
list of albums.
Throws:
AmpacheException
SAXException
IOException

getGenreSongs

public List<TrackMetadataBean> getGenreSongs(String genreId)
                                      throws IOException,
                                             SAXException,
                                             AmpacheException
Returns songs for given genre.

Parameters:
genreId - the genre id.
Returns:
list of songs.
Throws:
AmpacheException
SAXException
IOException

searchTracks

public List<TrackMetadataBean> searchTracks(String substring)
                                     throws IOException,
                                            SAXException,
                                            AmpacheException
Search song which Song Title, Artist Name, Album Name or Genre Name contains given substring.

Parameters:
substring - the substring to search for.
Returns:
the list of tracks, never null, may be empty. Sorted in no particular order.
Throws:
IOException
SAXException
AmpacheException


Copyright © 2007-2008. All Rights Reserved.