com.jalios.jcms
Class DescriptiveURLs

java.lang.Object
  extended by com.jalios.jcms.DescriptiveURLs

public class DescriptiveURLs
extends Object

Manages Descriptive URLs production and decoding.

Since:
jcms-5.7.0
Version:
$Revision: 28951 $
Author:
Olivier Jaquemet

Nested Class Summary
static class DescriptiveURLs.DescriptiveURLsListener
           
 
Constructor Summary
DescriptiveURLs()
           
 
Method Summary
static String cleanDescriptiveURLText(String str, Locale locale)
          Apply the following operation on the given string: unaccentuate lowercase (using given Locale) replace whitespace with "-" remove characters matching pattern [^0-9a-zA-Z/-] remove multiple contiguous letters [/-]
static String getDescriptiveURL(Data data, Locale locale)
          Retrieve an descriptive URL for the given Data in the given language.
static String getDescriptiveURLText(Data data, Locale locale)
          Returns the textual part of a descriptive URL built for the given Data.
static Category getFirstDescriptiveCategory(Publication pub)
          Returns the first category of the given Publication belonging to one the root categories specified for descriptive urls.
static String getId(javax.servlet.http.HttpServletRequest request)
          Returns a Data id computed from the URL of the requested url.
static String getId(String path)
          Returns a Data id computed from the given requested path (servletPath + pathInfo).
static String getServletPath()
          Returns the servlet path used for descriptive URL.
static void init()
          Initialize or reinitialize Descriptive URLS.
static boolean isEnabled()
          Check if descriptive URLs are enabled.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DescriptiveURLs

public DescriptiveURLs()
Method Detail

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

getId

public static String getId(javax.servlet.http.HttpServletRequest request)
Returns a Data id 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

public static String getId(String path)
Returns a Data id 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 optionnal)
Returns:
the Data's id extracted from the given path.
Since:
jcms-5.7.0

getServletPath

public static String 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

public static String getDescriptiveURL(Data data,
                                       Locale locale)
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

Parameters:
data - the Data for which create the URL (cannot be null)
locale - the Locale to use for I18N and localized operations if null, the channel locale is used Channel.getLocale()
Returns:
a relative URL
Throws:
IllegalArgumentException - if data is null
Since:
jcms-5.7.0

getDescriptiveURLText

public static String getDescriptiveURLText(Data data,
                                           Locale locale)
Returns the textual part of a descriptive URL built for the given Data. As the textual part is optionnal, this method is called only when the property descriptive-urls.text.enabled is set to "true".

Parameters:
data - the Data for which the URL is built.
locale - the Locale to use I18N and localized operation.
Returns:
the textual part of the descriptive URL.
Since:
jcms-5.7.0

getFirstDescriptiveCategory

public static Category getFirstDescriptiveCategory(Publication pub)
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

public static String cleanDescriptiveURLText(String str,
                                             Locale locale)
Apply the following operation on the given string:
  • unaccentuate
  • lowercase (using given Locale)
  • replace whitespace with "-"
  • remove characters matching pattern [^0-9a-zA-Z/-]
  • remove multiple contiguous letters [/-]

Parameters:
str - the string to clean
locale - the Locale to use I18N and localized operation
Returns:
the converted string or null if the given string is null
Since:
jcms-5.7.0


Copyright © 2001-2010 Jalios SA. All Rights Reserved.