Search in sources :

Example 1 with ParameterizedPatternSyntaxException

use of org.ocpsoft.rewrite.param.ParameterizedPatternSyntaxException in project oxCore by GluuFederation.

the class AccessRewriteConfiguration method addRulesForAllXHTML.

private void addRulesForAllXHTML(DocumentBuilder documentBuilder, String contexPath, String path, ConfigurationBuilder builder) {
    Collection<File> xhtmlFiles = FileUtils.listFiles(new File(contexPath), new RegexFileFilter(".*\\.xhtml$"), DirectoryFileFilter.DIRECTORY);
    Collection<File> navigationFiles = FileUtils.listFiles(new File(path), new RegexFileFilter(".*\\.navigation\\.xml"), DirectoryFileFilter.DIRECTORY);
    Map<String, String> rewriteMap = getRewriteMap(documentBuilder, navigationFiles);
    for (File file : xhtmlFiles) {
        String xhtmlPath = file.getAbsolutePath();
        xhtmlPath = xhtmlPath.replace("\\", "/");
        String xhtmlUri = xhtmlPath.substring(contexPath.length(), xhtmlPath.lastIndexOf(".xhtml"));
        try {
            String rewriteKey = file.getName().split("\\.")[0];
            if (rewriteMap.containsKey(rewriteKey)) {
                builder.addRule(Join.path(rewriteMap.get(rewriteKey)).to(xhtmlUri + ".htm"));
                log.debug("Added rule from navigation.xml {}", rewriteMap.get(rewriteKey), xhtmlUri + ".htm");
            } else {
                if (!xhtmlUri.startsWith(WEB_INF_PATH)) {
                    builder.addRule(Join.path(xhtmlUri).to(xhtmlUri + ".htm"));
                    log.debug("Added rule {}", xhtmlUri, xhtmlUri + ".htm");
                }
            }
        } catch (ParameterizedPatternSyntaxException ex) {
            FacesLogger.CONFIG.getLogger().log(Level.SEVERE, "Failed to add rule for " + xhtmlPath, ex);
        }
    }
}
Also used : RegexFileFilter(org.apache.commons.io.filefilter.RegexFileFilter) ParameterizedPatternSyntaxException(org.ocpsoft.rewrite.param.ParameterizedPatternSyntaxException) File(java.io.File)

Aggregations

File (java.io.File)1 RegexFileFilter (org.apache.commons.io.filefilter.RegexFileFilter)1 ParameterizedPatternSyntaxException (org.ocpsoft.rewrite.param.ParameterizedPatternSyntaxException)1