Class HibernateSpaceDao
- java.lang.Object
-
- org.springframework.dao.support.DaoSupport
-
- com.atlassian.confluence.core.persistence.hibernate.HibernateObjectDao<T>
-
- com.atlassian.confluence.core.persistence.hibernate.VersionedHibernateObjectDao<T>
-
- com.atlassian.confluence.core.persistence.hibernate.ConfluenceHibernateObjectDao<Space>
-
- com.atlassian.confluence.spaces.persistence.dao.hibernate.HibernateSpaceDao
-
- All Implemented Interfaces:
ObjectDao
,VersionedObjectDao<Space>
,ObjectDaoInternal<Space>
,VersionedObjectDaoInternal<Space>
,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
Fields Modifier and Type Field Description static String
CACHE_KEY
Deprecated.since 5.10-
Fields inherited from class com.atlassian.confluence.core.persistence.hibernate.VersionedHibernateObjectDao
cacheFactory, confluenceUserDao
-
-
Constructor Summary
Constructors Constructor Description HibernateSpaceDao()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description int
countSpaces(SpacesQueryWithPermissionQueryBuilder queryWithPermissionClauseBuilder)
Count the spaces specified by theSpacesQuery
.List<String>
findAllSpaceKeys()
Retrieves a list of space keys.int
findPageTotal(Space space)
Fast way to count pages in a space without loading them.List<Long>
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.@NonNull Class<Space>
getPersistentClass()
Gets the type ofEntityObject
this Dao works with.@Nullable Space
getPersonalSpace(@Nullable ConfluenceUser user)
@Nullable Space
getSpace(@Nullable String spaceKey)
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.@NonNull List<Space>
getSpaces(SpacesQueryWithPermissionQueryBuilder queryWithPermissionClauseBuilder)
Get a list of spaces specified by theSpacesQuery
.@NonNull List<Space>
getSpaces(SpacesQueryWithPermissionQueryBuilder queryWithPermissionClauseBuilder, int offset, int maxResults)
Get a list of spaces specified by theSpacesQueryWithPermissionQueryBuilder
.@NonNull List<Space>
getSpacesContainingCommentsByUser(@Nullable String username)
Find all spaces containing comments by a particular user.@NonNull List<Space>
getSpacesContainingPagesEditedByUser(@Nullable String username)
Find all spaces containing pages that were edited by a particular user.@NonNull List<Space>
getSpacesCreatedAfter(Date creationDate)
@NonNull List<Space>
getSpacesCreatedByUser(@Nullable String username)
Find all the spaces created by a given user.@NonNull List<Space>
getSpacesCreatedOrUpdatedSinceDate(Date previousLoginDate)
void
performOnAll(Consumer<Space> task)
Perform the task with all spaces.void
remove(com.atlassian.core.bean.EntityObject entity)
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.-
Methods inherited from class com.atlassian.confluence.core.persistence.hibernate.VersionedHibernateObjectDao
findAllSorted, findLatestVersionsCount, findLatestVersionsCount, findLatestVersionsIterator, findLatestVersionsIterator, findNamedQueryStringParams, findNamedQueryStringParams, save, saveEntity, setCacheFactory, setConfluenceUserDao, updateEntityModificationData, updateModificationData
-
Methods inherited from class com.atlassian.confluence.core.persistence.hibernate.HibernateObjectDao
applyTransactionTimeout, applyTransactionTimeout, checkDaoConfig, createHibernateTemplate, findAll, findAllSorted, findByClassIds, findByClassIdsFiltered, findNamedQuery, findNamedQuery, findNamedQuery, findNamedQueryStringParam, findNamedQueryStringParam, findNamedQueryStringParam, findNamedQueryStringParams, findNamedQueryStringParams, findNamedQueryStringParams, findNamedQueryStringParams, findNamedQueryStringParams, findNamedQueryStringParams, findNamedQueryStringParams, findNamedQueryStringParams, findNamedQueryStringParams, findNamedQueryStringParams, findNamedQueryStringParams, findSingleObject, getByClassId, getCountResult, getHibernateTemplate, getSessionFactory, index, indexEntity, refresh, refreshEntity, reIndex, reIndexEntity, removeEntity, replicate, replicateEntity, save, saveEntity, saveRaw, saveRawEntity, setEventPublisher, setHibernateTemplate, setIndexer, setSessionFactory, unIndex, unIndexEntity, uniqueResult
-
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.persistence.ObjectDaoInternal
findAll, findAllSorted, findAllSorted, findByClassIds, findByClassIdsFiltered, refresh, refreshEntity, removeEntity, replicate, replicateEntity, save, saveEntity, saveRaw, saveRawEntity
-
-
-
-
Field Detail
-
CACHE_KEY
@Deprecated public static final String CACHE_KEY
Deprecated.since 5.10
-
-
Method Detail
-
getSpace
public @Nullable Space getSpace(@Nullable String spaceKey)
first tries to fetch the space from the cache by space id if not, fetch it from database
-
getPersonalSpace
public @Nullable Space getPersonalSpace(@Nullable ConfluenceUser user)
- 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
public @NonNull List<Space> getSpacesCreatedByUser(@Nullable String username)
Description copied from interface:SpaceDao
Find all the spaces created by a given user.- Specified by:
getSpacesCreatedByUser
in interfaceSpaceDao
-
getSpacesContainingPagesEditedByUser
public @NonNull List<Space> getSpacesContainingPagesEditedByUser(@Nullable String username)
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:
username
- the name of 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
public @NonNull List<Space> getSpacesContainingCommentsByUser(@Nullable String username)
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:
username
- the name of 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
public @NonNull List<Space> getSpacesCreatedOrUpdatedSinceDate(Date previousLoginDate)
- Specified by:
getSpacesCreatedOrUpdatedSinceDate
in interfaceSpaceDao
-
findPageTotal
public int findPageTotal(Space space)
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
public void removeSpaceFromCache(String spaceKey)
Removes a cache element by space key.- Specified by:
removeSpaceFromCache
in interfaceSpaceDaoInternal
- Since:
- 8.3.0
-
remove
public void remove(com.atlassian.core.bean.EntityObject entity)
Override the parent remove method as we want to remove the object out of the cache as well- Specified by:
remove
in interfaceObjectDao
- Specified by:
remove
in interfaceObjectDaoInternal<Space>
- Overrides:
remove
in classHibernateObjectDao<Space>
- Parameters:
entity
- the object to remove
-
getPersistentClass
public @NonNull Class<Space> getPersistentClass()
Description copied from interface:ObjectDaoInternal
Gets the type ofEntityObject
this Dao works with.- Specified by:
getPersistentClass
in interfaceObjectDao
- Specified by:
getPersistentClass
in interfaceObjectDaoInternal<Space>
- Returns:
- the type
-
getNumberOfBlogPosts
public int getNumberOfBlogPosts(Space space)
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
public @NonNull List<Space> getSpacesCreatedAfter(Date creationDate)
- 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
public int countSpaces(SpacesQueryWithPermissionQueryBuilder queryWithPermissionClauseBuilder)
Description copied from interface:SpaceDao
Count the spaces specified by theSpacesQuery
.- Specified by:
countSpaces
in interfaceSpaceDao
-
getSpaceByContentId
public @Nullable Space getSpaceByContentId(long contentId)
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
public @NonNull Collection<String> findSpaceKeysWithStatus(String status)
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
public @NonNull String findUniqueVersionOfSpaceKey(String spaceKey)
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
public void performOnAll(Consumer<Space> task)
Description copied from interface:SpaceDao
Perform the task with all spaces.- Specified by:
performOnAll
in interfaceSpaceDao
- Parameters:
task
- apply to spaces.
-
findSpaceIdListWithIdGreaterOrEqual
public List<Long> findSpaceIdListWithIdGreaterOrEqual(Long startingId, int limit)
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
public List<String> findAllSpaceKeys()
Retrieves a list of space keys.- Specified by:
findAllSpaceKeys
in interfaceSpaceDaoInternal
- Returns:
- space key list
- Since:
- 7.10.0
-
-