Class GenericURLResolver

  • All Implemented Interfaces:
    IURLResolver
    Direct Known Subclasses:
    FriendlyUrlResolver

    public class GenericURLResolver
    extends java.lang.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:

    • wr: the WebResource 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 to null
    • 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 in resolveFriendlyPath(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 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:

    • converting all word characters to lower case ASCII characters (without accents)
    • replacing other characters, except '/', 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.urlTitle}${paramsPath}

    Since:
    5.0.0
    Version:
    $Revision$ $Date$
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      protected java.lang.String encodeSlashes​(java.lang.String value)
      Encodes the given value, in a way to keep all existing slashes so that they are not replaced into getSlashReplacementString().
      protected java.lang.String getSlashReplacementString()
      Returns the substituter string for slashes.
      protected boolean isParameterVisible​(java.lang.String name, java.lang.String[] values)
      Indicates if a parameter is to be shown in the string generated by paramsPath.
      protected java.lang.String normalize​(java.lang.String value)
      Normalizes a string value to the form it should take in the friendly path.
      java.lang.String resolveFriendlyPath​(WebResource resource, java.lang.String currentPath)
      Resolves the friendly path for a web resource.
      protected java.lang.Object resolveVariable​(java.lang.String variableName, WebResource webResource, java.lang.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 java.lang.String resolveFriendlyPath​(WebResource resource,
                                                    java.lang.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 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 a PageWebResource, 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 java.lang.String encodeSlashes​(java.lang.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 java.lang.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 java.lang.Object resolveVariable​(java.lang.String variableName,
                                                   WebResource webResource,
                                                   java.lang.String currentPath)
                                            throws javax.servlet.jsp.el.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:
        javax.servlet.jsp.el.ELException - if the variable could not be resolved.
        Since:
        5.0.0
        See Also:
        resolveFriendlyPath(WebResource, String), encodeSlashes(String)
      • isParameterVisible

        protected boolean isParameterVisible​(java.lang.String name,
                                             java.lang.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 java.lang.String normalize​(java.lang.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