use of com.dexels.navajo.server.enterprise.integrity.WorkerInterface in project navajo by Dexels.
the class Dispatcher method dispatch.
/*
* Process a webservice using a special handler class.
*
* @param handler the class the will process the webservice.
*
* @param in the request Navajo document.
*
* @param access
*
* @param parms
*
* @return
*
* @throws Exception
*/
private final Navajo dispatch(Access access) throws Exception {
WorkerInterface integ = null;
Navajo out = null;
if (access == null) {
logger.warn("Null access!!!");
return null;
}
Navajo in = access.getInDoc();
if (in != null) {
Header h = in.getHeader();
if (h != null) {
// Process client token:
String clientToken = h.getHeaderAttribute("clientToken");
if (clientToken != null) {
access.setClientToken(access.getClientToken() + " -- " + clientToken);
}
// Process client info:
String clientInfo = h.getHeaderAttribute("clientInfo");
if (clientInfo != null) {
access.setClientInfo(clientInfo);
}
// Process piggyback data:
Set<Map<String, String>> s = h.getPiggybackData();
if (s != null) {
for (Iterator<Map<String, String>> iter = s.iterator(); iter.hasNext(); ) {
Map<String, String> element = iter.next();
access.addPiggybackData(element);
}
}
}
} else {
throw NavajoFactory.getInstance().createNavajoException("Null input message in dispatch");
}
// Check for webservice transaction integrity.
boolean integrityViolation = false;
integ = navajoConfig.getIntegrityWorker();
if (integ != null) {
// Check for stored response or webservice that is still running.
out = integ.getResponse(access, in);
if (out != null) {
integrityViolation = true;
return out;
}
}
try {
ServiceHandler sh = handlerFactory.createHandler(navajoConfig, access, simulationMode);
out = sh.doService(access);
access.setOutputDoc(out);
// Store response for integrity checking.
if (integ != null && out != null && !integrityViolation) {
integ.setResponse(in, out);
}
return out;
} finally {
// Remove stored access from worker request list.
if (integ != null) {
integ.removeFromRunningRequestsList(in);
}
}
}
Aggregations