private String buildFacesViewId ( final String servletMapping , final String resourcePath ) { for ( String suffix : getFacesSuffixes ( ) ) { if ( resourcePath . endsWith ( suffix ) ) { StringBuffer result = new StringBuffer ( ) ; Map < Pattern , String > patterns = new HashMap <> ( ) ; Pattern pathMapping = Pattern . compile ( "^(/.*)/\\*$" ) ; Pattern extensionMapping = Pattern . compile ( "^\\*(\\..*)$" ) ; Pattern defaultMapping = Pattern . compile ( "^/\\*$" ) ; patterns . put ( pathMapping , "$1" + resourcePath ) ; patterns . put ( extensionMapping , resourcePath . replaceAll ( "^(.*)(\\.\\w+)$" , "$1" ) + "$1" ) ; patterns . put ( defaultMapping , resourcePath ) ; boolean matched = false ; Iterator < Pattern > iterator = patterns . keySet ( ) . iterator ( ) ; while ( ( matched == false ) && iterator . hasNext ( ) ) { Pattern p = iterator . next ( ) ; Matcher m = p . matcher ( servletMapping ) ; if ( m . matches ( ) ) { String replacement = patterns . get ( p ) ; m . appendReplacement ( result , replacement ) ; matched = true ; } } if ( matched == false ) { return null ; } return result . toString ( ) ; } } return resourcePath ; }
Build a Faces view ID for the given resource path return null if not mapped by Faces Servlet