Search in sources :

Example 1 with EventHandler

use of org.apache.ofbiz.webapp.event.EventHandler in project ofbiz-framework by apache.

the class RequestHandler method runEvent.

/**
 * Find the event handler and invoke an event.
 */
public String runEvent(HttpServletRequest request, HttpServletResponse response, ConfigXMLReader.Event event, ConfigXMLReader.RequestMap requestMap, String trigger) throws EventHandlerException {
    EventHandler eventHandler = eventFactory.getEventHandler(event.type);
    String eventReturn = eventHandler.invoke(event, requestMap, request, response);
    if (Debug.verboseOn() || (Debug.infoOn() && "request".equals(trigger)))
        Debug.logInfo("Ran Event [" + event.type + ":" + event.path + "#" + event.invoke + "] from [" + trigger + "], result is [" + eventReturn + "]", module);
    return eventReturn;
}
Also used : EventHandler(org.apache.ofbiz.webapp.event.EventHandler)

Example 2 with EventHandler

use of org.apache.ofbiz.webapp.event.EventHandler in project ofbiz-framework by apache.

the class TaskEvents method delegateAndAcceptAssignment.

/**
 * Delegate and accept assignment event
 */
public static String delegateAndAcceptAssignment(HttpServletRequest request, HttpServletResponse response) {
    ServletContext ctx = (ServletContext) request.getAttribute("servletContext");
    RequestHandler rh = (RequestHandler) ctx.getAttribute("_REQUEST_HANDLER_");
    Locale locale = UtilHttp.getLocale(request);
    if (addToOrderRole(request)) {
        try {
            EventHandler eh = rh.getEventFactory().getEventHandler("service");
            eh.invoke(new Event("service", "", "wfAcceptRoleAssignment", true), null, request, response);
        } catch (EventHandlerException e) {
            Debug.logError(e, "Invocation error", module);
            request.setAttribute("_ERROR_MESSAGE_", UtilProperties.getMessage(resource_error, "OrderFailedToInvokeTheWfDelegateAndAcceptAssignmentService", locale));
            return "error";
        }
        return "success";
    }
    return "error";
}
Also used : Locale(java.util.Locale) RequestHandler(org.apache.ofbiz.webapp.control.RequestHandler) EventHandlerException(org.apache.ofbiz.webapp.event.EventHandlerException) ServletContext(javax.servlet.ServletContext) EventHandler(org.apache.ofbiz.webapp.event.EventHandler) Event(org.apache.ofbiz.webapp.control.ConfigXMLReader.Event)

Example 3 with EventHandler

use of org.apache.ofbiz.webapp.event.EventHandler in project ofbiz-framework by apache.

the class TaskEvents method acceptRoleAssignment.

/**
 * Accept role assignment event
 */
public static String acceptRoleAssignment(HttpServletRequest request, HttpServletResponse response) {
    ServletContext ctx = (ServletContext) request.getAttribute("servletContext");
    RequestHandler rh = (RequestHandler) ctx.getAttribute("_REQUEST_HANDLER_");
    Locale locale = UtilHttp.getLocale(request);
    if (addToOrderRole(request)) {
        try {
            EventHandler eh = rh.getEventFactory().getEventHandler("service");
            eh.invoke(new Event("service", "", "wfAcceptRoleAssignment", true), null, request, response);
        } catch (EventHandlerException e) {
            Debug.logError(e, "Invocation error", module);
            request.setAttribute("_ERROR_MESSAGE_", UtilProperties.getMessage(resource_error, "OrderFailedToInvokeTheWfAcceptRoleAssignmentService", locale));
            return "error";
        }
        return "success";
    }
    return "error";
}
Also used : Locale(java.util.Locale) RequestHandler(org.apache.ofbiz.webapp.control.RequestHandler) EventHandlerException(org.apache.ofbiz.webapp.event.EventHandlerException) ServletContext(javax.servlet.ServletContext) EventHandler(org.apache.ofbiz.webapp.event.EventHandler) Event(org.apache.ofbiz.webapp.control.ConfigXMLReader.Event)

Aggregations

EventHandler (org.apache.ofbiz.webapp.event.EventHandler)3 Locale (java.util.Locale)2 ServletContext (javax.servlet.ServletContext)2 Event (org.apache.ofbiz.webapp.control.ConfigXMLReader.Event)2 RequestHandler (org.apache.ofbiz.webapp.control.RequestHandler)2 EventHandlerException (org.apache.ofbiz.webapp.event.EventHandlerException)2