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.
-
-
Field Summary
Fields Modifier and Type Field Description static String
MEMORY_CACHE
static String
REQUEST_CACHE
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 protected void
_createCaches()
Creates the cachesvoid
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
-
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
-
-
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
-
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
-
clearCache
public void clearCache()
Clear the site cache
-
-