com.atlassian.confluence.spaces.persistence.dao.hibernate
Class HibernateSpaceDao

java.lang.Object
  extended by org.springframework.dao.support.DaoSupport
      extended by org.springframework.orm.hibernate.support.HibernateDaoSupport
          extended by com.atlassian.hibernate.HibernateObjectDao
              extended by com.atlassian.confluence.core.persistence.hibernate.VersionedHibernateObjectDao
                  extended by com.atlassian.confluence.core.persistence.hibernate.ConfluenceHibernateObjectDao
                      extended by com.atlassian.confluence.spaces.persistence.dao.hibernate.HibernateSpaceDao
All Implemented Interfaces:
ObjectDao, VersionedObjectDao, SpaceDao, org.springframework.beans.factory.InitializingBean

public class HibernateSpaceDao
extends ConfluenceHibernateObjectDao
implements SpaceDao


Field Summary
static java.lang.String CACHE_KEY_SPACE_KEY_TO_SPACEID
           
 
Fields inherited from class com.atlassian.confluence.core.persistence.hibernate.VersionedHibernateObjectDao
cacheFactory
 
Fields inherited from class org.springframework.dao.support.DaoSupport
logger
 
Constructor Summary
HibernateSpaceDao()
           
 
Method Summary
 int countPermittedSpacesForUser(com.atlassian.user.User user, java.util.List<com.atlassian.user.Group> groups, java.lang.String permission)
           
 int countSpaces(SpacesQuery query)
          Count the spaces specified by the SpacesQuery.
 java.util.List<Space> findAllGlobalSpaces()
           
 java.util.List<Space> findAllSpacesSorted(java.lang.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.
protected  com.atlassian.core.bean.EntityObject getByClassId(long l)
          Retrieve the object with a particular id from the database.
 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.
 java.util.List<Space> getPermittedSpacesForUser(com.atlassian.user.User user, java.util.List<com.atlassian.user.Group> groups, java.lang.String permission)
          The database queries order the space's returned by spacename and then spacekey.
 java.util.List<Space> getPermittedSpacesForUser(com.atlassian.user.User user, java.util.List<com.atlassian.user.Group> groups, java.lang.String permission, int offset, int maxResults)
          Return a single page of spaces for a user with a particular permission
 java.util.List<Space> getPermittedSpacesForUser(com.atlassian.user.User user, java.lang.String permission)
          Deprecated. 
 java.util.List<Space> getPermittedSpacesForUserByType(com.atlassian.user.User user, java.util.List<com.atlassian.user.Group> groups, java.lang.String permission, SpaceType type)
          Query for spaces by type.
 java.util.List<Space> getPermittedSpacesForUserByType(com.atlassian.user.User user, java.lang.String permission, SpaceType type)
          Deprecated. 
 java.util.List<Space> getPermittedSpacesForUserInSpaceGroup(com.atlassian.user.User user, java.util.List<com.atlassian.user.Group> groups, java.lang.String permission, SpaceGroup spaceGroup)
          Query for spaces by type.
 java.util.List<Space> getPermittedSpacesForUserInSpaceGroup(com.atlassian.user.User user, java.lang.String permission, SpaceGroup spaceGroup)
          Deprecated. 
 java.lang.Class<Space> getPersistentClass()
           
 Space getSpace(java.lang.String spaceKey)
          first tries to fetch the space from the cache by space id if not, fetch it from database
 java.util.List<Space> getSpaces(SpacesQuery query)
          Get a list of spaces specified by the SpacesQuery.
 java.util.List<Space> getSpaces(SpacesQuery query, int offset, int maxResults)
          Get a list of spaces specified by the SpacesQuery.
 java.util.List<Space> getSpacesContainingCommentsByUser(java.lang.String username)
          Find all spaces containing comments by a particular user.
 java.util.List<Space> getSpacesContainingPagesEditedByUser(java.lang.String username)
          Find all spaces containing pages that were edited by a particular user.
 java.util.List<Space> getSpacesCreatedAfter(java.util.Date creationDate)
           
 java.util.List<Space> getSpacesCreatedByUser(java.lang.String username)
          Find all the spaces created by a given user.
 java.util.List<Space> getSpacesCreatedOrUpdatedSinceDate(java.util.Date previousLoginDate)
           
 java.util.List<Space> getSpacesInSpaceGroup(SpaceGroup spaceGroup)
          Find all spaces within a given spaceGroup
 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
 void setHibernateConfig(com.atlassian.config.db.HibernateConfig hibernateConfig)
           
 void setUserAccessor(UserAccessor userAccessor)
           
 
Methods inherited from class com.atlassian.confluence.core.persistence.hibernate.ConfluenceHibernateObjectDao
findByQuery
 
Methods inherited from class com.atlassian.confluence.core.persistence.hibernate.VersionedHibernateObjectDao
findAllSorted, findLatestVersionsCount, findLatestVersionsIterator, save, setCacheFactory, updateModificationData
 
Methods inherited from class com.atlassian.hibernate.HibernateObjectDao
findAll, findNamedQuery, findNamedQuery, findNamedQuery, findNamedQueryStringParam, findNamedQueryStringParam, findNamedQueryStringParam, findNamedQueryStringParams, findNamedQueryStringParams, findNamedQueryStringParams, findNamedQueryStringParams, findNamedQueryStringParams, findNamedQueryStringParams, findNamedQueryStringParams, findNamedQueryStringParams, findNamedQueryStringParams, findNamedQueryStringParams, findSingleObject, index, refresh, reIndex, replicate, save, saveRaw, setIndexer, unIndex
 
Methods inherited from class org.springframework.orm.hibernate.support.HibernateDaoSupport
checkDaoConfig, convertHibernateAccessException, createHibernateTemplate, getHibernateTemplate, getSession, getSession, getSessionFactory, releaseSession, setHibernateTemplate, setSessionFactory
 
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 bucket.core.persistence.ObjectDao
findAll, findAllSorted, refresh, replicate, save, saveRaw
 

Field Detail

CACHE_KEY_SPACE_KEY_TO_SPACEID

public static final java.lang.String CACHE_KEY_SPACE_KEY_TO_SPACEID
Constructor Detail

HibernateSpaceDao

public HibernateSpaceDao()
Method Detail

findAllGlobalSpaces

public java.util.List<Space> findAllGlobalSpaces()
Specified by:
findAllGlobalSpaces in interface SpaceDao
Returns:

findAllSpacesSorted

public java.util.List<Space> findAllSpacesSorted(java.lang.String sortField,
                                                 SpaceType type)
Like findAllSorted, but allows you to query for a specific type of space

Specified by:
findAllSpacesSorted in interface SpaceDao
Returns:
sorted List of spaces

getByClassId

protected com.atlassian.core.bean.EntityObject getByClassId(long l)
Description copied from class: HibernateObjectDao
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.

Overrides:
getByClassId in class HibernateObjectDao
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.

getById

public Space getById(long id)
Specified by:
getById in interface SpaceDao

getSpace

public Space getSpace(java.lang.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

getSpacesInSpaceGroup

public java.util.List<Space> getSpacesInSpaceGroup(SpaceGroup spaceGroup)
Description copied from interface: SpaceDao
Find all spaces within a given spaceGroup

Specified by:
getSpacesInSpaceGroup in interface SpaceDao
Returns:
List of spaces

getSpacesCreatedByUser

public java.util.List<Space> getSpacesCreatedByUser(java.lang.String username)
Description copied from interface: SpaceDao
Find all the spaces created by a given user.

Specified by:
getSpacesCreatedByUser in interface SpaceDao

getSpacesContainingPagesEditedByUser

public java.util.List<Space> getSpacesContainingPagesEditedByUser(java.lang.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 interface SpaceDao
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 java.util.List<Space> getSpacesContainingCommentsByUser(java.lang.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 interface SpaceDao
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 java.util.List<Space> getSpacesCreatedOrUpdatedSinceDate(java.util.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

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 interface ObjectDao
Overrides:
remove in class HibernateObjectDao
Parameters:
entity - the object to remove

setHibernateConfig

public void setHibernateConfig(com.atlassian.config.db.HibernateConfig hibernateConfig)

getPersistentClass

public java.lang.Class<Space> getPersistentClass()
Specified by:
getPersistentClass in interface ObjectDao

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

getNumberOfMail

public int getNumberOfMail(Space space)
Description copied from interface: SpaceDao
Fast way to count pages in a space without loading them. Counts all mail, not just the current versions.

Specified by:
getNumberOfMail in interface SpaceDao
Returns:
returns the number of all versions of all mail in a space

getSpacesCreatedAfter

public java.util.List<Space> getSpacesCreatedAfter(java.util.Date creationDate)
Specified by:
getSpacesCreatedAfter in interface SpaceDao

getPermittedSpacesForUser

@Deprecated
public java.util.List<Space> getPermittedSpacesForUser(com.atlassian.user.User user,
                                                                  java.lang.String permission)
Deprecated. 

Description copied from interface: SpaceDao
Find all spaces on which the given user has the given permission

Specified by:
getPermittedSpacesForUser in interface SpaceDao

getPermittedSpacesForUser

public java.util.List<Space> getPermittedSpacesForUser(com.atlassian.user.User user,
                                                       java.util.List<com.atlassian.user.Group> groups,
                                                       java.lang.String permission)
The database queries order the space's returned by spacename and then spacekey.

Specified by:
getPermittedSpacesForUser in interface SpaceDao

getPermittedSpacesForUser

public java.util.List<Space> getPermittedSpacesForUser(com.atlassian.user.User user,
                                                       java.util.List<com.atlassian.user.Group> groups,
                                                       java.lang.String permission,
                                                       int offset,
                                                       int maxResults)
Description copied from interface: SpaceDao
Return a single page of spaces for a user with a particular permission

Specified by:
getPermittedSpacesForUser in interface SpaceDao

countPermittedSpacesForUser

public int countPermittedSpacesForUser(com.atlassian.user.User user,
                                       java.util.List<com.atlassian.user.Group> groups,
                                       java.lang.String permission)
Specified by:
countPermittedSpacesForUser in interface SpaceDao

getPermittedSpacesForUserByType

@Deprecated
public java.util.List<Space> getPermittedSpacesForUserByType(com.atlassian.user.User user,
                                                                        java.lang.String permission,
                                                                        SpaceType type)
Deprecated. 

Description copied from interface: SpaceDao
Find all spaces of a certain type on which the given user has the given permission

Specified by:
getPermittedSpacesForUserByType in interface SpaceDao

getPermittedSpacesForUserByType

public java.util.List<Space> getPermittedSpacesForUserByType(com.atlassian.user.User user,
                                                             java.util.List<com.atlassian.user.Group> groups,
                                                             java.lang.String permission,
                                                             SpaceType type)
Query for spaces by type.

Specified by:
getPermittedSpacesForUserByType in interface SpaceDao

getPermittedSpacesForUserInSpaceGroup

@Deprecated
public java.util.List<Space> getPermittedSpacesForUserInSpaceGroup(com.atlassian.user.User user,
                                                                              java.lang.String permission,
                                                                              SpaceGroup spaceGroup)
Deprecated. 

Description copied from interface: SpaceDao
Find all spaces within a spaceGroup to which the given user has the given permission

Specified by:
getPermittedSpacesForUserInSpaceGroup in interface SpaceDao

getPermittedSpacesForUserInSpaceGroup

public java.util.List<Space> getPermittedSpacesForUserInSpaceGroup(com.atlassian.user.User user,
                                                                   java.util.List<com.atlassian.user.Group> groups,
                                                                   java.lang.String permission,
                                                                   SpaceGroup spaceGroup)
Query for spaces by type.

Specified by:
getPermittedSpacesForUserInSpaceGroup in interface SpaceDao

getSpaces

public java.util.List<Space> getSpaces(SpacesQuery query,
                                       int offset,
                                       int maxResults)
Description copied from interface: SpaceDao
Get a list of spaces specified by the SpacesQuery.

Specified by:
getSpaces in interface SpaceDao
Returns:

getSpaces

public java.util.List<Space> getSpaces(SpacesQuery query)
Description copied from interface: SpaceDao
Get a list of spaces specified by the SpacesQuery. Its recommended to use the SpaceDao.getSpaces(com.atlassian.confluence.spaces.SpacesQuery, int, int) form of this method where ever possible.

Specified by:
getSpaces in interface SpaceDao
Returns:

countSpaces

public int countSpaces(SpacesQuery query)
Description copied from interface: SpaceDao
Count the spaces specified by the SpacesQuery.

Specified by:
countSpaces in interface SpaceDao
Returns:

setUserAccessor

public void setUserAccessor(UserAccessor userAccessor)


Copyright © 2003-2010 Atlassian. All Rights Reserved.