private static final QName Q_TARGET
= new QName(XMLConfigConstants.SYNAPSE_NAMESPACE, "target");
public Mediator createSpecificMediator(OMElement elem, Properties properties) {
CalloutMediator callout = new CalloutMediator();
OMAttribute attServiceURL = elem.getAttribute(ATT_URL);
OMAttribute attAction = elem.getAttribute(ATT_ACTION);
OMElement configElt = elem.getFirstChildWithName(Q_CONFIG);
OMElement sourceElt = elem.getFirstChildWithName(Q_SOURCE);
OMElement targetElt = elem.getFirstChildWithName(Q_TARGET);
if (attServiceURL != null) {
callout.setServiceURL(attServiceURL.getAttributeValue());
} else {
handleException("The 'serviceURL' attribute is required for the Callout mediator");
}
if (attAction != null) {
callout.setAction(attAction.getAttributeValue());
}
if (configElt != null) {
OMAttribute axis2xmlAttr = configElt.getAttribute(ATT_AXIS2XML);
OMAttribute repoAttr = configElt.getAttribute(ATT_REPOSITORY);
if (axis2xmlAttr != null && axis2xmlAttr.getAttributeValue() != null) {
File axis2xml = new File(axis2xmlAttr.getAttributeValue());
if (axis2xml.exists() && axis2xml.isFile()) {
callout.setAxis2xml(axis2xmlAttr.getAttributeValue());
} else {
handleException("Invalid axis2.xml path: " + axis2xmlAttr.getAttributeValue());
}
}
if (repoAttr != null && repoAttr.getAttributeValue() != null) {
File repo = new File(repoAttr.getAttributeValue());
if (repo.exists() && repo.isDirectory()) {
callout.setClientRepository(repoAttr.getAttributeValue());
} else {
handleException("Invalid repository path: " + repoAttr.getAttributeValue());
}
}
}
if (sourceElt != null) {
if (sourceElt.getAttribute(ATT_XPATH) != null) {
try {
callout.setRequestXPath(
SynapseXPathFactory.getSynapseXPath(sourceElt, ATT_XPATH));
} catch (JaxenException e) {
handleException("Invalid source XPath : "
+ sourceElt.getAttributeValue(ATT_XPATH));
}
} else if (sourceElt.getAttribute(ATT_KEY) != null) {
callout.setRequestKey(sourceElt.getAttributeValue(ATT_KEY));
} else {
handleException("A 'xpath' or 'key' attribute " +
"is required for the Callout 'source'");
}
} else {
handleException("The message 'source' must be specified for a Callout mediator");
}
if (targetElt != null) {
if (targetElt.getAttribute(ATT_XPATH) != null) {
try {
callout.setTargetXPath(
SynapseXPathFactory.getSynapseXPath(targetElt, ATT_XPATH));
} catch (JaxenException e) {
handleException("Invalid target XPath : "
+ targetElt.getAttributeValue(ATT_XPATH));
}
} else if (targetElt.getAttribute(ATT_KEY) != null) {
callout.setTargetKey(targetElt.getAttributeValue(ATT_KEY));
} else {
handleException("A 'xpath' or 'key' attribute " +
"is required for the Callout 'target'");
}
} else {