public String getPermalink ( CmsObject cms , String resourceName , CmsUUID detailContentId ) { String permalink = "" ; try { permalink = substituteLink ( cms , CmsPermalinkResourceHandler . PERMALINK_HANDLER ) ; String id = cms . readResource ( resourceName , CmsResourceFilter . ALL ) . getStructureId ( ) . toString ( ) ; permalink += id ; if ( detailContentId != null ) { permalink += ":" + detailContentId ; } String ext = CmsFileUtil . getExtension ( resourceName ) ; if ( CmsStringUtil . isNotEmptyOrWhitespaceOnly ( ext ) ) { permalink += ext ; } CmsSite currentSite = OpenCms . getSiteManager ( ) . getCurrentSite ( cms ) ; String serverPrefix = null ; if ( currentSite == OpenCms . getSiteManager ( ) . getDefaultSite ( ) ) { Optional < CmsSite > siteForDefaultUri = OpenCms . getSiteManager ( ) . getSiteForDefaultUri ( ) ; if ( siteForDefaultUri . isPresent ( ) ) { serverPrefix = siteForDefaultUri . get ( ) . getServerPrefix ( cms , resourceName ) ; } else { serverPrefix = OpenCms . getSiteManager ( ) . getWorkplaceServer ( ) ; } } else { serverPrefix = currentSite . getServerPrefix ( cms , resourceName ) ; } if ( ! permalink . startsWith ( serverPrefix ) ) { permalink = serverPrefix + permalink ; } } catch ( CmsException e ) { // if something wrong permalink = e . getLocalizedMessage ( ) ; if ( LOG . isErrorEnabled ( ) ) { LOG . error ( e . getLocalizedMessage ( ) , e ) ; } } return permalink ; }
Returns the perma link for the given resource and optional detail content . <p<