public class VanityUrlService extends Object
| Modifier and Type | Field and Description |
|---|---|
static String |
CACHE_BY_URL |
| Constructor and Description |
|---|
VanityUrlService() |
| Modifier and Type | Method and Description |
|---|---|
List<VanityUrl> |
findExistingVanityUrls(String url,
String site,
String workspace)
Find any mappings for the given vanity URL.
|
void |
flushCacheEntry(String key) |
void |
flushCaches() |
String |
getCacheByUrlKey(String url,
String site,
String workspace) |
VanityUrl |
getVanityUrlForWorkspaceAndLocale(JCRNodeWrapper contentNode,
String workspace,
Locale locale,
String siteKey)
Gets a node's default vanity URL for the given locale and workspace.
|
VanityUrl |
getVanityUrlForWorkspaceAndLocale(String contentNodePath,
String workspace,
Locale locale,
String siteKey)
Gets a node's default vanity URL for the given locale and workspace.
|
List<VanityUrl> |
getVanityUrls(JCRNodeWrapper contentNode,
String languageCode,
JCRSessionWrapper session)
Gets all node's vanity URLs for the given locale
|
List<VanityUrl> |
getVanityUrlsForCurrentLocale(JCRNodeWrapper contentNode,
JCRSessionWrapper session)
Gets all node's vanity URLs for the current locale in the session
|
boolean |
removeVanityUrlMapping(JCRNodeWrapper contentNode,
VanityUrl vanityUrl)
Completely delete a mapped vanity URL.
|
boolean |
removeVanityUrlMappings(JCRNodeWrapper contentNode,
String languageCode)
Completely delete all mapped vanity URL for a locale.
|
boolean |
saveVanityUrlMapping(JCRNodeWrapper contentNode,
VanityUrl vanityUrl)
Add or update a vanity URL mapping belonging to a specific content node and identified either by the vanity URL node UUID or the
vanity URL value set in the VanityUrl bean.
|
boolean |
saveVanityUrlMapping(JCRNodeWrapper contentNode,
VanityUrl vanityUrl,
boolean save)
Add or update a vanity URL mapping belonging to a specific content node and identified either by the vanity URL node UUID or the
vanity URL value set in the VanityUrl bean.
|
boolean |
saveVanityUrlMappings(JCRNodeWrapper contentNode,
List<VanityUrl> vanityUrls,
Set<String> updatedLocales)
Add, update or delete all vanity URL mappings for a specific content node and the language codes set in the list of VanityUrl beans.
|
void |
setCacheService(CacheService cacheService) |
void |
setUrlResolverListener(URLResolverListener urlResolverListener) |
void |
setVanityUrlManager(VanityUrlManager vanityUrlManager)
Injects the dependency to
VanityUrlManager. |
public static final String CACHE_BY_URL
public VanityUrl getVanityUrlForWorkspaceAndLocale(JCRNodeWrapper contentNode, String workspace, Locale locale, String siteKey) throws javax.jcr.RepositoryException
contentNode - the content node for which to return a mappingworkspace - the workspace to look for mappingslocale - the locale to which the mapping should applysiteKey - the key of the current site; if the content node's site does not match the specified one in siteKey,
null is returned by this methodjavax.jcr.RepositoryException - if there was an unexpected exception accessing the repositorypublic VanityUrl getVanityUrlForWorkspaceAndLocale(String contentNodePath, String workspace, Locale locale, String siteKey) throws javax.jcr.RepositoryException
contentNodePath - the content node path for which to return a mappingworkspace - the workspace to look for mappingslocale - the locale to which the mapping should applysiteKey - the key of the current site; if the content node's site does not match the specified one in siteKey,
null is returned by this methodjavax.jcr.RepositoryException - if there was an unexpected exception accessing the repositorypublic List<VanityUrl> getVanityUrlsForCurrentLocale(JCRNodeWrapper contentNode, JCRSessionWrapper session) throws javax.jcr.RepositoryException
contentNode - the content node for which to return the mappingssession - the JCR session holding the information about the workspace, locale and userjavax.jcr.RepositoryException - if there was an unexpected exception accessing the repositorypublic List<VanityUrl> getVanityUrls(JCRNodeWrapper contentNode, String languageCode, JCRSessionWrapper session) throws javax.jcr.RepositoryException
contentNode - the content node for which to return the mappingslanguageCode - the language code for which to return the mappingssession - the JCR session holding the information about the workspace and userjavax.jcr.RepositoryException - if there was an unexpected exception accessing the repositorypublic boolean removeVanityUrlMapping(JCRNodeWrapper contentNode, VanityUrl vanityUrl) throws javax.jcr.RepositoryException
contentNode - the content node for which to remove the given mappingvanityUrl - the VanityUrl bean representing the URL to be removedjavax.jcr.RepositoryException - if there was an unexpected exception accessing the repositorypublic boolean removeVanityUrlMappings(JCRNodeWrapper contentNode, String languageCode) throws javax.jcr.RepositoryException
contentNode - the content node for which to remove the mappingslanguageCode - the language code for which the mappings should be removedjavax.jcr.RepositoryException - if there was an unexpected exception accessing the repositorypublic boolean saveVanityUrlMapping(JCRNodeWrapper contentNode, VanityUrl vanityUrl) throws javax.jcr.RepositoryException
If the URL mapping has already been saved before, we check whether the default, active, language or vanity URL value in the bean is different from the saved one, so we do an update, otherwise no operation is done.
If the new or updated mapping is now the default one for the language, then we also check if there already is another default URL for this language and set its default flag to false.
We also check whether the same URL is already existing for a different node or language in the current site and throw a ConstraintViolationException if this is the case.
contentNode - the content node for which to add or update the given mappingvanityUrl - the VanityUrl bean representing the URL to be added or updatedjavax.validation.ConstraintViolationException - if the vanity URL mapping already exists for a different content node or language within the sitejavax.jcr.RepositoryException - if there was an unexpected exception accessing the repositorypublic boolean saveVanityUrlMapping(JCRNodeWrapper contentNode, VanityUrl vanityUrl, boolean save) throws javax.jcr.RepositoryException
If the URL mapping has already been saved before, we check whether the default, active, language or vanity URL value in the bean is different from the saved one, so we do an update, otherwise no operation is done.
If the new or updated mapping is now the default one for the language, then we also check if there already is another default URL for this language and set its default flag to false.
We also check whether the same URL is already existing for a different node or language in the current site and throw a ConstraintViolationException if this is the case.
contentNode - the content node for which to add or update the given mappingvanityUrl - the VanityUrl bean representing the URL to be added or updatedsave - should the session be saved at the endjavax.validation.ConstraintViolationException - if the vanity URL mapping already exists for a different content node or language within the sitejavax.jcr.RepositoryException - if there was an unexpected exception accessing the repositorypublic boolean saveVanityUrlMappings(JCRNodeWrapper contentNode, List<VanityUrl> vanityUrls, Set<String> updatedLocales) throws javax.jcr.RepositoryException
contentNode - the content node for which to add the given mappingvanityUrls - the list of VanityUrls bean representing the URLs to be added or updatedupdatedLocales - a set with all locales, which have been edited (e.g. if all mappings for a language need to be deleted, add the language
to this set, while in the vanityUrls list there will be no mappings for that language)javax.validation.ConstraintViolationException - if the vanity URL mapping already exists for a different content node or language in the sitejavax.jcr.RepositoryException - if there was an unexpected exception accessing the repositorypublic List<VanityUrl> findExistingVanityUrls(String url, String site, String workspace) throws javax.jcr.RepositoryException
url - URL path to check whether there is a content mapping for it (URL must start with /)site - key of the site to search for the mapping or all sites if the string is null or emptyworkspace - the workspace to look for mappingsjavax.jcr.RepositoryException - if there was an unexpected exception accessing the repositorypublic void setVanityUrlManager(VanityUrlManager vanityUrlManager)
VanityUrlManager.vanityUrlManager - the dependency to VanityUrlManagerpublic void setCacheService(CacheService cacheService)
public void setUrlResolverListener(URLResolverListener urlResolverListener)
public void flushCaches()
public void flushCacheEntry(String key)
Copyright © 2004–2020 Jahia Solutions Group SA. All rights reserved.