if (xqueryKey != null) {
//Use KeyFactory to create Key
ValueFactory keyFactory = new ValueFactory();
queryKey = keyFactory.createValue(XMLConfigConstants.KEY, elem);
} else {
throw new MediatorException("The 'key' attribute is required for the XQuery mediator");
}
if (attrTarget != null) {
String targetValue = attrTarget.getAttributeValue();
if (targetValue != null && !"".equals(targetValue)) {
try {
this.querySource = targetValue;
this.target = SynapseXPathFactory.getSynapseXPath(elem, ATT_TARGET);
} catch (JaxenException e) {
throw new MediatorException("Invalid XPath specified for the target attribute : " +
targetValue);
}
}
}
// after successfully creating the mediator
// set its common attributes such as tracing etc
processAuditStatus(this, elem);
OMElement dataSource = elem.getFirstChildWithName(
new QName(XMLConfigConstants.SYNAPSE_NAMESPACE, "dataSource"));
if (dataSource != null) {
dataSourceProperties.addAll(getMediatorProperties(dataSource));
}
Iterator it = elem.getChildrenWithName(new QName(XMLConfigConstants.SYNAPSE_NAMESPACE,
"variable"));
while (it.hasNext()) {
OMElement variableOM = (OMElement) it.next();
String name = variableOM.getAttributeValue(ATT_NAME_Q);
if (name != null && !"".equals(name)) {
String type = variableOM.getAttributeValue(ATT_TYPE_Q);
if (type != null && !"".equals(type)) {
String value = variableOM.getAttributeValue(ATT_VALUE_Q);
Variable variable;
if (value != null && !"".equals(value)) {
variable = new Variable(new QName(name.trim()));
variable.setValue(value.trim());
variable.setType(Variable.BASE_VARIABLE);
} else {
String key = variableOM.getAttributeValue(ATT_KEY_Q);
String expr = variableOM.getAttributeValue(ATT_EXPR_Q);
variable = new Variable(new QName(name.trim()));
variable.setVariableType(Variable.CUSTOM_VARIABLE);
if (key != null) {
variable.setRegKey(key.trim());
}
if (expr != null && !"".equals(expr)) {
try {
variable.setExpression(SynapseXPathFactory.getSynapseXPath(
variableOM, MediatorProperty.ATT_EXPR_Q));
} catch (JaxenException e) {
throw new MediatorException("Invalid XPath specified for" +
" the expression attribute : " + expr);
}
}
}
if ("INT".equals(type.trim())) {
variable.setType(XQItemType.XQBASETYPE_INT);
} else if ("INTEGER".equals(type.trim())) {
variable.setType(XQItemType.XQBASETYPE_INTEGER);
} else if ("BOOLEAN".equals(type.trim())) {
variable.setType(XQItemType.XQBASETYPE_BOOLEAN);
} else if ("BYTE".equals(type.trim())) {
variable.setType(XQItemType.XQBASETYPE_BYTE);
} else if ("DOUBLE".equals(type.trim())) {
variable.setType(XQItemType.XQBASETYPE_DOUBLE);
} else if ("SHORT".equals(type.trim())) {
variable.setType(XQItemType.XQBASETYPE_SHORT);
} else if ("LONG".equals(type.trim())) {
variable.setType(XQItemType.XQBASETYPE_LONG);
} else if ("FLOAT".equals(type.trim())) {
variable.setType(XQItemType.XQBASETYPE_FLOAT);
} else if ("STRING".equals(type.trim())) {
variable.setType(XQItemType.XQBASETYPE_STRING);
} else if ("DOCUMENT".equals(type.trim())) {
variable.setType(XQItemType.XQITEMKIND_DOCUMENT);
} else if ("DOCUMENT_ELEMENT".equals(type.trim())) {
variable.setType(XQItemType.XQITEMKIND_DOCUMENT_ELEMENT);
} else if ("ELEMENT".equals(type.trim())) {
variable.setType(XQItemType.XQITEMKIND_ELEMENT);
} else {
throw new MediatorException("Unsupported Type");
}
variables.add(variable);
}
}
}