Search in sources :

Example 1 with ConfigurationBuilder

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;
}
Also used : ConfigurationBuilder(org.ocpsoft.rewrite.config.ConfigurationBuilder) DocumentBuilderFactory(javax.xml.parsers.DocumentBuilderFactory) DocumentBuilder(javax.xml.parsers.DocumentBuilder) ParserConfigurationException(javax.xml.parsers.ParserConfigurationException) IOException(java.io.IOException) URL(java.net.URL)

Aggregations

IOException (java.io.IOException)1 URL (java.net.URL)1 DocumentBuilder (javax.xml.parsers.DocumentBuilder)1 DocumentBuilderFactory (javax.xml.parsers.DocumentBuilderFactory)1 ParserConfigurationException (javax.xml.parsers.ParserConfigurationException)1 ConfigurationBuilder (org.ocpsoft.rewrite.config.ConfigurationBuilder)1