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 classSiteManager.RequestSiteCacheKey
-
Field Summary
Fields Modifier and Type Field Description private static String__IS_CACHE_FILLEDprivate AbstractCacheManager_cacheManagerprivate Context_contextprivate CopySiteComponent_copySiteComponentprivate CurrentUserProvider_currentUserProviderprivate PopulationContextHelper_populationContextHelperprivate JackrabbitRepository_repositoryprivate AmetysObjectResolver_resolverprivate RightManager_rightManagerprivate SynchronizeComponent_synchronizeComponentprivate WorkspaceSelector_workspaceSelectorstatic StringMEMORY_CACHEstatic StringREQUEST_CACHEConstant for theCacheid (theCacheis inREQUESTattribute) for theSites objects in cache bySiteManager.RequestSiteCacheKey(composition of site name and workspace name).static StringROLEAvalon Rolestatic StringROOT_SITESsites root's JCR node namestatic StringROOT_SITES_PATHsites 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()voidclearCache()Clear the site cachevoidcontextualize(Context context)SitecopySite(Site site, String siteName)Creates a site with the given name, from another site to copySitecopySite(Site site, String parentId, String siteName)Creates a site with the given name, from another site to copySitecreateSite(String siteName)Creates a site with the given name.SitecreateSite(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 userModifiableTraversableAmetysObjectgetRoot()Returns the root for sites.Collection<String>getRootSiteNames()Returns the sites names.AmetysObjectIterable<Site>getRootSites()Returns the root sites.SitegetSite(String siteName)Returns the namedSite.Collection<String>getSiteNames()Returns the sites names.AmetysObjectIterable<Site>getSites()Returns the all sites.booleanhasSite(String siteName)Returns true if the given site exists.voidinitialize()booleanisGrantedSite(UserIdentity user, String siteName)Determines if the user has granted access to the sitevoidservice(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 theCacheid (theCacheis inREQUESTattribute) for theSites 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:
servicein interfaceServiceable- Throws:
ServiceException
-
initialize
public void initialize() throws Exception
- Specified by:
initializein interfaceInitializable- Throws:
Exception
-
_createCaches
protected void _createCaches()
Creates the caches
-
contextualize
public void contextualize(Context context) throws ContextException
- Specified by:
contextualizein 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:
trueif 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
Siteor 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()
-
-