use of com.dexels.navajo.events.types.NavajoExceptionEvent in project navajo by Dexels.
the class Dispatcher method finalizeService.
@Override
public void finalizeService(Navajo inMessage, Access access, String rpcName, String rpcUser, Throwable myException, String origThreadName, boolean scheduledWebservice, boolean afterWebServiceActivated, AfterWebServiceEmitter emit) {
if (access != null && !scheduledWebservice) {
Navajo outMessage = access.getOutputDoc();
try {
// Always make sure header contains original rpcName and rpcUser
// (BUT NOT PASSWORD!).
Header h = outMessage.getHeader();
if (h == null) {
h = NavajoFactory.getInstance().createHeader(outMessage, rpcName, rpcUser, "", -1);
outMessage.addHeader(h);
} else {
h.setRPCName(rpcName);
h.setRPCUser(rpcUser);
}
// Set accessId to make sure it can be used as reference by
// triggered tasks.
h.setHeaderAttribute("accessId", access.getAccessID());
// If emitter is specified, first fire emitter.
if (emit != null) {
emit.emit(access.getOutputDoc());
}
// Call after web service event...
access.setAfterServiceTime(0);
if (access.getExitCode() != Access.EXIT_AUTH_EXECPTION) {
long astart = System.currentTimeMillis();
if (WebserviceListenerFactory.getInstance() != null) {
WebserviceListenerFactory.getInstance().afterWebservice(rpcName, access);
}
access.setAfterServiceTime((int) (System.currentTimeMillis() - astart));
}
// Set access to finished state.
access.setFinished();
// Translate property descriptions.
updatePropertyDescriptions(inMessage, outMessage, access);
access.storeStatistics(h);
// Call Navajoresponse event.
access.setException(myException);
NavajoEventRegistry.getInstance().publishEvent(new NavajoResponseEvent(access));
// Publish exception event if exception occurred.
if (myException != null) {
NavajoEventRegistry.getInstance().publishEvent(new NavajoExceptionEvent(rpcName, access.getAccessID(), rpcUser, myException));
}
} finally {
// Remove access object from set of active webservices first.
accessSet.remove(access);
}
}
generateNavajoRequestEvent(myException != null);
if (origThreadName != null) {
Thread.currentThread().setName(origThreadName);
}
}
Aggregations