Package org.opencms.staticexport
Class CmsAdvancedLinkSubstitutionHandler
java.lang.Object
org.opencms.staticexport.CmsDefaultLinkSubstitutionHandler
org.opencms.staticexport.CmsAdvancedLinkSubstitutionHandler
- All Implemented Interfaces:
I_CmsLinkSubstitutionHandler
Advanced link substitution behavior.
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.
- Since:
- 7.5.0
- See Also:
-
Field Summary
Fields inherited from class org.opencms.staticexport.CmsDefaultLinkSubstitutionHandler
ATTR_IS_IMAGE_LINK, DONT_USE_CURRENT_SITE_FOR_WORKPLACE_REQUESTS, OVERRIDE_SITEROOT_PREFIX
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionReturns the resource root path in the OpenCms VFS for the given link, ornull
in case the link points to an external site.getRootPath
(CmsObject cms, String targetUri, String basePath) Returns the resource root path in the OpenCms VFS for the given target URI link, ornull
in case the link points to an external site.protected boolean
isExcluded
(CmsObject cms, String path) Returns if the given path starts with an exclude prefix.Methods inherited from class org.opencms.staticexport.CmsDefaultLinkSubstitutionHandler
addVfsPrefix, generateCacheKey, getLink, getRootPathForSite, getSimpleRootPath, isDetailPageLinkSecure, isSecureLink, prepareExportParameters
-
Constructor Details
-
CmsAdvancedLinkSubstitutionHandler
public CmsAdvancedLinkSubstitutionHandler()
-
-
Method Details
-
getLink
Description copied from class:CmsDefaultLinkSubstitutionHandler
Returns the resource root path in the OpenCms VFS for the given link, ornull
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:someone@elsewhere.com -> null
- Specified by:
getLink
in interfaceI_CmsLinkSubstitutionHandler
- Overrides:
getLink
in classCmsDefaultLinkSubstitutionHandler
- Parameters:
cms
- 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 thelink
forceSecure
- iftrue
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
andsiteRoot
- See Also:
-
getRootPath
Description copied from interface:I_CmsLinkSubstitutionHandler
Returns the resource root path in the OpenCms VFS for the given target URI link, ornull
in case the link points to an external site.The default implementation applies the following transformations to the link:
- In case the link starts with a VFS prefix (for example
/opencms/opencms
, this prefix is removed from the result - In case the link is not a root path, the current site root is appended to the result.
- In case the link is relative, it will be made absolute using the given absolute
basePath
as starting point. - In case the link contains a server schema (for example
http://www.mysite.de/
), which points to a configured site in OpenCms, the server schema is replaced with the root path of the site. - In case the link points to an external site, or in case it is not a valid URI,
then
null
is returned.
CmsDefaultLinkSubstitutionHandler
, which can be fully customized using this handler interface.- Specified by:
getRootPath
in interfaceI_CmsLinkSubstitutionHandler
- Overrides:
getRootPath
in classCmsDefaultLinkSubstitutionHandler
- Parameters:
cms
- the current users OpenCms contexttargetUri
- the target URI linkbasePath
- path to use as base in case the target URI is relative (can benull
)- 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:
- In case the link starts with a VFS prefix (for example
-
isExcluded
Returns if the given path starts with an exclude prefix.- Parameters:
cms
- the cms contextpath
- the path to check- Returns:
true
if the given path starts with an exclude prefix
-