Class DirectoryHelper

    • Method Detail

      • 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

        public String normalizeString​(String s)
        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 List<DefaultLinkgetLinks​(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

        public AmetysObjectIterable<DefaultLinkgetUserLinks​(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

        public boolean isAccessRestricted​(AmetysObjectIterable<AmetysObject> links)
        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
      • 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,​StringgetContextVars​(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