com.atlassian.confluence.spaces
Class DefaultSpaceManager

java.lang.Object
  extended by com.atlassian.confluence.spaces.DefaultSpaceManager
All Implemented Interfaces:
SpaceManager

public class DefaultSpaceManager
extends java.lang.Object
implements SpaceManager


Field Summary
static java.lang.String DEFAULT_HOMEPAGE_CONTENT
           
static java.lang.String DEFAULT_HOMEPAGE_TITLE
           
static java.lang.String DEFAULT_INDEX_CONTENT
           
static java.lang.String DEFAULT_INDEX_TITLE
           
static org.apache.log4j.Category log
           
 
Fields inherited from interface com.atlassian.confluence.spaces.SpaceManager
PERSONAL_SPACEKEY_IDENTIFIER
 
Constructor Summary
DefaultSpaceManager()
           
 
Method Summary
 void convertToPersonalSpace(Space space, com.atlassian.user.User owner, boolean updateLinks)
          Convert a global space into a user's personal space.
 Space createPersonalSpace(java.lang.String name, java.lang.String description, com.atlassian.user.User owner)
          Creates a personal space.
 Space createSpace(java.lang.String key, java.lang.String name, java.lang.String description, com.atlassian.user.User creator)
           
 void ensureSpaceDescriptionExists(Space space)
          If the given Space does not have a description, creates one for it, and saves it.
 long findPageTotal(Space space)
          Get the number of pages in a space.
 java.util.List getAllSpaces()
          Finds all spaces in Confluence, of any type.
 java.util.List getAuthoredSpacesByUser(java.lang.String username)
           
 java.util.List getBlogPosts(Space space, boolean currentOnly)
           
 DraftManager getDraftManager()
           
 java.util.List getEditableSpacesByType(com.atlassian.user.User user, SpaceType type)
          Return all spaces of a given type in which the user can create or edit pages
 java.util.List getMail(Space space, boolean currentOnly)
           
 int getNumberOfBlogPosts(Space space)
          Get the number of blog posts in a space.
 int getNumberOfMail(Space space)
          Get the number of archived emails in a space.
 java.util.List getPages(Space space, boolean currentOnly)
           
 java.util.List getPagesStartingWith(Space space, java.lang.String s)
           
 java.util.List getPermittedSpaces(com.atlassian.user.User user)
          Return all spaces for which the the user has VIEW permission.
 java.util.List getPermittedSpacesByType(com.atlassian.user.User user, SpaceType type)
          Return all spaces of a given type for which the user has VIEW permission.
 java.util.List getPermittedSpacesInSpaceGroup(com.atlassian.user.User user, SpaceGroup spaceGroup)
          Return all spaces within a given spaceGroup for which the user has VIEW permission
 Space getPersonalSpace(java.lang.String username)
          Get the personal space for the user with the given username
 Space getPersonalSpace(com.atlassian.user.User user)
          Get the personal space of the given user.
 java.lang.String getPersonalSpaceKey(java.lang.String username)
           
 Space getSpace(long id)
          Retrieve a space by its ID.
 Space getSpace(java.lang.String exactKey)
          Retrieve a space by its key.
 java.util.List getSpaceContent(Space space, boolean currentOnly)
           
 java.lang.String getSpaceFromPageId(long pageId)
          Get the key for a space from its pageId in a single db call
 java.util.List getSpaces()
          Method to get a list of all global spaces in Confluence Warning: Despite the name, this method only returns global spaces.
 java.util.List getSpacesByType(SpaceType type)
           
 java.util.List getSpacesContainingCommentsBy(java.lang.String username)
           
 java.util.List getSpacesContainingPagesEditedBy(java.lang.String username)
           
 java.util.List getSpacesCreatedAfter(java.util.Date creationDate)
           
 java.util.List getSpacesCreatedOrUpdatedSinceDate(java.util.Date previousLoginDate)
           
 java.util.List getSpacesEditableByUser(com.atlassian.user.User user)
          Return all spaces in which the the can create or edit pages.
 java.util.List getSpacesInSpaceGroup(SpaceGroup spaceGroup)
           
 boolean isValidPersonalSpaceKey(java.lang.String key)
          Deprecated. since 2.3 use Space.isValidPersonalSpaceKey(String) instead
 boolean isValidSpaceKey(java.lang.String key)
          Deprecated. since 2.3 use Space.isValidGlobalSpaceKey(String) instead
 void moveHierarchy(Page topPage, Page newParentPage, Space newSpace, com.atlassian.user.User user, boolean moveChildren, java.util.List pagesToIndex)
          Moves a page and its hierarchy to a new parent page, space, or both.
 void removeSpace(Space space)
           
 void removeSpacesInGroup(SpaceGroup spaceGroup)
           
 void saveSpace(Space space)
           
 void saveSpace(Space space, Space originalSpace)
           
 void setBandanaPersister(com.atlassian.bandana.BandanaPersister bandanaPersister)
           
 void setContentPermissionManager(ContentPermissionManager contentPermissionManager)
           
 void setDraftManager(DraftManager draftManager)
           
 void setEventManager(com.atlassian.event.EventManager eventManager)
           
 void setIndexer(ConfluenceIndexer indexer)
           
 void setIndexManager(ConfluenceIndexManager indexManager)
           
 void setLabelManager(LabelManager labelManager)
           
 void setMailContentManager(MailContentManager mailContentManager)
           
 void setNotificationManager(NotificationManager notificationManager)
           
 void setPageManager(PageManager pageManager)
           
 void setPageTemplateManager(PageTemplateManager templateManager)
           
 void setSpaceDao(SpaceDao spaceDao)
           
 void setSpaceDescriptionManager(SpaceDescriptionManager spaceDescriptionManager)
           
 void setSpacePermissionManager(SpacePermissionManager spacePermissionManager)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

log

public static final org.apache.log4j.Category log

DEFAULT_HOMEPAGE_TITLE

public static final java.lang.String DEFAULT_HOMEPAGE_TITLE
See Also:
Constant Field Values

DEFAULT_HOMEPAGE_CONTENT

public static final java.lang.String DEFAULT_HOMEPAGE_CONTENT
See Also:
Constant Field Values

DEFAULT_INDEX_TITLE

public static final java.lang.String DEFAULT_INDEX_TITLE
See Also:
Constant Field Values

DEFAULT_INDEX_CONTENT

public static final java.lang.String DEFAULT_INDEX_CONTENT
See Also:
Constant Field Values
Constructor Detail

DefaultSpaceManager

public DefaultSpaceManager()
Method Detail

setSpaceDao

public void setSpaceDao(SpaceDao spaceDao)

isValidSpaceKey

public boolean isValidSpaceKey(java.lang.String key)
Deprecated. since 2.3 use Space.isValidGlobalSpaceKey(String) instead

Specified by:
isValidSpaceKey in interface SpaceManager

isValidPersonalSpaceKey

public boolean isValidPersonalSpaceKey(java.lang.String key)
Deprecated. since 2.3 use Space.isValidPersonalSpaceKey(String) instead

Specified by:
isValidPersonalSpaceKey in interface SpaceManager

setSpaceDescriptionManager

public void setSpaceDescriptionManager(SpaceDescriptionManager spaceDescriptionManager)

setPageManager

public void setPageManager(PageManager pageManager)

setSpacePermissionManager

public void setSpacePermissionManager(SpacePermissionManager spacePermissionManager)

getSpace

public Space getSpace(long id)
Description copied from interface: SpaceManager
Retrieve a space by its ID. The space can be of any type.

Specified by:
getSpace in interface SpaceManager
Parameters:
id - the ID of the space
Returns:
the space, or null if no space exists with that id.

getSpace

public Space getSpace(java.lang.String exactKey)
Description copied from interface: SpaceManager
Retrieve a space by its key. The space can be of any type.

Specified by:
getSpace in interface SpaceManager
Parameters:
exactKey - the space key of the space to retrieve
Returns:
the space, or null if no space exists with that key

getPersonalSpace

public Space getPersonalSpace(java.lang.String username)
Description copied from interface: SpaceManager
Get the personal space for the user with the given username

Specified by:
getPersonalSpace in interface SpaceManager
Parameters:
username - the username of the user to get the personal space of
Returns:
the personal space for that user, or null if the user has no personal space

setIndexer

public void setIndexer(ConfluenceIndexer indexer)

removeSpace

public void removeSpace(Space space)
Specified by:
removeSpace in interface SpaceManager

removeSpacesInGroup

public void removeSpacesInGroup(SpaceGroup spaceGroup)
Specified by:
removeSpacesInGroup in interface SpaceManager

saveSpace

public void saveSpace(Space space)
Specified by:
saveSpace in interface SpaceManager

saveSpace

public void saveSpace(Space space,
                      Space originalSpace)
Specified by:
saveSpace in interface SpaceManager

getAllSpaces

public java.util.List getAllSpaces()
Description copied from interface: SpaceManager
Finds all spaces in Confluence, of any type.

Specified by:
getAllSpaces in interface SpaceManager
Returns:
List of spaces

getSpaces

public java.util.List getSpaces()
Description copied from interface: SpaceManager
Method to get a list of all global spaces in Confluence Warning: Despite the name, this method only returns global spaces. This is why we've deprecated it in favour of the more clearly named methods.

Specified by:
getSpaces in interface SpaceManager
Returns:
List of global spaces

getSpacesByType

public java.util.List getSpacesByType(SpaceType type)
Specified by:
getSpacesByType in interface SpaceManager

getSpacesInSpaceGroup

public java.util.List getSpacesInSpaceGroup(SpaceGroup spaceGroup)
Specified by:
getSpacesInSpaceGroup in interface SpaceManager

getPermittedSpaces

public java.util.List getPermittedSpaces(com.atlassian.user.User user)
Description copied from interface: SpaceManager
Return all spaces for which the the user has VIEW permission.

Specified by:
getPermittedSpaces in interface SpaceManager
Parameters:
user - the user to check permissions against, or null for the anonymous user
Returns:
a list of all spaces that user is permitted to VIEW

getPermittedSpacesByType

public java.util.List getPermittedSpacesByType(com.atlassian.user.User user,
                                               SpaceType type)
Description copied from interface: SpaceManager
Return all spaces of a given type for which the user has VIEW permission.

Specified by:
getPermittedSpacesByType in interface SpaceManager
Parameters:
user - the user to check permissions against, or null for the anonymous user
type - the type of space to return
Returns:
a list of all spaces of that type the user is permitted to VIEW

getPermittedSpacesInSpaceGroup

public java.util.List getPermittedSpacesInSpaceGroup(com.atlassian.user.User user,
                                                     SpaceGroup spaceGroup)
Description copied from interface: SpaceManager
Return all spaces within a given spaceGroup for which the user has VIEW permission

Specified by:
getPermittedSpacesInSpaceGroup in interface SpaceManager
Parameters:
user - the user to check permissions against, or null for the anonymous user
spaceGroup - the spaceGroup from which we query the spaces
Returns:
a list of all spaces within the spaceGroup for which the user has VIEW permission

getEditableSpacesByType

public java.util.List getEditableSpacesByType(com.atlassian.user.User user,
                                              SpaceType type)
Description copied from interface: SpaceManager
Return all spaces of a given type in which the user can create or edit pages

Specified by:
getEditableSpacesByType in interface SpaceManager
Parameters:
user - the user to check permissions against, or null for the anonymous user
type - the type of space to return
Returns:
a list of all spaces of that type in which the user can create or edit pages

getSpacesEditableByUser

public java.util.List getSpacesEditableByUser(com.atlassian.user.User user)
Description copied from interface: SpaceManager
Return all spaces in which the the can create or edit pages.

Specified by:
getSpacesEditableByUser in interface SpaceManager
Parameters:
user - the user to check permissions against, or null for the anonymous user
Returns:
a list of all spaces in which the user can create or edit pages

getAuthoredSpacesByUser

public java.util.List getAuthoredSpacesByUser(java.lang.String username)
Specified by:
getAuthoredSpacesByUser in interface SpaceManager

getSpacesContainingPagesEditedBy

public java.util.List getSpacesContainingPagesEditedBy(java.lang.String username)
Specified by:
getSpacesContainingPagesEditedBy in interface SpaceManager

getSpacesContainingCommentsBy

public java.util.List getSpacesContainingCommentsBy(java.lang.String username)
Specified by:
getSpacesContainingCommentsBy in interface SpaceManager

getSpacesCreatedOrUpdatedSinceDate

public java.util.List getSpacesCreatedOrUpdatedSinceDate(java.util.Date previousLoginDate)
Specified by:
getSpacesCreatedOrUpdatedSinceDate in interface SpaceManager

moveHierarchy

public void moveHierarchy(Page topPage,
                          Page newParentPage,
                          Space newSpace,
                          com.atlassian.user.User user,
                          boolean moveChildren,
                          java.util.List pagesToIndex)
Description copied from interface: SpaceManager
Moves a page and its hierarchy to a new parent page, space, or both.

This method also updates the parent-child relationships of each of the affected pages, and rebuilds the ancestor lists.

If moveChildren is true or newSpace is the same as the current space, all of topPage's children will be moved to the new location. Otherwise, the children will be moved to the root of the current space ("orphaned").

Pages the user cannot see (due to page permissions) are not moved, as a security precuation, and are instead moved to the root of the current space.

Specified by:
moveHierarchy in interface SpaceManager
Parameters:
topPage - The page to move
newParentPage - The new parent page
newSpace - The new space (old space if the same)
user - The current user
moveChildren - True if topPage's children should be moved with it, false to leave them. Always treated as true if moving within the same space.
pagesToIndex - normally an empty array list that will be updated with all the pages that need indexing (this way we can delay indexing til after the move has been complete)

createSpace

public Space createSpace(java.lang.String key,
                         java.lang.String name,
                         java.lang.String description,
                         com.atlassian.user.User creator)
Specified by:
createSpace in interface SpaceManager

createPersonalSpace

public Space createPersonalSpace(java.lang.String name,
                                 java.lang.String description,
                                 com.atlassian.user.User owner)
Description copied from interface: SpaceManager
Creates a personal space. The difference to a normal space are that this space will have a type "personal" and the user passed to this space should not be the creator, but is the owner of the space.

Specified by:
createPersonalSpace in interface SpaceManager
Returns:
the created space

getPersonalSpace

public Space getPersonalSpace(com.atlassian.user.User user)
Description copied from interface: SpaceManager
Get the personal space of the given user. This method may be more convenient than SpaceManager.getPersonalSpace(String), as it behaves gracefully when the user is anonymous (i.e. null). Where the user is not null, this method is the equivalent of getPersonalSpace(user.getName()).

Specified by:
getPersonalSpace in interface SpaceManager
Parameters:
user - the user to get the space for. If user is null, the method will return null
Returns:
the personal space of the user if one exists, otherwise null.

convertToPersonalSpace

public void convertToPersonalSpace(Space space,
                                   com.atlassian.user.User owner,
                                   boolean updateLinks)
Description copied from interface: SpaceManager
Convert a global space into a user's personal space. This is only really useful for pre-2.2 Confluence installations that are upgrading to 2.2 or later, and want to convert existing "ad hoc" personal spaces into real personal spaces. The space's key will be updated to ~username, the owner will be set to the personal space owner, and optionally all incoming links will be refactored.

Specified by:
convertToPersonalSpace in interface SpaceManager
Parameters:
space - the space to convert
owner - the new owner of the personal space
updateLinks - true if you want to update incoming links to the space.

findPageTotal

public long findPageTotal(Space space)
Description copied from interface: SpaceManager
Get the number of pages in a space. This counts all pages, including non-current versions, and including pages that are in the trash. As such, it probably doesn't do what you think it does.

Specified by:
findPageTotal in interface SpaceManager
Parameters:
space - the space to count pages in
Returns:
the number of pages in that space

setBandanaPersister

public void setBandanaPersister(com.atlassian.bandana.BandanaPersister bandanaPersister)

setEventManager

public void setEventManager(com.atlassian.event.EventManager eventManager)

setContentPermissionManager

public void setContentPermissionManager(ContentPermissionManager contentPermissionManager)

getNumberOfBlogPosts

public int getNumberOfBlogPosts(Space space)
Description copied from interface: SpaceManager
Get the number of blog posts in a space. This counts all news, including non-current versions, and including news that is in the trash. As such, it probably doesn't do what you think it does.

Specified by:
getNumberOfBlogPosts in interface SpaceManager
Parameters:
space - the space to count pages in
Returns:
the number of blog posts (news items) in that space

getNumberOfMail

public int getNumberOfMail(Space space)
Description copied from interface: SpaceManager
Get the number of archived emails in a space. This counts all mail, including mail that is in the trash. As such, it probably doesn't do what you think it does.

Specified by:
getNumberOfMail in interface SpaceManager
Parameters:
space - the space to count mail in
Returns:
the number of emails archived in the space

getSpaceFromPageId

public java.lang.String getSpaceFromPageId(long pageId)
Description copied from interface: SpaceManager
Get the key for a space from its pageId in a single db call

Specified by:
getSpaceFromPageId in interface SpaceManager
Parameters:
pageId - the id of the page to look for
Returns:
the key for the space containing the given page

getPages

public java.util.List getPages(Space space,
                               boolean currentOnly)
Specified by:
getPages in interface SpaceManager

getPagesStartingWith

public java.util.List getPagesStartingWith(Space space,
                                           java.lang.String s)
Specified by:
getPagesStartingWith in interface SpaceManager

getBlogPosts

public java.util.List getBlogPosts(Space space,
                                   boolean currentOnly)
Specified by:
getBlogPosts in interface SpaceManager

getMail

public java.util.List getMail(Space space,
                              boolean currentOnly)
Specified by:
getMail in interface SpaceManager

ensureSpaceDescriptionExists

public void ensureSpaceDescriptionExists(Space space)
Description copied from interface: SpaceManager
If the given Space does not have a description, creates one for it, and saves it.

This is required for CONF-4080, because labels on a Space are attached to a Space Description.

Specified by:
ensureSpaceDescriptionExists in interface SpaceManager
Parameters:
space - an existing space. Not null.

getSpaceContent

public java.util.List getSpaceContent(Space space,
                                      boolean currentOnly)
Specified by:
getSpaceContent in interface SpaceManager

getSpacesCreatedAfter

public java.util.List getSpacesCreatedAfter(java.util.Date creationDate)
Specified by:
getSpacesCreatedAfter in interface SpaceManager

setMailContentManager

public void setMailContentManager(MailContentManager mailContentManager)

setNotificationManager

public void setNotificationManager(NotificationManager notificationManager)

setLabelManager

public void setLabelManager(LabelManager labelManager)

getPersonalSpaceKey

public java.lang.String getPersonalSpaceKey(java.lang.String username)
Specified by:
getPersonalSpaceKey in interface SpaceManager

setIndexManager

public void setIndexManager(ConfluenceIndexManager indexManager)

getDraftManager

public DraftManager getDraftManager()

setDraftManager

public void setDraftManager(DraftManager draftManager)

setPageTemplateManager

public void setPageTemplateManager(PageTemplateManager templateManager)


Copyright © 2003-2008 Atlassian Pty Ltd. All Rights Reserved.