Class CmsAliasManager

java.lang.Object
org.opencms.db.CmsAliasManager

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

  • Field Details

  • Constructor Details

    • CmsAliasManager

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

      Parameters:
      securityManager - the security manager
  • Method Details

    • getAliasesForPath

      public List<CmsAlias> getAliasesForPath(CmsObject cms, String siteRoot, 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 List<CmsAlias> getAliasesForSite(CmsObject cms, 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

      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

      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
    • getRewriteAliasMatcher

      Gets the rewrite alias matcher for the given site.

      Parameters:
      cms - the CMS context to use
      siteRoot - the site root
      Returns:
      the alias matcher for the site with the given site root
      Throws:
      CmsException - if something goes wrong
    • hasPermissionsForMassEdit

      public boolean hasPermissionsForMassEdit(CmsObject cms, 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 List<CmsAliasImportResult> importAliases(CmsObject cms, byte[] aliasData, String siteRoot, String separator) throws 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:
      Exception - if something goes wrong
    • saveAliases

      public void saveAliases(CmsObject cms, CmsUUID structureId, 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, String siteRoot, 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, Collection<CmsAlias> toDelete, 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
    • checkPermissionsForMassEdit

      protected void checkPermissionsForMassEdit(CmsObject cms) throws CmsException
      Checks whether the current user has the permissions to mass edit the alias table, and throws an exception otherwise.

      Parameters:
      cms - the current CMS context
      Throws:
      CmsException
    • importAlias

      protected CmsAliasImportResult importAlias(CmsObject cms, String siteRoot, String aliasPath, 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, String siteRoot, String aliasPath, 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, String siteRoot, String line, 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