use of org.ocpsoft.rewrite.config.ConfigurationBuilder in project oxCore by GluuFederation.
the class AccessRewriteConfiguration method getConfiguration.
@Override
public Configuration getConfiguration(final ServletContext context) {
ConfigurationBuilder builder = ConfigurationBuilder.begin();
DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
factory.setNamespaceAware(true);
try {
DocumentBuilder documentBuilder = factory.newDocumentBuilder();
Enumeration<URL> urlEnumeration = getClass().getClassLoader().getResources(DEFAULT_NAVIGATION_PATH);
if (urlEnumeration.hasMoreElements()) {
URL url = urlEnumeration.nextElement();
addRulesForAllXHTML(documentBuilder, context.getRealPath(""), url.getPath(), builder);
}
if (!Utils.isCustomPagesDirExists())
return builder;
addRulesForAllXHTML(documentBuilder, Utils.getCustomPagesPath(), Utils.getCustomPagesPath(), builder);
} catch (ParserConfigurationException ex) {
FacesLogger.CONFIG.getLogger().log(Level.SEVERE, "Can't parse rewrite rules", ex);
} catch (IOException ex) {
FacesLogger.CONFIG.getLogger().log(Level.SEVERE, "Can't load navigation rules", ex);
}
return builder;
}
Aggregations