public class CmsAdvancedLinkSubstitutionHandler extends CmsDefaultLinkSubstitutionHandler
You can define additional paths that are always used as external links, even if they point to the same configured site than the OpenCms itself.
for the method where this handler is used.ATTR_IS_IMAGE_LINK, DONT_USE_CURRENT_SITE_FOR_WORKPLACE_REQUESTS, OVERRIDE_SITEROOT_PREFIX| Constructor and Description |
|---|
CmsAdvancedLinkSubstitutionHandler() |
| Modifier and Type | Method and Description |
|---|---|
java.lang.String |
getLink(CmsObject cms,
java.lang.String link,
java.lang.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. |
java.lang.String |
getRootPath(CmsObject cms,
java.lang.String targetUri,
java.lang.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. |
protected boolean |
isExcluded(CmsObject cms,
java.lang.String path)
Returns if the given path starts with an exclude prefix.
|
addVfsPrefix, generateCacheKey, getLink, getRootPathForSite, getSimpleRootPath, isDetailPageLinkSecure, isSecureLink, prepareExportParameterspublic CmsAdvancedLinkSubstitutionHandler()
public java.lang.String getLink(CmsObject cms, java.lang.String link, java.lang.String siteRoot, boolean forceSecure)
CmsDefaultLinkSubstitutionHandlernull 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_pathIf 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.htmlIf 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 -> nullIf 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:someone@elsewhere.com -> null
getLink in interface I_CmsLinkSubstitutionHandlergetLink in class CmsDefaultLinkSubstitutionHandlercms - the current OpenCms user contextlink - the link to process which is assumed to point to a VFS resource, with optional parameterssiteRoot - the site root of the linkforceSecure - if true generates always an absolute URL (with protocol and server name) for secure linkslink and siteRootCmsDefaultLinkSubstitutionHandler.getLink(org.opencms.file.CmsObject, java.lang.String, java.lang.String, boolean)public java.lang.String getRootPath(CmsObject cms, java.lang.String targetUri, java.lang.String basePath)
I_CmsLinkSubstitutionHandlernull in
case the link points to an external site.The default implementation applies the following transformations to the link:
/opencms/opencms,
this prefix is removed from the result
basePath
as starting point.
http://www.mysite.de/),
which points to a configured site in OpenCms, the server schema is replaced with
the root path of the site.
null is returned.
CmsDefaultLinkSubstitutionHandler, which can be fully customized using this handler interface.getRootPath in interface I_CmsLinkSubstitutionHandlergetRootPath in class CmsDefaultLinkSubstitutionHandlercms - the current users OpenCms contexttargetUri - the target URI linkbasePath - path to use as base in case the target URI is relative (can be null)null in
case the link points to an external siteI_CmsLinkSubstitutionHandler.getRootPath(org.opencms.file.CmsObject, java.lang.String, java.lang.String)protected boolean isExcluded(CmsObject cms, java.lang.String path)
cms - the cms contextpath - the path to checktrue if the given path starts with an exclude prefix