Package org.ametys.web.repository.site
Class SiteManager
- java.lang.Object
-
- org.apache.avalon.framework.logger.AbstractLogEnabled
-
- org.ametys.web.repository.site.SiteManager
-
- All Implemented Interfaces:
Initializable
,Component
,Contextualizable
,LogEnabled
,Serviceable
public class SiteManager extends AbstractLogEnabled implements Serviceable, Component, Contextualizable, Initializable
Helper component for managing sites.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description private static class
SiteManager.RequestSiteCacheKey
-
Field Summary
Fields Modifier and Type Field Description private static String
__IS_CACHE_FILLED
private AbstractCacheManager
_cacheManager
private Context
_context
private CopySiteComponent
_copySiteComponent
private CurrentUserProvider
_currentUserProvider
private PopulationContextHelper
_populationContextHelper
private JackrabbitRepository
_repository
private AmetysObjectResolver
_resolver
private RightManager
_rightManager
private SynchronizeComponent
_synchronizeComponent
private WorkspaceSelector
_workspaceSelector
static String
MEMORY_CACHE
static String
REQUEST_CACHE
Constant for theCache
id (theCache
is inREQUEST
attribute) for theSite
s objects in cache bySiteManager.RequestSiteCacheKey
(composition of site name and workspace name).static String
ROLE
Avalon Rolestatic String
ROOT_SITES
sites root's JCR node namestatic String
ROOT_SITES_PATH
sites root's JCR path
-
Constructor Summary
Constructors Constructor Description SiteManager()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description private Site
_computeSite(String siteName)
protected void
_createCaches()
Creates the cachesprivate Cache<String,String>
_getMemoryCache()
private Request
_getRequest()
private Cache<SiteManager.RequestSiteCacheKey,Site>
_getRequestCache()
private Map<String,String>
_getUUIDCache()
void
clearCache()
Clear the site cachevoid
contextualize(Context context)
Site
copySite(Site site, String siteName)
Creates a site with the given name, from another site to copySite
copySite(Site site, String parentId, String siteName)
Creates a site with the given name, from another site to copySite
createSite(String siteName)
Creates a site with the given name.Site
createSite(String siteName, String parentId)
Creates a site with the given name.Set<String>
getGrantedSites()
Get the granted site names for the current userSet<String>
getGrantedSites(UserIdentity user)
Get the granted site names for userModifiableTraversableAmetysObject
getRoot()
Returns the root for sites.Collection<String>
getRootSiteNames()
Returns the sites names.AmetysObjectIterable<Site>
getRootSites()
Returns the root sites.Site
getSite(String siteName)
Returns the namedSite
.Collection<String>
getSiteNames()
Returns the sites names.AmetysObjectIterable<Site>
getSites()
Returns the all sites.boolean
hasSite(String siteName)
Returns true if the given site exists.void
initialize()
boolean
isGrantedSite(UserIdentity user, String siteName)
Determines if the user has granted access to the sitevoid
service(ServiceManager manager)
-
Methods inherited from class org.apache.avalon.framework.logger.AbstractLogEnabled
enableLogging, getLogger, setupLogger, setupLogger, setupLogger
-
-
-
-
Field Detail
-
REQUEST_CACHE
public static final String REQUEST_CACHE
Constant for theCache
id (theCache
is inREQUEST
attribute) for theSite
s objects in cache bySiteManager.RequestSiteCacheKey
(composition of site name and workspace name).
-
MEMORY_CACHE
public static final String MEMORY_CACHE
-
ROOT_SITES
public static final String ROOT_SITES
sites root's JCR node name- See Also:
- Constant Field Values
-
ROOT_SITES_PATH
public static final String ROOT_SITES_PATH
sites root's JCR path- See Also:
- Constant Field Values
-
__IS_CACHE_FILLED
private static final String __IS_CACHE_FILLED
- See Also:
- Constant Field Values
-
_resolver
private AmetysObjectResolver _resolver
-
_repository
private JackrabbitRepository _repository
-
_synchronizeComponent
private SynchronizeComponent _synchronizeComponent
-
_copySiteComponent
private CopySiteComponent _copySiteComponent
-
_workspaceSelector
private WorkspaceSelector _workspaceSelector
-
_rightManager
private RightManager _rightManager
-
_currentUserProvider
private CurrentUserProvider _currentUserProvider
-
_populationContextHelper
private PopulationContextHelper _populationContextHelper
-
_cacheManager
private AbstractCacheManager _cacheManager
-
-
Constructor Detail
-
SiteManager
public SiteManager()
-
-
Method Detail
-
service
public void service(ServiceManager manager) throws ServiceException
- Specified by:
service
in interfaceServiceable
- Throws:
ServiceException
-
initialize
public void initialize() throws Exception
- Specified by:
initialize
in interfaceInitializable
- Throws:
Exception
-
_createCaches
protected void _createCaches()
Creates the caches
-
contextualize
public void contextualize(Context context) throws ContextException
- Specified by:
contextualize
in interfaceContextualizable
- Throws:
ContextException
-
_getUUIDCache
private Map<String,String> _getUUIDCache()
-
_getRequest
private Request _getRequest()
-
getRootSiteNames
public Collection<String> getRootSiteNames()
Returns the sites names.- Returns:
- the sites names.
-
getSiteNames
public Collection<String> getSiteNames()
Returns the sites names.- Returns:
- the sites names.
-
getGrantedSites
public Set<String> getGrantedSites()
Get the granted site names for the current user- Returns:
- The name of sites the current user can access
-
getGrantedSites
public Set<String> getGrantedSites(UserIdentity user)
Get the granted site names for user- Parameters:
user
- The user- Returns:
- The name of sites the user can access
-
isGrantedSite
public boolean isGrantedSite(UserIdentity user, String siteName)
Determines if the user has granted access to the site- Parameters:
user
- The usersiteName
- The site name- Returns:
true
if the user can access to the site
-
getRoot
public ModifiableTraversableAmetysObject getRoot()
Returns the root for sites.- Returns:
- the root for sites.
-
getRootSites
public AmetysObjectIterable<Site> getRootSites()
Returns the root sites.- Returns:
- the root sites.
-
getSites
public AmetysObjectIterable<Site> getSites()
Returns the all sites.- Returns:
- the all sites.
-
createSite
public Site createSite(String siteName, String parentId) throws RepositoryIntegrityViolationException
Creates a site with the given name.- Parameters:
siteName
- the site name.parentId
- the id of the parent site. Can be null.- Returns:
- the newly created
Site
. - Throws:
RepositoryIntegrityViolationException
- if the named site already exists.
-
createSite
public Site createSite(String siteName) throws RepositoryIntegrityViolationException
Creates a site with the given name.- Parameters:
siteName
- the site name.- Returns:
- the newly created
Site
. - Throws:
RepositoryIntegrityViolationException
- if the named site already exists.
-
copySite
public Site copySite(Site site, String siteName) throws RepositoryIntegrityViolationException
Creates a site with the given name, from another site to copy- Parameters:
site
- the site to be copiedsiteName
- the site name- Returns:
- the newly created
Site
. - Throws:
RepositoryIntegrityViolationException
- if the named site already exists.
-
copySite
public Site copySite(Site site, String parentId, String siteName) throws RepositoryIntegrityViolationException
Creates a site with the given name, from another site to copy- Parameters:
site
- the site to be copiedparentId
- the id of the parent site. Can be null.siteName
- the site name- Returns:
- the newly created
Site
. - Throws:
RepositoryIntegrityViolationException
- if the named site already exists.
-
hasSite
public boolean hasSite(String siteName)
Returns true if the given site exists.- Parameters:
siteName
- the site name.- Returns:
- true if the given site exists.
-
getSite
public Site getSite(String siteName) throws UnknownAmetysObjectException
Returns the namedSite
.- Parameters:
siteName
- the site name.- Returns:
- the named
Site
or null if the siteName is null - Throws:
UnknownAmetysObjectException
- if the named site does not exist
-
_computeSite
private Site _computeSite(String siteName)
-
clearCache
public void clearCache()
Clear the site cache
-
_getMemoryCache
private Cache<String,String> _getMemoryCache()
-
_getRequestCache
private Cache<SiteManager.RequestSiteCacheKey,Site> _getRequestCache()
-
-