if (element.hasDefined(Constants.PREFIX)) log.setPrefix(element.get(Constants.PREFIX).asString());
return log;
}
static Valve createRewriteValve(final Container container, final ModelNode element) throws StartException {
final RewriteValve rewriteValve = new RewriteValve();
rewriteValve.setContainer(container);
StringBuilder configuration = new StringBuilder();
for (final ModelNode rewriteElement : element.asList()) {
final ModelNode rewrite = rewriteElement.asProperty().getValue();
if (rewrite.has(Constants.CONDITION)) {
for (final ModelNode conditionElement : rewrite.get(Constants.CONDITION).asList()) {
final ModelNode condition = conditionElement.asProperty().getValue();
configuration.append("RewriteCond ")
.append(condition.get(Constants.TEST).asString())
.append(" ").append(condition.get(Constants.PATTERN).asString());
if (condition.hasDefined(Constants.FLAGS)) {
configuration.append(" [").append(condition.get(Constants.FLAGS).asString()).append("]\r\n");
} else {
configuration.append("\r\n");
}
}
}
configuration.append("RewriteRule ")
.append(rewrite.get(Constants.PATTERN).asString())
.append(" ").append(rewrite.get(Constants.SUBSTITUTION).asString());
if (rewrite.hasDefined(Constants.FLAGS)) {
configuration.append(" [").append(rewrite.get(Constants.FLAGS).asString()).append("]\r\n");
} else {
configuration.append("\r\n");
}
}
try {
rewriteValve.setConfiguration(configuration.toString());
} catch(Exception e) {
throw new StartException(e);
}
return rewriteValve;
}