Package org.ametys.plugins.userdirectory
Class UserDirectoryPageHandler
- java.lang.Object
-
- org.ametys.runtime.plugin.component.AbstractLogEnabled
-
- org.ametys.plugins.userdirectory.UserDirectoryPageHandler
-
- All Implemented Interfaces:
LogEnabled
,Initializable
,Component
,Serviceable
public class UserDirectoryPageHandler extends AbstractLogEnabled implements Component, Serviceable, Initializable
Component providing methods to retrieve user directory virtual pages, such as the user directory root, transitional page and user page.
-
-
Field Summary
Fields Modifier and Type Field Description protected ContentTypeExtensionPoint
_contentTypeEP
The extension point for content typesprotected AmetysObjectResolver
_resolver
The ametys object resolver.protected Map<String,Map<String,Map<String,Map<String,Map<String,SortedSet<String>>>>>>
_transitionalPagesCache
The list of transitional page workspace --> contentType --> site --> language --> (key : page name -- list<> children pages names)protected Map<String,Map<String,Map<String,Set<String>>>>
_userDirectoryRootPages
The user directory root pages, indexed by workspace, site and sitemap name.protected Map<String,Map<String,Map<String,Map<String,Map<String,Map<String,String>>>>>>
_userPagesCache
The list of user page workspace --> contentType --> site --> language --> (key : page name --> Map(page name, content id))protected WorkspaceSelector
_workspaceSelector
The workspace selector.static String
ABSTRACT_USER_CONTENT_TYPE
The parent content type idstatic String
CLASSIFICATION_ATTRIBUTE_DATA_NAME
The data name for the classification attribute of the user directorystatic String
CONTENT_TYPE_DATA_NAME
The data name for the content type of the user directorystatic String
DEPTH_DATA_NAME
The data name for the depth of the user directorystatic String
ROLE
The avalon role.static String
USER_VIEW_NAME
The data name for the users' view to use
-
Constructor Summary
Constructors Constructor Description UserDirectoryPageHandler()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected Set<Page>
_getUserDirectoryRootPages(String siteName, String sitemapName)
Get the user directory root pages, without searching in the cache.void
clearCache(String contentTypeId)
Clear root page cachevoid
clearCache(Page rootPage)
Clear root page cacheString
getClassificationAttribute(Page rootPage)
Gets the name of the classification attributeAmetysObjectIterable<Content>
getContentsForRootPage(Page rootPage)
Get the user contents for a given root pageContentType
getContentType(Page rootPage)
Gets the content typeString
getContentTypeId(Page rootPage)
Gets the content type idint
getDepth(Page rootPage)
Gets the depth of the user directory root pageString
getName(String pathName)
Gets name form path nameString
getPathName(String name)
Checks if name contains only Unicode digits and if so, prefix it with "page-"String
getTransformedClassificationValue(Page rootPage, Content content)
Gets the value of the classification attribute for the given content, transformed for building tree hierarchy
The transformation takes the lower-case of all characters, removes non-alphanumeric characters, and takes the first characters to not have a string with a size bigger than the depth
For instance, if the value for the content is "Aéa Foo-bar" and the depth is 7, then this method will return "aeafoob"SortedSet<String>
getTransitionalPagesName(Page rootPage, String pagePath)
Get all transitional page child from page namePage
getUserDirectoryRootPage(String siteName, String sitemapName, String contentTypeId)
Gets the user directory root page of a specific content type.Set<Page>
getUserDirectoryRootPages(String contentTypeId)
Gets the user directory root pages from the given content type id, whatever the site.Set<Page>
getUserDirectoryRootPages(String siteName, String sitemapName)
Gets the user directory root pages.Map<String,String>
getUserPagesContent(Page rootPage, String pagePath)
Get all user page child from page namevoid
initialize()
void
service(ServiceManager manager)
-
Methods inherited from class org.ametys.runtime.plugin.component.AbstractLogEnabled
getLogger, setLogger
-
-
-
-
Field Detail
-
CONTENT_TYPE_DATA_NAME
public static final String CONTENT_TYPE_DATA_NAME
The data name for the content type of the user directory- See Also:
- Constant Field Values
-
USER_VIEW_NAME
public static final String USER_VIEW_NAME
The data name for the users' view to use- See Also:
- Constant Field Values
-
CLASSIFICATION_ATTRIBUTE_DATA_NAME
public static final String CLASSIFICATION_ATTRIBUTE_DATA_NAME
The data name for the classification attribute of the user directory- See Also:
- Constant Field Values
-
DEPTH_DATA_NAME
public static final String DEPTH_DATA_NAME
The data name for the depth of the user directory- See Also:
- Constant Field Values
-
ABSTRACT_USER_CONTENT_TYPE
public static final String ABSTRACT_USER_CONTENT_TYPE
The parent content type id- See Also:
- Constant Field Values
-
_workspaceSelector
protected WorkspaceSelector _workspaceSelector
The workspace selector.
-
_resolver
protected AmetysObjectResolver _resolver
The ametys object resolver.
-
_contentTypeEP
protected ContentTypeExtensionPoint _contentTypeEP
The extension point for content types
-
_userDirectoryRootPages
protected Map<String,Map<String,Map<String,Set<String>>>> _userDirectoryRootPages
The user directory root pages, indexed by workspace, site and sitemap name.
-
_transitionalPagesCache
protected Map<String,Map<String,Map<String,Map<String,Map<String,SortedSet<String>>>>>> _transitionalPagesCache
The list of transitional page workspace --> contentType --> site --> language --> (key : page name -- list<> children pages names)
-
-
Constructor Detail
-
UserDirectoryPageHandler
public UserDirectoryPageHandler()
-
-
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
-
getUserDirectoryRootPages
public Set<Page> getUserDirectoryRootPages(String contentTypeId) throws AmetysRepositoryException
Gets the user directory root pages from the given content type id, whatever the site.- Parameters:
contentTypeId
- The content type id- Returns:
- the user directory root pages.
- Throws:
AmetysRepositoryException
- if an error occured.
-
getUserDirectoryRootPage
public Page getUserDirectoryRootPage(String siteName, String sitemapName, String contentTypeId) throws AmetysRepositoryException
Gets the user directory root page of a specific content type.- Parameters:
siteName
- The site namesitemapName
- The sitemapcontentTypeId
- The content type id- Returns:
- the user directory root pages.
- Throws:
AmetysRepositoryException
- if an error occured.
-
getUserDirectoryRootPages
public Set<Page> getUserDirectoryRootPages(String siteName, String sitemapName) throws AmetysRepositoryException
Gets the user directory root pages.- Parameters:
siteName
- The site namesitemapName
- The sitemap- Returns:
- the user directory root pages.
- Throws:
AmetysRepositoryException
- if an error occured.
-
_getUserDirectoryRootPages
protected Set<Page> _getUserDirectoryRootPages(String siteName, String sitemapName) throws AmetysRepositoryException
Get the user directory root pages, without searching in the cache.- Parameters:
siteName
- the current site.sitemapName
- the sitemap name.- Returns:
- the user directory root pages
- Throws:
AmetysRepositoryException
- if an error occured.
-
getDepth
public int getDepth(Page rootPage)
Gets the depth of the user directory root page- Parameters:
rootPage
- The user directory root page- Returns:
- the depth of the user directory root page
-
getClassificationAttribute
public String getClassificationAttribute(Page rootPage)
Gets the name of the classification attribute- Parameters:
rootPage
- The user directory root page- Returns:
- the name of the classification attribute
-
getContentTypeId
public String getContentTypeId(Page rootPage)
Gets the content type id- Parameters:
rootPage
- The user directory root page- Returns:
- the content type id
-
getContentType
public ContentType getContentType(Page rootPage)
Gets the content type- Parameters:
rootPage
- The user directory root page- Returns:
- the content type
-
getTransformedClassificationValue
public String getTransformedClassificationValue(Page rootPage, Content content)
Gets the value of the classification attribute for the given content, transformed for building tree hierarchy
The transformation takes the lower-case of all characters, removes non-alphanumeric characters, and takes the first characters to not have a string with a size bigger than the depth
For instance, if the value for the content is "Aéa Foo-bar" and the depth is 7, then this method will return "aeafoob"- Parameters:
rootPage
- The user directory root pagecontent
- The content- Returns:
- the transformed value of the classification attribute for the given content. Can be null
-
getTransitionalPagesName
public SortedSet<String> getTransitionalPagesName(Page rootPage, String pagePath)
Get all transitional page child from page name- Parameters:
rootPage
- the root pagepagePath
- the page path- Returns:
- all transitional page child from page name
-
getUserPagesContent
public Map<String,String> getUserPagesContent(Page rootPage, String pagePath)
Get all user page child from page name- Parameters:
rootPage
- the root pagepagePath
- the page path- Returns:
- all user page child from page name
-
getContentsForRootPage
public AmetysObjectIterable<Content> getContentsForRootPage(Page rootPage)
Get the user contents for a given root page- Parameters:
rootPage
- the root page- Returns:
- the user contents
-
getName
public String getName(String pathName)
Gets name form path name- Parameters:
pathName
- the path name- Returns:
- the name
-
getPathName
public String getPathName(String name)
Checks if name contains only Unicode digits and if so, prefix it with "page-"- Parameters:
name
- The page name- Returns:
- The potentially prefixed page name
-
clearCache
public void clearCache(Page rootPage)
Clear root page cache- Parameters:
rootPage
- the root page
-
clearCache
public void clearCache(String contentTypeId)
Clear root page cache- Parameters:
contentTypeId
- the content type id
-
-