Class GenericURLResolver
- java.lang.Object
-
- lumis.portal.url.GenericURLResolver
-
- All Implemented Interfaces:
IURLResolver
- Direct Known Subclasses:
FriendlyUrlResolver
public class GenericURLResolver extends Object implements IURLResolver
Generic implementation ofIURLResolver
.The web resource's property
lumis.portal.url.IURLResolver.pattern
is used to customize the friendly path generated by this resolver. The value of the property is a EL expression where the following variables may be used:wr
: theWebResource
instance.ancestralPath
: the friendly path of the nearest ancestral web resource that has a friendly path value set. If no such web resource exists, it is resolved tonull
param
: Maps a request parameter name to a single value.paramValues
: Maps a request parameter name to an array of values.paramsPath
: an automatic generated path fragment containing parameter names and values. The path starts with slash if it is non-empty, otherwise it does not contain an starting slash. GUID format parameter values and values for special parameters are ignored.currentPath
: the current path value in the pipeline. Corresponds to the parameter given inresolveFriendlyPath(WebResource, String)
.
The string evaluated from each EL code fragment will have the '/' character replaced by
getSlashReplacementString()
(current implementation returns "-", override to customize it). If you overrideresolveVariable(String, WebResource, String)
to return a string, it may useencodeSlashes(String)
to prevent the slashes in the returned value from being replaced. The variablesancestralPath
,paramsPath
andcurrentPath
useencodeSlashes(String)
so the slash they generate are not replaced.The resulting value is normalized by:
- converting all word characters to lower case ASCII characters (without accents)
- replacing other characters, except '/', by '-'
normalize(String)
. It may be overridden to be customized.The default pattern (used if the pattern property is not set) is:
${ancestralPath}/${wr.urlTitle}${paramsPath}
- Since:
- 5.0.0
- Version:
- $Revision: 24008 $ $Date: 2020-08-06 18:26:28 -0300 (Thu, 06 Aug 2020) $
-
-
Constructor Summary
Constructors Constructor Description GenericURLResolver()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected String
encodeSlashes(String value)
Encodes the given value, in a way to keep all existing slashes so that they are not replaced intogetSlashReplacementString()
.protected String
getSlashReplacementString()
Returns the substituter string for slashes.protected boolean
isParameterVisible(String name, String[] values)
Indicates if a parameter is to be shown in the string generated byparamsPath
.protected String
normalize(String value)
Normalizes a string value to the form it should take in the friendly path.String
resolveFriendlyPath(WebResource resource, String currentPath)
Resolves the friendly path for a web resource.protected Object
resolveVariable(String variableName, WebResource webResource, String currentPath)
Resolves a variable in the friendly path expression.
-
-
-
Method Detail
-
resolveFriendlyPath
public String resolveFriendlyPath(WebResource resource, String currentPath) throws PortalException
Description copied from interface:IURLResolver
Resolves the friendly path for a web resource.- Specified by:
resolveFriendlyPath
in interfaceIURLResolver
- Parameters:
resource
- the web resource.currentPath
- the path value resolved by previousIURLResolver
in the resolution pipeline, or an empty String if this is the first resolver in the pipeline.- Returns:
- the resolved friendly path value. The final friendly path for
the resolution pipeline must one of the following alternatives:
- "/" for the root web resource for its website
- a string value that starts with '/'. If it is a path for a
ChannelWebResource
, it must not end with '/'. If it is a path for aPageWebResource
, it may end with '/', and in this case the friendly path will be a directory and any corresponding HTML cache will be generated as a index file inside such directory. - an empty string for no friendly path
- Throws:
PortalException
- Since:
- 5.0.0
-
encodeSlashes
protected final String encodeSlashes(String value)
Encodes the given value, in a way to keep all existing slashes so that they are not replaced intogetSlashReplacementString()
.This method is intended to be used in
resolveVariable(String, WebResource, String)
when a string containing '/' is returned and is not desired for it to be replaced bygetSlashReplacementString()
.- Parameters:
value
- the value to be encoded.- Returns:
- the encoded value.
- Since:
- 5.6.0
-
getSlashReplacementString
protected String getSlashReplacementString()
Returns the substituter string for slashes. Used onresolveFriendlyPath(WebResource, String)
. By default the value returned is "-".- Returns:
- the substituter string for friendly path
- Since:
- 5.6.0
-
resolveVariable
protected Object resolveVariable(String variableName, WebResource webResource, String currentPath) throws ELException
Resolves a variable in the friendly path expression.The string evaluated from each EL code fragment will have the '/' character replaced by
getSlashReplacementString()
(default is '-'). If you overrideresolveVariable(String, WebResource, String)
to return a string, it may useencodeSlashes(String)
to prevent the slashes in the returned value from being replaced.- Parameters:
variableName
- the name of the variable to be resolved.webResource
- the web resource.currentPath
- the current path in the friendly path resolution.- Returns:
- the variable value.
- Throws:
ELException
- if the variable could not be resolved.- Since:
- 5.0.0
- See Also:
resolveFriendlyPath(WebResource, String)
,encodeSlashes(String)
-
isParameterVisible
protected boolean isParameterVisible(String name, String[] values)
Indicates if a parameter is to be shown in the string generated byparamsPath
.- Parameters:
name
- the parameter name.values
- the parameter values.- Returns:
true
if the parameter is to be shown,false
otherwise.- Since:
- 5.0.0
-
-