Package com.jalios.jcms
Class DescriptiveURLs
java.lang.Object
com.jalios.jcms.DescriptiveURLs
Manages Descriptive URLs production and decoding.
- Since:
- jcms-5.7.0
- Author:
- Olivier Jaquemet
-
Nested Class Summary
Nested Classes -
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic StringcleanDescriptiveURLText(String str, Locale locale) Clean the specified text for use in textual part of a descriptive URL.static StringgetDescriptiveURL(Data data, Locale locale) Retrieve an descriptive URL for the given Data in the given language.static StringgetDescriptiveURLText(Data data, Locale locale) Returns the textual part of a descriptive URL built for the given Data.static CategoryReturns the first category of the given Publication belonging to one the root categories specified for descriptive urls.static StringReturns aDataid computed from the given requested path (servletPath + pathInfo).static StringgetId(javax.servlet.http.HttpServletRequest request) Returns aDataid computed from the URL of the requested url.static StringgetLanguage(String path) Returns a ISO-639 language code extracted from the given requested path (servletPath + pathInfo).static StringgetLanguage(javax.servlet.http.HttpServletRequest request) Returns a ISO-639 language code computed from the URL of the specified request.static StringReturns the servlet path used for descriptive URL.static voidinit()Initialize or reinitialize Descriptive URLS.static booleanCheck if descriptive URLs are enabled.static booleanCheck if language part is enabled in descriptive URLs.static voidremoveURLCache(Data data) Remove the cached Descriptive URL values for the given Data.
-
Field Details
-
FORCE_ORIGINAL_PORTAL
- See Also:
-
-
Constructor Details
-
DescriptiveURLs
public DescriptiveURLs()
-
-
Method Details
-
init
public static void init()Initialize or reinitialize Descriptive URLS. - read/reload properties. - initialize internal variable/caches. - initialize listener for cache management. - register ServletUtil hooks to provide custom behavior.- Since:
- jcms-5.7.0
-
isEnabled
public static boolean isEnabled()Check if descriptive URLs are enabled.- Returns:
- true if enabled, false otherwise.
- Since:
- jcms-5.7.0
-
isLanguagePartEnabled
public static boolean isLanguagePartEnabled()Check if language part is enabled in descriptive URLs.- Returns:
- true if enabled, false otherwise.
- Since:
- jcms-8.0.3
-
getId
Returns aDataid computed from the URL of the requested url.- Parameters:
request- the request for which we want the id- Returns:
- the Data's id extracted from the accessed path of the given request.
- Since:
- jcms-5.7.0
-
getId
Returns aDataid computed from the given requested path (servletPath + pathInfo).- Parameters:
path- the requested path relative to the webapp. That is if an url is http://domain.tld+/contextPath+/servletPath+/pathInfo + ?querystring the requested path would be /servletPath/pathInfo (starting slash is optional)- Returns:
- the Data's id extracted from the given path.
- Since:
- jcms-5.7.0
-
getLanguage
Returns a ISO-639 language code computed from the URL of the specified request.- Parameters:
request- the request for which we want the language- Returns:
- an ISO-639 language code extracted from the accessed path of the given request, or null if no valid value could be found.
- Since:
- jcms-7.1.0
-
getLanguage
Returns a ISO-639 language code extracted from the given requested path (servletPath + pathInfo).Returns only language configured in site (cf
Channel.getLanguageList(), otherwise returns null.- Parameters:
path- the requested path relative to the webapp. That is if an url is http://domain.tld+/contextPath+/servletPath+/pathInfo + ?querystring the requested path would be /servletPath/pathInfo (starting slash is optional)- Returns:
- the requested language extracted from the given path or null if no valid language could be found.
- Since:
- jcms-7.1.0
-
getServletPath
Returns the servlet path used for descriptive URL.- Returns:
- a path WITHOUT starting '/' and WITH traling '/', for example "jcms/".
- Since:
- jcms-5.7.0
-
getDescriptiveURL
Retrieve an descriptive URL for the given Data in the given language. The returned descriptive URL will follow the following format :{prefix}/{id}[/text]where{prefix}is the servlet mapping of theDisplayServlet{id}is the id of the given Data[/text]is an optional textual part retrieve from methodgetDescriptiveURLText(Data, Locale)if textual part has been enabled using propertydescriptive-urls.text.enabled
- Parameters:
data- theDatafor which create the URL (cannot be null)locale- theLocaleto use for I18N and localized operations if null, the channel locale is usedChannel.getLocale()- Returns:
- a relative URL
- Throws:
IllegalArgumentException- if data is null- Since:
- jcms-5.7.0
-
getDescriptiveURLText
Returns the textual part of a descriptive URL built for the given Data. As the textual part is optional, this method is called only when the propertydescriptive-urls.text.enabledis set to "true". -
getFirstDescriptiveCategory
Returns the first category of the given Publication belonging to one the root categories specified for descriptive urls.- Parameters:
pub- the publication for which we want the first Descriptive Category- Returns:
- a Category or null if no category could be found
- Since:
- jcms-5.7.0
-
cleanDescriptiveURLText
Clean the specified text for use in textual part of a descriptive URL.Current implementation applies the following operation on the specified string :
- unaccentuate
- lowercase (using given Locale)
- Replace characters as defined by regular expression in properties
descriptive-urls.text.clean.{idx}-regexand its corresponding replacement patterndescriptive-urls.text.clean.{idx}-replace(where{idx}is a sequential number from 1).Default replacement :
- replace whitespace and punctuation with dash character "-",
- remove characters matching pattern [^0-9a-zA-Z/-],
- remove multiple contiguous letters [/-]
- limit length to 1024 characters
- Parameters:
str- the string to cleanlocale- theLocaleto use I18N and localized operation- Returns:
- the converted string or null if the given string is null
- Since:
- jcms-5.7.0
-
removeURLCache
Remove the cached Descriptive URL values for the given Data.This method is automatically invoked during data update.
- Parameters:
data- the Data for which descriptive URL have been modified and for which cache need to be removed- Since:
- jcms-5.7.0
-