use of org.wso2.carbon.humantask.core.engine.runtime.api.HumanTaskIllegalAccessException in project carbon-business-process by wso2.
the class TaskOperationsImpl method remove.
/**
* Applies to notifications only.
* Used by notification recipients to remove the notification permanently from their task list client.
* @param taskId : Notification identifier
* @throws IllegalOperationFault
* @throws IllegalArgumentFault
* @throws IllegalAccessFault
*/
public void remove(URI taskId) throws IllegalOperationFault, IllegalArgumentFault, IllegalAccessFault {
try {
final Long notificationId = validateTaskId(taskId);
HumanTaskServiceComponent.getHumanTaskServer().getTaskEngine().getScheduler().execTransaction(new Callable<Object>() {
public Object call() throws Exception {
Remove removeCommand = new Remove(getCaller(), notificationId);
removeCommand.execute();
return null;
}
});
} catch (HumanTaskIllegalOperationException ex) {
log.error(ex);
throw new IllegalOperationFault(ex);
} catch (HumanTaskIllegalAccessException ex) {
log.error(ex);
throw new IllegalAccessFault(ex);
} catch (Exception ex) {
log.error(ex);
throw new IllegalArgumentFault(ex);
}
}
use of org.wso2.carbon.humantask.core.engine.runtime.api.HumanTaskIllegalAccessException in project carbon-business-process by wso2.
the class TaskOperationsImpl method authoriseToLoadTask.
/**
* Throws an exception if the current user is not allowed to perform loadTask() operation
* @param taskId
*/
private void authoriseToLoadTask(TaskDAO task) throws Exception {
List<GenericHumanRoleDAO.GenericHumanRoleType> allowedRoles = new ArrayList<GenericHumanRoleDAO.GenericHumanRoleType>();
allowedRoles.add(GenericHumanRoleDAO.GenericHumanRoleType.ACTUAL_OWNER);
allowedRoles.add(GenericHumanRoleDAO.GenericHumanRoleType.BUSINESS_ADMINISTRATORS);
allowedRoles.add(GenericHumanRoleDAO.GenericHumanRoleType.NOTIFICATION_RECIPIENTS);
allowedRoles.add(GenericHumanRoleDAO.GenericHumanRoleType.POTENTIAL_OWNERS);
allowedRoles.add(GenericHumanRoleDAO.GenericHumanRoleType.STAKEHOLDERS);
allowedRoles.add(GenericHumanRoleDAO.GenericHumanRoleType.TASK_INITIATOR);
HumanTaskEngine taskEngine = HumanTaskServiceComponent.getHumanTaskServer().getTaskEngine();
PeopleQueryEvaluator pqe = taskEngine.getPeopleQueryEvaluator();
OrganizationalEntityDAO invoker = taskEngine.getScheduler().execTransaction(new Callable<OrganizationalEntityDAO>() {
@Override
public OrganizationalEntityDAO call() throws Exception {
return HumanTaskServiceComponent.getHumanTaskServer().getDaoConnectionFactory().getConnection().createNewOrgEntityObject(getCaller(), OrganizationalEntityDAO.OrganizationalEntityType.USER);
}
});
if (!OperationAuthorizationUtil.authoriseUser(task, invoker, allowedRoles, pqe)) {
String errorMsg = String.format("The user[%s] cannot perform loadTask()" + " operation as either he is in EXCLUDED_OWNERS role or he is not in task roles [%s]", invoker.getName(), allowedRoles);
log.error(errorMsg);
throw new HumanTaskIllegalAccessException("Access Denied. You are not authorized to perform this task");
}
}
use of org.wso2.carbon.humantask.core.engine.runtime.api.HumanTaskIllegalAccessException in project carbon-business-process by wso2.
the class HTRenderingApiImpl method getTaskDAO.
/**
* Function to retrieve task DAO
*
* @param taskIdURI task ID
* @return task DAO
* @throws Exception
* @throws IllegalArgumentException
*/
private TaskDAO getTaskDAO(URI taskIdURI) throws IllegalArgumentException, HumanTaskIllegalAccessException, Exception {
final Long taskId = validateTaskId(taskIdURI);
TaskDAO task = HumanTaskServiceComponent.getHumanTaskServer().getTaskEngine().getScheduler().execTransaction(new Callable<TaskDAO>() {
public TaskDAO call() throws Exception {
HumanTaskEngine engine = HumanTaskServiceComponent.getHumanTaskServer().getTaskEngine();
HumanTaskDAOConnection daoConn = engine.getDaoConnectionFactory().getConnection();
TaskDAO task = daoConn.getTask(taskId);
validateTaskTenant(task);
return task;
}
});
return task;
}
use of org.wso2.carbon.humantask.core.engine.runtime.api.HumanTaskIllegalAccessException in project carbon-business-process by wso2.
the class Delegate method checkPreConditions.
/**
* Checks the Pre-conditions before executing the task operation.
*/
@Override
protected void checkPreConditions() {
checkForValidTask();
OrganizationalEntityDAO caller = getOperationInvoker();
TaskDAO task = getTask();
// if the delegatee is not an existing user
if (!getEngine().getPeopleQueryEvaluator().isExistingUser(delegatee.getName())) {
String errMsg = String.format("The user[%s] cannot delegate task[id:%d] to the given" + " delegatee[name:%s] as he/she does not exist in the user store", caller.getName(), task.getId(), delegatee.getName());
log.error(errMsg);
throw new HumanTaskIllegalArgumentException(errMsg);
}
if (isExcludedOwner(delegatee.getName())) {
String errMsg = String.format("The user[%s] cannot delegate task[id:%d] to the given" + " delegatee[name:%s] as he/she is an exclude owner for this task.", caller.getName(), task.getId(), delegatee.getName());
log.error(errMsg);
throw new HumanTaskIllegalArgumentException(errMsg);
}
// if the task is in reserved or in-progress we have to release it first.
if (TaskStatus.RESERVED.equals(task.getStatus()) || TaskStatus.IN_PROGRESS.equals(task.getStatus())) {
// task releasing can be done only by bus admins and the actual owner.
List<GenericHumanRoleDAO.GenericHumanRoleType> allowedRoles = new ArrayList<GenericHumanRoleDAO.GenericHumanRoleType>();
allowedRoles.add(GenericHumanRoleDAO.GenericHumanRoleType.BUSINESS_ADMINISTRATORS);
allowedRoles.add(GenericHumanRoleDAO.GenericHumanRoleType.ACTUAL_OWNER);
try {
authoriseRoles(allowedRoles);
} catch (Exception ex) {
String err = String.format("The task[id:%d] can be only delegated after it's released. " + "But for the task to be released you need to be a business " + "administrator or the actual owner of the task. " + "Given user[%s] is not in those roles!", task.getId(), caller.getName());
log.error(err);
throw new HumanTaskIllegalAccessException(err, ex);
}
task.release();
}
// Add delegatee as a potential owner.
GenericHumanRoleDAO potentialOwnersRole = task.getGenericHumanRole(GenericHumanRoleDAO.GenericHumanRoleType.POTENTIAL_OWNERS);
if (getEngine().getPeopleQueryEvaluator().isOrgEntityInRole(delegatee, potentialOwnersRole)) {
task.persistToPotentialOwners(delegatee);
}
}
Aggregations