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 String CACHE_KEY
           
 
Fields inherited from class com.atlassian.confluence.core.persistence.hibernate.VersionedHibernateObjectDao
cacheFactory, confluenceUserDao
 
Fields inherited from class org.springframework.dao.support.DaoSupport
logger
 
Fields inherited from interface bucket.core.persistence.ObjectDao
NON_CACHEABLE
 
Constructor Summary
HibernateSpaceDao()
           
 
Method Summary
 int countPermittedSpacesForUser(com.atlassian.user.User user, List<com.atlassian.user.Group> groups, String permission)
          Deprecated. 
 int countSpaces(SpacesQuery query)
          Count the spaces specified by the SpacesQuery.
 int findPageTotal(Space space)
          Fast way to count pages in a space without loading them.
 Collection<String> findSpaceKeysWithStatus(String status)
          find all space keys where the space status is equal to the given status.
 String findUniqueVersionOfSpaceKey(String spaceKey)
          Return a unique version of the supplied spaceKey.
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.
 Class<Space> getPersistentClass()
           
 Space getPersonalSpace(ConfluenceUser user)
           
 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)
           
 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 setUserAccessor(UserAccessor userAccessor)
           
 
Methods inherited from class com.atlassian.confluence.core.persistence.hibernate.VersionedHibernateObjectDao
findAllSorted, findLatestVersionsCount, findLatestVersionsIterator, findNamedQueryStringParams, save, setCacheFactory, setConfluenceUserDao, updateModificationData
 
Methods inherited from class com.atlassian.hibernate.HibernateObjectDao
findAll, findAllSorted, findNamedQuery, findNamedQuery, findNamedQuery, findNamedQueryStringParam, findNamedQueryStringParam, findNamedQueryStringParam, findNamedQueryStringParams, findNamedQueryStringParams, findNamedQueryStringParams, findNamedQueryStringParams, findNamedQueryStringParams, findNamedQueryStringParams, findNamedQueryStringParams, findNamedQueryStringParams, findNamedQueryStringParams, findNamedQueryStringParams, findSingleObject, getCountResult, index, refresh, reIndex, replicate, save, saveRaw, setIndexer, unIndex, uniqueResult
 
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, findAllSorted, refresh, replicate, save, saveRaw
 

Field Detail

CACHE_KEY

public static final String CACHE_KEY
Constructor Detail

HibernateSpaceDao

public HibernateSpaceDao()
Method Detail

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(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 Space getPersonalSpace(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 List<Space> getSpacesCreatedByUser(String username)
Description copied from interface: SpaceDao
Find all the spaces created by a given user.

Specified by:
getSpacesCreatedByUser in interface SpaceDao

getSpacesContainingPagesEditedByUser

public List<Space> getSpacesContainingPagesEditedByUser(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 List<Space> getSpacesContainingCommentsByUser(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 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

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

getPersistentClass

public 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 List<Space> getSpacesCreatedAfter(Date creationDate)
Specified by:
getSpacesCreatedAfter in interface SpaceDao

countPermittedSpacesForUser

@Deprecated
public int countPermittedSpacesForUser(com.atlassian.user.User user,
                                                  List<com.atlassian.user.Group> groups,
                                                  String permission)
Deprecated. 

Specified by:
countPermittedSpacesForUser in interface SpaceDao
Returns:
the number of spaces permitted.

getSpaces

public 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

getSpaces

public 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

countSpaces

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

Specified by:
countSpaces in interface SpaceDao

getSpaceByContentId

public 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 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 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

setUserAccessor

public void setUserAccessor(UserAccessor userAccessor)


Copyright © 2003–2015 Atlassian. All rights reserved.