private boolean linksToOtherDomain ( Adaptable adaptable , Page currentPage , Resource targetResource ) { if ( currentPage == null || targetResource == null ) { return false ; } UrlHandlerConfig urlHandlerConfig = AdaptTo . notNull ( adaptable , UrlHandlerConfig . class ) ; Resource currentResource = AdaptTo . notNull ( currentPage , Resource . class ) ; ResourceResolver resourceResolver = currentResource . getResourceResolver ( ) ; String currentSiteRoot = getRootPath ( currentPage . getPath ( ) , urlHandlerConfig . getSiteRootLevel ( currentResource ) , resourceResolver ) ; String pathSiteRoot = getRootPath ( targetResource . getPath ( ) , urlHandlerConfig . getSiteRootLevel ( targetResource ) , resourceResolver ) ; boolean notInCurrentSite = ! StringUtils . equals ( currentSiteRoot , pathSiteRoot ) ; if ( notInCurrentSite ) { UrlConfig targetUrlConfig = new UrlConfig ( targetResource ) ; return targetUrlConfig . isValid ( ) ; } else { return false ; } }
Checks if the target resource is located outsite the current site and if for this other resource context a valid url configuration with a specific hostname exists .