TSK-242 Implement role based access control to the lib

This commit is contained in:
BerndBreier 2018-02-23 16:53:13 +01:00 committed by Holger Hagen
parent a00289c0ab
commit 0bdbf4700b
42 changed files with 684 additions and 360 deletions

View File

@ -47,9 +47,11 @@ public interface ClassificationService {
* if there are Task existing, which refer to this classification. * if there are Task existing, which refer to this classification.
* @throws ClassificationNotFoundException * @throws ClassificationNotFoundException
* if for an domain no classification specification is found. * if for an domain no classification specification is found.
* @throws NotAuthorizedException
* if the current user is not member of role BUSINESS_ADMIN or ADMIN
*/ */
void deleteClassification(String classificationKey, String domain) void deleteClassification(String classificationKey, String domain)
throws ClassificationInUseException, ClassificationNotFoundException; throws ClassificationInUseException, ClassificationNotFoundException, NotAuthorizedException;
/** /**
* Persists a new classification after adding default values. <br > * Persists a new classification after adding default values. <br >
@ -60,9 +62,11 @@ public interface ClassificationService {
* @return classification which is persisted with unique ID. * @return classification which is persisted with unique ID.
* @throws ClassificationAlreadyExistException * @throws ClassificationAlreadyExistException
* when the classification does already exists at the given domain. * when the classification does already exists at the given domain.
* @throws NotAuthorizedException
* if the current user is not member of role BUSINESS_ADMIN or ADMIN
*/ */
Classification createClassification(Classification classification) Classification createClassification(Classification classification)
throws ClassificationAlreadyExistException; throws ClassificationAlreadyExistException, NotAuthorizedException;
/** /**
* Update a Classification. * Update a Classification.

View File

@ -324,8 +324,10 @@ public interface TaskService {
* If the given Id does not refer to an existing task. * If the given Id does not refer to an existing task.
* @throws InvalidStateException * @throws InvalidStateException
* If the state of the referenced task is not Completed. * If the state of the referenced task is not Completed.
* @throws NotAuthorizedException
* if the current user is not member of role ADMIN
*/ */
void deleteTask(String taskId) throws TaskNotFoundException, InvalidStateException; void deleteTask(String taskId) throws TaskNotFoundException, InvalidStateException, NotAuthorizedException;
/** /**
* Deletes the task with the given Id. * Deletes the task with the given Id.
@ -338,8 +340,11 @@ public interface TaskService {
* If the given Id does not refer to an existing task. * If the given Id does not refer to an existing task.
* @throws InvalidStateException * @throws InvalidStateException
* If the state of the referenced task is not Completed and forceDelet is false. * If the state of the referenced task is not Completed and forceDelet is false.
* @throws NotAuthorizedException
* if the current user is not member of role ADMIN
*/ */
void deleteTask(String taskId, boolean forceDelete) throws TaskNotFoundException, InvalidStateException; void deleteTask(String taskId, boolean forceDelete)
throws TaskNotFoundException, InvalidStateException, NotAuthorizedException;
/** /**
* Deletes a list of tasks. * Deletes a list of tasks.

View File

@ -1,6 +1,7 @@
package pro.taskana; package pro.taskana;
import pro.taskana.exceptions.InvalidArgumentException; import pro.taskana.exceptions.InvalidArgumentException;
import pro.taskana.exceptions.NotAuthorizedException;
import pro.taskana.impl.WorkbasketAuthorization; import pro.taskana.impl.WorkbasketAuthorization;
import pro.taskana.impl.WorkbasketType; import pro.taskana.impl.WorkbasketType;
@ -148,9 +149,11 @@ public interface WorkbasketQuery extends BaseQuery<WorkbasketSummary> {
* @return the current query object. * @return the current query object.
* @throws InvalidArgumentException * @throws InvalidArgumentException
* when permission OR the accessIds are NULL. * when permission OR the accessIds are NULL.
* @throws NotAuthorizedException
* if the current user is not member of role BUSINESS_ADMIN or ADMIN
*/ */
WorkbasketQuery accessIdsHavePermission(WorkbasketAuthorization permission, String... accessIds) WorkbasketQuery accessIdsHavePermission(WorkbasketAuthorization permission, String... accessIds)
throws InvalidArgumentException; throws InvalidArgumentException, NotAuthorizedException;
/** /**
* Setting up the permissions for the accessIds of the CurrentUserContext. READ permissions need to be granted,too * Setting up the permissions for the accessIds of the CurrentUserContext. READ permissions need to be granted,too

View File

@ -52,9 +52,11 @@ public interface WorkbasketService {
* @return the created and persisted Workbasket * @return the created and persisted Workbasket
* @throws InvalidWorkbasketException * @throws InvalidWorkbasketException
* If a required property of the Workbasket is not set. * If a required property of the Workbasket is not set.
* @throws NotAuthorizedException
* if the current user is not member of role BUSINESS_ADMIN or ADMIN
*/ */
Workbasket createWorkbasket(Workbasket workbasket) Workbasket createWorkbasket(Workbasket workbasket)
throws InvalidWorkbasketException; throws InvalidWorkbasketException, NotAuthorizedException;
/** /**
* Update a Workbasket. * Update a Workbasket.
@ -91,9 +93,11 @@ public interface WorkbasketService {
* @return the created WorkbasketAccessItem * @return the created WorkbasketAccessItem
* @throws InvalidArgumentException * @throws InvalidArgumentException
* when the preconditions doesn´t match the required ones. * when the preconditions doesn´t match the required ones.
* @throws NotAuthorizedException
* if the current user is not member of role BUSINESS_ADMIN or ADMIN
*/ */
WorkbasketAccessItem createWorkbasketAuthorization(WorkbasketAccessItem workbasketAccessItem) WorkbasketAccessItem createWorkbasketAuthorization(WorkbasketAccessItem workbasketAccessItem)
throws InvalidArgumentException; throws InvalidArgumentException, NotAuthorizedException;
/** /**
* This method updates an Workbasket Authorization. * This method updates an Workbasket Authorization.
@ -103,17 +107,21 @@ public interface WorkbasketService {
* @return the updated entity * @return the updated entity
* @throws InvalidArgumentException * @throws InvalidArgumentException
* if accessid or workbasketkey is changed in the workbasketAccessItem * if accessid or workbasketkey is changed in the workbasketAccessItem
* @throws NotAuthorizedException
* if the current user is not member of role BUSINESS_ADMIN or ADMIN
*/ */
WorkbasketAccessItem updateWorkbasketAuthorization(WorkbasketAccessItem workbasketAccessItem) WorkbasketAccessItem updateWorkbasketAuthorization(WorkbasketAccessItem workbasketAccessItem)
throws InvalidArgumentException; throws InvalidArgumentException, NotAuthorizedException;
/** /**
* Deletes a specific authorization. * Deletes a specific authorization.
* *
* @param id * @param id
* the id of the WorbasketAccessItem to be deleted * the id of the WorbasketAccessItem to be deleted
* @throws NotAuthorizedException
* if the current user is not member of role BUSINESS_ADMIN or ADMIN
*/ */
void deleteWorkbasketAuthorization(String id); void deleteWorkbasketAuthorization(String id) throws NotAuthorizedException;
/** /**
* This method checks the authorization with the saved one for the actual User. * This method checks the authorization with the saved one for the actual User.
@ -187,8 +195,10 @@ public interface WorkbasketService {
* This method provides a query builder for querying the database. * This method provides a query builder for querying the database.
* *
* @return a {@link WorkbasketAccessItemQuery} * @return a {@link WorkbasketAccessItemQuery}
* @throws NotAuthorizedException
* if the current user is not member of role BUSINESS_ADMIN or ADMIN
*/ */
WorkbasketAccessItemQuery createWorkbasketAccessItemQuery(); WorkbasketAccessItemQuery createWorkbasketAccessItemQuery() throws NotAuthorizedException;
/** /**
* Returns a new workbasket which is not persisted. * Returns a new workbasket which is not persisted.

View File

@ -26,7 +26,7 @@ public class ClassificationQueryImpl implements ClassificationQuery {
private static final String LINK_TO_MAPPER = "pro.taskana.mappings.QueryMapper.queryClassification"; private static final String LINK_TO_MAPPER = "pro.taskana.mappings.QueryMapper.queryClassification";
private static final String LINK_TO_COUNTER = "pro.taskana.mappings.QueryMapper.countQueryClassifications"; private static final String LINK_TO_COUNTER = "pro.taskana.mappings.QueryMapper.countQueryClassifications";
private static final Logger LOGGER = LoggerFactory.getLogger(ClassificationQueryImpl.class); private static final Logger LOGGER = LoggerFactory.getLogger(ClassificationQueryImpl.class);
private TaskanaEngineImpl taskanaEngineImpl; private TaskanaEngineImpl taskanaEngine;
private String[] key; private String[] key;
private String[] parentId; private String[] parentId;
private String[] category; private String[] category;
@ -61,7 +61,7 @@ public class ClassificationQueryImpl implements ClassificationQuery {
private List<String> orderBy; private List<String> orderBy;
ClassificationQueryImpl(TaskanaEngine taskanaEngine) { ClassificationQueryImpl(TaskanaEngine taskanaEngine) {
this.taskanaEngineImpl = (TaskanaEngineImpl) taskanaEngine; this.taskanaEngine = (TaskanaEngineImpl) taskanaEngine;
this.orderBy = new ArrayList<>(); this.orderBy = new ArrayList<>();
} }
@ -341,11 +341,11 @@ public class ClassificationQueryImpl implements ClassificationQuery {
LOGGER.debug("entry to list(), this = {}", this); LOGGER.debug("entry to list(), this = {}", this);
List<ClassificationSummary> result = null; List<ClassificationSummary> result = null;
try { try {
taskanaEngineImpl.openConnection(); taskanaEngine.openConnection();
result = taskanaEngineImpl.getSqlSession().selectList(LINK_TO_MAPPER, this); result = taskanaEngine.getSqlSession().selectList(LINK_TO_MAPPER, this);
return result; return result;
} finally { } finally {
taskanaEngineImpl.returnConnection(); taskanaEngine.returnConnection();
if (LOGGER.isDebugEnabled()) { if (LOGGER.isDebugEnabled()) {
int numberOfResultObjects = result == null ? 0 : result.size(); int numberOfResultObjects = result == null ? 0 : result.size();
LOGGER.debug("exit from list(). Returning {} resulting Objects: {} ", numberOfResultObjects, LOGGER.debug("exit from list(). Returning {} resulting Objects: {} ", numberOfResultObjects,
@ -359,9 +359,9 @@ public class ClassificationQueryImpl implements ClassificationQuery {
LOGGER.debug("entry to list(offset = {}, limit = {}), this = {}", offset, limit, this); LOGGER.debug("entry to list(offset = {}, limit = {}), this = {}", offset, limit, this);
List<ClassificationSummary> result = null; List<ClassificationSummary> result = null;
try { try {
taskanaEngineImpl.openConnection(); taskanaEngine.openConnection();
RowBounds rowBounds = new RowBounds(offset, limit); RowBounds rowBounds = new RowBounds(offset, limit);
result = taskanaEngineImpl.getSqlSession().selectList(LINK_TO_MAPPER, this, rowBounds); result = taskanaEngine.getSqlSession().selectList(LINK_TO_MAPPER, this, rowBounds);
return result; return result;
} catch (Exception e) { } catch (Exception e) {
if (e instanceof PersistenceException) { if (e instanceof PersistenceException) {
@ -374,7 +374,7 @@ public class ClassificationQueryImpl implements ClassificationQuery {
} }
throw e; throw e;
} finally { } finally {
taskanaEngineImpl.returnConnection(); taskanaEngine.returnConnection();
if (LOGGER.isDebugEnabled()) { if (LOGGER.isDebugEnabled()) {
int numberOfResultObjects = result == null ? 0 : result.size(); int numberOfResultObjects = result == null ? 0 : result.size();
LOGGER.debug("exit from list(offset,limit). Returning {} resulting Objects: {} ", numberOfResultObjects, LOGGER.debug("exit from list(offset,limit). Returning {} resulting Objects: {} ", numberOfResultObjects,
@ -388,11 +388,11 @@ public class ClassificationQueryImpl implements ClassificationQuery {
LOGGER.debug("entry to single(), this = {}", this); LOGGER.debug("entry to single(), this = {}", this);
ClassificationSummary result = null; ClassificationSummary result = null;
try { try {
taskanaEngineImpl.openConnection(); taskanaEngine.openConnection();
result = taskanaEngineImpl.getSqlSession().selectOne(LINK_TO_MAPPER, this); result = taskanaEngine.getSqlSession().selectOne(LINK_TO_MAPPER, this);
return result; return result;
} finally { } finally {
taskanaEngineImpl.returnConnection(); taskanaEngine.returnConnection();
LOGGER.debug("exit from single(). Returning result {} ", result); LOGGER.debug("exit from single(). Returning result {} ", result);
} }
} }
@ -535,11 +535,11 @@ public class ClassificationQueryImpl implements ClassificationQuery {
LOGGER.debug("entry to count(), this = {}", this); LOGGER.debug("entry to count(), this = {}", this);
Long rowCount = null; Long rowCount = null;
try { try {
taskanaEngineImpl.openConnection(); taskanaEngine.openConnection();
rowCount = taskanaEngineImpl.getSqlSession().selectOne(LINK_TO_COUNTER, this); rowCount = taskanaEngine.getSqlSession().selectOne(LINK_TO_COUNTER, this);
return (rowCount == null) ? 0L : rowCount; return (rowCount == null) ? 0L : rowCount;
} finally { } finally {
taskanaEngineImpl.returnConnection(); taskanaEngine.returnConnection();
LOGGER.debug("exit from count(). Returning result {} ", rowCount); LOGGER.debug("exit from count(). Returning result {} ", rowCount);
} }
} }

View File

@ -32,24 +32,25 @@ public class ClassificationServiceImpl implements ClassificationService {
private static final Logger LOGGER = LoggerFactory.getLogger(ClassificationServiceImpl.class); private static final Logger LOGGER = LoggerFactory.getLogger(ClassificationServiceImpl.class);
private ClassificationMapper classificationMapper; private ClassificationMapper classificationMapper;
private TaskMapper taskMapper; private TaskMapper taskMapper;
private TaskanaEngineImpl taskanaEngineImpl; private TaskanaEngineImpl taskanaEngine;
ClassificationServiceImpl(TaskanaEngine taskanaEngine, ClassificationMapper classificationMapper, ClassificationServiceImpl(TaskanaEngine taskanaEngine, ClassificationMapper classificationMapper,
TaskMapper taskMapper) { TaskMapper taskMapper) {
super(); super();
this.taskanaEngineImpl = (TaskanaEngineImpl) taskanaEngine; this.taskanaEngine = (TaskanaEngineImpl) taskanaEngine;
this.classificationMapper = classificationMapper; this.classificationMapper = classificationMapper;
this.taskMapper = taskMapper; this.taskMapper = taskMapper;
} }
@Override @Override
public Classification createClassification(Classification classification) public Classification createClassification(Classification classification)
throws ClassificationAlreadyExistException { throws ClassificationAlreadyExistException, NotAuthorizedException {
LOGGER.debug("entry to createClassification(classification = {})", classification); LOGGER.debug("entry to createClassification(classification = {})", classification);
taskanaEngine.checkRoleMembership(TaskanaRole.BUSINESS_ADMIN, TaskanaRole.ADMIN);
ClassificationImpl classificationImpl; ClassificationImpl classificationImpl;
final boolean isClassificationExisting; final boolean isClassificationExisting;
try { try {
taskanaEngineImpl.openConnection(); taskanaEngine.openConnection();
isClassificationExisting = doesClassificationExist(classification.getKey(), classification.getDomain()); isClassificationExisting = doesClassificationExist(classification.getKey(), classification.getDomain());
if (isClassificationExisting) { if (isClassificationExisting) {
@ -63,7 +64,7 @@ public class ClassificationServiceImpl implements ClassificationService {
addClassificationToRootDomain(classificationImpl); addClassificationToRootDomain(classificationImpl);
} finally { } finally {
taskanaEngineImpl.returnConnection(); taskanaEngine.returnConnection();
LOGGER.debug("exit from createClassification()"); LOGGER.debug("exit from createClassification()");
} }
return classificationImpl; return classificationImpl;
@ -104,9 +105,10 @@ public class ClassificationServiceImpl implements ClassificationService {
@Override @Override
public Classification updateClassification(Classification classification) throws NotAuthorizedException { public Classification updateClassification(Classification classification) throws NotAuthorizedException {
LOGGER.debug("entry to updateClassification(Classification = {})", classification); LOGGER.debug("entry to updateClassification(Classification = {})", classification);
taskanaEngine.checkRoleMembership(TaskanaRole.BUSINESS_ADMIN, TaskanaRole.ADMIN);
ClassificationImpl classificationImpl = null; ClassificationImpl classificationImpl = null;
try { try {
taskanaEngineImpl.openConnection(); taskanaEngine.openConnection();
classificationImpl = (ClassificationImpl) classification; classificationImpl = (ClassificationImpl) classification;
this.initDefaultClassificationValues(classificationImpl); this.initDefaultClassificationValues(classificationImpl);
@ -116,7 +118,7 @@ public class ClassificationServiceImpl implements ClassificationService {
classificationImpl.getDomain()); classificationImpl.getDomain());
// Update classification fields used by tasks // Update classification fields used by tasks
if (oldClassification.getCategory() != classificationImpl.getCategory()) { if (oldClassification.getCategory() != classificationImpl.getCategory()) {
List<TaskSummary> taskSumamries = taskanaEngineImpl.getTaskService() List<TaskSummary> taskSumamries = taskanaEngine.getTaskService()
.createTaskQuery() .createTaskQuery()
.classificationKeyIn(oldClassification.getKey()) .classificationKeyIn(oldClassification.getKey())
.classificationCategoryIn(oldClassification.getCategory()) .classificationCategoryIn(oldClassification.getCategory())
@ -150,7 +152,7 @@ public class ClassificationServiceImpl implements ClassificationService {
throw new SystemException("updateClassification didn't find new classification after update"); throw new SystemException("updateClassification didn't find new classification after update");
} }
} finally { } finally {
taskanaEngineImpl.returnConnection(); taskanaEngine.returnConnection();
LOGGER.debug("exit from updateClassification()."); LOGGER.debug("exit from updateClassification().");
} }
} }
@ -203,7 +205,7 @@ public class ClassificationServiceImpl implements ClassificationService {
LOGGER.debug("entry to getClassification(id = {})", id); LOGGER.debug("entry to getClassification(id = {})", id);
Classification result = null; Classification result = null;
try { try {
taskanaEngineImpl.openConnection(); taskanaEngine.openConnection();
result = classificationMapper.findById(id); result = classificationMapper.findById(id);
if (result == null) { if (result == null) {
LOGGER.error("Classification for id {} was not found. Throwing ClassificationNotFoundException", id); LOGGER.error("Classification for id {} was not found. Throwing ClassificationNotFoundException", id);
@ -211,13 +213,14 @@ public class ClassificationServiceImpl implements ClassificationService {
} }
return result; return result;
} finally { } finally {
taskanaEngineImpl.returnConnection(); taskanaEngine.returnConnection();
LOGGER.debug("exit from getClassification(). Returning result {} ", result); LOGGER.debug("exit from getClassification(). Returning result {} ", result);
} }
} }
@Override @Override
public Classification getClassification(String key, String domain) throws ClassificationNotFoundException { public Classification getClassification(String key, String domain) throws ClassificationNotFoundException {
LOGGER.debug("entry to getClassification(key = {}, domain = {})", key, domain);
if (key == null) { if (key == null) {
throw new ClassificationNotFoundException( throw new ClassificationNotFoundException(
"Classification for key " + key + " and domain " + domain + " was not found."); "Classification for key " + key + " and domain " + domain + " was not found.");
@ -225,7 +228,7 @@ public class ClassificationServiceImpl implements ClassificationService {
LOGGER.debug("entry to getClassification(key = {}, domain = {})", key, domain); LOGGER.debug("entry to getClassification(key = {}, domain = {})", key, domain);
Classification result = null; Classification result = null;
try { try {
taskanaEngineImpl.openConnection(); taskanaEngine.openConnection();
result = classificationMapper.findByKeyAndDomain(key, domain); result = classificationMapper.findByKeyAndDomain(key, domain);
if (result == null) { if (result == null) {
result = classificationMapper.findByKeyAndDomain(key, ""); result = classificationMapper.findByKeyAndDomain(key, "");
@ -238,14 +241,14 @@ public class ClassificationServiceImpl implements ClassificationService {
} }
return result; return result;
} finally { } finally {
taskanaEngineImpl.returnConnection(); taskanaEngine.returnConnection();
LOGGER.debug("exit from getClassification(). Returning result {} ", result); LOGGER.debug("exit from getClassification(). Returning result {} ", result);
} }
} }
@Override @Override
public ClassificationQuery createClassificationQuery() { public ClassificationQuery createClassificationQuery() {
return new ClassificationQueryImpl(taskanaEngineImpl); return new ClassificationQueryImpl(taskanaEngine);
} }
@Override @Override
@ -273,9 +276,11 @@ public class ClassificationServiceImpl implements ClassificationService {
@Override @Override
public void deleteClassification(String classificationKey, String domain) public void deleteClassification(String classificationKey, String domain)
throws ClassificationInUseException, ClassificationNotFoundException { throws ClassificationInUseException, ClassificationNotFoundException, NotAuthorizedException {
LOGGER.debug("entry to deleteClassification(key = {}, domain = {})", classificationKey, domain);
taskanaEngine.checkRoleMembership(TaskanaRole.BUSINESS_ADMIN, TaskanaRole.ADMIN);
try { try {
taskanaEngineImpl.openConnection(); taskanaEngine.openConnection();
Classification classification = this.classificationMapper.findByKeyAndDomain(classificationKey, domain); Classification classification = this.classificationMapper.findByKeyAndDomain(classificationKey, domain);
if (classification == null) { if (classification == null) {
throw new ClassificationNotFoundException( throw new ClassificationNotFoundException(
@ -291,7 +296,7 @@ public class ClassificationServiceImpl implements ClassificationService {
} }
} }
TaskServiceImpl taskService = (TaskServiceImpl) taskanaEngineImpl.getTaskService(); TaskServiceImpl taskService = (TaskServiceImpl) taskanaEngine.getTaskService();
try { try {
List<TaskSummary> classificationTasks = taskService.createTaskQuery() List<TaskSummary> classificationTasks = taskService.createTaskQuery()
.classificationKeyIn(classificationKey) .classificationKeyIn(classificationKey)
@ -315,7 +320,8 @@ public class ClassificationServiceImpl implements ClassificationService {
this.classificationMapper.deleteClassificationInDomain(classificationKey, domain); this.classificationMapper.deleteClassificationInDomain(classificationKey, domain);
} finally { } finally {
taskanaEngineImpl.returnConnection(); taskanaEngine.returnConnection();
LOGGER.debug("exit from deleteClassification()");
} }
} }
} }

View File

@ -24,7 +24,7 @@ public class ObjectReferenceQueryImpl implements ObjectReferenceQuery {
private static final String LINK_TO_COUNTER = "pro.taskana.mappings.QueryMapper.countQueryObjectReferences"; private static final String LINK_TO_COUNTER = "pro.taskana.mappings.QueryMapper.countQueryObjectReferences";
private static final Logger LOGGER = LoggerFactory.getLogger(ObjectReferenceQueryImpl.class); private static final Logger LOGGER = LoggerFactory.getLogger(ObjectReferenceQueryImpl.class);
private TaskanaEngineImpl taskanaEngineImpl; private TaskanaEngineImpl taskanaEngine;
private String[] company; private String[] company;
private String[] system; private String[] system;
private String[] systemInstance; private String[] systemInstance;
@ -32,7 +32,7 @@ public class ObjectReferenceQueryImpl implements ObjectReferenceQuery {
private String[] value; private String[] value;
ObjectReferenceQueryImpl(TaskanaEngine taskanaEngine) { ObjectReferenceQueryImpl(TaskanaEngine taskanaEngine) {
this.taskanaEngineImpl = (TaskanaEngineImpl) taskanaEngine; this.taskanaEngine = (TaskanaEngineImpl) taskanaEngine;
} }
@Override @Override
@ -70,11 +70,11 @@ public class ObjectReferenceQueryImpl implements ObjectReferenceQuery {
LOGGER.debug("entry to list(), this = {}", this); LOGGER.debug("entry to list(), this = {}", this);
List<ObjectReference> result = null; List<ObjectReference> result = null;
try { try {
taskanaEngineImpl.openConnection(); taskanaEngine.openConnection();
result = taskanaEngineImpl.getSqlSession().selectList(LINK_TO_MAPPER, this); result = taskanaEngine.getSqlSession().selectList(LINK_TO_MAPPER, this);
return result; return result;
} finally { } finally {
taskanaEngineImpl.returnConnection(); taskanaEngine.returnConnection();
if (LOGGER.isDebugEnabled()) { if (LOGGER.isDebugEnabled()) {
int numberOfResultObjects = result == null ? 0 : result.size(); int numberOfResultObjects = result == null ? 0 : result.size();
LOGGER.debug("exit from list(). Returning {} resulting Objects: {} ", numberOfResultObjects, LOGGER.debug("exit from list(). Returning {} resulting Objects: {} ", numberOfResultObjects,
@ -88,9 +88,9 @@ public class ObjectReferenceQueryImpl implements ObjectReferenceQuery {
LOGGER.debug("entry to list(offset = {}, limit = {}), this = {}", offset, limit, this); LOGGER.debug("entry to list(offset = {}, limit = {}), this = {}", offset, limit, this);
List<ObjectReference> result = null; List<ObjectReference> result = null;
try { try {
taskanaEngineImpl.openConnection(); taskanaEngine.openConnection();
RowBounds rowBounds = new RowBounds(offset, limit); RowBounds rowBounds = new RowBounds(offset, limit);
result = taskanaEngineImpl.getSqlSession().selectList(LINK_TO_MAPPER, this, rowBounds); result = taskanaEngine.getSqlSession().selectList(LINK_TO_MAPPER, this, rowBounds);
return result; return result;
} catch (Exception e) { } catch (Exception e) {
if (e instanceof PersistenceException) { if (e instanceof PersistenceException) {
@ -103,7 +103,7 @@ public class ObjectReferenceQueryImpl implements ObjectReferenceQuery {
} }
throw e; throw e;
} finally { } finally {
taskanaEngineImpl.returnConnection(); taskanaEngine.returnConnection();
if (LOGGER.isDebugEnabled()) { if (LOGGER.isDebugEnabled()) {
int numberOfResultObjects = result == null ? 0 : result.size(); int numberOfResultObjects = result == null ? 0 : result.size();
LOGGER.debug("exit from list(offset,limit). Returning {} resulting Objects: {} ", numberOfResultObjects, LOGGER.debug("exit from list(offset,limit). Returning {} resulting Objects: {} ", numberOfResultObjects,
@ -117,11 +117,11 @@ public class ObjectReferenceQueryImpl implements ObjectReferenceQuery {
LOGGER.debug("entry to single(), this = {}", this); LOGGER.debug("entry to single(), this = {}", this);
ObjectReference result = null; ObjectReference result = null;
try { try {
taskanaEngineImpl.openConnection(); taskanaEngine.openConnection();
result = taskanaEngineImpl.getSqlSession().selectOne(LINK_TO_MAPPER, this); result = taskanaEngine.getSqlSession().selectOne(LINK_TO_MAPPER, this);
return result; return result;
} finally { } finally {
taskanaEngineImpl.returnConnection(); taskanaEngine.returnConnection();
LOGGER.debug("exit from single(). Returning result {} ", result); LOGGER.debug("exit from single(). Returning result {} ", result);
} }
} }
@ -171,11 +171,11 @@ public class ObjectReferenceQueryImpl implements ObjectReferenceQuery {
LOGGER.debug("entry to count(), this = {}", this); LOGGER.debug("entry to count(), this = {}", this);
Long rowCount = null; Long rowCount = null;
try { try {
taskanaEngineImpl.openConnection(); taskanaEngine.openConnection();
rowCount = taskanaEngineImpl.getSqlSession().selectOne(LINK_TO_COUNTER, this); rowCount = taskanaEngine.getSqlSession().selectOne(LINK_TO_COUNTER, this);
return (rowCount == null) ? 0L : rowCount; return (rowCount == null) ? 0L : rowCount;
} finally { } finally {
taskanaEngineImpl.returnConnection(); taskanaEngine.returnConnection();
LOGGER.debug("exit from count(). Returning result {} ", rowCount); LOGGER.debug("exit from count(). Returning result {} ", rowCount);
} }
} }
@ -184,7 +184,7 @@ public class ObjectReferenceQueryImpl implements ObjectReferenceQuery {
public String toString() { public String toString() {
StringBuilder builder = new StringBuilder(); StringBuilder builder = new StringBuilder();
builder.append("ObjectReferenceQueryImpl [taskanaEngineImpl="); builder.append("ObjectReferenceQueryImpl [taskanaEngineImpl=");
builder.append(taskanaEngineImpl); builder.append(taskanaEngine);
builder.append(", company="); builder.append(", company=");
builder.append(Arrays.toString(company)); builder.append(Arrays.toString(company));
builder.append(", system="); builder.append(", system=");

View File

@ -28,7 +28,7 @@ public class TaskQueryImpl implements TaskQuery {
private static final String LINK_TO_MAPPER = "pro.taskana.mappings.QueryMapper.queryTasks"; private static final String LINK_TO_MAPPER = "pro.taskana.mappings.QueryMapper.queryTasks";
private static final String LINK_TO_COUNTER = "pro.taskana.mappings.QueryMapper.countQueryTasks"; private static final String LINK_TO_COUNTER = "pro.taskana.mappings.QueryMapper.countQueryTasks";
private static final Logger LOGGER = LoggerFactory.getLogger(TaskQueryImpl.class); private static final Logger LOGGER = LoggerFactory.getLogger(TaskQueryImpl.class);
private TaskanaEngineImpl taskanaEngineImpl; private TaskanaEngineImpl taskanaEngine;
private TaskServiceImpl taskService; private TaskServiceImpl taskService;
private String[] nameIn; private String[] nameIn;
private String[] nameLike; private String[] nameLike;
@ -93,8 +93,8 @@ public class TaskQueryImpl implements TaskQuery {
private List<String> orderBy; private List<String> orderBy;
TaskQueryImpl(TaskanaEngine taskanaEngine) { TaskQueryImpl(TaskanaEngine taskanaEngine) {
this.taskanaEngineImpl = (TaskanaEngineImpl) taskanaEngine; this.taskanaEngine = (TaskanaEngineImpl) taskanaEngine;
this.taskService = (TaskServiceImpl) taskanaEngineImpl.getTaskService(); this.taskService = (TaskServiceImpl) taskanaEngine.getTaskService();
this.orderBy = new ArrayList<>(); this.orderBy = new ArrayList<>();
} }
@ -655,7 +655,7 @@ public class TaskQueryImpl implements TaskQuery {
@Override @Override
public ObjectReferenceQuery createObjectReferenceQuery() { public ObjectReferenceQuery createObjectReferenceQuery() {
return new ObjectReferenceQueryImpl(taskanaEngineImpl); return new ObjectReferenceQueryImpl(taskanaEngine);
} }
@Override @Override
@ -663,16 +663,16 @@ public class TaskQueryImpl implements TaskQuery {
List<TaskSummary> result = new ArrayList<>(); List<TaskSummary> result = new ArrayList<>();
try { try {
LOGGER.debug("entry to list(), this = {}", this); LOGGER.debug("entry to list(), this = {}", this);
taskanaEngineImpl.openConnection(); taskanaEngine.openConnection();
checkOpenPermissionForSpecifiedWorkbaskets(); checkOpenPermissionForSpecifiedWorkbaskets();
List<TaskSummaryImpl> tasks = new ArrayList<>(); List<TaskSummaryImpl> tasks = new ArrayList<>();
tasks = taskanaEngineImpl.getSqlSession().selectList(LINK_TO_MAPPER, this); tasks = taskanaEngine.getSqlSession().selectList(LINK_TO_MAPPER, this);
result = taskService.augmentTaskSummariesByContainedSummaries(tasks); result = taskService.augmentTaskSummariesByContainedSummaries(tasks);
return result; return result;
} catch (NotAuthorizedException e) { } catch (NotAuthorizedException e) {
throw new NotAuthorizedToQueryWorkbasketException(e.getMessage()); throw new NotAuthorizedToQueryWorkbasketException(e.getMessage());
} finally { } finally {
taskanaEngineImpl.returnConnection(); taskanaEngine.returnConnection();
if (LOGGER.isDebugEnabled()) { if (LOGGER.isDebugEnabled()) {
int numberOfResultObjects = result == null ? 0 : result.size(); int numberOfResultObjects = result == null ? 0 : result.size();
LOGGER.debug("exit from list(). Returning {} resulting Objects: {} ", numberOfResultObjects, LOGGER.debug("exit from list(). Returning {} resulting Objects: {} ", numberOfResultObjects,
@ -686,10 +686,10 @@ public class TaskQueryImpl implements TaskQuery {
LOGGER.debug("entry to list(offset = {}, limit = {}), this = {}", offset, limit, this); LOGGER.debug("entry to list(offset = {}, limit = {}), this = {}", offset, limit, this);
List<TaskSummary> result = new ArrayList<>(); List<TaskSummary> result = new ArrayList<>();
try { try {
taskanaEngineImpl.openConnection(); taskanaEngine.openConnection();
checkOpenPermissionForSpecifiedWorkbaskets(); checkOpenPermissionForSpecifiedWorkbaskets();
RowBounds rowBounds = new RowBounds(offset, limit); RowBounds rowBounds = new RowBounds(offset, limit);
List<TaskSummaryImpl> tasks = taskanaEngineImpl.getSqlSession().selectList(LINK_TO_MAPPER, this, rowBounds); List<TaskSummaryImpl> tasks = taskanaEngine.getSqlSession().selectList(LINK_TO_MAPPER, this, rowBounds);
result = taskService.augmentTaskSummariesByContainedSummaries(tasks); result = taskService.augmentTaskSummariesByContainedSummaries(tasks);
return result; return result;
} catch (PersistenceException e) { } catch (PersistenceException e) {
@ -703,7 +703,7 @@ public class TaskQueryImpl implements TaskQuery {
} catch (NotAuthorizedException e) { } catch (NotAuthorizedException e) {
throw new NotAuthorizedToQueryWorkbasketException(e.getMessage()); throw new NotAuthorizedToQueryWorkbasketException(e.getMessage());
} finally { } finally {
taskanaEngineImpl.returnConnection(); taskanaEngine.returnConnection();
if (LOGGER.isDebugEnabled()) { if (LOGGER.isDebugEnabled()) {
int numberOfResultObjects = result == null ? 0 : result.size(); int numberOfResultObjects = result == null ? 0 : result.size();
LOGGER.debug("exit from list(offset,limit). Returning {} resulting Objects: {} ", numberOfResultObjects, LOGGER.debug("exit from list(offset,limit). Returning {} resulting Objects: {} ", numberOfResultObjects,
@ -717,9 +717,9 @@ public class TaskQueryImpl implements TaskQuery {
LOGGER.debug("entry to single(), this = {}", this); LOGGER.debug("entry to single(), this = {}", this);
TaskSummary result = null; TaskSummary result = null;
try { try {
taskanaEngineImpl.openConnection(); taskanaEngine.openConnection();
checkOpenPermissionForSpecifiedWorkbaskets(); checkOpenPermissionForSpecifiedWorkbaskets();
TaskSummaryImpl taskSummaryImpl = taskanaEngineImpl.getSqlSession().selectOne(LINK_TO_MAPPER, this); TaskSummaryImpl taskSummaryImpl = taskanaEngine.getSqlSession().selectOne(LINK_TO_MAPPER, this);
if (taskSummaryImpl == null) { if (taskSummaryImpl == null) {
return null; return null;
} }
@ -732,7 +732,7 @@ public class TaskQueryImpl implements TaskQuery {
} catch (NotAuthorizedException e) { } catch (NotAuthorizedException e) {
throw new NotAuthorizedToQueryWorkbasketException(e.getMessage()); throw new NotAuthorizedToQueryWorkbasketException(e.getMessage());
} finally { } finally {
taskanaEngineImpl.returnConnection(); taskanaEngine.returnConnection();
LOGGER.debug("exit from single(). Returning result {} ", result); LOGGER.debug("exit from single(). Returning result {} ", result);
} }
} }
@ -742,27 +742,31 @@ public class TaskQueryImpl implements TaskQuery {
LOGGER.debug("entry to count(), this = {}", this); LOGGER.debug("entry to count(), this = {}", this);
Long rowCount = null; Long rowCount = null;
try { try {
taskanaEngineImpl.openConnection(); taskanaEngine.openConnection();
checkOpenPermissionForSpecifiedWorkbaskets(); checkOpenPermissionForSpecifiedWorkbaskets();
rowCount = taskanaEngineImpl.getSqlSession().selectOne(LINK_TO_COUNTER, this); rowCount = taskanaEngine.getSqlSession().selectOne(LINK_TO_COUNTER, this);
return (rowCount == null) ? 0L : rowCount; return (rowCount == null) ? 0L : rowCount;
} finally { } finally {
taskanaEngineImpl.returnConnection(); taskanaEngine.returnConnection();
LOGGER.debug("exit from count(). Returning result {} ", rowCount); LOGGER.debug("exit from count(). Returning result {} ", rowCount);
} }
} }
private void checkOpenPermissionForSpecifiedWorkbaskets() { private void checkOpenPermissionForSpecifiedWorkbaskets() {
if (taskanaEngine.isUserInRole(TaskanaRole.ADMIN)) {
LOGGER.debug("Skipping permissions check since user is in role ADMIN.");
return;
}
try { try {
if (this.workbasketIdIn != null && this.workbasketIdIn.length > 0) { if (this.workbasketIdIn != null && this.workbasketIdIn.length > 0) {
for (String workbasketId : workbasketIdIn) { for (String workbasketId : workbasketIdIn) {
taskanaEngineImpl.getWorkbasketService().checkAuthorization(workbasketId, taskanaEngine.getWorkbasketService().checkAuthorization(workbasketId,
WorkbasketAuthorization.OPEN); WorkbasketAuthorization.OPEN);
} }
} }
if (workbasketKeyDomainIn != null && workbasketKeyDomainIn.length > 0) { if (workbasketKeyDomainIn != null && workbasketKeyDomainIn.length > 0) {
for (KeyDomain keyDomain : workbasketKeyDomainIn) { for (KeyDomain keyDomain : workbasketKeyDomainIn) {
taskanaEngineImpl.getWorkbasketService().checkAuthorization(keyDomain.getKey(), taskanaEngine.getWorkbasketService().checkAuthorization(keyDomain.getKey(),
keyDomain.getDomain(), WorkbasketAuthorization.OPEN); keyDomain.getDomain(), WorkbasketAuthorization.OPEN);
} }
} }
@ -772,7 +776,7 @@ public class TaskQueryImpl implements TaskQuery {
} }
public TaskanaEngineImpl getTaskanaEngine() { public TaskanaEngineImpl getTaskanaEngine() {
return taskanaEngineImpl; return taskanaEngine;
} }
public String[] getTaskIds() { public String[] getTaskIds() {

View File

@ -54,8 +54,7 @@ public class TaskServiceImpl implements TaskService {
private static final String ID_PREFIX_TASK = "TKI"; private static final String ID_PREFIX_TASK = "TKI";
private static final String ID_PREFIX_BUSINESS_PROCESS = "BPI"; private static final String ID_PREFIX_BUSINESS_PROCESS = "BPI";
private static final String MUST_NOT_BE_EMPTY = " must not be empty"; private static final String MUST_NOT_BE_EMPTY = " must not be empty";
private TaskanaEngine taskanaEngine; private TaskanaEngineImpl taskanaEngine;
private TaskanaEngineImpl taskanaEngineImpl;
private WorkbasketService workbasketService; private WorkbasketService workbasketService;
private ClassificationServiceImpl classificationService; private ClassificationServiceImpl classificationService;
private TaskMapper taskMapper; private TaskMapper taskMapper;
@ -64,12 +63,11 @@ public class TaskServiceImpl implements TaskService {
TaskServiceImpl(TaskanaEngine taskanaEngine, TaskMapper taskMapper, TaskServiceImpl(TaskanaEngine taskanaEngine, TaskMapper taskMapper,
AttachmentMapper attachmentMapper) { AttachmentMapper attachmentMapper) {
super(); super();
this.taskanaEngine = taskanaEngine; this.taskanaEngine = (TaskanaEngineImpl) taskanaEngine;
this.taskanaEngineImpl = (TaskanaEngineImpl) taskanaEngine;
this.taskMapper = taskMapper; this.taskMapper = taskMapper;
this.workbasketService = taskanaEngineImpl.getWorkbasketService(); this.workbasketService = taskanaEngine.getWorkbasketService();
this.attachmentMapper = attachmentMapper; this.attachmentMapper = attachmentMapper;
this.classificationService = (ClassificationServiceImpl) taskanaEngineImpl.getClassificationService(); this.classificationService = (ClassificationServiceImpl) taskanaEngine.getClassificationService();
} }
@Override @Override
@ -85,7 +83,7 @@ public class TaskServiceImpl implements TaskService {
LOGGER.debug("entry to claim(id = {}, forceClaim = {}, userId = {})", taskId, forceClaim, userId); LOGGER.debug("entry to claim(id = {}, forceClaim = {}, userId = {})", taskId, forceClaim, userId);
TaskImpl task = null; TaskImpl task = null;
try { try {
taskanaEngineImpl.openConnection(); taskanaEngine.openConnection();
task = (TaskImpl) getTask(taskId); task = (TaskImpl) getTask(taskId);
TaskState state = task.getState(); TaskState state = task.getState();
if (state == TaskState.COMPLETED) { if (state == TaskState.COMPLETED) {
@ -109,7 +107,7 @@ public class TaskServiceImpl implements TaskService {
taskMapper.update(task); taskMapper.update(task);
LOGGER.debug("Method claim() claimed task '{}' for user '{}'.", taskId, userId); LOGGER.debug("Method claim() claimed task '{}' for user '{}'.", taskId, userId);
} finally { } finally {
taskanaEngineImpl.returnConnection(); taskanaEngine.returnConnection();
LOGGER.debug("exit from claim()"); LOGGER.debug("exit from claim()");
} }
return task; return task;
@ -128,7 +126,7 @@ public class TaskServiceImpl implements TaskService {
forceUnclaim); forceUnclaim);
TaskImpl task = null; TaskImpl task = null;
try { try {
taskanaEngineImpl.openConnection(); taskanaEngine.openConnection();
task = (TaskImpl) getTask(taskId); task = (TaskImpl) getTask(taskId);
TaskState state = task.getState(); TaskState state = task.getState();
if (state == TaskState.COMPLETED) { if (state == TaskState.COMPLETED) {
@ -152,7 +150,7 @@ public class TaskServiceImpl implements TaskService {
taskMapper.update(task); taskMapper.update(task);
LOGGER.debug("Method cancelClaim() unclaimed task '{}' for user '{}'.", taskId, userId); LOGGER.debug("Method cancelClaim() unclaimed task '{}' for user '{}'.", taskId, userId);
} finally { } finally {
taskanaEngineImpl.returnConnection(); taskanaEngine.returnConnection();
LOGGER.debug("exit from cancelClaim(taskId = {}) with userId = {}, forceFlag = {}", taskId, userId, LOGGER.debug("exit from cancelClaim(taskId = {}) with userId = {}, forceFlag = {}", taskId, userId,
forceUnclaim); forceUnclaim);
} }
@ -171,7 +169,7 @@ public class TaskServiceImpl implements TaskService {
LOGGER.debug("entry to completeTask(id = {}, isForced {})", taskId, isForced); LOGGER.debug("entry to completeTask(id = {}, isForced {})", taskId, isForced);
TaskImpl task = null; TaskImpl task = null;
try { try {
taskanaEngineImpl.openConnection(); taskanaEngine.openConnection();
task = (TaskImpl) this.getTask(taskId); task = (TaskImpl) this.getTask(taskId);
// check pre-conditions for non-forced invocation // check pre-conditions for non-forced invocation
@ -201,7 +199,7 @@ public class TaskServiceImpl implements TaskService {
taskMapper.update(task); taskMapper.update(task);
LOGGER.debug("Method completeTask() completed Task '{}'.", taskId); LOGGER.debug("Method completeTask() completed Task '{}'.", taskId);
} finally { } finally {
taskanaEngineImpl.returnConnection(); taskanaEngine.returnConnection();
LOGGER.debug("exit from completeTask()"); LOGGER.debug("exit from completeTask()");
} }
return task; return task;
@ -212,7 +210,7 @@ public class TaskServiceImpl implements TaskService {
throws InvalidArgumentException { throws InvalidArgumentException {
try { try {
LOGGER.debug("entry to completeTasks(taskIds = {})", taskIds); LOGGER.debug("entry to completeTasks(taskIds = {})", taskIds);
taskanaEngineImpl.openConnection(); taskanaEngine.openConnection();
// Check pre-conditions with throwing Exceptions // Check pre-conditions with throwing Exceptions
if (taskIds == null) { if (taskIds == null) {
@ -268,7 +266,7 @@ public class TaskServiceImpl implements TaskService {
} }
return bulkLog; return bulkLog;
} finally { } finally {
taskanaEngineImpl.returnConnection(); taskanaEngine.returnConnection();
LOGGER.debug("exit from to completeTasks(taskIds = {})", taskIds); LOGGER.debug("exit from to completeTasks(taskIds = {})", taskIds);
} }
} }
@ -279,7 +277,7 @@ public class TaskServiceImpl implements TaskService {
TaskAlreadyExistException, InvalidWorkbasketException, InvalidArgumentException { TaskAlreadyExistException, InvalidWorkbasketException, InvalidArgumentException {
LOGGER.debug("entry to createTask(task = {})", taskToCreate); LOGGER.debug("entry to createTask(task = {})", taskToCreate);
try { try {
taskanaEngineImpl.openConnection(); taskanaEngine.openConnection();
TaskImpl task = (TaskImpl) taskToCreate; TaskImpl task = (TaskImpl) taskToCreate;
if (task.getId() != "" && task.getId() != null) { if (task.getId() != "" && task.getId() != null) {
throw new TaskAlreadyExistException(taskToCreate.getId()); throw new TaskAlreadyExistException(taskToCreate.getId());
@ -314,7 +312,7 @@ public class TaskServiceImpl implements TaskService {
} }
return task; return task;
} finally { } finally {
taskanaEngineImpl.returnConnection(); taskanaEngine.returnConnection();
LOGGER.debug("exit from createTask(task = {})"); LOGGER.debug("exit from createTask(task = {})");
} }
} }
@ -324,7 +322,7 @@ public class TaskServiceImpl implements TaskService {
LOGGER.debug("entry to getTaskById(id = {})", id); LOGGER.debug("entry to getTaskById(id = {})", id);
TaskImpl resultTask = null; TaskImpl resultTask = null;
try { try {
taskanaEngineImpl.openConnection(); taskanaEngine.openConnection();
resultTask = taskMapper.findById(id); resultTask = taskMapper.findById(id);
if (resultTask != null) { if (resultTask != null) {
@ -356,7 +354,7 @@ public class TaskServiceImpl implements TaskService {
throw new TaskNotFoundException(id); throw new TaskNotFoundException(id);
} }
} finally { } finally {
taskanaEngineImpl.returnConnection(); taskanaEngine.returnConnection();
LOGGER.debug("exit from getTaskById(). Returning result {} ", resultTask); LOGGER.debug("exit from getTaskById(). Returning result {} ", resultTask);
} }
} }
@ -367,7 +365,7 @@ public class TaskServiceImpl implements TaskService {
LOGGER.debug("entry to transfer(taskId = {}, destinationWorkbasketId = {})", taskId, destinationWorkbasketId); LOGGER.debug("entry to transfer(taskId = {}, destinationWorkbasketId = {})", taskId, destinationWorkbasketId);
TaskImpl task = null; TaskImpl task = null;
try { try {
taskanaEngineImpl.openConnection(); taskanaEngine.openConnection();
task = (TaskImpl) getTask(taskId); task = (TaskImpl) getTask(taskId);
// transfer requires TRANSFER in source and APPEND on destination workbasket // transfer requires TRANSFER in source and APPEND on destination workbasket
@ -391,7 +389,7 @@ public class TaskServiceImpl implements TaskService {
destinationWorkbasketId); destinationWorkbasketId);
return task; return task;
} finally { } finally {
taskanaEngineImpl.returnConnection(); taskanaEngine.returnConnection();
LOGGER.debug("exit from transfer(). Returning result {} ", task); LOGGER.debug("exit from transfer(). Returning result {} ", task);
} }
} }
@ -403,7 +401,7 @@ public class TaskServiceImpl implements TaskService {
destinationWorkbasketKey, domain); destinationWorkbasketKey, domain);
TaskImpl task = null; TaskImpl task = null;
try { try {
taskanaEngineImpl.openConnection(); taskanaEngine.openConnection();
task = (TaskImpl) getTask(taskId); task = (TaskImpl) getTask(taskId);
// transfer requires TRANSFER in source and APPEND on destination workbasket // transfer requires TRANSFER in source and APPEND on destination workbasket
@ -427,7 +425,7 @@ public class TaskServiceImpl implements TaskService {
destinationWorkbasket.getId()); destinationWorkbasket.getId());
return task; return task;
} finally { } finally {
taskanaEngineImpl.returnConnection(); taskanaEngine.returnConnection();
LOGGER.debug("exit from transfer(). Returning result {} ", task); LOGGER.debug("exit from transfer(). Returning result {} ", task);
} }
} }
@ -436,7 +434,7 @@ public class TaskServiceImpl implements TaskService {
public BulkOperationResults<String, TaskanaException> transferTasks(String destinationWorkbasketId, public BulkOperationResults<String, TaskanaException> transferTasks(String destinationWorkbasketId,
List<String> taskIds) throws NotAuthorizedException, InvalidArgumentException, WorkbasketNotFoundException { List<String> taskIds) throws NotAuthorizedException, InvalidArgumentException, WorkbasketNotFoundException {
try { try {
taskanaEngineImpl.openConnection(); taskanaEngine.openConnection();
LOGGER.debug("entry to transferBulk(targetWbId = {}, taskIds = {})", destinationWorkbasketId, taskIds); LOGGER.debug("entry to transferBulk(targetWbId = {}, taskIds = {})", destinationWorkbasketId, taskIds);
// Check pre-conditions with trowing Exceptions // Check pre-conditions with trowing Exceptions
if (destinationWorkbasketId == null || taskIds == null) { if (destinationWorkbasketId == null || taskIds == null) {
@ -448,7 +446,7 @@ public class TaskServiceImpl implements TaskService {
return transferTasks(taskIds, destinationWorkbasket); return transferTasks(taskIds, destinationWorkbasket);
} finally { } finally {
LOGGER.debug("exit from transferBulk(targetWbKey = {}, taskIds = {})", destinationWorkbasketId, taskIds); LOGGER.debug("exit from transferBulk(targetWbKey = {}, taskIds = {})", destinationWorkbasketId, taskIds);
taskanaEngineImpl.returnConnection(); taskanaEngine.returnConnection();
} }
} }
@ -457,7 +455,7 @@ public class TaskServiceImpl implements TaskService {
String destinationWorkbasketDomain, List<String> taskIds) String destinationWorkbasketDomain, List<String> taskIds)
throws NotAuthorizedException, InvalidArgumentException, WorkbasketNotFoundException { throws NotAuthorizedException, InvalidArgumentException, WorkbasketNotFoundException {
try { try {
taskanaEngineImpl.openConnection(); taskanaEngine.openConnection();
LOGGER.debug("entry to transferBulk(targetWbKey = {}, domain = {}, taskIds = {})", destinationWorkbasketKey, LOGGER.debug("entry to transferBulk(targetWbKey = {}, domain = {}, taskIds = {})", destinationWorkbasketKey,
destinationWorkbasketDomain, taskIds); destinationWorkbasketDomain, taskIds);
// Check pre-conditions with trowing Exceptions // Check pre-conditions with trowing Exceptions
@ -472,7 +470,7 @@ public class TaskServiceImpl implements TaskService {
} finally { } finally {
LOGGER.debug("exit from transferBulk(targetWbKey = {}, taskIds = {})", destinationWorkbasketKey, LOGGER.debug("exit from transferBulk(targetWbKey = {}, taskIds = {})", destinationWorkbasketKey,
destinationWorkbasketDomain, taskIds); destinationWorkbasketDomain, taskIds);
taskanaEngineImpl.returnConnection(); taskanaEngine.returnConnection();
} }
} }
@ -545,7 +543,7 @@ public class TaskServiceImpl implements TaskService {
LOGGER.debug("entry to setTaskRead(taskId = {}, isRead = {})", taskId, isRead); LOGGER.debug("entry to setTaskRead(taskId = {}, isRead = {})", taskId, isRead);
Task result = null; Task result = null;
try { try {
taskanaEngineImpl.openConnection(); taskanaEngine.openConnection();
TaskImpl task = (TaskImpl) getTask(taskId); TaskImpl task = (TaskImpl) getTask(taskId);
task.setRead(true); task.setRead(true);
task.setModified(Instant.now()); task.setModified(Instant.now());
@ -554,7 +552,7 @@ public class TaskServiceImpl implements TaskService {
LOGGER.debug("Method setTaskRead() set read property of Task '{}' to {} ", result, isRead); LOGGER.debug("Method setTaskRead() set read property of Task '{}' to {} ", result, isRead);
return result; return result;
} finally { } finally {
taskanaEngineImpl.returnConnection(); taskanaEngine.returnConnection();
LOGGER.debug("exit from setTaskRead(taskId, isRead). Returning result {} ", result); LOGGER.debug("exit from setTaskRead(taskId, isRead). Returning result {} ", result);
} }
} }
@ -574,7 +572,7 @@ public class TaskServiceImpl implements TaskService {
TaskImpl newTaskImpl = (TaskImpl) task; TaskImpl newTaskImpl = (TaskImpl) task;
TaskImpl oldTaskImpl = null; TaskImpl oldTaskImpl = null;
try { try {
taskanaEngineImpl.openConnection(); taskanaEngine.openConnection();
oldTaskImpl = (TaskImpl) getTask(newTaskImpl.getId()); oldTaskImpl = (TaskImpl) getTask(newTaskImpl.getId());
standardUpdateActions(oldTaskImpl, newTaskImpl); standardUpdateActions(oldTaskImpl, newTaskImpl);
handleAttachmentsOnTaskUpdate(oldTaskImpl, newTaskImpl); handleAttachmentsOnTaskUpdate(oldTaskImpl, newTaskImpl);
@ -584,7 +582,7 @@ public class TaskServiceImpl implements TaskService {
LOGGER.debug("Method updateTask() updated task '{}' for user '{}'.", task.getId(), userId); LOGGER.debug("Method updateTask() updated task '{}' for user '{}'.", task.getId(), userId);
} finally { } finally {
taskanaEngineImpl.returnConnection(); taskanaEngine.returnConnection();
LOGGER.debug("exit from claim()"); LOGGER.debug("exit from claim()");
} }
return task; return task;
@ -914,16 +912,18 @@ public class TaskServiceImpl implements TaskService {
} }
@Override @Override
public void deleteTask(String taskId) throws TaskNotFoundException, InvalidStateException { public void deleteTask(String taskId) throws TaskNotFoundException, InvalidStateException, NotAuthorizedException {
deleteTask(taskId, false); deleteTask(taskId, false);
} }
@Override @Override
public void deleteTask(String taskId, boolean forceDelete) throws TaskNotFoundException, InvalidStateException { public void deleteTask(String taskId, boolean forceDelete)
throws TaskNotFoundException, InvalidStateException, NotAuthorizedException {
LOGGER.debug("entry to deleteTask(taskId = {} , forceDelete = {} )", taskId, forceDelete); LOGGER.debug("entry to deleteTask(taskId = {} , forceDelete = {} )", taskId, forceDelete);
taskanaEngine.checkRoleMembership(TaskanaRole.ADMIN);
TaskImpl task = null; TaskImpl task = null;
try { try {
taskanaEngineImpl.openConnection(); taskanaEngine.openConnection();
task = (TaskImpl) getTask(taskId); task = (TaskImpl) getTask(taskId);
// reset read flag and set transferred flag // reset read flag and set transferred flag
@ -936,7 +936,7 @@ public class TaskServiceImpl implements TaskService {
taskMapper.delete(taskId); taskMapper.delete(taskId);
LOGGER.debug("Method deleteTask() deleted Task {}", taskId); LOGGER.debug("Method deleteTask() deleted Task {}", taskId);
} finally { } finally {
taskanaEngineImpl.returnConnection(); taskanaEngine.returnConnection();
LOGGER.debug("exit from deleteTask(). "); LOGGER.debug("exit from deleteTask(). ");
} }
} }
@ -948,7 +948,7 @@ public class TaskServiceImpl implements TaskService {
LOGGER.debug("entry to deleteTasks(tasks = {})", LoggerUtils.listToString(taskIds)); LOGGER.debug("entry to deleteTasks(tasks = {})", LoggerUtils.listToString(taskIds));
} }
try { try {
taskanaEngineImpl.openConnection(); taskanaEngine.openConnection();
if (taskIds == null) { if (taskIds == null) {
throw new InvalidArgumentException("TaskIds can´t be NULL as parameter for deleteTasks()."); throw new InvalidArgumentException("TaskIds can´t be NULL as parameter for deleteTasks().");
} }
@ -985,7 +985,7 @@ public class TaskServiceImpl implements TaskService {
return bulkLog; return bulkLog;
} finally { } finally {
LOGGER.debug("exit from deleteTasks()"); LOGGER.debug("exit from deleteTasks()");
taskanaEngineImpl.returnConnection(); taskanaEngine.returnConnection();
} }
} }

View File

@ -38,6 +38,7 @@ import pro.taskana.WorkbasketService;
import pro.taskana.configuration.TaskanaEngineConfiguration; import pro.taskana.configuration.TaskanaEngineConfiguration;
import pro.taskana.exceptions.AutocommitFailedException; import pro.taskana.exceptions.AutocommitFailedException;
import pro.taskana.exceptions.ConnectionNotSetException; import pro.taskana.exceptions.ConnectionNotSetException;
import pro.taskana.exceptions.NotAuthorizedException;
import pro.taskana.exceptions.SystemException; import pro.taskana.exceptions.SystemException;
import pro.taskana.exceptions.UnsupportedDatabaseException; import pro.taskana.exceptions.UnsupportedDatabaseException;
import pro.taskana.impl.persistence.MapTypeHandler; import pro.taskana.impl.persistence.MapTypeHandler;
@ -51,6 +52,7 @@ import pro.taskana.mappings.TaskMapper;
import pro.taskana.mappings.TaskMonitorMapper; import pro.taskana.mappings.TaskMonitorMapper;
import pro.taskana.mappings.WorkbasketAccessMapper; import pro.taskana.mappings.WorkbasketAccessMapper;
import pro.taskana.mappings.WorkbasketMapper; import pro.taskana.mappings.WorkbasketMapper;
import pro.taskana.security.CurrentUserContext;
/** /**
* This is the implementation of TaskanaEngine. * This is the implementation of TaskanaEngine.
@ -230,6 +232,47 @@ public class TaskanaEngineImpl implements TaskanaEngine {
return this.sessionManager; return this.sessionManager;
} }
/**
* Checks whether current user is member of any of the specified roles.
*
* @param roles
* The roles that are checked for membership of the current user
* @throws NotAuthorizedException
* If the current user is not member of any specified role
*/
void checkRoleMembership(TaskanaRole... roles) throws NotAuthorizedException {
if (isUserInRole(roles)) {
return;
} else {
throw new NotAuthorizedException("current user is not member of role(s) " + Arrays.toString(roles));
}
}
/**
* check whether the current user is member of one of the roles specified.
*
* @param roles
* The roles that are checked for membership of the current user
* @return true if the current user is a member of at least one of the specified groups
*/
boolean isUserInRole(TaskanaRole... roles) {
if (!getConfiguration().isSecurityEnabled()) {
return true;
} else {
List<String> accessIds = CurrentUserContext.getAccessIds();
Set<String> rolesMembers = new HashSet<>();
for (TaskanaRole role : roles) {
rolesMembers.addAll(roleMap.get(role));
}
for (String accessId : accessIds) {
if (rolesMembers.contains(accessId)) {
return true;
}
}
return false;
}
}
/** /**
* This method creates the sqlSessionManager of myBatis. It integrates all the SQL mappers and sets the databaseId * This method creates the sqlSessionManager of myBatis. It integrates all the SQL mappers and sets the databaseId
* attribute. * attribute.
@ -332,7 +375,7 @@ public class TaskanaEngineImpl implements TaskanaEngine {
String token = st.nextToken().toLowerCase().trim(); String token = st.nextToken().toLowerCase().trim();
roleMemberSet.add(token); roleMemberSet.add(token);
} }
TaskanaRole key = TaskanaRole.fromProperyName(propertyName); TaskanaRole key = TaskanaRole.fromPropertyName(propertyName);
if (key != null) { if (key != null) {
roleMap.put(key, roleMemberSet); roleMap.put(key, roleMemberSet);
} else { } else {

View File

@ -14,7 +14,7 @@ public enum TaskanaRole {
this.propertyName = propertyName; this.propertyName = propertyName;
} }
public static TaskanaRole fromProperyName(String name) { public static TaskanaRole fromPropertyName(String name) {
if (USER.propertyName.equalsIgnoreCase(name)) { if (USER.propertyName.equalsIgnoreCase(name)) {
return TaskanaRole.USER; return TaskanaRole.USER;
} else if (BUSINESS_ADMIN.propertyName.equalsIgnoreCase(name)) { } else if (BUSINESS_ADMIN.propertyName.equalsIgnoreCase(name)) {

View File

@ -29,11 +29,11 @@ public class WorkbasketAccessItemQueryImpl implements WorkbasketAccessItemQuery
private String[] workbasketIdIn; private String[] workbasketIdIn;
private String[] idIn; private String[] idIn;
private TaskanaEngineImpl taskanaEngineImpl; private TaskanaEngineImpl taskanaEngine;
private List<String> orderBy; private List<String> orderBy;
WorkbasketAccessItemQueryImpl(TaskanaEngine taskanaEngine) { WorkbasketAccessItemQueryImpl(TaskanaEngine taskanaEngine) {
this.taskanaEngineImpl = (TaskanaEngineImpl) taskanaEngine; this.taskanaEngine = (TaskanaEngineImpl) taskanaEngine;
orderBy = new ArrayList<>(); orderBy = new ArrayList<>();
} }
@ -76,13 +76,13 @@ public class WorkbasketAccessItemQueryImpl implements WorkbasketAccessItemQuery
LOGGER.debug("entry to list(), this = {}", this); LOGGER.debug("entry to list(), this = {}", this);
List<WorkbasketAccessItem> result = new ArrayList<>(); List<WorkbasketAccessItem> result = new ArrayList<>();
try { try {
taskanaEngineImpl.openConnection(); taskanaEngine.openConnection();
List<WorkbasketAccessItemImpl> foundAccessItms = taskanaEngineImpl.getSqlSession() List<WorkbasketAccessItemImpl> foundAccessItms = taskanaEngine.getSqlSession()
.selectList(LINK_TO_MAPPER, this); .selectList(LINK_TO_MAPPER, this);
result.addAll(foundAccessItms); result.addAll(foundAccessItms);
return result; return result;
} finally { } finally {
taskanaEngineImpl.returnConnection(); taskanaEngine.returnConnection();
if (LOGGER.isDebugEnabled()) { if (LOGGER.isDebugEnabled()) {
int numberOfResultObjects = result == null ? 0 : result.size(); int numberOfResultObjects = result == null ? 0 : result.size();
LOGGER.debug("exit from list(). Returning {} resulting Objects: {} ", numberOfResultObjects, LOGGER.debug("exit from list(). Returning {} resulting Objects: {} ", numberOfResultObjects,
@ -96,9 +96,9 @@ public class WorkbasketAccessItemQueryImpl implements WorkbasketAccessItemQuery
LOGGER.debug("entry to list(offset = {}, limit = {}), this = {}", offset, limit, this); LOGGER.debug("entry to list(offset = {}, limit = {}), this = {}", offset, limit, this);
List<WorkbasketAccessItem> result = new ArrayList<>(); List<WorkbasketAccessItem> result = new ArrayList<>();
try { try {
taskanaEngineImpl.openConnection(); taskanaEngine.openConnection();
RowBounds rowBounds = new RowBounds(offset, limit); RowBounds rowBounds = new RowBounds(offset, limit);
List<WorkbasketAccessItemImpl> foundAccessItms = taskanaEngineImpl.getSqlSession() List<WorkbasketAccessItemImpl> foundAccessItms = taskanaEngine.getSqlSession()
.selectList(LINK_TO_MAPPER, this, rowBounds); .selectList(LINK_TO_MAPPER, this, rowBounds);
result.addAll(foundAccessItms); result.addAll(foundAccessItms);
return result; return result;
@ -111,7 +111,7 @@ public class WorkbasketAccessItemQueryImpl implements WorkbasketAccessItemQuery
} }
throw e; throw e;
} finally { } finally {
taskanaEngineImpl.returnConnection(); taskanaEngine.returnConnection();
if (LOGGER.isDebugEnabled()) { if (LOGGER.isDebugEnabled()) {
int numberOfResultObjects = result == null ? 0 : result.size(); int numberOfResultObjects = result == null ? 0 : result.size();
LOGGER.debug("exit from list(offset,limit). Returning {} resulting Objects: {} ", numberOfResultObjects, LOGGER.debug("exit from list(offset,limit). Returning {} resulting Objects: {} ", numberOfResultObjects,
@ -125,11 +125,11 @@ public class WorkbasketAccessItemQueryImpl implements WorkbasketAccessItemQuery
LOGGER.debug("entry to single(), this = {}", this); LOGGER.debug("entry to single(), this = {}", this);
WorkbasketAccessItem accessItm = null; WorkbasketAccessItem accessItm = null;
try { try {
taskanaEngineImpl.openConnection(); taskanaEngine.openConnection();
accessItm = taskanaEngineImpl.getSqlSession().selectOne(LINK_TO_MAPPER, this); accessItm = taskanaEngine.getSqlSession().selectOne(LINK_TO_MAPPER, this);
return accessItm; return accessItm;
} finally { } finally {
taskanaEngineImpl.returnConnection(); taskanaEngine.returnConnection();
LOGGER.debug("exit from single(). Returning result {} ", accessItm); LOGGER.debug("exit from single(). Returning result {} ", accessItm);
} }
} }
@ -139,11 +139,11 @@ public class WorkbasketAccessItemQueryImpl implements WorkbasketAccessItemQuery
LOGGER.debug("entry to count(), this = {}", this); LOGGER.debug("entry to count(), this = {}", this);
Long rowCount = null; Long rowCount = null;
try { try {
taskanaEngineImpl.openConnection(); taskanaEngine.openConnection();
rowCount = taskanaEngineImpl.getSqlSession().selectOne(LINK_TO_COUNTER, this); rowCount = taskanaEngine.getSqlSession().selectOne(LINK_TO_COUNTER, this);
return (rowCount == null) ? 0L : rowCount; return (rowCount == null) ? 0L : rowCount;
} finally { } finally {
taskanaEngineImpl.returnConnection(); taskanaEngine.returnConnection();
LOGGER.debug("exit from count(). Returning result {} ", rowCount); LOGGER.debug("exit from count(). Returning result {} ", rowCount);
} }
} }

View File

@ -15,6 +15,7 @@ import pro.taskana.WorkbasketQuery;
import pro.taskana.WorkbasketSummary; import pro.taskana.WorkbasketSummary;
import pro.taskana.configuration.TaskanaEngineConfiguration; import pro.taskana.configuration.TaskanaEngineConfiguration;
import pro.taskana.exceptions.InvalidArgumentException; import pro.taskana.exceptions.InvalidArgumentException;
import pro.taskana.exceptions.NotAuthorizedException;
import pro.taskana.exceptions.TaskanaRuntimeException; import pro.taskana.exceptions.TaskanaRuntimeException;
import pro.taskana.impl.util.LoggerUtils; import pro.taskana.impl.util.LoggerUtils;
import pro.taskana.security.CurrentUserContext; import pro.taskana.security.CurrentUserContext;
@ -60,11 +61,11 @@ public class WorkbasketQueryImpl implements WorkbasketQuery {
private String[] orgLevel3Like; private String[] orgLevel3Like;
private String[] orgLevel4In; private String[] orgLevel4In;
private String[] orgLevel4Like; private String[] orgLevel4Like;
private TaskanaEngineImpl taskanaEngineImpl; private TaskanaEngineImpl taskanaEngine;
private List<String> orderBy; private List<String> orderBy;
WorkbasketQueryImpl(TaskanaEngine taskanaEngine) { WorkbasketQueryImpl(TaskanaEngine taskanaEngine) {
this.taskanaEngineImpl = (TaskanaEngineImpl) taskanaEngine; this.taskanaEngine = (TaskanaEngineImpl) taskanaEngine;
this.orderBy = new ArrayList<>(); this.orderBy = new ArrayList<>();
} }
@ -324,7 +325,8 @@ public class WorkbasketQueryImpl implements WorkbasketQuery {
@Override @Override
public WorkbasketQuery accessIdsHavePermission(WorkbasketAuthorization permission, String... accessIds) public WorkbasketQuery accessIdsHavePermission(WorkbasketAuthorization permission, String... accessIds)
throws InvalidArgumentException { throws InvalidArgumentException, NotAuthorizedException {
taskanaEngine.checkRoleMembership(TaskanaRole.ADMIN, TaskanaRole.BUSINESS_ADMIN);
// Checking pre-conditions // Checking pre-conditions
if (permission == null) { if (permission == null) {
throw new InvalidArgumentException("Permission can´t be null."); throw new InvalidArgumentException("Permission can´t be null.");
@ -352,12 +354,12 @@ public class WorkbasketQueryImpl implements WorkbasketQuery {
LOGGER.debug("entry to list(), this = {}", this); LOGGER.debug("entry to list(), this = {}", this);
List<WorkbasketSummary> workbaskets = null; List<WorkbasketSummary> workbaskets = null;
try { try {
taskanaEngineImpl.openConnection(); taskanaEngine.openConnection();
addAccessIdsOfCallerToQuery(); addAccessIdsOfCallerToQuery();
workbaskets = taskanaEngineImpl.getSqlSession().selectList(LINK_TO_MAPPER, this); workbaskets = taskanaEngine.getSqlSession().selectList(LINK_TO_MAPPER, this);
return workbaskets; return workbaskets;
} finally { } finally {
taskanaEngineImpl.returnConnection(); taskanaEngine.returnConnection();
if (LOGGER.isDebugEnabled()) { if (LOGGER.isDebugEnabled()) {
int numberOfResultObjects = workbaskets == null ? 0 : workbaskets.size(); int numberOfResultObjects = workbaskets == null ? 0 : workbaskets.size();
LOGGER.debug("exit from list(). Returning {} resulting Objects: {} ", numberOfResultObjects, LOGGER.debug("exit from list(). Returning {} resulting Objects: {} ", numberOfResultObjects,
@ -371,10 +373,10 @@ public class WorkbasketQueryImpl implements WorkbasketQuery {
LOGGER.debug("entry to list(offset = {}, limit = {}), this = {}", offset, limit, this); LOGGER.debug("entry to list(offset = {}, limit = {}), this = {}", offset, limit, this);
List<WorkbasketSummary> workbaskets = null; List<WorkbasketSummary> workbaskets = null;
try { try {
taskanaEngineImpl.openConnection(); taskanaEngine.openConnection();
RowBounds rowBounds = new RowBounds(offset, limit); RowBounds rowBounds = new RowBounds(offset, limit);
addAccessIdsOfCallerToQuery(); addAccessIdsOfCallerToQuery();
workbaskets = taskanaEngineImpl.getSqlSession().selectList(LINK_TO_MAPPER, this, rowBounds); workbaskets = taskanaEngine.getSqlSession().selectList(LINK_TO_MAPPER, this, rowBounds);
return workbaskets; return workbaskets;
} catch (Exception e) { } catch (Exception e) {
if (e instanceof PersistenceException) { if (e instanceof PersistenceException) {
@ -387,7 +389,7 @@ public class WorkbasketQueryImpl implements WorkbasketQuery {
} }
throw e; throw e;
} finally { } finally {
taskanaEngineImpl.returnConnection(); taskanaEngine.returnConnection();
if (LOGGER.isDebugEnabled()) { if (LOGGER.isDebugEnabled()) {
int numberOfResultObjects = workbaskets == null ? 0 : workbaskets.size(); int numberOfResultObjects = workbaskets == null ? 0 : workbaskets.size();
LOGGER.debug("exit from list(offset,limit). Returning {} resulting Objects: {} ", numberOfResultObjects, LOGGER.debug("exit from list(offset,limit). Returning {} resulting Objects: {} ", numberOfResultObjects,
@ -401,12 +403,12 @@ public class WorkbasketQueryImpl implements WorkbasketQuery {
LOGGER.debug("entry to single(), this = {}", this); LOGGER.debug("entry to single(), this = {}", this);
WorkbasketSummary workbasket = null; WorkbasketSummary workbasket = null;
try { try {
taskanaEngineImpl.openConnection(); taskanaEngine.openConnection();
addAccessIdsOfCallerToQuery(); addAccessIdsOfCallerToQuery();
workbasket = taskanaEngineImpl.getSqlSession().selectOne(LINK_TO_MAPPER, this); workbasket = taskanaEngine.getSqlSession().selectOne(LINK_TO_MAPPER, this);
return workbasket; return workbasket;
} finally { } finally {
taskanaEngineImpl.returnConnection(); taskanaEngine.returnConnection();
LOGGER.debug("exit from single(). Returning result {} ", workbasket); LOGGER.debug("exit from single(). Returning result {} ", workbasket);
} }
} }
@ -544,12 +546,12 @@ public class WorkbasketQueryImpl implements WorkbasketQuery {
LOGGER.debug("entry to count(), this = {}", this); LOGGER.debug("entry to count(), this = {}", this);
Long rowCount = null; Long rowCount = null;
try { try {
taskanaEngineImpl.openConnection(); taskanaEngine.openConnection();
addAccessIdsOfCallerToQuery(); addAccessIdsOfCallerToQuery();
rowCount = taskanaEngineImpl.getSqlSession().selectOne(LINK_TO_COUNTER, this); rowCount = taskanaEngine.getSqlSession().selectOne(LINK_TO_COUNTER, this);
return (rowCount == null) ? 0L : rowCount; return (rowCount == null) ? 0L : rowCount;
} finally { } finally {
taskanaEngineImpl.returnConnection(); taskanaEngine.returnConnection();
LOGGER.debug("exit from count(). Returning result {} ", rowCount); LOGGER.debug("exit from count(). Returning result {} ", rowCount);
} }
} }

View File

@ -126,8 +126,9 @@ public class WorkbasketServiceImpl implements WorkbasketService {
@Override @Override
public Workbasket createWorkbasket(Workbasket newWorkbasket) public Workbasket createWorkbasket(Workbasket newWorkbasket)
throws InvalidWorkbasketException { throws InvalidWorkbasketException, NotAuthorizedException {
LOGGER.debug("entry to createtWorkbasket(workbasket)", newWorkbasket); LOGGER.debug("entry to createtWorkbasket(workbasket)", newWorkbasket);
taskanaEngine.checkRoleMembership(TaskanaRole.BUSINESS_ADMIN, TaskanaRole.ADMIN);
Workbasket result = null; Workbasket result = null;
WorkbasketImpl workbasket = (WorkbasketImpl) newWorkbasket; WorkbasketImpl workbasket = (WorkbasketImpl) newWorkbasket;
try { try {
@ -154,6 +155,7 @@ public class WorkbasketServiceImpl implements WorkbasketService {
public Workbasket updateWorkbasket(Workbasket workbasketToUpdate) public Workbasket updateWorkbasket(Workbasket workbasketToUpdate)
throws NotAuthorizedException, WorkbasketNotFoundException, InvalidWorkbasketException { throws NotAuthorizedException, WorkbasketNotFoundException, InvalidWorkbasketException {
LOGGER.debug("entry to updateWorkbasket(workbasket)", workbasketToUpdate); LOGGER.debug("entry to updateWorkbasket(workbasket)", workbasketToUpdate);
taskanaEngine.checkRoleMembership(TaskanaRole.BUSINESS_ADMIN, TaskanaRole.ADMIN);
Workbasket result = null; Workbasket result = null;
WorkbasketImpl workbasket = (WorkbasketImpl) workbasketToUpdate; WorkbasketImpl workbasket = (WorkbasketImpl) workbasketToUpdate;
@ -180,8 +182,9 @@ public class WorkbasketServiceImpl implements WorkbasketService {
@Override @Override
public WorkbasketAccessItem createWorkbasketAuthorization(WorkbasketAccessItem workbasketAccessItem) public WorkbasketAccessItem createWorkbasketAuthorization(WorkbasketAccessItem workbasketAccessItem)
throws InvalidArgumentException { throws InvalidArgumentException, NotAuthorizedException {
LOGGER.debug("entry to createWorkbasketAuthorization(workbasketAccessItem = {})", workbasketAccessItem); LOGGER.debug("entry to createWorkbasketAuthorization(workbasketAccessItem = {})", workbasketAccessItem);
taskanaEngine.checkRoleMembership(TaskanaRole.BUSINESS_ADMIN, TaskanaRole.ADMIN);
WorkbasketAccessItemImpl accessItem = (WorkbasketAccessItemImpl) workbasketAccessItem; WorkbasketAccessItemImpl accessItem = (WorkbasketAccessItemImpl) workbasketAccessItem;
try { try {
taskanaEngine.openConnection(); taskanaEngine.openConnection();
@ -243,8 +246,9 @@ public class WorkbasketServiceImpl implements WorkbasketService {
} }
@Override @Override
public void deleteWorkbasketAuthorization(String accessItemId) { public void deleteWorkbasketAuthorization(String accessItemId) throws NotAuthorizedException {
LOGGER.debug("entry to deleteWorkbasketAuthorization(id = {})", accessItemId); LOGGER.debug("entry to deleteWorkbasketAuthorization(id = {})", accessItemId);
taskanaEngine.checkRoleMembership(TaskanaRole.BUSINESS_ADMIN, TaskanaRole.ADMIN);
try { try {
taskanaEngine.openConnection(); taskanaEngine.openConnection();
workbasketAccessMapper.delete(accessItemId); workbasketAccessMapper.delete(accessItemId);
@ -282,8 +286,9 @@ public class WorkbasketServiceImpl implements WorkbasketService {
@Override @Override
public WorkbasketAccessItem updateWorkbasketAuthorization(WorkbasketAccessItem workbasketAccessItem) public WorkbasketAccessItem updateWorkbasketAuthorization(WorkbasketAccessItem workbasketAccessItem)
throws InvalidArgumentException { throws InvalidArgumentException, NotAuthorizedException {
LOGGER.debug("entry to updateWorkbasketAuthorization(workbasketAccessItem = {}", workbasketAccessItem); LOGGER.debug("entry to updateWorkbasketAuthorization(workbasketAccessItem = {}", workbasketAccessItem);
taskanaEngine.checkRoleMembership(TaskanaRole.BUSINESS_ADMIN, TaskanaRole.ADMIN);
WorkbasketAccessItemImpl accessItem = (WorkbasketAccessItemImpl) workbasketAccessItem; WorkbasketAccessItemImpl accessItem = (WorkbasketAccessItemImpl) workbasketAccessItem;
try { try {
taskanaEngine.openConnection(); taskanaEngine.openConnection();
@ -526,6 +531,7 @@ public class WorkbasketServiceImpl implements WorkbasketService {
sourceWorkbasketId, sourceWorkbasketId,
LoggerUtils.listToString(targetWorkbasketIds)); LoggerUtils.listToString(targetWorkbasketIds));
} }
taskanaEngine.checkRoleMembership(TaskanaRole.BUSINESS_ADMIN, TaskanaRole.ADMIN);
try { try {
taskanaEngine.openConnection(); taskanaEngine.openConnection();
// check existence of source workbasket // check existence of source workbasket
@ -561,6 +567,7 @@ public class WorkbasketServiceImpl implements WorkbasketService {
throws NotAuthorizedException, WorkbasketNotFoundException { throws NotAuthorizedException, WorkbasketNotFoundException {
LOGGER.debug("entry to addDistributionTarget(sourceWorkbasketId = {}, targetWorkbasketId = {})", LOGGER.debug("entry to addDistributionTarget(sourceWorkbasketId = {}, targetWorkbasketId = {})",
sourceWorkbasketId, targetWorkbasketId); sourceWorkbasketId, targetWorkbasketId);
taskanaEngine.checkRoleMembership(TaskanaRole.BUSINESS_ADMIN, TaskanaRole.ADMIN);
try { try {
taskanaEngine.openConnection(); taskanaEngine.openConnection();
// check existence of source workbasket // check existence of source workbasket
@ -594,6 +601,7 @@ public class WorkbasketServiceImpl implements WorkbasketService {
throws NotAuthorizedException { throws NotAuthorizedException {
LOGGER.debug("entry to removeDistributionTarget(sourceWorkbasketId = {}, targetWorkbasketId = {})", LOGGER.debug("entry to removeDistributionTarget(sourceWorkbasketId = {}, targetWorkbasketId = {})",
sourceWorkbasketId, targetWorkbasketId); sourceWorkbasketId, targetWorkbasketId);
taskanaEngine.checkRoleMembership(TaskanaRole.BUSINESS_ADMIN, TaskanaRole.ADMIN);
try { try {
taskanaEngine.openConnection(); taskanaEngine.openConnection();
// don't check existence of source / target workbasket to enable cleanup even if the db is corrupted // don't check existence of source / target workbasket to enable cleanup even if the db is corrupted
@ -630,6 +638,7 @@ public class WorkbasketServiceImpl implements WorkbasketService {
public void deleteWorkbasket(String workbasketId) public void deleteWorkbasket(String workbasketId)
throws NotAuthorizedException, WorkbasketNotFoundException, WorkbasketInUseException, InvalidArgumentException { throws NotAuthorizedException, WorkbasketNotFoundException, WorkbasketInUseException, InvalidArgumentException {
LOGGER.debug("entry to deleteWorkbasket(workbasketId = {})", workbasketId); LOGGER.debug("entry to deleteWorkbasket(workbasketId = {})", workbasketId);
taskanaEngine.checkRoleMembership(TaskanaRole.BUSINESS_ADMIN, TaskanaRole.ADMIN);
try { try {
taskanaEngine.openConnection(); taskanaEngine.openConnection();
if (workbasketId == null || workbasketId.isEmpty()) { if (workbasketId == null || workbasketId.isEmpty()) {
@ -659,7 +668,8 @@ public class WorkbasketServiceImpl implements WorkbasketService {
} }
@Override @Override
public WorkbasketAccessItemQuery createWorkbasketAccessItemQuery() { public WorkbasketAccessItemQuery createWorkbasketAccessItemQuery() throws NotAuthorizedException {
taskanaEngine.checkRoleMembership(TaskanaRole.ADMIN, TaskanaRole.BUSINESS_ADMIN);
return new WorkbasketAccessItemQueryImpl(this.taskanaEngine); return new WorkbasketAccessItemQueryImpl(this.taskanaEngine);
} }
@ -671,6 +681,11 @@ public class WorkbasketServiceImpl implements WorkbasketService {
if (workbasketAuthorization == null) { if (workbasketAuthorization == null) {
throw new SystemException("checkAuthorization was called with an invalid parameter combination"); throw new SystemException("checkAuthorization was called with an invalid parameter combination");
} }
if (taskanaEngine.isUserInRole(TaskanaRole.ADMIN)) {
LOGGER.debug("Skipping permissions check since user is in role ADMIN.");
return;
}
boolean isAuthorized = false; boolean isAuthorized = false;
try { try {
taskanaEngine.openConnection(); taskanaEngine.openConnection();

View File

@ -4,6 +4,7 @@ import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotEquals; import static org.junit.Assert.assertNotEquals;
import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue; import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
import java.sql.SQLException; import java.sql.SQLException;
@ -34,6 +35,9 @@ public class DeleteClassificationAccTest extends AbstractAccTest {
classificationService = taskanaEngine.getClassificationService(); classificationService = taskanaEngine.getClassificationService();
} }
@WithAccessId(
userName = "dummy",
groupNames = {"businessadmin"})
@Test @Test
public void testDeleteClassificationInDomain() public void testDeleteClassificationInDomain()
throws SQLException, ClassificationNotFoundException, NotAuthorizedException, ClassificationInUseException { throws SQLException, ClassificationNotFoundException, NotAuthorizedException, ClassificationInUseException {
@ -47,6 +51,16 @@ public class DeleteClassificationAccTest extends AbstractAccTest {
@WithAccessId( @WithAccessId(
userName = "teamlead_1", userName = "teamlead_1",
groupNames = {"group_1", "group_2"}) groupNames = {"group_1", "group_2"})
@Test(expected = NotAuthorizedException.class)
public void testDeleteClassificationInDomainUserIsNotAuthorized()
throws SQLException, ClassificationNotFoundException, NotAuthorizedException, ClassificationInUseException {
classificationService.deleteClassification("L140101", "DOMAIN_A");
fail("NotAuthorizedException should have been thrown");
}
@WithAccessId(
userName = "teamlead_1",
groupNames = {"group_1", "businessadmin"})
@Test(expected = ClassificationInUseException.class) @Test(expected = ClassificationInUseException.class)
public void testThrowExeptionIfDeleteClassificationWithExistingTasks() public void testThrowExeptionIfDeleteClassificationWithExistingTasks()
throws SQLException, ClassificationNotFoundException, NotAuthorizedException, ClassificationInUseException { throws SQLException, ClassificationNotFoundException, NotAuthorizedException, ClassificationInUseException {
@ -55,13 +69,16 @@ public class DeleteClassificationAccTest extends AbstractAccTest {
@WithAccessId( @WithAccessId(
userName = "teamlead_1", userName = "teamlead_1",
groupNames = {"group_1", "group_2"}) groupNames = {"group_1", "businessadmin"})
@Test(expected = ClassificationInUseException.class) @Test(expected = ClassificationInUseException.class)
public void testThrowExeptionIfDeleteMasterClassificationWithExistingTasks() public void testThrowExeptionIfDeleteMasterClassificationWithExistingTasks()
throws SQLException, ClassificationNotFoundException, NotAuthorizedException, ClassificationInUseException { throws SQLException, ClassificationNotFoundException, NotAuthorizedException, ClassificationInUseException {
classificationService.deleteClassification("L1050", ""); classificationService.deleteClassification("L1050", "");
} }
@WithAccessId(
userName = "dummy",
groupNames = {"businessadmin"})
@Test @Test
public void testDeleteMasterClassification() public void testDeleteMasterClassification()
throws SQLException, ClassificationNotFoundException, NotAuthorizedException, ClassificationInUseException { throws SQLException, ClassificationNotFoundException, NotAuthorizedException, ClassificationInUseException {
@ -78,8 +95,7 @@ public class DeleteClassificationAccTest extends AbstractAccTest {
@WithAccessId( @WithAccessId(
userName = "teamlead_1", userName = "teamlead_1",
groupNames = {"group_1"}) groupNames = {"group_1", "businessadmin"})
@Test @Test
public void testThrowExceptionWhenChildClassificationIsInUseAndRollback() public void testThrowExceptionWhenChildClassificationIsInUseAndRollback()
throws ClassificationInUseException, NotAuthorizedException, ClassificationNotFoundException { throws ClassificationInUseException, NotAuthorizedException, ClassificationNotFoundException {
@ -106,15 +122,21 @@ public class DeleteClassificationAccTest extends AbstractAccTest {
assertNotEquals(rollbackMaster.getDomain(), rollbackA.getDomain()); assertNotEquals(rollbackMaster.getDomain(), rollbackA.getDomain());
} }
@WithAccessId(
userName = "dummy",
groupNames = {"businessadmin"})
@Test(expected = ClassificationNotFoundException.class) @Test(expected = ClassificationNotFoundException.class)
public void testThrowClassificationNotFoundIfClassificationNotExists() public void testThrowClassificationNotFoundIfClassificationNotExists()
throws ClassificationNotFoundException, ClassificationInUseException { throws ClassificationNotFoundException, ClassificationInUseException, NotAuthorizedException {
classificationService.deleteClassification("not existing classification key", ""); classificationService.deleteClassification("not existing classification key", "");
} }
@WithAccessId(
userName = "dummy",
groupNames = {"businessadmin"})
@Test(expected = ClassificationNotFoundException.class) @Test(expected = ClassificationNotFoundException.class)
public void testThrowClassificationNotFoundIfClassificationNotExistsInDomain() public void testThrowClassificationNotFoundIfClassificationNotExistsInDomain()
throws ClassificationNotFoundException, ClassificationInUseException { throws ClassificationNotFoundException, ClassificationInUseException, NotAuthorizedException {
classificationService.deleteClassification("L10000", "DOMAIN_B"); classificationService.deleteClassification("L10000", "DOMAIN_B");
} }

View File

@ -33,6 +33,9 @@ public class UpdateClassificationAccTest extends AbstractAccTest {
super(); super();
} }
@WithAccessId(
userName = "dummy",
groupNames = {"businessadmin"})
@Test @Test
public void testUpdateClassification() public void testUpdateClassification()
throws SQLException, ClassificationNotFoundException, NotAuthorizedException { throws SQLException, ClassificationNotFoundException, NotAuthorizedException {
@ -67,6 +70,43 @@ public class UpdateClassificationAccTest extends AbstractAccTest {
assertThat(updatedClassification.getApplicationEntryPoint(), equalTo(newEntryPoint)); assertThat(updatedClassification.getApplicationEntryPoint(), equalTo(newEntryPoint));
} }
@Test(expected = NotAuthorizedException.class)
public void testUpdateClassificationFails()
throws SQLException, ClassificationNotFoundException, NotAuthorizedException {
String newName = "updated Name";
String newEntryPoint = "updated EntryPoint";
ClassificationService classificationService = taskanaEngine.getClassificationService();
Classification classification = classificationService.getClassification("T2100", "DOMAIN_A");
classification.setApplicationEntryPoint(newEntryPoint);
classification.setCategory("PROCESS");
classification.setCustom1("newCustom1");
classification.setCustom2("newCustom2");
classification.setCustom3("newCustom3");
classification.setCustom4("newCustom4");
classification.setCustom5("newCustom5");
classification.setCustom6("newCustom6");
classification.setCustom7("newCustom7");
classification.setCustom8("newCustom8");
classification.setDescription("newDescription");
classification.setIsValidInDomain(false);
classification.setName(newName);
classification.setParentId("T2000");
classification.setPriority(1000);
classification.setServiceLevel("P2DT3H4M");
classificationService.updateClassification(classification);
// Get and check the new value
Classification updatedClassification = classificationService.getClassification("T2100", "DOMAIN_A");
assertNotNull(updatedClassification);
assertThat(updatedClassification.getName(), equalTo(newName));
assertThat(updatedClassification.getApplicationEntryPoint(), equalTo(newEntryPoint));
}
@WithAccessId(
userName = "dummy",
groupNames = {"businessadmin"})
@Test @Test
public void testUpdateUnpersistedClassification() public void testUpdateUnpersistedClassification()
throws SQLException, ClassificationNotFoundException, NotAuthorizedException { throws SQLException, ClassificationNotFoundException, NotAuthorizedException {
@ -111,7 +151,7 @@ public class UpdateClassificationAccTest extends AbstractAccTest {
@WithAccessId( @WithAccessId(
userName = "teamlead_1", userName = "teamlead_1",
groupNames = {"group_1", "group_2"}) groupNames = {"group_1", "businessadmin"})
@Test @Test
public void testUpdateTaskOnClassificationKeyCategoryChange() public void testUpdateTaskOnClassificationKeyCategoryChange()
throws TaskNotFoundException, ClassificationNotFoundException, NotAuthorizedException { throws TaskNotFoundException, ClassificationNotFoundException, NotAuthorizedException {

View File

@ -39,8 +39,8 @@ public class TaskanaRoleConfigAccTest extends TaskanaEngineImpl {
assertTrue(users.contains("user_1_2")); assertTrue(users.contains("user_1_2"));
Set<String> admins = roleMap.get(TaskanaRole.ADMIN); Set<String> admins = roleMap.get(TaskanaRole.ADMIN);
assertTrue(admins.contains("teamlead_1")); assertTrue(admins.contains("name=konrad,organisation=novatec"));
assertTrue(admins.contains("teamlead_2")); assertTrue(admins.contains("admin"));
Set<String> businessAdmins = roleMap.get(TaskanaRole.BUSINESS_ADMIN); Set<String> businessAdmins = roleMap.get(TaskanaRole.BUSINESS_ADMIN);
assertTrue(businessAdmins.contains("max")); assertTrue(businessAdmins.contains("max"));

View File

@ -18,6 +18,7 @@ import pro.taskana.Task;
import pro.taskana.TaskService; import pro.taskana.TaskService;
import pro.taskana.exceptions.InvalidArgumentException; import pro.taskana.exceptions.InvalidArgumentException;
import pro.taskana.exceptions.InvalidStateException; import pro.taskana.exceptions.InvalidStateException;
import pro.taskana.exceptions.NotAuthorizedException;
import pro.taskana.exceptions.TaskNotFoundException; import pro.taskana.exceptions.TaskNotFoundException;
import pro.taskana.exceptions.TaskanaException; import pro.taskana.exceptions.TaskanaException;
import pro.taskana.impl.BulkOperationResults; import pro.taskana.impl.BulkOperationResults;
@ -37,8 +38,20 @@ public class DeleteTaskAccTest extends AbstractAccTest {
@WithAccessId( @WithAccessId(
userName = "user_1_2", userName = "user_1_2",
groupNames = {"group_1"}) groupNames = {"group_1"})
@Test(expected = NotAuthorizedException.class)
public void testDeleteSingleTaskNotAuthorized()
throws TaskNotFoundException, InvalidStateException, NotAuthorizedException {
TaskService taskService = taskanaEngine.getTaskService();
taskService.deleteTask("TKI:000000000000000000000000000000000037");
fail("NotAuthorizedException should have been thrown");
}
@WithAccessId(
userName = "user_1_2",
groupNames = {"group_1", "admin"})
@Test(expected = TaskNotFoundException.class) @Test(expected = TaskNotFoundException.class)
public void testDeleteSingleTask() throws TaskNotFoundException, InvalidStateException { public void testDeleteSingleTask() throws TaskNotFoundException, InvalidStateException, NotAuthorizedException {
TaskService taskService = taskanaEngine.getTaskService(); TaskService taskService = taskanaEngine.getTaskService();
Task task = taskService.getTask("TKI:000000000000000000000000000000000036"); Task task = taskService.getTask("TKI:000000000000000000000000000000000036");
@ -50,10 +63,10 @@ public class DeleteTaskAccTest extends AbstractAccTest {
@WithAccessId( @WithAccessId(
userName = "user_1_2", userName = "user_1_2",
groupNames = {"group_1"}) groupNames = {"group_1", "admin"})
@Test(expected = InvalidStateException.class) @Test(expected = InvalidStateException.class)
public void testThrowsExceptionIfTaskIsNotCompleted() public void testThrowsExceptionIfTaskIsNotCompleted()
throws TaskNotFoundException, InvalidStateException, SQLException { throws TaskNotFoundException, InvalidStateException, SQLException, NotAuthorizedException {
TaskService taskService = taskanaEngine.getTaskService(); TaskService taskService = taskanaEngine.getTaskService();
Task task = taskService.getTask("TKI:000000000000000000000000000000000029"); Task task = taskService.getTask("TKI:000000000000000000000000000000000029");
@ -62,9 +75,10 @@ public class DeleteTaskAccTest extends AbstractAccTest {
@WithAccessId( @WithAccessId(
userName = "user_1_2", userName = "user_1_2",
groupNames = {"group_1"}) groupNames = {"group_1", "admin"})
@Test(expected = TaskNotFoundException.class) @Test(expected = TaskNotFoundException.class)
public void testForceDeleteTaskIfNotCompleted() throws SQLException, TaskNotFoundException, InvalidStateException { public void testForceDeleteTaskIfNotCompleted()
throws SQLException, TaskNotFoundException, InvalidStateException, NotAuthorizedException {
TaskService taskService = taskanaEngine.getTaskService(); TaskService taskService = taskanaEngine.getTaskService();
Task task = taskService.getTask("TKI:000000000000000000000000000000000027"); Task task = taskService.getTask("TKI:000000000000000000000000000000000027");
try { try {

View File

@ -33,7 +33,7 @@ public class CreateWorkbasketAccTest extends AbstractAccTest {
@WithAccessId( @WithAccessId(
userName = "user_1_2", userName = "user_1_2",
groupNames = {"group_1"}) groupNames = {"businessadmin"})
@Test @Test
public void testCreateWorkbasket() public void testCreateWorkbasket()
throws SQLException, NotAuthorizedException, InvalidArgumentException, WorkbasketNotFoundException, throws SQLException, NotAuthorizedException, InvalidArgumentException, WorkbasketNotFoundException,
@ -60,6 +60,25 @@ public class CreateWorkbasketAccTest extends AbstractAccTest {
assertEquals(createdWorkbasket, createdWorkbasket2); assertEquals(createdWorkbasket, createdWorkbasket2);
} }
@WithAccessId(
userName = "dummy")
@Test(expected = NotAuthorizedException.class)
public void testCreateWorkbasketNotAuthorized()
throws SQLException, NotAuthorizedException, InvalidArgumentException, WorkbasketNotFoundException,
InvalidWorkbasketException {
WorkbasketService workbasketService = taskanaEngine.getWorkbasketService();
Workbasket workbasket = workbasketService.newWorkbasket("key3", "novatec");
workbasket.setName("Megabasket");
workbasket.setType(WorkbasketType.GROUP);
workbasket.setOrgLevel1("company");
workbasketService.createWorkbasket(workbasket);
fail("NotAuthorizedException should have been thrown");
}
@WithAccessId(
userName = "dummy",
groupNames = {"businessadmin"})
@Test @Test
public void testCreateWorkbasketWithMissingRequiredField() public void testCreateWorkbasketWithMissingRequiredField()
throws WorkbasketNotFoundException, NotAuthorizedException { throws WorkbasketNotFoundException, NotAuthorizedException {

View File

@ -38,7 +38,7 @@ public class DeleteWorkbasketAccTest extends AbstractAccTest {
workbasketService = taskanaEngine.getWorkbasketService(); workbasketService = taskanaEngine.getWorkbasketService();
} }
@WithAccessId(userName = "teamlead_2") @WithAccessId(userName = "teamlead_2", groupNames = {"businessadmin"})
@Test @Test
public void testDeleteWorkbasket() public void testDeleteWorkbasket()
throws WorkbasketNotFoundException, NotAuthorizedException, WorkbasketInUseException, InvalidArgumentException { throws WorkbasketNotFoundException, NotAuthorizedException, WorkbasketInUseException, InvalidArgumentException {
@ -53,7 +53,18 @@ public class DeleteWorkbasketAccTest extends AbstractAccTest {
} }
} }
@WithAccessId(userName = "user_1_1", groupNames = {"teamlead_1", "group_1"}) @WithAccessId(userName = "elena")
@Test(expected = NotAuthorizedException.class)
public void testDeleteWorkbasketNotAuthorized()
throws WorkbasketNotFoundException, NotAuthorizedException, WorkbasketInUseException, InvalidArgumentException {
Workbasket wb = workbasketService.getWorkbasket("TEAMLEAD_2", "DOMAIN_A");
workbasketService.deleteWorkbasket(wb.getId());
workbasketService.getWorkbasket("TEAMLEAD_2", "DOMAIN_A");
fail("NotAuthorizedException was expected.");
}
@WithAccessId(userName = "user_1_1", groupNames = {"teamlead_1", "group_1", "businessadmin"})
@Test @Test
public void testDeleteWorkbasketAlsoAsDistributionTarget() public void testDeleteWorkbasketAlsoAsDistributionTarget()
throws WorkbasketNotFoundException, NotAuthorizedException, WorkbasketInUseException, InvalidArgumentException { throws WorkbasketNotFoundException, NotAuthorizedException, WorkbasketInUseException, InvalidArgumentException {
@ -76,6 +87,9 @@ public class DeleteWorkbasketAccTest extends AbstractAccTest {
assertTrue(newDistTargets < distTargets); assertTrue(newDistTargets < distTargets);
} }
@WithAccessId(
userName = "dummy",
groupNames = {"businessadmin"})
@Test @Test
public void testDeleteWorkbasketWithNullOrEmptyParam() public void testDeleteWorkbasketWithNullOrEmptyParam()
throws WorkbasketNotFoundException, NotAuthorizedException, WorkbasketInUseException { throws WorkbasketNotFoundException, NotAuthorizedException, WorkbasketInUseException {
@ -96,13 +110,17 @@ public class DeleteWorkbasketAccTest extends AbstractAccTest {
} }
} }
@WithAccessId(
userName = "dummy",
groupNames = {"businessadmin"})
@Test(expected = WorkbasketNotFoundException.class) @Test(expected = WorkbasketNotFoundException.class)
public void testDeleteWorkbasketButNotExisting() public void testDeleteWorkbasketButNotExisting()
throws WorkbasketNotFoundException, NotAuthorizedException, WorkbasketInUseException, InvalidArgumentException { throws WorkbasketNotFoundException, NotAuthorizedException, WorkbasketInUseException, InvalidArgumentException {
workbasketService.deleteWorkbasket("SOME NOT EXISTING ID"); workbasketService.deleteWorkbasket("SOME NOT EXISTING ID");
} }
@WithAccessId(userName = "user_1_1") @WithAccessId(userName = "user_1_1",
groupNames = {"businessadmin"})
@Test(expected = WorkbasketInUseException.class) @Test(expected = WorkbasketInUseException.class)
public void testDeleteWorkbasketWhichIsUsed() public void testDeleteWorkbasketWhichIsUsed()
throws WorkbasketNotFoundException, NotAuthorizedException, WorkbasketInUseException, InvalidArgumentException { throws WorkbasketNotFoundException, NotAuthorizedException, WorkbasketInUseException, InvalidArgumentException {

View File

@ -2,6 +2,7 @@ package acceptance.workbasket;
import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue; import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
import java.sql.SQLException; import java.sql.SQLException;
import java.util.ArrayList; import java.util.ArrayList;
@ -84,7 +85,7 @@ public class DistributionTargetsAccTest extends AbstractAccTest {
@WithAccessId( @WithAccessId(
userName = "user_1_1", userName = "user_1_1",
groupNames = {"teamlead_1", "group_1", "group_2"}) groupNames = {"teamlead_1", "group_1", "group_2", "businessadmin"})
@Test @Test
public void testDistributionTargetCallsWithNonExistingWorkbaskets() public void testDistributionTargetCallsWithNonExistingWorkbaskets()
throws NotAuthorizedException, WorkbasketNotFoundException { throws NotAuthorizedException, WorkbasketNotFoundException {
@ -124,7 +125,7 @@ public class DistributionTargetsAccTest extends AbstractAccTest {
} }
@WithAccessId( @WithAccessId(
userName = "user_3_1") userName = "user_3_1", groupNames = {"businessadmin"})
@Test @Test
public void testDistributionTargetCallsFailWithNotAuthorizedException() public void testDistributionTargetCallsFailWithNotAuthorizedException()
throws NotAuthorizedException, WorkbasketNotFoundException { throws NotAuthorizedException, WorkbasketNotFoundException {
@ -167,7 +168,7 @@ public class DistributionTargetsAccTest extends AbstractAccTest {
@WithAccessId( @WithAccessId(
userName = "user_2_2", userName = "user_2_2",
groupNames = {"group_1", "group_2"}) groupNames = {"group_1", "group_2", "businessadmin"})
@Test @Test
public void testAddAndRemoveDistributionTargets() public void testAddAndRemoveDistributionTargets()
throws NotAuthorizedException, WorkbasketNotFoundException, InvalidWorkbasketException { throws NotAuthorizedException, WorkbasketNotFoundException, InvalidWorkbasketException {
@ -199,6 +200,24 @@ public class DistributionTargetsAccTest extends AbstractAccTest {
@WithAccessId( @WithAccessId(
userName = "user_2_2", userName = "user_2_2",
groupNames = {"group_1", "group_2"}) groupNames = {"group_1", "group_2"})
@Test(expected = NotAuthorizedException.class)
public void testAddDistributionTargetsFailsNotAuthorized()
throws NotAuthorizedException, WorkbasketNotFoundException, InvalidWorkbasketException {
WorkbasketService workbasketService = taskanaEngine.getWorkbasketService();
Workbasket workbasket = workbasketService.getWorkbasket("GPK_KSC_1", "DOMAIN_A");
List<WorkbasketSummary> distributionTargets = workbasketService.getDistributionTargets(workbasket.getId());
assertEquals(4, distributionTargets.size());
// add a new distribution target
Workbasket newTarget = workbasketService.getWorkbasket("GPK_B_KSC_2", "DOMAIN_B");
workbasketService.addDistributionTarget(workbasket.getId(), newTarget.getId());
fail("NotAuthorizedException should have been thrown");
}
@WithAccessId(
userName = "user_2_2",
groupNames = {"group_1", "group_2", "businessadmin"})
@Test @Test
public void testSetDistributionTargets() public void testSetDistributionTargets()
throws NotAuthorizedException, WorkbasketNotFoundException, InvalidWorkbasketException, SQLException { throws NotAuthorizedException, WorkbasketNotFoundException, InvalidWorkbasketException, SQLException {

View File

@ -1,5 +1,7 @@
package acceptance.workbasket; package acceptance.workbasket;
import static org.junit.Assert.fail;
import java.sql.SQLException; import java.sql.SQLException;
import java.util.List; import java.util.List;
@ -17,6 +19,7 @@ import pro.taskana.WorkbasketService;
import pro.taskana.exceptions.InvalidArgumentException; import pro.taskana.exceptions.InvalidArgumentException;
import pro.taskana.exceptions.NotAuthorizedException; import pro.taskana.exceptions.NotAuthorizedException;
import pro.taskana.security.JAASRunner; import pro.taskana.security.JAASRunner;
import pro.taskana.security.WithAccessId;
/** /**
* Acceptance test for all "query access items for workbaskets" scenarios. * Acceptance test for all "query access items for workbaskets" scenarios.
@ -31,6 +34,9 @@ public class QueryWorkbasketAccessItemsAccTest extends AbstractAccTest {
super(); super();
} }
@WithAccessId(
userName = "dummy",
groupNames = {"businessadmin"})
@Test @Test
public void testQueryAccessItemsForAccessIds() public void testQueryAccessItemsForAccessIds()
throws SQLException, NotAuthorizedException, InvalidArgumentException { throws SQLException, NotAuthorizedException, InvalidArgumentException {
@ -41,6 +47,21 @@ public class QueryWorkbasketAccessItemsAccTest extends AbstractAccTest {
Assert.assertEquals(8L, results.size()); Assert.assertEquals(8L, results.size());
} }
@WithAccessId(
userName = "dummy")
@Test(expected = NotAuthorizedException.class)
public void testQueryAccessItemsForAccessIdsNotAuthorized()
throws SQLException, NotAuthorizedException, InvalidArgumentException {
WorkbasketService workbasketService = taskanaEngine.getWorkbasketService();
List<WorkbasketAccessItem> results = workbasketService.createWorkbasketAccessItemQuery()
.accessIdIn("user_1_1", "group_1")
.list();
fail("NotAuthorizedException was expected");
}
@WithAccessId(
userName = "dummy",
groupNames = {"businessadmin"})
@Test @Test
public void testQueryAccessItemsForAccessIdsOrderedAscending() public void testQueryAccessItemsForAccessIdsOrderedAscending()
throws SQLException, NotAuthorizedException, InvalidArgumentException { throws SQLException, NotAuthorizedException, InvalidArgumentException {
@ -56,6 +77,9 @@ public class QueryWorkbasketAccessItemsAccTest extends AbstractAccTest {
Assert.assertEquals("WAI:100000000000000000000000000000000003", results.get(0).getId()); Assert.assertEquals("WAI:100000000000000000000000000000000003", results.get(0).getId());
} }
@WithAccessId(
userName = "dummy",
groupNames = {"businessadmin"})
@Test @Test
public void testQueryAccessItemsForAccessIdsAndWorkbasketKey() public void testQueryAccessItemsForAccessIdsAndWorkbasketKey()
throws SQLException, NotAuthorizedException, InvalidArgumentException { throws SQLException, NotAuthorizedException, InvalidArgumentException {
@ -67,6 +91,9 @@ public class QueryWorkbasketAccessItemsAccTest extends AbstractAccTest {
Assert.assertEquals(3L, results.size()); Assert.assertEquals(3L, results.size());
} }
@WithAccessId(
userName = "dummy",
groupNames = {"businessadmin"})
@Test @Test
public void testQueryAccessItemsByWorkbasketKey() public void testQueryAccessItemsByWorkbasketKey()
throws SQLException, NotAuthorizedException, InvalidArgumentException { throws SQLException, NotAuthorizedException, InvalidArgumentException {
@ -77,6 +104,9 @@ public class QueryWorkbasketAccessItemsAccTest extends AbstractAccTest {
Assert.assertEquals(3L, results.size()); Assert.assertEquals(3L, results.size());
} }
@WithAccessId(
userName = "dummy",
groupNames = {"businessadmin"})
@Test @Test
public void testQueryAccessItemsByWorkbasketKeyOrderedDescending() public void testQueryAccessItemsByWorkbasketKeyOrderedDescending()
throws SQLException, NotAuthorizedException, InvalidArgumentException { throws SQLException, NotAuthorizedException, InvalidArgumentException {

View File

@ -1,5 +1,7 @@
package acceptance.workbasket; package acceptance.workbasket;
import static org.junit.Assert.fail;
import java.sql.SQLException; import java.sql.SQLException;
import java.util.List; import java.util.List;
@ -34,6 +36,9 @@ public class QueryWorkbasketByPermissionAccTest extends AbstractAccTest {
super(); super();
} }
@WithAccessId(
userName = "dummy",
groupNames = {"businessadmin"})
@Test @Test
public void testQueryAllTransferTargetsForUser() public void testQueryAllTransferTargetsForUser()
throws SQLException, NotAuthorizedException, InvalidArgumentException { throws SQLException, NotAuthorizedException, InvalidArgumentException {
@ -45,6 +50,21 @@ public class QueryWorkbasketByPermissionAccTest extends AbstractAccTest {
Assert.assertEquals("USER_1_1", results.get(0).getKey()); Assert.assertEquals("USER_1_1", results.get(0).getKey());
} }
@WithAccessId(
userName = "dummy")
@Test(expected = NotAuthorizedException.class)
public void testQueryAllTransferTargetsForUserNotAuthorized()
throws SQLException, NotAuthorizedException, InvalidArgumentException {
WorkbasketService workbasketService = taskanaEngine.getWorkbasketService();
workbasketService.createWorkbasketQuery()
.accessIdsHavePermission(WorkbasketAuthorization.APPEND, "user_1_1")
.list();
fail("NotAuthorizedException was expected");
}
@WithAccessId(
userName = "dummy",
groupNames = {"businessadmin"})
@Test @Test
public void testQueryAllTransferTargetsForUserAndGroup() public void testQueryAllTransferTargetsForUserAndGroup()
throws SQLException, NotAuthorizedException, InvalidArgumentException, SystemException { throws SQLException, NotAuthorizedException, InvalidArgumentException, SystemException {
@ -55,6 +75,9 @@ public class QueryWorkbasketByPermissionAccTest extends AbstractAccTest {
Assert.assertEquals(7, results.size()); Assert.assertEquals(7, results.size());
} }
@WithAccessId(
userName = "dummy",
groupNames = {"businessadmin"})
@Test @Test
public void testQueryAllTransferTargetsForUserAndGroupSortedByNameAscending() public void testQueryAllTransferTargetsForUserAndGroupSortedByNameAscending()
throws SQLException, NotAuthorizedException, InvalidArgumentException, SystemException, throws SQLException, NotAuthorizedException, InvalidArgumentException, SystemException,
@ -68,6 +91,9 @@ public class QueryWorkbasketByPermissionAccTest extends AbstractAccTest {
Assert.assertEquals("GPK_KSC_1", results.get(0).getKey()); Assert.assertEquals("GPK_KSC_1", results.get(0).getKey());
} }
@WithAccessId(
userName = "dummy",
groupNames = {"businessadmin"})
@Test @Test
public void testQueryAllTransferTargetsForUserAndGroupSortedByNameDescending() public void testQueryAllTransferTargetsForUserAndGroupSortedByNameDescending()
throws SQLException, NotAuthorizedException, InvalidArgumentException, SystemException, throws SQLException, NotAuthorizedException, InvalidArgumentException, SystemException,

View File

@ -6,7 +6,6 @@ import java.time.Instant;
import org.h2.store.fs.FileUtils; import org.h2.store.fs.FileUtils;
import org.junit.AfterClass; import org.junit.AfterClass;
import org.junit.Assert; import org.junit.Assert;
import org.junit.Ignore;
import org.junit.Test; import org.junit.Test;
import org.junit.runner.RunWith; import org.junit.runner.RunWith;
@ -33,7 +32,7 @@ public class UpdateWorkbasketAccTest extends AbstractAccTest {
@WithAccessId( @WithAccessId(
userName = "teamlead_1", userName = "teamlead_1",
groupNames = {"group_1"}) groupNames = {"group_1", "businessadmin"})
@Test @Test
public void testUpdateWorkbasket() public void testUpdateWorkbasket()
throws SQLException, NotAuthorizedException, InvalidArgumentException, WorkbasketNotFoundException, throws SQLException, NotAuthorizedException, InvalidArgumentException, WorkbasketNotFoundException,
@ -64,16 +63,15 @@ public class UpdateWorkbasketAccTest extends AbstractAccTest {
Assert.assertEquals(WorkbasketType.TOPIC, updatedWorkbasket.getType()); Assert.assertEquals(WorkbasketType.TOPIC, updatedWorkbasket.getType());
} }
@Ignore
@WithAccessId( @WithAccessId(
userName = "teamlead_1", userName = "user_1_1",
groupNames = {"group_1"}) groupNames = {"group_1"})
@Test(expected = NotAuthorizedException.class) @Test(expected = NotAuthorizedException.class)
public void testCheckAuthorizationToUpdateWorkbasket() public void testCheckAuthorizationToUpdateWorkbasket()
throws SQLException, NotAuthorizedException, InvalidArgumentException, WorkbasketNotFoundException, throws SQLException, NotAuthorizedException, InvalidArgumentException, WorkbasketNotFoundException,
InvalidWorkbasketException { InvalidWorkbasketException {
WorkbasketService workbasketService = taskanaEngine.getWorkbasketService(); WorkbasketService workbasketService = taskanaEngine.getWorkbasketService();
Workbasket workbasket = workbasketService.getWorkbasket("GPK_KSC", "DOMAIN_A"); Workbasket workbasket = workbasketService.getWorkbasket("USER_1_1", "DOMAIN_A");
workbasket.setName("new name"); workbasket.setName("new name");
workbasketService.updateWorkbasket(workbasket); workbasketService.updateWorkbasket(workbasket);

View File

@ -47,9 +47,9 @@ public class UpdateWorkbasketAuthorizationsAccTest extends AbstractAccTest {
@WithAccessId( @WithAccessId(
userName = "teamlead_1", userName = "teamlead_1",
groupNames = {"group_1"}) groupNames = {"group_1", "businessadmin"})
@Test @Test
public void testUpdateWorkbasketAccessItemSucceeds() throws InvalidArgumentException { public void testUpdateWorkbasketAccessItemSucceeds() throws InvalidArgumentException, NotAuthorizedException {
WorkbasketService workbasketService = taskanaEngine.getWorkbasketService(); WorkbasketService workbasketService = taskanaEngine.getWorkbasketService();
WorkbasketAccessItem accessItem = workbasketService WorkbasketAccessItem accessItem = workbasketService
.newWorkbasketAccessItem("key1000000000000000000000000000000000000", "user1"); .newWorkbasketAccessItem("key1000000000000000000000000000000000000", "user1");
@ -71,7 +71,7 @@ public class UpdateWorkbasketAuthorizationsAccTest extends AbstractAccTest {
@WithAccessId( @WithAccessId(
userName = "teamlead_1", userName = "teamlead_1",
groupNames = {"group_1"}) groupNames = {"group_1", "businessadmin"})
@Test @Test
public void testUpdateWorkbasketAccessItemRejected() public void testUpdateWorkbasketAccessItemRejected()
throws SQLException, NotAuthorizedException, InvalidArgumentException, WorkbasketNotFoundException, throws SQLException, NotAuthorizedException, InvalidArgumentException, WorkbasketNotFoundException,
@ -113,7 +113,7 @@ public class UpdateWorkbasketAuthorizationsAccTest extends AbstractAccTest {
@WithAccessId( @WithAccessId(
userName = "user_1_1", userName = "user_1_1",
groupNames = {"group_2"}) groupNames = {"group_2", "businessadmin"})
@Test @Test
public void testUpdatedAccessItemLeadsToNotAuthorizedException() public void testUpdatedAccessItemLeadsToNotAuthorizedException()
throws SQLException, NotAuthorizedException, InvalidArgumentException, WorkbasketNotFoundException, throws SQLException, NotAuthorizedException, InvalidArgumentException, WorkbasketNotFoundException,
@ -236,8 +236,11 @@ public class UpdateWorkbasketAuthorizationsAccTest extends AbstractAccTest {
assertFalse(item0.isPermTransfer()); assertFalse(item0.isPermTransfer());
} }
@WithAccessId(
userName = "teamlead_1",
groupNames = {"businessadmin"})
@Test @Test
public void testDeleteAccessItemsForAccessId() { public void testDeleteAccessItemsForAccessId() throws NotAuthorizedException {
WorkbasketService workbasketService = taskanaEngine.getWorkbasketService(); WorkbasketService workbasketService = taskanaEngine.getWorkbasketService();
final String accessId = "group_1"; final String accessId = "group_1";
final long accessIdCountBefore = workbasketService final long accessIdCountBefore = workbasketService

View File

@ -59,7 +59,7 @@ public class ClassificationServiceImplTest {
@Test(expected = ClassificationAlreadyExistException.class) @Test(expected = ClassificationAlreadyExistException.class)
public void testCreateClassificationAlreadyExisting() public void testCreateClassificationAlreadyExisting()
throws ClassificationAlreadyExistException, ClassificationNotFoundException { throws ClassificationAlreadyExistException, ClassificationNotFoundException, NotAuthorizedException {
Classification classification = createDummyClassification(); Classification classification = createDummyClassification();
doReturn(classification).when(classificationMapperMock).findByKeyAndDomain(classification.getKey(), doReturn(classification).when(classificationMapperMock).findByKeyAndDomain(classification.getKey(),
classification.getDomain()); classification.getDomain());
@ -71,6 +71,7 @@ public class ClassificationServiceImplTest {
verify(classificationMapperMock, times(1)).findByKeyAndDomain(classification.getKey(), verify(classificationMapperMock, times(1)).findByKeyAndDomain(classification.getKey(),
classification.getDomain()); classification.getDomain());
verify(taskanaEngineImplMock, times(1)).returnConnection(); verify(taskanaEngineImplMock, times(1)).returnConnection();
verify(taskanaEngineImplMock, times(1)).checkRoleMembership(any());
verifyNoMoreInteractions(classificationMapperMock, taskanaEngineImplMock, classificationQueryImplMock); verifyNoMoreInteractions(classificationMapperMock, taskanaEngineImplMock, classificationQueryImplMock);
throw e; throw e;
} }
@ -78,7 +79,8 @@ public class ClassificationServiceImplTest {
@Test @Test
public void testCreateClassificationInOwnDomainButExistingInRoot() public void testCreateClassificationInOwnDomainButExistingInRoot()
throws ClassificationAlreadyExistException, ClassificationNotFoundException, InterruptedException { throws ClassificationAlreadyExistException, ClassificationNotFoundException, InterruptedException,
NotAuthorizedException {
Instant beforeTimestamp = Instant.now(); Instant beforeTimestamp = Instant.now();
Thread.sleep(10L); Thread.sleep(10L);
Classification classification = createDummyClassification(); Classification classification = createDummyClassification();
@ -96,6 +98,7 @@ public class ClassificationServiceImplTest {
verify(classificationMapperMock, times(1)).findByKeyAndDomain(key, ""); verify(classificationMapperMock, times(1)).findByKeyAndDomain(key, "");
verify(classificationMapperMock, times(1)).insert(any()); verify(classificationMapperMock, times(1)).insert(any());
verify(taskanaEngineImplMock, times(2)).returnConnection(); verify(taskanaEngineImplMock, times(2)).returnConnection();
verify(taskanaEngineImplMock, times(1)).checkRoleMembership(any());
verifyNoMoreInteractions(classificationMapperMock, taskanaEngineImplMock, classificationQueryImplMock); verifyNoMoreInteractions(classificationMapperMock, taskanaEngineImplMock, classificationQueryImplMock);
Thread.sleep(15); Thread.sleep(15);
assertThat(classification.getCreated().toString().substring(0, 10), equalTo(todaysDate)); assertThat(classification.getCreated().toString().substring(0, 10), equalTo(todaysDate));
@ -107,7 +110,7 @@ public class ClassificationServiceImplTest {
@Test @Test
public void testCreateClassificationInOwnDomainAndCopyInRootDomain() public void testCreateClassificationInOwnDomainAndCopyInRootDomain()
throws ClassificationAlreadyExistException { throws ClassificationAlreadyExistException, NotAuthorizedException {
Classification classification = createDummyClassification(); Classification classification = createDummyClassification();
String domain = classification.getDomain(); String domain = classification.getDomain();
String key = classification.getKey(); String key = classification.getKey();
@ -122,6 +125,7 @@ public class ClassificationServiceImplTest {
verify(classificationMapperMock, times(2)).findByKeyAndDomain(key, ""); verify(classificationMapperMock, times(2)).findByKeyAndDomain(key, "");
verify(classificationMapperMock, times(2)).insert(any()); verify(classificationMapperMock, times(2)).insert(any());
verify(taskanaEngineImplMock, times(2)).returnConnection(); verify(taskanaEngineImplMock, times(2)).returnConnection();
verify(taskanaEngineImplMock, times(1)).checkRoleMembership(any());
verifyNoMoreInteractions(classificationMapperMock, taskanaEngineImplMock, classificationQueryImplMock); verifyNoMoreInteractions(classificationMapperMock, taskanaEngineImplMock, classificationQueryImplMock);
assertThat(classification.getCreated().toString().substring(0, 10), equalTo(todaysDate)); assertThat(classification.getCreated().toString().substring(0, 10), equalTo(todaysDate));
assertThat(classification.getDomain(), equalTo(domain)); assertThat(classification.getDomain(), equalTo(domain));
@ -130,7 +134,7 @@ public class ClassificationServiceImplTest {
@Test @Test
public void testCreateClassificationIntoRootDomain() public void testCreateClassificationIntoRootDomain()
throws ClassificationAlreadyExistException { throws ClassificationAlreadyExistException, NotAuthorizedException {
ClassificationImpl classification = (ClassificationImpl) createDummyClassification(); ClassificationImpl classification = (ClassificationImpl) createDummyClassification();
classification.setDomain(""); classification.setDomain("");
doReturn(null).when(classificationMapperMock).findByKeyAndDomain(classification.getKey(), doReturn(null).when(classificationMapperMock).findByKeyAndDomain(classification.getKey(),
@ -143,6 +147,7 @@ public class ClassificationServiceImplTest {
classification.getDomain()); classification.getDomain());
verify(classificationMapperMock, times(1)).insert(classification); verify(classificationMapperMock, times(1)).insert(classification);
verify(taskanaEngineImplMock, times(1)).returnConnection(); verify(taskanaEngineImplMock, times(1)).returnConnection();
verify(taskanaEngineImplMock, times(1)).checkRoleMembership(any());
verifyNoMoreInteractions(classificationMapperMock, taskanaEngineImplMock, classificationQueryImplMock); verifyNoMoreInteractions(classificationMapperMock, taskanaEngineImplMock, classificationQueryImplMock);
assertThat(classification.getCreated().toString().substring(0, 10), equalTo(todaysDate)); assertThat(classification.getCreated().toString().substring(0, 10), equalTo(todaysDate));
} }
@ -158,6 +163,7 @@ public class ClassificationServiceImplTest {
verify(taskanaEngineImplMock, times(1)).openConnection(); verify(taskanaEngineImplMock, times(1)).openConnection();
verify(cutSpy, times(2)).getClassification(classification.getKey(), classification.getDomain()); verify(cutSpy, times(2)).getClassification(classification.getKey(), classification.getDomain());
verify(classificationMapperMock, times(1)).update(any()); verify(classificationMapperMock, times(1)).update(any());
verify(taskanaEngineImplMock, times(1)).checkRoleMembership(any());
verify(taskanaEngineImplMock, times(1)).returnConnection(); verify(taskanaEngineImplMock, times(1)).returnConnection();
verifyNoMoreInteractions(classificationMapperMock, taskanaEngineImplMock, classificationQueryImplMock); verifyNoMoreInteractions(classificationMapperMock, taskanaEngineImplMock, classificationQueryImplMock);
} }

View File

@ -79,9 +79,6 @@ public class TaskServiceImplTest {
@Mock @Mock
private TaskanaEngineImpl taskanaEngineMock; private TaskanaEngineImpl taskanaEngineMock;
@Mock
private TaskanaEngineImpl taskanaEngineImpl;
@Mock @Mock
private TaskMapper taskMapperMock; private TaskMapper taskMapperMock;
@ -116,8 +113,8 @@ public class TaskServiceImplTest {
} catch (NotAuthorizedException e) { } catch (NotAuthorizedException e) {
e.printStackTrace(); e.printStackTrace();
} }
Mockito.doNothing().when(taskanaEngineImpl).openConnection(); Mockito.doNothing().when(taskanaEngineMock).openConnection();
Mockito.doNothing().when(taskanaEngineImpl).returnConnection(); Mockito.doNothing().when(taskanaEngineMock).returnConnection();
} }
@Test @Test
@ -144,16 +141,16 @@ public class TaskServiceImplTest {
Task actualTask = cutSpy.createTask(expectedTask); Task actualTask = cutSpy.createTask(expectedTask);
verify(taskanaEngineImpl, times(1)).openConnection(); verify(taskanaEngineMock, times(1)).openConnection();
verify(workbasketServiceMock, times(1)).checkAuthorization(any(), any()); verify(workbasketServiceMock, times(1)).checkAuthorization(any(), any());
verify(workbasketServiceMock, times(1)).getWorkbasket(any(), any()); verify(workbasketServiceMock, times(1)).getWorkbasket(any(), any());
verify(classificationServiceImplMock, times(1)).getClassification(any(), any()); verify(classificationServiceImplMock, times(1)).getClassification(any(), any());
verify(taskanaEngineMock, times(1)).getConfiguration(); verify(taskanaEngineMock, times(1)).getConfiguration();
verify(taskanaEngineConfigurationMock, times(1)).isSecurityEnabled(); verify(taskanaEngineConfigurationMock, times(1)).isSecurityEnabled();
verify(taskMapperMock, times(1)).insert(expectedTask); verify(taskMapperMock, times(1)).insert(expectedTask);
verify(taskanaEngineImpl, times(1)).returnConnection(); verify(taskanaEngineMock, times(1)).returnConnection();
verifyNoMoreInteractions(attachmentMapperMock, taskanaEngineConfigurationMock, taskanaEngineMock, verifyNoMoreInteractions(attachmentMapperMock, taskanaEngineConfigurationMock, taskanaEngineMock,
taskanaEngineImpl, taskMapperMock, objectReferenceMapperMock, workbasketServiceMock, sqlSessionMock, taskMapperMock, objectReferenceMapperMock, workbasketServiceMock, sqlSessionMock,
classificationQueryImplMock, classificationQueryImplMock,
classificationServiceImplMock); classificationServiceImplMock);
@ -221,7 +218,7 @@ public class TaskServiceImplTest {
doReturn(false).when(taskanaEngineConfigurationMock).isSecurityEnabled(); doReturn(false).when(taskanaEngineConfigurationMock).isSecurityEnabled();
Task actualTask = cutSpy.createTask(expectedTask); Task actualTask = cutSpy.createTask(expectedTask);
verify(taskanaEngineImpl, times(1)).openConnection(); verify(taskanaEngineMock, times(1)).openConnection();
verify(workbasketServiceMock, times(1)).getWorkbasket(wb.getKey(), wb.getDomain()); verify(workbasketServiceMock, times(1)).getWorkbasket(wb.getKey(), wb.getDomain());
verify(workbasketServiceMock, times(1)).checkAuthorization(wb.getId(), verify(workbasketServiceMock, times(1)).checkAuthorization(wb.getId(),
WorkbasketAuthorization.APPEND); WorkbasketAuthorization.APPEND);
@ -230,9 +227,9 @@ public class TaskServiceImplTest {
verify(taskanaEngineMock, times(1)).getConfiguration(); verify(taskanaEngineMock, times(1)).getConfiguration();
verify(taskanaEngineConfigurationMock, times(1)).isSecurityEnabled(); verify(taskanaEngineConfigurationMock, times(1)).isSecurityEnabled();
verify(taskMapperMock, times(1)).insert(expectedTask); verify(taskMapperMock, times(1)).insert(expectedTask);
verify(taskanaEngineImpl, times(1)).returnConnection(); verify(taskanaEngineMock, times(1)).returnConnection();
verifyNoMoreInteractions(attachmentMapperMock, taskanaEngineConfigurationMock, taskanaEngineMock, verifyNoMoreInteractions(attachmentMapperMock, taskanaEngineConfigurationMock, taskanaEngineMock,
taskanaEngineImpl, taskMapperMock, objectReferenceMapperMock, workbasketServiceMock, sqlSessionMock, taskMapperMock, objectReferenceMapperMock, workbasketServiceMock, sqlSessionMock,
classificationQueryImplMock, classificationQueryImplMock,
classificationServiceImplMock); classificationServiceImplMock);
assertNull(actualTask.getOwner()); assertNull(actualTask.getOwner());
@ -274,7 +271,7 @@ public class TaskServiceImplTest {
Task actualTask = cutSpy.createTask(expectedTask); Task actualTask = cutSpy.createTask(expectedTask);
expectedTask.getPrimaryObjRef().setId(actualTask.getPrimaryObjRef().getId()); // get only new ID expectedTask.getPrimaryObjRef().setId(actualTask.getPrimaryObjRef().getId()); // get only new ID
verify(taskanaEngineImpl, times(1)).openConnection(); verify(taskanaEngineMock, times(1)).openConnection();
verify(workbasketServiceMock, times(1)).getWorkbasket(expectedTask.getWorkbasketKey(), verify(workbasketServiceMock, times(1)).getWorkbasket(expectedTask.getWorkbasketKey(),
expectedTask.getDomain()); expectedTask.getDomain());
verify(workbasketServiceMock, times(1)).checkAuthorization(expectedTask.getWorkbasketSummary().getId(), verify(workbasketServiceMock, times(1)).checkAuthorization(expectedTask.getWorkbasketSummary().getId(),
@ -284,9 +281,9 @@ public class TaskServiceImplTest {
verify(taskanaEngineMock, times(1)).getConfiguration(); verify(taskanaEngineMock, times(1)).getConfiguration();
verify(taskanaEngineConfigurationMock, times(1)).isSecurityEnabled(); verify(taskanaEngineConfigurationMock, times(1)).isSecurityEnabled();
verify(taskMapperMock, times(1)).insert(expectedTask); verify(taskMapperMock, times(1)).insert(expectedTask);
verify(taskanaEngineImpl, times(1)).returnConnection(); verify(taskanaEngineMock, times(1)).returnConnection();
verifyNoMoreInteractions(attachmentMapperMock, taskanaEngineConfigurationMock, taskanaEngineMock, verifyNoMoreInteractions(attachmentMapperMock, taskanaEngineConfigurationMock, taskanaEngineMock,
taskanaEngineImpl, taskMapperMock, objectReferenceMapperMock, workbasketServiceMock, sqlSessionMock, taskanaEngineMock, taskMapperMock, objectReferenceMapperMock, workbasketServiceMock, sqlSessionMock,
classificationQueryImplMock, classificationQueryImplMock,
classificationServiceImplMock); classificationServiceImplMock);
assertNull(actualTask.getOwner()); assertNull(actualTask.getOwner());
@ -344,7 +341,7 @@ public class TaskServiceImplTest {
cutSpy.createTask(task2); cutSpy.createTask(task2);
verify(taskanaEngineImpl, times(2)).openConnection(); verify(taskanaEngineMock, times(2)).openConnection();
verify(workbasketServiceMock, times(2)).getWorkbasket(any()); verify(workbasketServiceMock, times(2)).getWorkbasket(any());
verify(workbasketServiceMock, times(2)).checkAuthorization(any(), any()); verify(workbasketServiceMock, times(2)).checkAuthorization(any(), any());
verify(classificationServiceImplMock, times(2)).getClassification(any(), any()); verify(classificationServiceImplMock, times(2)).getClassification(any(), any());
@ -352,9 +349,9 @@ public class TaskServiceImplTest {
verify(taskanaEngineConfigurationMock, times(2)).isSecurityEnabled(); verify(taskanaEngineConfigurationMock, times(2)).isSecurityEnabled();
verify(taskMapperMock, times(1)).insert(task); verify(taskMapperMock, times(1)).insert(task);
verify(taskMapperMock, times(1)).insert(task2); verify(taskMapperMock, times(1)).insert(task2);
verify(taskanaEngineImpl, times(2)).returnConnection(); verify(taskanaEngineMock, times(2)).returnConnection();
verifyNoMoreInteractions(attachmentMapperMock, taskanaEngineConfigurationMock, taskanaEngineMock, verifyNoMoreInteractions(attachmentMapperMock, taskanaEngineConfigurationMock, taskanaEngineMock,
taskanaEngineImpl, taskMapperMock, objectReferenceMapperMock, workbasketServiceMock, sqlSessionMock, taskanaEngineMock, taskMapperMock, objectReferenceMapperMock, workbasketServiceMock, sqlSessionMock,
classificationQueryImplMock, classificationQueryImplMock,
classificationServiceImplMock); classificationServiceImplMock);
@ -384,11 +381,11 @@ public class TaskServiceImplTest {
try { try {
cutSpy.createTask(task); cutSpy.createTask(task);
} catch (TaskAlreadyExistException ex) { } catch (TaskAlreadyExistException ex) {
verify(taskanaEngineImpl, times(1)).openConnection(); verify(taskanaEngineMock, times(1)).openConnection();
verify(taskanaEngineImpl, times(1)).returnConnection(); verify(taskanaEngineMock, times(1)).returnConnection();
verifyNoMoreInteractions(attachmentMapperMock, taskanaEngineConfigurationMock, verifyNoMoreInteractions(attachmentMapperMock, taskanaEngineConfigurationMock,
taskanaEngineMock, taskanaEngineMock,
taskanaEngineImpl, taskMapperMock, objectReferenceMapperMock, workbasketServiceMock, sqlSessionMock, taskanaEngineMock, taskMapperMock, objectReferenceMapperMock, workbasketServiceMock, sqlSessionMock,
classificationQueryImplMock, classificationQueryImplMock,
classificationServiceImplMock); classificationServiceImplMock);
throw ex; throw ex;
@ -412,14 +409,14 @@ public class TaskServiceImplTest {
try { try {
cutSpy.createTask(task); cutSpy.createTask(task);
} catch (NotAuthorizedException e) { } catch (NotAuthorizedException e) {
verify(taskanaEngineImpl, times(1)).openConnection(); verify(taskanaEngineMock, times(1)).openConnection();
verify(workbasketServiceMock, times(1)).getWorkbasket(task.getWorkbasketSummary().getId()); verify(workbasketServiceMock, times(1)).getWorkbasket(task.getWorkbasketSummary().getId());
verify(workbasketServiceMock, times(1)).checkAuthorization(task.getWorkbasketSummary().getId(), verify(workbasketServiceMock, times(1)).checkAuthorization(task.getWorkbasketSummary().getId(),
WorkbasketAuthorization.APPEND); WorkbasketAuthorization.APPEND);
verify(taskanaEngineImpl, times(1)).returnConnection(); verify(taskanaEngineMock, times(1)).returnConnection();
verifyNoMoreInteractions(attachmentMapperMock, taskanaEngineConfigurationMock, verifyNoMoreInteractions(attachmentMapperMock, taskanaEngineConfigurationMock,
taskanaEngineMock, taskanaEngineMock,
taskanaEngineImpl, taskMapperMock, objectReferenceMapperMock, workbasketServiceMock, sqlSessionMock, taskMapperMock, objectReferenceMapperMock, workbasketServiceMock, sqlSessionMock,
classificationQueryImplMock, classificationQueryImplMock,
classificationServiceImplMock); classificationServiceImplMock);
throw e; throw e;
@ -438,13 +435,13 @@ public class TaskServiceImplTest {
try { try {
cutSpy.createTask(task); cutSpy.createTask(task);
} catch (WorkbasketNotFoundException e) { } catch (WorkbasketNotFoundException e) {
verify(taskanaEngineImpl, times(1)).openConnection(); verify(taskanaEngineMock, times(1)).openConnection();
verify(workbasketServiceMock, times(1)).getWorkbasket(task.getWorkbasketKey(), verify(workbasketServiceMock, times(1)).getWorkbasket(task.getWorkbasketKey(),
task.getWorkbasketSummary().getDomain()); task.getWorkbasketSummary().getDomain());
verify(taskanaEngineImpl, times(1)).returnConnection(); verify(taskanaEngineMock, times(1)).returnConnection();
verifyNoMoreInteractions(attachmentMapperMock, taskanaEngineConfigurationMock, verifyNoMoreInteractions(attachmentMapperMock, taskanaEngineConfigurationMock,
taskanaEngineMock, taskanaEngineMock,
taskanaEngineImpl, taskMapperMock, objectReferenceMapperMock, workbasketServiceMock, sqlSessionMock, taskMapperMock, objectReferenceMapperMock, workbasketServiceMock, sqlSessionMock,
classificationQueryImplMock, classificationQueryImplMock,
classificationServiceImplMock); classificationServiceImplMock);
throw e; throw e;
@ -460,7 +457,7 @@ public class TaskServiceImplTest {
cutSpy.claim(expectedTask.getId()); cutSpy.claim(expectedTask.getId());
verify(cutSpy, times(1)).claim(expectedTask.getId(), false); verify(cutSpy, times(1)).claim(expectedTask.getId(), false);
verifyNoMoreInteractions(attachmentMapperMock, taskanaEngineConfigurationMock, taskanaEngineMock, verifyNoMoreInteractions(attachmentMapperMock, taskanaEngineConfigurationMock, taskanaEngineMock,
taskanaEngineImpl, taskMapperMock, objectReferenceMapperMock, workbasketServiceMock, sqlSessionMock, taskMapperMock, objectReferenceMapperMock, workbasketServiceMock, sqlSessionMock,
classificationQueryImplMock); classificationQueryImplMock);
} }
@ -476,12 +473,12 @@ public class TaskServiceImplTest {
Task acturalTask = cutSpy.claim(expectedTask.getId(), true); Task acturalTask = cutSpy.claim(expectedTask.getId(), true);
verify(taskanaEngineImpl, times(1)).openConnection(); verify(taskanaEngineMock, times(1)).openConnection();
verify(cutSpy, times(1)).getTask(expectedTask.getId()); verify(cutSpy, times(1)).getTask(expectedTask.getId());
verify(taskMapperMock, times(1)).update(any()); verify(taskMapperMock, times(1)).update(any());
verify(taskanaEngineImpl, times(1)).returnConnection(); verify(taskanaEngineMock, times(1)).returnConnection();
verifyNoMoreInteractions(attachmentMapperMock, taskanaEngineConfigurationMock, taskanaEngineMock, verifyNoMoreInteractions(attachmentMapperMock, taskanaEngineConfigurationMock, taskanaEngineMock,
taskanaEngineImpl, taskMapperMock, objectReferenceMapperMock, workbasketServiceMock, sqlSessionMock, taskMapperMock, objectReferenceMapperMock, workbasketServiceMock, sqlSessionMock,
classificationQueryImplMock); classificationQueryImplMock);
assertThat(acturalTask.getState(), equalTo(TaskState.CLAIMED)); assertThat(acturalTask.getState(), equalTo(TaskState.CLAIMED));
@ -500,12 +497,12 @@ public class TaskServiceImplTest {
try { try {
cut.claim("1", true); cut.claim("1", true);
} catch (Exception e) { } catch (Exception e) {
verify(taskanaEngineImpl, times(2)).openConnection(); verify(taskanaEngineMock, times(2)).openConnection();
verify(taskMapperMock, times(1)).findById(any()); verify(taskMapperMock, times(1)).findById(any());
verify(taskanaEngineImpl, times(2)).returnConnection(); verify(taskanaEngineMock, times(2)).returnConnection();
verifyNoMoreInteractions(attachmentMapperMock, taskanaEngineConfigurationMock, verifyNoMoreInteractions(attachmentMapperMock, taskanaEngineConfigurationMock,
taskanaEngineMock, taskanaEngineMock,
taskanaEngineImpl, taskMapperMock, objectReferenceMapperMock, workbasketServiceMock, sqlSessionMock, taskMapperMock, objectReferenceMapperMock, workbasketServiceMock, sqlSessionMock,
classificationQueryImplMock); classificationQueryImplMock);
throw e; throw e;
} }
@ -521,12 +518,12 @@ public class TaskServiceImplTest {
try { try {
cutSpy.claim("1", true); cutSpy.claim("1", true);
} catch (Exception e) { } catch (Exception e) {
verify(taskanaEngineImpl, times(1)).openConnection(); verify(taskanaEngineMock, times(1)).openConnection();
verify(cutSpy, times(1)).getTask(task.getId()); verify(cutSpy, times(1)).getTask(task.getId());
verify(taskanaEngineImpl, times(1)).returnConnection(); verify(taskanaEngineMock, times(1)).returnConnection();
verifyNoMoreInteractions(attachmentMapperMock, taskanaEngineConfigurationMock, verifyNoMoreInteractions(attachmentMapperMock, taskanaEngineConfigurationMock,
taskanaEngineMock, taskanaEngineMock,
taskanaEngineImpl, taskMapperMock, objectReferenceMapperMock, workbasketServiceMock, sqlSessionMock, taskMapperMock, objectReferenceMapperMock, workbasketServiceMock, sqlSessionMock,
classificationQueryImplMock); classificationQueryImplMock);
throw e; throw e;
} }
@ -543,12 +540,12 @@ public class TaskServiceImplTest {
try { try {
cutSpy.claim("1"); cutSpy.claim("1");
} catch (Exception e) { } catch (Exception e) {
verify(taskanaEngineImpl, times(1)).openConnection(); verify(taskanaEngineMock, times(1)).openConnection();
verify(cutSpy, times(1)).getTask(task.getId()); verify(cutSpy, times(1)).getTask(task.getId());
verify(taskanaEngineImpl, times(1)).returnConnection(); verify(taskanaEngineMock, times(1)).returnConnection();
verifyNoMoreInteractions(attachmentMapperMock, taskanaEngineConfigurationMock, verifyNoMoreInteractions(attachmentMapperMock, taskanaEngineConfigurationMock,
taskanaEngineMock, taskanaEngineMock,
taskanaEngineImpl, taskMapperMock, objectReferenceMapperMock, workbasketServiceMock, sqlSessionMock, taskMapperMock, objectReferenceMapperMock, workbasketServiceMock, sqlSessionMock,
classificationQueryImplMock); classificationQueryImplMock);
throw e; throw e;
} }
@ -566,11 +563,11 @@ public class TaskServiceImplTest {
try { try {
cutSpy.cancelClaim(expectedTask.getId()); cutSpy.cancelClaim(expectedTask.getId());
} catch (InvalidStateException e) { } catch (InvalidStateException e) {
verify(taskanaEngineImpl, times(1)).openConnection(); verify(taskanaEngineMock, times(1)).openConnection();
verify(cutSpy, times(1)).getTask(expectedTask.getId()); verify(cutSpy, times(1)).getTask(expectedTask.getId());
verify(taskanaEngineImpl, times(1)).returnConnection(); verify(taskanaEngineMock, times(1)).returnConnection();
verifyNoMoreInteractions(attachmentMapperMock, taskanaEngineConfigurationMock, taskanaEngineMock, verifyNoMoreInteractions(attachmentMapperMock, taskanaEngineConfigurationMock, taskanaEngineMock,
taskanaEngineImpl, taskMapperMock, objectReferenceMapperMock, workbasketServiceMock, sqlSessionMock, taskMapperMock, objectReferenceMapperMock, workbasketServiceMock, sqlSessionMock,
classificationQueryImplMock); classificationQueryImplMock);
throw e; throw e;
} }
@ -591,11 +588,11 @@ public class TaskServiceImplTest {
try { try {
cutSpy.cancelClaim(expectedTask.getId()); cutSpy.cancelClaim(expectedTask.getId());
} catch (InvalidOwnerException e) { } catch (InvalidOwnerException e) {
verify(taskanaEngineImpl, times(1)).openConnection(); verify(taskanaEngineMock, times(1)).openConnection();
verify(cutSpy, times(1)).getTask(expectedTask.getId()); verify(cutSpy, times(1)).getTask(expectedTask.getId());
verify(taskanaEngineImpl, times(1)).returnConnection(); verify(taskanaEngineMock, times(1)).returnConnection();
verifyNoMoreInteractions(attachmentMapperMock, taskanaEngineConfigurationMock, taskanaEngineMock, verifyNoMoreInteractions(attachmentMapperMock, taskanaEngineConfigurationMock, taskanaEngineMock,
taskanaEngineImpl, taskMapperMock, objectReferenceMapperMock, workbasketServiceMock, sqlSessionMock, taskMapperMock, objectReferenceMapperMock, workbasketServiceMock, sqlSessionMock,
classificationQueryImplMock); classificationQueryImplMock);
throw e; throw e;
} }
@ -610,7 +607,7 @@ public class TaskServiceImplTest {
cutSpy.cancelClaim(expectedTask.getId()); cutSpy.cancelClaim(expectedTask.getId());
verify(cutSpy, times(1)).cancelClaim(expectedTask.getId(), false); verify(cutSpy, times(1)).cancelClaim(expectedTask.getId(), false);
verifyNoMoreInteractions(attachmentMapperMock, taskanaEngineConfigurationMock, taskanaEngineMock, verifyNoMoreInteractions(attachmentMapperMock, taskanaEngineConfigurationMock, taskanaEngineMock,
taskanaEngineImpl, taskMapperMock, objectReferenceMapperMock, workbasketServiceMock, sqlSessionMock, taskMapperMock, objectReferenceMapperMock, workbasketServiceMock, sqlSessionMock,
classificationQueryImplMock); classificationQueryImplMock);
} }
@ -630,12 +627,12 @@ public class TaskServiceImplTest {
Task acturalTask = cutSpy.cancelClaim(expectedTask.getId(), true); Task acturalTask = cutSpy.cancelClaim(expectedTask.getId(), true);
verify(taskanaEngineImpl, times(1)).openConnection(); verify(taskanaEngineMock, times(1)).openConnection();
verify(cutSpy, times(1)).getTask(expectedTask.getId()); verify(cutSpy, times(1)).getTask(expectedTask.getId());
verify(taskMapperMock, times(1)).update(any()); verify(taskMapperMock, times(1)).update(any());
verify(taskanaEngineImpl, times(1)).returnConnection(); verify(taskanaEngineMock, times(1)).returnConnection();
verifyNoMoreInteractions(attachmentMapperMock, taskanaEngineConfigurationMock, taskanaEngineMock, verifyNoMoreInteractions(attachmentMapperMock, taskanaEngineConfigurationMock, taskanaEngineMock,
taskanaEngineImpl, taskMapperMock, objectReferenceMapperMock, workbasketServiceMock, sqlSessionMock, taskMapperMock, objectReferenceMapperMock, workbasketServiceMock, sqlSessionMock,
classificationQueryImplMock); classificationQueryImplMock);
assertThat(acturalTask.getState(), equalTo(TaskState.READY)); assertThat(acturalTask.getState(), equalTo(TaskState.READY));
@ -660,12 +657,12 @@ public class TaskServiceImplTest {
Task acturalTask = cutSpy.cancelClaim(expectedTask.getId(), true); Task acturalTask = cutSpy.cancelClaim(expectedTask.getId(), true);
verify(taskanaEngineImpl, times(1)).openConnection(); verify(taskanaEngineMock, times(1)).openConnection();
verify(cutSpy, times(1)).getTask(expectedTask.getId()); verify(cutSpy, times(1)).getTask(expectedTask.getId());
verify(taskMapperMock, times(1)).update(any()); verify(taskMapperMock, times(1)).update(any());
verify(taskanaEngineImpl, times(1)).returnConnection(); verify(taskanaEngineMock, times(1)).returnConnection();
verifyNoMoreInteractions(attachmentMapperMock, taskanaEngineConfigurationMock, taskanaEngineMock, verifyNoMoreInteractions(attachmentMapperMock, taskanaEngineConfigurationMock, taskanaEngineMock,
taskanaEngineImpl, taskMapperMock, objectReferenceMapperMock, workbasketServiceMock, sqlSessionMock, taskMapperMock, objectReferenceMapperMock, workbasketServiceMock, sqlSessionMock,
classificationQueryImplMock); classificationQueryImplMock);
assertThat(acturalTask.getState(), equalTo(TaskState.READY)); assertThat(acturalTask.getState(), equalTo(TaskState.READY));
@ -703,7 +700,7 @@ public class TaskServiceImplTest {
Task actualTask = cut.completeTask(task.getId()); Task actualTask = cut.completeTask(task.getId());
verify(taskanaEngineImpl, times(2)).openConnection(); verify(taskanaEngineMock, times(2)).openConnection();
verify(taskMapperMock, times(1)).findById(task.getId()); verify(taskMapperMock, times(1)).findById(task.getId());
verify(attachmentMapperMock, times(1)).findAttachmentsByTaskId(task.getId()); verify(attachmentMapperMock, times(1)).findAttachmentsByTaskId(task.getId());
verify(classificationServiceImplMock, times(1)).createClassificationQuery(); verify(classificationServiceImplMock, times(1)).createClassificationQuery();
@ -711,9 +708,9 @@ public class TaskServiceImplTest {
verify(classificationQueryImplMock, times(1)).keyIn(any()); verify(classificationQueryImplMock, times(1)).keyIn(any());
verify(classificationQueryImplMock, times(1)).list(); verify(classificationQueryImplMock, times(1)).list();
verify(taskMapperMock, times(1)).update(any()); verify(taskMapperMock, times(1)).update(any());
verify(taskanaEngineImpl, times(2)).returnConnection(); verify(taskanaEngineMock, times(2)).returnConnection();
verifyNoMoreInteractions(attachmentMapperMock, taskanaEngineConfigurationMock, taskanaEngineMock, verifyNoMoreInteractions(attachmentMapperMock, taskanaEngineConfigurationMock, taskanaEngineMock,
taskanaEngineImpl, taskMapperMock, objectReferenceMapperMock, workbasketServiceMock, sqlSessionMock, taskMapperMock, objectReferenceMapperMock, workbasketServiceMock, sqlSessionMock,
classificationQueryImplMock); classificationQueryImplMock);
assertThat(actualTask.getState(), equalTo(TaskState.COMPLETED)); assertThat(actualTask.getState(), equalTo(TaskState.COMPLETED));
@ -740,12 +737,12 @@ public class TaskServiceImplTest {
Task actualTask = cutSpy.completeTask(task.getId(), isForced); Task actualTask = cutSpy.completeTask(task.getId(), isForced);
verify(taskanaEngineImpl, times(1)).openConnection(); verify(taskanaEngineMock, times(1)).openConnection();
verify(cutSpy, times(1)).getTask(task.getId()); verify(cutSpy, times(1)).getTask(task.getId());
verify(taskMapperMock, times(1)).update(task); verify(taskMapperMock, times(1)).update(task);
verify(taskanaEngineImpl, times(1)).returnConnection(); verify(taskanaEngineMock, times(1)).returnConnection();
verifyNoMoreInteractions(attachmentMapperMock, taskanaEngineConfigurationMock, taskanaEngineMock, verifyNoMoreInteractions(attachmentMapperMock, taskanaEngineConfigurationMock, taskanaEngineMock,
taskanaEngineImpl, taskMapperMock, objectReferenceMapperMock, workbasketServiceMock, sqlSessionMock, taskMapperMock, objectReferenceMapperMock, workbasketServiceMock, sqlSessionMock,
classificationQueryImplMock); classificationQueryImplMock);
assertThat(actualTask.getState(), equalTo(TaskState.COMPLETED)); assertThat(actualTask.getState(), equalTo(TaskState.COMPLETED));
@ -768,12 +765,12 @@ public class TaskServiceImplTest {
try { try {
cutSpy.completeTask(task.getId(), isForced); cutSpy.completeTask(task.getId(), isForced);
} catch (InvalidStateException e) { } catch (InvalidStateException e) {
verify(taskanaEngineImpl, times(1)).openConnection(); verify(taskanaEngineMock, times(1)).openConnection();
verify(cutSpy, times(1)).getTask(task.getId()); verify(cutSpy, times(1)).getTask(task.getId());
verify(taskanaEngineImpl, times(1)).returnConnection(); verify(taskanaEngineMock, times(1)).returnConnection();
verifyNoMoreInteractions(attachmentMapperMock, taskanaEngineConfigurationMock, verifyNoMoreInteractions(attachmentMapperMock, taskanaEngineConfigurationMock,
taskanaEngineMock, taskanaEngineMock,
taskanaEngineImpl, taskMapperMock, objectReferenceMapperMock, workbasketServiceMock, sqlSessionMock, taskMapperMock, objectReferenceMapperMock, workbasketServiceMock, sqlSessionMock,
classificationQueryImplMock); classificationQueryImplMock);
throw e; throw e;
} }
@ -794,12 +791,12 @@ public class TaskServiceImplTest {
try { try {
cutSpy.completeTask(task.getId(), isForced); cutSpy.completeTask(task.getId(), isForced);
} catch (InvalidOwnerException e) { } catch (InvalidOwnerException e) {
verify(taskanaEngineImpl, times(1)).openConnection(); verify(taskanaEngineMock, times(1)).openConnection();
verify(cutSpy, times(1)).getTask(task.getId()); verify(cutSpy, times(1)).getTask(task.getId());
verify(taskanaEngineImpl, times(1)).returnConnection(); verify(taskanaEngineMock, times(1)).returnConnection();
verifyNoMoreInteractions(attachmentMapperMock, taskanaEngineConfigurationMock, verifyNoMoreInteractions(attachmentMapperMock, taskanaEngineConfigurationMock,
taskanaEngineMock, taskanaEngineMock,
taskanaEngineImpl, taskMapperMock, objectReferenceMapperMock, workbasketServiceMock, sqlSessionMock, taskMapperMock, objectReferenceMapperMock, workbasketServiceMock, sqlSessionMock,
classificationQueryImplMock); classificationQueryImplMock);
throw e; throw e;
} }
@ -815,12 +812,12 @@ public class TaskServiceImplTest {
try { try {
cutSpy.completeTask(taskId, isForced); cutSpy.completeTask(taskId, isForced);
} catch (InvalidOwnerException e) { } catch (InvalidOwnerException e) {
verify(taskanaEngineImpl, times(1)).openConnection(); verify(taskanaEngineMock, times(1)).openConnection();
verify(cutSpy, times(1)).getTask(taskId); verify(cutSpy, times(1)).getTask(taskId);
verify(taskanaEngineImpl, times(1)).returnConnection(); verify(taskanaEngineMock, times(1)).returnConnection();
verifyNoMoreInteractions(attachmentMapperMock, taskanaEngineConfigurationMock, verifyNoMoreInteractions(attachmentMapperMock, taskanaEngineConfigurationMock,
taskanaEngineMock, taskanaEngineMock,
taskanaEngineImpl, taskMapperMock, objectReferenceMapperMock, workbasketServiceMock, sqlSessionMock, taskMapperMock, objectReferenceMapperMock, workbasketServiceMock, sqlSessionMock,
classificationQueryImplMock); classificationQueryImplMock);
throw e; throw e;
} }
@ -844,12 +841,12 @@ public class TaskServiceImplTest {
Task actualTask = cutSpy.completeTask(task.getId(), isForced); Task actualTask = cutSpy.completeTask(task.getId(), isForced);
verify(taskanaEngineImpl, times(1)).openConnection(); verify(taskanaEngineMock, times(1)).openConnection();
verify(cutSpy, times(1)).getTask(task.getId()); verify(cutSpy, times(1)).getTask(task.getId());
verify(taskMapperMock, times(1)).update(task); verify(taskMapperMock, times(1)).update(task);
verify(taskanaEngineImpl, times(1)).returnConnection(); verify(taskanaEngineMock, times(1)).returnConnection();
verifyNoMoreInteractions(attachmentMapperMock, taskanaEngineConfigurationMock, taskanaEngineMock, verifyNoMoreInteractions(attachmentMapperMock, taskanaEngineConfigurationMock, taskanaEngineMock,
taskanaEngineImpl, taskMapperMock, objectReferenceMapperMock, workbasketServiceMock, sqlSessionMock, taskMapperMock, objectReferenceMapperMock, workbasketServiceMock, sqlSessionMock,
classificationQueryImplMock); classificationQueryImplMock);
assertThat(actualTask.getState(), equalTo(TaskState.COMPLETED)); assertThat(actualTask.getState(), equalTo(TaskState.COMPLETED));
@ -880,13 +877,13 @@ public class TaskServiceImplTest {
Task actualTask = cutSpy.completeTask(task.getId(), isForced); Task actualTask = cutSpy.completeTask(task.getId(), isForced);
verify(taskanaEngineImpl, times(1)).openConnection(); verify(taskanaEngineMock, times(1)).openConnection();
verify(cutSpy, times(1)).getTask(task.getId()); verify(cutSpy, times(1)).getTask(task.getId());
verify(cutSpy, times(1)).claim(task.getId(), isForced); verify(cutSpy, times(1)).claim(task.getId(), isForced);
verify(taskMapperMock, times(1)).update(claimedTask); verify(taskMapperMock, times(1)).update(claimedTask);
verify(taskanaEngineImpl, times(1)).returnConnection(); verify(taskanaEngineMock, times(1)).returnConnection();
verifyNoMoreInteractions(attachmentMapperMock, taskanaEngineConfigurationMock, taskanaEngineMock, verifyNoMoreInteractions(attachmentMapperMock, taskanaEngineConfigurationMock, taskanaEngineMock,
taskanaEngineImpl, taskMapperMock, objectReferenceMapperMock, workbasketServiceMock, sqlSessionMock, taskMapperMock, objectReferenceMapperMock, workbasketServiceMock, sqlSessionMock,
classificationQueryImplMock); classificationQueryImplMock);
assertThat(actualTask.getState(), equalTo(TaskState.COMPLETED)); assertThat(actualTask.getState(), equalTo(TaskState.COMPLETED));
assertThat(actualTask.getCreated(), not(equalTo(claimedTask.getModified()))); assertThat(actualTask.getCreated(), not(equalTo(claimedTask.getModified())));
@ -918,16 +915,16 @@ public class TaskServiceImplTest {
Task actualTask = cutSpy.transfer(task.getId(), destinationWorkbasket.getId()); Task actualTask = cutSpy.transfer(task.getId(), destinationWorkbasket.getId());
verify(taskanaEngineImpl, times(1)).openConnection(); verify(taskanaEngineMock, times(1)).openConnection();
verify(workbasketServiceMock, times(1)).checkAuthorization(destinationWorkbasket.getId(), verify(workbasketServiceMock, times(1)).checkAuthorization(destinationWorkbasket.getId(),
WorkbasketAuthorization.APPEND); WorkbasketAuthorization.APPEND);
verify(workbasketServiceMock, times(1)).checkAuthorization(sourceWorkbasket.getId(), verify(workbasketServiceMock, times(1)).checkAuthorization(sourceWorkbasket.getId(),
WorkbasketAuthorization.TRANSFER); WorkbasketAuthorization.TRANSFER);
verify(workbasketServiceMock, times(1)).getWorkbasket(destinationWorkbasket.getId()); verify(workbasketServiceMock, times(1)).getWorkbasket(destinationWorkbasket.getId());
verify(taskMapperMock, times(1)).update(any()); verify(taskMapperMock, times(1)).update(any());
verify(taskanaEngineImpl, times(1)).returnConnection(); verify(taskanaEngineMock, times(1)).returnConnection();
verifyNoMoreInteractions(attachmentMapperMock, taskanaEngineConfigurationMock, taskanaEngineMock, verifyNoMoreInteractions(attachmentMapperMock, taskanaEngineConfigurationMock, taskanaEngineMock,
taskanaEngineImpl, taskMapperMock, objectReferenceMapperMock, workbasketServiceMock, sqlSessionMock, taskMapperMock, objectReferenceMapperMock, workbasketServiceMock, sqlSessionMock,
classificationQueryImplMock); classificationQueryImplMock);
assertThat(actualTask.isRead(), equalTo(false)); assertThat(actualTask.isRead(), equalTo(false));
@ -954,15 +951,15 @@ public class TaskServiceImplTest {
// doNothing().when(workbasketServiceMock).checkAuthorizationById(any(), WorkbasketAuthorization.TRANSFER); // doNothing().when(workbasketServiceMock).checkAuthorizationById(any(), WorkbasketAuthorization.TRANSFER);
Task actualTask = cutSpy.transfer(task.getId(), destinationWorkbasket.getId()); Task actualTask = cutSpy.transfer(task.getId(), destinationWorkbasket.getId());
verify(taskanaEngineImpl, times(1)).openConnection(); verify(taskanaEngineMock, times(1)).openConnection();
verify(workbasketServiceMock, times(2)).checkAuthorization(any(), any()); verify(workbasketServiceMock, times(2)).checkAuthorization(any(), any());
verify(workbasketServiceMock, times(1)).getWorkbasket(destinationWorkbasket.getId()); verify(workbasketServiceMock, times(1)).getWorkbasket(destinationWorkbasket.getId());
verify(taskanaEngineMock, times(0)).getConfiguration(); verify(taskanaEngineMock, times(0)).getConfiguration();
verify(taskanaEngineConfigurationMock, times(0)).isSecurityEnabled(); verify(taskanaEngineConfigurationMock, times(0)).isSecurityEnabled();
verify(taskMapperMock, times(1)).update(any()); verify(taskMapperMock, times(1)).update(any());
verify(taskanaEngineImpl, times(1)).returnConnection(); verify(taskanaEngineMock, times(1)).returnConnection();
verifyNoMoreInteractions(attachmentMapperMock, taskanaEngineConfigurationMock, taskanaEngineMock, verifyNoMoreInteractions(attachmentMapperMock, taskanaEngineConfigurationMock, taskanaEngineMock,
taskanaEngineImpl, taskMapperMock, objectReferenceMapperMock, workbasketServiceMock, sqlSessionMock, taskMapperMock, objectReferenceMapperMock, workbasketServiceMock, sqlSessionMock,
classificationQueryImplMock); classificationQueryImplMock);
assertThat(actualTask.isRead(), equalTo(false)); assertThat(actualTask.isRead(), equalTo(false));
@ -986,13 +983,13 @@ public class TaskServiceImplTest {
try { try {
cutSpy.transfer(task.getId(), destinationWorkbasketId); cutSpy.transfer(task.getId(), destinationWorkbasketId);
} catch (Exception e) { } catch (Exception e) {
verify(taskanaEngineImpl, times(1)).openConnection(); verify(taskanaEngineMock, times(1)).openConnection();
verify(workbasketServiceMock, times(1)).checkAuthorization(destinationWorkbasketId, verify(workbasketServiceMock, times(1)).checkAuthorization(destinationWorkbasketId,
WorkbasketAuthorization.APPEND); WorkbasketAuthorization.APPEND);
verify(taskanaEngineImpl, times(1)).returnConnection(); verify(taskanaEngineMock, times(1)).returnConnection();
verifyNoMoreInteractions(attachmentMapperMock, taskanaEngineConfigurationMock, verifyNoMoreInteractions(attachmentMapperMock, taskanaEngineConfigurationMock,
taskanaEngineMock, taskanaEngineMock,
taskanaEngineImpl, taskMapperMock, objectReferenceMapperMock, workbasketServiceMock, sqlSessionMock, taskMapperMock, objectReferenceMapperMock, workbasketServiceMock, sqlSessionMock,
classificationQueryImplMock); classificationQueryImplMock);
throw e; throw e;
} }
@ -1010,11 +1007,11 @@ public class TaskServiceImplTest {
try { try {
cutSpy.transfer(task.getId(), "2"); cutSpy.transfer(task.getId(), "2");
} catch (Exception e) { } catch (Exception e) {
verify(taskanaEngineImpl, times(1)).openConnection(); verify(taskanaEngineMock, times(1)).openConnection();
verify(taskanaEngineImpl, times(1)).returnConnection(); verify(taskanaEngineMock, times(1)).returnConnection();
verifyNoMoreInteractions(attachmentMapperMock, taskanaEngineConfigurationMock, verifyNoMoreInteractions(attachmentMapperMock, taskanaEngineConfigurationMock,
taskanaEngineMock, taskanaEngineMock,
taskanaEngineImpl, taskMapperMock, objectReferenceMapperMock, workbasketServiceMock, sqlSessionMock, taskMapperMock, objectReferenceMapperMock, workbasketServiceMock, sqlSessionMock,
classificationQueryImplMock); classificationQueryImplMock);
throw e; throw e;
} }
@ -1035,13 +1032,13 @@ public class TaskServiceImplTest {
try { try {
cutSpy.transfer(task.getId(), destinationWorkbasketId); cutSpy.transfer(task.getId(), destinationWorkbasketId);
} catch (Exception e) { } catch (Exception e) {
verify(taskanaEngineImpl, times(1)).openConnection(); verify(taskanaEngineMock, times(1)).openConnection();
verify(workbasketServiceMock, times(1)).checkAuthorization(destinationWorkbasketId, verify(workbasketServiceMock, times(1)).checkAuthorization(destinationWorkbasketId,
WorkbasketAuthorization.APPEND); WorkbasketAuthorization.APPEND);
verify(taskanaEngineImpl, times(1)).returnConnection(); verify(taskanaEngineMock, times(1)).returnConnection();
verifyNoMoreInteractions(attachmentMapperMock, taskanaEngineConfigurationMock, verifyNoMoreInteractions(attachmentMapperMock, taskanaEngineConfigurationMock,
taskanaEngineMock, taskanaEngineMock,
taskanaEngineImpl, taskMapperMock, objectReferenceMapperMock, workbasketServiceMock, sqlSessionMock, taskMapperMock, objectReferenceMapperMock, workbasketServiceMock, sqlSessionMock,
classificationQueryImplMock); classificationQueryImplMock);
throw e; throw e;
} }
@ -1064,15 +1061,15 @@ public class TaskServiceImplTest {
try { try {
cutSpy.transfer(task.getId(), destinationWorkbasketId); cutSpy.transfer(task.getId(), destinationWorkbasketId);
} catch (Exception e) { } catch (Exception e) {
verify(taskanaEngineImpl, times(1)).openConnection(); verify(taskanaEngineMock, times(1)).openConnection();
verify(workbasketServiceMock, times(1)).checkAuthorization(destinationWorkbasketId, verify(workbasketServiceMock, times(1)).checkAuthorization(destinationWorkbasketId,
WorkbasketAuthorization.APPEND); WorkbasketAuthorization.APPEND);
verify(workbasketServiceMock, times(1)).checkAuthorization(task.getWorkbasketSummary().getId(), verify(workbasketServiceMock, times(1)).checkAuthorization(task.getWorkbasketSummary().getId(),
WorkbasketAuthorization.TRANSFER); WorkbasketAuthorization.TRANSFER);
verify(taskanaEngineImpl, times(1)).returnConnection(); verify(taskanaEngineMock, times(1)).returnConnection();
verifyNoMoreInteractions(attachmentMapperMock, taskanaEngineConfigurationMock, verifyNoMoreInteractions(attachmentMapperMock, taskanaEngineConfigurationMock,
taskanaEngineMock, taskanaEngineMock,
taskanaEngineImpl, taskMapperMock, objectReferenceMapperMock, workbasketServiceMock, sqlSessionMock, taskMapperMock, objectReferenceMapperMock, workbasketServiceMock, sqlSessionMock,
classificationQueryImplMock); classificationQueryImplMock);
throw e; throw e;
} }
@ -1090,11 +1087,11 @@ public class TaskServiceImplTest {
Task actualTask = cutSpy.setTaskRead("1", true); Task actualTask = cutSpy.setTaskRead("1", true);
verify(taskanaEngineImpl, times(1)).openConnection(); verify(taskanaEngineMock, times(1)).openConnection();
verify(taskMapperMock, times(1)).update(task); verify(taskMapperMock, times(1)).update(task);
verify(taskanaEngineImpl, times(1)).returnConnection(); verify(taskanaEngineMock, times(1)).returnConnection();
verifyNoMoreInteractions(attachmentMapperMock, taskanaEngineConfigurationMock, taskanaEngineMock, verifyNoMoreInteractions(attachmentMapperMock, taskanaEngineConfigurationMock, taskanaEngineMock,
taskanaEngineImpl, taskMapperMock, objectReferenceMapperMock, workbasketServiceMock, sqlSessionMock, taskMapperMock, objectReferenceMapperMock, workbasketServiceMock, sqlSessionMock,
classificationQueryImplMock); classificationQueryImplMock);
assertThat(actualTask.getModified(), not(equalTo(null))); assertThat(actualTask.getModified(), not(equalTo(null)));
assertThat(actualTask.isRead(), equalTo(true)); assertThat(actualTask.isRead(), equalTo(true));
@ -1111,11 +1108,10 @@ public class TaskServiceImplTest {
try { try {
cutSpy.setTaskRead("1", true); cutSpy.setTaskRead("1", true);
} catch (Exception e) { } catch (Exception e) {
verify(taskanaEngineImpl, times(1)).openConnection(); verify(taskanaEngineMock, times(1)).openConnection();
verify(taskanaEngineImpl, times(1)).returnConnection(); verify(taskanaEngineMock, times(1)).returnConnection();
verifyNoMoreInteractions(attachmentMapperMock, taskanaEngineConfigurationMock, verifyNoMoreInteractions(attachmentMapperMock, taskanaEngineConfigurationMock,
taskanaEngineMock, taskanaEngineMock,
taskanaEngineImpl,
taskMapperMock, objectReferenceMapperMock, workbasketServiceMock, sqlSessionMock, taskMapperMock, objectReferenceMapperMock, workbasketServiceMock, sqlSessionMock,
classificationQueryImplMock); classificationQueryImplMock);
throw e; throw e;
@ -1142,16 +1138,16 @@ public class TaskServiceImplTest {
.list(); .list();
Task actualTask = cut.getTask(expectedTask.getId()); Task actualTask = cut.getTask(expectedTask.getId());
verify(taskanaEngineImpl, times(1)).openConnection(); verify(taskanaEngineMock, times(1)).openConnection();
verify(taskMapperMock, times(1)).findById(expectedTask.getId()); verify(taskMapperMock, times(1)).findById(expectedTask.getId());
verify(attachmentMapperMock, times(1)).findAttachmentsByTaskId(expectedTask.getId()); verify(attachmentMapperMock, times(1)).findAttachmentsByTaskId(expectedTask.getId());
verify(classificationServiceImplMock, times(1)).createClassificationQuery(); verify(classificationServiceImplMock, times(1)).createClassificationQuery();
verify(classificationQueryImplMock, times(1)).domainIn(any()); verify(classificationQueryImplMock, times(1)).domainIn(any());
verify(classificationQueryImplMock, times(1)).keyIn(any()); verify(classificationQueryImplMock, times(1)).keyIn(any());
verify(classificationQueryImplMock, times(1)).list(); verify(classificationQueryImplMock, times(1)).list();
verify(taskanaEngineImpl, times(1)).returnConnection(); verify(taskanaEngineMock, times(1)).returnConnection();
verifyNoMoreInteractions(attachmentMapperMock, taskanaEngineConfigurationMock, taskanaEngineMock, verifyNoMoreInteractions(attachmentMapperMock, taskanaEngineConfigurationMock, taskanaEngineMock,
taskanaEngineImpl, taskMapperMock, objectReferenceMapperMock, workbasketServiceMock, sqlSessionMock, taskMapperMock, objectReferenceMapperMock, workbasketServiceMock, sqlSessionMock,
classificationQueryImplMock); classificationQueryImplMock);
assertThat(actualTask, equalTo(expectedTask)); assertThat(actualTask, equalTo(expectedTask));
} }
@ -1165,12 +1161,12 @@ public class TaskServiceImplTest {
try { try {
cut.getTask(task.getId()); cut.getTask(task.getId());
} catch (Exception e) { } catch (Exception e) {
verify(taskanaEngineImpl, times(1)).openConnection(); verify(taskanaEngineMock, times(1)).openConnection();
verify(taskMapperMock, times(1)).findById(task.getId()); verify(taskMapperMock, times(1)).findById(task.getId());
verify(taskanaEngineImpl, times(1)).returnConnection(); verify(taskanaEngineMock, times(1)).returnConnection();
verifyNoMoreInteractions(attachmentMapperMock, taskanaEngineConfigurationMock, verifyNoMoreInteractions(attachmentMapperMock, taskanaEngineConfigurationMock,
taskanaEngineMock, taskanaEngineMock,
taskanaEngineImpl, taskMapperMock, objectReferenceMapperMock, workbasketServiceMock, sqlSessionMock, taskMapperMock, objectReferenceMapperMock, workbasketServiceMock, sqlSessionMock,
classificationQueryImplMock); classificationQueryImplMock);
throw e; throw e;
} }
@ -1197,10 +1193,10 @@ public class TaskServiceImplTest {
Task actualTask = cutSpy.updateTask(task); Task actualTask = cutSpy.updateTask(task);
verify(taskanaEngineImpl, times(1)).openConnection(); verify(taskanaEngineMock, times(1)).openConnection();
verify(cutSpy, times(1)).getTask(task.getId()); verify(cutSpy, times(1)).getTask(task.getId());
verify(attachmentMapperMock, times(1)).insert(((AttachmentImpl) attachment)); verify(attachmentMapperMock, times(1)).insert(((AttachmentImpl) attachment));
verify(taskanaEngineImpl, times(1)).returnConnection(); verify(taskanaEngineMock, times(1)).returnConnection();
assertThat(actualTask.getAttachments().size(), equalTo(1)); assertThat(actualTask.getAttachments().size(), equalTo(1));
} }
@ -1226,10 +1222,10 @@ public class TaskServiceImplTest {
Task actualTask = cutSpy.updateTask(task); Task actualTask = cutSpy.updateTask(task);
verify(taskanaEngineImpl, times(1)).openConnection(); verify(taskanaEngineMock, times(1)).openConnection();
verify(cutSpy, times(1)).getTask(task.getId()); verify(cutSpy, times(1)).getTask(task.getId());
verify(attachmentMapperMock, times(1)).insert(((AttachmentImpl) attachment)); verify(attachmentMapperMock, times(1)).insert(((AttachmentImpl) attachment));
verify(taskanaEngineImpl, times(1)).returnConnection(); verify(taskanaEngineMock, times(1)).returnConnection();
assertThat(actualTask.getAttachments().size(), equalTo(1)); assertThat(actualTask.getAttachments().size(), equalTo(1));
} }
@ -1259,10 +1255,10 @@ public class TaskServiceImplTest {
try { try {
cutSpy.updateTask(task); cutSpy.updateTask(task);
} catch (AttachmentPersistenceException e) { } catch (AttachmentPersistenceException e) {
verify(taskanaEngineImpl, times(1)).openConnection(); verify(taskanaEngineMock, times(1)).openConnection();
verify(cutSpy, times(1)).getTask(task.getId()); verify(cutSpy, times(1)).getTask(task.getId());
verify(attachmentMapperMock, times(1)).insert(((AttachmentImpl) attachment)); verify(attachmentMapperMock, times(1)).insert(((AttachmentImpl) attachment));
verify(taskanaEngineImpl, times(1)).returnConnection(); verify(taskanaEngineMock, times(1)).returnConnection();
throw e; throw e;
} }
} }
@ -1293,10 +1289,10 @@ public class TaskServiceImplTest {
Task actualTask = cutSpy.updateTask(task); Task actualTask = cutSpy.updateTask(task);
verify(taskanaEngineImpl, times(1)).openConnection(); verify(taskanaEngineMock, times(1)).openConnection();
verify(cutSpy, times(1)).getTask(task.getId()); verify(cutSpy, times(1)).getTask(task.getId());
verify(attachmentMapperMock, times(1)).update(((AttachmentImpl) attachmentToUpdate)); verify(attachmentMapperMock, times(1)).update(((AttachmentImpl) attachmentToUpdate));
verify(taskanaEngineImpl, times(1)).returnConnection(); verify(taskanaEngineMock, times(1)).returnConnection();
assertThat(actualTask.getAttachments().size(), equalTo(1)); assertThat(actualTask.getAttachments().size(), equalTo(1));
assertThat(actualTask.getAttachments().get(0).getChannel(), equalTo(channelUpdate)); assertThat(actualTask.getAttachments().get(0).getChannel(), equalTo(channelUpdate));
} }
@ -1323,10 +1319,10 @@ public class TaskServiceImplTest {
Task actualTask = cutSpy.updateTask(task); Task actualTask = cutSpy.updateTask(task);
verify(taskanaEngineImpl, times(1)).openConnection(); verify(taskanaEngineMock, times(1)).openConnection();
verify(cutSpy, times(1)).getTask(task.getId()); verify(cutSpy, times(1)).getTask(task.getId());
verify(attachmentMapperMock, times(1)).deleteAttachment(attachment.getId()); verify(attachmentMapperMock, times(1)).deleteAttachment(attachment.getId());
verify(taskanaEngineImpl, times(1)).returnConnection(); verify(taskanaEngineMock, times(1)).returnConnection();
assertThat(actualTask.getAttachments().size(), equalTo(0)); assertThat(actualTask.getAttachments().size(), equalTo(0));
} }

View File

@ -218,6 +218,7 @@ public class WorkbasketServiceImplTest {
} catch (InvalidWorkbasketException ex) { } catch (InvalidWorkbasketException ex) {
verify(taskanaEngineImplMock, times(serviceCalls)).openConnection(); verify(taskanaEngineImplMock, times(serviceCalls)).openConnection();
verify(taskanaEngineImplMock, times(serviceCalls)).returnConnection(); verify(taskanaEngineImplMock, times(serviceCalls)).returnConnection();
verify(taskanaEngineImplMock, times(serviceCalls)).checkRoleMembership(any());
verifyNoMoreInteractions(taskQueryMock, taskServiceMock, workbasketMapperMock, workbasketAccessMapperMock, verifyNoMoreInteractions(taskQueryMock, taskServiceMock, workbasketMapperMock, workbasketAccessMapperMock,
distributionTargetMapperMock, distributionTargetMapperMock,
taskanaEngineImplMock, taskanaEngineConfigurationMock); taskanaEngineImplMock, taskanaEngineConfigurationMock);
@ -234,6 +235,7 @@ public class WorkbasketServiceImplTest {
} catch (InvalidWorkbasketException ex) { } catch (InvalidWorkbasketException ex) {
verify(taskanaEngineImplMock, times(serviceCalls)).openConnection(); verify(taskanaEngineImplMock, times(serviceCalls)).openConnection();
verify(taskanaEngineImplMock, times(serviceCalls)).returnConnection(); verify(taskanaEngineImplMock, times(serviceCalls)).returnConnection();
verify(taskanaEngineImplMock, times(serviceCalls)).checkRoleMembership(any());
verifyNoMoreInteractions(taskQueryMock, taskServiceMock, workbasketMapperMock, workbasketAccessMapperMock, verifyNoMoreInteractions(taskQueryMock, taskServiceMock, workbasketMapperMock, workbasketAccessMapperMock,
distributionTargetMapperMock, distributionTargetMapperMock,
taskanaEngineImplMock, taskanaEngineConfigurationMock); taskanaEngineImplMock, taskanaEngineConfigurationMock);
@ -251,6 +253,7 @@ public class WorkbasketServiceImplTest {
} catch (InvalidWorkbasketException ex) { } catch (InvalidWorkbasketException ex) {
verify(taskanaEngineImplMock, times(serviceCalls)).openConnection(); verify(taskanaEngineImplMock, times(serviceCalls)).openConnection();
verify(taskanaEngineImplMock, times(serviceCalls)).returnConnection(); verify(taskanaEngineImplMock, times(serviceCalls)).returnConnection();
verify(taskanaEngineImplMock, times(serviceCalls)).checkRoleMembership(any());
verifyNoMoreInteractions(taskQueryMock, taskServiceMock, workbasketMapperMock, workbasketAccessMapperMock, verifyNoMoreInteractions(taskQueryMock, taskServiceMock, workbasketMapperMock, workbasketAccessMapperMock,
distributionTargetMapperMock, distributionTargetMapperMock,
taskanaEngineImplMock, taskanaEngineConfigurationMock); taskanaEngineImplMock, taskanaEngineConfigurationMock);
@ -267,6 +270,7 @@ public class WorkbasketServiceImplTest {
} catch (InvalidWorkbasketException ex) { } catch (InvalidWorkbasketException ex) {
verify(taskanaEngineImplMock, times(serviceCalls)).openConnection(); verify(taskanaEngineImplMock, times(serviceCalls)).openConnection();
verify(taskanaEngineImplMock, times(serviceCalls)).returnConnection(); verify(taskanaEngineImplMock, times(serviceCalls)).returnConnection();
verify(taskanaEngineImplMock, times(serviceCalls)).checkRoleMembership(any());
verifyNoMoreInteractions(taskQueryMock, taskServiceMock, workbasketMapperMock, workbasketAccessMapperMock, verifyNoMoreInteractions(taskQueryMock, taskServiceMock, workbasketMapperMock, workbasketAccessMapperMock,
distributionTargetMapperMock, distributionTargetMapperMock,
taskanaEngineImplMock, taskanaEngineConfigurationMock); taskanaEngineImplMock, taskanaEngineConfigurationMock);
@ -284,6 +288,7 @@ public class WorkbasketServiceImplTest {
} catch (InvalidWorkbasketException ex) { } catch (InvalidWorkbasketException ex) {
verify(taskanaEngineImplMock, times(serviceCalls)).openConnection(); verify(taskanaEngineImplMock, times(serviceCalls)).openConnection();
verify(taskanaEngineImplMock, times(serviceCalls)).returnConnection(); verify(taskanaEngineImplMock, times(serviceCalls)).returnConnection();
verify(taskanaEngineImplMock, times(serviceCalls)).checkRoleMembership(any());
verifyNoMoreInteractions(taskQueryMock, taskServiceMock, workbasketMapperMock, workbasketAccessMapperMock, verifyNoMoreInteractions(taskQueryMock, taskServiceMock, workbasketMapperMock, workbasketAccessMapperMock,
distributionTargetMapperMock, distributionTargetMapperMock,
taskanaEngineImplMock, taskanaEngineConfigurationMock); taskanaEngineImplMock, taskanaEngineConfigurationMock);
@ -301,6 +306,7 @@ public class WorkbasketServiceImplTest {
} catch (InvalidWorkbasketException ex) { } catch (InvalidWorkbasketException ex) {
verify(taskanaEngineImplMock, times(serviceCalls)).openConnection(); verify(taskanaEngineImplMock, times(serviceCalls)).openConnection();
verify(taskanaEngineImplMock, times(serviceCalls)).returnConnection(); verify(taskanaEngineImplMock, times(serviceCalls)).returnConnection();
verify(taskanaEngineImplMock, times(serviceCalls)).checkRoleMembership(any());
verifyNoMoreInteractions(taskQueryMock, taskServiceMock, workbasketMapperMock, workbasketAccessMapperMock, verifyNoMoreInteractions(taskQueryMock, taskServiceMock, workbasketMapperMock, workbasketAccessMapperMock,
distributionTargetMapperMock, distributionTargetMapperMock,
taskanaEngineImplMock, taskanaEngineConfigurationMock); taskanaEngineImplMock, taskanaEngineConfigurationMock);
@ -330,6 +336,8 @@ public class WorkbasketServiceImplTest {
verify(workbasketMapperMock, times(2)).findById(expectedWb.getId()); verify(workbasketMapperMock, times(2)).findById(expectedWb.getId());
verify(workbasketMapperMock, times(1)).update(any()); verify(workbasketMapperMock, times(1)).update(any());
verify(taskanaEngineImplMock, times(5)).returnConnection(); verify(taskanaEngineImplMock, times(5)).returnConnection();
verify(taskanaEngineImplMock, times(2)).checkRoleMembership(any());
verify(taskanaEngineImplMock, times(2)).isUserInRole(any());
verify(distributionTargetMapperMock, times(1)).deleteAllDistributionTargetsBySourceId(any()); verify(distributionTargetMapperMock, times(1)).deleteAllDistributionTargetsBySourceId(any());
verifyNoMoreInteractions(taskQueryMock, taskServiceMock, workbasketMapperMock, workbasketAccessMapperMock, verifyNoMoreInteractions(taskQueryMock, taskServiceMock, workbasketMapperMock, workbasketAccessMapperMock,
distributionTargetMapperMock, distributionTargetMapperMock,
@ -364,6 +372,8 @@ public class WorkbasketServiceImplTest {
verify(workbasketMapperMock, times(3)).findById(any()); verify(workbasketMapperMock, times(3)).findById(any());
verify(workbasketMapperMock, times(1)).update(any()); verify(workbasketMapperMock, times(1)).update(any());
verify(taskanaEngineImplMock, times(5)).returnConnection(); verify(taskanaEngineImplMock, times(5)).returnConnection();
verify(taskanaEngineImplMock, times(4)).checkRoleMembership(any());
verify(taskanaEngineImplMock, times(1)).isUserInRole(any());
verifyNoMoreInteractions(taskQueryMock, taskServiceMock, workbasketMapperMock, workbasketAccessMapperMock, verifyNoMoreInteractions(taskQueryMock, taskServiceMock, workbasketMapperMock, workbasketAccessMapperMock,
distributionTargetMapperMock, distributionTargetMapperMock,
taskanaEngineImplMock, taskanaEngineConfigurationMock); taskanaEngineImplMock, taskanaEngineConfigurationMock);
@ -392,6 +402,7 @@ public class WorkbasketServiceImplTest {
verify(workbasketMapperMock, times(2)).findById(any()); verify(workbasketMapperMock, times(2)).findById(any());
verify(cutSpy, times(1)).getWorkbasket(any()); verify(cutSpy, times(1)).getWorkbasket(any());
verify(taskanaEngineImplMock, times(3)).returnConnection(); verify(taskanaEngineImplMock, times(3)).returnConnection();
verify(taskanaEngineImplMock, times(2)).checkRoleMembership(any());
verifyNoMoreInteractions(taskQueryMock, taskServiceMock, workbasketMapperMock, workbasketAccessMapperMock, verifyNoMoreInteractions(taskQueryMock, taskServiceMock, workbasketMapperMock, workbasketAccessMapperMock,
distributionTargetMapperMock, distributionTargetMapperMock,
taskanaEngineImplMock, taskanaEngineConfigurationMock); taskanaEngineImplMock, taskanaEngineConfigurationMock);
@ -432,6 +443,7 @@ public class WorkbasketServiceImplTest {
} catch (InvalidArgumentException e) { } catch (InvalidArgumentException e) {
verify(taskanaEngineImplMock, times(1)).openConnection(); verify(taskanaEngineImplMock, times(1)).openConnection();
verify(taskanaEngineImplMock, times(1)).returnConnection(); verify(taskanaEngineImplMock, times(1)).returnConnection();
verify(taskanaEngineImplMock, times(1)).checkRoleMembership(any());
verifyNoMoreInteractions(taskQueryMock, taskServiceMock, workbasketMapperMock, workbasketAccessMapperMock, verifyNoMoreInteractions(taskQueryMock, taskServiceMock, workbasketMapperMock, workbasketAccessMapperMock,
distributionTargetMapperMock, distributionTargetMapperMock,
taskanaEngineImplMock, taskanaEngineConfigurationMock); taskanaEngineImplMock, taskanaEngineConfigurationMock);
@ -444,6 +456,7 @@ public class WorkbasketServiceImplTest {
} catch (InvalidArgumentException e) { } catch (InvalidArgumentException e) {
verify(taskanaEngineImplMock, times(2)).openConnection(); verify(taskanaEngineImplMock, times(2)).openConnection();
verify(taskanaEngineImplMock, times(2)).returnConnection(); verify(taskanaEngineImplMock, times(2)).returnConnection();
verify(taskanaEngineImplMock, times(2)).checkRoleMembership(any());
verifyNoMoreInteractions(taskQueryMock, taskServiceMock, workbasketMapperMock, workbasketAccessMapperMock, verifyNoMoreInteractions(taskQueryMock, taskServiceMock, workbasketMapperMock, workbasketAccessMapperMock,
distributionTargetMapperMock, distributionTargetMapperMock,
taskanaEngineImplMock, taskanaEngineConfigurationMock); taskanaEngineImplMock, taskanaEngineConfigurationMock);
@ -461,6 +474,7 @@ public class WorkbasketServiceImplTest {
verify(taskanaEngineImplMock, times(1)).openConnection(); verify(taskanaEngineImplMock, times(1)).openConnection();
verify(cutSpy, times(1)).getWorkbasket(workbasketId); verify(cutSpy, times(1)).getWorkbasket(workbasketId);
verify(taskanaEngineImplMock, times(1)).returnConnection(); verify(taskanaEngineImplMock, times(1)).returnConnection();
verify(taskanaEngineImplMock, times(1)).checkRoleMembership(any());
verifyNoMoreInteractions(taskQueryMock, taskServiceMock, workbasketMapperMock, workbasketAccessMapperMock, verifyNoMoreInteractions(taskQueryMock, taskServiceMock, workbasketMapperMock, workbasketAccessMapperMock,
distributionTargetMapperMock, distributionTargetMapperMock,
taskanaEngineImplMock, taskanaEngineConfigurationMock); taskanaEngineImplMock, taskanaEngineConfigurationMock);
@ -519,6 +533,7 @@ public class WorkbasketServiceImplTest {
verify(workbasketAccessMapperMock, times(1)).deleteAllAccessItemsForWorkbasketId(wb.getId()); verify(workbasketAccessMapperMock, times(1)).deleteAllAccessItemsForWorkbasketId(wb.getId());
verify(workbasketMapperMock, times(1)).delete(wb.getId()); verify(workbasketMapperMock, times(1)).delete(wb.getId());
verify(taskanaEngineImplMock, times(1)).returnConnection(); verify(taskanaEngineImplMock, times(1)).returnConnection();
verify(taskanaEngineImplMock, times(1)).checkRoleMembership(any());
verifyNoMoreInteractions(taskQueryMock, taskServiceMock, workbasketMapperMock, workbasketAccessMapperMock, verifyNoMoreInteractions(taskQueryMock, taskServiceMock, workbasketMapperMock, workbasketAccessMapperMock,
distributionTargetMapperMock, distributionTargetMapperMock,
taskanaEngineImplMock, taskanaEngineConfigurationMock); taskanaEngineImplMock, taskanaEngineConfigurationMock);

View File

@ -71,7 +71,7 @@ public class ClassificationServiceImplIntAutoCommitTest {
@Before @Before
public void setup() throws FileNotFoundException, SQLException, LoginException { public void setup() throws FileNotFoundException, SQLException, LoginException {
dataSource = TaskanaEngineConfigurationTest.getDataSource(); dataSource = TaskanaEngineConfigurationTest.getDataSource();
taskanaEngineConfiguration = new TaskanaEngineConfiguration(dataSource, false); taskanaEngineConfiguration = new TaskanaEngineConfiguration(dataSource, false, false);
taskanaEngine = taskanaEngineConfiguration.buildTaskanaEngine(); taskanaEngine = taskanaEngineConfiguration.buildTaskanaEngine();
classificationService = taskanaEngine.getClassificationService(); classificationService = taskanaEngine.getClassificationService();
taskanaEngineImpl = (TaskanaEngineImpl) taskanaEngine; taskanaEngineImpl = (TaskanaEngineImpl) taskanaEngine;
@ -159,7 +159,7 @@ public class ClassificationServiceImplIntAutoCommitTest {
} }
@Test @Test
public void testFindAllClassifications() throws ClassificationAlreadyExistException { public void testFindAllClassifications() throws ClassificationAlreadyExistException, NotAuthorizedException {
Classification classification0 = this.createDummyClassificationWithUniqueKey("", "type1"); Classification classification0 = this.createDummyClassificationWithUniqueKey("", "type1");
classificationService.createClassification(classification0); classificationService.createClassification(classification0);
Classification classification1 = this.createDummyClassificationWithUniqueKey("", "type1"); Classification classification1 = this.createDummyClassificationWithUniqueKey("", "type1");
@ -223,7 +223,8 @@ public class ClassificationServiceImplIntAutoCommitTest {
} }
@Test @Test
public void testFindWithClassificationMapperDomainAndCategory() throws ClassificationAlreadyExistException { public void testFindWithClassificationMapperDomainAndCategory()
throws ClassificationAlreadyExistException, NotAuthorizedException {
Classification classification1 = this.createDummyClassificationWithUniqueKey("domain1", "type1"); Classification classification1 = this.createDummyClassificationWithUniqueKey("domain1", "type1");
classification1.setCategory("category1"); classification1.setCategory("category1");
classificationService.createClassification(classification1); classificationService.createClassification(classification1);
@ -244,7 +245,8 @@ public class ClassificationServiceImplIntAutoCommitTest {
} }
@Test @Test
public void testFindWithClassificationMapperCustomAndCategory() throws ClassificationAlreadyExistException { public void testFindWithClassificationMapperCustomAndCategory()
throws ClassificationAlreadyExistException, NotAuthorizedException {
Classification classification1 = this.createDummyClassificationWithUniqueKey("", "type1"); Classification classification1 = this.createDummyClassificationWithUniqueKey("", "type1");
classification1.setDescription("DESC1"); classification1.setDescription("DESC1");
classification1.setCategory("category1"); classification1.setCategory("category1");
@ -281,7 +283,7 @@ public class ClassificationServiceImplIntAutoCommitTest {
@Test @Test
public void testFindWithClassificationMapperPriorityTypeAndParent() public void testFindWithClassificationMapperPriorityTypeAndParent()
throws ClassificationAlreadyExistException, NumberFormatException { throws ClassificationAlreadyExistException, NumberFormatException, NotAuthorizedException {
Classification classification = this.createDummyClassificationWithUniqueKey("", "type1"); Classification classification = this.createDummyClassificationWithUniqueKey("", "type1");
classification.setPriority(Integer.decode("5")); classification.setPriority(Integer.decode("5"));
classificationService.createClassification(classification); classificationService.createClassification(classification);
@ -315,7 +317,7 @@ public class ClassificationServiceImplIntAutoCommitTest {
@Test @Test
public void testFindWithClassificationMapperServiceLevelNameAndDescription() public void testFindWithClassificationMapperServiceLevelNameAndDescription()
throws ClassificationAlreadyExistException { throws ClassificationAlreadyExistException, NotAuthorizedException {
int all = 0; int all = 0;
Classification classification = this.createDummyClassificationWithUniqueKey("", "type1"); Classification classification = this.createDummyClassificationWithUniqueKey("", "type1");
classification.setServiceLevel("P1D"); classification.setServiceLevel("P1D");
@ -395,7 +397,8 @@ public class ClassificationServiceImplIntAutoCommitTest {
return new TimeInterval(begin, end); return new TimeInterval(begin, end);
} }
private Classification createDummyClassificationWithUniqueKey(String domain, String type) { private Classification createDummyClassificationWithUniqueKey(String domain, String type)
throws NotAuthorizedException {
Classification classification = classificationService.newClassification("TEST" + counter, domain, type); Classification classification = classificationService.newClassification("TEST" + counter, domain, type);
counter++; counter++;
return classification; return classification;

View File

@ -72,7 +72,7 @@ public class ClassificationServiceImplIntExplicitTest {
@Before @Before
public void setup() throws SQLException { public void setup() throws SQLException {
dataSource = TaskanaEngineConfigurationTest.getDataSource(); dataSource = TaskanaEngineConfigurationTest.getDataSource();
taskanaEngineConfiguration = new TaskanaEngineConfiguration(dataSource, false); taskanaEngineConfiguration = new TaskanaEngineConfiguration(dataSource, false, false);
taskanaEngine = taskanaEngineConfiguration.buildTaskanaEngine(); taskanaEngine = taskanaEngineConfiguration.buildTaskanaEngine();
classificationService = taskanaEngine.getClassificationService(); classificationService = taskanaEngine.getClassificationService();
taskanaEngineImpl = (TaskanaEngineImpl) taskanaEngine; taskanaEngineImpl = (TaskanaEngineImpl) taskanaEngine;
@ -83,7 +83,8 @@ public class ClassificationServiceImplIntExplicitTest {
@Test @Test
public void testInsertClassification() public void testInsertClassification()
throws SQLException, ClassificationNotFoundException, ClassificationAlreadyExistException { throws SQLException, ClassificationNotFoundException, ClassificationAlreadyExistException,
NotAuthorizedException {
Connection connection = dataSource.getConnection(); Connection connection = dataSource.getConnection();
taskanaEngineImpl.setConnection(connection); taskanaEngineImpl.setConnection(connection);
@ -168,7 +169,8 @@ public class ClassificationServiceImplIntExplicitTest {
} }
@Test @Test
public void testFindAllClassifications() throws SQLException, ClassificationAlreadyExistException { public void testFindAllClassifications()
throws SQLException, ClassificationAlreadyExistException, NotAuthorizedException {
Connection connection = dataSource.getConnection(); Connection connection = dataSource.getConnection();
taskanaEngineImpl.setConnection(connection); taskanaEngineImpl.setConnection(connection);
Classification classification0 = this.createNewClassificationWithUniqueKey("", "t1"); Classification classification0 = this.createNewClassificationWithUniqueKey("", "t1");
@ -205,7 +207,7 @@ public class ClassificationServiceImplIntExplicitTest {
@Test @Test
public void testInsertAndClassificationQuery() public void testInsertAndClassificationQuery()
throws SQLException, ClassificationAlreadyExistException { throws SQLException, ClassificationAlreadyExistException, NotAuthorizedException {
Connection connection = dataSource.getConnection(); Connection connection = dataSource.getConnection();
taskanaEngineImpl.setConnection(connection); taskanaEngineImpl.setConnection(connection);
Classification classification = this.createNewClassificationWithUniqueKey("", "t1"); Classification classification = this.createNewClassificationWithUniqueKey("", "t1");
@ -248,7 +250,7 @@ public class ClassificationServiceImplIntExplicitTest {
@Test @Test
public void testFindWithClassificationMapperDomainAndCategory() public void testFindWithClassificationMapperDomainAndCategory()
throws SQLException, ClassificationAlreadyExistException { throws SQLException, ClassificationAlreadyExistException, NotAuthorizedException {
Connection connection = dataSource.getConnection(); Connection connection = dataSource.getConnection();
taskanaEngineImpl.setConnection(connection); taskanaEngineImpl.setConnection(connection);
Classification classification1 = this.createNewClassificationWithUniqueKey("domain1", "t1"); Classification classification1 = this.createNewClassificationWithUniqueKey("domain1", "t1");
@ -274,7 +276,7 @@ public class ClassificationServiceImplIntExplicitTest {
@Test @Test
public void testFindWithClassificationMapperCustomAndCategory() public void testFindWithClassificationMapperCustomAndCategory()
throws SQLException, ClassificationAlreadyExistException { throws SQLException, ClassificationAlreadyExistException, NotAuthorizedException {
Connection connection = dataSource.getConnection(); Connection connection = dataSource.getConnection();
taskanaEngineImpl.setConnection(connection); taskanaEngineImpl.setConnection(connection);
Classification classification1 = this.createNewClassificationWithUniqueKey("", "t1"); Classification classification1 = this.createNewClassificationWithUniqueKey("", "t1");
@ -314,7 +316,7 @@ public class ClassificationServiceImplIntExplicitTest {
@Test @Test
public void testFindWithClassificationMapperPriorityTypeAndParent() public void testFindWithClassificationMapperPriorityTypeAndParent()
throws SQLException, ClassificationAlreadyExistException { throws SQLException, ClassificationAlreadyExistException, NotAuthorizedException {
Connection connection = dataSource.getConnection(); Connection connection = dataSource.getConnection();
taskanaEngineImpl.setConnection(connection); taskanaEngineImpl.setConnection(connection);
Classification classification = this.createNewClassificationWithUniqueKey("", "type1"); Classification classification = this.createNewClassificationWithUniqueKey("", "type1");
@ -436,7 +438,8 @@ public class ClassificationServiceImplIntExplicitTest {
taskanaEngineImpl.setConnection(null); taskanaEngineImpl.setConnection(null);
} }
private Classification createNewClassificationWithUniqueKey(String domain, String type) { private Classification createNewClassificationWithUniqueKey(String domain, String type)
throws NotAuthorizedException {
Classification classification = classificationService.newClassification("TEST" + counter, domain, type); Classification classification = classificationService.newClassification("TEST" + counter, domain, type);
counter++; counter++;
return classification; return classification;

View File

@ -280,7 +280,7 @@ public class TaskServiceImplIntAutocommitTest {
taskServiceImpl.transfer(UUID.randomUUID() + "_X", "1"); taskServiceImpl.transfer(UUID.randomUUID() + "_X", "1");
} }
@WithAccessId(userName = "User") @WithAccessId(userName = "User", groupNames = {"businessadmin"})
@Test @Test
public void shouldNotTransferByFailingSecurity() throws WorkbasketNotFoundException, public void shouldNotTransferByFailingSecurity() throws WorkbasketNotFoundException,
ClassificationNotFoundException, NotAuthorizedException, ClassificationAlreadyExistException, SQLException, ClassificationNotFoundException, NotAuthorizedException, ClassificationAlreadyExistException, SQLException,
@ -401,7 +401,7 @@ public class TaskServiceImplIntAutocommitTest {
} }
private void createWorkbasketWithSecurity(Workbasket wb, String accessId, boolean permOpen, private void createWorkbasketWithSecurity(Workbasket wb, String accessId, boolean permOpen,
boolean permRead, boolean permAppend, boolean permTransfer) throws InvalidArgumentException { boolean permRead, boolean permAppend, boolean permTransfer) throws InvalidArgumentException, NotAuthorizedException {
WorkbasketAccessItem accessItem = workbasketService.newWorkbasketAccessItem(wb.getId(), accessId); WorkbasketAccessItem accessItem = workbasketService.newWorkbasketAccessItem(wb.getId(), accessId);
accessItem.setPermOpen(permOpen); accessItem.setPermOpen(permOpen);
accessItem.setPermRead(permRead); accessItem.setPermRead(permRead);

View File

@ -101,7 +101,7 @@ public class TaskServiceImplIntExplicitTest {
cleaner.clearDb(dataSource, false); cleaner.clearDb(dataSource, false);
} }
@WithAccessId(userName = "Elena") @WithAccessId(userName = "Elena", groupNames = {"businessadmin"})
@Test(expected = TaskNotFoundException.class) @Test(expected = TaskNotFoundException.class)
public void testStartTransactionFail() public void testStartTransactionFail()
throws FileNotFoundException, SQLException, TaskNotFoundException, NotAuthorizedException, throws FileNotFoundException, SQLException, TaskNotFoundException, NotAuthorizedException,
@ -136,7 +136,7 @@ public class TaskServiceImplIntExplicitTest {
connection.commit(); connection.commit();
} }
@WithAccessId(userName = "Elena") @WithAccessId(userName = "Elena", groupNames = {"businessadmin"})
@Test @Test
public void testCreateTask() public void testCreateTask()
throws FileNotFoundException, SQLException, TaskNotFoundException, NotAuthorizedException, throws FileNotFoundException, SQLException, TaskNotFoundException, NotAuthorizedException,
@ -167,6 +167,7 @@ public class TaskServiceImplIntExplicitTest {
connection.commit(); connection.commit();
} }
@WithAccessId(userName = "Elena", groupNames = {"businessadmin"})
@Test @Test
public void testCreateTaskInTaskanaWithDefaultDb() public void testCreateTaskInTaskanaWithDefaultDb()
throws FileNotFoundException, SQLException, TaskNotFoundException, NotAuthorizedException, throws FileNotFoundException, SQLException, TaskNotFoundException, NotAuthorizedException,
@ -205,7 +206,7 @@ public class TaskServiceImplIntExplicitTest {
te.setConnection(null); te.setConnection(null);
} }
@WithAccessId(userName = "Elena") @WithAccessId(userName = "Elena", groupNames = {"businessadmin"})
@Test @Test
public void testCreateTaskWithPlannedAndName() throws SQLException, NotAuthorizedException, public void testCreateTaskWithPlannedAndName() throws SQLException, NotAuthorizedException,
WorkbasketNotFoundException, ClassificationNotFoundException, ClassificationAlreadyExistException, WorkbasketNotFoundException, ClassificationNotFoundException, ClassificationAlreadyExistException,
@ -272,7 +273,7 @@ public class TaskServiceImplIntExplicitTest {
Assert.assertFalse(resultTask.getName().equals(resultTask2.getName())); Assert.assertFalse(resultTask.getName().equals(resultTask2.getName()));
} }
@WithAccessId(userName = "Elena") @WithAccessId(userName = "Elena", groupNames = {"businessadmin"})
@Test(expected = WorkbasketNotFoundException.class) @Test(expected = WorkbasketNotFoundException.class)
public void createTaskShouldThrowWorkbasketNotFoundException() public void createTaskShouldThrowWorkbasketNotFoundException()
throws NotAuthorizedException, WorkbasketNotFoundException, ClassificationNotFoundException, SQLException, throws NotAuthorizedException, WorkbasketNotFoundException, ClassificationNotFoundException, SQLException,
@ -288,7 +289,7 @@ public class TaskServiceImplIntExplicitTest {
taskServiceImpl.createTask(test); taskServiceImpl.createTask(test);
} }
@WithAccessId(userName = "Elena") @WithAccessId(userName = "Elena", groupNames = {"businessadmin"})
@Test(expected = ClassificationNotFoundException.class) @Test(expected = ClassificationNotFoundException.class)
public void createManualTaskShouldThrowClassificationNotFoundException() public void createManualTaskShouldThrowClassificationNotFoundException()
throws NotAuthorizedException, WorkbasketNotFoundException, ClassificationNotFoundException, SQLException, throws NotAuthorizedException, WorkbasketNotFoundException, ClassificationNotFoundException, SQLException,
@ -316,7 +317,7 @@ public class TaskServiceImplIntExplicitTest {
taskServiceImpl.createTask(task); taskServiceImpl.createTask(task);
} }
@WithAccessId(userName = "Elena", groupNames = {"DummyGroup"}) @WithAccessId(userName = "Elena", groupNames = {"DummyGroup", "businessadmin"})
@Test @Test
public void should_ReturnList_when_BuilderIsUsed() throws SQLException, NotAuthorizedException, public void should_ReturnList_when_BuilderIsUsed() throws SQLException, NotAuthorizedException,
WorkbasketNotFoundException, ClassificationNotFoundException, ClassificationAlreadyExistException, WorkbasketNotFoundException, ClassificationNotFoundException, ClassificationAlreadyExistException,
@ -360,7 +361,7 @@ public class TaskServiceImplIntExplicitTest {
connection.commit(); connection.commit();
} }
@WithAccessId(userName = "Elena") @WithAccessId(userName = "Elena", groupNames = {"businessadmin"})
@Test @Test
public void shouldTransferTaskToOtherWorkbasket() public void shouldTransferTaskToOtherWorkbasket()
throws WorkbasketNotFoundException, ClassificationNotFoundException, NotAuthorizedException, throws WorkbasketNotFoundException, ClassificationNotFoundException, NotAuthorizedException,
@ -438,7 +439,7 @@ public class TaskServiceImplIntExplicitTest {
taskServiceImpl.transfer(UUID.randomUUID() + "_X", "1"); taskServiceImpl.transfer(UUID.randomUUID() + "_X", "1");
} }
@WithAccessId(userName = "User") @WithAccessId(userName = "User", groupNames = {"businessadmin"})
@Test @Test
public void shouldNotTransferByFailingSecurity() throws WorkbasketNotFoundException, public void shouldNotTransferByFailingSecurity() throws WorkbasketNotFoundException,
ClassificationNotFoundException, NotAuthorizedException, ClassificationAlreadyExistException, SQLException, ClassificationNotFoundException, NotAuthorizedException, ClassificationAlreadyExistException, SQLException,
@ -540,7 +541,7 @@ public class TaskServiceImplIntExplicitTest {
return task; return task;
} }
private void generateSampleAccessItems() throws InvalidArgumentException { private void generateSampleAccessItems() throws InvalidArgumentException, NotAuthorizedException {
WorkbasketAccessItem accessItem = workbasketService.newWorkbasketAccessItem("1", "Elena"); WorkbasketAccessItem accessItem = workbasketService.newWorkbasketAccessItem("1", "Elena");
accessItem.setPermAppend(true); accessItem.setPermAppend(true);
accessItem.setPermRead(true); accessItem.setPermRead(true);
@ -554,7 +555,7 @@ public class TaskServiceImplIntExplicitTest {
} }
private void createWorkbasketWithSecurity(Workbasket wb, String accessId, boolean permOpen, private void createWorkbasketWithSecurity(Workbasket wb, String accessId, boolean permOpen,
boolean permRead, boolean permAppend, boolean permTransfer) throws InvalidArgumentException { boolean permRead, boolean permAppend, boolean permTransfer) throws InvalidArgumentException, NotAuthorizedException {
WorkbasketAccessItem accessItem = workbasketService.newWorkbasketAccessItem(wb.getId(), accessId); WorkbasketAccessItem accessItem = workbasketService.newWorkbasketAccessItem(wb.getId(), accessId);
accessItem.setPermOpen(permOpen); accessItem.setPermOpen(permOpen);
accessItem.setPermRead(permRead); accessItem.setPermRead(permRead);

View File

@ -86,7 +86,7 @@ public class WorkbasketServiceImplIntAutocommitTest {
now = Instant.now(); now = Instant.now();
} }
@WithAccessId(userName = "Elena") @WithAccessId(userName = "Elena", groupNames = {"businessadmin"})
@Test @Test
public void testSelectWorkbasket() public void testSelectWorkbasket()
throws WorkbasketNotFoundException, NotAuthorizedException, InvalidWorkbasketException, throws WorkbasketNotFoundException, NotAuthorizedException, InvalidWorkbasketException,
@ -105,7 +105,7 @@ public class WorkbasketServiceImplIntAutocommitTest {
workBasketService.getWorkbasket("fail"); workBasketService.getWorkbasket("fail");
} }
@WithAccessId(userName = "Elena") @WithAccessId(userName = "Elena", groupNames = {"businessadmin"})
@Test @Test
public void testSelectWorkbasketWithDistribution() public void testSelectWorkbasketWithDistribution()
throws WorkbasketNotFoundException, NotAuthorizedException, InvalidWorkbasketException, throws WorkbasketNotFoundException, NotAuthorizedException, InvalidWorkbasketException,
@ -132,7 +132,7 @@ public class WorkbasketServiceImplIntAutocommitTest {
} }
@WithAccessId(userName = "Elena") @WithAccessId(userName = "Elena", groupNames = {"businessadmin"})
@Test @Test
public void testUpdateWorkbasket() throws Exception { public void testUpdateWorkbasket() throws Exception {
String id0 = IdGenerator.generateWithPrefix("TWB"); String id0 = IdGenerator.generateWithPrefix("TWB");
@ -177,6 +177,7 @@ public class WorkbasketServiceImplIntAutocommitTest {
workBasketService.getWorkbasket(id3).getModified()); workBasketService.getWorkbasket(id3).getModified());
} }
@WithAccessId(userName = "Elena", groupNames = {"businessadmin"})
@Test @Test
public void testInsertWorkbasketAccessUser() throws NotAuthorizedException, InvalidArgumentException { public void testInsertWorkbasketAccessUser() throws NotAuthorizedException, InvalidArgumentException {
WorkbasketAccessItem accessItem = workBasketService WorkbasketAccessItem accessItem = workBasketService
@ -189,6 +190,7 @@ public class WorkbasketServiceImplIntAutocommitTest {
workBasketService.getWorkbasketAuthorizations("k100000000000000000000000000000000000000").size()); workBasketService.getWorkbasketAuthorizations("k100000000000000000000000000000000000000").size());
} }
@WithAccessId(userName = "Elena", groupNames = {"businessadmin"})
@Test @Test
public void testUpdateWorkbasketAccessUser() throws NotAuthorizedException, InvalidArgumentException { public void testUpdateWorkbasketAccessUser() throws NotAuthorizedException, InvalidArgumentException {
WorkbasketAccessItem accessItem = workBasketService.newWorkbasketAccessItem( WorkbasketAccessItem accessItem = workBasketService.newWorkbasketAccessItem(
@ -238,7 +240,8 @@ public class WorkbasketServiceImplIntAutocommitTest {
} }
private void createWorkbasketWithSecurity(Workbasket wb, String accessId, boolean permOpen, private void createWorkbasketWithSecurity(Workbasket wb, String accessId, boolean permOpen,
boolean permRead, boolean permAppend, boolean permTransfer) throws InvalidArgumentException { boolean permRead, boolean permAppend, boolean permTransfer)
throws InvalidArgumentException, NotAuthorizedException {
WorkbasketAccessItem accessItem = workBasketService.newWorkbasketAccessItem(wb.getId(), accessId); WorkbasketAccessItem accessItem = workBasketService.newWorkbasketAccessItem(wb.getId(), accessId);
accessItem.setPermOpen(permOpen); accessItem.setPermOpen(permOpen);
accessItem.setPermRead(permRead); accessItem.setPermRead(permRead);
@ -247,7 +250,8 @@ public class WorkbasketServiceImplIntAutocommitTest {
workBasketService.createWorkbasketAuthorization(accessItem); workBasketService.createWorkbasketAuthorization(accessItem);
} }
private Workbasket createTestWorkbasket(String id, String key, String domain, String name, WorkbasketType type) { private Workbasket createTestWorkbasket(String id, String key, String domain, String name, WorkbasketType type)
throws NotAuthorizedException {
WorkbasketImpl wb = (WorkbasketImpl) workBasketService.newWorkbasket(key, domain); WorkbasketImpl wb = (WorkbasketImpl) workBasketService.newWorkbasket(key, domain);
wb.setId(id); wb.setId(id);
wb.setName(name); wb.setName(name);

View File

@ -73,7 +73,7 @@ public class WorkbasketServiceImplIntExplicitTest {
cleaner.clearDb(dataSource, false); cleaner.clearDb(dataSource, false);
} }
@WithAccessId(userName = "Elena") @WithAccessId(userName = "Elena", groupNames = {"businessadmin"})
@Test @Test
public void testSelectWorkbasket() public void testSelectWorkbasket()
throws WorkbasketNotFoundException, NotAuthorizedException, SQLException, InvalidWorkbasketException, throws WorkbasketNotFoundException, NotAuthorizedException, SQLException, InvalidWorkbasketException,
@ -111,7 +111,7 @@ public class WorkbasketServiceImplIntExplicitTest {
connection.commit(); connection.commit();
} }
@WithAccessId(userName = "Elena") @WithAccessId(userName = "Elena", groupNames = {"businessadmin"})
@Test @Test
public void testSelectWorkbasketWithDistribution() public void testSelectWorkbasketWithDistribution()
throws WorkbasketNotFoundException, NotAuthorizedException, SQLException, InvalidWorkbasketException, throws WorkbasketNotFoundException, NotAuthorizedException, SQLException, InvalidWorkbasketException,
@ -144,7 +144,7 @@ public class WorkbasketServiceImplIntExplicitTest {
connection.commit(); connection.commit();
} }
@WithAccessId(userName = "Elena") @WithAccessId(userName = "Elena", groupNames = {"businessadmin"})
@Test @Test
public void testUpdateWorkbasket() throws Exception { public void testUpdateWorkbasket() throws Exception {
Connection connection = dataSource.getConnection(); Connection connection = dataSource.getConnection();
@ -193,6 +193,7 @@ public class WorkbasketServiceImplIntExplicitTest {
connection.commit(); connection.commit();
} }
@WithAccessId(userName = "Elena", groupNames = {"businessadmin"})
@Test @Test
public void testInsertWorkbasketAccessUser() throws NotAuthorizedException, SQLException, InvalidArgumentException { public void testInsertWorkbasketAccessUser() throws NotAuthorizedException, SQLException, InvalidArgumentException {
Connection connection = dataSource.getConnection(); Connection connection = dataSource.getConnection();
@ -209,6 +210,7 @@ public class WorkbasketServiceImplIntExplicitTest {
connection.commit(); connection.commit();
} }
@WithAccessId(userName = "Elena", groupNames = {"businessadmin"})
@Test @Test
public void testUpdateWorkbasketAccessUser() throws NotAuthorizedException, SQLException, InvalidArgumentException { public void testUpdateWorkbasketAccessUser() throws NotAuthorizedException, SQLException, InvalidArgumentException {
Connection connection = dataSource.getConnection(); Connection connection = dataSource.getConnection();
@ -227,7 +229,8 @@ public class WorkbasketServiceImplIntExplicitTest {
} }
private void createWorkbasketWithSecurity(Workbasket wb, String accessId, boolean permOpen, private void createWorkbasketWithSecurity(Workbasket wb, String accessId, boolean permOpen,
boolean permRead, boolean permAppend, boolean permTransfer) throws InvalidArgumentException { boolean permRead, boolean permAppend, boolean permTransfer)
throws InvalidArgumentException, NotAuthorizedException {
WorkbasketAccessItem accessItem = workBasketService.newWorkbasketAccessItem( WorkbasketAccessItem accessItem = workBasketService.newWorkbasketAccessItem(
wb.getId(), accessId); wb.getId(), accessId);
accessItem.setPermOpen(permOpen); accessItem.setPermOpen(permOpen);
@ -237,7 +240,8 @@ public class WorkbasketServiceImplIntExplicitTest {
workBasketService.createWorkbasketAuthorization(accessItem); workBasketService.createWorkbasketAuthorization(accessItem);
} }
private Workbasket createTestWorkbasket(String id, String key, String domain, String name, WorkbasketType type) { private Workbasket createTestWorkbasket(String id, String key, String domain, String name, WorkbasketType type)
throws NotAuthorizedException {
WorkbasketImpl wb = (WorkbasketImpl) workBasketService.newWorkbasket(key, domain); WorkbasketImpl wb = (WorkbasketImpl) workBasketService.newWorkbasket(key, domain);
wb.setId(id); wb.setId(id);
wb.setName(name); wb.setName(name);

View File

@ -1,3 +1,3 @@
taskana.roles.user = group1 | group2|teamlead_1 |teamlead_2 |user_1_1| user_1_1| user_1_2| user_2_1| user_2_2| max|elena|simone taskana.roles.user = group1 | group2|teamlead_1 |teamlead_2 |user_1_1| user_1_1| user_1_2| user_2_1| user_2_2| max|elena|simone
taskana.roles.Admin=teamlead_1|teamlead_2 taskana.roles.Admin=name=konrad,Organisation=novatec|admin
taskana.roles.businessadmin=max|Moritz taskana.roles.businessadmin=max|Moritz|businessadmin

View File

@ -61,7 +61,7 @@ public class TaskanaConfig {
@Bean @Bean
public SpringTaskanaEngineConfiguration taskanaEngineConfiguration(DataSource dataSource) { public SpringTaskanaEngineConfiguration taskanaEngineConfiguration(DataSource dataSource) {
SpringTaskanaEngineConfiguration taskanaEngineConfiguration = new SpringTaskanaEngineConfiguration(); SpringTaskanaEngineConfiguration taskanaEngineConfiguration = new SpringTaskanaEngineConfiguration(false);
taskanaEngineConfiguration.setDataSource(dataSource); taskanaEngineConfiguration.setDataSource(dataSource);
return taskanaEngineConfiguration; return taskanaEngineConfiguration;
} }

View File

@ -115,7 +115,7 @@ public class TaskanaTestController {
return jdbcTemplate.queryForObject("SELECT COUNT(*) FROM GESCHBUCH.TEST", Integer.class); return jdbcTemplate.queryForObject("SELECT COUNT(*) FROM GESCHBUCH.TEST", Integer.class);
} }
private Workbasket createWorkBasket(String key, String name) { private Workbasket createWorkBasket(String key, String name) throws NotAuthorizedException {
WorkbasketImpl workbasket = (WorkbasketImpl) taskanaEngine.getWorkbasketService().newWorkbasket(key, WorkbasketImpl workbasket = (WorkbasketImpl) taskanaEngine.getWorkbasketService().newWorkbasket(key,
"generali"); "generali");
String id1 = IdGenerator.generateWithPrefix("TWB"); String id1 = IdGenerator.generateWithPrefix("TWB");

View File

@ -134,7 +134,8 @@ public class WorkbasketController {
@PostMapping @PostMapping
@Transactional(rollbackFor = Exception.class) @Transactional(rollbackFor = Exception.class)
public ResponseEntity<WorkbasketResource> createWorkbasket(@RequestBody WorkbasketResource workbasketResource) { public ResponseEntity<WorkbasketResource> createWorkbasket(@RequestBody WorkbasketResource workbasketResource)
throws NotAuthorizedException {
try { try {
Workbasket workbasket = workbasketMapper.toModel(workbasketResource); Workbasket workbasket = workbasketMapper.toModel(workbasketResource);
workbasket = workbasketService.createWorkbasket(workbasket); workbasket = workbasketService.createWorkbasket(workbasket);
@ -189,7 +190,7 @@ public class WorkbasketController {
@PostMapping(path = "/authorizations") @PostMapping(path = "/authorizations")
@Transactional(rollbackFor = Exception.class) @Transactional(rollbackFor = Exception.class)
public ResponseEntity<WorkbasketAccessItemResource> createWorkbasketAuthorization( public ResponseEntity<WorkbasketAccessItemResource> createWorkbasketAuthorization(
@RequestBody WorkbasketAccessItemResource workbasketAccessItemResource) { @RequestBody WorkbasketAccessItemResource workbasketAccessItemResource) throws NotAuthorizedException {
try { try {
WorkbasketAccessItem workbasketAccessItem = workbasketAccessItemMapper WorkbasketAccessItem workbasketAccessItem = workbasketAccessItemMapper
.toModel(workbasketAccessItemResource); .toModel(workbasketAccessItemResource);
@ -210,7 +211,7 @@ public class WorkbasketController {
.toModel(workbasketAccessItemResource); .toModel(workbasketAccessItemResource);
workbasketAccessItem = workbasketService.updateWorkbasketAuthorization(workbasketAccessItem); workbasketAccessItem = workbasketService.updateWorkbasketAuthorization(workbasketAccessItem);
return new ResponseEntity<>(workbasketAccessItemMapper.toResource(workbasketAccessItem), HttpStatus.OK); return new ResponseEntity<>(workbasketAccessItemMapper.toResource(workbasketAccessItem), HttpStatus.OK);
} catch (InvalidArgumentException e) { } catch (InvalidArgumentException | NotAuthorizedException e) {
return new ResponseEntity<>(HttpStatus.PRECONDITION_FAILED); return new ResponseEntity<>(HttpStatus.PRECONDITION_FAILED);
} }
} }
@ -234,7 +235,8 @@ public class WorkbasketController {
@DeleteMapping(path = "/authorizations/{authId}") @DeleteMapping(path = "/authorizations/{authId}")
@Transactional(rollbackFor = Exception.class) @Transactional(rollbackFor = Exception.class)
public ResponseEntity<?> deleteWorkbasketAuthorization(@PathVariable(value = "authId") String authId) { public ResponseEntity<?> deleteWorkbasketAuthorization(@PathVariable(value = "authId") String authId)
throws NotAuthorizedException {
workbasketService.deleteWorkbasketAuthorization(authId); workbasketService.deleteWorkbasketAuthorization(authId);
return ResponseEntity.status(HttpStatus.NO_CONTENT).build(); return ResponseEntity.status(HttpStatus.NO_CONTENT).build();
} }

View File

@ -9,12 +9,14 @@ import org.springframework.stereotype.Component;
import pro.taskana.Classification; import pro.taskana.Classification;
import pro.taskana.ClassificationService; import pro.taskana.ClassificationService;
import pro.taskana.impl.ClassificationImpl; import pro.taskana.impl.ClassificationImpl;
import pro.taskana.exceptions.NotAuthorizedException;
import pro.taskana.rest.resource.ClassificationResource; import pro.taskana.rest.resource.ClassificationResource;
@Component @Component
public class ClassificationMapper { public class ClassificationMapper {
@Autowired ClassificationService classificationService; @Autowired
ClassificationService classificationService;
public ClassificationResource toResource(Classification classification) { public ClassificationResource toResource(Classification classification) {
ClassificationResource resource = new ClassificationResource(); ClassificationResource resource = new ClassificationResource();
@ -25,7 +27,7 @@ public class ClassificationMapper {
return resource; return resource;
} }
public Classification toModel(ClassificationResource classificationResource) { public Classification toModel(ClassificationResource classificationResource) throws NotAuthorizedException {
ClassificationImpl classification = (ClassificationImpl) classificationService.newClassification( ClassificationImpl classification = (ClassificationImpl) classificationService.newClassification(
classificationResource.domain, classificationResource.key, classificationResource.type); classificationResource.domain, classificationResource.key, classificationResource.type);
BeanUtils.copyProperties(classificationResource, classification); BeanUtils.copyProperties(classificationResource, classification);

View File

@ -11,6 +11,7 @@ import org.springframework.stereotype.Component;
import pro.taskana.Workbasket; import pro.taskana.Workbasket;
import pro.taskana.WorkbasketService; import pro.taskana.WorkbasketService;
import pro.taskana.exceptions.NotAuthorizedException;
import pro.taskana.impl.WorkbasketImpl; import pro.taskana.impl.WorkbasketImpl;
import pro.taskana.rest.WorkbasketController; import pro.taskana.rest.WorkbasketController;
import pro.taskana.rest.resource.WorkbasketResource; import pro.taskana.rest.resource.WorkbasketResource;
@ -34,7 +35,7 @@ public class WorkbasketMapper {
return resource; return resource;
} }
public Workbasket toModel(WorkbasketResource wbResource) { public Workbasket toModel(WorkbasketResource wbResource) throws NotAuthorizedException {
WorkbasketImpl workbasket = (WorkbasketImpl) workbasketService.newWorkbasket(wbResource.key, wbResource.domain); WorkbasketImpl workbasket = (WorkbasketImpl) workbasketService.newWorkbasket(wbResource.key, wbResource.domain);
BeanUtils.copyProperties(wbResource, workbasket); BeanUtils.copyProperties(wbResource, workbasket);

View File

@ -12,6 +12,7 @@ import org.springframework.test.context.web.WebAppConfiguration;
import pro.taskana.Classification; import pro.taskana.Classification;
import pro.taskana.ClassificationService; import pro.taskana.ClassificationService;
import pro.taskana.exceptions.NotAuthorizedException;
import pro.taskana.impl.ClassificationImpl; import pro.taskana.impl.ClassificationImpl;
import pro.taskana.rest.RestApplication; import pro.taskana.rest.RestApplication;
import pro.taskana.rest.resource.ClassificationResource; import pro.taskana.rest.resource.ClassificationResource;
@ -21,8 +22,10 @@ import pro.taskana.rest.resource.ClassificationResource;
@WebAppConfiguration @WebAppConfiguration
public class ClassificationMapperTest { public class ClassificationMapperTest {
@Autowired ClassificationMapper classificationMapper; @Autowired
@Autowired ClassificationService classificationService; ClassificationMapper classificationMapper;
@Autowired
ClassificationService classificationService;
@Test @Test
public void classificationToResource() { public void classificationToResource() {
@ -54,7 +57,7 @@ public class ClassificationMapperTest {
} }
@Test @Test
public void resourceToClassification() { public void resourceToClassification() throws NotAuthorizedException {
// given // given
ClassificationResource classificationResource = new ClassificationResource(); ClassificationResource classificationResource = new ClassificationResource();
classificationResource.setClassificationId("1"); classificationResource.setClassificationId("1");

View File

@ -12,6 +12,7 @@ import org.springframework.test.context.web.WebAppConfiguration;
import pro.taskana.Workbasket; import pro.taskana.Workbasket;
import pro.taskana.WorkbasketService; import pro.taskana.WorkbasketService;
import pro.taskana.exceptions.NotAuthorizedException;
import pro.taskana.impl.WorkbasketImpl; import pro.taskana.impl.WorkbasketImpl;
import pro.taskana.impl.WorkbasketType; import pro.taskana.impl.WorkbasketType;
import pro.taskana.rest.RestApplication; import pro.taskana.rest.RestApplication;
@ -22,8 +23,10 @@ import pro.taskana.rest.resource.WorkbasketResource;
@WebAppConfiguration @WebAppConfiguration
public class WorkbasketMapperTest { public class WorkbasketMapperTest {
@Autowired WorkbasketService workbasketService; @Autowired
@Autowired WorkbasketMapper workbasketMapper; WorkbasketService workbasketService;
@Autowired
WorkbasketMapper workbasketMapper;
@Test @Test
public void workbasketToResource() { public void workbasketToResource() {
@ -51,7 +54,7 @@ public class WorkbasketMapperTest {
} }
@Test @Test
public void resourceToWorkbasket() { public void resourceToWorkbasket() throws NotAuthorizedException {
// given // given
WorkbasketResource workbasketResource = new WorkbasketResource(); WorkbasketResource workbasketResource = new WorkbasketResource();
workbasketResource.setWorkbasketId("1"); workbasketResource.setWorkbasketId("1");