org.opencms.staticexport
Class CmsTestLinkSubstitutionHandler

java.lang.Object
  extended by org.opencms.staticexport.CmsDefaultLinkSubstitutionHandler
      extended by org.opencms.staticexport.CmsTestLinkSubstitutionHandler
All Implemented Interfaces:
I_CmsLinkSubstitutionHandler

public class CmsTestLinkSubstitutionHandler
extends CmsDefaultLinkSubstitutionHandler

Test handler for custom link substitution.


Field Summary
 
Fields inherited from class org.opencms.staticexport.CmsDefaultLinkSubstitutionHandler
DONT_USE_CURRENT_SITE_FOR_WORKPLACE_REQUESTS
 
Constructor Summary
CmsTestLinkSubstitutionHandler()
           
 
Method Summary
 String getLink(CmsObject cms, String link, String siteRoot, boolean forceSecure)
          Returns the resource root path in the OpenCms VFS for the given link, or null in case the link points to an external site.
 String getRootPath(CmsObject cms, String targetUri, String basePath)
          Returns the resource root path in the OpenCms VFS for the given target URI link, or null in case the link points to an external site.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

CmsTestLinkSubstitutionHandler

public CmsTestLinkSubstitutionHandler()
Method Detail

getLink

public String getLink(CmsObject cms,
                      String link,
                      String siteRoot,
                      boolean forceSecure)
Description copied from class: CmsDefaultLinkSubstitutionHandler
Returns the resource root path in the OpenCms VFS for the given link, or null in case the link points to an external site.

If the target URI contains no site information, but starts with the opencms context, the context is removed:

 /opencms/opencms/system/further_path -> /system/further_path
If the target URI contains no site information, the path will be prefixed with the current site from the provided OpenCms user context:
 /folder/page.html -> /sites/mysite/folder/page.html
If the path of the target URI is relative, i.e. does not start with "/", the path will be prefixed with the current site and the given relative path, then normalized. If no relative path is given, null is returned. If the normalized path is outsite a site, null is returned.
 page.html -> /sites/mysite/page.html
 ../page.html -> /sites/mysite/page.html
 ../../page.html -> null
If the target URI contains a scheme/server name that denotes an opencms site, it is replaced by the appropriate site path:
 http://www.mysite.de/folder/page.html -> /sites/mysite/folder/page.html

If the target URI contains a scheme/server name that does not match with any site, or if the URI is opaque or invalid, null is returned:

 http://www.elsewhere.com/page.html -> null
 mailto:[email protected] -> null

Specified by:
getLink in interface I_CmsLinkSubstitutionHandler
Overrides:
getLink in class CmsDefaultLinkSubstitutionHandler
Parameters:
cms - the current OpenCms user context
link - the link to process which is assumed to point to a VFS resource, with optional parameters
siteRoot - the site root of the link
forceSecure - if true generates always an absolute URL (with protocol and server name) for secure links
Returns:
a link from the URI stored in the provided OpenCms user context to the VFS resource indicated by the given link and siteRoot
See Also:
CmsDefaultLinkSubstitutionHandler.getLink(org.opencms.file.CmsObject, java.lang.String, java.lang.String, boolean)

getRootPath

public String getRootPath(CmsObject cms,
                          String targetUri,
                          String basePath)
Description copied from interface: I_CmsLinkSubstitutionHandler
Returns the resource root path in the OpenCms VFS for the given target URI link, or null in case the link points to an external site.

The default implementation applies the following transformations to the link:

Please note the above text describes the default behavior as implemented by CmsDefaultLinkSubstitutionHandler, which can be fully customized using this handler interface.

Specified by:
getRootPath in interface I_CmsLinkSubstitutionHandler
Overrides:
getRootPath in class CmsDefaultLinkSubstitutionHandler
Parameters:
cms - the current users OpenCms context
targetUri - the target URI link
basePath - path to use as base in case the target URI is relative (can be null)
Returns:
the resource root path in the OpenCms VFS for the given target URI link, or null in case the link points to an external site
See Also:
CmsDefaultLinkSubstitutionHandler.getRootPath(org.opencms.file.CmsObject, java.lang.String, java.lang.String)