Class CmsAdvancedLinkSubstitutionHandler

    • Method Detail

      • getLink

        public java.lang.String getLink​(CmsObject cms,
                                        java.lang.String link,
                                        java.lang.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:someone@elsewhere.com -> 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 java.lang.String getRootPath​(CmsObject cms,
                                            java.lang.String targetUri,
                                            java.lang.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:

        • 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.

        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:
        I_CmsLinkSubstitutionHandler.getRootPath(org.opencms.file.CmsObject, java.lang.String, java.lang.String)
      • isExcluded

        protected boolean isExcluded​(CmsObject cms,
                                     java.lang.String path)
        Returns if the given path starts with an exclude prefix.

        Parameters:
        cms - the cms context
        path - the path to check
        Returns:
        true if the given path starts with an exclude prefix