org.shredzone.flattr4j.impl
Class FlattrServiceImpl

java.lang.Object
  extended by org.shredzone.flattr4j.impl.FlattrServiceImpl
All Implemented Interfaces:
FlattrService, OpenService

public class FlattrServiceImpl
extends Object
implements FlattrService

Default implementation of FlattrService.

Author:
Richard "Shred" Körber

Constructor Summary
FlattrServiceImpl(Connector connector)
           
 
Method Summary
 void click(AutoSubmission submission)
          Flattrs an AutoSubmission.
 void click(String url)
          Flattrs a URL.
 void click(ThingId thingId)
          Flattrs a Thing.
 ThingId create(Submission thing)
          Creates a new Thing.
 void delete(ThingId thingId)
          Deletes a Thing.
 List<Activity> getActivities(UserId user, Activity.Type type)
          Returns all Activity of the given user ID.
 List<Category> getCategories()
          Gets a list of all Flattr Category.
protected  Connector getConnector()
          Returns the Connector used for calling the API.
 List<Flattr> getFlattrs(ThingId thingId)
          Gets all Flattr most recently posted for the given thing ID.
 List<Flattr> getFlattrs(ThingId thingId, Integer count, Integer page)
          Gets all Flattr most recently posted for the given thing ID.
 List<Flattr> getFlattrs(UserId user)
          Gets all Flattr most recently posted by the given user ID.
 List<Flattr> getFlattrs(UserId userId, Integer count, Integer page)
          Gets all Flattr most recently posted by the given user ID.
 List<Language> getLanguages()
          Gets a list of all Flattr Language.
 RateLimit getLastRateLimit()
          Gets the rate limit and remaining rate returned by the last API call.
 List<Activity> getMyActivities(Activity.Type type)
          Returns all Activity of the associated user.
 List<Flattr> getMyFlattrs()
          Returns all Flattr submitted by the associated user.
 List<Flattr> getMyFlattrs(Integer count, Integer page)
          Returns all Flattr submitted by the associated user.
 User getMyself()
          Gets the User profile of the associated user.
 List<Thing> getMyThings()
          Returns all Thing submitted by the associated user.
 List<Thing> getMyThings(Integer count, Integer page)
          Returns all Thing submitted by the associated user.
 Thing getThing(ThingId thingId)
          Gets a Thing for the given ThingId.
 Thing getThingBySubmission(AutoSubmission submission)
          Gets a Thing by its autosubmit URL.
 Thing getThingByUrl(String url)
          Gets a Thing by its registered URL.
 List<Thing> getThings(Collection<ThingId> thingIds)
          Gets a list of Thing by a collection of thing IDs.
 List<Thing> getThings(UserId user)
          Gets a list of Thing most recently submitted by the given user.
 List<Thing> getThings(UserId user, Integer count, Integer page)
          Gets a list of Thing most recently submitted by the given user.
 User getUser(UserId user)
          Gets the User profile of the given user ID.
 SearchResult searchThings(SearchQuery query, Integer count, Integer page)
          Searches for Thing.
 void update(Thing thing)
          Updates a Thing.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

FlattrServiceImpl

public FlattrServiceImpl(Connector connector)
Method Detail

getConnector

protected Connector getConnector()
Returns the Connector used for calling the API.

Returns:
Connector

create

public ThingId create(Submission thing)
               throws FlattrException
Description copied from interface: FlattrService
Creates a new Thing. The authenticated user will be the owner of the Thing.

Specified by:
create in interface FlattrService
Parameters:
thing - Submission to be submitted
Returns:
ThingId of the Thing that was created
Throws:
FlattrException

update

public void update(Thing thing)
            throws FlattrException
Description copied from interface: FlattrService
Updates a Thing.

Specified by:
update in interface FlattrService
Parameters:
thing - Thing to be modified
Throws:
FlattrException

delete

public void delete(ThingId thingId)
            throws FlattrException
Description copied from interface: FlattrService
Deletes a Thing.

Specified by:
delete in interface FlattrService
Parameters:
thingId - ThingId to delete
Throws:
FlattrException

click

public void click(AutoSubmission submission)
           throws FlattrException
Description copied from interface: FlattrService
Flattrs an AutoSubmission. If the submission has not been submitted to Flattr yet, it will automatically be submitted before.

Specified by:
click in interface FlattrService
Parameters:
submission - AutoSubmission to flattr
Throws:
FlattrException

click

public void click(String url)
           throws FlattrException
Description copied from interface: FlattrService
Flattrs a URL.

Specified by:
click in interface FlattrService
Parameters:
url - URL to flattr
Throws:
FlattrException

click

public void click(ThingId thingId)
           throws FlattrException
Description copied from interface: FlattrService
Flattrs a Thing. This means that the Thing is flattr-ed by the associated user.

Specified by:
click in interface FlattrService
Parameters:
thingId - ThingId to flattr
Throws:
FlattrException

getMyself

public User getMyself()
               throws FlattrException
Description copied from interface: FlattrService
Gets the User profile of the associated user.

Specified by:
getMyself in interface FlattrService
Returns:
User profile of oneself
Throws:
FlattrException

getMyThings

public List<Thing> getMyThings()
                        throws FlattrException
Description copied from interface: FlattrService
Returns all Thing submitted by the associated user. Limited to 30 entries.

Specified by:
getMyThings in interface FlattrService
Returns:
List of Thing
Throws:
FlattrException

getMyThings

public List<Thing> getMyThings(Integer count,
                               Integer page)
                        throws FlattrException
Description copied from interface: FlattrService
Returns all Thing submitted by the associated user.

Specified by:
getMyThings in interface FlattrService
Parameters:
count - Number of entries per page, null defaults to 30 entries
page - Page number (counted from 1), or null to turn off paging
Returns:
List of Thing
Throws:
FlattrException

getMyFlattrs

public List<Flattr> getMyFlattrs()
                          throws FlattrException
Description copied from interface: FlattrService
Returns all Flattr submitted by the associated user. Limited to 30 entries.

Specified by:
getMyFlattrs in interface FlattrService
Returns:
List of Flattr
Throws:
FlattrException

getMyFlattrs

public List<Flattr> getMyFlattrs(Integer count,
                                 Integer page)
                          throws FlattrException
Description copied from interface: FlattrService
Returns all Flattr submitted by the associated user.

Specified by:
getMyFlattrs in interface FlattrService
Parameters:
count - Number of entries per page, null defaults to 30 entries
page - Page number (counted from 1), or null to turn off paging
Returns:
List of Flattr
Throws:
FlattrException

getThing

public Thing getThing(ThingId thingId)
               throws FlattrException
Description copied from interface: OpenService
Gets a Thing for the given ThingId.

Specified by:
getThing in interface OpenService
Parameters:
thingId - ThingId of the Thing to be fetched
Returns:
Thing
Throws:
FlattrException

getThingByUrl

public Thing getThingByUrl(String url)
                    throws FlattrException
Description copied from interface: OpenService
Gets a Thing by its registered URL.

Uses two rates!

Specified by:
getThingByUrl in interface OpenService
Parameters:
url - Thing's URL
Returns:
Thing of the URL that was found, null if nothing was found
Throws:
FlattrException

getThingBySubmission

public Thing getThingBySubmission(AutoSubmission submission)
                           throws FlattrException
Description copied from interface: OpenService
Gets a Thing by its autosubmit URL.

Uses two rates!

Specified by:
getThingBySubmission in interface OpenService
Parameters:
submission - AutoSubmission to check for
Returns:
Thing of the submission if found, null if nothing was found
Throws:
FlattrException

getThings

public List<Thing> getThings(UserId user)
                      throws FlattrException
Description copied from interface: OpenService
Gets a list of Thing most recently submitted by the given user. This list is limited to 30 entries.

Specified by:
getThings in interface OpenService
Parameters:
user - UserId to find the Things of
Returns:
List of Thing submitted by the user
Throws:
FlattrException

getThings

public List<Thing> getThings(UserId user,
                             Integer count,
                             Integer page)
                      throws FlattrException
Description copied from interface: OpenService
Gets a list of Thing most recently submitted by the given user.

Specified by:
getThings in interface OpenService
Parameters:
user - UserId to find the Things of
count - Number of entries per page, null defaults to 30 entries
page - Page number (counted from 1), or null to turn off paging
Returns:
List of Thing submitted by the user
Throws:
FlattrException

getThings

public List<Thing> getThings(Collection<ThingId> thingIds)
                      throws FlattrException
Description copied from interface: OpenService
Gets a list of Thing by a collection of thing IDs.

Specified by:
getThings in interface OpenService
Parameters:
thingIds - Collection of ThingId. The order of Thing returned may not match the order of the provided IDs.
Returns:
List of Thing fetched
Throws:
FlattrException

searchThings

public SearchResult searchThings(SearchQuery query,
                                 Integer count,
                                 Integer page)
                          throws FlattrException
Description copied from interface: OpenService
Searches for Thing.

Specified by:
searchThings in interface OpenService
Parameters:
query - SearchQuery, or null to search for everything
count - Number of entries per page, null defaults to 30 entries
page - Page number (counted from 1), or null to turn off paging
Returns:
SearchResult
Throws:
FlattrException

getUser

public User getUser(UserId user)
             throws FlattrException
Description copied from interface: OpenService
Gets the User profile of the given user ID.

Specified by:
getUser in interface OpenService
Parameters:
user - UserId to get a profile for
Returns:
User profile of that user
Throws:
FlattrException

getFlattrs

public List<Flattr> getFlattrs(UserId user)
                        throws FlattrException
Description copied from interface: OpenService
Gets all Flattr most recently posted by the given user ID. Limited to 30 results.

Specified by:
getFlattrs in interface OpenService
Parameters:
user - UserId to get the result for
Returns:
List of Flattr posted by the user
Throws:
FlattrException

getFlattrs

public List<Flattr> getFlattrs(UserId userId,
                               Integer count,
                               Integer page)
                        throws FlattrException
Description copied from interface: OpenService
Gets all Flattr most recently posted by the given user ID.

Specified by:
getFlattrs in interface OpenService
Parameters:
userId - UserId to get the result for
count - Number of entries per page, null defaults to 30 entries
page - Page number (counted from 1), or null to turn off paging
Returns:
List of Flattr posted by the user
Throws:
FlattrException

getFlattrs

public List<Flattr> getFlattrs(ThingId thingId)
                        throws FlattrException
Description copied from interface: OpenService
Gets all Flattr most recently posted for the given thing ID.

Specified by:
getFlattrs in interface OpenService
Parameters:
thingId - ThingId to get the result for
Returns:
List of Flattr posted by the user
Throws:
FlattrException

getFlattrs

public List<Flattr> getFlattrs(ThingId thingId,
                               Integer count,
                               Integer page)
                        throws FlattrException
Description copied from interface: OpenService
Gets all Flattr most recently posted for the given thing ID.

Specified by:
getFlattrs in interface OpenService
Parameters:
thingId - ThingId to get the result for
count - Number of entries per page, null defaults to 30 entries
page - Page number (counted from 1), or null to turn off paging
Returns:
List of Flattr posted by the user
Throws:
FlattrException

getActivities

public List<Activity> getActivities(UserId user,
                                    Activity.Type type)
                             throws FlattrException
Description copied from interface: OpenService
Returns all Activity of the given user ID.

Specified by:
getActivities in interface OpenService
Parameters:
user - UserId to get the result for
type - activity type. null defaults to Activity.Type#OUTGOING.
Returns:
List of Activity
Throws:
FlattrException

getMyActivities

public List<Activity> getMyActivities(Activity.Type type)
                               throws FlattrException
Description copied from interface: FlattrService
Returns all Activity of the associated user.

Specified by:
getMyActivities in interface FlattrService
Parameters:
type - activity type. null defaults to Activity.Type#OUTGOING.
Returns:
List of Activity
Throws:
FlattrException

getCategories

public List<Category> getCategories()
                             throws FlattrException
Description copied from interface: OpenService
Gets a list of all Flattr Category.

Note: The result is not cached.

Specified by:
getCategories in interface OpenService
Returns:
List of Flattr Category.
Throws:
FlattrException

getLanguages

public List<Language> getLanguages()
                            throws FlattrException
Description copied from interface: OpenService
Gets a list of all Flattr Language.

Note: The result is not cached.

Specified by:
getLanguages in interface OpenService
Returns:
List of Flattr Language.
Throws:
FlattrException

getLastRateLimit

public RateLimit getLastRateLimit()
Description copied from interface: OpenService
Gets the rate limit and remaining rate returned by the last API call.

Specified by:
getLastRateLimit in interface OpenService
Returns:
Rate limit.


Copyright © 2010-2012. All Rights Reserved.