use of org.jbpm.services.task.exception.PermissionDeniedException in project jbpm by kiegroup.
the class UserTaskServiceImpl method complete.
@Override
public void complete(String deploymentId, Long taskId, String userId, Map<String, Object> params) {
UserTaskInstanceDesc task = dataService.getTaskById(taskId);
validateTask(deploymentId, taskId, task);
RuntimeManager manager = getRuntimeManager(task);
if (manager == null) {
logger.warn("Cannot find runtime manager for task {}", taskId);
return;
}
if (manager instanceof InternalRuntimeManager) {
params = process(params, ((InternalRuntimeManager) manager).getEnvironment().getClassLoader());
}
RuntimeEngine engine = manager.getRuntimeEngine(ProcessInstanceIdContext.get(task.getProcessInstanceId()));
try {
TaskService taskService = engine.getTaskService();
// perform actual operation
taskService.complete(taskId, userId, params);
} catch (PermissionDeniedException e) {
throw new TaskNotFoundException(e.getMessage());
} finally {
disposeRuntimeEngine(manager, engine);
}
}
use of org.jbpm.services.task.exception.PermissionDeniedException in project jbpm by kiegroup.
the class UserTaskServiceImpl method resume.
@Override
public void resume(String deploymentId, Long taskId, String userId) {
UserTaskInstanceDesc task = dataService.getTaskById(taskId);
validateTask(deploymentId, taskId, task);
RuntimeManager manager = getRuntimeManager(task);
if (manager == null) {
logger.warn("Cannot find runtime manager for task {}", taskId);
return;
}
RuntimeEngine engine = manager.getRuntimeEngine(ProcessInstanceIdContext.get(task.getProcessInstanceId()));
try {
TaskService taskService = engine.getTaskService();
// perform actual operation
taskService.resume(taskId, userId);
} catch (PermissionDeniedException e) {
throw new TaskNotFoundException(e.getMessage());
} finally {
disposeRuntimeEngine(manager, engine);
}
}
use of org.jbpm.services.task.exception.PermissionDeniedException in project jbpm by kiegroup.
the class UserTaskServiceImpl method start.
@Override
public void start(String deploymentId, Long taskId, String userId) {
UserTaskInstanceDesc task = dataService.getTaskById(taskId);
validateTask(deploymentId, taskId, task);
RuntimeManager manager = getRuntimeManager(task);
if (manager == null) {
logger.warn("Cannot find runtime manager for task {}", taskId);
return;
}
RuntimeEngine engine = manager.getRuntimeEngine(ProcessInstanceIdContext.get(task.getProcessInstanceId()));
try {
TaskService taskService = engine.getTaskService();
// perform actual operation
taskService.start(taskId, userId);
} catch (PermissionDeniedException e) {
throw new TaskNotFoundException(e.getMessage());
} finally {
disposeRuntimeEngine(manager, engine);
}
}
use of org.jbpm.services.task.exception.PermissionDeniedException in project jbpm by kiegroup.
the class UserTaskServiceImpl method forward.
@Override
public void forward(String deploymentId, Long taskId, String userId, String targetEntityId) {
UserTaskInstanceDesc task = dataService.getTaskById(taskId);
validateTask(deploymentId, taskId, task);
RuntimeManager manager = getRuntimeManager(task);
if (manager == null) {
logger.warn("Cannot find runtime manager for task {}", taskId);
return;
}
RuntimeEngine engine = manager.getRuntimeEngine(ProcessInstanceIdContext.get(task.getProcessInstanceId()));
try {
TaskService taskService = engine.getTaskService();
// perform actual operation
taskService.forward(taskId, userId, targetEntityId);
} catch (PermissionDeniedException e) {
throw new TaskNotFoundException(e.getMessage());
} finally {
disposeRuntimeEngine(manager, engine);
}
}
use of org.jbpm.services.task.exception.PermissionDeniedException in project jbpm by kiegroup.
the class AddPeopleAssignmentsCommand method execute.
@Override
public Void execute(Context cntxt) {
TaskContext context = (TaskContext) cntxt;
TaskEventSupport taskEventSupport = context.getTaskEventSupport();
Task task = context.getTaskQueryService().getTaskInstanceById(taskId);
// security check
if (!isBusinessAdmin(userId, task.getPeopleAssignments().getBusinessAdministrators(), context)) {
throw new PermissionDeniedException("User " + userId + " is not business admin of task " + taskId);
}
List<OrganizationalEntity> entityList = Arrays.asList(entities);
AssignmentType assignmentType = null;
switch(type) {
case POT_OWNER:
if (removeExisting) {
task.getPeopleAssignments().getPotentialOwners().clear();
}
task.getPeopleAssignments().getPotentialOwners().addAll(entityList);
assignmentType = AssignmentType.POT_OWNER;
break;
case EXCL_OWNER:
if (removeExisting) {
((InternalPeopleAssignments) task.getPeopleAssignments()).getExcludedOwners().clear();
}
((InternalPeopleAssignments) task.getPeopleAssignments()).getExcludedOwners().addAll(entityList);
assignmentType = AssignmentType.EXCL_OWNER;
break;
case ADMIN:
if (removeExisting) {
task.getPeopleAssignments().getBusinessAdministrators().clear();
}
task.getPeopleAssignments().getBusinessAdministrators().addAll(entityList);
assignmentType = AssignmentType.ADMIN;
break;
default:
break;
}
taskEventSupport.fireBeforeTaskAssignmentsAddedEvent(task, context, assignmentType, entityList);
doCallbackOperationForPeopleAssignments(((InternalPeopleAssignments) task.getPeopleAssignments()), context);
taskEventSupport.fireAfterTaskAssignmentsAddedEvent(task, context, assignmentType, entityList);
return null;
}
Aggregations