Class CmsAliasManager


  • public class CmsAliasManager
    extends java.lang.Object
    The alias manager provides access to the aliases stored in the database.

    • Constructor Detail

      • CmsAliasManager

        public CmsAliasManager​(CmsSecurityManager securityManager)
        Creates a new alias manager instance.

        Parameters:
        securityManager - the security manager
    • Method Detail

      • getAliasesForPath

        public java.util.List<CmsAliasgetAliasesForPath​(CmsObject cms,
                                                          java.lang.String siteRoot,
                                                          java.lang.String aliasPath)
                                                   throws CmsException
        Gets the list of aliases for a path in a given site.

        This should only return either an empty list or a list with a single element.

        Parameters:
        cms - the current CMS context
        siteRoot - the site root for which we want the aliases
        aliasPath - the alias path
        Returns:
        the aliases for the given site root and path
        Throws:
        CmsException - if something goes wrong
      • getAliasesForSite

        public java.util.List<CmsAliasgetAliasesForSite​(CmsObject cms,
                                                          java.lang.String siteRoot)
                                                   throws CmsException
        Gets the list of aliases for a given site root.

        Parameters:
        cms - the current CMS context
        siteRoot - the site root
        Returns:
        the list of aliases for the given site
        Throws:
        CmsException - if something goes wrong
      • getAliasesForStructureId

        public java.util.List<CmsAliasgetAliasesForStructureId​(CmsObject cms,
                                                                 CmsUUID structureId)
                                                          throws CmsException
        Gets the aliases for a given structure id.

        Parameters:
        cms - the current CMS context
        structureId - the structure id of a resource
        Returns:
        the aliases which point to the resource with the given structure id
        Throws:
        CmsException - if something goes wrong
      • getRewriteAliases

        public java.util.List<CmsRewriteAliasgetRewriteAliases​(CmsObject cms,
                                                                 java.lang.String siteRoot)
                                                          throws CmsException
        Reads the rewrite aliases for a given site root.

        Parameters:
        cms - the current CMS context
        siteRoot - the site root for which the rewrite aliases should be retrieved
        Returns:
        the list of rewrite aliases for the given site root
        Throws:
        CmsException - if something goes wrong
      • hasPermissionsForMassEdit

        public boolean hasPermissionsForMassEdit​(CmsObject cms,
                                                 java.lang.String siteRoot)
        Checks whether the current user has permissions for mass editing the alias table.

        Parameters:
        cms - the current CMS context
        siteRoot - the site root to check
        Returns:
        true if the user from the CMS context is allowed to mass edit the alias table
      • importAliases

        public java.util.List<CmsAliasImportResultimportAliases​(CmsObject cms,
                                                                  byte[] aliasData,
                                                                  java.lang.String siteRoot,
                                                                  java.lang.String separator)
                                                           throws java.lang.Exception
        Imports alias CSV data.

        Parameters:
        cms - the current CMS context
        aliasData - the alias data
        siteRoot - the root of the site into which the alias data should be imported
        separator - the field separator which is used by the imported data
        Returns:
        the list of import results
        Throws:
        java.lang.Exception - if something goes wrong
      • saveAliases

        public void saveAliases​(CmsObject cms,
                                CmsUUID structureId,
                                java.util.List<CmsAlias> aliases)
                         throws CmsException
        Saves the aliases for a given structure id, completely replacing any existing aliases for the same structure id.

        Parameters:
        cms - the current CMS context
        structureId - the structure id of a resource
        aliases - the list of aliases which should be written
        Throws:
        CmsException - if something goes wrong
      • saveRewriteAliases

        public void saveRewriteAliases​(CmsObject cms,
                                       java.lang.String siteRoot,
                                       java.util.List<CmsRewriteAlias> newAliases)
                                throws CmsException
        Saves the rewrite alias for a given site root.

        Parameters:
        cms - the current CMS context
        siteRoot - the site root for which the rewrite aliases should be saved
        newAliases - the list of aliases to save
        Throws:
        CmsException - if something goes wrong
      • updateAliases

        public void updateAliases​(CmsObject cms,
                                  java.util.Collection<CmsAlias> toDelete,
                                  java.util.Collection<CmsAlias> toAdd)
                           throws CmsException
        Updates the aliases in the database.

        Parameters:
        cms - the current CMS context
        toDelete - the collection of aliases to delete
        toAdd - the collection of aliases to add
        Throws:
        CmsException - if something goes wrong
      • importAlias

        protected CmsAliasImportResult importAlias​(CmsObject cms,
                                                   java.lang.String siteRoot,
                                                   java.lang.String aliasPath,
                                                   java.lang.String vfsPath,
                                                   CmsAliasMode mode)
                                            throws CmsException
        Imports a single alias.

        Parameters:
        cms - the current CMS context
        siteRoot - the site root
        aliasPath - the alias path
        vfsPath - the VFS path
        mode - the alias mode
        Returns:
        the result of the import
        Throws:
        CmsException - if something goes wrong
      • processAliasImport

        protected CmsAliasImportResult processAliasImport​(CmsObject cms,
                                                          java.lang.String siteRoot,
                                                          java.lang.String aliasPath,
                                                          java.lang.String vfsPath,
                                                          CmsAliasMode mode)
        Processes a single alias import operation which has already been parsed into fields.

        Parameters:
        cms - the current CMS context
        siteRoot - the site root
        aliasPath - the alias path
        vfsPath - the VFS resource path
        mode - the alias mode
        Returns:
        the result of the import operation
      • processAliasLine

        protected CmsAliasImportResult processAliasLine​(CmsObject cms,
                                                        java.lang.String siteRoot,
                                                        java.lang.String line,
                                                        java.lang.String separator)
        Processes a line from a CSV file containing the alias data to be imported.

        Parameters:
        cms - the current CMS context
        siteRoot - the site root
        line - the line with the data to import
        separator - the field separator
        Returns:
        the import result