final Request request = rc.getRequest();
final Signature rsig = request.getSignature();
if(rsig != Signature.QUERY) {
throw new IllegalStateException("Illegal command is passed to QueryProcessor: " + rsig);
}
final QueryRequest queryRequest = (QueryRequest) request;
final String query = queryRequest.getQuery();
if(query == null) {
throw new IllegalStateException("query was null for: " + queryRequest);
}
// load shipped variables
final XQueryModule module = new XQueryModule();
final ShippedVariable[] vars = queryRequest.getShippedVariables();
if(vars != null) {
for(ShippedVariable var : vars) {
try {
module.putVariable(var.getVarName(), var);
} catch (XQueryException e) {
throw new RemoteException("failed to declare shipped variable: " + var, e);
}
}
}
final XQueryProcessor proccessor = new XQueryProcessor(module);
try {
proccessor.parse(query, queryRequest.getBaseUri());
} catch (XQueryException e) {
LOG.error("parse failed: \n" + query, e);
rc.setFault(e);
_resHandler.onResponse(rc);
return;