}
}
expression.close();
conn.close();
} catch (XQException e) {
throw new MessagingException("Caught Exception while opening a connection to the datasource", e);
}
if(xQueryParameters != null) {
if (xQueryParameterMap == null) {
throw new MessagingException("Expecting " + xQueryParameters.size() + " parameters in the xquery, " +
"but none provided to the router");
}
//now check if all the parameter needed are present in the map
List<String> missingParameters = new ArrayList<String>();
for(String xQueryParameter:xQueryParameters) {
if(!xQueryParameterMap.containsKey(xQueryParameter)) {
missingParameters.add(xQueryParameter);
}
}
if(missingParameters.size() > 0) {
StringBuilder builder = new StringBuilder();
builder.append("[").append("$").append(missingParameters.get(0));
if(missingParameters.size() > 1) {
for(int i = 1;i < missingParameters.size();i++) {
builder.append(", ").append("$").append(missingParameters.get(i));
}
}
builder.append("]");
throw new MessagingException("Missing parameter(s) " + builder.toString());
}
}
}