Package org.opencms.db
Class CmsAliasManager
java.lang.Object
org.opencms.db.CmsAliasManager
The alias manager provides access to the aliases stored in the database.
-
Field Summary
Modifier and TypeFieldDescriptionprotected CmsSecurityManager
The security manager for accessing the database. -
Constructor Summary
ConstructorDescriptionCmsAliasManager
(CmsSecurityManager securityManager) Creates a new alias manager instance. -
Method Summary
Modifier and TypeMethodDescriptionprotected void
Checks whether the current user has the permissions to mass edit the alias table, and throws an exception otherwise.getAliasesForPath
(CmsObject cms, String siteRoot, String aliasPath) Gets the list of aliases for a path in a given site.getAliasesForSite
(CmsObject cms, String siteRoot) Gets the list of aliases for a given site root.getAliasesForStructureId
(CmsObject cms, CmsUUID structureId) Gets the aliases for a given structure id.getRewriteAliases
(CmsObject cms, String siteRoot) Reads the rewrite aliases for a given site root.getRewriteAliasMatcher
(CmsObject cms, String siteRoot) Gets the rewrite alias matcher for the given site.boolean
hasPermissionsForMassEdit
(CmsObject cms, String siteRoot) Checks whether the current user has permissions for mass editing the alias table.protected CmsAliasImportResult
importAlias
(CmsObject cms, String siteRoot, String aliasPath, String vfsPath, CmsAliasMode mode) Imports a single alias.importAliases
(CmsObject cms, byte[] aliasData, String siteRoot, String separator) Imports alias CSV data.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.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.void
saveAliases
(CmsObject cms, CmsUUID structureId, List<CmsAlias> aliases) Saves the aliases for a given structure id, completely replacing any existing aliases for the same structure id.void
saveRewriteAliases
(CmsObject cms, String siteRoot, List<CmsRewriteAlias> newAliases) Saves the rewrite alias for a given site root.void
updateAliases
(CmsObject cms, Collection<CmsAlias> toDelete, Collection<CmsAlias> toAdd) Updates the aliases in the database.
-
Field Details
-
m_securityManager
The security manager for accessing the database.
-
-
Constructor Details
-
CmsAliasManager
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 contextsiteRoot
- the site root for which we want the aliasesaliasPath
- the alias path- Returns:
- the aliases for the given site root and path
- Throws:
CmsException
- if something goes wrong
-
getAliasesForSite
Gets the list of aliases for a given site root.- Parameters:
cms
- the current CMS contextsiteRoot
- the site root- Returns:
- the list of aliases for the given site
- Throws:
CmsException
- if something goes wrong
-
getAliasesForStructureId
public List<CmsAlias> getAliasesForStructureId(CmsObject cms, CmsUUID structureId) throws CmsException Gets the aliases for a given structure id.- Parameters:
cms
- the current CMS contextstructureId
- 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 contextsiteRoot
- 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
public CmsRewriteAliasMatcher getRewriteAliasMatcher(CmsObject cms, String siteRoot) throws CmsException Gets the rewrite alias matcher for the given site.- Parameters:
cms
- the CMS context to usesiteRoot
- the site root- Returns:
- the alias matcher for the site with the given site root
- Throws:
CmsException
- if something goes wrong
-
hasPermissionsForMassEdit
Checks whether the current user has permissions for mass editing the alias table.- Parameters:
cms
- the current CMS contextsiteRoot
- 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 contextaliasData
- the alias datasiteRoot
- the root of the site into which the alias data should be importedseparator
- 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 contextstructureId
- the structure id of a resourcealiases
- 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 contextsiteRoot
- the site root for which the rewrite aliases should be savednewAliases
- 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 contexttoDelete
- the collection of aliases to deletetoAdd
- the collection of aliases to add- Throws:
CmsException
- if something goes wrong
-
checkPermissionsForMassEdit
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
-
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 contextsiteRoot
- the site rootline
- the line with the data to importseparator
- the field separator- Returns:
- the import result
-