Search in sources :

Example 1 with URLRewriteMediator

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;
}
Also used : URLRewriteMediator(org.apache.synapse.mediators.transform.url.URLRewriteMediator) Iterator(java.util.Iterator) OMElement(org.apache.axiom.om.OMElement)

Example 2 with URLRewriteMediator

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;
}
Also used : URLRewriteMediator(org.apache.synapse.mediators.transform.url.URLRewriteMediator) EvaluatorException(org.apache.synapse.commons.evaluators.EvaluatorException) OMElement(org.apache.axiom.om.OMElement) RewriteRule(org.apache.synapse.mediators.transform.url.RewriteRule)

Aggregations

OMElement (org.apache.axiom.om.OMElement)2 URLRewriteMediator (org.apache.synapse.mediators.transform.url.URLRewriteMediator)2 Iterator (java.util.Iterator)1 EvaluatorException (org.apache.synapse.commons.evaluators.EvaluatorException)1 RewriteRule (org.apache.synapse.mediators.transform.url.RewriteRule)1