com.atlassian.jira.portal
Class CachingPortalPageStore

java.lang.Object
  extended by com.atlassian.jira.portal.CachingPortalPageStore
All Implemented Interfaces:
Startable, PortalPageStore

public class CachingPortalPageStore
extends Object
implements PortalPageStore, Startable

Caching store for PortalPage. The cache stores a id -> PortalPage and a portalPage.owner -> id mapping.

This class is not completely thread safe in that it is possible for the cache and the database to become unsynchronized.

Since:
v3.13

Constructor Summary
CachingPortalPageStore(PortalPageStore delegateStore, com.atlassian.event.api.EventPublisher eventPublisher)
           
 
Method Summary
 PortalPage adjustFavouriteCount(SharedEntity portalPage, int incrementValue)
          Updates the favourite count of the PortalPage in the database.
 PortalPage create(PortalPage portalPage)
          Creates a PortalPage in the database
 void delete(Long portalPageId)
          Deletes the PortalPage with the specified portalPageId
 void flush()
          Flushes any caches that may exist
 EnclosedIterable<PortalPage> get(SharedEntityAccessor.RetrievalDescriptor ids)
          Get a EnclosedIterable of PortalPages for the specified List of ids.
 EnclosedIterable<PortalPage> getAll()
          Get a EnclosedIterable of all PortalPages in the database.
 Collection<PortalPage> getAllOwnedPortalPages(User owner)
          Gets all the PortalPage's owned by the specified User
 PortalPage getPortalPage(Long portalPageId)
          Gets the PortalPage with the specified portalPageId
 PortalPage getPortalPageByOwnerAndName(User owner, String portalPageName)
          Gets the specified PortalPage that is owned by the User and has the specified portalPageName
 PortalPage getSystemDefaultPortalPage()
          Goes to the database and fetches the system default dashboard configuration.
 void onClearCache(ClearCacheEvent event)
           
 void start()
          This method wil be called after the plugin system is fully initialised and all components added to the dependency injection framework.
 PortalPage update(PortalPage portalPage)
          Updates the PortalPage in the database.
 boolean updatePortalPageOptimisticLock(Long portalPageId, Long currentVersion)
          This method will increment the version of the given portalPage by one.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

CachingPortalPageStore

public CachingPortalPageStore(PortalPageStore delegateStore,
                              com.atlassian.event.api.EventPublisher eventPublisher)
Method Detail

start

public void start()
           throws Exception
Description copied from interface: Startable
This method wil be called after the plugin system is fully initialised and all components added to the dependency injection framework.

Specified by:
start in interface Startable
Throws:
Exception - Allows implementations to throw an Exception.

onClearCache

@EventListener
public void onClearCache(ClearCacheEvent event)

get

public EnclosedIterable<PortalPage> get(SharedEntityAccessor.RetrievalDescriptor ids)
Description copied from interface: PortalPageStore
Get a EnclosedIterable of PortalPages for the specified List of ids.

Specified by:
get in interface PortalPageStore
Parameters:
ids - retrieval descriptor
Returns:
CloseableIterable that contains reference to PortalPages with the specified ids.

getAll

public EnclosedIterable<PortalPage> getAll()
Description copied from interface: PortalPageStore
Get a EnclosedIterable of all PortalPages in the database.

Specified by:
getAll in interface PortalPageStore
Returns:
CloseableIterable that contains reference to all PortalPages.

getSystemDefaultPortalPage

public PortalPage getSystemDefaultPortalPage()
Description copied from interface: PortalPageStore
Goes to the database and fetches the system default dashboard configuration.

Specified by:
getSystemDefaultPortalPage in interface PortalPageStore
Returns:
the system default portal page.

getAllOwnedPortalPages

public Collection<PortalPage> getAllOwnedPortalPages(User owner)
Description copied from interface: PortalPageStore
Gets all the PortalPage's owned by the specified User

Specified by:
getAllOwnedPortalPages in interface PortalPageStore
Parameters:
owner - the user who is the owner of the PortalPage's
Returns:
a Collection of PortalPage objects owner by the User

getPortalPageByOwnerAndName

public PortalPage getPortalPageByOwnerAndName(User owner,
                                              String portalPageName)
Description copied from interface: PortalPageStore
Gets the specified PortalPage that is owned by the User and has the specified portalPageName

Specified by:
getPortalPageByOwnerAndName in interface PortalPageStore
Parameters:
owner - the User how is the owner of the PortalPage
portalPageName - the name of the PortalPage
Returns:
a PortalPage object or null if it cant be found

getPortalPage

public PortalPage getPortalPage(Long portalPageId)
Description copied from interface: PortalPageStore
Gets the PortalPage with the specified portalPageId

Specified by:
getPortalPage in interface PortalPageStore
Parameters:
portalPageId - the id of the PortalPage to locate
Returns:
a PortalPage or null if it cant be found

create

public PortalPage create(PortalPage portalPage)
Description copied from interface: PortalPageStore
Creates a PortalPage in the database

Specified by:
create in interface PortalPageStore
Parameters:
portalPage - the PortalPage to create
Returns:
the new PortalPage with its new database id

update

public PortalPage update(PortalPage portalPage)
Description copied from interface: PortalPageStore
Updates the PortalPage in the database.

Specified by:
update in interface PortalPageStore
Parameters:
portalPage - the PortalPage to update
Returns:
a newly updated PortalPage object

updatePortalPageOptimisticLock

public boolean updatePortalPageOptimisticLock(Long portalPageId,
                                              Long currentVersion)
Description copied from interface: PortalPageStore
This method will increment the version of the given portalPage by one. When doing this, it will check that the version currently equals what was passed in. If the update is successful, this method returns true. False otherwise In JIRA since we don't have transactions, this method should be called inside a pessimistic lock (potentially striped by portalPageId) and all update operations should follow while holding this same lock.

Specified by:
updatePortalPageOptimisticLock in interface PortalPageStore
Parameters:
portalPageId - The dashboard to update
currentVersion - The current version for this dashboard
Returns:
true if the update is successful, false otherwise

adjustFavouriteCount

public PortalPage adjustFavouriteCount(SharedEntity portalPage,
                                       int incrementValue)
Description copied from interface: PortalPageStore
Updates the favourite count of the PortalPage in the database.

Specified by:
adjustFavouriteCount in interface PortalPageStore
Parameters:
portalPage - the portal page to change.
incrementValue - the value to increase the favourite count by. Can be a number < 0 to decrease the favourite count.
Returns:
a newly updated PortalPage object.

delete

public void delete(Long portalPageId)
Description copied from interface: PortalPageStore
Deletes the PortalPage with the specified portalPageId

Specified by:
delete in interface PortalPageStore
Parameters:
portalPageId - the id of the PortalPage to delete

flush

public void flush()
Description copied from interface: PortalPageStore
Flushes any caches that may exist

Specified by:
flush in interface PortalPageStore


Copyright © 2002-2010 Atlassian. All Rights Reserved.