Search in sources :

Example 1 with NavajoResponseEvent

use of com.dexels.navajo.events.types.NavajoResponseEvent 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);
    }
}
Also used : NavajoExceptionEvent(com.dexels.navajo.events.types.NavajoExceptionEvent) Header(com.dexels.navajo.document.Header) Navajo(com.dexels.navajo.document.Navajo) NavajoResponseEvent(com.dexels.navajo.events.types.NavajoResponseEvent)

Example 2 with NavajoResponseEvent

use of com.dexels.navajo.events.types.NavajoResponseEvent in project navajo by Dexels.

the class ArticleTmlRunnable method run.

@Override
public void run() {
    try {
        runInternal();
    } catch (Throwable t1) {
        fail(t1);
    } finally {
        continuation.complete();
        runtime.getAccess().setFinished();
        NavajoEventRegistry.getInstance().publishEvent(new NavajoResponseEvent(runtime.getAccess()));
        if (getRequestQueue() != null) {
            // Check whether there is a request queue available.
            getRequestQueue().finished();
        }
    }
}
Also used : NavajoResponseEvent(com.dexels.navajo.events.types.NavajoResponseEvent)

Aggregations

NavajoResponseEvent (com.dexels.navajo.events.types.NavajoResponseEvent)2 Header (com.dexels.navajo.document.Header)1 Navajo (com.dexels.navajo.document.Navajo)1 NavajoExceptionEvent (com.dexels.navajo.events.types.NavajoExceptionEvent)1