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_contentTypeEPThe extension point for content typesprotected AmetysObjectResolver_resolverThe ametys object resolver.protected Map<String,Map<String,Map<String,SortedSet<String>>>>_transitionalPagesCacheThe list of transitional page workspace --> contentType --> (key : page name -- list<> children pages names)protected Map<String,Map<String,Map<String,Set<String>>>>_userDirectoryRootPagesThe user directory root pages, indexed by workspace, site and sitemap name.protected Map<String,Map<String,Map<String,Map<String,String>>>>_userPagesCacheThe list of user page workspace --> contentType --> (key : page name --> Map(page name, content id))protected WorkspaceSelector_workspaceSelectorThe workspace selector.static StringABSTRACT_USER_CONTENT_TYPEThe parent content type idstatic StringCLASSIFICATION_METADATA_METADATA_NAMEThe metadata name for the classification metadata of the user directorystatic StringCONTENT_TYPE_METADATA_NAMEThe attribute name for the content type of the user directorystatic StringDEPTH_METADATA_NAMEThe metadata name for the depth of the user directorystatic StringROLEThe avalon role.
-
Constructor Summary
Constructors Constructor Description UserDirectoryPageHandler()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description private void_buildTransitionalPageCache(Set<String> transformedValues, Map<String,SortedSet<String>> transitionalPageCache)private void_buildUserPageCache(Map<Content,String> transformedValuesByContent, int depth, Map<String,Map<String,String>> userPageCache)private String_filterName(String name)private AmetysObjectIterable<Content>_getContentsForRootPage(Page rootPage)protected Set<Page>_getUserDirectoryRootPages(String siteName, String sitemapName)Get the user directory root pages, without searching in the cache.private void_initializeCaches(Page rootPage, String workspace, String contentType)private Page_resolvePage(String pageId)voidclearCache(String contentTypeId)Clear root page cachevoidclearCache(Page rootPage)Clear root page cacheStringgetClassificationAttribute(Page rootPage)Gets the name of the classification metadataContentTypegetContentType(Page rootPage)Gets the content typeStringgetContentTypeId(Page rootPage)Gets the content type idintgetDepth(Page rootPage)Gets the depth of the user directory root pageStringgetName(String pathName)Gets name form path nameStringgetPathName(String name)Checks if name contains only Unicode digits and if so, prefix it with "page-"StringgetTransformedClassificationValue(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 namePagegetUserDirectoryRootPage(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 namevoidinitialize()voidservice(ServiceManager manager)-
Methods inherited from class org.ametys.runtime.plugin.component.AbstractLogEnabled
getLogger, setLogger
-
-
-
-
Field Detail
-
CONTENT_TYPE_METADATA_NAME
public static final String CONTENT_TYPE_METADATA_NAME
The attribute name for the content type of the user directory- See Also:
- Constant Field Values
-
CLASSIFICATION_METADATA_METADATA_NAME
public static final String CLASSIFICATION_METADATA_METADATA_NAME
The metadata name for the classification metadata of the user directory- See Also:
- Constant Field Values
-
DEPTH_METADATA_NAME
public static final String DEPTH_METADATA_NAME
The metadata 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,SortedSet<String>>>> _transitionalPagesCache
The list of transitional page workspace --> contentType --> (key : page name -- list<> children pages names)
-
-
Constructor Detail
-
UserDirectoryPageHandler
public UserDirectoryPageHandler()
-
-
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
-
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.
-
_resolvePage
private Page _resolvePage(String pageId)
-
_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 metadata- Parameters:
rootPage- The user directory root page- Returns:
- the name of the classification metadata
-
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
-
_filterName
private String _filterName(String name)
-
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
-
_initializeCaches
private void _initializeCaches(Page rootPage, String workspace, String contentType)
-
_buildTransitionalPageCache
private void _buildTransitionalPageCache(Set<String> transformedValues, Map<String,SortedSet<String>> transitionalPageCache)
-
_buildUserPageCache
private void _buildUserPageCache(Map<Content,String> transformedValuesByContent, int depth, Map<String,Map<String,String>> userPageCache)
-
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
private AmetysObjectIterable<Content> _getContentsForRootPage(Page rootPage)
-
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
-
-