lumis.portal.url
Class GenericURLResolver

Package class diagram package GenericURLResolver
java.lang.Object
  extended by lumis.portal.url.GenericURLResolver
All Implemented Interfaces:
IURLResolver

public class GenericURLResolver
extends Object
implements IURLResolver

Generic implementation of IURLResolver.

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:

The string evaluated from each EL code fragment will have the '/' character replaced by getSlashReplacementString() (current implementation returns "-", override to customize it). If you override resolveVariable(String, WebResource, String) to return a string, it may use encodeSlashes(String) to prevent the slashes in the returned value from being replaced. The variables ancestralPath, paramsPath and currentPath use encodeSlashes(String) so the slash they generate are not replaced.

The resulting value is normalized by:

This normalization behavior is implemented in the method normalize(String). It may be overridden to be customized.

The default pattern (used if the pattern property is not set) is: ${ancestralPath}/${wr.title}${paramsPath}

Since:
5.0.0

Constructor Summary
GenericURLResolver()
           
 
Method Summary
protected  String encodeSlashes(String value)
          Encodes the given value, in a way to keep all existing slashes so that they are not replaced into getSlashReplacementString().
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 by paramsPath.
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.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

GenericURLResolver

public GenericURLResolver()
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 interface IURLResolver
Parameters:
resource - the web resource.
currentPath - the path value resolved by previous IURLResolver 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 start with '/', or be 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 into getSlashReplacementString().

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 by getSlashReplacementString().

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 on resolveFriendlyPath(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 override resolveVariable(String, WebResource, String) to return a string, it may use encodeSlashes(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 by paramsPath.

Parameters:
name - the parameter name.
values - the parameter values.
Returns:
true if the parameter is to be shown, false otherwise.
Since:
5.0.0

normalize

protected String normalize(String value)
Normalizes a string value to the form it should take in the friendly path.

Parameters:
value - the string value to be normalized.
Returns:
the normalized value.
Since:
5.0.0


Lumisportal  6.2.0.120405 - Copyright © 2006–2012 Lumis EIP Tecnologia da Informação LTDA. All Rights Reserved.