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,SortedSet<String>>>>
_transitionalPagesCache
The list of transitional page workspace --> contentType --> (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,String>>>>
_userPagesCache
The list of user page workspace --> contentType --> (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_METADATA_METADATA_NAME
The metadata name for the classification metadata of the user directorystatic String
CONTENT_TYPE_METADATA_NAME
The metadata name for the content type of the user directorystatic String
DEPTH_METADATA_NAME
The metadata name for the depth of the user directorystatic String
ROLE
The 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 String
_getClassificationMetadata(Content content, String metadataPath)
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)
void
clearCache(String contentTypeId)
Clear root page cachevoid
clearCache(Page rootPage)
Clear root page cacheString
getClassificationMetadata(Page rootPage)
Gets the name of the classification metadataContentType
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
getTransformedClassificationMetadataValue(Page rootPage, Content content)
Gets the value of the classification metadata 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_METADATA_NAME
public static final String CONTENT_TYPE_METADATA_NAME
The metadata 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:
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.
-
_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
-
getClassificationMetadata
public String getClassificationMetadata(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
-
getTransformedClassificationMetadataValue
public String getTransformedClassificationMetadataValue(Page rootPage, Content content)
Gets the value of the classification metadata 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 metadata 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)
-
_getClassificationMetadata
private String _getClassificationMetadata(Content content, String metadataPath) throws UnknownMetadataException
- Throws:
UnknownMetadataException
-
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
-
-