public class VanityUrlManager extends Object
| Modifier and Type | Field and Description |
|---|---|
static String |
JAHIAMIX_VANITYURLMAPPED
mixin, which will automatically be attached once a vanity URL mapping is applied to a node
|
static String |
JAHIANT_VANITYURL
node type of the vanity URL node
|
static String |
JAHIANT_VANITYURLS |
static String |
PROPERTY_ACTIVE
Property name specifying if vanity URL is active
|
static String |
PROPERTY_DEFAULT
Property name specifying if vanity URL is the default one for a locale
|
static String |
PROPERTY_FILE
Property name specifying if it's vanity URL for a file
|
static String |
PROPERTY_URL
Property name holding the vanity URL
|
static String |
VANITYURLMAPPINGS_NODE
node name holding vanity URL mappings for a node
|
| Constructor and Description |
|---|
VanityUrlManager() |
| Modifier and Type | Method and Description |
|---|---|
List<VanityUrl> |
findExistingVanityUrls(String url,
String site,
JCRSessionWrapper session)
Find any mappings for the given vanity URL.
|
VanityUrl |
getVanityUrlForCurrentLocale(JCRNodeWrapper contentNode,
String siteKey,
JCRSessionWrapper session)
Gets a node's default vanity URL for the current locale or if none is default
then take the first mapping for the locale.
|
List<VanityUrl> |
getVanityUrls(JCRNodeWrapper contentNode,
String languageCode,
JCRSessionWrapper session)
Gets all node's vanity URLs for the given locale
|
boolean |
removeVanityUrlMapping(JCRNodeWrapper contentNode,
VanityUrl vanityUrl,
JCRSessionWrapper session)
Completely delete a mapped vanity URL.
|
boolean |
removeVanityUrlMappings(JCRNodeWrapper contentNode,
String languageCode,
JCRSessionWrapper session)
Completely delete all mapped vanity URL for a locale.
|
boolean |
saveVanityUrlMapping(JCRNodeWrapper contentNode,
VanityUrl vanityUrl,
JCRSessionWrapper session)
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,
JCRSessionWrapper session,
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,
JCRSessionWrapper session)
Add, update or delete all vanity URL mappings for a specific content node and the language codes
set in the list of VanityUrl beans.
|
public static final String JAHIAMIX_VANITYURLMAPPED
public static final String JAHIANT_VANITYURL
public static final String JAHIANT_VANITYURLS
public static final String VANITYURLMAPPINGS_NODE
public static final String PROPERTY_URL
public static final String PROPERTY_DEFAULT
public static final String PROPERTY_ACTIVE
public static final String PROPERTY_FILE
public List<VanityUrl> findExistingVanityUrls(String url, String site, JCRSessionWrapper session) 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 emptysession - the JCR session holding the information about workspace and localejavax.jcr.RepositoryException - if there was an unexpected exception accessing the repositorypublic VanityUrl getVanityUrlForCurrentLocale(JCRNodeWrapper contentNode, String siteKey, JCRSessionWrapper session) throws javax.jcr.RepositoryException
contentNode - the content node for which to return a mappingsiteKey - 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 methodsession - the JCR session holding the information about workspace and localejavax.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 mappings. Null to get all 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, JCRSessionWrapper session) throws javax.jcr.RepositoryException
contentNode - the content node for which to remove the given mappingvanityUrl - the VanityUrl bean representing the URL to be removedsession - the JCR session used to find and remove the vanity URL nodejavax.jcr.RepositoryException - if there was an unexpected exception accessing the repositorypublic boolean removeVanityUrlMappings(JCRNodeWrapper contentNode, String languageCode, JCRSessionWrapper session) throws javax.jcr.RepositoryException
contentNode - the content node for which to remove the mappingslanguageCode - the language code for which the mappings should be removedsession - the JCR session used to find and remove the vanity URL nodesjavax.jcr.RepositoryException - if there was an unexpected exception accessing the repositorypublic boolean saveVanityUrlMapping(JCRNodeWrapper contentNode, VanityUrl vanityUrl, JCRSessionWrapper session) 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 updatedsession - the JCR session used to find and save the vanity URL nodejavax.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, JCRSessionWrapper session, 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 updatedsession - the JCR session used to find and save the vanity URL nodesave - 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, JCRSessionWrapper session) throws javax.jcr.RepositoryException
If the default mapping for a language is set for a new or updated mapping, then we check if there already is another default URL for this language and set its default flag to false.
We also check whether the same added URL is already existing for a different node or language in the current site (and which is not being deleted in the same operation) and throw a ConstraintViolationException if this is the case. We also throw a ConstraintViolationException if two URL mappings for the same language in the given vanityUrls collection have the default flag set to true.
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)session - the JCR session used to find and save the vanity URL nodesjavax.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 repositoryCopyright © 2004–2020 Jahia Solutions Group SA. All rights reserved.