public class

HibernateSpaceDao

extends ConfluenceHibernateObjectDao
implements SpaceDao
java.lang.Object
   ↳ org.springframework.dao.support.DaoSupport
     ↳ org.springframework.orm.hibernate.support.HibernateDaoSupport
       ↳ com.atlassian.hibernate.HibernateObjectDao
         ↳ com.atlassian.confluence.core.persistence.hibernate.VersionedHibernateObjectDao<T extends com.atlassian.core.bean.EntityObject>
           ↳ com.atlassian.confluence.core.persistence.hibernate.ConfluenceHibernateObjectDao
             ↳ com.atlassian.confluence.spaces.persistence.dao.hibernate.HibernateSpaceDao

Summary

Fields
public static final String CACHE_KEY_SPACE_KEY_TO_SPACEID
[Expand]
Inherited Fields
From class com.atlassian.confluence.core.persistence.hibernate.VersionedHibernateObjectDao
From class com.atlassian.hibernate.HibernateObjectDao
From class org.springframework.dao.support.DaoSupport
Public Constructors
HibernateSpaceDao()
Public Methods
int countPermittedSpacesForUser(User user, List<Group> groups, String permission)
int countSpaces(SpacesQuery query)
Count the spaces specified by the SpacesQuery.
List<Space> findAllGlobalSpaces()
List<Space> findAllSpacesSorted(String sortField, SpaceType type)
Like findAllSorted, but allows you to query for a specific type of space
int findPageTotal(Space space)
Fast way to count pages in a space without loading them.
Space getById(long id)
int getNumberOfBlogPosts(Space space)
Fast way to count blog posts in a space without loading them.
int getNumberOfMail(Space space)
Fast way to count pages in a space without loading them.
List<Space> getPermittedSpacesForUser(User user, List<Group> groups, String permission, int offset, int maxResults)
Return a single page of spaces for a user with a particular permission
@Deprecated List<Space> getPermittedSpacesForUser(User user, String permission)
Find all spaces on which the given user has the given permission
List<Space> getPermittedSpacesForUser(User user, List<Group> groups, String permission)
The database queries order the space's returned by spacename and then spacekey.
@Deprecated List<Space> getPermittedSpacesForUserByType(User user, String permission, SpaceType type)
Find all spaces of a certain type on which the given user has the given permission
List<Space> getPermittedSpacesForUserByType(User user, List<Group> groups, String permission, SpaceType type)
Query for spaces by type.
@Deprecated List<Space> getPermittedSpacesForUserInSpaceGroup(User user, String permission, SpaceGroup spaceGroup)
Find all spaces within a spaceGroup to which the given user has the given permission
List<Space> getPermittedSpacesForUserInSpaceGroup(User user, List<Group> groups, String permission, SpaceGroup spaceGroup)
Query for spaces by type.
Class<Space> getPersistentClass()
Space getSpace(String spaceKey)
first tries to fetch the space from the cache by space id if not, fetch it from database
Space getSpaceByContentId(long contentId)
Get the space that some content belongs to in a single db query.
List<Space> getSpaces(SpacesQuery query)
Get a list of spaces specified by the SpacesQuery.
List<Space> getSpaces(SpacesQuery query, int offset, int maxResults)
Get a list of spaces specified by the SpacesQuery.
List<Space> getSpacesContainingCommentsByUser(String username)
Find all spaces containing comments by a particular user.
List<Space> getSpacesContainingPagesEditedByUser(String username)
Find all spaces containing pages that were edited by a particular user.
List<Space> getSpacesCreatedAfter(Date creationDate)
List<Space> getSpacesCreatedByUser(String username)
Find all the spaces created by a given user.
List<Space> getSpacesCreatedOrUpdatedSinceDate(Date previousLoginDate)
List<Space> getSpacesInSpaceGroup(SpaceGroup spaceGroup)
Find all spaces within a given spaceGroup
void remove(EntityObject entity)
Override the parent remove method as we want to remove the object out of the cache as well
void setHibernateConfig(HibernateConfig hibernateConfig)
void setUserAccessor(UserAccessor userAccessor)
Protected Methods
EntityObject getByClassId(long l)
Retrieve the object with a particular id from the database.
[Expand]
Inherited Methods
From class com.atlassian.confluence.core.persistence.hibernate.VersionedHibernateObjectDao
From class com.atlassian.hibernate.HibernateObjectDao
From class org.springframework.orm.hibernate.support.HibernateDaoSupport
From class org.springframework.dao.support.DaoSupport
From class java.lang.Object
From interface bucket.core.persistence.ObjectDao
From interface com.atlassian.confluence.core.persistence.VersionedObjectDao
From interface com.atlassian.confluence.spaces.persistence.dao.SpaceDao
From interface org.springframework.beans.factory.InitializingBean

Fields

public static final String CACHE_KEY_SPACE_KEY_TO_SPACEID

Public Constructors

public HibernateSpaceDao ()

Public Methods

public int countPermittedSpacesForUser (User user, List<Group> groups, String permission)

public int countSpaces (SpacesQuery query)

Count the spaces specified by the SpacesQuery.

public List<Space> findAllGlobalSpaces ()

public List<Space> findAllSpacesSorted (String sortField, SpaceType type)

Like findAllSorted, but allows you to query for a specific type of space

public int findPageTotal (Space space)

Fast way to count pages in a space without loading them. Counts all pages, not just the current versions.

Returns
  • returns the number of all versions of all pages in a space

public Space getById (long id)

public int getNumberOfBlogPosts (Space space)

Fast way to count blog posts in a space without loading them. Counts all blog posts, not just the current versions.

Returns
  • returns the number of all versions of all blog posts in a space

public int getNumberOfMail (Space space)

Fast way to count pages in a space without loading them. Counts all mail, not just the current versions.

Returns
  • returns the number of all versions of all mail in a space

public List<Space> getPermittedSpacesForUser (User user, List<Group> groups, String permission, int offset, int maxResults)

Return a single page of spaces for a user with a particular permission

@Deprecated public List<Space> getPermittedSpacesForUser (User user, String permission)

Find all spaces on which the given user has the given permission

public List<Space> getPermittedSpacesForUser (User user, List<Group> groups, String permission)

The database queries order the space's returned by spacename and then spacekey.

@Deprecated public List<Space> getPermittedSpacesForUserByType (User user, String permission, SpaceType type)

Find all spaces of a certain type on which the given user has the given permission

public List<Space> getPermittedSpacesForUserByType (User user, List<Group> groups, String permission, SpaceType type)

Query for spaces by type.

@Deprecated public List<Space> getPermittedSpacesForUserInSpaceGroup (User user, String permission, SpaceGroup spaceGroup)

Find all spaces within a spaceGroup to which the given user has the given permission

public List<Space> getPermittedSpacesForUserInSpaceGroup (User user, List<Group> groups, String permission, SpaceGroup spaceGroup)

Query for spaces by type.

public Class<Space> getPersistentClass ()

public Space getSpace (String spaceKey)

first tries to fetch the space from the cache by space id if not, fetch it from database

public Space getSpaceByContentId (long contentId)

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)

Parameters
contentId the ID of the content
Returns
  • the space that content belongs to

public List<Space> getSpaces (SpacesQuery query)

Get a list of spaces specified by the SpacesQuery. Its recommended to use the getSpaces(com.atlassian.confluence.spaces.SpacesQuery, int, int) form of this method where ever possible.

public List<Space> getSpaces (SpacesQuery query, int offset, int maxResults)

Get a list of spaces specified by the SpacesQuery.

public List<Space> getSpacesContainingCommentsByUser (String username)

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.

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.

public List<Space> getSpacesContainingPagesEditedByUser (String username)

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.

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.

public List<Space> getSpacesCreatedAfter (Date creationDate)

public List<Space> getSpacesCreatedByUser (String username)

Find all the spaces created by a given user.

public List<Space> getSpacesCreatedOrUpdatedSinceDate (Date previousLoginDate)

public List<Space> getSpacesInSpaceGroup (SpaceGroup spaceGroup)

Find all spaces within a given spaceGroup

Parameters
spaceGroup the group
Returns
  • List of spaces

public void remove (EntityObject entity)

Override the parent remove method as we want to remove the object out of the cache as well

Parameters
entity the object to remove

public void setHibernateConfig (HibernateConfig hibernateConfig)

public void setUserAccessor (UserAccessor userAccessor)

Protected Methods

protected EntityObject getByClassId (long l)

Retrieve the object with a particular id from the database. The object must be of the same class as the DAO's getPersistentClass() method returns.

Parameters
l the id of the object to look up
Returns
  • the corresponding object, or null if the object does not exist with the appropriate class and id.