com.atlassian.confluence.pages.persistence.dao.hibernate
Class CachingPageDao

java.lang.Object
  extended by com.atlassian.confluence.pages.persistence.dao.hibernate.CachingPageDao
All Implemented Interfaces:
ObjectDao, ContentEntityObjectDao, VersionedObjectDao, PageDao

public class CachingPageDao
extends java.lang.Object
implements PageDao

This maintains a cache of (space key, page title) -> (page id) mappings. All page ids cached refer to current pages. When a page is marked for deletion, it is removed from this cache.


Constructor Summary
CachingPageDao(PageDao delegateDao, PageIdCache pageIdCache)
           
 
Method Summary
 java.util.List findAll()
          Find all objects currently persisted of a particular type.
 java.util.List findAllSorted(java.lang.String s)
          Find all objects currently persisted of a particular type and sort results by named property.
 long findLatestVersionsCount()
          Returns the number of results for the latest versions of the current persistent class.
 java.util.Iterator findLatestVersionsIterator()
          Returns an iterator for the latest versions of the current persistent class.
 java.util.List findPagesWithHistoricalTitle(java.lang.String pageTitle)
           
 java.util.List<AbstractPage> findPagesWithHistoricalTitleInAllPermittedSpacesExcept(java.lang.String pageTitle, Space space, int maxResultCount)
          Searches for pages in all spaces except the one specified, looking for those that have the given title in a previous version, and returns the first maxResultCount results.
 java.util.List<AbstractPage> findPagesWithHistoricalTitleInPermittedSpace(java.lang.String pageTitle, Space space, int maxResultCount)
          Searches for pages in the space specified, looking for those that have the given title in a previous version, and returns the first maxResultCount results.
 java.util.List findPreviousVersions(long originalContentId)
           
 java.util.Iterator getAllCurrentEntities()
           
 int getAuthoredPagesCountByUser(java.lang.String username)
           
 ContentEntityObject getById(long id)
           
 int getCommentCountOnPage(long id)
          Count the number of comments on the passed in page.
 java.util.List getContentAuthoredByUser(java.lang.String username)
           
 java.util.List getDescendentIds(Page page)
           
 java.util.List<Page> getDescendents(Page page)
           
 ContentEntityObject getFirstVersionAfter(long originalVersionContentId, int version)
           
 ContentEntityObject getFirstVersionBefore(long originalVersionContentId, int version)
           
 java.util.List<ContentEntityObject> getLastEditedVersionsOf(ContentEntityObject content)
          Retrieves all the last edited versions for each user who has contributed to the specified piece of content.
 java.util.List getLockedContentBySpace(java.lang.String spaceKey)
           
 java.lang.String getObjectType(long id)
           
 java.util.List getOrphanedPages(java.lang.String spaceKey)
           
 Page getPage(Space space, java.lang.String pageTitle)
          Get the page by space and title.
 Page getPage(java.lang.String spaceKey, java.lang.String pageTitle)
          Deprecated. 
 Page getPage(java.lang.String spaceKey, java.lang.String pageTitle, boolean eagerLoadComments)
          Deprecated. 
 Page getPageById(long id)
          Get the page with the given id.
 Page getPageByIdWithComments(long id)
          Get the page with the given id, and perform an eager load of the comments and their children.
 java.util.List getPageInTrash(java.lang.String spaceKey, java.lang.String title)
           
 java.util.List getPages(Space space, boolean currentOnly)
           
 java.util.List getPagesCreatedOrUpdatedSinceDate(java.util.Date previousLoginDate)
           
 java.util.List getPagesStartingWith(Space space, java.lang.String s)
           
 Page getPageWithComments(Space space, java.lang.String pageTitle)
          Get the page by space and title, and perform an eager load of the comments and their children.
 java.util.List getPermissionPages(Space space)
           
 java.lang.Class getPersistentClass()
           
 java.util.Iterator getRecentlyAddedEntities(java.lang.String spaceKey, int maxResults)
           
 java.util.List getRecentlyAddedPages(int maxCount, java.lang.String spaceKey)
           
 java.util.List getRecentlyAuthoredPagesByUser(java.lang.String username, int maxCount)
           
 java.util.Iterator getRecentlyModifiedEntities(int maxResults)
           
 java.util.Iterator getRecentlyModifiedEntities(java.lang.String spaceKey, int maxResults)
           
 java.util.Iterator getRecentlyModifiedEntitiesForUser(java.lang.String username)
           
 java.util.List getRecentlyModifiedForChangeDigest(java.util.Date fromDate)
          Retrieves a list of ContentEntityObjects that have been newly added or modified since the date specified.
 java.util.List getRecentlyUpdatedPages(int maxCount, java.lang.String spaceKey)
           
 java.util.List<Page> getTopLevelPages(Space space)
           
 java.util.List getTrashedContent(java.lang.String spaceKey)
           
 java.util.List getUndefinedPages(java.lang.String spaceKey)
           
 ContentEntityObject getVersion(long originalVersionContentId, int version)
           
 java.util.List getVersionHistorySummary(long originalContentId)
           
 void refresh(com.atlassian.core.bean.EntityObject objectToRefresh)
          Refreshes the object again with the fresh data from db.
 void remove(com.atlassian.core.bean.EntityObject object)
          Remove object from persistence.
 void removeFromPageKeyCache(java.lang.String spaceKey, java.lang.String pageTitle)
          Deprecated. 
 void replicate(java.lang.Object objectToReplicate)
          Replicate the object.
 void save(com.atlassian.core.bean.EntityObject objectToSave)
           
 void save(com.atlassian.core.bean.EntityObject objectToSave, com.atlassian.core.bean.EntityObject originalObject)
           
 void saveRaw(com.atlassian.core.bean.EntityObject objectToSave)
          saves the object.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

CachingPageDao

public CachingPageDao(PageDao delegateDao,
                      PageIdCache pageIdCache)
Method Detail

getPage

public Page getPage(Space space,
                    java.lang.String pageTitle)
Description copied from interface: PageDao
Get the page by space and title.

Specified by:
getPage in interface PageDao
Parameters:
space - The space the page belongs to
pageTitle - The title of the page
Returns:
the page with the given title in the given space, or null if no such page exists

getPageWithComments

public Page getPageWithComments(Space space,
                                java.lang.String pageTitle)
Description copied from interface: PageDao
Get the page by space and title, and perform an eager load of the comments and their children. This can be used as a performance optimisation when it is known that all comments will be displayed.

Specified by:
getPageWithComments in interface PageDao
Parameters:
space - The space the page belongs to
pageTitle - The title of the page
Returns:
the page with the given title in the given space, or null if no such page exists

removeFromPageKeyCache

@Deprecated
public void removeFromPageKeyCache(java.lang.String spaceKey,
                                              java.lang.String pageTitle)
Deprecated. 

Specified by:
removeFromPageKeyCache in interface PageDao

remove

public void remove(com.atlassian.core.bean.EntityObject object)
Description copied from interface: ObjectDao
Remove object from persistence.

Specified by:
remove in interface ObjectDao

save

public void save(com.atlassian.core.bean.EntityObject objectToSave,
                 com.atlassian.core.bean.EntityObject originalObject)
Specified by:
save in interface VersionedObjectDao

save

public void save(com.atlassian.core.bean.EntityObject objectToSave)
Specified by:
save in interface ObjectDao

saveRaw

public void saveRaw(com.atlassian.core.bean.EntityObject objectToSave)
Description copied from interface: ObjectDao
saves the object. if the object is new, this won't set the creation date on the object. if it already exists, then it won't set the date that it was updated.

Specified by:
saveRaw in interface ObjectDao

findAll

public java.util.List findAll()
Description copied from interface: ObjectDao
Find all objects currently persisted of a particular type.

Specified by:
findAll in interface ObjectDao

findAllSorted

public java.util.List findAllSorted(java.lang.String s)
Description copied from interface: ObjectDao
Find all objects currently persisted of a particular type and sort results by named property.

Specified by:
findAllSorted in interface ObjectDao

findLatestVersionsCount

public long findLatestVersionsCount()
Description copied from interface: VersionedObjectDao
Returns the number of results for the latest versions of the current persistent class.

Specified by:
findLatestVersionsCount in interface VersionedObjectDao
Returns:
a long representing the number of results

findLatestVersionsIterator

public java.util.Iterator findLatestVersionsIterator()
Description copied from interface: VersionedObjectDao
Returns an iterator for the latest versions of the current persistent class.

Specified by:
findLatestVersionsIterator in interface VersionedObjectDao
Returns:
Iterator

findPagesWithHistoricalTitle

public java.util.List findPagesWithHistoricalTitle(java.lang.String pageTitle)
Specified by:
findPagesWithHistoricalTitle in interface PageDao

findPreviousVersions

public java.util.List findPreviousVersions(long originalContentId)
Specified by:
findPreviousVersions in interface ContentEntityObjectDao

findPagesWithHistoricalTitleInPermittedSpace

public java.util.List<AbstractPage> findPagesWithHistoricalTitleInPermittedSpace(java.lang.String pageTitle,
                                                                                 Space space,
                                                                                 int maxResultCount)
Description copied from interface: PageDao
Searches for pages in the space specified, looking for those that have the given title in a previous version, and returns the first maxResultCount results.

Only pages in spaces the remote user is able to view will be returned.

Specified by:
findPagesWithHistoricalTitleInPermittedSpace in interface PageDao
Parameters:
pageTitle - title of a page in a previous version.
space - Space to search. Must not be null.
maxResultCount - maximum pages to return

findPagesWithHistoricalTitleInAllPermittedSpacesExcept

public java.util.List<AbstractPage> findPagesWithHistoricalTitleInAllPermittedSpacesExcept(java.lang.String pageTitle,
                                                                                           Space space,
                                                                                           int maxResultCount)
Description copied from interface: PageDao
Searches for pages in all spaces except the one specified, looking for those that have the given title in a previous version, and returns the first maxResultCount results.

Only pages in spaces the remote user is able to view will be returned.

Specified by:
findPagesWithHistoricalTitleInAllPermittedSpacesExcept in interface PageDao
Parameters:
pageTitle - title of a page in a previous version.
space - Space to exclude from search. If null, all spaces are searched.
maxResultCount - maximum pages to return

getAllCurrentEntities

public java.util.Iterator getAllCurrentEntities()
Specified by:
getAllCurrentEntities in interface ContentEntityObjectDao

getAuthoredPagesCountByUser

public int getAuthoredPagesCountByUser(java.lang.String username)
Specified by:
getAuthoredPagesCountByUser in interface PageDao

getById

public ContentEntityObject getById(long id)
Specified by:
getById in interface ContentEntityObjectDao

getContentAuthoredByUser

public java.util.List getContentAuthoredByUser(java.lang.String username)
Specified by:
getContentAuthoredByUser in interface ContentEntityObjectDao

getDescendentIds

public java.util.List getDescendentIds(Page page)
Specified by:
getDescendentIds in interface PageDao

getDescendents

public java.util.List<Page> getDescendents(Page page)
Specified by:
getDescendents in interface PageDao

getFirstVersionAfter

public ContentEntityObject getFirstVersionAfter(long originalVersionContentId,
                                                int version)
Specified by:
getFirstVersionAfter in interface ContentEntityObjectDao

getFirstVersionBefore

public ContentEntityObject getFirstVersionBefore(long originalVersionContentId,
                                                 int version)
Specified by:
getFirstVersionBefore in interface ContentEntityObjectDao

getLockedContentBySpace

public java.util.List getLockedContentBySpace(java.lang.String spaceKey)
Specified by:
getLockedContentBySpace in interface ContentEntityObjectDao

getObjectType

public java.lang.String getObjectType(long id)
Specified by:
getObjectType in interface ContentEntityObjectDao

getOrphanedPages

public java.util.List getOrphanedPages(java.lang.String spaceKey)
Specified by:
getOrphanedPages in interface PageDao

getPageById

public Page getPageById(long id)
Description copied from interface: PageDao
Get the page with the given id.

Specified by:
getPageById in interface PageDao
Parameters:
id - of the page to load
Returns:
the page with the given id, or null if no such page exists

getPageByIdWithComments

public Page getPageByIdWithComments(long id)
Description copied from interface: PageDao
Get the page with the given id, and perform an eager load of the comments and their children. This can be used as a performance optimisation when it is known that all comments will be displayed.

Specified by:
getPageByIdWithComments in interface PageDao
Parameters:
id - of the page to load
Returns:
the page with the given id, or null if no such page exists

getCommentCountOnPage

public int getCommentCountOnPage(long id)
Description copied from interface: PageDao
Count the number of comments on the passed in page.

Specified by:
getCommentCountOnPage in interface PageDao
Returns:

getPageInTrash

public java.util.List getPageInTrash(java.lang.String spaceKey,
                                     java.lang.String title)
Specified by:
getPageInTrash in interface PageDao

getPages

public java.util.List getPages(Space space,
                               boolean currentOnly)
Specified by:
getPages in interface PageDao

getPagesCreatedOrUpdatedSinceDate

public java.util.List getPagesCreatedOrUpdatedSinceDate(java.util.Date previousLoginDate)
Specified by:
getPagesCreatedOrUpdatedSinceDate in interface PageDao

getPagesStartingWith

public java.util.List getPagesStartingWith(Space space,
                                           java.lang.String s)
Specified by:
getPagesStartingWith in interface PageDao

getPermissionPages

public java.util.List getPermissionPages(Space space)
Specified by:
getPermissionPages in interface PageDao

getPersistentClass

public java.lang.Class getPersistentClass()
Specified by:
getPersistentClass in interface ObjectDao

getRecentlyAddedEntities

public java.util.Iterator getRecentlyAddedEntities(java.lang.String spaceKey,
                                                   int maxResults)
Specified by:
getRecentlyAddedEntities in interface ContentEntityObjectDao

getRecentlyAddedPages

public java.util.List getRecentlyAddedPages(int maxCount,
                                            java.lang.String spaceKey)
Specified by:
getRecentlyAddedPages in interface PageDao

getRecentlyAuthoredPagesByUser

public java.util.List getRecentlyAuthoredPagesByUser(java.lang.String username,
                                                     int maxCount)
Specified by:
getRecentlyAuthoredPagesByUser in interface PageDao

getRecentlyModifiedEntities

public java.util.Iterator getRecentlyModifiedEntities(int maxResults)
Specified by:
getRecentlyModifiedEntities in interface ContentEntityObjectDao

getRecentlyModifiedEntities

public java.util.Iterator getRecentlyModifiedEntities(java.lang.String spaceKey,
                                                      int maxResults)
Specified by:
getRecentlyModifiedEntities in interface ContentEntityObjectDao

getRecentlyModifiedEntitiesForUser

public java.util.Iterator getRecentlyModifiedEntitiesForUser(java.lang.String username)
Specified by:
getRecentlyModifiedEntitiesForUser in interface ContentEntityObjectDao

getRecentlyModifiedForChangeDigest

public java.util.List getRecentlyModifiedForChangeDigest(java.util.Date fromDate)
Description copied from interface: ContentEntityObjectDao
Retrieves a list of ContentEntityObjects that have been newly added or modified since the date specified. This list excludes drafts, space descriptions and mail.

Specified by:
getRecentlyModifiedForChangeDigest in interface ContentEntityObjectDao
Parameters:
fromDate - content modified after this date will be returned
Returns:
a list of ContentEntityObjects that have been newly added or modified since the date specified

getRecentlyUpdatedPages

public java.util.List getRecentlyUpdatedPages(int maxCount,
                                              java.lang.String spaceKey)
Specified by:
getRecentlyUpdatedPages in interface PageDao

getTopLevelPages

public java.util.List<Page> getTopLevelPages(Space space)
Specified by:
getTopLevelPages in interface PageDao

getTrashedContent

public java.util.List getTrashedContent(java.lang.String spaceKey)
Specified by:
getTrashedContent in interface ContentEntityObjectDao

getUndefinedPages

public java.util.List getUndefinedPages(java.lang.String spaceKey)
Specified by:
getUndefinedPages in interface PageDao

getVersion

public ContentEntityObject getVersion(long originalVersionContentId,
                                      int version)
Specified by:
getVersion in interface ContentEntityObjectDao

getVersionHistorySummary

public java.util.List getVersionHistorySummary(long originalContentId)
Specified by:
getVersionHistorySummary in interface ContentEntityObjectDao

refresh

public void refresh(com.atlassian.core.bean.EntityObject objectToRefresh)
Description copied from interface: ObjectDao
Refreshes the object again with the fresh data from db.

Specified by:
refresh in interface ObjectDao

replicate

public void replicate(java.lang.Object objectToReplicate)
Description copied from interface: ObjectDao
Replicate the object. Replication does not generate a new id if the object does not exist in database and it overwrites the database row if the object already exists in database.

Specified by:
replicate in interface ObjectDao

getPage

@Deprecated
public Page getPage(java.lang.String spaceKey,
                               java.lang.String pageTitle,
                               boolean eagerLoadComments)
Deprecated. 

Description copied from interface: PageDao
Get the page by space key and title, and perform an eager load of the comments and their children. This can be used as a performance optimisation when it is known that all comments will be displayed.

Specified by:
getPage in interface PageDao
Parameters:
spaceKey - to match with
pageTitle - to match with
eagerLoadComments - true if comments should be loaded eagerly
Returns:
the page

getPage

@Deprecated
public Page getPage(java.lang.String spaceKey,
                               java.lang.String pageTitle)
Deprecated. 

Specified by:
getPage in interface PageDao

getLastEditedVersionsOf

public java.util.List<ContentEntityObject> getLastEditedVersionsOf(ContentEntityObject content)
Description copied from interface: ContentEntityObjectDao
Retrieves all the last edited versions for each user who has contributed to the specified piece of content. That is, if a user has contributed multiple edits, only the version that corresponds to their latest edit will be added to the list returned. Result will be sorted with the earliest version coming first.

Specified by:
getLastEditedVersionsOf in interface ContentEntityObjectDao
Parameters:
content - content (must be the latest version)
Returns:
the last edited versions for each user who has contributed to the specified piece of content.


Copyright © 2003-2010 Atlassian. All Rights Reserved.