Class HibernateSpaceDao
java.lang.Object
org.springframework.dao.support.DaoSupport
com.atlassian.confluence.core.persistence.hibernate.HibernateObjectDao<T>
com.atlassian.confluence.core.persistence.hibernate.ConfluenceHibernateObjectDao<Space>
com.atlassian.confluence.spaces.persistence.dao.hibernate.HibernateSpaceDao
- All Implemented Interfaces:
SpaceDaoInternal
,SpaceDao
,org.springframework.beans.factory.InitializingBean
@ParametersAreNonnullByDefault
public class HibernateSpaceDao
extends ConfluenceHibernateObjectDao<Space>
implements SpaceDaoInternal
-
Nested Class Summary
Nested classes/interfaces inherited from class com.atlassian.confluence.core.persistence.hibernate.HibernateObjectDao
HibernateObjectDao.Cacheability
-
Field Summary
FieldsFields inherited from class org.springframework.dao.support.DaoSupport
logger
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionint
countSpaces
(SpacesQueryWithPermissionQueryBuilder queryWithPermissionClauseBuilder) Count the spaces specified by theSpacesQuery
.Retrieves a list of space keys.int
findPageTotal
(Space space) Fast way to count pages in a space without loading them.findSpaceIdListWithIdGreaterOrEqual
(Long startingId, int limit) Retrieves a limited space list starting with a particular space id.@NonNull Collection<String>
findSpaceKeysWithStatus
(String status) find all space keys where the space status is equal to the given status.@NonNull String
findUniqueVersionOfSpaceKey
(String spaceKey) Return a unique version of the supplied spaceKey.@Nullable Space
getById
(long id) int
getNumberOfBlogPosts
(Space space) Fast way to count blog posts in a space without loading them.@Nullable Space
getPersonalSpace
(@Nullable ConfluenceUser user) @Nullable Space
first tries to fetch the space from the cache by space id if not, fetch it from database@Nullable Space
getSpaceByContentId
(long contentId) Get the space that some content belongs to in a single db query.getSpaces
(SpacesQueryWithPermissionQueryBuilder queryWithPermissionClauseBuilder) Get a list of spaces specified by theSpacesQuery
.getSpaces
(SpacesQueryWithPermissionQueryBuilder queryWithPermissionClauseBuilder, int offset, int maxResults) Get a list of spaces specified by theSpacesQueryWithPermissionQueryBuilder
.getSpacesContainingCommentsByUser
(@Nullable ConfluenceUser user) Find all spaces containing comments by a particular user.getSpacesContainingPagesEditedByUser
(@Nullable ConfluenceUser user) Find all spaces containing pages that were edited by a particular user.getSpacesCreatedAfter
(Date creationDate) getSpacesCreatedByUser
(@Nullable ConfluenceUser user) Find all the spaces created by a given user.getSpacesCreatedOrUpdatedSinceDate
(Date previousLoginDate) void
performOnAll
(Consumer<Space> task) Perform the task with all spaces.void
void
Override the parent remove method as we want to remove the object out of the cache as wellvoid
removeSpaceFromCache
(String spaceKey) Removes a cache element by space key.void
setCacheFactory
(com.atlassian.cache.CacheFactory cacheFactory) Methods inherited from class com.atlassian.confluence.core.persistence.hibernate.ConfluenceHibernateObjectDao
findNamedQueryStringParams, getContentStatusStringList, getStatusNames, scanFilteredContents, scanFilteredContents, updateModificationData
Methods inherited from class com.atlassian.confluence.core.persistence.hibernate.HibernateObjectDao
applyTransactionTimeout, applyTransactionTimeout, checkDaoConfig, createHibernateTemplate, findAll, findAllSorted, findAllSorted, findNamedQuery, findNamedQuery, findNamedQuery, findNamedQueryStringParam, findNamedQueryStringParam, findNamedQueryStringParam, findNamedQueryStringParams, findNamedQueryStringParams, findNamedQueryStringParams, findNamedQueryStringParams, findNamedQueryStringParams, findNamedQueryStringParams, findNamedQueryStringParams, findNamedQueryStringParams, findNamedQueryStringParams, findNamedQueryStringParams, findNamedQueryStringParams, findSingleObject, getByClassId, getCountResult, getHibernateTemplate, getSessionFactory, publishEvent, reIndex, save, saveEntity, saveRaw, setHibernateTemplate, setSessionFactory, uniqueResult
Methods inherited from class org.springframework.dao.support.DaoSupport
afterPropertiesSet, initDao
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface com.atlassian.confluence.internal.spaces.persistence.SpaceDaoInternal
findAllSorted, save
-
Field Details
-
CACHE_KEY
Deprecated.since 5.10
-
-
Constructor Details
-
HibernateSpaceDao
public HibernateSpaceDao()
-
-
Method Details
-
setCacheFactory
public void setCacheFactory(com.atlassian.cache.CacheFactory cacheFactory) -
getById
-
getSpace
first tries to fetch the space from the cache by space id if not, fetch it from database -
getPersonalSpace
- Specified by:
getPersonalSpace
in interfaceSpaceDao
- Parameters:
user
- the user who's personal space is to be retrieved- Returns:
- the personal space for the specified user or null if none exists
-
getSpacesCreatedByUser
Description copied from interface:SpaceDao
Find all the spaces created by a given user.- Specified by:
getSpacesCreatedByUser
in interfaceSpaceDao
-
getSpacesContainingPagesEditedByUser
Description copied from interface:SpaceDao
Find all spaces containing pages that were edited by a particular user. This is for tracking down whether a user can be safely deleted or not.- Specified by:
getSpacesContainingPagesEditedByUser
in interfaceSpaceDao
- Parameters:
user
- the user to track down- Returns:
- a list of the spaces containing pages that were edited by this user, or the empty list if no such spaces exist.
-
getSpacesContainingCommentsByUser
Description copied from interface:SpaceDao
Find all spaces containing comments by a particular user. This is for tracking down whether a user can be safely deleted or not.Does currently not include personal spaces, but probably should.
- Specified by:
getSpacesContainingCommentsByUser
in interfaceSpaceDao
- Parameters:
user
- the user to track down- Returns:
- a list of the spaces containing comments by this user, or the empty list if no such spaces exist.
-
getSpacesCreatedOrUpdatedSinceDate
- Specified by:
getSpacesCreatedOrUpdatedSinceDate
in interfaceSpaceDao
-
findPageTotal
Description copied from interface:SpaceDao
Fast way to count pages in a space without loading them. Counts all pages, not just the current versions.- Specified by:
findPageTotal
in interfaceSpaceDao
- Returns:
- returns the number of all versions of all pages in a space
-
removeSpaceFromCache
Removes a cache element by space key.- Specified by:
removeSpaceFromCache
in interfaceSpaceDaoInternal
- Since:
- 8.3.0
-
refresh
- Specified by:
refresh
in interfaceSpaceDaoInternal
-
remove
Override the parent remove method as we want to remove the object out of the cache as well- Specified by:
remove
in interfaceSpaceDaoInternal
- Overrides:
remove
in classHibernateObjectDao<Space>
- Parameters:
space
- the object to remove
-
getPersistentClass
- Specified by:
getPersistentClass
in classHibernateObjectDao<Space>
-
getNumberOfBlogPosts
Description copied from interface:SpaceDao
Fast way to count blog posts in a space without loading them. Counts all blog posts, not just the current versions.- Specified by:
getNumberOfBlogPosts
in interfaceSpaceDao
- Returns:
- returns the number of all versions of all blog posts in a space
-
getSpacesCreatedAfter
- Specified by:
getSpacesCreatedAfter
in interfaceSpaceDao
-
getSpaces
public @NonNull List<Space> getSpaces(SpacesQueryWithPermissionQueryBuilder queryWithPermissionClauseBuilder, int offset, int maxResults) Description copied from interface:SpaceDao
Get a list of spaces specified by theSpacesQueryWithPermissionQueryBuilder
. -
getSpaces
public @NonNull List<Space> getSpaces(SpacesQueryWithPermissionQueryBuilder queryWithPermissionClauseBuilder) Description copied from interface:SpaceDao
Get a list of spaces specified by theSpacesQuery
. Its recommended to use theSpaceDao.getSpaces(SpacesQueryWithPermissionQueryBuilder, int, int)
form of this method where ever possible. -
countSpaces
Description copied from interface:SpaceDao
Count the spaces specified by theSpacesQuery
.- Specified by:
countSpaces
in interfaceSpaceDao
-
getSpaceByContentId
Description copied from interface:SpaceDao
Get the space that some content belongs to in a single db query. This will only work for content that directly belongs to a space (i.e. Pages, Blog Posts, Space Descriptions but not Comments or Attachments) and it will only work for current content (old content is dissassociated from its space)- Specified by:
getSpaceByContentId
in interfaceSpaceDao
- Parameters:
contentId
- the ID of the content- Returns:
- the space that content belongs to
-
findSpaceKeysWithStatus
Description copied from interface:SpaceDao
find all space keys where the space status is equal to the given status.- Specified by:
findSpaceKeysWithStatus
in interfaceSpaceDao
- Parameters:
status
- the status to search for- Returns:
- all space keys of spaces that match that status
-
findUniqueVersionOfSpaceKey
Description copied from interface:SpaceDao
Return a unique version of the supplied spaceKey. This is done by checking the database for a duplicate and following the algorithm of counting up until a duplicate is achieved e.g. spaceKey_1, spaceKey_2, etc.- Specified by:
findUniqueVersionOfSpaceKey
in interfaceSpaceDao
- Parameters:
spaceKey
- the space key to create a unique version of- Returns:
- the unique space key
-
performOnAll
Description copied from interface:SpaceDao
Perform the task with all spaces.- Specified by:
performOnAll
in interfaceSpaceDao
- Parameters:
task
- apply to spaces.
-
findSpaceIdListWithIdGreaterOrEqual
Retrieves a limited space list starting with a particular space id. It's used when we want to scan all spaces, but do this within a set small transactions.- Specified by:
findSpaceIdListWithIdGreaterOrEqual
in interfaceSpaceDaoInternal
- Parameters:
startingId
- - space idlimit
- - limit- Returns:
- list of space ids
- Since:
- 7.10.0
-
findAllSpaceKeys
Retrieves a list of space keys.- Specified by:
findAllSpaceKeys
in interfaceSpaceDaoInternal
- Returns:
- space key list
- Since:
- 7.10.0
-