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 StringCACHE_KEYDeprecated.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 intcountSpaces(SpacesQueryWithPermissionQueryBuilder queryWithPermissionClauseBuilder)Count the spaces specified by theSpacesQuery.List<String>findAllSpaceKeys()Retrieves a list of space keys.intfindPageTotal(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 StringfindUniqueVersionOfSpaceKey(String spaceKey)Return a unique version of the supplied spaceKey.@Nullable SpacegetById(long id)intgetNumberOfBlogPosts(Space space)Fast way to count blog posts in a space without loading them.@NonNull Class<Space>getPersistentClass()Gets the type ofEntityObjectthis Dao works with.@Nullable SpacegetPersonalSpace(@Nullable ConfluenceUser user)@Nullable SpacegetSpace(@Nullable String spaceKey)first tries to fetch the space from the cache by space id if not, fetch it from database@Nullable SpacegetSpaceByContentId(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)voidperformOnAll(Consumer<Space> task)Perform the task with all spaces.voidremove(com.atlassian.core.bean.EntityObject entity)Override the parent remove method as we want to remove the object out of the cache as wellvoidremoveSpaceFromCache(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:
 getPersonalSpacein 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:SpaceDaoFind all the spaces created by a given user.- Specified by:
 getSpacesCreatedByUserin interfaceSpaceDao
 
- 
getSpacesContainingPagesEditedByUser
public @NonNull List<Space> getSpacesContainingPagesEditedByUser(@Nullable String username)
Description copied from interface:SpaceDaoFind 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:
 getSpacesContainingPagesEditedByUserin 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:SpaceDaoFind 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:
 getSpacesContainingCommentsByUserin 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:
 getSpacesCreatedOrUpdatedSinceDatein interfaceSpaceDao
 
- 
findPageTotal
public int findPageTotal(Space space)
Description copied from interface:SpaceDaoFast way to count pages in a space without loading them. Counts all pages, not just the current versions.- Specified by:
 findPageTotalin 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:
 removeSpaceFromCachein 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:
 removein interfaceObjectDao- Specified by:
 removein interfaceObjectDaoInternal<Space>- Overrides:
 removein classHibernateObjectDao<Space>- Parameters:
 entity- the object to remove
 
- 
getPersistentClass
public @NonNull Class<Space> getPersistentClass()
Description copied from interface:ObjectDaoInternalGets the type ofEntityObjectthis Dao works with.- Specified by:
 getPersistentClassin interfaceObjectDao- Specified by:
 getPersistentClassin interfaceObjectDaoInternal<Space>- Returns:
 - the type
 
 
- 
getNumberOfBlogPosts
public int getNumberOfBlogPosts(Space space)
Description copied from interface:SpaceDaoFast way to count blog posts in a space without loading them. Counts all blog posts, not just the current versions.- Specified by:
 getNumberOfBlogPostsin 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:
 getSpacesCreatedAfterin interfaceSpaceDao
 
- 
getSpaces
public @NonNull List<Space> getSpaces(SpacesQueryWithPermissionQueryBuilder queryWithPermissionClauseBuilder, int offset, int maxResults)
Description copied from interface:SpaceDaoGet a list of spaces specified by theSpacesQueryWithPermissionQueryBuilder. 
- 
getSpaces
public @NonNull List<Space> getSpaces(SpacesQueryWithPermissionQueryBuilder queryWithPermissionClauseBuilder)
Description copied from interface:SpaceDaoGet 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:SpaceDaoCount the spaces specified by theSpacesQuery.- Specified by:
 countSpacesin interfaceSpaceDao
 
- 
getSpaceByContentId
public @Nullable Space getSpaceByContentId(long contentId)
Description copied from interface:SpaceDaoGet 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:
 getSpaceByContentIdin 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:SpaceDaofind all space keys where the space status is equal to the given status.- Specified by:
 findSpaceKeysWithStatusin 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:SpaceDaoReturn 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:
 findUniqueVersionOfSpaceKeyin 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:SpaceDaoPerform the task with all spaces.- Specified by:
 performOnAllin 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:
 findSpaceIdListWithIdGreaterOrEqualin 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:
 findAllSpaceKeysin interfaceSpaceDaoInternal- Returns:
 - space key list
 - Since:
 - 7.10.0
 
 
 - 
 
 -