Search in sources :

Example 1 with ActivitiCdiException

use of org.activiti.cdi.ActivitiCdiException in project Activiti by Activiti.

the class CompleteTaskInterceptor method invoke.

@AroundInvoke
public Object invoke(InvocationContext ctx) throws Exception {
    try {
        Object result = ctx.proceed();
        CompleteTask completeTaskAnnotation = ctx.getMethod().getAnnotation(CompleteTask.class);
        boolean endConversation = completeTaskAnnotation.endConversation();
        businessProcess.completeTask(endConversation);
        return result;
    } catch (InvocationTargetException e) {
        throw new ActivitiCdiException("Error while completing task: " + e.getCause().getMessage(), e.getCause());
    }
}
Also used : CompleteTask(org.activiti.cdi.annotation.CompleteTask) ActivitiCdiException(org.activiti.cdi.ActivitiCdiException) InvocationTargetException(java.lang.reflect.InvocationTargetException) AroundInvoke(javax.interceptor.AroundInvoke)

Example 2 with ActivitiCdiException

use of org.activiti.cdi.ActivitiCdiException in project Activiti by Activiti.

the class DefaultContextAssociationManager method setExecution.

@Override
public void setExecution(Execution execution) {
    if (execution == null) {
        throw new ActivitiCdiException("Cannot associate with execution: null");
    }
    if (Context.getCommandContext() != null) {
        throw new ActivitiCdiException("Cannot work with scoped associations inside command context.");
    }
    ScopedAssociation scopedAssociation = getScopedAssociation();
    Execution associatedExecution = scopedAssociation.getExecution();
    if (associatedExecution != null && !associatedExecution.getId().equals(execution.getId())) {
        throw new ActivitiCdiException("Cannot associate " + execution + ", already associated with " + associatedExecution + ". Disassociate first!");
    }
    if (log.isTraceEnabled()) {
        log.trace("Associating {} (@{})", execution, scopedAssociation.getClass().getAnnotations()[0].annotationType().getSimpleName());
    }
    scopedAssociation.setExecution(execution);
}
Also used : Execution(org.activiti.engine.runtime.Execution) ActivitiCdiException(org.activiti.cdi.ActivitiCdiException)

Aggregations

ActivitiCdiException (org.activiti.cdi.ActivitiCdiException)2 InvocationTargetException (java.lang.reflect.InvocationTargetException)1 AroundInvoke (javax.interceptor.AroundInvoke)1 CompleteTask (org.activiti.cdi.annotation.CompleteTask)1 Execution (org.activiti.engine.runtime.Execution)1