use of org.kie.api.task.model.TaskData in project jbpm by kiegroup.
the class MVELLifeCycleManager method evalCommand.
void evalCommand(final Operation operation, final List<OperationCommand> commands, final Task task, final User user, final OrganizationalEntity targetEntity, List<String> groupIds, OrganizationalEntity... entities) throws PermissionDeniedException {
boolean statusMatched = false;
final TaskData taskData = task.getTaskData();
for (OperationCommand command : commands) {
// first find out if we have a matching status
if (command.getStatus() != null) {
for (Status status : command.getStatus()) {
if (task.getTaskData().getStatus() == status) {
statusMatched = true;
// next find out if the user can execute this doOperation
if (!isAllowed(command, task, user, groupIds)) {
String errorMessage = "User '" + user + "' does not have permissions to execute operation '" + operation + "' on task id " + task.getId();
throw new PermissionDeniedException(errorMessage);
}
commands(command, task, user, targetEntity, entities);
} else {
logger.debug("No match on status for task {} :status {} != {}", task.getId(), task.getTaskData().getStatus(), status);
}
}
}
if (command.getPreviousStatus() != null) {
for (Status status : command.getPreviousStatus()) {
if (taskData.getPreviousStatus() == status) {
statusMatched = true;
// next find out if the user can execute this doOperation
if (!isAllowed(command, task, user, groupIds)) {
String errorMessage = "User '" + user + "' does not have permissions to execute operation '" + operation + "' on task id " + task.getId();
throw new PermissionDeniedException(errorMessage);
}
commands(command, task, user, targetEntity, entities);
} else {
logger.debug("No match on previous status for task {} :status {} != {}", task.getId(), task.getTaskData().getStatus(), status);
}
}
}
if (!command.isGroupTargetEntityAllowed() && targetEntity instanceof Group) {
String errorMessage = "User '" + user + "' was unable to execute operation '" + operation + "' on task id " + task.getId() + " due to 'target entity cannot be group'";
throw new PermissionDeniedException(errorMessage);
}
}
if (!statusMatched) {
String errorMessage = "User '" + user + "' was unable to execute operation '" + operation + "' on task id " + task.getId() + " due to a no 'current status' match";
throw new PermissionDeniedException(errorMessage);
}
}
Aggregations