ValueFactory keyFactory = new ValueFactory();
Value key = keyFactory.createValue(XMLConfigConstants.KEY, omElem);
schemaKeys.add(key);
} else {
throw new MediatorException("A 'schema' definition must contain a local property 'key'");
}
} else {
throw new MediatorException("Invalid 'schema' declaration for validate mediator");
}
}
if (schemaKeys.size() == 0) {
throw new MediatorException("No schemas specified for the validate mediator");
} else {
this.schemaKeys = schemaKeys;
}
// process source XPath attribute if present
OMAttribute attSource = elem.getAttribute(ATT_SOURCE);
if (attSource != null) {
try {
source = SynapseXPathFactory.getSynapseXPath(elem, ATT_SOURCE);
} catch (JaxenException e) {
throw new MediatorException("Invalid XPath expression specified for attribute 'source'");
}
}
// process on-fail
OMElement onFail = null;
Iterator iterator = elem.getChildrenWithName(ON_FAIL_Q);
if (iterator.hasNext()) {
onFail = (OMElement) iterator.next();
}
if (onFail != null && onFail.getChildElements().hasNext()) {
addChildren(onFail, this);
} else {
throw new MediatorException("A non-empty <on-fail> child element is required for " +
"the <validate> mediator");
}
// after successfully creating the mediator
// set its common attributes such as tracing etc
processAuditStatus(this, elem);
// set the features
for (Map.Entry<String, String> entry : collectNameValuePairs(elem, FEATURE_Q).entrySet()) {
String value = entry.getValue();
boolean isFeatureEnabled;
if ("true".equals(value)) {
isFeatureEnabled = true;
} else if ("false".equals(value)) {
isFeatureEnabled = false;
} else {
throw new MediatorException("The feature must have value true or false");
}
addFeature(entry.getKey(), isFeatureEnabled);
}
}