if (valueAttr == null && xpathAttr == null) {
String msg =
"The 'value'/'xpath' attribute is required for "
+ "the configuration for the 'set'/'append'"
+ "/'prepend' or repalce action";
throw new MediatorException(msg);
}
if (valueAttr != null && valueAttr.getAttributeValue() != null) {
urlRewriteActions.setValue(valueAttr.getAttributeValue());
}
if (xpathAttr != null && xpathAttr.getAttributeValue() != null) {
try {
urlRewriteActions.setXpath(SynapseXPathFactory.getSynapseXPath(actionEle,
ATT_XPATH));
} catch (JaxenException e) {
throw new MediatorException("Could not construct the" + " xpath");
}
}
}
if ("replace".equals(typeAttr.getAttributeValue())) {
if (regexAttr == null) {
String msg =
"The 'regex' attribute is required for the "
+ "configuration for the 'replace' action";
throw new MediatorException(msg);
}
urlRewriteActions.setRegex(regexAttr.getAttributeValue());
}
if (typeAttr.getAttributeValue() != null) {
urlRewriteActions.setAction(typeAttr.getAttributeValue());
}
if (fragmentAttr != null) {
urlRewriteActions.setFragment(fragmentAttr.getAttributeValue());
}
// if a value is specified, use it, else look for an expression
if (valueAttr != null) {
urlRewriteActions.setValue(valueAttr.getAttributeValue());
} else if (xpathAttr != null) {
try {
urlRewriteActions.setXpath(SynapseXPathFactory.getSynapseXPath(actionEle,
XPATH_Q));
} catch (JaxenException e) {
String msg = "Invalid XPapth expression : " + xpathAttr.getAttributeValue();
throw new MediatorException(msg);
}
}
actionList.add(urlRewriteActions);
}
return actionList;