use of pro.taskana.exceptions.NotAuthorizedException in project taskana by Taskana.
the class TaskQueryImpl method single.
@Override
public TaskSummary single() {
LOGGER.debug("entry to single(), this = {}", this);
TaskSummary result = null;
try {
taskanaEngine.openConnection();
checkOpenPermissionForSpecifiedWorkbaskets();
TaskSummaryImpl taskSummaryImpl = taskanaEngine.getSqlSession().selectOne(LINK_TO_MAPPER, this);
if (taskSummaryImpl == null) {
return null;
}
List<TaskSummaryImpl> tasks = new ArrayList<>();
tasks.add(taskSummaryImpl);
List<TaskSummary> augmentedList = taskService.augmentTaskSummariesByContainedSummaries(tasks);
result = augmentedList.get(0);
return result;
} catch (NotAuthorizedException e) {
throw new NotAuthorizedToQueryWorkbasketException(e.getMessage());
} finally {
taskanaEngine.returnConnection();
LOGGER.debug("exit from single(). Returning result {} ", result);
}
}
use of pro.taskana.exceptions.NotAuthorizedException in project taskana by Taskana.
the class TaskQueryImpl method list.
@Override
public List<TaskSummary> list() {
List<TaskSummary> result = new ArrayList<>();
try {
LOGGER.debug("entry to list(), this = {}", this);
taskanaEngine.openConnection();
checkOpenPermissionForSpecifiedWorkbaskets();
List<TaskSummaryImpl> tasks = new ArrayList<>();
tasks = taskanaEngine.getSqlSession().selectList(LINK_TO_MAPPER, this);
if (LOGGER.isDebugEnabled()) {
LOGGER.debug("mapper returned {} resulting Objects: {} ", tasks.size(), LoggerUtils.listToString(tasks));
}
result = taskService.augmentTaskSummariesByContainedSummaries(tasks);
return result;
} catch (NotAuthorizedException e) {
throw new NotAuthorizedToQueryWorkbasketException(e.getMessage());
} finally {
taskanaEngine.returnConnection();
if (LOGGER.isDebugEnabled()) {
int numberOfResultObjects = result == null ? 0 : result.size();
LOGGER.debug("exit from list(). Returning {} resulting Objects: {} ", numberOfResultObjects, LoggerUtils.listToString(result));
}
}
}
use of pro.taskana.exceptions.NotAuthorizedException in project taskana by Taskana.
the class DeleteWorkbasketAccTest method testCreateAndDeleteWorkbasket.
@WithAccessId(userName = "user_1_2", groupNames = { "businessadmin" })
@Test
public void testCreateAndDeleteWorkbasket() throws SQLException, NotAuthorizedException, InvalidArgumentException, WorkbasketNotFoundException, InvalidWorkbasketException, WorkbasketAlreadyExistException, DomainNotFoundException {
WorkbasketService workbasketService = taskanaEngine.getWorkbasketService();
int before = workbasketService.createWorkbasketQuery().domainIn("DOMAIN_A").list().size();
Workbasket workbasket = workbasketService.newWorkbasket("NT1234", "DOMAIN_A");
workbasket.setName("TheUltimate");
workbasket.setType(WorkbasketType.GROUP);
workbasket.setOrgLevel1("company");
workbasket = workbasketService.createWorkbasket(workbasket);
try {
workbasketService.deleteWorkbasket(workbasket.getId());
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
use of pro.taskana.exceptions.NotAuthorizedException in project taskana by Taskana.
the class DistributionTargetsAccTest method testDistributionTargetCallsFailWithNotAuthorizedException.
@WithAccessId(userName = "user_3_1", groupNames = { "group_1" })
@Test
public void testDistributionTargetCallsFailWithNotAuthorizedException() throws NotAuthorizedException, WorkbasketNotFoundException {
WorkbasketService workbasketService = taskanaEngine.getWorkbasketService();
String existingWb = "WBI:100000000000000000000000000000000001";
try {
workbasketService.getDistributionTargets(existingWb);
assertTrue("This line of code should not be reached", false);
} catch (NotAuthorizedException ex) {
// nothing to do
}
try {
List<String> distributionTargets = new ArrayList<>(Arrays.asList("WBI:100000000000000000000000000000000002"));
workbasketService.setDistributionTargets(existingWb, distributionTargets);
assertTrue("This line of code should not be reached", false);
} catch (NotAuthorizedException ex) {
// nothing to do
}
try {
workbasketService.addDistributionTarget(existingWb, "WBI:100000000000000000000000000000000002");
assertTrue("This line of code should not be reached", false);
} catch (NotAuthorizedException ex) {
// nothing to do
}
try {
workbasketService.removeDistributionTarget(existingWb, "WBI:100000000000000000000000000000000002");
assertTrue("This line of code should not be reached", false);
} catch (NotAuthorizedException ex) {
// nothing to do
}
}
use of pro.taskana.exceptions.NotAuthorizedException in project taskana by Taskana.
the class DistributionTargetsAccTest method testSetDistributionTargets.
@WithAccessId(userName = "user_2_2", groupNames = { "group_1", "group_2", "businessadmin" })
@Test
public void testSetDistributionTargets() throws NotAuthorizedException, WorkbasketNotFoundException, InvalidWorkbasketException, SQLException {
WorkbasketService workbasketService = taskanaEngine.getWorkbasketService();
Workbasket sourceWorkbasket = workbasketService.getWorkbasket("GPK_KSC_1", "DOMAIN_A");
List<WorkbasketSummary> initialDistributionTargets = workbasketService.getDistributionTargets(sourceWorkbasket.getId());
assertEquals(4, initialDistributionTargets.size());
List<WorkbasketSummary> newDistributionTargets = workbasketService.createWorkbasketQuery().keyIn("USER_1_1", "GPK_B_KSC_1").list();
assertEquals(2, newDistributionTargets.size());
List<String> newDistributionTargetIds = newDistributionTargets.stream().map(t -> t.getId()).collect(Collectors.toList());
workbasketService.setDistributionTargets(sourceWorkbasket.getId(), newDistributionTargetIds);
List<WorkbasketSummary> changedTargets = workbasketService.getDistributionTargets(sourceWorkbasket.getId());
assertEquals(2, changedTargets.size());
// reset DB to original state
resetDb(false);
}
Aggregations