use of org.activiti.engine.ActivitiIllegalArgumentException in project Activiti by Activiti.
the class JobEntityManager method schedule.
public void schedule(TimerEntity timer) {
Date duedate = timer.getDuedate();
if (duedate == null) {
throw new ActivitiIllegalArgumentException("duedate is null");
}
timer.insert();
ProcessEngineConfiguration engineConfiguration = Context.getProcessEngineConfiguration();
if (engineConfiguration.isAsyncExecutorEnabled() == false && timer.getDuedate().getTime() <= (engineConfiguration.getClock().getCurrentTime().getTime())) {
hintJobExecutor(timer);
}
}
use of org.activiti.engine.ActivitiIllegalArgumentException in project Activiti by Activiti.
the class RequestUtil method getDate.
public static Date getDate(Map<String, String> requestParams, String name) {
Date value = null;
if (requestParams.get(name) != null) {
String input = requestParams.get(name).trim();
//this is zero time so we need to add that TZ indicator for
if (input.endsWith("Z")) {
input = input.substring(0, input.length() - 1) + "GMT-00:00";
} else {
int inset = 6;
String s0 = input.substring(0, input.length() - inset);
String s1 = input.substring(input.length() - inset, input.length());
input = s0 + "GMT" + s1;
}
try {
value = longDateFormat.parse(input);
} catch (Exception e) {
throw new ActivitiIllegalArgumentException("Failed to parse date " + input);
}
}
return value;
}
use of org.activiti.engine.ActivitiIllegalArgumentException in project Activiti by Activiti.
the class DelegateExpressionExecutionListener method notify.
public void notify(DelegateExecution execution) throws Exception {
// Note: we can't cache the result of the expression, because the
// execution can change: eg. delegateExpression='${mySpringBeanFactory.randomSpringBean()}'
Object delegate = expression.getValue(execution);
ClassDelegate.applyFieldDeclaration(fieldDeclarations, delegate);
if (delegate instanceof ExecutionListener) {
Context.getProcessEngineConfiguration().getDelegateInterceptor().handleInvocation(new ExecutionListenerInvocation((ExecutionListener) delegate, execution));
} else if (delegate instanceof JavaDelegate) {
Context.getProcessEngineConfiguration().getDelegateInterceptor().handleInvocation(new JavaDelegateInvocation((JavaDelegate) delegate, execution));
} else {
throw new ActivitiIllegalArgumentException("Delegate expression " + expression + " did not resolve to an implementation of " + ExecutionListener.class + " nor " + JavaDelegate.class);
}
}
use of org.activiti.engine.ActivitiIllegalArgumentException in project Activiti by Activiti.
the class ExecuteJobsCmd method execute.
public Object execute(CommandContext commandContext) {
if (jobId == null && job == null) {
throw new ActivitiIllegalArgumentException("jobId and job is null");
}
if (job == null) {
job = commandContext.getJobEntityManager().findJobById(jobId);
}
if (job == null) {
throw new JobNotFoundException(jobId);
}
if (log.isDebugEnabled()) {
log.debug("Executing job {}", job.getId());
}
JobExecutorContext jobExecutorContext = Context.getJobExecutorContext();
if (jobExecutorContext != null) {
// if null, then we are not called by the job executor
jobExecutorContext.setCurrentJob(job);
}
FailedJobListener failedJobListener = null;
try {
// When transaction is rolled back, decrement retries
failedJobListener = new FailedJobListener(commandContext.getProcessEngineConfiguration().getCommandExecutor(), jobId);
commandContext.getTransactionContext().addTransactionListener(TransactionState.ROLLED_BACK, failedJobListener);
job.execute(commandContext);
if (commandContext.getEventDispatcher().isEnabled()) {
commandContext.getEventDispatcher().dispatchEvent(ActivitiEventBuilder.createEntityEvent(ActivitiEventType.JOB_EXECUTION_SUCCESS, job));
}
} catch (Throwable exception) {
failedJobListener.setException(exception);
// exception to be swallowed
if (commandContext.getEventDispatcher().isEnabled()) {
try {
commandContext.getEventDispatcher().dispatchEvent(ActivitiEventBuilder.createEntityExceptionEvent(ActivitiEventType.JOB_EXECUTION_FAILURE, job, exception));
} catch (Throwable ignore) {
log.warn("Exception occured while dispatching job failure event, ignoring.", ignore);
}
}
// Finally, Throw the exception to indicate the ExecuteJobCmd failed
throw new ActivitiException("Job " + jobId + " failed", exception);
} finally {
if (jobExecutorContext != null) {
jobExecutorContext.setCurrentJob(null);
}
}
return null;
}
use of org.activiti.engine.ActivitiIllegalArgumentException in project Activiti by Activiti.
the class DeploymentManager method getBpmnModelById.
public BpmnModel getBpmnModelById(String processDefinitionId) {
if (processDefinitionId == null) {
throw new ActivitiIllegalArgumentException("Invalid process definition id : null");
}
// first try the cache
BpmnModel bpmnModel = bpmnModelCache.get(processDefinitionId);
if (bpmnModel == null) {
ProcessDefinitionEntity processDefinition = findDeployedProcessDefinitionById(processDefinitionId);
if (processDefinition == null) {
throw new ActivitiObjectNotFoundException("no deployed process definition found with id '" + processDefinitionId + "'", ProcessDefinition.class);
}
// Fetch the resource
String resourceName = processDefinition.getResourceName();
ResourceEntity resource = Context.getCommandContext().getResourceEntityManager().findResourceByDeploymentIdAndResourceName(processDefinition.getDeploymentId(), resourceName);
if (resource == null) {
if (Context.getCommandContext().getDeploymentEntityManager().findDeploymentById(processDefinition.getDeploymentId()) == null) {
throw new ActivitiObjectNotFoundException("deployment for process definition does not exist: " + processDefinition.getDeploymentId(), Deployment.class);
} else {
throw new ActivitiObjectNotFoundException("no resource found with name '" + resourceName + "' in deployment '" + processDefinition.getDeploymentId() + "'", InputStream.class);
}
}
// Convert the bpmn 2.0 xml to a bpmn model
BpmnXMLConverter bpmnXMLConverter = new BpmnXMLConverter();
bpmnModel = bpmnXMLConverter.convertToBpmnModel(new BytesStreamSource(resource.getBytes()), false, false);
bpmnModelCache.add(processDefinition.getId(), bpmnModel);
}
return bpmnModel;
}
Aggregations