ExecutionEntity execution = commandContext
.getExecutionEntityManager()
.findExecutionById(processInstanceId);
if (execution==null) {
throw new ActivitiObjectNotFoundException("process instance " + processInstanceId + " doesn't exist", ProcessInstance.class);
}
if(!execution.isProcessInstanceType()) {
throw new ActivitiObjectNotFoundException("process instance " + processInstanceId +
" doesn't exist, the given ID references an execution, though", ProcessInstance.class);
}
if (execution.isSuspended()) {
throw new ActivitiException("process instance " + processInstanceId + " is suspended, cannot set name");