sk.baka.ambient.collection.ampache
Class AmpacheClient

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

@ThreadSafe
public final class AmpacheClient
extends java.lang.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
 java.lang.String serverURL
          Holds the server URL.
 
Constructor Summary
AmpacheClient(java.lang.String serverURL)
          Creates new object instance.
 
Method Summary
static java.lang.String computePassphrase(java.lang.String password, java.lang.String time)
          Computes Ampache passphrase for given time and password.
 AmpacheInfo connect(java.lang.String user, java.lang.String password)
          Connects to the Ampache server.
 java.util.List<CategoryItem> getAlbums(java.lang.String substring)
          Returns albums from Ampache.
 java.util.List<TrackMetadataBean> getAlbumSongs(java.lang.String albumId)
          Returns tracks for given album.
 java.util.List<CategoryItem> getArtistAlbums(java.lang.String artistId, java.lang.String substring)
          Returns albums for given artist.
 java.util.List<CategoryItem> getArtists(java.lang.String substring)
          Returns artists from Ampache.
 java.util.List<TrackMetadataBean> getArtistSongs(java.lang.String artistId)
          Returns songs for given artist.
 java.util.List<CategoryItem> getGenreAlbums(java.lang.String genreId, java.lang.String substring)
          Returns albums for given genre.
 java.util.List<CategoryItem> getGenreArtists(java.lang.String genreId, java.lang.String substring)
          Returns artists for given genre.
 java.util.List<CategoryItem> getGenres(java.lang.String substring)
          Returns albums from Ampache.
 java.util.List<TrackMetadataBean> getGenreSongs(java.lang.String genreId)
          Returns songs for given genre.
 AmpacheInfo getInfo()
          Returns server information.
 java.util.List<TrackMetadataBean> searchTracks(java.lang.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 java.lang.String serverURL
Holds the server URL.

Constructor Detail

AmpacheClient

public AmpacheClient(java.lang.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(java.lang.String user,
                           java.lang.String password)
                    throws AmpacheException,
                           java.io.IOException,
                           org.xml.sax.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.
java.io.IOException - if i/o error occurs.
org.xml.sax.SAXException

computePassphrase

public static java.lang.String computePassphrase(java.lang.String password,
                                                 java.lang.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 java.util.List<CategoryItem> getArtists(java.lang.String substring)
                                        throws java.io.IOException,
                                               org.xml.sax.SAXException,
                                               AmpacheException
Returns artists from Ampache.

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

getArtistSongs

public java.util.List<TrackMetadataBean> getArtistSongs(java.lang.String artistId)
                                                 throws java.io.IOException,
                                                        org.xml.sax.SAXException,
                                                        AmpacheException
Returns songs for given artist.

Parameters:
artistId - the artist ID.
Returns:
list of tracks.
Throws:
AmpacheException
org.xml.sax.SAXException
java.io.IOException

getArtistAlbums

public java.util.List<CategoryItem> getArtistAlbums(java.lang.String artistId,
                                                    java.lang.String substring)
                                             throws java.io.IOException,
                                                    org.xml.sax.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
org.xml.sax.SAXException
java.io.IOException

getAlbums

public java.util.List<CategoryItem> getAlbums(java.lang.String substring)
                                       throws java.io.IOException,
                                              org.xml.sax.SAXException,
                                              AmpacheException
Returns albums from Ampache.

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

getAlbumSongs

public java.util.List<TrackMetadataBean> getAlbumSongs(java.lang.String albumId)
                                                throws java.io.IOException,
                                                       org.xml.sax.SAXException,
                                                       AmpacheException
Returns tracks for given album.

Parameters:
albumId - the album ID.
Returns:
list of tracks.
Throws:
AmpacheException
org.xml.sax.SAXException
java.io.IOException

getGenres

public java.util.List<CategoryItem> getGenres(java.lang.String substring)
                                       throws java.io.IOException,
                                              org.xml.sax.SAXException,
                                              AmpacheException
Returns albums from Ampache.

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

getGenreArtists

public java.util.List<CategoryItem> getGenreArtists(java.lang.String genreId,
                                                    java.lang.String substring)
                                             throws java.io.IOException,
                                                    org.xml.sax.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
org.xml.sax.SAXException
java.io.IOException

getGenreAlbums

public java.util.List<CategoryItem> getGenreAlbums(java.lang.String genreId,
                                                   java.lang.String substring)
                                            throws java.io.IOException,
                                                   org.xml.sax.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
org.xml.sax.SAXException
java.io.IOException

getGenreSongs

public java.util.List<TrackMetadataBean> getGenreSongs(java.lang.String genreId)
                                                throws java.io.IOException,
                                                       org.xml.sax.SAXException,
                                                       AmpacheException
Returns songs for given genre.

Parameters:
genreId - the genre id.
Returns:
list of songs.
Throws:
AmpacheException
org.xml.sax.SAXException
java.io.IOException

searchTracks

public java.util.List<TrackMetadataBean> searchTracks(java.lang.String substring)
                                               throws java.io.IOException,
                                                      org.xml.sax.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:
java.io.IOException
org.xml.sax.SAXException
AmpacheException


Copyright © 2007-2009. All Rights Reserved.