com.atlassian.jira.favourites
Class DefaultFavouritesManager

java.lang.Object
  extended by com.atlassian.jira.favourites.DefaultFavouritesManager
All Implemented Interfaces:
FavouritesManager

public class DefaultFavouritesManager
extends Object
implements FavouritesManager


Constructor Summary
DefaultFavouritesManager(FavouritesStore store, SharedEntityAccessor.Factory sharedEntityAccessorFactory, ShareManager shareManager)
           
 
Method Summary
 void addFavourite(User user, SharedEntity entity)
          Add the given entity as a favourite of the user passed in add to favourites count if necessary.
 void addFavouriteInPosition(User user, SharedEntity entity, long position)
          Add the given entity as a favourite of the user passed in, in the specified position, add to favourites count if necessary.
 void decreaseFavouriteSequence(User user, SharedEntity entity)
          Decreases the position of the SharedEntity relative to the user's set of all other entities of the same type.
 Collection getFavouriteIds(User user, SharedEntity.TypeDescriptor entityType)
          Get the ids of a user's favourite Entities for a given entity type
 void increaseFavouriteSequence(User user, SharedEntity entity)
          Increases the position of the SharedEntity relative to the user's set of all other entities of the same type.
 boolean isFavourite(User user, SharedEntity entity)
          Check to see if the given entity is a favourite of the user passed in.
 void moveToEndFavouriteSequence(User user, SharedEntity entity)
          Moves the position of the SharedEntity to the end relative to the user's set of all other entities of the same type.
 void moveToStartFavouriteSequence(User user, SharedEntity entity)
          Moves the position of the SharedEntity to the start relative to the user's set of all other entities of the same type.
 void removeFavourite(User user, SharedEntity entity)
          Remove the given entity as a favourite of the user passed in.
 void removeFavouritesForEntityDelete(SharedEntity entity)
          Remove all favourite associations for a given entity for entity deletion.
 void removeFavouritesForUser(User user, SharedEntity.TypeDescriptor entityType)
          Remove the favourite associations for the given User and the given type
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DefaultFavouritesManager

public DefaultFavouritesManager(FavouritesStore store,
                                SharedEntityAccessor.Factory sharedEntityAccessorFactory,
                                ShareManager shareManager)
Method Detail

addFavourite

public void addFavourite(User user,
                         SharedEntity entity)
                  throws PermissionException
Description copied from interface: FavouritesManager
Add the given entity as a favourite of the user passed in add to favourites count if necessary.

Specified by:
addFavourite in interface FavouritesManager
Parameters:
user - The user adding the favourite
entity - The entity to favourite
Throws:
PermissionException - when trying to add a filter as favourite when you have no permissions

addFavouriteInPosition

public void addFavouriteInPosition(User user,
                                   SharedEntity entity,
                                   long position)
                            throws PermissionException
Description copied from interface: FavouritesManager
Add the given entity as a favourite of the user passed in, in the specified position, add to favourites count if necessary. The entity currently in the specified position and all those after will be moved down one position.

Specified by:
addFavouriteInPosition in interface FavouritesManager
Parameters:
user - The user adding the favourite
entity - The entity to favourite
position - the position in which this entity should be added in the favourites order.
Throws:
PermissionException - when trying to add a filter as favourite when you have no permissions

removeFavourite

public void removeFavourite(User user,
                            SharedEntity entity)
Description copied from interface: FavouritesManager
Remove the given entity as a favourite of the user passed in. Remove even if user doesn't have permission to see it and adjust count of favourites if necessary.

Specified by:
removeFavourite in interface FavouritesManager
Parameters:
user - The user removing the favourite
entity - The entity to favourite

isFavourite

public boolean isFavourite(User user,
                           SharedEntity entity)
                    throws PermissionException
Description copied from interface: FavouritesManager
Check to see if the given entity is a favourite of the user passed in.

Specified by:
isFavourite in interface FavouritesManager
Parameters:
user - The user checking the favourite
entity - The entity to favourite
Returns:
true if the entity is favourite and can be seen by user, otherwise false
Throws:
PermissionException - when checking a filter with no permission

getFavouriteIds

public Collection getFavouriteIds(User user,
                                  SharedEntity.TypeDescriptor entityType)
Description copied from interface: FavouritesManager
Get the ids of a user's favourite Entities for a given entity type

Specified by:
getFavouriteIds in interface FavouritesManager
Parameters:
user - The user for the associated entities. Can not be null.
entityType - The type of entities to get. E.g. SearchRequest.ENTITY_TYPE. Can not be null.
Returns:
A Collection on Longs that represent the entities, sorted into sequence order

removeFavouritesForUser

public void removeFavouritesForUser(User user,
                                    SharedEntity.TypeDescriptor entityType)
Description copied from interface: FavouritesManager
Remove the favourite associations for the given User and the given type

Specified by:
removeFavouritesForUser in interface FavouritesManager
Parameters:
user - The user with whom to disassociate entities with
entityType - The type of entity to disassociate user with.

removeFavouritesForEntityDelete

public void removeFavouritesForEntityDelete(SharedEntity entity)
Description copied from interface: FavouritesManager
Remove all favourite associations for a given entity for entity deletion. This method is for only for when an entity is deleted as it does not adjust favourite counts.

Specified by:
removeFavouritesForEntityDelete in interface FavouritesManager
Parameters:
entity - The entity that is being deleted

increaseFavouriteSequence

public void increaseFavouriteSequence(User user,
                                      SharedEntity entity)
                               throws PermissionException
Description copied from interface: FavouritesManager
Increases the position of the SharedEntity relative to the user's set of all other entities of the same type.

Specified by:
increaseFavouriteSequence in interface FavouritesManager
Parameters:
user - the user whom the entity belongs to
entity - The entity in question
Throws:
PermissionException - when the user does not have permission to perform the action.

decreaseFavouriteSequence

public void decreaseFavouriteSequence(User user,
                                      SharedEntity entity)
                               throws PermissionException
Description copied from interface: FavouritesManager
Decreases the position of the SharedEntity relative to the user's set of all other entities of the same type.

Specified by:
decreaseFavouriteSequence in interface FavouritesManager
Parameters:
user - the user whom the entity belongs to
entity - The entity in question
Throws:
PermissionException - when the user does not have permission to perform the action.

moveToStartFavouriteSequence

public void moveToStartFavouriteSequence(User user,
                                         SharedEntity entity)
                                  throws PermissionException
Description copied from interface: FavouritesManager
Moves the position of the SharedEntity to the start relative to the user's set of all other entities of the same type.

Specified by:
moveToStartFavouriteSequence in interface FavouritesManager
Parameters:
user - the user whom the entity belongs to
entity - The entity in question
Throws:
PermissionException - when the user does not have permission to perform the action.

moveToEndFavouriteSequence

public void moveToEndFavouriteSequence(User user,
                                       SharedEntity entity)
                                throws PermissionException
Description copied from interface: FavouritesManager
Moves the position of the SharedEntity to the end relative to the user's set of all other entities of the same type.

Specified by:
moveToEndFavouriteSequence in interface FavouritesManager
Parameters:
user - the user whom the entity belongs to
entity - The entity in question
Throws:
PermissionException - when the user does not have permission to perform the action.


Copyright © 2002-2008 Atlassian. All Rights Reserved.