java.lang.Object
org.springframework.dao.support.DaoSupport
All Implemented Interfaces:
SpaceDaoInternal, SpaceDao, org.springframework.beans.factory.InitializingBean

@ParametersAreNonnullByDefault public class HibernateSpaceDao extends ConfluenceHibernateObjectDao<Space> implements SpaceDaoInternal
  • Field Details

    • CACHE_KEY

      @Deprecated public static final String CACHE_KEY
      Deprecated.
      since 5.10
  • Constructor Details

    • HibernateSpaceDao

      public HibernateSpaceDao()
  • Method Details

    • setCacheFactory

      public void setCacheFactory(com.atlassian.cache.CacheFactory cacheFactory)
    • getById

      public @Nullable Space getById(long id)
      Specified by:
      getById in interface SpaceDao
    • 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
      Specified by:
      getSpace in interface SpaceDao
    • getPersonalSpace

      public @Nullable Space getPersonalSpace(@Nullable ConfluenceUser user)
      Specified by:
      getPersonalSpace in interface SpaceDao
      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 ConfluenceUser user)
      Description copied from interface: SpaceDao
      Find all the spaces created by a given user.
      Specified by:
      getSpacesCreatedByUser in interface SpaceDao
    • getSpacesContainingPagesEditedByUser

      public @NonNull List<Space> getSpacesContainingPagesEditedByUser(@Nullable ConfluenceUser user)
      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 interface SpaceDao
      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

      public @NonNull List<Space> getSpacesContainingCommentsByUser(@Nullable ConfluenceUser user)
      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 interface SpaceDao
      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

      public @NonNull List<Space> getSpacesCreatedOrUpdatedSinceDate(Date previousLoginDate)
      Specified by:
      getSpacesCreatedOrUpdatedSinceDate in interface SpaceDao
    • 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 interface SpaceDao
      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 interface SpaceDaoInternal
      Since:
      8.3.0
    • refresh

      public void refresh(Space space)
      Specified by:
      refresh in interface SpaceDaoInternal
    • remove

      public void remove(Space space)
      Override the parent remove method as we want to remove the object out of the cache as well
      Specified by:
      remove in interface SpaceDaoInternal
      Overrides:
      remove in class HibernateObjectDao<Space>
      Parameters:
      space - the object to remove
    • getPersistentClass

      public @NonNull Class<Space> getPersistentClass()
      Specified by:
      getPersistentClass in class HibernateObjectDao<Space>
    • 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 interface SpaceDao
      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 interface SpaceDao
    • getSpaces

      public @NonNull List<Space> getSpaces(SpacesQueryWithPermissionQueryBuilder queryWithPermissionClauseBuilder, int offset, int maxResults)
      Description copied from interface: SpaceDao
      Get a list of spaces specified by the SpacesQueryWithPermissionQueryBuilder.
      Specified by:
      getSpaces in interface SpaceDao
    • getSpaces

      public @NonNull List<Space> getSpaces(SpacesQueryWithPermissionQueryBuilder queryWithPermissionClauseBuilder)
      Description copied from interface: SpaceDao
      Get a list of spaces specified by the SpacesQuery. Its recommended to use the SpaceDao.getSpaces(SpacesQueryWithPermissionQueryBuilder, int, int) form of this method where ever possible.
      Specified by:
      getSpaces in interface SpaceDao
    • countSpaces

      public int countSpaces(SpacesQueryWithPermissionQueryBuilder queryWithPermissionClauseBuilder)
      Description copied from interface: SpaceDao
      Count the spaces specified by the SpacesQuery.
      Specified by:
      countSpaces in interface SpaceDao
    • 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 interface SpaceDao
      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 interface SpaceDao
      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 interface SpaceDao
      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 interface SpaceDao
      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 interface SpaceDaoInternal
      Parameters:
      startingId - - space id
      limit - - 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 interface SpaceDaoInternal
      Returns:
      space key list
      Since:
      7.10.0