use of org.tuckey.web.filters.urlrewrite.utils.ModRewriteConfLoader in project camel by apache.
the class UrlRewriteFilter method doStart.
@Override
protected void doStart() throws Exception {
ObjectHelper.notNull(camelContext, "camelContext");
if (conf == null) {
if (modRewriteConfFile != null) {
LOG.debug("Using mod rewrite config file: {} as config for urlRewrite", modRewriteConfFile);
InputStream is = camelContext.getClassResolver().loadResourceAsStream(modRewriteConfFile);
if (is == null) {
throw new IOException("Cannot load mod rewrite config file: " + modRewriteConfFile);
}
try {
String text = camelContext.getTypeConverter().mandatoryConvertTo(String.class, is);
ModRewriteConfLoader loader = new ModRewriteConfLoader();
conf = new Conf();
loader.process(text, conf);
} finally {
IOHelper.close(is);
}
} else if (modRewriteConfText != null) {
LOG.debug("Using modRewriteConfText: {} as config for urlRewrite", modRewriteConfText);
ModRewriteConfLoader loader = new ModRewriteConfLoader();
conf = new Conf();
loader.process(modRewriteConfText, conf);
} else if (configFile != null) {
LOG.debug("Using config file: {} as config for urlRewrite", configFile);
InputStream is = camelContext.getClassResolver().loadResourceAsStream(configFile);
if (is == null) {
throw new IOException("Cannot load config file: " + configFile);
}
try {
conf = new Conf(is, configFile);
} finally {
IOHelper.close(is);
}
}
if (conf != null) {
// set options before initializing
conf.setUseQueryString(isUseQueryString());
conf.setUseContext(isUseContext());
if (getDefaultMatchType() != null) {
conf.setDefaultMatchType(getDefaultMatchType());
}
if (getDecodeUsing() != null) {
conf.setDecodeUsing(getDecodeUsing());
}
conf.initialise();
}
if (conf == null || !conf.isOk()) {
throw new IllegalStateException("Error configuring config file: " + configFile);
}
}
if (urlRewriter == null) {
urlRewriter = new UrlRewriter(conf);
}
}
use of org.tuckey.web.filters.urlrewrite.utils.ModRewriteConfLoader in project load-balancer by RestComm.
the class BalancerConf method loadModRewriteStyle.
protected void loadModRewriteStyle(InputStream inputStream) {
ModRewriteConfLoader loader = new ModRewriteConfLoader();
try {
loader.process(inputStream, this);
docProcessed = true;
} catch (IOException e) {
addError("Exception loading conf " + " " + e.getMessage(), e);
}
}
Aggregations