public final class DirectoryHelper extends AbstractLogEnabled implements Component, Serviceable, Contextualizable
Modifier and Type | Class and Description |
---|---|
private class |
DirectoryHelper.DefaultLinkSorter
Helper class to sort links (DefaultLinkSorter implementation)
If both links are in the ordered links list, this order is used
If one of them is in it and not the other, the one in it will be before the other
If none of them is in the list, the initial order will be used
|
Modifier and Type | Field and Description |
---|---|
private static String |
__LINKS_NODE_NAME |
private static String |
__PLUGIN_NODE_NAME |
private static String |
__THEMES_NODE_NAME |
private static String |
__USER_LINKS_NODE_NAME |
private AmetysObjectResolver |
_ametysObjectResolver
The Ametys object resolver
|
private Context |
_context
The context
|
private CurrentUserProvider |
_currentUserProvider
The current user provider
|
private DynamicInformationProviderExtensionPoint |
_dynamicProviderEP |
private LinkDAO |
_linkDAO
The link DAO
|
private RightManager |
_rightManager
The right manager
|
private SiteManager |
_siteManager
The site manager
|
private UserPreferencesManager |
_userPreferencesManager
The user preferences manager
|
static String |
ROLE
The component role
|
Constructor and Description |
---|
DirectoryHelper() |
Modifier and Type | Method and Description |
---|---|
private void |
_addURLAttribute(DefaultLink link,
boolean hasIPRestriction,
boolean isIPAuthorized,
AttributesImpl attrs)
Add the URL attribute to sax
|
private boolean |
_isCurrentUserGrantedAccess(DefaultLink link)
Determines if the current user is allowed to see the link or not
|
private boolean |
_isIPAuthorized(Pattern ipRestriction)
Checks if the IP is authorized for use link internal URL
|
private void |
_saxThemes(ContentHandler contentHandler,
DefaultLink link)
Sax the themes
|
private void |
_saxThemesLabel(ContentHandler contentHandler,
DefaultLink link)
Sax the label of the themes
|
void |
contextualize(Context context) |
String |
getAllLinksQuery(String siteName,
String language)
Get all the links
|
Map<String,String> |
getContextVars(Request request)
Retrieve the context variables from the front
|
String |
getLanguage(Request request)
Get the site's language
|
List<DefaultLink> |
getLinks(List<String> themesIds,
UserIdentity user,
String siteName,
String language)
Get the list of links corresponding to the given theme ids
|
AmetysObjectIterable<DefaultLink> |
getLinks(String siteName,
String language)
Get links of a given site and language
|
ModifiableTraversableAmetysObject |
getLinksForUserNode(Site site,
String language,
UserIdentity user)
Get the links root node for the given user.
|
String |
getLinksForUserNodePath(String siteName,
String language,
UserIdentity user)
Get the links root node path for the given user
|
ModifiableTraversableAmetysObject |
getLinksNode(Site site,
String language)
Get the links root node.
|
String |
getLinksNodePath(String siteName,
String language)
Get the links root node path
|
String |
getLinksQuery(String siteName,
String language,
Expression expression)
Get the link query corresponding to the expression passed as a parameter
|
private ModifiableTraversableAmetysObject |
getOrCreateNode(ModifiableTraversableAmetysObject parentNode,
String nodeName,
String nodeType) |
ModifiableTraversableAmetysObject |
getPluginNode(Site site)
Get the root plugin storage object.
|
String |
getPluginNodePath(String siteName)
Get the plugin node path
|
String |
getSiteName(Request request)
Get the site's name
|
String |
getThemeExistsQuery(String siteName,
String language,
String label)
Get the query verifying the existence of a theme
|
String |
getThemeIdFromThemeName(Site site,
String language,
String configuredThemeName)
Retrieve theme id from theme name
|
String |
getThemeName(String themeId)
Get theme name from jcr id
|
String |
getThemeQuery(String siteName,
String language,
Expression expression)
Get the theme query corresponding to the expression passed as a parameter
|
List<String> |
getThemesIdsFromThemesNames(Site site,
String language,
List<String> configuredThemesNames)
Retrieve theme ids from theme names
|
Map<String,List<String>> |
getThemesMap(List<String> configuredThemesNames,
String siteName,
String language)
Get the actual ids of the themes configured properly, their names if they were not
|
ModifiableTraversableAmetysObject |
getThemesNode(Site site,
String language)
Get the themes storage node.
|
String |
getThemesNodePath(String siteName,
String language)
Get the themes node path
|
String |
getUrlExistsForUserQuery(String siteName,
String language,
String url,
UserIdentity user)
Get the query verifying the existence of an url for the given user
|
String |
getUrlExistsQuery(String siteName,
String language,
String url)
Get the query verifying the existence of an url
|
AmetysObjectIterable<DefaultLink> |
getUserLinks(String siteName,
String language,
UserIdentity user)
Get links of a given site and language, for the given user
|
AmetysObjectIterable<DefaultLink> |
getUserLinks(String siteName,
String language,
UserIdentity user,
String themeId)
Get links of a given site and language, for the given user
|
String |
getUserLinksQuery(String siteName,
String language,
UserIdentity user,
Expression expression)
Get the user link query corresponding to the expression passed as a parameter
|
boolean |
hasInternalUrl(String siteName,
String language,
List<String> themesIds)
Checks if the links displayed in a link directory service has internal link
|
boolean |
hasRestrictions(String siteName,
String language,
List<String> themesIds)
Checks if the links displayed in a link directory service has access restrictions
|
boolean |
isAccessRestricted(AmetysObjectIterable<AmetysObject> links)
Check if the links' access is restricted or not
|
String |
normalizeString(String s)
Normalizes an input string in order to capitalize it, remove accents, and replace whitespaces with underscores
|
void |
saxLink(String siteName,
ContentHandler contentHandler,
DefaultLink link,
boolean saxThemesLabelOnly,
boolean selected,
boolean saxLinksOnly,
boolean hasIPRestriction,
boolean isIPAuthorized,
boolean userLink,
boolean isHidden)
Generate a directory link.
|
void |
saxLinks(String siteName,
ContentHandler contentHandler,
List<DefaultLink> links,
List<DefaultLink> userLinks,
Map<String,String> contextVars,
String storageContext,
UserIdentity user,
boolean saxThemesLabelOnly,
boolean saxLinksOnly)
Sax the directory links
|
void |
service(ServiceManager manager) |
boolean |
themeExists(String themeId)
Verify the existence of a theme
|
getLogger, setLogger
private static final String __PLUGIN_NODE_NAME
private static final String __LINKS_NODE_NAME
private static final String __THEMES_NODE_NAME
private static final String __USER_LINKS_NODE_NAME
private AmetysObjectResolver _ametysObjectResolver
private SiteManager _siteManager
private UserPreferencesManager _userPreferencesManager
private CurrentUserProvider _currentUserProvider
private RightManager _rightManager
private DynamicInformationProviderExtensionPoint _dynamicProviderEP
public DirectoryHelper()
public void service(ServiceManager manager) throws ServiceException
service
in interface Serviceable
ServiceException
public void contextualize(Context context) throws ContextException
contextualize
in interface Contextualizable
ContextException
public ModifiableTraversableAmetysObject getPluginNode(Site site) throws AmetysRepositoryException
site
- the site.AmetysRepositoryException
- if a repository error occurs.public ModifiableTraversableAmetysObject getLinksNode(Site site, String language) throws AmetysRepositoryException
site
- the sitelanguage
- the language.AmetysRepositoryException
- if a repository error occurs.public ModifiableTraversableAmetysObject getLinksForUserNode(Site site, String language, UserIdentity user) throws AmetysRepositoryException
site
- the sitelanguage
- the language.user
- The user identityAmetysRepositoryException
- if a repository error occurs.public ModifiableTraversableAmetysObject getThemesNode(Site site, String language) throws AmetysRepositoryException
site
- the sitelanguage
- the language.AmetysRepositoryException
- if a repository error occurs.public String getPluginNodePath(String siteName)
siteName
- the site name.public String getLinksNodePath(String siteName, String language)
siteName
- the site name.language
- the languagepublic String getLinksForUserNodePath(String siteName, String language, UserIdentity user)
siteName
- the site name.language
- the languageuser
- The user identitypublic String getThemesNodePath(String siteName, String language)
siteName
- the site name.language
- the languagepublic String getAllLinksQuery(String siteName, String language)
siteName
- the site name.language
- the language.public String getLinksQuery(String siteName, String language, Expression expression)
siteName
- the site name.language
- the language.expression
- the Expression
of the links retrieval querypublic String getUserLinksQuery(String siteName, String language, UserIdentity user, Expression expression)
siteName
- the site name.language
- the language.user
- the userexpression
- the Expression
of the links retrieval querypublic String getThemeQuery(String siteName, String language, Expression expression)
siteName
- the site name.language
- the language.expression
- the Expression
of the theme retrieval querypublic String getUrlExistsQuery(String siteName, String language, String url)
siteName
- the site name.language
- the language.url
- the url to test.public String getUrlExistsForUserQuery(String siteName, String language, String url, UserIdentity user)
siteName
- the site name.language
- the language.url
- the url to test.user
- The user identitypublic String getThemeExistsQuery(String siteName, String language, String label)
siteName
- the site name.language
- the language.label
- the label of the theme to test.public String normalizeString(String s)
s
- the string to normalizepublic AmetysObjectIterable<DefaultLink> getLinks(String siteName, String language)
siteName
- the site namelanguage
- the languagepublic List<DefaultLink> getLinks(List<String> themesIds, UserIdentity user, String siteName, String language)
themesIds
- the ids of the configured themesuser
- the current usersiteName
- the site's namelanguage
- the site's languagepublic AmetysObjectIterable<DefaultLink> getUserLinks(String siteName, String language, UserIdentity user)
siteName
- the site namelanguage
- the languageuser
- The user identitypublic AmetysObjectIterable<DefaultLink> getUserLinks(String siteName, String language, UserIdentity user, String themeId)
siteName
- the site namelanguage
- the languageuser
- The user identitythemeId
- the theme id to filter user links. If null, return all user linkspublic boolean hasRestrictions(String siteName, String language, List<String> themesIds)
siteName
- the name of the sitelanguage
- the languagethemesIds
- the list of selected theme idspublic boolean hasInternalUrl(String siteName, String language, List<String> themesIds)
siteName
- the name of the sitelanguage
- the languagethemesIds
- the list of selected theme idspublic boolean isAccessRestricted(AmetysObjectIterable<AmetysObject> links)
links
- the links to be testedprivate ModifiableTraversableAmetysObject getOrCreateNode(ModifiableTraversableAmetysObject parentNode, String nodeName, String nodeType) throws AmetysRepositoryException
AmetysRepositoryException
public void saxLinks(String siteName, ContentHandler contentHandler, List<DefaultLink> links, List<DefaultLink> userLinks, Map<String,String> contextVars, String storageContext, UserIdentity user, boolean saxThemesLabelOnly, boolean saxLinksOnly) throws SAXException, UserPreferencesException
siteName
- the site namecontentHandler
- the content handlerlinks
- the list of links to sax (can be nulluserLinks
- the user links to sax (can be null)storageContext
- the storage context, null if there is no connected usercontextVars
- the context variablesuser
- the usersaxThemesLabelOnly
- true to sax themes label onlysaxLinksOnly
- true if the only the links need to be saxed, false otherwiseSAXException
- If an error occurs while generating the SAX eventsUserPreferencesException
- if an exception occurs while getting the user preferencespublic void saxLink(String siteName, ContentHandler contentHandler, DefaultLink link, boolean saxThemesLabelOnly, boolean selected, boolean saxLinksOnly, boolean hasIPRestriction, boolean isIPAuthorized, boolean userLink, boolean isHidden) throws SAXException
siteName
- the site namecontentHandler
- the content handlerlink
- the link to generate.saxThemesLabelOnly
- true to sax themes label onlyselected
- true if a front end user has checked this link as a user preference, false otherwise (deprecated, only used for old views, isHidden should be used now)saxLinksOnly
- true if we want to sax a link for an input datahasIPRestriction
- true if we have IP restrictionisIPAuthorized
- true if the IP is authorizeduserLink
- true if it is a user linkisHidden
- true if the link is hiddenSAXException
- If an error occurs while generating the SAX eventsprivate void _addURLAttribute(DefaultLink link, boolean hasIPRestriction, boolean isIPAuthorized, AttributesImpl attrs)
link
- the linkhasIPRestriction
- true if we have IP restrictionisIPAuthorized
- true if the IP is authorizedattrs
- the attributepublic Map<String,List<String>> getThemesMap(List<String> configuredThemesNames, String siteName, String language)
configuredThemesNames
- the normalized ids of the configured themessiteName
- the site's namelanguage
- the site's languagepublic List<String> getThemesIdsFromThemesNames(Site site, String language, List<String> configuredThemesNames)
site
- the sitelanguage
- the languageconfiguredThemesNames
- the names of the configured themespublic String getThemeIdFromThemeName(Site site, String language, String configuredThemeName)
site
- the sitelanguage
- the languageconfiguredThemeName
- the name of the configured themepublic boolean themeExists(String themeId)
themeId
- the id of the theme to verifypublic String getThemeName(String themeId)
themeId
- the jcr theme idpublic String getSiteName(Request request)
request
- the requestpublic String getLanguage(Request request)
request
- the requestpublic Map<String,String> getContextVars(Request request)
request
- the requestprivate void _saxThemes(ContentHandler contentHandler, DefaultLink link) throws SAXException
contentHandler
- the content handlerlink
- the linkSAXException
- If an error occurs while generating the SAX eventsprivate void _saxThemesLabel(ContentHandler contentHandler, DefaultLink link) throws SAXException
contentHandler
- the content handlerlink
- the linkSAXException
- if an error occurs while saxingprivate boolean _isCurrentUserGrantedAccess(DefaultLink link)
link
- the linkprivate boolean _isIPAuthorized(Pattern ipRestriction)
ipRestriction
- The ip restriction pattern