use of org.apache.synapse.mediators.transform.url.URLRewriteMediator in project wso2-synapse by wso2.
the class URLRewriteMediatorFactory method createSpecificMediator.
protected Mediator createSpecificMediator(OMElement element, Properties properties) {
Iterator rules = element.getChildrenWithName(RULE_Q);
String inputProperty = element.getAttributeValue(ATT_IN_PROPERTY);
String outputProperty = element.getAttributeValue(ATT_OUT_PROPERTY);
URLRewriteMediator mediator = new URLRewriteMediator();
if (inputProperty != null) {
mediator.setInputProperty(inputProperty);
}
if (outputProperty != null) {
mediator.setOutputProperty(outputProperty);
}
while (rules.hasNext()) {
mediator.addRule(parseRule((OMElement) rules.next()));
}
processAuditStatus(mediator, element);
return mediator;
}
use of org.apache.synapse.mediators.transform.url.URLRewriteMediator in project wso2-synapse by wso2.
the class URLRewriteMediatorSerializer method serializeSpecificMediator.
protected OMElement serializeSpecificMediator(Mediator m) {
if (!(m instanceof URLRewriteMediator)) {
handleException("Unsupported mediator passed in for serialization : " + m.getType());
return null;
}
URLRewriteMediator mediator = (URLRewriteMediator) m;
OMElement rewrite = fac.createOMElement("rewrite", synNS);
String inProperty = mediator.getInputProperty();
String outProperty = mediator.getOutputProperty();
if (inProperty != null) {
rewrite.addAttribute(fac.createOMAttribute("inProperty", nullNS, inProperty));
}
if (outProperty != null) {
rewrite.addAttribute(fac.createOMAttribute("outProperty", nullNS, outProperty));
}
saveTracingState(rewrite, mediator);
List<RewriteRule> rules = mediator.getRules();
try {
for (RewriteRule r : rules) {
OMElement rule = serializeRule(r);
rewrite.addChild(rule);
}
} catch (EvaluatorException e) {
handleException("Error while serializing the rewrite rule", e);
}
return rewrite;
}
Aggregations