Class DirectoryHelper

java.lang.Object
org.ametys.runtime.plugin.component.AbstractLogEnabled
org.ametys.plugins.linkdirectory.DirectoryHelper
All Implemented Interfaces:
LogEnabled, Component, Contextualizable, Serviceable

Link directory helper.
  • Field Details

  • Constructor Details

  • Method Details

    • service

      public void service(ServiceManager manager) throws ServiceException
      Specified by:
      service in interface Serviceable
      Throws:
      ServiceException
    • contextualize

      public void contextualize(Context context) throws ContextException
      Specified by:
      contextualize in interface Contextualizable
      Throws:
      ContextException
    • getPluginNode

      Get the root plugin storage object.
      Parameters:
      site - the site.
      Returns:
      the root plugin storage object.
      Throws:
      AmetysRepositoryException - if a repository error occurs.
    • getLinksNode

      Get the links root node.
      Parameters:
      site - the site
      language - the language.
      Returns:
      the links root node.
      Throws:
      AmetysRepositoryException - if a repository error occurs.
    • getLinksForUserNode

      Get the links root node for the given user.
      Parameters:
      site - the site
      language - the language.
      user - The user identity
      Returns:
      the links root node for the given user.
      Throws:
      AmetysRepositoryException - if a repository error occurs.
    • getPluginNodePath

      public String getPluginNodePath(String siteName)
      Get the plugin node path
      Parameters:
      siteName - the site name.
      Returns:
      the plugin node path.
    • getLinksNodePath

      public String getLinksNodePath(String siteName, String language)
      Get the links root node path
      Parameters:
      siteName - the site name.
      language - the language
      Returns:
      the links root node path.
    • getLinksForUserNodePath

      public String getLinksForUserNodePath(String siteName, String language, UserIdentity user)
      Get the links root node path for the given user
      Parameters:
      siteName - the site name.
      language - the language
      user - The user identity
      Returns:
      the links root node path for the given user.
    • getAllLinksQuery

      public String getAllLinksQuery(String siteName, String language)
      Get all the links
      Parameters:
      siteName - the site name.
      language - the language.
      Returns:
      all the links' nodes
    • getLinksQuery

      public String getLinksQuery(String siteName, String language, Expression expression)
      Get the link query corresponding to the expression passed as a parameter
      Parameters:
      siteName - the site name.
      language - the language.
      expression - the Expression of the links retrieval query
      Returns:
      the link corresponding to the expression passed as a parameter
    • getUserLinksQuery

      public String getUserLinksQuery(String siteName, String language, UserIdentity user, Expression expression)
      Get the user link query corresponding to the expression passed as a parameter
      Parameters:
      siteName - the site name.
      language - the language.
      user - the user
      expression - the Expression of the links retrieval query
      Returns:
      the user link corresponding to the expression passed as a parameter
    • getUrlExistsQuery

      public String getUrlExistsQuery(String siteName, String language, String url)
      Get the query verifying the existence of an url
      Parameters:
      siteName - the site name.
      language - the language.
      url - the url to test.
      Returns:
      the query verifying the existence of an url
    • getUrlExistsForUserQuery

      public String getUrlExistsForUserQuery(String siteName, String language, String url, UserIdentity user)
      Get the query verifying the existence of an url for the given user
      Parameters:
      siteName - the site name.
      language - the language.
      url - the url to test.
      user - The user identity
      Returns:
      the query verifying the existence of an url for the given user
    • normalizeString

      Normalizes an input string in order to capitalize it, remove accents, and replace whitespaces with underscores
      Parameters:
      s - the string to normalize
      Returns:
      the normalized string
    • getLinks

      public AmetysObjectIterable<DefaultLink> getLinks(String siteName, String language)
      Get links of a given site and language
      Parameters:
      siteName - the site name
      language - the language
      Returns:
      the links
    • getLinks

      public List<DefaultLink> getLinks(List<String> themesIds, UserIdentity user, String siteName, String language)
      Get the list of links corresponding to the given theme ids
      Parameters:
      themesIds - the ids of the configured themes
      user - the current user
      siteName - the site's name
      language - the site's language
      Returns:
      the list of default links corresponding to the given themes
    • getUserLinks

      Get links of a given site and language, for the given user
      Parameters:
      siteName - the site name
      language - the language
      user - The user identity
      Returns:
      the links for the given user
    • getUserLinks

      public AmetysObjectIterable<DefaultLink> getUserLinks(String siteName, String language, UserIdentity user, String themeName)
      Get links of a given site and language, for the given user
      Parameters:
      siteName - the site name
      language - the language
      user - The user identity
      themeName - the theme id to filter user links. If null, return all user links
      Returns:
      the links for the given user
    • hasRestrictions

      public boolean hasRestrictions(String siteName, String language, List<String> themesIds)
      Checks if the links displayed in a link directory service has access restrictions
      Parameters:
      siteName - the name of the site
      language - the language
      themesIds - the list of selected theme ids
      Returns:
      true if the links of the service have access restrictions, false otherwise
    • hasInternalUrl

      public boolean hasInternalUrl(String siteName, String language, List<String> themesIds)
      Checks if the links displayed in a link directory service has internal link
      Parameters:
      siteName - the name of the site
      language - the language
      themesIds - the list of selected theme ids
      Returns:
      true if the links of the service has internal link, false otherwise
    • isAccessRestricted

      Check if the links' access is restricted or not
      Parameters:
      links - the links to be tested
      Returns:
      true if the link has a restricted access, false otherwise
    • getSkinLinksConfiguration

      Get the configuration of links brought by skin
      Parameters:
      skinName - the skin name
      Returns:
      the skin configuration
      Throws:
      IOException - if an error occured
      ConfigurationException - if an error occured
      SAXException - if an error occured
    • saxLinks

      public void saxLinks(String siteName, ContentHandler contentHandler, List<DefaultLink> links, List<DefaultLink> userLinks, Map<String,String> contextVars, String storageContext, UserIdentity user) throws SAXException, UserPreferencesException
      Sax the directory links
      Parameters:
      siteName - the site name
      contentHandler - the content handler
      links - the list of links to sax (can be null
      userLinks - the user links to sax (can be null)
      storageContext - the storage context, null if there is no connected user
      contextVars - the context variables
      user - the user
      Throws:
      SAXException - If an error occurs while generating the SAX events
      UserPreferencesException - if an exception occurs while getting the user preferences
    • saxLink

      public void saxLink(String siteName, ContentHandler contentHandler, DefaultLink link, boolean selected, boolean hasIPRestriction, boolean isIPAuthorized, boolean userLink, boolean isHidden) throws SAXException
      Generate a directory link.
      Parameters:
      siteName - the site name
      contentHandler - the content handler
      link - the link to generate.
      selected - 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)
      hasIPRestriction - true if we have IP restriction
      isIPAuthorized - true if the IP is authorized
      userLink - true if it is a user link
      isHidden - true if the link is hidden
      Throws:
      SAXException - If an error occurs while generating the SAX events
    • getThemesMap

      public 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
      Parameters:
      configuredThemesNames - the normalized ids of the configured themes
      siteName - the site's name
      language - the site's language
      Returns:
      the actual ids of the configured themes
    • themeExists

      public boolean themeExists(String themeName, String siteName, String language)
      Verify the existence of a theme
      Parameters:
      themeName - the id of the theme to verify
      siteName - the site's name
      language - the site's language
      Returns:
      true if the theme exists, false otherwise
    • getThemeTitle

      public I18nizableText getThemeTitle(String themeName, String siteName, String language)
      Get theme's title from its name
      Parameters:
      themeName - the theme name
      siteName - the site's name
      language - the site's language
      Returns:
      the title of the theme. Null if the theme doesn't exist
    • getSiteName

      public String getSiteName(Request request)
      Get the site's name
      Parameters:
      request - the request
      Returns:
      the site's name
    • getLanguage

      public String getLanguage(Request request)
      Get the site's language
      Parameters:
      request - the request
      Returns:
      the site's language
    • getContextVars

      public Map<String,String> getContextVars(Request request)
      Retrieve the context variables from the front
      Parameters:
      request - the request
      Returns:
      the map of context variables
    • getStorageContext

      public String getStorageContext(Request request, String zoneItemId)
      Get the appropriate storage context from request
      Parameters:
      request - the request
      zoneItemId - the id of the zone item if we deal with a service, null for an input data
      Returns:
      the storage context in which the user preferences will be kept
    • getStorageContext

      public String getStorageContext(String siteName, String language, String zoneItemId)
      Get the appropriate storage context
      Parameters:
      siteName - the name of the site
      language - the language
      zoneItemId - the id of the zone item if we deal with a service, null for an input data
      Returns:
      the storage context in which the user preferences will be kept