org.wicketstuff.minis.util
Class VersatileWebRequestCodingStrategy

java.lang.Object
  extended by org.wicketstuff.minis.util.VersatileWebRequestCodingStrategy
All Implemented Interfaces:
org.apache.wicket.request.IRequestCodingStrategy, org.apache.wicket.request.IRequestTargetMounter, org.apache.wicket.request.IRequestTargetMountsInfo

public class VersatileWebRequestCodingStrategy
extends java.lang.Object
implements org.apache.wicket.request.IRequestCodingStrategy, org.apache.wicket.request.IRequestTargetMountsInfo

https://issues.apache.org/jira/browse/WICKET-1534. Request parameters factory implementation that uses http request parameters and path info to construct the request parameters object.

This implementation is based on WebRequestCodingStrategy, and supports multiple URL coding strategies per mount path. It uses the first strategy matching a given URL.

Author:
Eelco Hillenius, Jonathan Locke, Erik van Oosten, Sebastian Thomschke

Constructor Summary
VersatileWebRequestCodingStrategy()
          Construct.
VersatileWebRequestCodingStrategy(org.apache.wicket.protocol.http.request.WebRequestCodingStrategy.Settings settings)
          Construct.
 
Method Summary
protected  void addBookmarkablePageParameters(org.apache.wicket.Request request, org.apache.wicket.request.RequestParameters parameters)
          Adds bookmarkable page related parameters (page alias and optionally page parameters).
 void addIgnoreMountPath(java.lang.String path)
           
protected  void addInterfaceParameters(org.apache.wicket.Request request, org.apache.wicket.request.RequestParameters parameters)
          Adds page related parameters (path and pagemap and optionally version and interface).
static void addInterfaceParameters(java.lang.String interfaceParameter, org.apache.wicket.request.RequestParameters parameters)
          Analyzes the passed in interfaceParameter for the relevant parts and puts the parts as parameters in the provided request parameters object.
protected  void addResourceParameters(org.apache.wicket.Request request, org.apache.wicket.request.RequestParameters parameters)
          Adds (shared) resource related parameters (resource key).
 org.apache.wicket.request.RequestParameters decode(org.apache.wicket.Request request)
           
static java.lang.String decodePageMapName(java.lang.String pageMapName)
          Undoes the effect of encodePageMapName(String)
protected  java.lang.String doEncode(org.apache.wicket.RequestCycle requestCycle, org.apache.wicket.IRequestTarget requestTarget)
          In case you are using custom targets that are not part of the default target hierarchy, you need to override this method, which will be called after the defaults have been tried.
 java.lang.CharSequence encode(java.lang.CharSequence url)
          Returns the given url encoded.
protected  java.lang.CharSequence encode(org.apache.wicket.RequestCycle requestCycle, org.apache.wicket.request.target.component.IBookmarkablePageRequestTarget requestTarget)
          Encode a page class target.
protected  java.lang.CharSequence encode(org.apache.wicket.RequestCycle requestCycle, org.apache.wicket.request.target.component.listener.IListenerInterfaceRequestTarget requestTarget)
          Encode a listener interface target.
protected  java.lang.CharSequence encode(org.apache.wicket.RequestCycle requestCycle, org.apache.wicket.request.target.component.IPageRequestTarget requestTarget)
          Encode a page target.
 java.lang.CharSequence encode(org.apache.wicket.RequestCycle requestCycle, org.apache.wicket.IRequestTarget requestTarget)
          Encode the given request target.
protected  java.lang.CharSequence encode(org.apache.wicket.RequestCycle requestCycle, org.apache.wicket.request.target.resource.ISharedResourceRequestTarget requestTarget)
          Encode a shared resource target.
protected  java.lang.CharSequence encode(org.apache.wicket.RequestCycle requestCycle, org.apache.wicket.request.target.component.PageReferenceRequestTarget requestTarget)
          Encode a pageid request target.
static java.lang.String encodePageMapName(java.lang.String pageMapName)
          Makes page map name url safe.
protected  org.apache.wicket.request.target.coding.IRequestTargetUrlCodingStrategy getMountEncoder(org.apache.wicket.IRequestTarget requestTarget)
          Gets the mount encoder for the given request target if any.
protected  java.lang.String getRequestPath(org.apache.wicket.Request request)
          Gets the request info path.
 org.apache.wicket.request.target.coding.IRequestTargetUrlCodingStrategy[] listMounts()
           
 void mount(org.apache.wicket.request.target.coding.IRequestTargetUrlCodingStrategy encoder)
           
 java.lang.CharSequence pathForTarget(org.apache.wicket.IRequestTarget requestTarget)
           
 java.lang.String rewriteStaticRelativeUrl(java.lang.String string)
          
 org.apache.wicket.IRequestTarget targetForRequest(org.apache.wicket.request.RequestParameters requestParameters)
           
 void unmount(java.lang.String path)
           
 void unmount(java.lang.String path, org.apache.wicket.request.target.coding.IRequestTargetUrlCodingStrategy encoder)
           
 org.apache.wicket.request.target.coding.IRequestTargetUrlCodingStrategy urlCodingStrategyForPath(java.lang.String path)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

VersatileWebRequestCodingStrategy

public VersatileWebRequestCodingStrategy()
Construct.


VersatileWebRequestCodingStrategy

public VersatileWebRequestCodingStrategy(org.apache.wicket.protocol.http.request.WebRequestCodingStrategy.Settings settings)
Construct.

Parameters:
settings -
Method Detail

decode

public org.apache.wicket.request.RequestParameters decode(org.apache.wicket.Request request)
Specified by:
decode in interface org.apache.wicket.request.IRequestCodingStrategy
See Also:
IRequestCodingStrategy.decode(org.apache.wicket.Request)

encode

public java.lang.CharSequence encode(org.apache.wicket.RequestCycle requestCycle,
                                     org.apache.wicket.IRequestTarget requestTarget)
Encode the given request target. If a mount is found, that mounted url will be returned. Otherwise, one of the delegation methods will be called. In case you are using custom targets that are not part of the default target hierarchy, you need to override doEncode(RequestCycle, IRequestTarget), which will be called after the defaults have been tried. When that doesn't provide a url either, an exception will be thrown saying that encoding could not be done.

Specified by:
encode in interface org.apache.wicket.request.IRequestCodingStrategy
See Also:
IRequestCodingStrategy.encode(org.apache.wicket.RequestCycle, org.apache.wicket.IRequestTarget)

encode

public java.lang.CharSequence encode(java.lang.CharSequence url)
Returns the given url encoded.

Parameters:
url - The URL to encode
Returns:
The encoded url

listMounts

public org.apache.wicket.request.target.coding.IRequestTargetUrlCodingStrategy[] listMounts()
Specified by:
listMounts in interface org.apache.wicket.request.IRequestTargetMountsInfo
See Also:
IRequestTargetMountsInfo.listMounts()

urlCodingStrategyForPath

public org.apache.wicket.request.target.coding.IRequestTargetUrlCodingStrategy urlCodingStrategyForPath(java.lang.String path)
Specified by:
urlCodingStrategyForPath in interface org.apache.wicket.request.IRequestTargetMounter
See Also:
IRequestTargetMounter.urlCodingStrategyForPath(java.lang.String)

mount

public void mount(org.apache.wicket.request.target.coding.IRequestTargetUrlCodingStrategy encoder)
Specified by:
mount in interface org.apache.wicket.request.IRequestTargetMounter
See Also:
IRequestTargetMounter.mount(org.apache.wicket.request.target.coding.IRequestTargetUrlCodingStrategy)

addIgnoreMountPath

public void addIgnoreMountPath(java.lang.String path)
Specified by:
addIgnoreMountPath in interface org.apache.wicket.request.IRequestTargetMounter
See Also:
IRequestTargetMounter.addIgnoreMountPath(String)

pathForTarget

public java.lang.CharSequence pathForTarget(org.apache.wicket.IRequestTarget requestTarget)
Specified by:
pathForTarget in interface org.apache.wicket.request.IRequestTargetMounter
See Also:
IRequestTargetMounter.pathForTarget(org.apache.wicket.IRequestTarget)

targetForRequest

public org.apache.wicket.IRequestTarget targetForRequest(org.apache.wicket.request.RequestParameters requestParameters)
Specified by:
targetForRequest in interface org.apache.wicket.request.IRequestTargetMounter
See Also:
IRequestTargetMounter.targetForRequest(org.apache.wicket.request.RequestParameters)

unmount

public void unmount(java.lang.String path)
Specified by:
unmount in interface org.apache.wicket.request.IRequestTargetMounter
See Also:
IRequestTargetMounter.unmount(java.lang.String)

unmount

public final void unmount(java.lang.String path,
                          org.apache.wicket.request.target.coding.IRequestTargetUrlCodingStrategy encoder)
Parameters:
path - the mount path
encoder - the coding strategy to remove

addBookmarkablePageParameters

protected void addBookmarkablePageParameters(org.apache.wicket.Request request,
                                             org.apache.wicket.request.RequestParameters parameters)
Adds bookmarkable page related parameters (page alias and optionally page parameters). Any bookmarkable page alias mount will override this method; hence if a mount is found, this method will not be called. If you override this method to behave differently then encode(RequestCycle, IBookmarkablePageRequestTarget) should also be overridden to be in sync with that behavior.

Parameters:
request - the incoming request
parameters - the parameters object to set the found values on

addInterfaceParameters

protected void addInterfaceParameters(org.apache.wicket.Request request,
                                      org.apache.wicket.request.RequestParameters parameters)
Adds page related parameters (path and pagemap and optionally version and interface). If you override this method to behave different then also encode(RequestCycle, IListenerInterfaceRequestTarget) should be overridden to be in sync with that behavior.

Parameters:
request - the incoming request
parameters - the parameters object to set the found values on

addInterfaceParameters

public static void addInterfaceParameters(java.lang.String interfaceParameter,
                                          org.apache.wicket.request.RequestParameters parameters)
Analyzes the passed in interfaceParameter for the relevant parts and puts the parts as parameters in the provided request parameters object.

Parameters:
interfaceParameter - The format of the interfaceParameter is: page-map-name:path:version:interface:behaviourId:urlDepth
parameters - parameters object to set the found parts in

addResourceParameters

protected void addResourceParameters(org.apache.wicket.Request request,
                                     org.apache.wicket.request.RequestParameters parameters)
Adds (shared) resource related parameters (resource key). Any shared resource key mount will override this method; hence if a mount is found, this method will not be called. If you override this method to behave different then also encode(RequestCycle, ISharedResourceRequestTarget) should be overridden to be in sync with that behavior.

Parameters:
request - the incoming request
parameters - the parameters object to set the found values on

doEncode

protected java.lang.String doEncode(org.apache.wicket.RequestCycle requestCycle,
                                    org.apache.wicket.IRequestTarget requestTarget)
In case you are using custom targets that are not part of the default target hierarchy, you need to override this method, which will be called after the defaults have been tried. When this doesn't provide a url either (returns null), null will be returned by the encode method.

Parameters:
requestCycle - the current request cycle (for efficient access)
requestTarget - the request target
Returns:
the url to the provided target, as a relative path from the filter root.

encode

protected java.lang.CharSequence encode(org.apache.wicket.RequestCycle requestCycle,
                                        org.apache.wicket.request.target.component.IBookmarkablePageRequestTarget requestTarget)
Encode a page class target. If you override this method to behave different then also addBookmarkablePageParameters(Request, RequestParameters) should be overridden to be in sync with that behavior.

Parameters:
requestCycle - the current request cycle
requestTarget - the target to encode
Returns:
the encoded url

encode

protected java.lang.CharSequence encode(org.apache.wicket.RequestCycle requestCycle,
                                        org.apache.wicket.request.target.resource.ISharedResourceRequestTarget requestTarget)
Encode a shared resource target. If you override this method to behave different then also addResourceParameters(Request, RequestParameters) should be overridden to be in sync with that behavior.

Parameters:
requestCycle - the current request cycle
requestTarget - the target to encode
Returns:
the encoded url

encode

protected java.lang.CharSequence encode(org.apache.wicket.RequestCycle requestCycle,
                                        org.apache.wicket.request.target.component.PageReferenceRequestTarget requestTarget)
Encode a pageid request target.

Parameters:
requestCycle - the current request cycle
requestTarget - the target to encode
Returns:
the encoded url

encode

protected java.lang.CharSequence encode(org.apache.wicket.RequestCycle requestCycle,
                                        org.apache.wicket.request.target.component.listener.IListenerInterfaceRequestTarget requestTarget)
Encode a listener interface target. If you override this method to behave different then also addInterfaceParameters(Request, RequestParameters) should be overridden to be in sync with that behavior.

Parameters:
requestCycle - the current request cycle
requestTarget - the target to encode
Returns:
the encoded url

encode

protected java.lang.CharSequence encode(org.apache.wicket.RequestCycle requestCycle,
                                        org.apache.wicket.request.target.component.IPageRequestTarget requestTarget)
Encode a page target.

Parameters:
requestCycle - the current request cycle
requestTarget - the target to encode
Returns:
the encoded url

getMountEncoder

protected org.apache.wicket.request.target.coding.IRequestTargetUrlCodingStrategy getMountEncoder(org.apache.wicket.IRequestTarget requestTarget)
Gets the mount encoder for the given request target if any.

Parameters:
requestTarget - the request target to match
Returns:
the mount encoder if any

getRequestPath

protected java.lang.String getRequestPath(org.apache.wicket.Request request)
Gets the request info path. This is an overridable method in order to provide users with a means to implement e.g. a path encryption scheme. This method by default returns Request.getPath().

Parameters:
request - the request
Returns:
the path info object, possibly processed

encodePageMapName

public static final java.lang.String encodePageMapName(java.lang.String pageMapName)
Makes page map name url safe. Since the default page map name in wicket is null and null does not encode well into urls this method will substitute null for a known token. If the pageMapName passed in is not null it is returned without modification.

Parameters:
pageMapName - page map name
Returns:
encoded pagemap name

decodePageMapName

public static java.lang.String decodePageMapName(java.lang.String pageMapName)
Undoes the effect of encodePageMapName(String)

Parameters:
pageMapName - page map name
Returns:
decoded page map name

rewriteStaticRelativeUrl

public java.lang.String rewriteStaticRelativeUrl(java.lang.String string)

Specified by:
rewriteStaticRelativeUrl in interface org.apache.wicket.request.IRequestCodingStrategy


Copyright © 2011. All Rights Reserved.