TSK-1992 remove unnecessary ParentExceptions

Deleted Exceptions:
* NotAuthorizedException
* NotFoundException
* InvalidStateException
This commit is contained in:
arolfes 2023-02-08 10:17:18 +01:00 committed by Mustapha Zorgati
parent e40417f1fd
commit 20d389a7d5
122 changed files with 907 additions and 810 deletions

View File

@ -3,7 +3,7 @@ package pro.taskana.common.api.exceptions;
import pro.taskana.common.internal.util.MapCreator; import pro.taskana.common.internal.util.MapCreator;
/** This exception is thrown when the specified domain is not found in the configuration. */ /** This exception is thrown when the specified domain is not found in the configuration. */
public class DomainNotFoundException extends NotFoundException { public class DomainNotFoundException extends TaskanaException {
public static final String ERROR_KEY = "DOMAIN_NOT_FOUND"; public static final String ERROR_KEY = "DOMAIN_NOT_FOUND";
private final String domain; private final String domain;

View File

@ -9,7 +9,7 @@ import pro.taskana.common.internal.util.MapCreator;
* This exception is thrown when the current user is not in a certain {@linkplain TaskanaRole role} * This exception is thrown when the current user is not in a certain {@linkplain TaskanaRole role}
* it is supposed to be. * it is supposed to be.
*/ */
public class MismatchedRoleException extends NotAuthorizedException { public class MismatchedRoleException extends TaskanaException {
public static final String ERROR_KEY = "ROLE_MISMATCHED"; public static final String ERROR_KEY = "ROLE_MISMATCHED";
private final String currentUserId; private final String currentUserId;

View File

@ -1,9 +0,0 @@
package pro.taskana.common.api.exceptions;
/** This exception is thrown when a user is not authorized. */
public class NotAuthorizedException extends TaskanaException {
protected NotAuthorizedException(String msg, ErrorCode errorCode) {
super(msg, errorCode);
}
}

View File

@ -1,9 +0,0 @@
package pro.taskana.common.api.exceptions;
/** This exception is thrown when a specific object is not in the database. */
public class NotFoundException extends TaskanaException {
protected NotFoundException(String message, ErrorCode errorCode) {
super(message, errorCode);
}
}

View File

@ -1,7 +1,7 @@
package pro.taskana.simplehistory; package pro.taskana.simplehistory;
import pro.taskana.common.api.TaskanaRole; import pro.taskana.common.api.TaskanaRole;
import pro.taskana.common.api.exceptions.NotAuthorizedException; import pro.taskana.common.api.exceptions.MismatchedRoleException;
import pro.taskana.spi.history.api.TaskanaHistory; import pro.taskana.spi.history.api.TaskanaHistory;
/** The TaskanaHistoryEngine represents an overall set of all needed services. */ /** The TaskanaHistoryEngine represents an overall set of all needed services. */
@ -25,7 +25,7 @@ public interface TaskanaHistoryEngine {
* Checks whether current user is member of any of the specified roles. * 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 * @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 * @throws MismatchedRoleException If the current user is not member of any specified role
*/ */
void checkRoleMembership(TaskanaRole... roles) throws NotAuthorizedException; void checkRoleMembership(TaskanaRole... roles) throws MismatchedRoleException;
} }

View File

@ -9,7 +9,7 @@ import org.slf4j.LoggerFactory;
import pro.taskana.common.api.TaskanaEngine; import pro.taskana.common.api.TaskanaEngine;
import pro.taskana.common.api.TaskanaRole; import pro.taskana.common.api.TaskanaRole;
import pro.taskana.common.api.exceptions.InvalidArgumentException; import pro.taskana.common.api.exceptions.InvalidArgumentException;
import pro.taskana.common.api.exceptions.NotAuthorizedException; import pro.taskana.common.api.exceptions.MismatchedRoleException;
import pro.taskana.simplehistory.impl.classification.ClassificationHistoryEventMapper; import pro.taskana.simplehistory.impl.classification.ClassificationHistoryEventMapper;
import pro.taskana.simplehistory.impl.classification.ClassificationHistoryQuery; import pro.taskana.simplehistory.impl.classification.ClassificationHistoryQuery;
import pro.taskana.simplehistory.impl.task.TaskHistoryEventMapper; import pro.taskana.simplehistory.impl.task.TaskHistoryEventMapper;
@ -103,7 +103,7 @@ public class SimpleHistoryServiceImpl implements TaskanaHistory {
@Override @Override
public void deleteHistoryEventsByTaskIds(List<String> taskIds) public void deleteHistoryEventsByTaskIds(List<String> taskIds)
throws InvalidArgumentException, NotAuthorizedException { throws InvalidArgumentException, MismatchedRoleException {
taskanaHistoryEngine.checkRoleMembership(TaskanaRole.ADMIN); taskanaHistoryEngine.checkRoleMembership(TaskanaRole.ADMIN);
if (taskIds == null) { if (taskIds == null) {

View File

@ -25,7 +25,6 @@ import pro.taskana.TaskanaConfiguration;
import pro.taskana.common.api.TaskanaEngine; import pro.taskana.common.api.TaskanaEngine;
import pro.taskana.common.api.TaskanaRole; import pro.taskana.common.api.TaskanaRole;
import pro.taskana.common.api.exceptions.MismatchedRoleException; import pro.taskana.common.api.exceptions.MismatchedRoleException;
import pro.taskana.common.api.exceptions.NotAuthorizedException;
import pro.taskana.common.api.exceptions.SystemException; import pro.taskana.common.api.exceptions.SystemException;
import pro.taskana.common.internal.OracleSqlSessionFactory; import pro.taskana.common.internal.OracleSqlSessionFactory;
import pro.taskana.common.internal.configuration.DB; import pro.taskana.common.internal.configuration.DB;
@ -90,7 +89,7 @@ public class TaskanaHistoryEngineImpl implements TaskanaHistoryEngine {
.anyMatch(rolesMembers::contains); .anyMatch(rolesMembers::contains);
} }
public void checkRoleMembership(TaskanaRole... roles) throws NotAuthorizedException { public void checkRoleMembership(TaskanaRole... roles) throws MismatchedRoleException {
if (!isUserInRole(roles)) { if (!isUserInRole(roles)) {
if (LOGGER.isDebugEnabled()) { if (LOGGER.isDebugEnabled()) {
LOGGER.debug( LOGGER.debug(

View File

@ -19,7 +19,7 @@ import pro.taskana.common.api.ScheduledJob;
import pro.taskana.common.api.TaskanaEngine; import pro.taskana.common.api.TaskanaEngine;
import pro.taskana.common.api.TimeInterval; import pro.taskana.common.api.TimeInterval;
import pro.taskana.common.api.exceptions.InvalidArgumentException; import pro.taskana.common.api.exceptions.InvalidArgumentException;
import pro.taskana.common.api.exceptions.NotAuthorizedException; import pro.taskana.common.api.exceptions.MismatchedRoleException;
import pro.taskana.common.api.exceptions.SystemException; import pro.taskana.common.api.exceptions.SystemException;
import pro.taskana.common.internal.JobServiceImpl; import pro.taskana.common.internal.JobServiceImpl;
import pro.taskana.common.internal.jobs.AbstractTaskanaJob; import pro.taskana.common.internal.jobs.AbstractTaskanaJob;
@ -196,7 +196,7 @@ public class HistoryCleanupJob extends AbstractTaskanaJob {
} }
private int deleteEvents(List<String> taskIdsToDeleteHistoryEventsFor) private int deleteEvents(List<String> taskIdsToDeleteHistoryEventsFor)
throws InvalidArgumentException, NotAuthorizedException { throws InvalidArgumentException, MismatchedRoleException {
SimpleHistoryServiceImpl simpleHistoryService = SimpleHistoryServiceImpl simpleHistoryService =
(SimpleHistoryServiceImpl) taskanaHistoryEngine.getTaskanaHistoryService(); (SimpleHistoryServiceImpl) taskanaHistoryEngine.getTaskanaHistoryService();

View File

@ -8,15 +8,15 @@ import javax.enterprise.event.Observes;
import pro.taskana.classification.api.exceptions.ClassificationNotFoundException; import pro.taskana.classification.api.exceptions.ClassificationNotFoundException;
import pro.taskana.common.api.exceptions.InvalidArgumentException; import pro.taskana.common.api.exceptions.InvalidArgumentException;
import pro.taskana.common.api.exceptions.NotAuthorizedException;
import pro.taskana.task.api.exceptions.AttachmentPersistenceException; import pro.taskana.task.api.exceptions.AttachmentPersistenceException;
import pro.taskana.task.api.exceptions.InvalidOwnerException; import pro.taskana.task.api.exceptions.InvalidOwnerException;
import pro.taskana.task.api.exceptions.InvalidStateException; import pro.taskana.task.api.exceptions.InvalidTaskStateException;
import pro.taskana.task.api.exceptions.ObjectReferencePersistenceException; import pro.taskana.task.api.exceptions.ObjectReferencePersistenceException;
import pro.taskana.task.api.exceptions.TaskAlreadyExistException; import pro.taskana.task.api.exceptions.TaskAlreadyExistException;
import pro.taskana.task.api.exceptions.TaskNotFoundException; import pro.taskana.task.api.exceptions.TaskNotFoundException;
import pro.taskana.task.api.models.Task; import pro.taskana.task.api.models.Task;
import pro.taskana.task.internal.models.ObjectReferenceImpl; import pro.taskana.task.internal.models.ObjectReferenceImpl;
import pro.taskana.workbasket.api.exceptions.MismatchedWorkbasketPermissionException;
import pro.taskana.workbasket.api.exceptions.WorkbasketNotFoundException; import pro.taskana.workbasket.api.exceptions.WorkbasketNotFoundException;
/** Example Bootstrap Application. */ /** Example Bootstrap Application. */
@ -27,10 +27,10 @@ public class ExampleBootstrap {
@PostConstruct @PostConstruct
public void init(@Observes @Initialized(ApplicationScoped.class) Object init) public void init(@Observes @Initialized(ApplicationScoped.class) Object init)
throws TaskNotFoundException, NotAuthorizedException, WorkbasketNotFoundException, throws TaskNotFoundException, WorkbasketNotFoundException, ClassificationNotFoundException,
ClassificationNotFoundException, InvalidStateException, InvalidOwnerException, InvalidOwnerException, TaskAlreadyExistException, InvalidArgumentException,
TaskAlreadyExistException, InvalidArgumentException, AttachmentPersistenceException, AttachmentPersistenceException, ObjectReferencePersistenceException,
ObjectReferencePersistenceException { MismatchedWorkbasketPermissionException, InvalidTaskStateException {
System.out.println("---------------------------> Start App"); System.out.println("---------------------------> Start App");
ObjectReferenceImpl objRef = new ObjectReferenceImpl(); ObjectReferenceImpl objRef = new ObjectReferenceImpl();
objRef.setCompany("aCompany"); objRef.setCompany("aCompany");

View File

@ -28,7 +28,6 @@ import pro.taskana.common.internal.util.EnumUtil;
import pro.taskana.task.api.TaskService; import pro.taskana.task.api.TaskService;
import pro.taskana.task.api.TaskState; import pro.taskana.task.api.TaskState;
import pro.taskana.task.api.exceptions.InvalidOwnerException; import pro.taskana.task.api.exceptions.InvalidOwnerException;
import pro.taskana.task.api.exceptions.InvalidStateException;
import pro.taskana.task.api.exceptions.InvalidTaskStateException; import pro.taskana.task.api.exceptions.InvalidTaskStateException;
import pro.taskana.task.api.exceptions.TaskNotFoundException; import pro.taskana.task.api.exceptions.TaskNotFoundException;
import pro.taskana.task.api.models.ObjectReference; import pro.taskana.task.api.models.ObjectReference;
@ -465,7 +464,8 @@ class CompleteTaskAccTest implements TaskanaEngineConfigurationModifier {
assertThat(results.containsErrors()).isTrue(); assertThat(results.containsErrors()).isTrue();
assertThat(results.getFailedIds()).containsExactlyInAnyOrder(task.getId()); assertThat(results.getFailedIds()).containsExactlyInAnyOrder(task.getId());
assertThat(results.getErrorMap().values()).hasOnlyElementsOfType(InvalidStateException.class); assertThat(results.getErrorMap().values())
.hasOnlyElementsOfType(InvalidTaskStateException.class);
assertThat(results.getErrorForId(task.getId())) assertThat(results.getErrorForId(task.getId()))
.hasMessage( .hasMessage(
"Task with id '%s' is in state: '%s', but must be in one of these states: '[%s, %s]'", "Task with id '%s' is in state: '%s', but must be in one of these states: '[%s, %s]'",
@ -485,7 +485,8 @@ class CompleteTaskAccTest implements TaskanaEngineConfigurationModifier {
assertThat(results.containsErrors()).isTrue(); assertThat(results.containsErrors()).isTrue();
assertThat(results.getFailedIds()).containsExactlyInAnyOrder(task1.getId(), task2.getId()); assertThat(results.getFailedIds()).containsExactlyInAnyOrder(task1.getId(), task2.getId());
assertThat(results.getErrorMap().values()).hasOnlyElementsOfType(InvalidStateException.class); assertThat(results.getErrorMap().values())
.hasOnlyElementsOfType(InvalidTaskStateException.class);
assertThat(results.getErrorForId(task1.getId())) assertThat(results.getErrorForId(task1.getId()))
.hasMessage( .hasMessage(
"Task with id '%s' is in state: '%s', but must be in one of these states: '%s'", "Task with id '%s' is in state: '%s', but must be in one of these states: '%s'",
@ -596,7 +597,8 @@ class CompleteTaskAccTest implements TaskanaEngineConfigurationModifier {
assertThat(results.containsErrors()).isTrue(); assertThat(results.containsErrors()).isTrue();
assertThat(results.getFailedIds()).containsExactlyInAnyOrder(task1.getId(), task2.getId()); assertThat(results.getFailedIds()).containsExactlyInAnyOrder(task1.getId(), task2.getId());
assertThat(results.getErrorMap().values()).hasOnlyElementsOfType(InvalidStateException.class); assertThat(results.getErrorMap().values())
.hasOnlyElementsOfType(InvalidTaskStateException.class);
assertThat(results.getErrorForId(task1.getId())) assertThat(results.getErrorForId(task1.getId()))
.hasMessage( .hasMessage(
"Task with id '%s' is in state: '%s', but must be in one of these states: '%s'", "Task with id '%s' is in state: '%s', but must be in one of these states: '%s'",

View File

@ -14,8 +14,8 @@ import org.junit.jupiter.api.Test;
import pro.taskana.classification.api.ClassificationService; import pro.taskana.classification.api.ClassificationService;
import pro.taskana.classification.api.models.ClassificationSummary; import pro.taskana.classification.api.models.ClassificationSummary;
import pro.taskana.common.api.exceptions.ConcurrencyException; import pro.taskana.common.api.exceptions.ConcurrencyException;
import pro.taskana.common.api.exceptions.NotAuthorizedException;
import pro.taskana.task.api.TaskService; import pro.taskana.task.api.TaskService;
import pro.taskana.task.api.exceptions.MismatchedTaskCommentCreatorException;
import pro.taskana.task.api.models.ObjectReference; import pro.taskana.task.api.models.ObjectReference;
import pro.taskana.task.api.models.Task; import pro.taskana.task.api.models.Task;
import pro.taskana.task.api.models.TaskComment; import pro.taskana.task.api.models.TaskComment;
@ -28,6 +28,7 @@ import pro.taskana.testapi.builder.WorkbasketAccessItemBuilder;
import pro.taskana.testapi.security.WithAccessId; import pro.taskana.testapi.security.WithAccessId;
import pro.taskana.workbasket.api.WorkbasketPermission; import pro.taskana.workbasket.api.WorkbasketPermission;
import pro.taskana.workbasket.api.WorkbasketService; import pro.taskana.workbasket.api.WorkbasketService;
import pro.taskana.workbasket.api.exceptions.MismatchedWorkbasketPermissionException;
import pro.taskana.workbasket.api.models.WorkbasketSummary; import pro.taskana.workbasket.api.models.WorkbasketSummary;
@TaskanaIntegrationTest @TaskanaIntegrationTest
@ -89,7 +90,7 @@ class UpdateTaskCommentAccTest {
taskComment.setTextField("updated textfield"); taskComment.setTextField("updated textfield");
assertThatThrownBy(() -> taskService.updateTaskComment(taskComment)) assertThatThrownBy(() -> taskService.updateTaskComment(taskComment))
.isInstanceOf(NotAuthorizedException.class); .isInstanceOf(MismatchedWorkbasketPermissionException.class);
} }
@WithAccessId(user = "user-1-1") @WithAccessId(user = "user-1-1")
@ -106,7 +107,8 @@ class UpdateTaskCommentAccTest {
taskComment.setCreator("user-1-2"); taskComment.setCreator("user-1-2");
ThrowingCallable updateTaskCommentCall = () -> taskService.updateTaskComment(taskComment); ThrowingCallable updateTaskCommentCall = () -> taskService.updateTaskComment(taskComment);
assertThatThrownBy(updateTaskCommentCall).isInstanceOf(NotAuthorizedException.class); assertThatThrownBy(updateTaskCommentCall)
.isInstanceOf(MismatchedTaskCommentCreatorException.class);
} }
@WithAccessId(user = "user-1-1") @WithAccessId(user = "user-1-1")

View File

@ -9,7 +9,7 @@ import pro.taskana.common.api.TaskanaRole;
import pro.taskana.common.api.exceptions.ConcurrencyException; import pro.taskana.common.api.exceptions.ConcurrencyException;
import pro.taskana.common.api.exceptions.DomainNotFoundException; import pro.taskana.common.api.exceptions.DomainNotFoundException;
import pro.taskana.common.api.exceptions.InvalidArgumentException; import pro.taskana.common.api.exceptions.InvalidArgumentException;
import pro.taskana.common.api.exceptions.NotAuthorizedException; import pro.taskana.common.api.exceptions.MismatchedRoleException;
import pro.taskana.task.api.models.Task; import pro.taskana.task.api.models.Task;
/** /**
@ -59,7 +59,7 @@ public interface ClassificationService {
* id}. * id}.
* @throws ClassificationAlreadyExistException if the {@linkplain Classification} already exists * @throws ClassificationAlreadyExistException if the {@linkplain Classification} already exists
* in the given {@linkplain Classification#getDomain() domain}. * in the given {@linkplain Classification#getDomain() domain}.
* @throws NotAuthorizedException if the current user is not member of {@linkplain * @throws MismatchedRoleException if the current user is not member of {@linkplain
* TaskanaRole#BUSINESS_ADMIN} or {@linkplain TaskanaRole#ADMIN} * TaskanaRole#BUSINESS_ADMIN} or {@linkplain TaskanaRole#ADMIN}
* @throws DomainNotFoundException if the {@linkplain Classification#getDomain() domain} does not * @throws DomainNotFoundException if the {@linkplain Classification#getDomain() domain} does not
* exist in the configuration * exist in the configuration
@ -68,8 +68,8 @@ public interface ClassificationService {
* @throws InvalidArgumentException if the {@linkplain Classification} contains invalid properties * @throws InvalidArgumentException if the {@linkplain Classification} contains invalid properties
*/ */
Classification createClassification(Classification classification) Classification createClassification(Classification classification)
throws ClassificationAlreadyExistException, NotAuthorizedException, DomainNotFoundException, throws ClassificationAlreadyExistException, DomainNotFoundException, InvalidArgumentException,
InvalidArgumentException, MalformedServiceLevelException; MalformedServiceLevelException, MismatchedRoleException;
// READ // READ
@ -114,7 +114,7 @@ public interface ClassificationService {
* @return the updated {@linkplain Classification}. * @return the updated {@linkplain Classification}.
* @throws ClassificationNotFoundException if the specified {@linkplain Classification} or its * @throws ClassificationNotFoundException if the specified {@linkplain Classification} or its
* parent does not exist * parent does not exist
* @throws NotAuthorizedException if the caller is neither member of{@linkplain * @throws MismatchedRoleException if the caller is neither member of{@linkplain
* TaskanaRole#BUSINESS_ADMIN} nor {@linkplain TaskanaRole#ADMIN} * TaskanaRole#BUSINESS_ADMIN} nor {@linkplain TaskanaRole#ADMIN}
* @throws ConcurrencyException if the {@linkplain Classification} was modified in the meantime * @throws ConcurrencyException if the {@linkplain Classification} was modified in the meantime
* and is not the most up to date anymore; that's the case if the given {@linkplain * and is not the most up to date anymore; that's the case if the given {@linkplain
@ -124,8 +124,8 @@ public interface ClassificationService {
* @throws InvalidArgumentException if the {@linkplain Classification} contains invalid properties * @throws InvalidArgumentException if the {@linkplain Classification} contains invalid properties
*/ */
Classification updateClassification(Classification classification) Classification updateClassification(Classification classification)
throws ClassificationNotFoundException, NotAuthorizedException, ConcurrencyException, throws ClassificationNotFoundException, ConcurrencyException, InvalidArgumentException,
InvalidArgumentException, MalformedServiceLevelException; MalformedServiceLevelException, MismatchedRoleException;
// DELETE // DELETE
@ -139,11 +139,11 @@ public interface ClassificationService {
* {@linkplain Classification} * {@linkplain Classification}
* @throws ClassificationNotFoundException if no {@linkplain Classification} with the specified * @throws ClassificationNotFoundException if no {@linkplain Classification} with the specified
* {@linkplain Classification#getId() id} was found * {@linkplain Classification#getId() id} was found
* @throws NotAuthorizedException if the current user is not member of {@linkplain * @throws MismatchedRoleException if the current user is not member of {@linkplain
* TaskanaRole#BUSINESS_ADMIN} or {@linkplain TaskanaRole#ADMIN} * TaskanaRole#BUSINESS_ADMIN} or {@linkplain TaskanaRole#ADMIN}
*/ */
void deleteClassification(String id) void deleteClassification(String id)
throws ClassificationInUseException, ClassificationNotFoundException, NotAuthorizedException; throws ClassificationInUseException, ClassificationNotFoundException, MismatchedRoleException;
/** /**
* Deletes the {@linkplain Classification} identified by the provided {@linkplain * Deletes the {@linkplain Classification} identified by the provided {@linkplain
@ -161,11 +161,11 @@ public interface ClassificationService {
* @throws ClassificationNotFoundException if no {@linkplain Classification} with the specified * @throws ClassificationNotFoundException if no {@linkplain Classification} with the specified
* {@linkplain Classification#getKey() key} and {@linkplain Classification#getDomain() domain} * {@linkplain Classification#getKey() key} and {@linkplain Classification#getDomain() domain}
* was found * was found
* @throws NotAuthorizedException if the current user is not member of {@linkplain * @throws MismatchedRoleException if the current user is not member of {@linkplain
* TaskanaRole#BUSINESS_ADMIN} or {@linkplain TaskanaRole#ADMIN} * TaskanaRole#BUSINESS_ADMIN} or {@linkplain TaskanaRole#ADMIN}
*/ */
void deleteClassification(String classificationKey, String domain) void deleteClassification(String classificationKey, String domain)
throws ClassificationInUseException, ClassificationNotFoundException, NotAuthorizedException; throws ClassificationInUseException, ClassificationNotFoundException, MismatchedRoleException;
// endregion // endregion

View File

@ -2,11 +2,11 @@ package pro.taskana.classification.api.exceptions;
import pro.taskana.classification.api.models.Classification; import pro.taskana.classification.api.models.Classification;
import pro.taskana.common.api.exceptions.ErrorCode; import pro.taskana.common.api.exceptions.ErrorCode;
import pro.taskana.common.api.exceptions.NotFoundException; import pro.taskana.common.api.exceptions.TaskanaException;
import pro.taskana.common.internal.util.MapCreator; import pro.taskana.common.internal.util.MapCreator;
/** Thrown if a specific {@linkplain Classification} is not in the database. */ /** Thrown if a specific {@linkplain Classification} is not in the database. */
public class ClassificationNotFoundException extends NotFoundException { public class ClassificationNotFoundException extends TaskanaException {
public static final String ERROR_KEY_ID = "CLASSIFICATION_WITH_ID_NOT_FOUND"; public static final String ERROR_KEY_ID = "CLASSIFICATION_WITH_ID_NOT_FOUND";
public static final String ERROR_KEY_KEY_DOMAIN = "CLASSIFICATION_WITH_KEY_NOT_FOUND"; public static final String ERROR_KEY_KEY_DOMAIN = "CLASSIFICATION_WITH_KEY_NOT_FOUND";

View File

@ -30,7 +30,7 @@ import pro.taskana.common.api.TaskanaRole;
import pro.taskana.common.api.exceptions.ConcurrencyException; import pro.taskana.common.api.exceptions.ConcurrencyException;
import pro.taskana.common.api.exceptions.DomainNotFoundException; import pro.taskana.common.api.exceptions.DomainNotFoundException;
import pro.taskana.common.api.exceptions.InvalidArgumentException; import pro.taskana.common.api.exceptions.InvalidArgumentException;
import pro.taskana.common.api.exceptions.NotAuthorizedException; import pro.taskana.common.api.exceptions.MismatchedRoleException;
import pro.taskana.common.internal.InternalTaskanaEngine; import pro.taskana.common.internal.InternalTaskanaEngine;
import pro.taskana.common.internal.util.IdGenerator; import pro.taskana.common.internal.util.IdGenerator;
import pro.taskana.common.internal.util.LogSanitizer; import pro.taskana.common.internal.util.LogSanitizer;
@ -108,7 +108,8 @@ public class ClassificationServiceImpl implements ClassificationService {
@Override @Override
public void deleteClassification(String classificationId) public void deleteClassification(String classificationId)
throws ClassificationInUseException, ClassificationNotFoundException, NotAuthorizedException { throws ClassificationInUseException, ClassificationNotFoundException,
MismatchedRoleException {
taskanaEngine.getEngine().checkRoleMembership(TaskanaRole.BUSINESS_ADMIN, TaskanaRole.ADMIN); taskanaEngine.getEngine().checkRoleMembership(TaskanaRole.BUSINESS_ADMIN, TaskanaRole.ADMIN);
try { try {
taskanaEngine.openConnection(); taskanaEngine.openConnection();
@ -163,7 +164,8 @@ public class ClassificationServiceImpl implements ClassificationService {
@Override @Override
public void deleteClassification(String classificationKey, String domain) public void deleteClassification(String classificationKey, String domain)
throws ClassificationInUseException, ClassificationNotFoundException, NotAuthorizedException { throws ClassificationInUseException, ClassificationNotFoundException,
MismatchedRoleException {
taskanaEngine.getEngine().checkRoleMembership(TaskanaRole.BUSINESS_ADMIN, TaskanaRole.ADMIN); taskanaEngine.getEngine().checkRoleMembership(TaskanaRole.BUSINESS_ADMIN, TaskanaRole.ADMIN);
try { try {
taskanaEngine.openConnection(); taskanaEngine.openConnection();
@ -180,8 +182,8 @@ public class ClassificationServiceImpl implements ClassificationService {
@Override @Override
public Classification createClassification(Classification classification) public Classification createClassification(Classification classification)
throws ClassificationAlreadyExistException, NotAuthorizedException, DomainNotFoundException, throws ClassificationAlreadyExistException, DomainNotFoundException, InvalidArgumentException,
InvalidArgumentException, MalformedServiceLevelException { MalformedServiceLevelException, MismatchedRoleException {
taskanaEngine.getEngine().checkRoleMembership(TaskanaRole.BUSINESS_ADMIN, TaskanaRole.ADMIN); taskanaEngine.getEngine().checkRoleMembership(TaskanaRole.BUSINESS_ADMIN, TaskanaRole.ADMIN);
if (!taskanaEngine.domainExists(classification.getDomain()) if (!taskanaEngine.domainExists(classification.getDomain())
&& !MASTER_DOMAIN.equals(classification.getDomain())) { && !MASTER_DOMAIN.equals(classification.getDomain())) {
@ -234,8 +236,8 @@ public class ClassificationServiceImpl implements ClassificationService {
@Override @Override
public Classification updateClassification(Classification classification) public Classification updateClassification(Classification classification)
throws NotAuthorizedException, ConcurrencyException, ClassificationNotFoundException, throws ConcurrencyException, ClassificationNotFoundException, InvalidArgumentException,
InvalidArgumentException, MalformedServiceLevelException { MalformedServiceLevelException, MismatchedRoleException {
taskanaEngine.getEngine().checkRoleMembership(TaskanaRole.BUSINESS_ADMIN, TaskanaRole.ADMIN); taskanaEngine.getEngine().checkRoleMembership(TaskanaRole.BUSINESS_ADMIN, TaskanaRole.ADMIN);
ClassificationImpl classificationImpl; ClassificationImpl classificationImpl;
try { try {

View File

@ -5,7 +5,7 @@ import java.util.function.Supplier;
import pro.taskana.TaskanaConfiguration; import pro.taskana.TaskanaConfiguration;
import pro.taskana.classification.api.ClassificationService; import pro.taskana.classification.api.ClassificationService;
import pro.taskana.common.api.exceptions.NotAuthorizedException; import pro.taskana.common.api.exceptions.MismatchedRoleException;
import pro.taskana.common.api.security.CurrentUserContext; import pro.taskana.common.api.security.CurrentUserContext;
import pro.taskana.common.internal.TaskanaEngineImpl; import pro.taskana.common.internal.TaskanaEngineImpl;
import pro.taskana.monitor.api.MonitorService; import pro.taskana.monitor.api.MonitorService;
@ -187,10 +187,10 @@ public interface TaskanaEngine {
* *
* @param roles The {@linkplain TaskanaRole TaskanaRoles} that are checked for membership of the * @param roles The {@linkplain TaskanaRole TaskanaRoles} that are checked for membership of the
* current user * current user
* @throws NotAuthorizedException If the current user is not member of any specified {@linkplain * @throws MismatchedRoleException If the current user is not member of any specified {@linkplain
* TaskanaRole TaskanaRole} * TaskanaRole TaskanaRole}
*/ */
void checkRoleMembership(TaskanaRole... roles) throws NotAuthorizedException; void checkRoleMembership(TaskanaRole... roles) throws MismatchedRoleException;
/** /**
* Executes a given {@code Supplier} with admin privileges and thus skips further permission * Executes a given {@code Supplier} with admin privileges and thus skips further permission

View File

@ -38,7 +38,6 @@ import pro.taskana.common.api.WorkingDaysToDaysConverter;
import pro.taskana.common.api.exceptions.AutocommitFailedException; import pro.taskana.common.api.exceptions.AutocommitFailedException;
import pro.taskana.common.api.exceptions.ConnectionNotSetException; import pro.taskana.common.api.exceptions.ConnectionNotSetException;
import pro.taskana.common.api.exceptions.MismatchedRoleException; import pro.taskana.common.api.exceptions.MismatchedRoleException;
import pro.taskana.common.api.exceptions.NotAuthorizedException;
import pro.taskana.common.api.exceptions.SystemException; import pro.taskana.common.api.exceptions.SystemException;
import pro.taskana.common.api.security.CurrentUserContext; import pro.taskana.common.api.security.CurrentUserContext;
import pro.taskana.common.api.security.UserPrincipal; import pro.taskana.common.api.security.UserPrincipal;
@ -283,7 +282,7 @@ public class TaskanaEngineImpl implements TaskanaEngine {
} }
@Override @Override
public void checkRoleMembership(TaskanaRole... roles) throws NotAuthorizedException { public void checkRoleMembership(TaskanaRole... roles) throws MismatchedRoleException {
if (!isUserInRole(roles)) { if (!isUserInRole(roles)) {
if (LOGGER.isDebugEnabled()) { if (LOGGER.isDebugEnabled()) {
String rolesAsString = Arrays.toString(roles); String rolesAsString = Arrays.toString(roles);

View File

@ -5,7 +5,7 @@ import java.util.List;
import pro.taskana.classification.api.models.Classification; import pro.taskana.classification.api.models.Classification;
import pro.taskana.common.api.TimeInterval; import pro.taskana.common.api.TimeInterval;
import pro.taskana.common.api.exceptions.InvalidArgumentException; import pro.taskana.common.api.exceptions.InvalidArgumentException;
import pro.taskana.common.api.exceptions.NotAuthorizedException; import pro.taskana.common.api.exceptions.MismatchedRoleException;
import pro.taskana.monitor.api.TaskTimestamp; import pro.taskana.monitor.api.TaskTimestamp;
import pro.taskana.monitor.api.reports.header.ColumnHeader; import pro.taskana.monitor.api.reports.header.ColumnHeader;
import pro.taskana.monitor.api.reports.header.TimeIntervalColumnHeader; import pro.taskana.monitor.api.reports.header.TimeIntervalColumnHeader;
@ -34,10 +34,10 @@ public class ClassificationCategoryReport
@Override @Override
ClassificationCategoryReport buildReport() ClassificationCategoryReport buildReport()
throws NotAuthorizedException, InvalidArgumentException; throws InvalidArgumentException, MismatchedRoleException;
@Override @Override
ClassificationCategoryReport buildReport(TaskTimestamp timestamp) ClassificationCategoryReport buildReport(TaskTimestamp timestamp)
throws NotAuthorizedException, InvalidArgumentException; throws InvalidArgumentException, MismatchedRoleException;
} }
} }

View File

@ -3,9 +3,10 @@ package pro.taskana.monitor.api.reports;
import java.util.List; import java.util.List;
import pro.taskana.classification.api.models.Classification; import pro.taskana.classification.api.models.Classification;
import pro.taskana.common.api.TaskanaRole;
import pro.taskana.common.api.TimeInterval; import pro.taskana.common.api.TimeInterval;
import pro.taskana.common.api.exceptions.InvalidArgumentException; import pro.taskana.common.api.exceptions.InvalidArgumentException;
import pro.taskana.common.api.exceptions.NotAuthorizedException; import pro.taskana.common.api.exceptions.MismatchedRoleException;
import pro.taskana.monitor.api.TaskTimestamp; import pro.taskana.monitor.api.TaskTimestamp;
import pro.taskana.monitor.api.reports.header.ColumnHeader; import pro.taskana.monitor.api.reports.header.ColumnHeader;
import pro.taskana.monitor.api.reports.header.TimeIntervalColumnHeader; import pro.taskana.monitor.api.reports.header.TimeIntervalColumnHeader;
@ -35,11 +36,11 @@ public class ClassificationReport extends Report<MonitorQueryItem, TimeIntervalC
extends TimeIntervalReportBuilder<Builder, MonitorQueryItem, TimeIntervalColumnHeader> { extends TimeIntervalReportBuilder<Builder, MonitorQueryItem, TimeIntervalColumnHeader> {
@Override @Override
ClassificationReport buildReport() throws NotAuthorizedException, InvalidArgumentException; ClassificationReport buildReport() throws InvalidArgumentException, MismatchedRoleException;
@Override @Override
ClassificationReport buildReport(TaskTimestamp timestamp) ClassificationReport buildReport(TaskTimestamp timestamp)
throws NotAuthorizedException, InvalidArgumentException; throws InvalidArgumentException, MismatchedRoleException;
/** /**
* Returns a {@linkplain DetailedClassificationReport} containing all tasks after applying the * Returns a {@linkplain DetailedClassificationReport} containing all tasks after applying the
@ -49,13 +50,14 @@ public class ClassificationReport extends Report<MonitorQueryItem, TimeIntervalC
* *
* @return the DetailedClassificationReport * @return the DetailedClassificationReport
* @throws InvalidArgumentException if the column headers are not initialized * @throws InvalidArgumentException if the column headers are not initialized
* @throws NotAuthorizedException if the user has no rights to access the monitor * @throws MismatchedRoleException if the current user is not member of {@linkplain
* TaskanaRole#MONITOR} or {@linkplain TaskanaRole#ADMIN}
*/ */
DetailedClassificationReport buildDetailedReport() DetailedClassificationReport buildDetailedReport()
throws InvalidArgumentException, NotAuthorizedException; throws InvalidArgumentException, MismatchedRoleException;
DetailedClassificationReport buildDetailedReport(TaskTimestamp timestamp) DetailedClassificationReport buildDetailedReport(TaskTimestamp timestamp)
throws InvalidArgumentException, NotAuthorizedException; throws InvalidArgumentException, MismatchedRoleException;
} }
/** /**

View File

@ -8,7 +8,7 @@ import java.util.Map;
import java.util.Set; import java.util.Set;
import pro.taskana.common.api.exceptions.InvalidArgumentException; import pro.taskana.common.api.exceptions.InvalidArgumentException;
import pro.taskana.common.api.exceptions.NotAuthorizedException; import pro.taskana.common.api.exceptions.MismatchedRoleException;
import pro.taskana.monitor.api.reports.header.ColumnHeader; import pro.taskana.monitor.api.reports.header.ColumnHeader;
import pro.taskana.monitor.api.reports.item.QueryItem; import pro.taskana.monitor.api.reports.item.QueryItem;
import pro.taskana.monitor.api.reports.item.QueryItemPreprocessor; import pro.taskana.monitor.api.reports.item.QueryItemPreprocessor;
@ -133,6 +133,6 @@ public abstract class Report<I extends QueryItem, H extends ColumnHeader<? super
*/ */
public interface Builder<I extends QueryItem, H extends ColumnHeader<? super I>> { public interface Builder<I extends QueryItem, H extends ColumnHeader<? super I>> {
Report<I, H> buildReport() throws NotAuthorizedException, InvalidArgumentException; Report<I, H> buildReport() throws InvalidArgumentException, MismatchedRoleException;
} }
} }

View File

@ -4,7 +4,7 @@ import java.util.List;
import pro.taskana.common.api.TimeInterval; import pro.taskana.common.api.TimeInterval;
import pro.taskana.common.api.exceptions.InvalidArgumentException; import pro.taskana.common.api.exceptions.InvalidArgumentException;
import pro.taskana.common.api.exceptions.NotAuthorizedException; import pro.taskana.common.api.exceptions.MismatchedRoleException;
import pro.taskana.monitor.api.TaskTimestamp; import pro.taskana.monitor.api.TaskTimestamp;
import pro.taskana.monitor.api.reports.header.ColumnHeader; import pro.taskana.monitor.api.reports.header.ColumnHeader;
import pro.taskana.monitor.api.reports.header.TimeIntervalColumnHeader; import pro.taskana.monitor.api.reports.header.TimeIntervalColumnHeader;
@ -32,10 +32,10 @@ public class TaskCustomFieldValueReport extends Report<MonitorQueryItem, TimeInt
@Override @Override
TaskCustomFieldValueReport buildReport() TaskCustomFieldValueReport buildReport()
throws NotAuthorizedException, InvalidArgumentException; throws InvalidArgumentException, MismatchedRoleException;
@Override @Override
TaskCustomFieldValueReport buildReport(TaskTimestamp timestamp) TaskCustomFieldValueReport buildReport(TaskTimestamp timestamp)
throws NotAuthorizedException, InvalidArgumentException; throws InvalidArgumentException, MismatchedRoleException;
} }
} }

View File

@ -4,7 +4,7 @@ import java.util.List;
import java.util.stream.Collectors; import java.util.stream.Collectors;
import java.util.stream.Stream; import java.util.stream.Stream;
import pro.taskana.common.api.exceptions.NotAuthorizedException; import pro.taskana.common.api.exceptions.MismatchedRoleException;
import pro.taskana.monitor.api.reports.header.ColumnHeader; import pro.taskana.monitor.api.reports.header.ColumnHeader;
import pro.taskana.monitor.api.reports.header.TaskStatusColumnHeader; import pro.taskana.monitor.api.reports.header.TaskStatusColumnHeader;
import pro.taskana.monitor.api.reports.item.TaskQueryItem; import pro.taskana.monitor.api.reports.item.TaskQueryItem;
@ -34,7 +34,7 @@ public class TaskStatusReport extends Report<TaskQueryItem, TaskStatusColumnHead
public interface Builder extends Report.Builder<TaskQueryItem, TaskStatusColumnHeader> { public interface Builder extends Report.Builder<TaskQueryItem, TaskStatusColumnHeader> {
@Override @Override
TaskStatusReport buildReport() throws NotAuthorizedException; TaskStatusReport buildReport() throws MismatchedRoleException;
/** /**
* Adds a list of states to the builder. The created report contains only tasks with a state in * Adds a list of states to the builder. The created report contains only tasks with a state in

View File

@ -3,8 +3,9 @@ package pro.taskana.monitor.api.reports;
import java.util.List; import java.util.List;
import pro.taskana.common.api.IntInterval; import pro.taskana.common.api.IntInterval;
import pro.taskana.common.api.TaskanaRole;
import pro.taskana.common.api.exceptions.InvalidArgumentException; import pro.taskana.common.api.exceptions.InvalidArgumentException;
import pro.taskana.common.api.exceptions.NotAuthorizedException; import pro.taskana.common.api.exceptions.MismatchedRoleException;
import pro.taskana.monitor.api.SelectedItem; import pro.taskana.monitor.api.SelectedItem;
import pro.taskana.monitor.api.TaskTimestamp; import pro.taskana.monitor.api.TaskTimestamp;
import pro.taskana.monitor.api.reports.header.TimeIntervalColumnHeader; import pro.taskana.monitor.api.reports.header.TimeIntervalColumnHeader;
@ -215,30 +216,33 @@ public interface TimeIntervalReportBuilder<
* @param timestamp the {@linkplain TaskTimestamp} of interest * @param timestamp the {@linkplain TaskTimestamp} of interest
* @return the list of all taskIds * @return the list of all taskIds
* @throws InvalidArgumentException if the column headers are not initialized * @throws InvalidArgumentException if the column headers are not initialized
* @throws NotAuthorizedException if the user has no rights to access the monitor * @throws MismatchedRoleException if the current user is not member of {@linkplain
* TaskanaRole#MONITOR} or {@linkplain TaskanaRole#ADMIN}
*/ */
List<String> listTaskIdsForSelectedItems( List<String> listTaskIdsForSelectedItems(
List<SelectedItem> selectedItems, TaskTimestamp timestamp) List<SelectedItem> selectedItems, TaskTimestamp timestamp)
throws NotAuthorizedException, InvalidArgumentException; throws InvalidArgumentException, MismatchedRoleException;
/** /**
* Returns a list of all values of an entered custom field that are in the {@linkplain Report}. * Returns a list of all values of an entered custom field that are in the {@linkplain Report}.
* *
* @param taskCustomField the {@linkplain TaskCustomField} whose values should appear in the list * @param taskCustomField the {@linkplain TaskCustomField} whose values should appear in the list
* @return the list of all custom attribute values * @return the list of all custom attribute values
* @throws NotAuthorizedException if the user has no rights to access the monitor * @throws MismatchedRoleException if the current user is not member of {@linkplain
* TaskanaRole#MONITOR} or {@linkplain TaskanaRole#ADMIN}
*/ */
List<String> listCustomAttributeValuesForCustomAttributeName(TaskCustomField taskCustomField) List<String> listCustomAttributeValuesForCustomAttributeName(TaskCustomField taskCustomField)
throws NotAuthorizedException; throws MismatchedRoleException;
/** /**
* Builds the {@linkplain Report} for the specified {@linkplain TaskTimestamp}. * Builds the {@linkplain Report} for the specified {@linkplain TaskTimestamp}.
* *
* @param timestamp The {@linkplain TaskTimestamp} of interest * @param timestamp The {@linkplain TaskTimestamp} of interest
* @return The build {@linkplain Report} * @return The build {@linkplain Report}
* @throws NotAuthorizedException if the user has no rights to access the monitor * @throws MismatchedRoleException if the current user is not member of {@linkplain
* TaskanaRole#MONITOR} or {@linkplain TaskanaRole#ADMIN}
* @throws InvalidArgumentException if an error occurs * @throws InvalidArgumentException if an error occurs
*/ */
Report<I, H> buildReport(TaskTimestamp timestamp) Report<I, H> buildReport(TaskTimestamp timestamp)
throws NotAuthorizedException, InvalidArgumentException; throws InvalidArgumentException, MismatchedRoleException;
} }

View File

@ -4,7 +4,7 @@ import java.util.List;
import pro.taskana.common.api.TimeInterval; import pro.taskana.common.api.TimeInterval;
import pro.taskana.common.api.exceptions.InvalidArgumentException; import pro.taskana.common.api.exceptions.InvalidArgumentException;
import pro.taskana.common.api.exceptions.NotAuthorizedException; import pro.taskana.common.api.exceptions.MismatchedRoleException;
import pro.taskana.monitor.api.TaskTimestamp; import pro.taskana.monitor.api.TaskTimestamp;
import pro.taskana.monitor.api.reports.header.ColumnHeader; import pro.taskana.monitor.api.reports.header.ColumnHeader;
import pro.taskana.monitor.api.reports.header.TimeIntervalColumnHeader; import pro.taskana.monitor.api.reports.header.TimeIntervalColumnHeader;
@ -45,7 +45,7 @@ public class TimestampReport extends Report<TimestampQueryItem, TimeIntervalColu
TimestampReport.Builder, TimestampQueryItem, TimeIntervalColumnHeader> { TimestampReport.Builder, TimestampQueryItem, TimeIntervalColumnHeader> {
@Override @Override
TimestampReport buildReport() throws NotAuthorizedException, InvalidArgumentException; TimestampReport buildReport() throws InvalidArgumentException, MismatchedRoleException;
Builder withTimestamps(List<TaskTimestamp> taskTimestamps); Builder withTimestamps(List<TaskTimestamp> taskTimestamps);
} }

View File

@ -4,7 +4,7 @@ import java.util.List;
import pro.taskana.common.api.IntInterval; import pro.taskana.common.api.IntInterval;
import pro.taskana.common.api.exceptions.InvalidArgumentException; import pro.taskana.common.api.exceptions.InvalidArgumentException;
import pro.taskana.common.api.exceptions.NotAuthorizedException; import pro.taskana.common.api.exceptions.MismatchedRoleException;
import pro.taskana.monitor.api.reports.header.ColumnHeader; import pro.taskana.monitor.api.reports.header.ColumnHeader;
import pro.taskana.monitor.api.reports.header.PriorityColumnHeader; import pro.taskana.monitor.api.reports.header.PriorityColumnHeader;
import pro.taskana.monitor.api.reports.item.PriorityQueryItem; import pro.taskana.monitor.api.reports.item.PriorityQueryItem;
@ -33,7 +33,7 @@ public class WorkbasketPriorityReport extends Report<PriorityQueryItem, Priority
public interface Builder extends Report.Builder<PriorityQueryItem, PriorityColumnHeader> { public interface Builder extends Report.Builder<PriorityQueryItem, PriorityColumnHeader> {
@Override @Override
WorkbasketPriorityReport buildReport() throws NotAuthorizedException; WorkbasketPriorityReport buildReport() throws MismatchedRoleException;
/** /**
* Adds {@linkplain WorkbasketType WorkbasketTypes} to the builder. The created report will only * Adds {@linkplain WorkbasketType WorkbasketTypes} to the builder. The created report will only

View File

@ -4,7 +4,7 @@ import java.util.List;
import pro.taskana.common.api.TimeInterval; import pro.taskana.common.api.TimeInterval;
import pro.taskana.common.api.exceptions.InvalidArgumentException; import pro.taskana.common.api.exceptions.InvalidArgumentException;
import pro.taskana.common.api.exceptions.NotAuthorizedException; import pro.taskana.common.api.exceptions.MismatchedRoleException;
import pro.taskana.monitor.api.CombinedClassificationFilter; import pro.taskana.monitor.api.CombinedClassificationFilter;
import pro.taskana.monitor.api.TaskTimestamp; import pro.taskana.monitor.api.TaskTimestamp;
import pro.taskana.monitor.api.reports.header.ColumnHeader; import pro.taskana.monitor.api.reports.header.ColumnHeader;
@ -32,11 +32,11 @@ public class WorkbasketReport extends Report<MonitorQueryItem, TimeIntervalColum
extends TimeIntervalReportBuilder<Builder, MonitorQueryItem, TimeIntervalColumnHeader> { extends TimeIntervalReportBuilder<Builder, MonitorQueryItem, TimeIntervalColumnHeader> {
@Override @Override
WorkbasketReport buildReport() throws NotAuthorizedException, InvalidArgumentException; WorkbasketReport buildReport() throws InvalidArgumentException, MismatchedRoleException;
@Override @Override
WorkbasketReport buildReport(TaskTimestamp timestamp) WorkbasketReport buildReport(TaskTimestamp timestamp)
throws NotAuthorizedException, InvalidArgumentException; throws InvalidArgumentException, MismatchedRoleException;
/** /**
* Adds a list of {@linkplain CombinedClassificationFilter} to the builder. The created report * Adds a list of {@linkplain CombinedClassificationFilter} to the builder. The created report

View File

@ -5,7 +5,7 @@ import java.util.List;
import pro.taskana.common.api.TaskanaRole; import pro.taskana.common.api.TaskanaRole;
import pro.taskana.common.api.exceptions.InvalidArgumentException; import pro.taskana.common.api.exceptions.InvalidArgumentException;
import pro.taskana.common.api.exceptions.NotAuthorizedException; import pro.taskana.common.api.exceptions.MismatchedRoleException;
import pro.taskana.common.internal.InternalTaskanaEngine; import pro.taskana.common.internal.InternalTaskanaEngine;
import pro.taskana.monitor.api.TaskTimestamp; import pro.taskana.monitor.api.TaskTimestamp;
import pro.taskana.monitor.api.reports.ClassificationCategoryReport; import pro.taskana.monitor.api.reports.ClassificationCategoryReport;
@ -27,13 +27,13 @@ public class ClassificationCategoryReportBuilderImpl
@Override @Override
public ClassificationCategoryReport buildReport() public ClassificationCategoryReport buildReport()
throws NotAuthorizedException, InvalidArgumentException { throws InvalidArgumentException, MismatchedRoleException {
return buildReport(TaskTimestamp.DUE); return buildReport(TaskTimestamp.DUE);
} }
@Override @Override
public ClassificationCategoryReport buildReport(TaskTimestamp timestamp) public ClassificationCategoryReport buildReport(TaskTimestamp timestamp)
throws InvalidArgumentException, NotAuthorizedException { throws InvalidArgumentException, MismatchedRoleException {
this.taskanaEngine.getEngine().checkRoleMembership(TaskanaRole.MONITOR, TaskanaRole.ADMIN); this.taskanaEngine.getEngine().checkRoleMembership(TaskanaRole.MONITOR, TaskanaRole.ADMIN);
try { try {
this.taskanaEngine.openConnection(); this.taskanaEngine.openConnection();

View File

@ -10,7 +10,7 @@ import pro.taskana.classification.api.ClassificationService;
import pro.taskana.classification.api.models.ClassificationSummary; import pro.taskana.classification.api.models.ClassificationSummary;
import pro.taskana.common.api.TaskanaRole; import pro.taskana.common.api.TaskanaRole;
import pro.taskana.common.api.exceptions.InvalidArgumentException; import pro.taskana.common.api.exceptions.InvalidArgumentException;
import pro.taskana.common.api.exceptions.NotAuthorizedException; import pro.taskana.common.api.exceptions.MismatchedRoleException;
import pro.taskana.common.internal.InternalTaskanaEngine; import pro.taskana.common.internal.InternalTaskanaEngine;
import pro.taskana.monitor.api.TaskTimestamp; import pro.taskana.monitor.api.TaskTimestamp;
import pro.taskana.monitor.api.reports.ClassificationReport; import pro.taskana.monitor.api.reports.ClassificationReport;
@ -38,13 +38,13 @@ public class ClassificationReportBuilderImpl
@Override @Override
public ClassificationReport buildReport() public ClassificationReport buildReport()
throws NotAuthorizedException, InvalidArgumentException { throws InvalidArgumentException, MismatchedRoleException {
return buildReport(TaskTimestamp.DUE); return buildReport(TaskTimestamp.DUE);
} }
@Override @Override
public ClassificationReport buildReport(TaskTimestamp timestamp) public ClassificationReport buildReport(TaskTimestamp timestamp)
throws InvalidArgumentException, NotAuthorizedException { throws InvalidArgumentException, MismatchedRoleException {
this.taskanaEngine.getEngine().checkRoleMembership(TaskanaRole.MONITOR, TaskanaRole.ADMIN); this.taskanaEngine.getEngine().checkRoleMembership(TaskanaRole.MONITOR, TaskanaRole.ADMIN);
try { try {
this.taskanaEngine.openConnection(); this.taskanaEngine.openConnection();
@ -77,13 +77,13 @@ public class ClassificationReportBuilderImpl
@Override @Override
public DetailedClassificationReport buildDetailedReport() public DetailedClassificationReport buildDetailedReport()
throws InvalidArgumentException, NotAuthorizedException { throws InvalidArgumentException, MismatchedRoleException {
return buildDetailedReport(TaskTimestamp.DUE); return buildDetailedReport(TaskTimestamp.DUE);
} }
@Override @Override
public DetailedClassificationReport buildDetailedReport(TaskTimestamp timestamp) public DetailedClassificationReport buildDetailedReport(TaskTimestamp timestamp)
throws InvalidArgumentException, NotAuthorizedException { throws InvalidArgumentException, MismatchedRoleException {
this.taskanaEngine.getEngine().checkRoleMembership(TaskanaRole.MONITOR, TaskanaRole.ADMIN); this.taskanaEngine.getEngine().checkRoleMembership(TaskanaRole.MONITOR, TaskanaRole.ADMIN);
try { try {
this.taskanaEngine.openConnection(); this.taskanaEngine.openConnection();

View File

@ -5,7 +5,7 @@ import java.util.List;
import pro.taskana.common.api.TaskanaRole; import pro.taskana.common.api.TaskanaRole;
import pro.taskana.common.api.exceptions.InvalidArgumentException; import pro.taskana.common.api.exceptions.InvalidArgumentException;
import pro.taskana.common.api.exceptions.NotAuthorizedException; import pro.taskana.common.api.exceptions.MismatchedRoleException;
import pro.taskana.common.internal.InternalTaskanaEngine; import pro.taskana.common.internal.InternalTaskanaEngine;
import pro.taskana.monitor.api.TaskTimestamp; import pro.taskana.monitor.api.TaskTimestamp;
import pro.taskana.monitor.api.reports.TaskCustomFieldValueReport; import pro.taskana.monitor.api.reports.TaskCustomFieldValueReport;
@ -33,13 +33,13 @@ public class TaskCustomFieldValueReportBuilderImpl
@Override @Override
public TaskCustomFieldValueReport buildReport() public TaskCustomFieldValueReport buildReport()
throws NotAuthorizedException, InvalidArgumentException { throws InvalidArgumentException, MismatchedRoleException {
return buildReport(TaskTimestamp.DUE); return buildReport(TaskTimestamp.DUE);
} }
@Override @Override
public TaskCustomFieldValueReport buildReport(TaskTimestamp timestamp) public TaskCustomFieldValueReport buildReport(TaskTimestamp timestamp)
throws InvalidArgumentException, NotAuthorizedException { throws InvalidArgumentException, MismatchedRoleException {
this.taskanaEngine.getEngine().checkRoleMembership(TaskanaRole.MONITOR, TaskanaRole.ADMIN); this.taskanaEngine.getEngine().checkRoleMembership(TaskanaRole.MONITOR, TaskanaRole.ADMIN);
try { try {
this.taskanaEngine.openConnection(); this.taskanaEngine.openConnection();

View File

@ -6,7 +6,7 @@ import java.util.Map;
import java.util.stream.Collectors; import java.util.stream.Collectors;
import pro.taskana.common.api.TaskanaRole; import pro.taskana.common.api.TaskanaRole;
import pro.taskana.common.api.exceptions.NotAuthorizedException; import pro.taskana.common.api.exceptions.MismatchedRoleException;
import pro.taskana.common.internal.InternalTaskanaEngine; import pro.taskana.common.internal.InternalTaskanaEngine;
import pro.taskana.monitor.api.reports.TaskStatusReport; import pro.taskana.monitor.api.reports.TaskStatusReport;
import pro.taskana.monitor.api.reports.TaskStatusReport.Builder; import pro.taskana.monitor.api.reports.TaskStatusReport.Builder;
@ -35,7 +35,7 @@ public class TaskStatusReportBuilderImpl implements TaskStatusReport.Builder {
} }
@Override @Override
public TaskStatusReport buildReport() throws NotAuthorizedException { public TaskStatusReport buildReport() throws MismatchedRoleException {
this.taskanaEngine.getEngine().checkRoleMembership(TaskanaRole.MONITOR, TaskanaRole.ADMIN); this.taskanaEngine.getEngine().checkRoleMembership(TaskanaRole.MONITOR, TaskanaRole.ADMIN);
try { try {
this.taskanaEngine.openConnection(); this.taskanaEngine.openConnection();

View File

@ -9,7 +9,7 @@ import pro.taskana.common.api.IntInterval;
import pro.taskana.common.api.TaskanaRole; import pro.taskana.common.api.TaskanaRole;
import pro.taskana.common.api.WorkingDaysToDaysConverter; import pro.taskana.common.api.WorkingDaysToDaysConverter;
import pro.taskana.common.api.exceptions.InvalidArgumentException; import pro.taskana.common.api.exceptions.InvalidArgumentException;
import pro.taskana.common.api.exceptions.NotAuthorizedException; import pro.taskana.common.api.exceptions.MismatchedRoleException;
import pro.taskana.common.api.exceptions.SystemException; import pro.taskana.common.api.exceptions.SystemException;
import pro.taskana.common.internal.InternalTaskanaEngine; import pro.taskana.common.internal.InternalTaskanaEngine;
import pro.taskana.monitor.api.CombinedClassificationFilter; import pro.taskana.monitor.api.CombinedClassificationFilter;
@ -547,7 +547,7 @@ abstract class TimeIntervalReportBuilderImpl<
@Override @Override
public List<String> listTaskIdsForSelectedItems( public List<String> listTaskIdsForSelectedItems(
List<SelectedItem> selectedItems, TaskTimestamp timestamp) List<SelectedItem> selectedItems, TaskTimestamp timestamp)
throws NotAuthorizedException, InvalidArgumentException { throws InvalidArgumentException, MismatchedRoleException {
this.taskanaEngine.getEngine().checkRoleMembership(TaskanaRole.MONITOR); this.taskanaEngine.getEngine().checkRoleMembership(TaskanaRole.MONITOR);
try { try {
@ -583,7 +583,7 @@ abstract class TimeIntervalReportBuilderImpl<
@Override @Override
public List<String> listCustomAttributeValuesForCustomAttributeName( public List<String> listCustomAttributeValuesForCustomAttributeName(
TaskCustomField taskCustomField) throws NotAuthorizedException { TaskCustomField taskCustomField) throws MismatchedRoleException {
this.taskanaEngine.getEngine().checkRoleMembership(TaskanaRole.MONITOR); this.taskanaEngine.getEngine().checkRoleMembership(TaskanaRole.MONITOR);
try { try {
this.taskanaEngine.openConnection(); this.taskanaEngine.openConnection();

View File

@ -9,7 +9,7 @@ import java.util.stream.Collectors;
import pro.taskana.common.api.TaskanaRole; import pro.taskana.common.api.TaskanaRole;
import pro.taskana.common.api.exceptions.InvalidArgumentException; import pro.taskana.common.api.exceptions.InvalidArgumentException;
import pro.taskana.common.api.exceptions.NotAuthorizedException; import pro.taskana.common.api.exceptions.MismatchedRoleException;
import pro.taskana.common.internal.InternalTaskanaEngine; import pro.taskana.common.internal.InternalTaskanaEngine;
import pro.taskana.monitor.api.SelectedItem; import pro.taskana.monitor.api.SelectedItem;
import pro.taskana.monitor.api.TaskTimestamp; import pro.taskana.monitor.api.TaskTimestamp;
@ -55,12 +55,12 @@ public class TimestampReportBuilderImpl
@Override @Override
public Report<TimestampQueryItem, TimeIntervalColumnHeader> buildReport(TaskTimestamp timestamp) public Report<TimestampQueryItem, TimeIntervalColumnHeader> buildReport(TaskTimestamp timestamp)
throws NotAuthorizedException, InvalidArgumentException { throws InvalidArgumentException, MismatchedRoleException {
return buildReport(); return buildReport();
} }
@Override @Override
public TimestampReport buildReport() throws NotAuthorizedException, InvalidArgumentException { public TimestampReport buildReport() throws InvalidArgumentException, MismatchedRoleException {
this.taskanaEngine.getEngine().checkRoleMembership(TaskanaRole.MONITOR, TaskanaRole.ADMIN); this.taskanaEngine.getEngine().checkRoleMembership(TaskanaRole.MONITOR, TaskanaRole.ADMIN);
try { try {
this.taskanaEngine.openConnection(); this.taskanaEngine.openConnection();

View File

@ -7,7 +7,7 @@ import pro.taskana.common.api.IntInterval;
import pro.taskana.common.api.TaskanaRole; import pro.taskana.common.api.TaskanaRole;
import pro.taskana.common.api.WorkingDaysToDaysConverter; import pro.taskana.common.api.WorkingDaysToDaysConverter;
import pro.taskana.common.api.exceptions.InvalidArgumentException; import pro.taskana.common.api.exceptions.InvalidArgumentException;
import pro.taskana.common.api.exceptions.NotAuthorizedException; import pro.taskana.common.api.exceptions.MismatchedRoleException;
import pro.taskana.common.api.exceptions.SystemException; import pro.taskana.common.api.exceptions.SystemException;
import pro.taskana.common.internal.InternalTaskanaEngine; import pro.taskana.common.internal.InternalTaskanaEngine;
import pro.taskana.monitor.api.reports.WorkbasketPriorityReport; import pro.taskana.monitor.api.reports.WorkbasketPriorityReport;
@ -125,7 +125,7 @@ public class WorkbasketPriorityReportBuilderImpl implements WorkbasketPriorityRe
} }
@Override @Override
public WorkbasketPriorityReport buildReport() throws NotAuthorizedException { public WorkbasketPriorityReport buildReport() throws MismatchedRoleException {
taskanaEngine.getEngine().checkRoleMembership(TaskanaRole.MONITOR, TaskanaRole.ADMIN); taskanaEngine.getEngine().checkRoleMembership(TaskanaRole.MONITOR, TaskanaRole.ADMIN);
WorkbasketPriorityReport report = new WorkbasketPriorityReport(columnHeaders); WorkbasketPriorityReport report = new WorkbasketPriorityReport(columnHeaders);

View File

@ -7,7 +7,7 @@ import java.util.stream.Collectors;
import pro.taskana.common.api.TaskanaRole; import pro.taskana.common.api.TaskanaRole;
import pro.taskana.common.api.exceptions.InvalidArgumentException; import pro.taskana.common.api.exceptions.InvalidArgumentException;
import pro.taskana.common.api.exceptions.NotAuthorizedException; import pro.taskana.common.api.exceptions.MismatchedRoleException;
import pro.taskana.common.internal.InternalTaskanaEngine; import pro.taskana.common.internal.InternalTaskanaEngine;
import pro.taskana.monitor.api.CombinedClassificationFilter; import pro.taskana.monitor.api.CombinedClassificationFilter;
import pro.taskana.monitor.api.TaskTimestamp; import pro.taskana.monitor.api.TaskTimestamp;
@ -34,13 +34,13 @@ public class WorkbasketReportBuilderImpl
} }
@Override @Override
public WorkbasketReport buildReport() throws NotAuthorizedException, InvalidArgumentException { public WorkbasketReport buildReport() throws InvalidArgumentException, MismatchedRoleException {
return buildReport(TaskTimestamp.DUE); return buildReport(TaskTimestamp.DUE);
} }
@Override @Override
public WorkbasketReport buildReport(TaskTimestamp timestamp) public WorkbasketReport buildReport(TaskTimestamp timestamp)
throws InvalidArgumentException, NotAuthorizedException { throws InvalidArgumentException, MismatchedRoleException {
this.taskanaEngine.getEngine().checkRoleMembership(TaskanaRole.MONITOR, TaskanaRole.ADMIN); this.taskanaEngine.getEngine().checkRoleMembership(TaskanaRole.MONITOR, TaskanaRole.ADMIN);
try { try {
this.taskanaEngine.openConnection(); this.taskanaEngine.openConnection();

View File

@ -3,8 +3,9 @@ package pro.taskana.spi.history.api;
import java.util.List; import java.util.List;
import pro.taskana.common.api.TaskanaEngine; import pro.taskana.common.api.TaskanaEngine;
import pro.taskana.common.api.TaskanaRole;
import pro.taskana.common.api.exceptions.InvalidArgumentException; import pro.taskana.common.api.exceptions.InvalidArgumentException;
import pro.taskana.common.api.exceptions.NotAuthorizedException; import pro.taskana.common.api.exceptions.MismatchedRoleException;
import pro.taskana.spi.history.api.events.classification.ClassificationHistoryEvent; import pro.taskana.spi.history.api.events.classification.ClassificationHistoryEvent;
import pro.taskana.spi.history.api.events.task.TaskHistoryEvent; import pro.taskana.spi.history.api.events.task.TaskHistoryEvent;
import pro.taskana.spi.history.api.events.workbasket.WorkbasketHistoryEvent; import pro.taskana.spi.history.api.events.workbasket.WorkbasketHistoryEvent;
@ -45,8 +46,9 @@ public interface TaskanaHistory {
* *
* @param taskIds the task ids for which all history events must be deleted * @param taskIds the task ids for which all history events must be deleted
* @throws InvalidArgumentException If the list of taskIds is null * @throws InvalidArgumentException If the list of taskIds is null
* @throws NotAuthorizedException If the user has no permission to delete events * @throws MismatchedRoleException if the current user is not member of {@linkplain
* TaskanaRole#ADMIN}
*/ */
void deleteHistoryEventsByTaskIds(List<String> taskIds) void deleteHistoryEventsByTaskIds(List<String> taskIds)
throws InvalidArgumentException, NotAuthorizedException; throws InvalidArgumentException, MismatchedRoleException;
} }

View File

@ -1,7 +1,7 @@
package pro.taskana.spi.history.api.exceptions; package pro.taskana.spi.history.api.exceptions;
import pro.taskana.common.api.exceptions.ErrorCode; import pro.taskana.common.api.exceptions.ErrorCode;
import pro.taskana.common.api.exceptions.NotFoundException; import pro.taskana.common.api.exceptions.TaskanaException;
import pro.taskana.common.internal.util.MapCreator; import pro.taskana.common.internal.util.MapCreator;
import pro.taskana.spi.history.api.events.task.TaskHistoryEvent; import pro.taskana.spi.history.api.events.task.TaskHistoryEvent;
@ -9,7 +9,7 @@ import pro.taskana.spi.history.api.events.task.TaskHistoryEvent;
* This exception is thrown when the {@linkplain TaskHistoryEvent} with the specified {@linkplain * This exception is thrown when the {@linkplain TaskHistoryEvent} with the specified {@linkplain
* TaskHistoryEvent#getId() id} was not found. * TaskHistoryEvent#getId() id} was not found.
*/ */
public class TaskanaHistoryEventNotFoundException extends NotFoundException { public class TaskanaHistoryEventNotFoundException extends TaskanaException {
public static final String ERROR_KEY = "HISTORY_EVENT_NOT_FOUND"; public static final String ERROR_KEY = "HISTORY_EVENT_NOT_FOUND";
private final String historyEventId; private final String historyEventId;

View File

@ -10,13 +10,14 @@ import pro.taskana.common.api.BulkOperationResults;
import pro.taskana.common.api.TaskanaRole; import pro.taskana.common.api.TaskanaRole;
import pro.taskana.common.api.exceptions.ConcurrencyException; import pro.taskana.common.api.exceptions.ConcurrencyException;
import pro.taskana.common.api.exceptions.InvalidArgumentException; import pro.taskana.common.api.exceptions.InvalidArgumentException;
import pro.taskana.common.api.exceptions.NotAuthorizedException; import pro.taskana.common.api.exceptions.MismatchedRoleException;
import pro.taskana.common.api.exceptions.TaskanaException; import pro.taskana.common.api.exceptions.TaskanaException;
import pro.taskana.spi.routing.api.TaskRoutingProvider; import pro.taskana.spi.routing.api.TaskRoutingProvider;
import pro.taskana.task.api.exceptions.AttachmentPersistenceException; import pro.taskana.task.api.exceptions.AttachmentPersistenceException;
import pro.taskana.task.api.exceptions.InvalidCallbackStateException;
import pro.taskana.task.api.exceptions.InvalidOwnerException; import pro.taskana.task.api.exceptions.InvalidOwnerException;
import pro.taskana.task.api.exceptions.InvalidStateException;
import pro.taskana.task.api.exceptions.InvalidTaskStateException; import pro.taskana.task.api.exceptions.InvalidTaskStateException;
import pro.taskana.task.api.exceptions.MismatchedTaskCommentCreatorException;
import pro.taskana.task.api.exceptions.ObjectReferencePersistenceException; import pro.taskana.task.api.exceptions.ObjectReferencePersistenceException;
import pro.taskana.task.api.exceptions.TaskAlreadyExistException; import pro.taskana.task.api.exceptions.TaskAlreadyExistException;
import pro.taskana.task.api.exceptions.TaskCommentNotFoundException; import pro.taskana.task.api.exceptions.TaskCommentNotFoundException;
@ -26,6 +27,7 @@ import pro.taskana.task.api.models.ObjectReference;
import pro.taskana.task.api.models.Task; import pro.taskana.task.api.models.Task;
import pro.taskana.task.api.models.TaskComment; import pro.taskana.task.api.models.TaskComment;
import pro.taskana.workbasket.api.WorkbasketPermission; import pro.taskana.workbasket.api.WorkbasketPermission;
import pro.taskana.workbasket.api.exceptions.MismatchedWorkbasketPermissionException;
import pro.taskana.workbasket.api.exceptions.WorkbasketNotFoundException; import pro.taskana.workbasket.api.exceptions.WorkbasketNotFoundException;
import pro.taskana.workbasket.api.models.Workbasket; import pro.taskana.workbasket.api.models.Workbasket;
@ -105,7 +107,7 @@ public interface TaskService {
* @param taskToCreate the transient {@linkplain Task} to be inserted * @param taskToCreate the transient {@linkplain Task} to be inserted
* @return the created and inserted {@linkplain Task} * @return the created and inserted {@linkplain Task}
* @throws TaskAlreadyExistException if the {@linkplain Task} already exists * @throws TaskAlreadyExistException if the {@linkplain Task} already exists
* @throws NotAuthorizedException if the current user has no {@linkplain * @throws MismatchedWorkbasketPermissionException if the current user has no {@linkplain
* WorkbasketPermission#APPEND} for the {@linkplain Workbasket} the {@linkplain Task} is in * WorkbasketPermission#APPEND} for the {@linkplain Workbasket} the {@linkplain Task} is in
* @throws WorkbasketNotFoundException if the {@linkplain Workbasket} referenced by the * @throws WorkbasketNotFoundException if the {@linkplain Workbasket} referenced by the
* {@linkplain Task#getWorkbasketSummary() workbasketSummary} of the {@linkplain Task} isn't * {@linkplain Task#getWorkbasketSummary() workbasketSummary} of the {@linkplain Task} isn't
@ -123,9 +125,9 @@ public interface TaskService {
* without using {@linkplain Task#addSecondaryObjectReference(ObjectReference)} * without using {@linkplain Task#addSecondaryObjectReference(ObjectReference)}
*/ */
Task createTask(Task taskToCreate) Task createTask(Task taskToCreate)
throws NotAuthorizedException, WorkbasketNotFoundException, ClassificationNotFoundException, throws WorkbasketNotFoundException, ClassificationNotFoundException,
TaskAlreadyExistException, InvalidArgumentException, AttachmentPersistenceException, TaskAlreadyExistException, InvalidArgumentException, AttachmentPersistenceException,
ObjectReferencePersistenceException; ObjectReferencePersistenceException, MismatchedWorkbasketPermissionException;
// endregion // endregion
@ -137,10 +139,10 @@ public interface TaskService {
* @param taskId the {@linkplain Task#getId() id} of the {@linkplain Task} * @param taskId the {@linkplain Task#getId() id} of the {@linkplain Task}
* @return the {@linkplain Task} with the specified taskId * @return the {@linkplain Task} with the specified taskId
* @throws TaskNotFoundException if the {@linkplain Task} with taskId wasn't found * @throws TaskNotFoundException if the {@linkplain Task} with taskId wasn't found
* @throws NotAuthorizedException if the current user has no {@linkplain * @throws MismatchedWorkbasketPermissionException if the current user has no {@linkplain
* WorkbasketPermission#READ} for the {@linkplain Workbasket} the {@linkplain Task} is in * WorkbasketPermission#READ} for the {@linkplain Workbasket} the {@linkplain Task} is in
*/ */
Task getTask(String taskId) throws TaskNotFoundException, NotAuthorizedException; Task getTask(String taskId) throws TaskNotFoundException, MismatchedWorkbasketPermissionException;
// endregion // endregion
@ -152,15 +154,15 @@ public interface TaskService {
* @param taskId the {@linkplain Task#getId() id} of the {@linkplain Task} to be claimed * @param taskId the {@linkplain Task#getId() id} of the {@linkplain Task} to be claimed
* @return the claimed {@linkplain Task} * @return the claimed {@linkplain Task}
* @throws TaskNotFoundException if the {@linkplain Task} with taskId was not found * @throws TaskNotFoundException if the {@linkplain Task} with taskId was not found
* @throws InvalidStateException if the {@linkplain Task#getState() state} of the {@linkplain * @throws InvalidTaskStateException if the {@linkplain Task#getState() state} of the {@linkplain
* Task} with taskId isn't {@linkplain TaskState#READY} * Task} with taskId isn't {@linkplain TaskState#READY}
* @throws InvalidOwnerException if the {@linkplain Task} with taskId is claimed by some else * @throws InvalidOwnerException if the {@linkplain Task} with taskId is claimed by some else
* @throws NotAuthorizedException if the current user has no {@linkplain * @throws MismatchedWorkbasketPermissionException if the current user has no {@linkplain
* WorkbasketPermission#READ} for the {@linkplain Workbasket} the {@linkplain Task} is in * WorkbasketPermission#READ} for the {@linkplain Workbasket} the {@linkplain Task} is in
*/ */
Task claim(String taskId) Task claim(String taskId)
throws TaskNotFoundException, InvalidStateException, InvalidOwnerException, throws TaskNotFoundException, InvalidOwnerException, MismatchedWorkbasketPermissionException,
NotAuthorizedException; InvalidTaskStateException;
/** /**
* Claim an existing {@linkplain Task} for the current user even if it is already claimed by * Claim an existing {@linkplain Task} for the current user even if it is already claimed by
@ -169,15 +171,15 @@ public interface TaskService {
* @param taskId the {@linkplain Task#getId() id} of the {@linkplain Task} to be claimed * @param taskId the {@linkplain Task#getId() id} of the {@linkplain Task} to be claimed
* @return the claimed {@linkplain Task} * @return the claimed {@linkplain Task}
* @throws TaskNotFoundException if the {@linkplain Task} with taskId was not found * @throws TaskNotFoundException if the {@linkplain Task} with taskId was not found
* @throws InvalidStateException if the state of Task with taskId is in {@linkplain * @throws InvalidTaskStateException if the state of Task with taskId is in {@linkplain
* TaskState#END_STATES} * TaskState#END_STATES}
* @throws InvalidOwnerException cannot be thrown * @throws InvalidOwnerException cannot be thrown
* @throws NotAuthorizedException if the current user has no {@linkplain * @throws MismatchedWorkbasketPermissionException if the current user has no {@linkplain
* WorkbasketPermission#READ} for the {@linkplain Workbasket} the {@linkplain Task} is in * WorkbasketPermission#READ} for the {@linkplain Workbasket} the {@linkplain Task} is in
*/ */
Task forceClaim(String taskId) Task forceClaim(String taskId)
throws TaskNotFoundException, InvalidStateException, InvalidOwnerException, throws TaskNotFoundException, InvalidOwnerException, MismatchedWorkbasketPermissionException,
NotAuthorizedException; InvalidTaskStateException;
/** /**
* Selects and claims the first {@linkplain Task} which is returned by the {@linkplain TaskQuery}. * Selects and claims the first {@linkplain Task} which is returned by the {@linkplain TaskQuery}.
@ -185,10 +187,11 @@ public interface TaskService {
* @param taskQuery the {@linkplain TaskQuery} * @param taskQuery the {@linkplain TaskQuery}
* @return the {@linkplain Task} that got selected and claimed * @return the {@linkplain Task} that got selected and claimed
* @throws InvalidOwnerException if the {@linkplain Task} is claimed by someone else * @throws InvalidOwnerException if the {@linkplain Task} is claimed by someone else
* @throws NotAuthorizedException if the current user has no {@linkplain * @throws MismatchedWorkbasketPermissionException if the current user has no {@linkplain
* WorkbasketPermission#READ} for the {@linkplain Workbasket} the {@linkplain Task} is in * WorkbasketPermission#READ} for the {@linkplain Workbasket} the {@linkplain Task} is in
*/ */
Task selectAndClaim(TaskQuery taskQuery) throws NotAuthorizedException, InvalidOwnerException; Task selectAndClaim(TaskQuery taskQuery)
throws InvalidOwnerException, MismatchedWorkbasketPermissionException;
/** /**
* Cancel the claim of an existing {@linkplain Task} if it was claimed by the current user before. * Cancel the claim of an existing {@linkplain Task} if it was claimed by the current user before.
@ -197,15 +200,15 @@ public interface TaskService {
* unclaimed * unclaimed
* @return the unclaimed {@linkplain Task} * @return the unclaimed {@linkplain Task}
* @throws TaskNotFoundException if the {@linkplain Task} with taskId was not found * @throws TaskNotFoundException if the {@linkplain Task} with taskId was not found
* @throws InvalidStateException if the {@linkplain Task} is already in one of the {@linkplain * @throws InvalidTaskStateException if the {@linkplain Task} is already in one of the {@linkplain
* TaskState#END_STATES} * TaskState#END_STATES}
* @throws InvalidOwnerException if the {@linkplain Task} is claimed by another user * @throws InvalidOwnerException if the {@linkplain Task} is claimed by another user
* @throws NotAuthorizedException if the current user has no {@linkplain * @throws MismatchedWorkbasketPermissionException if the current user has no {@linkplain
* WorkbasketPermission#READ} for the {@linkplain Workbasket} the {@linkplain Task} is in * WorkbasketPermission#READ} for the {@linkplain Workbasket} the {@linkplain Task} is in
*/ */
Task cancelClaim(String taskId) Task cancelClaim(String taskId)
throws TaskNotFoundException, InvalidStateException, InvalidOwnerException, throws TaskNotFoundException, InvalidOwnerException, MismatchedWorkbasketPermissionException,
NotAuthorizedException; InvalidTaskStateException;
/** /**
* Cancel the claim of an existing {@linkplain Task} even if it was claimed by another user. * Cancel the claim of an existing {@linkplain Task} even if it was claimed by another user.
@ -214,15 +217,15 @@ public interface TaskService {
* unclaimed * unclaimed
* @return the unclaimed {@linkplain Task} * @return the unclaimed {@linkplain Task}
* @throws TaskNotFoundException if the {@linkplain Task} with taskId was not found * @throws TaskNotFoundException if the {@linkplain Task} with taskId was not found
* @throws InvalidStateException if the {@linkplain Task} is already in one of the {@linkplain * @throws InvalidTaskStateException if the {@linkplain Task} is already in one of the {@linkplain
* TaskState#END_STATES} * TaskState#END_STATES}
* @throws InvalidOwnerException cannot be thrown * @throws InvalidOwnerException cannot be thrown
* @throws NotAuthorizedException if the current user has no {@linkplain * @throws MismatchedWorkbasketPermissionException if the current user has no {@linkplain
* WorkbasketPermission#READ} for the {@linkplain Workbasket} the {@linkplain Task} is in * WorkbasketPermission#READ} for the {@linkplain Workbasket} the {@linkplain Task} is in
*/ */
Task forceCancelClaim(String taskId) Task forceCancelClaim(String taskId)
throws TaskNotFoundException, InvalidStateException, InvalidOwnerException, throws TaskNotFoundException, InvalidOwnerException, MismatchedWorkbasketPermissionException,
NotAuthorizedException; InvalidTaskStateException;
/** /**
* Request review for an existing {@linkplain Task} that is in {@linkplain TaskState#CLAIMED}. * Request review for an existing {@linkplain Task} that is in {@linkplain TaskState#CLAIMED}.
@ -233,12 +236,12 @@ public interface TaskService {
* Task} with taskId is not in {@linkplain TaskState#CLAIMED} * Task} with taskId is not in {@linkplain TaskState#CLAIMED}
* @throws TaskNotFoundException if the {@linkplain Task} with taskId wasn't found * @throws TaskNotFoundException if the {@linkplain Task} with taskId wasn't found
* @throws InvalidOwnerException if the {@linkplain Task} is claimed by another user * @throws InvalidOwnerException if the {@linkplain Task} is claimed by another user
* @throws NotAuthorizedException if the current user has no {@linkplain * @throws MismatchedWorkbasketPermissionException if the current user has no {@linkplain
* WorkbasketPermission#READ} for the {@linkplain Workbasket} the {@linkplain Task} is in * WorkbasketPermission#READ} for the {@linkplain Workbasket} the {@linkplain Task} is in
*/ */
Task requestReview(String taskId) Task requestReview(String taskId)
throws InvalidTaskStateException, TaskNotFoundException, NotAuthorizedException, throws InvalidTaskStateException, TaskNotFoundException, InvalidOwnerException,
InvalidOwnerException; MismatchedWorkbasketPermissionException;
/** /**
* Request review for an existing {@linkplain Task} even if the current user is not the * Request review for an existing {@linkplain Task} even if the current user is not the
@ -250,12 +253,12 @@ public interface TaskService {
* Task} with taskId is one of the {@linkplain TaskState#END_STATES} * Task} with taskId is one of the {@linkplain TaskState#END_STATES}
* @throws TaskNotFoundException if the {@linkplain Task} with taskId wasn't found * @throws TaskNotFoundException if the {@linkplain Task} with taskId wasn't found
* @throws InvalidOwnerException cannot be thrown * @throws InvalidOwnerException cannot be thrown
* @throws NotAuthorizedException if the current user has no {@linkplain * @throws MismatchedWorkbasketPermissionException if the current user has no {@linkplain
* WorkbasketPermission#READ} for the {@linkplain Workbasket} the {@linkplain Task} is in * WorkbasketPermission#READ} for the {@linkplain Workbasket} the {@linkplain Task} is in
*/ */
Task forceRequestReview(String taskId) Task forceRequestReview(String taskId)
throws InvalidTaskStateException, TaskNotFoundException, NotAuthorizedException, throws InvalidTaskStateException, TaskNotFoundException, InvalidOwnerException,
InvalidOwnerException; MismatchedWorkbasketPermissionException;
/** /**
* Request changes for an existing {@linkplain Task} that is in {@linkplain TaskState#IN_REVIEW}. * Request changes for an existing {@linkplain Task} that is in {@linkplain TaskState#IN_REVIEW}.
@ -268,12 +271,12 @@ public interface TaskService {
* Task} with taskId is not in {@linkplain TaskState#IN_REVIEW} * Task} with taskId is not in {@linkplain TaskState#IN_REVIEW}
* @throws TaskNotFoundException if the {@linkplain Task} with taskId wasn't found * @throws TaskNotFoundException if the {@linkplain Task} with taskId wasn't found
* @throws InvalidOwnerException if the {@linkplain Task} is claimed by another user * @throws InvalidOwnerException if the {@linkplain Task} is claimed by another user
* @throws NotAuthorizedException if the current user has no {@linkplain * @throws MismatchedWorkbasketPermissionException if the current user has no {@linkplain
* WorkbasketPermission#READ} for the {@linkplain Workbasket} the {@linkplain Task} is in * WorkbasketPermission#READ} for the {@linkplain Workbasket} the {@linkplain Task} is in
*/ */
Task requestChanges(String taskId) Task requestChanges(String taskId)
throws InvalidTaskStateException, TaskNotFoundException, NotAuthorizedException, throws InvalidTaskStateException, TaskNotFoundException, InvalidOwnerException,
InvalidOwnerException; MismatchedWorkbasketPermissionException;
/** /**
* Request changes for an existing {@linkplain Task} even if the current user is not the * Request changes for an existing {@linkplain Task} even if the current user is not the
@ -287,12 +290,12 @@ public interface TaskService {
* Task} with taskId is one of the {@linkplain TaskState#END_STATES} * Task} with taskId is one of the {@linkplain TaskState#END_STATES}
* @throws TaskNotFoundException if the {@linkplain Task} with taskId wasn't found * @throws TaskNotFoundException if the {@linkplain Task} with taskId wasn't found
* @throws InvalidOwnerException cannot be thrown * @throws InvalidOwnerException cannot be thrown
* @throws NotAuthorizedException if the current user has no {@linkplain * @throws MismatchedWorkbasketPermissionException if the current user has no {@linkplain
* WorkbasketPermission#READ} for the {@linkplain Workbasket} the {@linkplain Task} is in * WorkbasketPermission#READ} for the {@linkplain Workbasket} the {@linkplain Task} is in
*/ */
Task forceRequestChanges(String taskId) Task forceRequestChanges(String taskId)
throws InvalidTaskStateException, TaskNotFoundException, NotAuthorizedException, throws InvalidTaskStateException, TaskNotFoundException, InvalidOwnerException,
InvalidOwnerException; MismatchedWorkbasketPermissionException;
/** /**
* Complete a claimed {@linkplain Task} as {@linkplain Task#getOwner() owner} or {@linkplain * Complete a claimed {@linkplain Task} as {@linkplain Task#getOwner() owner} or {@linkplain
@ -303,18 +306,18 @@ public interface TaskService {
* @param taskId the {@linkplain Task#getId() id} of the {@linkplain Task} which should be * @param taskId the {@linkplain Task#getId() id} of the {@linkplain Task} which should be
* completed * completed
* @return the completed {@linkplain Task} * @return the completed {@linkplain Task}
* @throws InvalidStateException if the {@linkplain Task#getState() state} of the {@linkplain * @throws InvalidTaskStateException if the {@linkplain Task#getState() state} of the {@linkplain
* Task} with taskId is neither {@linkplain TaskState#CLAIMED} nor {@linkplain * Task} with taskId is neither {@linkplain TaskState#CLAIMED} nor {@linkplain
* TaskState#COMPLETED} * TaskState#COMPLETED}
* @throws TaskNotFoundException if the {@linkplain Task} with taskId wasn't found * @throws TaskNotFoundException if the {@linkplain Task} with taskId wasn't found
* @throws InvalidOwnerException if current user isn't the {@linkplain Task#getOwner() owner} of * @throws InvalidOwnerException if current user isn't the {@linkplain Task#getOwner() owner} of
* the {@linkplain Task} or {@linkplain TaskanaRole#ADMIN} * the {@linkplain Task} or {@linkplain TaskanaRole#ADMIN}
* @throws NotAuthorizedException if the current user has no {@linkplain * @throws MismatchedWorkbasketPermissionException if the current user has no {@linkplain
* WorkbasketPermission#READ} for the {@linkplain Workbasket} the {@linkplain Task} is in * WorkbasketPermission#READ} for the {@linkplain Workbasket} the {@linkplain Task} is in
*/ */
Task completeTask(String taskId) Task completeTask(String taskId)
throws TaskNotFoundException, InvalidOwnerException, InvalidStateException, throws TaskNotFoundException, InvalidOwnerException, MismatchedWorkbasketPermissionException,
NotAuthorizedException; InvalidTaskStateException;
/** /**
* Completes a {@linkplain Task} and updates {@linkplain Task#getState() state} and timestamps in * Completes a {@linkplain Task} and updates {@linkplain Task#getState() state} and timestamps in
@ -325,18 +328,18 @@ public interface TaskService {
* @param taskId the {@linkplain Task#getId() id} of the {@linkplain Task} which should be * @param taskId the {@linkplain Task#getId() id} of the {@linkplain Task} which should be
* completed * completed
* @return the updated {@linkplain Task} after completion * @return the updated {@linkplain Task} after completion
* @throws InvalidStateException if the {@linkplain Task#getState() state} of the {@linkplain * @throws InvalidTaskStateException if the {@linkplain Task#getState() state} of the {@linkplain
* Task} with taskId is with taskId is {@linkplain TaskState#TERMINATED} or {@linkplain * Task} with taskId is with taskId is {@linkplain TaskState#TERMINATED} or {@linkplain
* TaskState#CANCELLED} * TaskState#CANCELLED}
* @throws TaskNotFoundException if the {@linkplain Task} with taskId wasn't found * @throws TaskNotFoundException if the {@linkplain Task} with taskId wasn't found
* @throws InvalidOwnerException if current user isn't the {@linkplain Task#getOwner() owner} of * @throws InvalidOwnerException if current user isn't the {@linkplain Task#getOwner() owner} of
* the {@linkplain Task} or {@linkplain TaskanaRole#ADMIN} * the {@linkplain Task} or {@linkplain TaskanaRole#ADMIN}
* @throws NotAuthorizedException if the current user has no {@linkplain * @throws MismatchedWorkbasketPermissionException if the current user has no {@linkplain
* WorkbasketPermission#READ} for the {@linkplain Workbasket} the {@linkplain Task} is in * WorkbasketPermission#READ} for the {@linkplain Workbasket} the {@linkplain Task} is in
*/ */
Task forceCompleteTask(String taskId) Task forceCompleteTask(String taskId)
throws TaskNotFoundException, InvalidOwnerException, InvalidStateException, throws TaskNotFoundException, InvalidOwnerException, MismatchedWorkbasketPermissionException,
NotAuthorizedException; InvalidTaskStateException;
/** /**
* Completes a List of {@linkplain Task Tasks}. * Completes a List of {@linkplain Task Tasks}.
@ -376,13 +379,14 @@ public interface TaskService {
* @param taskId the {@linkplain Task#getId() id} of the {@linkplain Task} to cancel * @param taskId the {@linkplain Task#getId() id} of the {@linkplain Task} to cancel
* @return the updated {@linkplain Task} * @return the updated {@linkplain Task}
* @throws TaskNotFoundException if the {@linkplain Task} with taskId wasn't found * @throws TaskNotFoundException if the {@linkplain Task} with taskId wasn't found
* @throws InvalidStateException if the {@linkplain Task} isn't in {@linkplain TaskState#READY} or * @throws InvalidTaskStateException if the {@linkplain Task} isn't in {@linkplain
* {@linkplain TaskState#CLAIMED} * TaskState#READY} or {@linkplain TaskState#CLAIMED}
* @throws NotAuthorizedException if the current user has no {@linkplain * @throws MismatchedWorkbasketPermissionException if the current user has no {@linkplain
* WorkbasketPermission#READ} for the {@linkplain Workbasket} the {@linkplain Task} is in * WorkbasketPermission#READ} for the {@linkplain Workbasket} the {@linkplain Task} is in
*/ */
Task cancelTask(String taskId) Task cancelTask(String taskId)
throws TaskNotFoundException, InvalidStateException, NotAuthorizedException; throws TaskNotFoundException, MismatchedWorkbasketPermissionException,
InvalidTaskStateException;
/** /**
* Terminates a {@linkplain Task}. Termination is an administrative action to complete a * Terminates a {@linkplain Task}. Termination is an administrative action to complete a
@ -393,13 +397,16 @@ public interface TaskService {
* @param taskId the {@linkplain Task#getId() id} of the {@linkplain Task} to terminate * @param taskId the {@linkplain Task#getId() id} of the {@linkplain Task} to terminate
* @return the updated {@linkplain Task} * @return the updated {@linkplain Task}
* @throws TaskNotFoundException if the {@linkplain Task} with taskId wasn't found * @throws TaskNotFoundException if the {@linkplain Task} with taskId wasn't found
* @throws InvalidStateException if the {@linkplain Task} isn't in {@linkplain TaskState#READY} or * @throws InvalidTaskStateException if the {@linkplain Task} isn't in {@linkplain
* {@linkplain TaskState#CLAIMED} * TaskState#READY} or {@linkplain TaskState#CLAIMED}
* @throws NotAuthorizedException if the current user isn't member of {@linkplain * @throws MismatchedRoleException if the current user isn't member of {@linkplain
* TaskanaRole#ADMIN} or {@linkplain TaskanaRole#TASK_ADMIN} * TaskanaRole#ADMIN} or {@linkplain TaskanaRole#TASK_ADMIN}
* @throws MismatchedWorkbasketPermissionException If the current user doesn't have the correct
* permission
*/ */
Task terminateTask(String taskId) Task terminateTask(String taskId)
throws TaskNotFoundException, InvalidStateException, NotAuthorizedException; throws TaskNotFoundException, MismatchedRoleException,
MismatchedWorkbasketPermissionException, InvalidTaskStateException;
/** /**
* Transfers a {@linkplain Task} to another {@linkplain Workbasket} while always setting * Transfers a {@linkplain Task} to another {@linkplain Workbasket} while always setting
@ -409,8 +416,8 @@ public interface TaskService {
*/ */
@SuppressWarnings("checkstyle:JavadocMethod") @SuppressWarnings("checkstyle:JavadocMethod")
default Task transfer(String taskId, String destinationWorkbasketId) default Task transfer(String taskId, String destinationWorkbasketId)
throws TaskNotFoundException, WorkbasketNotFoundException, NotAuthorizedException, throws TaskNotFoundException, WorkbasketNotFoundException,
InvalidStateException { MismatchedWorkbasketPermissionException, InvalidTaskStateException {
return transfer(taskId, destinationWorkbasketId, true); return transfer(taskId, destinationWorkbasketId, true);
} }
@ -429,15 +436,15 @@ public interface TaskService {
* @return the transferred {@linkplain Task} * @return the transferred {@linkplain Task}
* @throws TaskNotFoundException if the {@linkplain Task} with taskId wasn't found * @throws TaskNotFoundException if the {@linkplain Task} with taskId wasn't found
* @throws WorkbasketNotFoundException if the target {@linkplain Workbasket} was not found * @throws WorkbasketNotFoundException if the target {@linkplain Workbasket} was not found
* @throws NotAuthorizedException if the current user has no {@linkplain * @throws MismatchedWorkbasketPermissionException if the current user has no {@linkplain
* WorkbasketPermission#READ} for the source {@linkplain Workbasket} or no {@linkplain * WorkbasketPermission#READ} for the source {@linkplain Workbasket} or no {@linkplain
* WorkbasketPermission#TRANSFER} for the target {@linkplain Workbasket} * WorkbasketPermission#TRANSFER} for the target {@linkplain Workbasket}
* @throws InvalidStateException if the {@linkplain Task} is in one of the {@linkplain * @throws InvalidTaskStateException if the {@linkplain Task} is in one of the {@linkplain
* TaskState#END_STATES} * TaskState#END_STATES}
*/ */
Task transfer(String taskId, String destinationWorkbasketId, boolean setTransferFlag) Task transfer(String taskId, String destinationWorkbasketId, boolean setTransferFlag)
throws TaskNotFoundException, WorkbasketNotFoundException, NotAuthorizedException, throws TaskNotFoundException, WorkbasketNotFoundException,
InvalidStateException; MismatchedWorkbasketPermissionException, InvalidTaskStateException;
/** /**
* Transfers a {@linkplain Task} to another {@linkplain Workbasket} while always setting * Transfers a {@linkplain Task} to another {@linkplain Workbasket} while always setting
@ -447,8 +454,8 @@ public interface TaskService {
*/ */
@SuppressWarnings("checkstyle:JavadocMethod") @SuppressWarnings("checkstyle:JavadocMethod")
default Task transfer(String taskId, String workbasketKey, String domain) default Task transfer(String taskId, String workbasketKey, String domain)
throws TaskNotFoundException, WorkbasketNotFoundException, NotAuthorizedException, throws TaskNotFoundException, WorkbasketNotFoundException,
InvalidStateException { MismatchedWorkbasketPermissionException, InvalidTaskStateException {
return transfer(taskId, workbasketKey, domain, true); return transfer(taskId, workbasketKey, domain, true);
} }
@ -469,15 +476,15 @@ public interface TaskService {
* @return the transferred {@linkplain Task} * @return the transferred {@linkplain Task}
* @throws TaskNotFoundException if the {@linkplain Task} with taskId was not found * @throws TaskNotFoundException if the {@linkplain Task} with taskId was not found
* @throws WorkbasketNotFoundException if the target {@linkplain Workbasket} was not found * @throws WorkbasketNotFoundException if the target {@linkplain Workbasket} was not found
* @throws NotAuthorizedException if the current user has no {@linkplain * @throws MismatchedWorkbasketPermissionException if the current user has no {@linkplain
* WorkbasketPermission#READ} for the source {@linkplain Workbasket} or no {@linkplain * WorkbasketPermission#READ} for the source {@linkplain Workbasket} or no {@linkplain
* WorkbasketPermission#TRANSFER} for the target {@linkplain Workbasket} * WorkbasketPermission#TRANSFER} for the target {@linkplain Workbasket}
* @throws InvalidStateException if the {@linkplain Task} is in one of the {@linkplain * @throws InvalidTaskStateException if the {@linkplain Task} is in one of the {@linkplain
* TaskState#END_STATES} * TaskState#END_STATES}
*/ */
Task transfer(String taskId, String workbasketKey, String domain, boolean setTransferFlag) Task transfer(String taskId, String workbasketKey, String domain, boolean setTransferFlag)
throws TaskNotFoundException, WorkbasketNotFoundException, NotAuthorizedException, throws TaskNotFoundException, WorkbasketNotFoundException,
InvalidStateException; MismatchedWorkbasketPermissionException, InvalidTaskStateException;
/** /**
* Transfers a List of {@linkplain Task Tasks} to another {@linkplain Workbasket} while always * Transfers a List of {@linkplain Task Tasks} to another {@linkplain Workbasket} while always
@ -488,7 +495,8 @@ public interface TaskService {
@SuppressWarnings("checkstyle:JavadocMethod") @SuppressWarnings("checkstyle:JavadocMethod")
default BulkOperationResults<String, TaskanaException> transferTasks( default BulkOperationResults<String, TaskanaException> transferTasks(
String destinationWorkbasketId, List<String> taskIds) String destinationWorkbasketId, List<String> taskIds)
throws NotAuthorizedException, InvalidArgumentException, WorkbasketNotFoundException { throws InvalidArgumentException, WorkbasketNotFoundException,
MismatchedWorkbasketPermissionException {
return transferTasks(destinationWorkbasketId, taskIds, true); return transferTasks(destinationWorkbasketId, taskIds, true);
} }
@ -506,7 +514,7 @@ public interface TaskService {
* @param setTransferFlag controls whether to set {@linkplain Task#isTransferred() isTransferred} * @param setTransferFlag controls whether to set {@linkplain Task#isTransferred() isTransferred}
* or not * or not
* @return Bulkresult with {@linkplain Task#getId() ids} and Error for each failed transactions * @return Bulkresult with {@linkplain Task#getId() ids} and Error for each failed transactions
* @throws NotAuthorizedException if the current user has no {@linkplain * @throws MismatchedWorkbasketPermissionException if the current user has no {@linkplain
* WorkbasketPermission#READ} for the source {@linkplain Workbasket} or no {@linkplain * WorkbasketPermission#READ} for the source {@linkplain Workbasket} or no {@linkplain
* WorkbasketPermission#TRANSFER} for the target {@linkplain Workbasket} * WorkbasketPermission#TRANSFER} for the target {@linkplain Workbasket}
* @throws InvalidArgumentException if the method parameters are empty or NULL * @throws InvalidArgumentException if the method parameters are empty or NULL
@ -514,7 +522,8 @@ public interface TaskService {
*/ */
BulkOperationResults<String, TaskanaException> transferTasks( BulkOperationResults<String, TaskanaException> transferTasks(
String destinationWorkbasketId, List<String> taskIds, boolean setTransferFlag) String destinationWorkbasketId, List<String> taskIds, boolean setTransferFlag)
throws NotAuthorizedException, InvalidArgumentException, WorkbasketNotFoundException; throws InvalidArgumentException, WorkbasketNotFoundException,
MismatchedWorkbasketPermissionException;
/** /**
* Transfers a List of {@linkplain Task Tasks} to another {@linkplain Workbasket} while always * Transfers a List of {@linkplain Task Tasks} to another {@linkplain Workbasket} while always
@ -525,7 +534,8 @@ public interface TaskService {
@SuppressWarnings("checkstyle:JavadocMethod") @SuppressWarnings("checkstyle:JavadocMethod")
default BulkOperationResults<String, TaskanaException> transferTasks( default BulkOperationResults<String, TaskanaException> transferTasks(
String destinationWorkbasketKey, String destinationWorkbasketDomain, List<String> taskIds) String destinationWorkbasketKey, String destinationWorkbasketDomain, List<String> taskIds)
throws NotAuthorizedException, InvalidArgumentException, WorkbasketNotFoundException { throws InvalidArgumentException, WorkbasketNotFoundException,
MismatchedWorkbasketPermissionException {
return transferTasks(destinationWorkbasketKey, destinationWorkbasketDomain, taskIds, true); return transferTasks(destinationWorkbasketKey, destinationWorkbasketDomain, taskIds, true);
} }
@ -544,7 +554,7 @@ public interface TaskService {
* @param setTransferFlag controls whether to set {@linkplain Task#isTransferred() isTransferred} * @param setTransferFlag controls whether to set {@linkplain Task#isTransferred() isTransferred}
* or not * or not
* @return BulkResult with {@linkplain Task#getId() ids} and Error for each failed transactions * @return BulkResult with {@linkplain Task#getId() ids} and Error for each failed transactions
* @throws NotAuthorizedException if the current user has no {@linkplain * @throws MismatchedWorkbasketPermissionException if the current user has no {@linkplain
* WorkbasketPermission#READ} for the source {@linkplain Workbasket} or no {@linkplain * WorkbasketPermission#READ} for the source {@linkplain Workbasket} or no {@linkplain
* WorkbasketPermission#TRANSFER} for the target {@linkplain Workbasket} * WorkbasketPermission#TRANSFER} for the target {@linkplain Workbasket}
* @throws InvalidArgumentException if the method parameters are empty or NULL * @throws InvalidArgumentException if the method parameters are empty or NULL
@ -555,7 +565,8 @@ public interface TaskService {
String destinationWorkbasketDomain, String destinationWorkbasketDomain,
List<String> taskIds, List<String> taskIds,
boolean setTransferFlag) boolean setTransferFlag)
throws NotAuthorizedException, InvalidArgumentException, WorkbasketNotFoundException; throws InvalidArgumentException, WorkbasketNotFoundException,
MismatchedWorkbasketPermissionException;
/** /**
* Update a {@linkplain Task}. * Update a {@linkplain Task}.
@ -573,7 +584,7 @@ public interface TaskService {
* @throws ClassificationNotFoundException if the {@linkplain Task#getClassificationSummary() * @throws ClassificationNotFoundException if the {@linkplain Task#getClassificationSummary()
* classificationSummary} of the updated {@linkplain Task} refers to a {@link Classification} * classificationSummary} of the updated {@linkplain Task} refers to a {@link Classification}
* that can't be found * that can't be found
* @throws NotAuthorizedException if the current user has no {@linkplain * @throws MismatchedWorkbasketPermissionException if the current user has no {@linkplain
* WorkbasketPermission#READ} for the {@linkplain Workbasket} the {@linkplain Task} is in * WorkbasketPermission#READ} for the {@linkplain Workbasket} the {@linkplain Task} is in
* @throws AttachmentPersistenceException if an {@linkplain Attachment} with the same {@linkplain * @throws AttachmentPersistenceException if an {@linkplain Attachment} with the same {@linkplain
* Attachment#getId() id} was added to the {@linkplain Task} multiple times without using * Attachment#getId() id} was added to the {@linkplain Task} multiple times without using
@ -581,14 +592,15 @@ public interface TaskService {
* @throws ObjectReferencePersistenceException if an {@linkplain ObjectReference} with the same * @throws ObjectReferencePersistenceException if an {@linkplain ObjectReference} with the same
* {@linkplain ObjectReference#getId() id} was added to the {@linkplain Task} multiple times * {@linkplain ObjectReference#getId() id} was added to the {@linkplain Task} multiple times
* without using {@linkplain Task#addSecondaryObjectReference(ObjectReference)} * without using {@linkplain Task#addSecondaryObjectReference(ObjectReference)}
* @throws InvalidStateException if an attempt is made to change the {@linkplain Task#getOwner() * @throws InvalidTaskStateException if an attempt is made to change the {@linkplain
* owner} of the {@linkplain Task} that {@linkplain Task#getState() state} isn't {@linkplain * Task#getOwner() owner} of the {@linkplain Task} that {@linkplain Task#getState() state}
* TaskState#READY} * isn't {@linkplain TaskState#READY}
*/ */
Task updateTask(Task task) Task updateTask(Task task)
throws InvalidArgumentException, TaskNotFoundException, ConcurrencyException, throws InvalidArgumentException, TaskNotFoundException, ConcurrencyException,
ClassificationNotFoundException, NotAuthorizedException, AttachmentPersistenceException, ClassificationNotFoundException, AttachmentPersistenceException,
ObjectReferencePersistenceException, InvalidStateException; ObjectReferencePersistenceException, MismatchedWorkbasketPermissionException,
InvalidTaskStateException;
/** /**
* Updates specified {@linkplain TaskCustomField TaskCustomFields} of {@linkplain Task Tasks} * Updates specified {@linkplain TaskCustomField TaskCustomFields} of {@linkplain Task Tasks}
@ -631,11 +643,11 @@ public interface TaskService {
* @param isRead the new status of {@linkplain Task#isRead() isRead} * @param isRead the new status of {@linkplain Task#isRead() isRead}
* @return the updated {@linkplain Task} * @return the updated {@linkplain Task}
* @throws TaskNotFoundException if the {@linkplain Task} with taskId wasn't found * @throws TaskNotFoundException if the {@linkplain Task} with taskId wasn't found
* @throws NotAuthorizedException if the current user has no {@linkplain * @throws MismatchedWorkbasketPermissionException if the current user has no {@linkplain
* WorkbasketPermission#READ} for the {@linkplain Workbasket} the {@linkplain Task} is in * WorkbasketPermission#READ} for the {@linkplain Workbasket} the {@linkplain Task} is in
*/ */
Task setTaskRead(String taskId, boolean isRead) Task setTaskRead(String taskId, boolean isRead)
throws TaskNotFoundException, NotAuthorizedException; throws TaskNotFoundException, MismatchedWorkbasketPermissionException;
/** /**
* Sets the specified {@linkplain CallbackState} on a List of {@linkplain Task Tasks}. * Sets the specified {@linkplain CallbackState} on a List of {@linkplain Task Tasks}.
@ -693,15 +705,21 @@ public interface TaskService {
* Deletes the {@linkplain Task} with the given {@linkplain Task#getId() id}. * Deletes the {@linkplain Task} with the given {@linkplain Task#getId() id}.
* *
* @param taskId The {@linkplain Task#getId() id} of the {@linkplain Task} to delete * @param taskId The {@linkplain Task#getId() id} of the {@linkplain Task} to delete
* @throws MismatchedWorkbasketPermissionException If the current user doesn't have correct
* permission
* @throws TaskNotFoundException If the given {@linkplain Task#getId() id} doesn't refer to an * @throws TaskNotFoundException If the given {@linkplain Task#getId() id} doesn't refer to an
* existing {@linkplain Task} * existing {@linkplain Task}
* @throws InvalidStateException If the {@linkplain Task#getState() state} of the referenced * @throws InvalidTaskStateException If the {@linkplain Task#getState() state} of the referenced
* {@linkplain Task} isn't one of the {@linkplain TaskState#END_STATES} * {@linkplain Task} isn't one of the {@linkplain TaskState#END_STATES}
* @throws NotAuthorizedException if the current user isn't member of {@linkplain * @throws MismatchedRoleException if the current user isn't member of {@linkplain
* TaskanaRole#ADMIN} * TaskanaRole#ADMIN}
* @throws InvalidCallbackStateException the Callback State of the Task is {@linkplain
* CallbackState#CALLBACK_PROCESSING_REQUIRED}
*/ */
void deleteTask(String taskId) void deleteTask(String taskId)
throws TaskNotFoundException, InvalidStateException, NotAuthorizedException; throws TaskNotFoundException, MismatchedRoleException,
MismatchedWorkbasketPermissionException, InvalidTaskStateException,
InvalidCallbackStateException;
/** /**
* Deletes the {@linkplain Task} with the given {@linkplain Task#getId() id} even if it isn't * Deletes the {@linkplain Task} with the given {@linkplain Task#getId() id} even if it isn't
@ -710,15 +728,20 @@ public interface TaskService {
* @param taskId The {@linkplain Task#getId() id} of the {@linkplain Task} to delete * @param taskId The {@linkplain Task#getId() id} of the {@linkplain Task} to delete
* @throws TaskNotFoundException if the given {@linkplain Task#getId() id} doesn't refer to an * @throws TaskNotFoundException if the given {@linkplain Task#getId() id} doesn't refer to an
* existing {@linkplain Task} * existing {@linkplain Task}
* @throws InvalidStateException if the {@linkplain Task#getState() state} of the referenced * @throws InvalidTaskStateException if the {@linkplain Task#getState() state} of the referenced
* {@linkplain Task} isn't {@linkplain TaskState#TERMINATED} or {@linkplain * {@linkplain Task} isn't {@linkplain TaskState#TERMINATED} or {@linkplain
* TaskState#CANCELLED} and the Callback State of the Task is {@linkplain * TaskState#CANCELLED}
* CallbackState#CALLBACK_PROCESSING_REQUIRED} * @throws MismatchedWorkbasketPermissionException If the current user doesn't have correct
* @throws NotAuthorizedException if the current user isn't member of {@linkplain * permissions
* @throws MismatchedRoleException if the current user isn't member of {@linkplain
* TaskanaRole#ADMIN} * TaskanaRole#ADMIN}
* @throws InvalidCallbackStateException the Callback State of the Task is {@linkplain
* CallbackState#CALLBACK_PROCESSING_REQUIRED}
*/ */
void forceDeleteTask(String taskId) void forceDeleteTask(String taskId)
throws TaskNotFoundException, InvalidStateException, NotAuthorizedException; throws TaskNotFoundException, MismatchedRoleException,
MismatchedWorkbasketPermissionException, InvalidTaskStateException,
InvalidCallbackStateException;
/** /**
* Deletes a List of {@linkplain Task Tasks}. * Deletes a List of {@linkplain Task Tasks}.
@ -727,11 +750,11 @@ public interface TaskService {
* @return the result of the operations with each {@linkplain Task#getId() id} and Exception for * @return the result of the operations with each {@linkplain Task#getId() id} and Exception for
* each failed deletion * each failed deletion
* @throws InvalidArgumentException if the tasks parameter contains NULL values * @throws InvalidArgumentException if the tasks parameter contains NULL values
* @throws NotAuthorizedException if the current user isn't member of {@linkplain * @throws MismatchedRoleException if the current user isn't member of {@linkplain
* TaskanaRole#ADMIN} * TaskanaRole#ADMIN}
*/ */
BulkOperationResults<String, TaskanaException> deleteTasks(List<String> tasks) BulkOperationResults<String, TaskanaException> deleteTasks(List<String> tasks)
throws InvalidArgumentException, NotAuthorizedException; throws InvalidArgumentException, MismatchedRoleException;
// endregion // endregion
@ -754,7 +777,7 @@ public interface TaskService {
* *
* @param taskComment the {@linkplain TaskComment} to be created * @param taskComment the {@linkplain TaskComment} to be created
* @return the created {@linkplain TaskComment} * @return the created {@linkplain TaskComment}
* @throws NotAuthorizedException if the current user has no {@linkplain * @throws MismatchedWorkbasketPermissionException if the current user has no {@linkplain
* WorkbasketPermission#READ} for the {@linkplain Workbasket} of the commented {@linkplain * WorkbasketPermission#READ} for the {@linkplain Workbasket} of the commented {@linkplain
* Task}. * Task}.
* @throws TaskNotFoundException if the given {@linkplain TaskComment#getTaskId() taskId} doesn't * @throws TaskNotFoundException if the given {@linkplain TaskComment#getTaskId() taskId} doesn't
@ -763,7 +786,8 @@ public interface TaskService {
* {@link TaskComment} is neither NULL nor empty * {@link TaskComment} is neither NULL nor empty
*/ */
TaskComment createTaskComment(TaskComment taskComment) TaskComment createTaskComment(TaskComment taskComment)
throws NotAuthorizedException, TaskNotFoundException, InvalidArgumentException; throws TaskNotFoundException, InvalidArgumentException,
MismatchedWorkbasketPermissionException;
// endregion // endregion
@ -777,7 +801,7 @@ public interface TaskService {
* @return the {@linkplain TaskComment} identified by taskCommentId * @return the {@linkplain TaskComment} identified by taskCommentId
* @throws TaskCommentNotFoundException if the given taskCommentId doesn't refer to an existing * @throws TaskCommentNotFoundException if the given taskCommentId doesn't refer to an existing
* {@linkplain TaskComment} * {@linkplain TaskComment}
* @throws NotAuthorizedException if the current user has no {@linkplain * @throws MismatchedWorkbasketPermissionException if the current user has no {@linkplain
* WorkbasketPermission#READ} for the {@linkplain Workbasket} of the commented {@linkplain * WorkbasketPermission#READ} for the {@linkplain Workbasket} of the commented {@linkplain
* Task} * Task}
* @throws TaskNotFoundException if the {@linkplain TaskComment#getTaskId() taskId} of the * @throws TaskNotFoundException if the {@linkplain TaskComment#getTaskId() taskId} of the
@ -785,8 +809,8 @@ public interface TaskService {
* @throws InvalidArgumentException if the given taskCommentId is NULL or empty * @throws InvalidArgumentException if the given taskCommentId is NULL or empty
*/ */
TaskComment getTaskComment(String taskCommentId) TaskComment getTaskComment(String taskCommentId)
throws TaskCommentNotFoundException, NotAuthorizedException, TaskNotFoundException, throws TaskCommentNotFoundException, TaskNotFoundException, InvalidArgumentException,
InvalidArgumentException; MismatchedWorkbasketPermissionException;
/** /**
* Retrieves the List of {@linkplain TaskComment TaskComments} for the {@linkplain Task} with * Retrieves the List of {@linkplain TaskComment TaskComments} for the {@linkplain Task} with
@ -796,14 +820,14 @@ public interface TaskService {
* {@linkplain TaskComment TaskComments} should be retrieved * {@linkplain TaskComment TaskComments} should be retrieved
* @return the List of {@linkplain TaskComment TaskComments} attached to the specified {@linkplain * @return the List of {@linkplain TaskComment TaskComments} attached to the specified {@linkplain
* Task} * Task}
* @throws NotAuthorizedException if the current user has no {@linkplain * @throws MismatchedWorkbasketPermissionException if the current user has no {@linkplain
* WorkbasketPermission#READ} for the {@linkplain Workbasket} of the commented {@linkplain * WorkbasketPermission#READ} for the {@linkplain Workbasket} of the commented {@linkplain
* Task} * Task}
* @throws TaskNotFoundException if the given taskId doesn't refer to an existing {@linkplain * @throws TaskNotFoundException if the given taskId doesn't refer to an existing {@linkplain
* Task} * Task}
*/ */
List<TaskComment> getTaskComments(String taskId) List<TaskComment> getTaskComments(String taskId)
throws NotAuthorizedException, TaskNotFoundException; throws TaskNotFoundException, MismatchedWorkbasketPermissionException;
// endregion // endregion
@ -814,7 +838,7 @@ public interface TaskService {
* *
* @param taskComment the {@linkplain TaskComment} to be updated in the database * @param taskComment the {@linkplain TaskComment} to be updated in the database
* @return the updated {@linkplain TaskComment} * @return the updated {@linkplain TaskComment}
* @throws NotAuthorizedException if the current user has no {@linkplain * @throws MismatchedWorkbasketPermissionException if the current user has no {@linkplain
* WorkbasketPermission#READ} for the {@linkplain Workbasket} of the commented {@linkplain * WorkbasketPermission#READ} for the {@linkplain Workbasket} of the commented {@linkplain
* Task}. * Task}.
* @throws ConcurrencyException if an attempt is made to update the {@linkplain TaskComment} and * @throws ConcurrencyException if an attempt is made to update the {@linkplain TaskComment} and
@ -826,10 +850,13 @@ public interface TaskService {
* to an existing {@linkplain Task} * to an existing {@linkplain Task}
* @throws InvalidArgumentException if the {@linkplain TaskComment#getId() id} of the specified * @throws InvalidArgumentException if the {@linkplain TaskComment#getId() id} of the specified
* {@linkplain TaskComment} is NULL or empty * {@linkplain TaskComment} is NULL or empty
* @throws MismatchedTaskCommentCreatorException If the current user doesn't have correct
* permissions
*/ */
TaskComment updateTaskComment(TaskComment taskComment) TaskComment updateTaskComment(TaskComment taskComment)
throws NotAuthorizedException, ConcurrencyException, TaskCommentNotFoundException, throws ConcurrencyException, TaskCommentNotFoundException, TaskNotFoundException,
TaskNotFoundException, InvalidArgumentException; InvalidArgumentException, MismatchedTaskCommentCreatorException,
MismatchedWorkbasketPermissionException;
// endregion // endregion
@ -840,20 +867,21 @@ public interface TaskService {
* *
* @param taskCommentId the {@linkplain TaskComment#getId() id} of the {@linkplain TaskComment} to * @param taskCommentId the {@linkplain TaskComment#getId() id} of the {@linkplain TaskComment} to
* delete * delete
* @throws NotAuthorizedException if the current user isn't {@linkplain TaskanaRole#ADMIN},
* {@linkplain TaskanaRole#TASK_ADMIN} or the {@linkplain TaskComment#getCreator() creator} of
* the {@linkplain TaskComment}; the user also needs {@linkplain WorkbasketPermission#READ}
* for the {@linkplain Workbasket} of the commented {@linkplain Task}
* @throws InvalidArgumentException if the taskCommentId is NULL or empty * @throws InvalidArgumentException if the taskCommentId is NULL or empty
* @throws TaskCommentNotFoundException if the given taskCommentId doesn't refer to an existing * @throws TaskCommentNotFoundException if the given taskCommentId doesn't refer to an existing
* {@linkplain TaskComment} * {@linkplain TaskComment}
* @throws TaskNotFoundException if the {@linkplain TaskComment#getTaskId() taskId} of the * @throws TaskNotFoundException if the {@linkplain TaskComment#getTaskId() taskId} of the
* TaskComment doesn't refer to an existing {@linkplain Task} * TaskComment doesn't refer to an existing {@linkplain Task}
* @throws InvalidArgumentException if the given taskCommentId is NULL or empty * @throws InvalidArgumentException if the given taskCommentId is NULL or empty
* @throws MismatchedWorkbasketPermissionException if the current user has no {@linkplain
* WorkbasketPermission#READ} for the {@linkplain Workbasket} the commented {@linkplain Task}
* is in
* @throws MismatchedTaskCommentCreatorException if the current user is not the {@linkplain
* TaskComment#getCreator() creator} of the {@linkplain TaskComment}.
*/ */
void deleteTaskComment(String taskCommentId) void deleteTaskComment(String taskCommentId)
throws NotAuthorizedException, TaskCommentNotFoundException, TaskNotFoundException, throws TaskCommentNotFoundException, TaskNotFoundException, InvalidArgumentException,
InvalidArgumentException; MismatchedTaskCommentCreatorException, MismatchedWorkbasketPermissionException;
// endregion // endregion

View File

@ -3,6 +3,7 @@ package pro.taskana.task.api.exceptions;
import java.util.Arrays; import java.util.Arrays;
import pro.taskana.common.api.exceptions.ErrorCode; import pro.taskana.common.api.exceptions.ErrorCode;
import pro.taskana.common.api.exceptions.TaskanaException;
import pro.taskana.common.internal.util.MapCreator; import pro.taskana.common.internal.util.MapCreator;
import pro.taskana.task.api.CallbackState; import pro.taskana.task.api.CallbackState;
import pro.taskana.task.api.models.Task; import pro.taskana.task.api.models.Task;
@ -12,7 +13,7 @@ import pro.taskana.task.internal.models.MinimalTaskSummary;
* This exception is thrown when the {@linkplain MinimalTaskSummary#getCallbackState() callback * This exception is thrown when the {@linkplain MinimalTaskSummary#getCallbackState() callback
* state} of the {@linkplain Task} doesn't allow the requested operation. * state} of the {@linkplain Task} doesn't allow the requested operation.
*/ */
public class InvalidCallbackStateException extends InvalidStateException { public class InvalidCallbackStateException extends TaskanaException {
public static final String ERROR_KEY = "TASK_INVALID_CALLBACK_STATE"; public static final String ERROR_KEY = "TASK_INVALID_CALLBACK_STATE";
private final String taskId; private final String taskId;

View File

@ -1,12 +0,0 @@
package pro.taskana.task.api.exceptions;
import pro.taskana.common.api.exceptions.ErrorCode;
import pro.taskana.common.api.exceptions.TaskanaException;
/** This exception is thrown when the current state doesn't allow the requested operation. */
public class InvalidStateException extends TaskanaException {
protected InvalidStateException(String msg, ErrorCode errorCode) {
super(msg, errorCode);
}
}

View File

@ -3,6 +3,7 @@ package pro.taskana.task.api.exceptions;
import java.util.Arrays; import java.util.Arrays;
import pro.taskana.common.api.exceptions.ErrorCode; import pro.taskana.common.api.exceptions.ErrorCode;
import pro.taskana.common.api.exceptions.TaskanaException;
import pro.taskana.common.internal.util.MapCreator; import pro.taskana.common.internal.util.MapCreator;
import pro.taskana.task.api.TaskState; import pro.taskana.task.api.TaskState;
import pro.taskana.task.api.models.Task; import pro.taskana.task.api.models.Task;
@ -11,7 +12,7 @@ import pro.taskana.task.api.models.Task;
* This exception is thrown when the {@linkplain Task#getState() state} of the {@linkplain Task} * This exception is thrown when the {@linkplain Task#getState() state} of the {@linkplain Task}
* doesn't allow the requested operation. * doesn't allow the requested operation.
*/ */
public class InvalidTaskStateException extends InvalidStateException { public class InvalidTaskStateException extends TaskanaException {
public static final String ERROR_KEY = "TASK_INVALID_STATE"; public static final String ERROR_KEY = "TASK_INVALID_STATE";
private final String taskId; private final String taskId;

View File

@ -1,7 +1,7 @@
package pro.taskana.task.api.exceptions; package pro.taskana.task.api.exceptions;
import pro.taskana.common.api.exceptions.ErrorCode; import pro.taskana.common.api.exceptions.ErrorCode;
import pro.taskana.common.api.exceptions.NotAuthorizedException; import pro.taskana.common.api.exceptions.TaskanaException;
import pro.taskana.common.internal.util.MapCreator; import pro.taskana.common.internal.util.MapCreator;
import pro.taskana.task.api.models.TaskComment; import pro.taskana.task.api.models.TaskComment;
@ -9,7 +9,7 @@ import pro.taskana.task.api.models.TaskComment;
* This exception is thrown when the current user is not the creator of the {@linkplain TaskComment} * This exception is thrown when the current user is not the creator of the {@linkplain TaskComment}
* it tries to modify. * it tries to modify.
*/ */
public class MismatchedTaskCommentCreatorException extends NotAuthorizedException { public class MismatchedTaskCommentCreatorException extends TaskanaException {
public static final String ERROR_KEY = "TASK_COMMENT_CREATOR_MISMATCHED"; public static final String ERROR_KEY = "TASK_COMMENT_CREATOR_MISMATCHED";
private final String currentUserId; private final String currentUserId;

View File

@ -1,12 +1,12 @@
package pro.taskana.task.api.exceptions; package pro.taskana.task.api.exceptions;
import pro.taskana.common.api.exceptions.ErrorCode; import pro.taskana.common.api.exceptions.ErrorCode;
import pro.taskana.common.api.exceptions.NotFoundException; import pro.taskana.common.api.exceptions.TaskanaException;
import pro.taskana.common.internal.util.MapCreator; import pro.taskana.common.internal.util.MapCreator;
import pro.taskana.task.api.models.TaskComment; import pro.taskana.task.api.models.TaskComment;
/** This exception is thrown when a specific {@linkplain TaskComment} is not in the database. */ /** This exception is thrown when a specific {@linkplain TaskComment} is not in the database. */
public class TaskCommentNotFoundException extends NotFoundException { public class TaskCommentNotFoundException extends TaskanaException {
public static final String ERROR_KEY = "TASK_COMMENT_NOT_FOUND"; public static final String ERROR_KEY = "TASK_COMMENT_NOT_FOUND";
private final String taskCommentId; private final String taskCommentId;

View File

@ -1,12 +1,12 @@
package pro.taskana.task.api.exceptions; package pro.taskana.task.api.exceptions;
import pro.taskana.common.api.exceptions.ErrorCode; import pro.taskana.common.api.exceptions.ErrorCode;
import pro.taskana.common.api.exceptions.NotFoundException; import pro.taskana.common.api.exceptions.TaskanaException;
import pro.taskana.common.internal.util.MapCreator; import pro.taskana.common.internal.util.MapCreator;
import pro.taskana.task.api.models.Task; import pro.taskana.task.api.models.Task;
/** This exception is thrown when a specific {@linkplain Task} is not in the database. */ /** This exception is thrown when a specific {@linkplain Task} is not in the database. */
public class TaskNotFoundException extends NotFoundException { public class TaskNotFoundException extends TaskanaException {
public static final String ERROR_KEY = "TASK_NOT_FOUND"; public static final String ERROR_KEY = "TASK_NOT_FOUND";
private final String taskId; private final String taskId;

View File

@ -9,12 +9,12 @@ import org.slf4j.LoggerFactory;
import pro.taskana.common.api.TaskanaRole; import pro.taskana.common.api.TaskanaRole;
import pro.taskana.common.api.TimeInterval; import pro.taskana.common.api.TimeInterval;
import pro.taskana.common.api.exceptions.NotAuthorizedException;
import pro.taskana.common.internal.InternalTaskanaEngine; import pro.taskana.common.internal.InternalTaskanaEngine;
import pro.taskana.task.api.TaskCommentQuery; import pro.taskana.task.api.TaskCommentQuery;
import pro.taskana.task.api.TaskCommentQueryColumnName; import pro.taskana.task.api.TaskCommentQueryColumnName;
import pro.taskana.task.api.exceptions.TaskNotFoundException; import pro.taskana.task.api.exceptions.TaskNotFoundException;
import pro.taskana.task.api.models.TaskComment; import pro.taskana.task.api.models.TaskComment;
import pro.taskana.workbasket.api.exceptions.MismatchedWorkbasketPermissionException;
import pro.taskana.workbasket.api.exceptions.NotAuthorizedToQueryWorkbasketException; import pro.taskana.workbasket.api.exceptions.NotAuthorizedToQueryWorkbasketException;
import pro.taskana.workbasket.internal.WorkbasketQueryImpl; import pro.taskana.workbasket.internal.WorkbasketQueryImpl;
@ -307,7 +307,7 @@ public class TaskCommentQueryImpl implements TaskCommentQuery {
taskId -> { taskId -> {
try { try {
taskService.getTask(taskId); taskService.getTask(taskId);
} catch (NotAuthorizedException e) { } catch (MismatchedWorkbasketPermissionException e) {
throw new NotAuthorizedToQueryWorkbasketException( throw new NotAuthorizedToQueryWorkbasketException(
e.getMessage(), e.getErrorCode(), e); e.getMessage(), e.getErrorCode(), e);
} catch (TaskNotFoundException e) { } catch (TaskNotFoundException e) {

View File

@ -8,7 +8,6 @@ import org.slf4j.LoggerFactory;
import pro.taskana.common.api.TaskanaRole; import pro.taskana.common.api.TaskanaRole;
import pro.taskana.common.api.exceptions.ConcurrencyException; import pro.taskana.common.api.exceptions.ConcurrencyException;
import pro.taskana.common.api.exceptions.InvalidArgumentException; import pro.taskana.common.api.exceptions.InvalidArgumentException;
import pro.taskana.common.api.exceptions.NotAuthorizedException;
import pro.taskana.common.api.exceptions.SystemException; import pro.taskana.common.api.exceptions.SystemException;
import pro.taskana.common.internal.InternalTaskanaEngine; import pro.taskana.common.internal.InternalTaskanaEngine;
import pro.taskana.common.internal.util.IdGenerator; import pro.taskana.common.internal.util.IdGenerator;
@ -19,6 +18,7 @@ import pro.taskana.task.api.models.TaskComment;
import pro.taskana.task.internal.models.TaskCommentImpl; import pro.taskana.task.internal.models.TaskCommentImpl;
import pro.taskana.user.api.models.User; import pro.taskana.user.api.models.User;
import pro.taskana.user.internal.UserMapper; import pro.taskana.user.internal.UserMapper;
import pro.taskana.workbasket.api.exceptions.MismatchedWorkbasketPermissionException;
class TaskCommentServiceImpl { class TaskCommentServiceImpl {
@ -49,8 +49,9 @@ class TaskCommentServiceImpl {
} }
TaskComment updateTaskComment(TaskComment taskCommentToUpdate) TaskComment updateTaskComment(TaskComment taskCommentToUpdate)
throws NotAuthorizedException, ConcurrencyException, TaskCommentNotFoundException, throws ConcurrencyException, TaskCommentNotFoundException, TaskNotFoundException,
TaskNotFoundException, InvalidArgumentException { InvalidArgumentException, MismatchedTaskCommentCreatorException,
MismatchedWorkbasketPermissionException {
String userId = taskanaEngine.getEngine().getCurrentUserContext().getUserid(); String userId = taskanaEngine.getEngine().getCurrentUserContext().getUserid();
@ -91,7 +92,8 @@ class TaskCommentServiceImpl {
} }
TaskComment createTaskComment(TaskComment taskCommentToCreate) TaskComment createTaskComment(TaskComment taskCommentToCreate)
throws NotAuthorizedException, TaskNotFoundException, InvalidArgumentException { throws TaskNotFoundException, InvalidArgumentException,
MismatchedWorkbasketPermissionException {
TaskCommentImpl taskCommentImplToCreate = (TaskCommentImpl) taskCommentToCreate; TaskCommentImpl taskCommentImplToCreate = (TaskCommentImpl) taskCommentToCreate;
@ -115,8 +117,8 @@ class TaskCommentServiceImpl {
} }
void deleteTaskComment(String taskCommentId) void deleteTaskComment(String taskCommentId)
throws NotAuthorizedException, TaskCommentNotFoundException, TaskNotFoundException, throws TaskCommentNotFoundException, TaskNotFoundException, InvalidArgumentException,
InvalidArgumentException { MismatchedTaskCommentCreatorException, MismatchedWorkbasketPermissionException {
String userId = taskanaEngine.getEngine().getCurrentUserContext().getUserid(); String userId = taskanaEngine.getEngine().getCurrentUserContext().getUserid();
@ -146,7 +148,7 @@ class TaskCommentServiceImpl {
} }
List<TaskComment> getTaskComments(String taskId) List<TaskComment> getTaskComments(String taskId)
throws NotAuthorizedException, TaskNotFoundException { throws TaskNotFoundException, MismatchedWorkbasketPermissionException {
try { try {
@ -168,8 +170,8 @@ class TaskCommentServiceImpl {
} }
TaskComment getTaskComment(String taskCommentId) TaskComment getTaskComment(String taskCommentId)
throws TaskCommentNotFoundException, NotAuthorizedException, TaskNotFoundException, throws TaskCommentNotFoundException, TaskNotFoundException, InvalidArgumentException,
InvalidArgumentException { MismatchedWorkbasketPermissionException {
TaskCommentImpl result; TaskCommentImpl result;

View File

@ -13,7 +13,6 @@ import pro.taskana.common.api.KeyDomain;
import pro.taskana.common.api.TaskanaRole; import pro.taskana.common.api.TaskanaRole;
import pro.taskana.common.api.TimeInterval; import pro.taskana.common.api.TimeInterval;
import pro.taskana.common.api.exceptions.InvalidArgumentException; import pro.taskana.common.api.exceptions.InvalidArgumentException;
import pro.taskana.common.api.exceptions.NotAuthorizedException;
import pro.taskana.common.api.exceptions.SystemException; import pro.taskana.common.api.exceptions.SystemException;
import pro.taskana.common.api.exceptions.TaskanaRuntimeException; import pro.taskana.common.api.exceptions.TaskanaRuntimeException;
import pro.taskana.common.internal.InternalTaskanaEngine; import pro.taskana.common.internal.InternalTaskanaEngine;
@ -30,6 +29,7 @@ import pro.taskana.task.api.models.ObjectReference;
import pro.taskana.task.api.models.TaskSummary; import pro.taskana.task.api.models.TaskSummary;
import pro.taskana.task.internal.models.TaskSummaryImpl; import pro.taskana.task.internal.models.TaskSummaryImpl;
import pro.taskana.workbasket.api.WorkbasketPermission; import pro.taskana.workbasket.api.WorkbasketPermission;
import pro.taskana.workbasket.api.exceptions.MismatchedWorkbasketPermissionException;
import pro.taskana.workbasket.api.exceptions.NotAuthorizedToQueryWorkbasketException; import pro.taskana.workbasket.api.exceptions.NotAuthorizedToQueryWorkbasketException;
import pro.taskana.workbasket.api.exceptions.WorkbasketNotFoundException; import pro.taskana.workbasket.api.exceptions.WorkbasketNotFoundException;
import pro.taskana.workbasket.internal.WorkbasketQueryImpl; import pro.taskana.workbasket.internal.WorkbasketQueryImpl;
@ -2197,12 +2197,13 @@ public class TaskQueryImpl implements TaskQuery {
checkOpenAndReadPermissionByKeyDomain(keyDomain); checkOpenAndReadPermissionByKeyDomain(keyDomain);
} }
} }
} catch (NotAuthorizedException e) { } catch (MismatchedWorkbasketPermissionException e) {
throw new NotAuthorizedToQueryWorkbasketException(e.getMessage(), e.getErrorCode(), e); throw new NotAuthorizedToQueryWorkbasketException(e.getMessage(), e.getErrorCode(), e);
} }
} }
private void checkOpenAndReadPermissionById(String workbasketId) throws NotAuthorizedException { private void checkOpenAndReadPermissionById(String workbasketId)
throws MismatchedWorkbasketPermissionException {
try { try {
taskanaEngine taskanaEngine
.getEngine() .getEngine()
@ -2215,7 +2216,7 @@ public class TaskQueryImpl implements TaskQuery {
} }
private void checkOpenAndReadPermissionByKeyDomain(KeyDomain keyDomain) private void checkOpenAndReadPermissionByKeyDomain(KeyDomain keyDomain)
throws NotAuthorizedException { throws MismatchedWorkbasketPermissionException {
try { try {
taskanaEngine taskanaEngine
.getEngine() .getEngine()

View File

@ -32,7 +32,7 @@ import pro.taskana.common.api.BulkOperationResults;
import pro.taskana.common.api.TaskanaRole; import pro.taskana.common.api.TaskanaRole;
import pro.taskana.common.api.exceptions.ConcurrencyException; import pro.taskana.common.api.exceptions.ConcurrencyException;
import pro.taskana.common.api.exceptions.InvalidArgumentException; import pro.taskana.common.api.exceptions.InvalidArgumentException;
import pro.taskana.common.api.exceptions.NotAuthorizedException; import pro.taskana.common.api.exceptions.MismatchedRoleException;
import pro.taskana.common.api.exceptions.SystemException; import pro.taskana.common.api.exceptions.SystemException;
import pro.taskana.common.api.exceptions.TaskanaException; import pro.taskana.common.api.exceptions.TaskanaException;
import pro.taskana.common.internal.InternalTaskanaEngine; import pro.taskana.common.internal.InternalTaskanaEngine;
@ -68,8 +68,8 @@ import pro.taskana.task.api.TaskState;
import pro.taskana.task.api.exceptions.AttachmentPersistenceException; import pro.taskana.task.api.exceptions.AttachmentPersistenceException;
import pro.taskana.task.api.exceptions.InvalidCallbackStateException; import pro.taskana.task.api.exceptions.InvalidCallbackStateException;
import pro.taskana.task.api.exceptions.InvalidOwnerException; import pro.taskana.task.api.exceptions.InvalidOwnerException;
import pro.taskana.task.api.exceptions.InvalidStateException;
import pro.taskana.task.api.exceptions.InvalidTaskStateException; import pro.taskana.task.api.exceptions.InvalidTaskStateException;
import pro.taskana.task.api.exceptions.MismatchedTaskCommentCreatorException;
import pro.taskana.task.api.exceptions.ObjectReferencePersistenceException; import pro.taskana.task.api.exceptions.ObjectReferencePersistenceException;
import pro.taskana.task.api.exceptions.TaskAlreadyExistException; import pro.taskana.task.api.exceptions.TaskAlreadyExistException;
import pro.taskana.task.api.exceptions.TaskCommentNotFoundException; import pro.taskana.task.api.exceptions.TaskCommentNotFoundException;
@ -158,79 +158,79 @@ public class TaskServiceImpl implements TaskService {
@Override @Override
public Task claim(String taskId) public Task claim(String taskId)
throws TaskNotFoundException, InvalidStateException, InvalidOwnerException, throws TaskNotFoundException, InvalidOwnerException, MismatchedWorkbasketPermissionException,
NotAuthorizedException { InvalidTaskStateException {
return claim(taskId, false); return claim(taskId, false);
} }
@Override @Override
public Task forceClaim(String taskId) public Task forceClaim(String taskId)
throws TaskNotFoundException, InvalidStateException, InvalidOwnerException, throws TaskNotFoundException, InvalidOwnerException, MismatchedWorkbasketPermissionException,
NotAuthorizedException { InvalidTaskStateException {
return claim(taskId, true); return claim(taskId, true);
} }
@Override @Override
public Task cancelClaim(String taskId) public Task cancelClaim(String taskId)
throws TaskNotFoundException, InvalidStateException, InvalidOwnerException, throws TaskNotFoundException, InvalidOwnerException, MismatchedWorkbasketPermissionException,
NotAuthorizedException { InvalidTaskStateException {
return this.cancelClaim(taskId, false); return this.cancelClaim(taskId, false);
} }
@Override @Override
public Task forceCancelClaim(String taskId) public Task forceCancelClaim(String taskId)
throws TaskNotFoundException, InvalidStateException, InvalidOwnerException, throws TaskNotFoundException, InvalidOwnerException, MismatchedWorkbasketPermissionException,
NotAuthorizedException { InvalidTaskStateException {
return this.cancelClaim(taskId, true); return this.cancelClaim(taskId, true);
} }
@Override @Override
public Task requestReview(String taskId) public Task requestReview(String taskId)
throws InvalidTaskStateException, TaskNotFoundException, NotAuthorizedException, throws InvalidTaskStateException, TaskNotFoundException, InvalidOwnerException,
InvalidOwnerException { MismatchedWorkbasketPermissionException {
return requestReview(taskId, false); return requestReview(taskId, false);
} }
@Override @Override
public Task forceRequestReview(String taskId) public Task forceRequestReview(String taskId)
throws InvalidTaskStateException, TaskNotFoundException, NotAuthorizedException, throws InvalidTaskStateException, TaskNotFoundException, InvalidOwnerException,
InvalidOwnerException { MismatchedWorkbasketPermissionException {
return requestReview(taskId, true); return requestReview(taskId, true);
} }
@Override @Override
public Task requestChanges(String taskId) public Task requestChanges(String taskId)
throws InvalidTaskStateException, TaskNotFoundException, NotAuthorizedException, throws InvalidTaskStateException, TaskNotFoundException, InvalidOwnerException,
InvalidOwnerException { MismatchedWorkbasketPermissionException {
return requestChanges(taskId, false); return requestChanges(taskId, false);
} }
@Override @Override
public Task forceRequestChanges(String taskId) public Task forceRequestChanges(String taskId)
throws InvalidTaskStateException, TaskNotFoundException, NotAuthorizedException, throws InvalidTaskStateException, TaskNotFoundException, InvalidOwnerException,
InvalidOwnerException { MismatchedWorkbasketPermissionException {
return requestChanges(taskId, true); return requestChanges(taskId, true);
} }
@Override @Override
public Task completeTask(String taskId) public Task completeTask(String taskId)
throws TaskNotFoundException, InvalidOwnerException, InvalidStateException, throws TaskNotFoundException, InvalidOwnerException, MismatchedWorkbasketPermissionException,
NotAuthorizedException { InvalidTaskStateException {
return completeTask(taskId, false); return completeTask(taskId, false);
} }
@Override @Override
public Task forceCompleteTask(String taskId) public Task forceCompleteTask(String taskId)
throws TaskNotFoundException, InvalidOwnerException, InvalidStateException, throws TaskNotFoundException, InvalidOwnerException, MismatchedWorkbasketPermissionException,
NotAuthorizedException { InvalidTaskStateException {
return completeTask(taskId, true); return completeTask(taskId, true);
} }
@Override @Override
public Task createTask(Task taskToCreate) public Task createTask(Task taskToCreate)
throws NotAuthorizedException, WorkbasketNotFoundException, ClassificationNotFoundException, throws WorkbasketNotFoundException, ClassificationNotFoundException,
TaskAlreadyExistException, InvalidArgumentException, AttachmentPersistenceException, TaskAlreadyExistException, InvalidArgumentException, AttachmentPersistenceException,
ObjectReferencePersistenceException { ObjectReferencePersistenceException, MismatchedWorkbasketPermissionException {
if (createTaskPreprocessorManager.isEnabled()) { if (createTaskPreprocessorManager.isEnabled()) {
taskToCreate = createTaskPreprocessorManager.processTaskBeforeCreation(taskToCreate); taskToCreate = createTaskPreprocessorManager.processTaskBeforeCreation(taskToCreate);
@ -348,7 +348,8 @@ public class TaskServiceImpl implements TaskService {
} }
@Override @Override
public Task getTask(String id) throws NotAuthorizedException, TaskNotFoundException { public Task getTask(String id)
throws MismatchedWorkbasketPermissionException, TaskNotFoundException {
try { try {
taskanaEngine.openConnection(); taskanaEngine.openConnection();
@ -410,21 +411,21 @@ public class TaskServiceImpl implements TaskService {
@Override @Override
public Task transfer(String taskId, String destinationWorkbasketId, boolean setTransferFlag) public Task transfer(String taskId, String destinationWorkbasketId, boolean setTransferFlag)
throws TaskNotFoundException, WorkbasketNotFoundException, NotAuthorizedException, throws TaskNotFoundException, WorkbasketNotFoundException,
InvalidStateException { MismatchedWorkbasketPermissionException, InvalidTaskStateException {
return taskTransferrer.transfer(taskId, destinationWorkbasketId, setTransferFlag); return taskTransferrer.transfer(taskId, destinationWorkbasketId, setTransferFlag);
} }
@Override @Override
public Task transfer(String taskId, String workbasketKey, String domain, boolean setTransferFlag) public Task transfer(String taskId, String workbasketKey, String domain, boolean setTransferFlag)
throws TaskNotFoundException, WorkbasketNotFoundException, NotAuthorizedException, throws TaskNotFoundException, WorkbasketNotFoundException,
InvalidStateException { MismatchedWorkbasketPermissionException, InvalidTaskStateException {
return taskTransferrer.transfer(taskId, workbasketKey, domain, setTransferFlag); return taskTransferrer.transfer(taskId, workbasketKey, domain, setTransferFlag);
} }
@Override @Override
public Task setTaskRead(String taskId, boolean isRead) public Task setTaskRead(String taskId, boolean isRead)
throws TaskNotFoundException, NotAuthorizedException { throws TaskNotFoundException, MismatchedWorkbasketPermissionException {
TaskImpl task; TaskImpl task;
try { try {
taskanaEngine.openConnection(); taskanaEngine.openConnection();
@ -500,9 +501,9 @@ public class TaskServiceImpl implements TaskService {
@Override @Override
public Task updateTask(Task task) public Task updateTask(Task task)
throws InvalidArgumentException, TaskNotFoundException, ConcurrencyException, throws InvalidArgumentException, TaskNotFoundException, ConcurrencyException,
NotAuthorizedException, AttachmentPersistenceException, AttachmentPersistenceException, ObjectReferencePersistenceException,
ObjectReferencePersistenceException, InvalidStateException, ClassificationNotFoundException, MismatchedWorkbasketPermissionException,
ClassificationNotFoundException { InvalidTaskStateException {
String userId = taskanaEngine.getEngine().getCurrentUserContext().getUserid(); String userId = taskanaEngine.getEngine().getCurrentUserContext().getUserid();
TaskImpl newTaskImpl = (TaskImpl) task; TaskImpl newTaskImpl = (TaskImpl) task;
try { try {
@ -550,7 +551,8 @@ public class TaskServiceImpl implements TaskService {
@Override @Override
public BulkOperationResults<String, TaskanaException> transferTasks( public BulkOperationResults<String, TaskanaException> transferTasks(
String destinationWorkbasketId, List<String> taskIds, boolean setTransferFlag) String destinationWorkbasketId, List<String> taskIds, boolean setTransferFlag)
throws NotAuthorizedException, InvalidArgumentException, WorkbasketNotFoundException { throws InvalidArgumentException, WorkbasketNotFoundException,
MismatchedWorkbasketPermissionException {
return taskTransferrer.transfer(taskIds, destinationWorkbasketId, setTransferFlag); return taskTransferrer.transfer(taskIds, destinationWorkbasketId, setTransferFlag);
} }
@ -560,26 +562,31 @@ public class TaskServiceImpl implements TaskService {
String destinationWorkbasketDomain, String destinationWorkbasketDomain,
List<String> taskIds, List<String> taskIds,
boolean setTransferFlag) boolean setTransferFlag)
throws NotAuthorizedException, InvalidArgumentException, WorkbasketNotFoundException { throws InvalidArgumentException, WorkbasketNotFoundException,
MismatchedWorkbasketPermissionException {
return taskTransferrer.transfer( return taskTransferrer.transfer(
taskIds, destinationWorkbasketKey, destinationWorkbasketDomain, setTransferFlag); taskIds, destinationWorkbasketKey, destinationWorkbasketDomain, setTransferFlag);
} }
@Override @Override
public void deleteTask(String taskId) public void deleteTask(String taskId)
throws TaskNotFoundException, InvalidStateException, NotAuthorizedException { throws TaskNotFoundException, MismatchedRoleException,
MismatchedWorkbasketPermissionException, InvalidTaskStateException,
InvalidCallbackStateException {
deleteTask(taskId, false); deleteTask(taskId, false);
} }
@Override @Override
public void forceDeleteTask(String taskId) public void forceDeleteTask(String taskId)
throws TaskNotFoundException, InvalidStateException, NotAuthorizedException { throws TaskNotFoundException, MismatchedRoleException,
MismatchedWorkbasketPermissionException, InvalidTaskStateException,
InvalidCallbackStateException {
deleteTask(taskId, true); deleteTask(taskId, true);
} }
@Override @Override
public Task selectAndClaim(TaskQuery taskQuery) public Task selectAndClaim(TaskQuery taskQuery)
throws NotAuthorizedException, InvalidOwnerException { throws InvalidOwnerException, MismatchedWorkbasketPermissionException {
try { try {
@ -597,7 +604,7 @@ public class TaskServiceImpl implements TaskService {
return claim(taskSummary.getId()); return claim(taskSummary.getId());
} catch (InvalidStateException | TaskNotFoundException e) { } catch (TaskNotFoundException | InvalidTaskStateException e) {
throw new SystemException("Caught exception ", e); throw new SystemException("Caught exception ", e);
} finally { } finally {
taskanaEngine.returnConnection(); taskanaEngine.returnConnection();
@ -606,7 +613,7 @@ public class TaskServiceImpl implements TaskService {
@Override @Override
public BulkOperationResults<String, TaskanaException> deleteTasks(List<String> taskIds) public BulkOperationResults<String, TaskanaException> deleteTasks(List<String> taskIds)
throws InvalidArgumentException, NotAuthorizedException { throws InvalidArgumentException, MismatchedRoleException {
taskanaEngine.getEngine().checkRoleMembership(TaskanaRole.ADMIN); taskanaEngine.getEngine().checkRoleMembership(TaskanaRole.ADMIN);
@ -732,34 +739,36 @@ public class TaskServiceImpl implements TaskService {
@Override @Override
public TaskComment createTaskComment(TaskComment taskComment) public TaskComment createTaskComment(TaskComment taskComment)
throws NotAuthorizedException, TaskNotFoundException, InvalidArgumentException { throws TaskNotFoundException, InvalidArgumentException,
MismatchedWorkbasketPermissionException {
return taskCommentService.createTaskComment(taskComment); return taskCommentService.createTaskComment(taskComment);
} }
@Override @Override
public TaskComment updateTaskComment(TaskComment taskComment) public TaskComment updateTaskComment(TaskComment taskComment)
throws NotAuthorizedException, ConcurrencyException, TaskCommentNotFoundException, throws ConcurrencyException, TaskCommentNotFoundException, TaskNotFoundException,
TaskNotFoundException, InvalidArgumentException { InvalidArgumentException, MismatchedTaskCommentCreatorException,
MismatchedWorkbasketPermissionException {
return taskCommentService.updateTaskComment(taskComment); return taskCommentService.updateTaskComment(taskComment);
} }
@Override @Override
public void deleteTaskComment(String taskCommentId) public void deleteTaskComment(String taskCommentId)
throws NotAuthorizedException, TaskCommentNotFoundException, TaskNotFoundException, throws TaskCommentNotFoundException, TaskNotFoundException, InvalidArgumentException,
InvalidArgumentException { MismatchedTaskCommentCreatorException, MismatchedWorkbasketPermissionException {
taskCommentService.deleteTaskComment(taskCommentId); taskCommentService.deleteTaskComment(taskCommentId);
} }
@Override @Override
public TaskComment getTaskComment(String taskCommentid) public TaskComment getTaskComment(String taskCommentid)
throws TaskCommentNotFoundException, NotAuthorizedException, TaskNotFoundException, throws TaskCommentNotFoundException, TaskNotFoundException, InvalidArgumentException,
InvalidArgumentException { MismatchedWorkbasketPermissionException {
return taskCommentService.getTaskComment(taskCommentid); return taskCommentService.getTaskComment(taskCommentid);
} }
@Override @Override
public List<TaskComment> getTaskComments(String taskId) public List<TaskComment> getTaskComments(String taskId)
throws NotAuthorizedException, TaskNotFoundException { throws TaskNotFoundException, MismatchedWorkbasketPermissionException {
return taskCommentService.getTaskComments(taskId); return taskCommentService.getTaskComments(taskId);
} }
@ -853,7 +862,8 @@ public class TaskServiceImpl implements TaskService {
@Override @Override
public Task cancelTask(String taskId) public Task cancelTask(String taskId)
throws TaskNotFoundException, InvalidStateException, NotAuthorizedException { throws TaskNotFoundException, MismatchedWorkbasketPermissionException,
InvalidTaskStateException {
Task cancelledTask; Task cancelledTask;
@ -877,7 +887,8 @@ public class TaskServiceImpl implements TaskService {
@Override @Override
public Task terminateTask(String taskId) public Task terminateTask(String taskId)
throws TaskNotFoundException, InvalidStateException, NotAuthorizedException { throws TaskNotFoundException, MismatchedRoleException,
MismatchedWorkbasketPermissionException, InvalidTaskStateException {
taskanaEngine.getEngine().checkRoleMembership(TaskanaRole.ADMIN, TaskanaRole.TASK_ADMIN); taskanaEngine.getEngine().checkRoleMembership(TaskanaRole.ADMIN, TaskanaRole.TASK_ADMIN);
@ -1191,7 +1202,8 @@ public class TaskServiceImpl implements TaskService {
} }
private TaskImpl terminateCancelCommonActions(String taskId, TaskState targetState) private TaskImpl terminateCancelCommonActions(String taskId, TaskState targetState)
throws NotAuthorizedException, TaskNotFoundException, InvalidStateException { throws TaskNotFoundException, MismatchedWorkbasketPermissionException,
InvalidTaskStateException {
if (taskId == null || taskId.isEmpty()) { if (taskId == null || taskId.isEmpty()) {
throw new TaskNotFoundException(taskId); throw new TaskNotFoundException(taskId);
} }
@ -1216,8 +1228,8 @@ public class TaskServiceImpl implements TaskService {
} }
private Task claim(String taskId, boolean forceClaim) private Task claim(String taskId, boolean forceClaim)
throws TaskNotFoundException, InvalidStateException, InvalidOwnerException, throws TaskNotFoundException, InvalidOwnerException, MismatchedWorkbasketPermissionException,
NotAuthorizedException { InvalidTaskStateException {
String userId = taskanaEngine.getEngine().getCurrentUserContext().getUserid(); String userId = taskanaEngine.getEngine().getCurrentUserContext().getUserid();
String userLongName = null; String userLongName = null;
if (taskanaEngine.getEngine().getConfiguration().isAddAdditionalUserInfo()) { if (taskanaEngine.getEngine().getConfiguration().isAddAdditionalUserInfo()) {
@ -1258,8 +1270,8 @@ public class TaskServiceImpl implements TaskService {
} }
private Task requestReview(String taskId, boolean force) private Task requestReview(String taskId, boolean force)
throws TaskNotFoundException, NotAuthorizedException, InvalidTaskStateException, throws TaskNotFoundException, InvalidTaskStateException, InvalidOwnerException,
InvalidOwnerException { MismatchedWorkbasketPermissionException {
String userId = taskanaEngine.getEngine().getCurrentUserContext().getUserid(); String userId = taskanaEngine.getEngine().getCurrentUserContext().getUserid();
TaskImpl task; TaskImpl task;
try { try {
@ -1309,8 +1321,8 @@ public class TaskServiceImpl implements TaskService {
} }
private Task requestChanges(String taskId, boolean force) private Task requestChanges(String taskId, boolean force)
throws InvalidTaskStateException, TaskNotFoundException, NotAuthorizedException, throws InvalidTaskStateException, TaskNotFoundException, InvalidOwnerException,
InvalidOwnerException { MismatchedWorkbasketPermissionException {
String userId = taskanaEngine.getEngine().getCurrentUserContext().getUserid(); String userId = taskanaEngine.getEngine().getCurrentUserContext().getUserid();
TaskImpl task; TaskImpl task;
try { try {
@ -1391,7 +1403,7 @@ public class TaskServiceImpl implements TaskService {
} }
private void checkPreconditionsForClaimTask(TaskSummary task, boolean forced) private void checkPreconditionsForClaimTask(TaskSummary task, boolean forced)
throws InvalidStateException, InvalidOwnerException { throws InvalidOwnerException, InvalidTaskStateException {
TaskState state = task.getState(); TaskState state = task.getState();
if (state.isEndState()) { if (state.isEndState()) {
throw new InvalidTaskStateException( throw new InvalidTaskStateException(
@ -1412,7 +1424,7 @@ public class TaskServiceImpl implements TaskService {
} }
private static void checkIfTaskIsTerminatedOrCancelled(TaskSummary task) private static void checkIfTaskIsTerminatedOrCancelled(TaskSummary task)
throws InvalidStateException { throws InvalidTaskStateException {
if (task.getState().in(TaskState.CANCELLED, TaskState.TERMINATED)) { if (task.getState().in(TaskState.CANCELLED, TaskState.TERMINATED)) {
throw new InvalidTaskStateException( throw new InvalidTaskStateException(
task.getId(), task.getId(),
@ -1422,7 +1434,7 @@ public class TaskServiceImpl implements TaskService {
} }
private void checkPreconditionsForCompleteTask(TaskSummary task) private void checkPreconditionsForCompleteTask(TaskSummary task)
throws InvalidStateException, InvalidOwnerException { throws InvalidOwnerException, InvalidTaskStateException {
if (taskIsNotClaimed(task)) { if (taskIsNotClaimed(task)) {
throw new InvalidTaskStateException( throw new InvalidTaskStateException(
task.getId(), task.getState(), TaskState.CLAIMED, TaskState.IN_REVIEW); task.getId(), task.getState(), TaskState.CLAIMED, TaskState.IN_REVIEW);
@ -1438,8 +1450,8 @@ public class TaskServiceImpl implements TaskService {
} }
private Task cancelClaim(String taskId, boolean forceUnclaim) private Task cancelClaim(String taskId, boolean forceUnclaim)
throws TaskNotFoundException, InvalidStateException, InvalidOwnerException, throws TaskNotFoundException, InvalidOwnerException, MismatchedWorkbasketPermissionException,
NotAuthorizedException { InvalidTaskStateException {
String userId = taskanaEngine.getEngine().getCurrentUserContext().getUserid(); String userId = taskanaEngine.getEngine().getCurrentUserContext().getUserid();
TaskImpl task; TaskImpl task;
try { try {
@ -1482,8 +1494,8 @@ public class TaskServiceImpl implements TaskService {
} }
private Task completeTask(String taskId, boolean isForced) private Task completeTask(String taskId, boolean isForced)
throws TaskNotFoundException, InvalidOwnerException, InvalidStateException, throws TaskNotFoundException, InvalidOwnerException, MismatchedWorkbasketPermissionException,
NotAuthorizedException { InvalidTaskStateException {
String userId = taskanaEngine.getEngine().getCurrentUserContext().getUserid(); String userId = taskanaEngine.getEngine().getCurrentUserContext().getUserid();
TaskImpl task; TaskImpl task;
try { try {
@ -1525,7 +1537,9 @@ public class TaskServiceImpl implements TaskService {
} }
private void deleteTask(String taskId, boolean forceDelete) private void deleteTask(String taskId, boolean forceDelete)
throws TaskNotFoundException, InvalidStateException, NotAuthorizedException { throws TaskNotFoundException, MismatchedRoleException,
MismatchedWorkbasketPermissionException, InvalidTaskStateException,
InvalidCallbackStateException {
taskanaEngine.getEngine().checkRoleMembership(TaskanaRole.ADMIN); taskanaEngine.getEngine().checkRoleMembership(TaskanaRole.ADMIN);
TaskImpl task; TaskImpl task;
try { try {
@ -2017,7 +2031,7 @@ public class TaskServiceImpl implements TaskService {
} }
private void standardUpdateActions(TaskImpl oldTaskImpl, TaskImpl newTaskImpl) private void standardUpdateActions(TaskImpl oldTaskImpl, TaskImpl newTaskImpl)
throws InvalidArgumentException, InvalidStateException, ClassificationNotFoundException { throws InvalidArgumentException, ClassificationNotFoundException, InvalidTaskStateException {
if (oldTaskImpl.getExternalId() == null if (oldTaskImpl.getExternalId() == null
|| !(oldTaskImpl.getExternalId().equals(newTaskImpl.getExternalId()))) { || !(oldTaskImpl.getExternalId().equals(newTaskImpl.getExternalId()))) {

View File

@ -15,7 +15,6 @@ import java.util.stream.Collectors;
import pro.taskana.common.api.BulkOperationResults; import pro.taskana.common.api.BulkOperationResults;
import pro.taskana.common.api.exceptions.InvalidArgumentException; import pro.taskana.common.api.exceptions.InvalidArgumentException;
import pro.taskana.common.api.exceptions.NotAuthorizedException;
import pro.taskana.common.api.exceptions.TaskanaException; import pro.taskana.common.api.exceptions.TaskanaException;
import pro.taskana.common.internal.InternalTaskanaEngine; import pro.taskana.common.internal.InternalTaskanaEngine;
import pro.taskana.common.internal.util.EnumUtil; import pro.taskana.common.internal.util.EnumUtil;
@ -24,7 +23,6 @@ import pro.taskana.common.internal.util.ObjectAttributeChangeDetector;
import pro.taskana.spi.history.api.events.task.TaskTransferredEvent; import pro.taskana.spi.history.api.events.task.TaskTransferredEvent;
import pro.taskana.spi.history.internal.HistoryEventManager; import pro.taskana.spi.history.internal.HistoryEventManager;
import pro.taskana.task.api.TaskState; import pro.taskana.task.api.TaskState;
import pro.taskana.task.api.exceptions.InvalidStateException;
import pro.taskana.task.api.exceptions.InvalidTaskStateException; import pro.taskana.task.api.exceptions.InvalidTaskStateException;
import pro.taskana.task.api.exceptions.TaskNotFoundException; import pro.taskana.task.api.exceptions.TaskNotFoundException;
import pro.taskana.task.api.models.Task; import pro.taskana.task.api.models.Task;
@ -57,8 +55,8 @@ final class TaskTransferrer {
} }
Task transfer(String taskId, String destinationWorkbasketId, boolean setTransferFlag) Task transfer(String taskId, String destinationWorkbasketId, boolean setTransferFlag)
throws TaskNotFoundException, WorkbasketNotFoundException, NotAuthorizedException, throws TaskNotFoundException, WorkbasketNotFoundException,
InvalidStateException { MismatchedWorkbasketPermissionException, InvalidTaskStateException {
WorkbasketSummary destinationWorkbasket = WorkbasketSummary destinationWorkbasket =
workbasketService.getWorkbasket(destinationWorkbasketId).asSummary(); workbasketService.getWorkbasket(destinationWorkbasketId).asSummary();
return transferSingleTask(taskId, destinationWorkbasket, setTransferFlag); return transferSingleTask(taskId, destinationWorkbasket, setTransferFlag);
@ -69,8 +67,8 @@ final class TaskTransferrer {
String destinationWorkbasketKey, String destinationWorkbasketKey,
String destinationDomain, String destinationDomain,
boolean setTransferFlag) boolean setTransferFlag)
throws TaskNotFoundException, WorkbasketNotFoundException, NotAuthorizedException, throws TaskNotFoundException, WorkbasketNotFoundException,
InvalidStateException { MismatchedWorkbasketPermissionException, InvalidTaskStateException {
WorkbasketSummary destinationWorkbasket = WorkbasketSummary destinationWorkbasket =
workbasketService.getWorkbasket(destinationWorkbasketKey, destinationDomain).asSummary(); workbasketService.getWorkbasket(destinationWorkbasketKey, destinationDomain).asSummary();
return transferSingleTask(taskId, destinationWorkbasket, setTransferFlag); return transferSingleTask(taskId, destinationWorkbasket, setTransferFlag);
@ -78,7 +76,8 @@ final class TaskTransferrer {
BulkOperationResults<String, TaskanaException> transfer( BulkOperationResults<String, TaskanaException> transfer(
List<String> taskIds, String destinationWorkbasketId, boolean setTransferFlag) List<String> taskIds, String destinationWorkbasketId, boolean setTransferFlag)
throws NotAuthorizedException, WorkbasketNotFoundException, InvalidArgumentException { throws WorkbasketNotFoundException, InvalidArgumentException,
MismatchedWorkbasketPermissionException {
WorkbasketSummary destinationWorkbasket = WorkbasketSummary destinationWorkbasket =
workbasketService.getWorkbasket(destinationWorkbasketId).asSummary(); workbasketService.getWorkbasket(destinationWorkbasketId).asSummary();
checkDestinationWorkbasket(destinationWorkbasket); checkDestinationWorkbasket(destinationWorkbasket);
@ -91,7 +90,8 @@ final class TaskTransferrer {
String destinationWorkbasketKey, String destinationWorkbasketKey,
String destinationDomain, String destinationDomain,
boolean setTransferFlag) boolean setTransferFlag)
throws NotAuthorizedException, WorkbasketNotFoundException, InvalidArgumentException { throws WorkbasketNotFoundException, InvalidArgumentException,
MismatchedWorkbasketPermissionException {
WorkbasketSummary destinationWorkbasket = WorkbasketSummary destinationWorkbasket =
workbasketService.getWorkbasket(destinationWorkbasketKey, destinationDomain).asSummary(); workbasketService.getWorkbasket(destinationWorkbasketKey, destinationDomain).asSummary();
checkDestinationWorkbasket(destinationWorkbasket); checkDestinationWorkbasket(destinationWorkbasket);
@ -101,8 +101,8 @@ final class TaskTransferrer {
private Task transferSingleTask( private Task transferSingleTask(
String taskId, WorkbasketSummary destinationWorkbasket, boolean setTransferFlag) String taskId, WorkbasketSummary destinationWorkbasket, boolean setTransferFlag)
throws NotAuthorizedException, TaskNotFoundException, WorkbasketNotFoundException, throws TaskNotFoundException, WorkbasketNotFoundException,
InvalidStateException { MismatchedWorkbasketPermissionException, InvalidTaskStateException {
try { try {
taskanaEngine.openConnection(); taskanaEngine.openConnection();
TaskImpl task = (TaskImpl) taskService.getTask(taskId); TaskImpl task = (TaskImpl) taskService.getTask(taskId);
@ -157,7 +157,8 @@ final class TaskTransferrer {
private void checkPreconditionsForTransferTask( private void checkPreconditionsForTransferTask(
Task task, WorkbasketSummary destinationWorkbasket, WorkbasketSummary originWorkbasket) Task task, WorkbasketSummary destinationWorkbasket, WorkbasketSummary originWorkbasket)
throws NotAuthorizedException, WorkbasketNotFoundException, InvalidStateException { throws WorkbasketNotFoundException, MismatchedWorkbasketPermissionException,
InvalidTaskStateException {
if (task.getState().isEndState()) { if (task.getState().isEndState()) {
throw new InvalidTaskStateException( throw new InvalidTaskStateException(
task.getId(), task.getState(), EnumUtil.allValuesExceptFor(TaskState.END_STATES)); task.getId(), task.getState(), EnumUtil.allValuesExceptFor(TaskState.END_STATES));
@ -167,7 +168,7 @@ final class TaskTransferrer {
} }
private void checkDestinationWorkbasket(WorkbasketSummary destinationWorkbasket) private void checkDestinationWorkbasket(WorkbasketSummary destinationWorkbasket)
throws NotAuthorizedException, WorkbasketNotFoundException { throws WorkbasketNotFoundException, MismatchedWorkbasketPermissionException {
workbasketService.checkAuthorization( workbasketService.checkAuthorization(
destinationWorkbasket.getId(), WorkbasketPermission.APPEND); destinationWorkbasket.getId(), WorkbasketPermission.APPEND);

View File

@ -18,7 +18,7 @@ import pro.taskana.common.api.ScheduledJob;
import pro.taskana.common.api.TaskanaEngine; import pro.taskana.common.api.TaskanaEngine;
import pro.taskana.common.api.TimeInterval; import pro.taskana.common.api.TimeInterval;
import pro.taskana.common.api.exceptions.InvalidArgumentException; import pro.taskana.common.api.exceptions.InvalidArgumentException;
import pro.taskana.common.api.exceptions.NotAuthorizedException; import pro.taskana.common.api.exceptions.MismatchedRoleException;
import pro.taskana.common.api.exceptions.SystemException; import pro.taskana.common.api.exceptions.SystemException;
import pro.taskana.common.api.exceptions.TaskanaException; import pro.taskana.common.api.exceptions.TaskanaException;
import pro.taskana.common.internal.JobServiceImpl; import pro.taskana.common.internal.JobServiceImpl;
@ -146,7 +146,7 @@ public class TaskCleanupJob extends AbstractTaskanaJob {
} }
private int deleteTasks(List<TaskSummary> tasksToBeDeleted) private int deleteTasks(List<TaskSummary> tasksToBeDeleted)
throws InvalidArgumentException, NotAuthorizedException { throws InvalidArgumentException, MismatchedRoleException {
List<String> tasksIdsToBeDeleted = List<String> tasksIdsToBeDeleted =
tasksToBeDeleted.stream().map(TaskSummary::getId).collect(Collectors.toList()); tasksToBeDeleted.stream().map(TaskSummary::getId).collect(Collectors.toList());

View File

@ -4,7 +4,7 @@ import java.util.List;
import java.util.Set; import java.util.Set;
import pro.taskana.common.api.exceptions.InvalidArgumentException; import pro.taskana.common.api.exceptions.InvalidArgumentException;
import pro.taskana.common.api.exceptions.NotAuthorizedException; import pro.taskana.common.api.exceptions.MismatchedRoleException;
import pro.taskana.user.api.exceptions.UserAlreadyExistException; import pro.taskana.user.api.exceptions.UserAlreadyExistException;
import pro.taskana.user.api.exceptions.UserNotFoundException; import pro.taskana.user.api.exceptions.UserNotFoundException;
import pro.taskana.user.api.models.User; import pro.taskana.user.api.models.User;
@ -41,14 +41,14 @@ public interface UserService {
* @param userToCreate the {@linkplain User} which should be inserted * @param userToCreate the {@linkplain User} which should be inserted
* @return the inserted {@linkplain User} * @return the inserted {@linkplain User}
* @throws InvalidArgumentException if some fields are not set properly * @throws InvalidArgumentException if some fields are not set properly
* @throws NotAuthorizedException if the current user is not {@linkplain * @throws MismatchedRoleException if the current user is not {@linkplain
* pro.taskana.common.api.TaskanaRole#ADMIN admin} or {@linkplain * pro.taskana.common.api.TaskanaRole#ADMIN admin} or {@linkplain
* pro.taskana.common.api.TaskanaRole#BUSINESS_ADMIN business-admin} * pro.taskana.common.api.TaskanaRole#BUSINESS_ADMIN business-admin}
* @throws UserAlreadyExistException if there already exists a {@linkplain User} with the * @throws UserAlreadyExistException if there already exists a {@linkplain User} with the
* specified {@linkplain User#getId() id} inside the database * specified {@linkplain User#getId() id} inside the database
*/ */
User createUser(User userToCreate) User createUser(User userToCreate)
throws InvalidArgumentException, NotAuthorizedException, UserAlreadyExistException; throws InvalidArgumentException, UserAlreadyExistException, MismatchedRoleException;
/** /**
* Gets a {@linkplain User}. * Gets a {@linkplain User}.
@ -85,7 +85,7 @@ public interface UserService {
* *
* @param userToUpdate the {@linkplain User} which should be updated * @param userToUpdate the {@linkplain User} which should be updated
* @return the updated {@linkplain User} * @return the updated {@linkplain User}
* @throws NotAuthorizedException if the current user is not {@linkplain * @throws MismatchedRoleException if the current user is not {@linkplain
* pro.taskana.common.api.TaskanaRole#ADMIN admin} or {@linkplain * pro.taskana.common.api.TaskanaRole#ADMIN admin} or {@linkplain
* pro.taskana.common.api.TaskanaRole#BUSINESS_ADMIN business-admin} * pro.taskana.common.api.TaskanaRole#BUSINESS_ADMIN business-admin}
* @throws UserNotFoundException if there does not exist a {@linkplain User} with the specified * @throws UserNotFoundException if there does not exist a {@linkplain User} with the specified
@ -93,7 +93,7 @@ public interface UserService {
* @throws InvalidArgumentException if some fields are not set properly * @throws InvalidArgumentException if some fields are not set properly
*/ */
User updateUser(User userToUpdate) User updateUser(User userToUpdate)
throws UserNotFoundException, NotAuthorizedException, InvalidArgumentException; throws UserNotFoundException, InvalidArgumentException, MismatchedRoleException;
/** /**
* Deletes a {@linkplain User}. * Deletes a {@linkplain User}.
@ -103,7 +103,7 @@ public interface UserService {
* gets deleted. * gets deleted.
* *
* @param id the {@linkplain User#getId() id} of the {@linkplain User} which should be deleted * @param id the {@linkplain User#getId() id} of the {@linkplain User} which should be deleted
* @throws NotAuthorizedException if the current user is not {@linkplain * @throws MismatchedRoleException if the current user is not {@linkplain
* pro.taskana.common.api.TaskanaRole#ADMIN admin} or {@linkplain * pro.taskana.common.api.TaskanaRole#ADMIN admin} or {@linkplain
* pro.taskana.common.api.TaskanaRole#BUSINESS_ADMIN business-admin} * pro.taskana.common.api.TaskanaRole#BUSINESS_ADMIN business-admin}
* @throws UserNotFoundException if there does not exist a {@linkplain User} with the specified * @throws UserNotFoundException if there does not exist a {@linkplain User} with the specified
@ -111,5 +111,5 @@ public interface UserService {
* @throws InvalidArgumentException if the userIds parameter is NULL or empty * @throws InvalidArgumentException if the userIds parameter is NULL or empty
*/ */
void deleteUser(String id) void deleteUser(String id)
throws UserNotFoundException, NotAuthorizedException, InvalidArgumentException; throws UserNotFoundException, InvalidArgumentException, MismatchedRoleException;
} }

View File

@ -1,7 +1,7 @@
package pro.taskana.user.api.exceptions; package pro.taskana.user.api.exceptions;
import pro.taskana.common.api.exceptions.ErrorCode; import pro.taskana.common.api.exceptions.ErrorCode;
import pro.taskana.common.api.exceptions.NotFoundException; import pro.taskana.common.api.exceptions.TaskanaException;
import pro.taskana.common.internal.util.MapCreator; import pro.taskana.common.internal.util.MapCreator;
import pro.taskana.user.api.models.User; import pro.taskana.user.api.models.User;
@ -9,7 +9,7 @@ import pro.taskana.user.api.models.User;
* This exception is thrown when a specific {@linkplain User} referenced by its {@linkplain * This exception is thrown when a specific {@linkplain User} referenced by its {@linkplain
* User#getId() id} is not in the database. * User#getId() id} is not in the database.
*/ */
public class UserNotFoundException extends NotFoundException { public class UserNotFoundException extends TaskanaException {
public static final String ERROR_KEY = "USER_NOT_FOUND"; public static final String ERROR_KEY = "USER_NOT_FOUND";
private final String userId; private final String userId;

View File

@ -15,7 +15,7 @@ import pro.taskana.TaskanaConfiguration;
import pro.taskana.common.api.BaseQuery.SortDirection; import pro.taskana.common.api.BaseQuery.SortDirection;
import pro.taskana.common.api.TaskanaRole; import pro.taskana.common.api.TaskanaRole;
import pro.taskana.common.api.exceptions.InvalidArgumentException; import pro.taskana.common.api.exceptions.InvalidArgumentException;
import pro.taskana.common.api.exceptions.NotAuthorizedException; import pro.taskana.common.api.exceptions.MismatchedRoleException;
import pro.taskana.common.internal.InternalTaskanaEngine; import pro.taskana.common.internal.InternalTaskanaEngine;
import pro.taskana.user.api.UserService; import pro.taskana.user.api.UserService;
import pro.taskana.user.api.exceptions.UserAlreadyExistException; import pro.taskana.user.api.exceptions.UserAlreadyExistException;
@ -90,7 +90,7 @@ public class UserServiceImpl implements UserService {
@Override @Override
public User createUser(User userToCreate) public User createUser(User userToCreate)
throws InvalidArgumentException, NotAuthorizedException, UserAlreadyExistException { throws InvalidArgumentException, UserAlreadyExistException, MismatchedRoleException {
internalTaskanaEngine internalTaskanaEngine
.getEngine() .getEngine()
.checkRoleMembership(TaskanaRole.BUSINESS_ADMIN, TaskanaRole.ADMIN); .checkRoleMembership(TaskanaRole.BUSINESS_ADMIN, TaskanaRole.ADMIN);
@ -107,7 +107,7 @@ public class UserServiceImpl implements UserService {
@Override @Override
public User updateUser(User userToUpdate) public User updateUser(User userToUpdate)
throws UserNotFoundException, NotAuthorizedException, InvalidArgumentException { throws UserNotFoundException, InvalidArgumentException, MismatchedRoleException {
internalTaskanaEngine internalTaskanaEngine
.getEngine() .getEngine()
.checkRoleMembership(TaskanaRole.BUSINESS_ADMIN, TaskanaRole.ADMIN); .checkRoleMembership(TaskanaRole.BUSINESS_ADMIN, TaskanaRole.ADMIN);
@ -132,7 +132,7 @@ public class UserServiceImpl implements UserService {
@Override @Override
public void deleteUser(String id) public void deleteUser(String id)
throws UserNotFoundException, NotAuthorizedException, InvalidArgumentException { throws UserNotFoundException, InvalidArgumentException, MismatchedRoleException {
internalTaskanaEngine internalTaskanaEngine
.getEngine() .getEngine()
.checkRoleMembership(TaskanaRole.BUSINESS_ADMIN, TaskanaRole.ADMIN); .checkRoleMembership(TaskanaRole.BUSINESS_ADMIN, TaskanaRole.ADMIN);

View File

@ -3,9 +3,10 @@ package pro.taskana.workbasket.api;
import java.util.List; import java.util.List;
import pro.taskana.common.api.BaseQuery; import pro.taskana.common.api.BaseQuery;
import pro.taskana.common.api.TaskanaRole;
import pro.taskana.common.api.TimeInterval; import pro.taskana.common.api.TimeInterval;
import pro.taskana.common.api.exceptions.InvalidArgumentException; import pro.taskana.common.api.exceptions.InvalidArgumentException;
import pro.taskana.common.api.exceptions.NotAuthorizedException; import pro.taskana.common.api.exceptions.MismatchedRoleException;
import pro.taskana.workbasket.api.models.WorkbasketSummary; import pro.taskana.workbasket.api.models.WorkbasketSummary;
/** WorkitemQuery for generating dynamic sql. */ /** WorkitemQuery for generating dynamic sql. */
@ -151,12 +152,12 @@ public interface WorkbasketQuery extends BaseQuery<WorkbasketSummary, Workbasket
* @param accessIds Users which should be checked for given permissions on workbaskets. * @param accessIds Users which should be checked for given permissions on workbaskets.
* @return the current query object. * @return the current query object.
* @throws InvalidArgumentException if permissions OR the accessIds are NULL or empty. * @throws InvalidArgumentException if permissions OR the accessIds are NULL or empty.
* @throws NotAuthorizedException if the current user is not member of role BUSINESS_ADMIN or * @throws MismatchedRoleException if the current user is not member of {@linkplain
* ADMIN * TaskanaRole#BUSINESS_ADMIN} or {@linkplain TaskanaRole#ADMIN}
*/ */
WorkbasketQuery accessIdsHavePermissions( WorkbasketQuery accessIdsHavePermissions(
List<WorkbasketPermission> permissions, String... accessIds) List<WorkbasketPermission> permissions, String... accessIds)
throws InvalidArgumentException, NotAuthorizedException; throws InvalidArgumentException, MismatchedRoleException;
/** /**
* Add condition to query if the caller (one of the accessIds of the caller) has the given * Add condition to query if the caller (one of the accessIds of the caller) has the given

View File

@ -3,12 +3,14 @@ package pro.taskana.workbasket.api;
import java.util.List; import java.util.List;
import pro.taskana.common.api.BulkOperationResults; import pro.taskana.common.api.BulkOperationResults;
import pro.taskana.common.api.TaskanaRole;
import pro.taskana.common.api.exceptions.ConcurrencyException; import pro.taskana.common.api.exceptions.ConcurrencyException;
import pro.taskana.common.api.exceptions.DomainNotFoundException; import pro.taskana.common.api.exceptions.DomainNotFoundException;
import pro.taskana.common.api.exceptions.InvalidArgumentException; import pro.taskana.common.api.exceptions.InvalidArgumentException;
import pro.taskana.common.api.exceptions.NotAuthorizedException; import pro.taskana.common.api.exceptions.MismatchedRoleException;
import pro.taskana.common.api.exceptions.TaskanaException; import pro.taskana.common.api.exceptions.TaskanaException;
import pro.taskana.user.api.models.User; import pro.taskana.user.api.models.User;
import pro.taskana.workbasket.api.exceptions.MismatchedWorkbasketPermissionException;
import pro.taskana.workbasket.api.exceptions.WorkbasketAccessItemAlreadyExistException; import pro.taskana.workbasket.api.exceptions.WorkbasketAccessItemAlreadyExistException;
import pro.taskana.workbasket.api.exceptions.WorkbasketAlreadyExistException; import pro.taskana.workbasket.api.exceptions.WorkbasketAlreadyExistException;
import pro.taskana.workbasket.api.exceptions.WorkbasketInUseException; import pro.taskana.workbasket.api.exceptions.WorkbasketInUseException;
@ -47,7 +49,7 @@ public interface WorkbasketService {
* @return the created and inserted {@linkplain Workbasket} * @return the created and inserted {@linkplain Workbasket}
* @throws InvalidArgumentException If a required property of the {@linkplain Workbasket} is not * @throws InvalidArgumentException If a required property of the {@linkplain Workbasket} is not
* set. * set.
* @throws NotAuthorizedException if the current user is not member of role {@linkplain * @throws MismatchedRoleException if the current user is not member of role {@linkplain
* pro.taskana.common.api.TaskanaRole#ADMIN admin} or {@linkplain * pro.taskana.common.api.TaskanaRole#ADMIN admin} or {@linkplain
* pro.taskana.common.api.TaskanaRole#BUSINESS_ADMIN business-admin} * pro.taskana.common.api.TaskanaRole#BUSINESS_ADMIN business-admin}
* @throws WorkbasketAlreadyExistException if the {@linkplain Workbasket} exists already * @throws WorkbasketAlreadyExistException if the {@linkplain Workbasket} exists already
@ -55,8 +57,8 @@ public interface WorkbasketService {
* exist in the configuration. * exist in the configuration.
*/ */
Workbasket createWorkbasket(Workbasket workbasket) Workbasket createWorkbasket(Workbasket workbasket)
throws InvalidArgumentException, NotAuthorizedException, WorkbasketAlreadyExistException, throws InvalidArgumentException, WorkbasketAlreadyExistException, DomainNotFoundException,
DomainNotFoundException; MismatchedRoleException;
// READ // READ
@ -69,11 +71,11 @@ public interface WorkbasketService {
* @return the requested Workbasket * @return the requested Workbasket
* @throws WorkbasketNotFoundException If the {@linkplain Workbasket} with workbasketId is not * @throws WorkbasketNotFoundException If the {@linkplain Workbasket} with workbasketId is not
* found * found
* @throws NotAuthorizedException If the current user or group does not have the {@linkplain * @throws MismatchedWorkbasketPermissionException if the current user has no {@linkplain
* WorkbasketPermission permissions} for interactions. * WorkbasketPermission#READ} for the requested {@linkplain Workbasket}
*/ */
Workbasket getWorkbasket(String workbasketId) Workbasket getWorkbasket(String workbasketId)
throws WorkbasketNotFoundException, NotAuthorizedException; throws WorkbasketNotFoundException, MismatchedWorkbasketPermissionException;
/** /**
* Get the {@linkplain Workbasket} specified by the given {@linkplain WorkbasketSummary#getKey() * Get the {@linkplain Workbasket} specified by the given {@linkplain WorkbasketSummary#getKey()
@ -86,11 +88,11 @@ public interface WorkbasketService {
* @return the requested {@linkplain Workbasket} * @return the requested {@linkplain Workbasket}
* @throws WorkbasketNotFoundException If the {@linkplain Workbasket} with workbasketId is not * @throws WorkbasketNotFoundException If the {@linkplain Workbasket} with workbasketId is not
* found * found
* @throws NotAuthorizedException If the current user or group does not have the {@linkplain * @throws MismatchedWorkbasketPermissionException if the current user has no {@linkplain
* WorkbasketPermission permissions} for interactions. * WorkbasketPermission#READ} for the requested {@linkplain Workbasket}
*/ */
Workbasket getWorkbasket(String workbasketKey, String domain) Workbasket getWorkbasket(String workbasketKey, String domain)
throws WorkbasketNotFoundException, NotAuthorizedException; throws WorkbasketNotFoundException, MismatchedWorkbasketPermissionException;
// UPDATE // UPDATE
@ -101,16 +103,17 @@ public interface WorkbasketService {
* @return the updated {@linkplain Workbasket} * @return the updated {@linkplain Workbasket}
* @throws InvalidArgumentException if {@linkplain Workbasket#getName() name} or {@linkplain * @throws InvalidArgumentException if {@linkplain Workbasket#getName() name} or {@linkplain
* Workbasket#getType() type} of the {@linkplain Workbasket} is invalid * Workbasket#getType() type} of the {@linkplain Workbasket} is invalid
* @throws NotAuthorizedException if the current user is not authorized to update the {@linkplain * @throws MismatchedWorkbasketPermissionException This is never thrown
* Workbasket} * @throws MismatchedRoleException if the current user is not member of {@linkplain
* TaskanaRole#BUSINESS_ADMIN} or {@linkplain TaskanaRole#ADMIN}
* @throws WorkbasketNotFoundException if the {@linkplain Workbasket} cannot be found. * @throws WorkbasketNotFoundException if the {@linkplain Workbasket} cannot be found.
* @throws ConcurrencyException if an attempt is made to update the {@linkplain Workbasket} and * @throws ConcurrencyException if an attempt is made to update the {@linkplain Workbasket} and
* another user updated it already; that's the case if the given modified timestamp differs * another user updated it already; that's the case if the given modified timestamp differs
* from the one in the database * from the one in the database
*/ */
Workbasket updateWorkbasket(Workbasket workbasket) Workbasket updateWorkbasket(Workbasket workbasket)
throws InvalidArgumentException, NotAuthorizedException, WorkbasketNotFoundException, throws InvalidArgumentException, WorkbasketNotFoundException, ConcurrencyException,
ConcurrencyException; MismatchedRoleException, MismatchedWorkbasketPermissionException;
// DELETE // DELETE
@ -121,15 +124,16 @@ public interface WorkbasketService {
* should be deleted. * should be deleted.
* @return true if the {@linkplain Workbasket} was deleted successfully; false if the {@linkplain * @return true if the {@linkplain Workbasket} was deleted successfully; false if the {@linkplain
* Workbasket} is marked for deletion * Workbasket} is marked for deletion
* @throws NotAuthorizedException if the current user got no {@linkplain WorkbasketPermission}s * @throws MismatchedWorkbasketPermissionException This is never thrown
* for this interaction * @throws MismatchedRoleException if the current user is not member of {@linkplain
* TaskanaRole#BUSINESS_ADMIN} or {@linkplain TaskanaRole#ADMIN}
* @throws WorkbasketNotFoundException if the {@linkplain Workbasket} does not exist * @throws WorkbasketNotFoundException if the {@linkplain Workbasket} does not exist
* @throws WorkbasketInUseException if the {@linkplain Workbasket} does contain task-content * @throws WorkbasketInUseException if the {@linkplain Workbasket} does contain task-content
* @throws InvalidArgumentException if the workbasketId is NULL or EMPTY * @throws InvalidArgumentException if the workbasketId is NULL or EMPTY
*/ */
boolean deleteWorkbasket(String workbasketId) boolean deleteWorkbasket(String workbasketId)
throws NotAuthorizedException, WorkbasketNotFoundException, WorkbasketInUseException, throws WorkbasketNotFoundException, WorkbasketInUseException, InvalidArgumentException,
InvalidArgumentException; MismatchedRoleException, MismatchedWorkbasketPermissionException;
/** /**
* Deletes the list of {@linkplain Workbasket}s specified via {@linkplain Workbasket#getId() ids}. * Deletes the list of {@linkplain Workbasket}s specified via {@linkplain Workbasket#getId() ids}.
@ -138,11 +142,11 @@ public interface WorkbasketService {
* to delete. * to delete.
* @return the result of the operations and an Exception for each failed workbasket deletion * @return the result of the operations and an Exception for each failed workbasket deletion
* @throws InvalidArgumentException if the WorkbasketIds parameter List is NULL or empty * @throws InvalidArgumentException if the WorkbasketIds parameter List is NULL or empty
* @throws NotAuthorizedException if the current user got no {@linkplain WorkbasketPermission} for * @throws MismatchedRoleException if the current user is not member of {@linkplain
* this interaction * TaskanaRole#BUSINESS_ADMIN} or {@linkplain TaskanaRole#ADMIN}
*/ */
BulkOperationResults<String, TaskanaException> deleteWorkbaskets(List<String> workbasketsIds) BulkOperationResults<String, TaskanaException> deleteWorkbaskets(List<String> workbasketsIds)
throws NotAuthorizedException, InvalidArgumentException; throws InvalidArgumentException, MismatchedRoleException;
// endregion // endregion
@ -156,13 +160,15 @@ public interface WorkbasketService {
* @param sourceWorkbasketId the {@linkplain Workbasket#getId() id} of the source {@linkplain * @param sourceWorkbasketId the {@linkplain Workbasket#getId() id} of the source {@linkplain
* Workbasket} for which the distribution targets are to be set * Workbasket} for which the distribution targets are to be set
* @param targetWorkbasketIds a list of the ids of the target {@linkplain Workbasket}s * @param targetWorkbasketIds a list of the ids of the target {@linkplain Workbasket}s
* @throws NotAuthorizedException if the current used doesn't have {@linkplain * @throws MismatchedWorkbasketPermissionException This is never thrown
* WorkbasketPermission#READ READ permission} for the source {@linkplain Workbasket} * @throws MismatchedRoleException if the current user is not member of {@linkplain
* TaskanaRole#BUSINESS_ADMIN} or {@linkplain TaskanaRole#ADMIN}
* @throws WorkbasketNotFoundException if either the source {@linkplain Workbasket} or any of the * @throws WorkbasketNotFoundException if either the source {@linkplain Workbasket} or any of the
* target {@linkplain Workbasket}s don't exist * target {@linkplain Workbasket}s don't exist
*/ */
void setDistributionTargets(String sourceWorkbasketId, List<String> targetWorkbasketIds) void setDistributionTargets(String sourceWorkbasketId, List<String> targetWorkbasketIds)
throws NotAuthorizedException, WorkbasketNotFoundException; throws WorkbasketNotFoundException, MismatchedRoleException,
MismatchedWorkbasketPermissionException;
// READ // READ
@ -172,12 +178,12 @@ public interface WorkbasketService {
* @param workbasketId the {@linkplain Workbasket#getId() id} of the referenced {@linkplain * @param workbasketId the {@linkplain Workbasket#getId() id} of the referenced {@linkplain
* Workbasket} * Workbasket}
* @return the distribution targets of the specified {@linkplain Workbasket} * @return the distribution targets of the specified {@linkplain Workbasket}
* @throws NotAuthorizedException if the current user has no {@linkplain WorkbasketPermission#READ * @throws MismatchedWorkbasketPermissionException if the current user has no {@linkplain
* READ permission} for the specified {@linkplain Workbasket} * WorkbasketPermission#READ READ permission} for the specified {@linkplain Workbasket}
* @throws WorkbasketNotFoundException if the {@linkplain Workbasket} doesn't exist * @throws WorkbasketNotFoundException if the {@linkplain Workbasket} doesn't exist
*/ */
List<WorkbasketSummary> getDistributionTargets(String workbasketId) List<WorkbasketSummary> getDistributionTargets(String workbasketId)
throws NotAuthorizedException, WorkbasketNotFoundException; throws WorkbasketNotFoundException, MismatchedWorkbasketPermissionException;
/** /**
* Returns the distribution targets for a given {@linkplain Workbasket}. * Returns the distribution targets for a given {@linkplain Workbasket}.
@ -187,12 +193,12 @@ public interface WorkbasketService {
* @param domain the {@linkplain Workbasket#getDomain() domain} of the referenced {@linkplain * @param domain the {@linkplain Workbasket#getDomain() domain} of the referenced {@linkplain
* Workbasket} * Workbasket}
* @return the distribution targets of the specified {@linkplain Workbasket} * @return the distribution targets of the specified {@linkplain Workbasket}
* @throws NotAuthorizedException if the current user has no {@linkplain WorkbasketPermission#READ * @throws MismatchedWorkbasketPermissionException if the current user has no {@linkplain
* READ permission} for the specified {@linkplain Workbasket} * WorkbasketPermission#READ READ permission} for the specified {@linkplain Workbasket}
* @throws WorkbasketNotFoundException if the {@linkplain Workbasket} doesn't exist * @throws WorkbasketNotFoundException if the {@linkplain Workbasket} doesn't exist
*/ */
List<WorkbasketSummary> getDistributionTargets(String workbasketKey, String domain) List<WorkbasketSummary> getDistributionTargets(String workbasketKey, String domain)
throws NotAuthorizedException, WorkbasketNotFoundException; throws WorkbasketNotFoundException, MismatchedWorkbasketPermissionException;
/** /**
* Returns the distribution sources for a given {@linkplain Workbasket}. * Returns the distribution sources for a given {@linkplain Workbasket}.
@ -200,12 +206,12 @@ public interface WorkbasketService {
* @param workbasketId the {@linkplain Workbasket#getId() id} of the referenced {@linkplain * @param workbasketId the {@linkplain Workbasket#getId() id} of the referenced {@linkplain
* Workbasket} * Workbasket}
* @return the workbaskets that are distribution sources of the specified {@linkplain Workbasket}. * @return the workbaskets that are distribution sources of the specified {@linkplain Workbasket}.
* @throws NotAuthorizedException if the current user has no {@linkplain WorkbasketPermission#READ * @throws MismatchedWorkbasketPermissionException if the current user has no {@linkplain
* READ permission} for the specified {@linkplain Workbasket} * WorkbasketPermission#READ READ permission} for the specified {@linkplain Workbasket}
* @throws WorkbasketNotFoundException if the {@linkplain Workbasket} doesn't exist * @throws WorkbasketNotFoundException if the {@linkplain Workbasket} doesn't exist
*/ */
List<WorkbasketSummary> getDistributionSources(String workbasketId) List<WorkbasketSummary> getDistributionSources(String workbasketId)
throws NotAuthorizedException, WorkbasketNotFoundException; throws WorkbasketNotFoundException, MismatchedWorkbasketPermissionException;
/** /**
* Returns the distribution sources for a given {@linkplain Workbasket}. * Returns the distribution sources for a given {@linkplain Workbasket}.
@ -215,12 +221,12 @@ public interface WorkbasketService {
* @param domain the {@linkplain Workbasket#getDomain() domain} of the referenced {@linkplain * @param domain the {@linkplain Workbasket#getDomain() domain} of the referenced {@linkplain
* Workbasket} * Workbasket}
* @return the workbaskets that are distribution sources of the specified {@linkplain Workbasket}. * @return the workbaskets that are distribution sources of the specified {@linkplain Workbasket}.
* @throws NotAuthorizedException if the current user has no {@linkplain WorkbasketPermission#READ * @throws MismatchedWorkbasketPermissionException if the current user has no {@linkplain
* READ permission} for the specified {@linkplain Workbasket} * WorkbasketPermission#READ READ permission} for the specified {@linkplain Workbasket}
* @throws WorkbasketNotFoundException if the {@linkplain Workbasket} doesn't exist * @throws WorkbasketNotFoundException if the {@linkplain Workbasket} doesn't exist
*/ */
List<WorkbasketSummary> getDistributionSources(String workbasketKey, String domain) List<WorkbasketSummary> getDistributionSources(String workbasketKey, String domain)
throws NotAuthorizedException, WorkbasketNotFoundException; throws WorkbasketNotFoundException, MismatchedWorkbasketPermissionException;
// UPDATE // UPDATE
@ -232,13 +238,16 @@ public interface WorkbasketService {
* Workbasket} * Workbasket}
* @param targetWorkbasketId the {@linkplain Workbasket#getId() id} of the target {@linkplain * @param targetWorkbasketId the {@linkplain Workbasket#getId() id} of the target {@linkplain
* Workbasket} * Workbasket}
* @throws NotAuthorizedException if the current user doesn't have {@linkplain * @throws MismatchedWorkbasketPermissionException if the current user doesn't have {@linkplain
* WorkbasketPermission#READ READ permission} for the source {@linkplain Workbasket}s * WorkbasketPermission#READ READ permission} for the source {@linkplain Workbasket}s
* @throws MismatchedRoleException if the current user is not member of {@linkplain
* TaskanaRole#BUSINESS_ADMIN} or {@linkplain TaskanaRole#ADMIN}
* @throws WorkbasketNotFoundException if either the source {@linkplain Workbasket} or the target * @throws WorkbasketNotFoundException if either the source {@linkplain Workbasket} or the target
* {@linkplain Workbasket} doesn't exist * {@linkplain Workbasket} doesn't exist
*/ */
void addDistributionTarget(String sourceWorkbasketId, String targetWorkbasketId) void addDistributionTarget(String sourceWorkbasketId, String targetWorkbasketId)
throws NotAuthorizedException, WorkbasketNotFoundException; throws WorkbasketNotFoundException, MismatchedRoleException,
MismatchedWorkbasketPermissionException;
// DELETE // DELETE
@ -250,11 +259,13 @@ public interface WorkbasketService {
* Workbasket} * Workbasket}
* @param targetWorkbasketId The {@linkplain Workbasket#getId() id} of the target {@linkplain * @param targetWorkbasketId The {@linkplain Workbasket#getId() id} of the target {@linkplain
* Workbasket} * Workbasket}
* @throws NotAuthorizedException If the current user doesn't have {@linkplain * @throws MismatchedWorkbasketPermissionException If the current user doesn't have {@linkplain
* WorkbasketPermission#READ READ permission} for the source {@linkplain Workbasket} * WorkbasketPermission#READ READ permission} for the source {@linkplain Workbasket}
* @throws MismatchedRoleException if the current user is not member of {@linkplain
* TaskanaRole#BUSINESS_ADMIN} or {@linkplain TaskanaRole#ADMIN}
*/ */
void removeDistributionTarget(String sourceWorkbasketId, String targetWorkbasketId) void removeDistributionTarget(String sourceWorkbasketId, String targetWorkbasketId)
throws NotAuthorizedException; throws MismatchedRoleException, MismatchedWorkbasketPermissionException;
// endregion // endregion
@ -281,7 +292,7 @@ public interface WorkbasketService {
* @param workbasketAccessItem the new {@linkplain WorkbasketAccessItem} * @param workbasketAccessItem the new {@linkplain WorkbasketAccessItem}
* @return the created {@linkplain WorkbasketAccessItem} * @return the created {@linkplain WorkbasketAccessItem}
* @throws InvalidArgumentException if the preconditions don't match the required ones. * @throws InvalidArgumentException if the preconditions don't match the required ones.
* @throws NotAuthorizedException if the current user is not member of role {@linkplain * @throws MismatchedRoleException if the current user is not member of role {@linkplain
* pro.taskana.common.api.TaskanaRole#ADMIN admin} or {@linkplain * pro.taskana.common.api.TaskanaRole#ADMIN admin} or {@linkplain
* pro.taskana.common.api.TaskanaRole#BUSINESS_ADMIN business-admin} * pro.taskana.common.api.TaskanaRole#BUSINESS_ADMIN business-admin}
* @throws WorkbasketNotFoundException if the {@linkplain WorkbasketAccessItem} refers to a not * @throws WorkbasketNotFoundException if the {@linkplain WorkbasketAccessItem} refers to a not
@ -291,8 +302,8 @@ public interface WorkbasketService {
* and {@linkplain Workbasket} * and {@linkplain Workbasket}
*/ */
WorkbasketAccessItem createWorkbasketAccessItem(WorkbasketAccessItem workbasketAccessItem) WorkbasketAccessItem createWorkbasketAccessItem(WorkbasketAccessItem workbasketAccessItem)
throws InvalidArgumentException, NotAuthorizedException, WorkbasketNotFoundException, throws InvalidArgumentException, WorkbasketNotFoundException,
WorkbasketAccessItemAlreadyExistException; WorkbasketAccessItemAlreadyExistException, MismatchedRoleException;
/** /**
* Setting up the new {@linkplain WorkbasketAccessItem}s for a {@linkplain Workbasket}. Already * Setting up the new {@linkplain WorkbasketAccessItem}s for a {@linkplain Workbasket}. Already
@ -312,9 +323,9 @@ public interface WorkbasketService {
* stored ones. * stored ones.
* @throws InvalidArgumentException will be thrown when the parameter {@code wbAccessItems} is * @throws InvalidArgumentException will be thrown when the parameter {@code wbAccessItems} is
* NULL or member doesn't match the preconditions * NULL or member doesn't match the preconditions
* @throws NotAuthorizedException if the current user is not member of role {@linkplain * @throws MismatchedRoleException if the current user is not member of {@linkplain
* pro.taskana.common.api.TaskanaRole#ADMIN admin} or {@linkplain * TaskanaRole#BUSINESS_ADMIN} or {@linkplain TaskanaRole#ADMIN}
* pro.taskana.common.api.TaskanaRole#BUSINESS_ADMIN business-admin} * @throws MismatchedWorkbasketPermissionException This is never thrown
* @throws WorkbasketAccessItemAlreadyExistException if {@code wbAccessItems} contains multiple * @throws WorkbasketAccessItemAlreadyExistException if {@code wbAccessItems} contains multiple
* {@linkplain WorkbasketAccessItem} with the same {@linkplain * {@linkplain WorkbasketAccessItem} with the same {@linkplain
* WorkbasketAccessItem#getAccessId() accessId}. * WorkbasketAccessItem#getAccessId() accessId}.
@ -322,8 +333,9 @@ public interface WorkbasketService {
* given {@linkplain Workbasket#getId() id}. * given {@linkplain Workbasket#getId() id}.
*/ */
void setWorkbasketAccessItems(String workbasketId, List<WorkbasketAccessItem> wbAccessItems) void setWorkbasketAccessItems(String workbasketId, List<WorkbasketAccessItem> wbAccessItems)
throws InvalidArgumentException, NotAuthorizedException, throws InvalidArgumentException, WorkbasketAccessItemAlreadyExistException,
WorkbasketAccessItemAlreadyExistException, WorkbasketNotFoundException; WorkbasketNotFoundException, MismatchedRoleException,
MismatchedWorkbasketPermissionException;
// READ // READ
@ -332,12 +344,12 @@ public interface WorkbasketService {
* *
* @param workbasketId the {@linkplain Workbasket#getId() id} of the {@linkplain Workbasket} * @param workbasketId the {@linkplain Workbasket#getId() id} of the {@linkplain Workbasket}
* @return List of {@linkplain WorkbasketAccessItem}s for the {@linkplain Workbasket} * @return List of {@linkplain WorkbasketAccessItem}s for the {@linkplain Workbasket}
* @throws NotAuthorizedException if the current user is not member of role {@linkplain * @throws MismatchedRoleException if the current user is not member of role {@linkplain
* pro.taskana.common.api.TaskanaRole#BUSINESS_ADMIN} or {@linkplain * pro.taskana.common.api.TaskanaRole#BUSINESS_ADMIN} or {@linkplain
* pro.taskana.common.api.TaskanaRole#ADMIN} * pro.taskana.common.api.TaskanaRole#ADMIN}
*/ */
List<WorkbasketAccessItem> getWorkbasketAccessItems(String workbasketId) List<WorkbasketAccessItem> getWorkbasketAccessItems(String workbasketId)
throws NotAuthorizedException; throws MismatchedRoleException;
// UPDATE // UPDATE
@ -349,12 +361,12 @@ public interface WorkbasketService {
* @throws InvalidArgumentException if {@linkplain WorkbasketAccessItem#getAccessId() accessId} or * @throws InvalidArgumentException if {@linkplain WorkbasketAccessItem#getAccessId() accessId} or
* {@linkplain WorkbasketAccessItem#getWorkbasketId() workbasketId} is changed in the * {@linkplain WorkbasketAccessItem#getWorkbasketId() workbasketId} is changed in the
* {@linkplain WorkbasketAccessItem} * {@linkplain WorkbasketAccessItem}
* @throws NotAuthorizedException if the current user is not member of role {@linkplain * @throws MismatchedRoleException if the current user is not member of role {@linkplain
* pro.taskana.common.api.TaskanaRole#ADMIN admin} or {@linkplain * pro.taskana.common.api.TaskanaRole#ADMIN admin} or {@linkplain
* pro.taskana.common.api.TaskanaRole#BUSINESS_ADMIN business-admin} * pro.taskana.common.api.TaskanaRole#BUSINESS_ADMIN business-admin}
*/ */
WorkbasketAccessItem updateWorkbasketAccessItem(WorkbasketAccessItem workbasketAccessItem) WorkbasketAccessItem updateWorkbasketAccessItem(WorkbasketAccessItem workbasketAccessItem)
throws InvalidArgumentException, NotAuthorizedException; throws InvalidArgumentException, MismatchedRoleException;
// DELETE // DELETE
@ -363,22 +375,22 @@ public interface WorkbasketService {
* *
* @param id the {@linkplain WorkbasketAccessItem#getId() id} of the {@linkplain * @param id the {@linkplain WorkbasketAccessItem#getId() id} of the {@linkplain
* WorkbasketAccessItem} to be deleted * WorkbasketAccessItem} to be deleted
* @throws NotAuthorizedException if the current user is not member of role {@linkplain * @throws MismatchedRoleException if the current user is not member of role {@linkplain
* pro.taskana.common.api.TaskanaRole#ADMIN admin} or {@linkplain * pro.taskana.common.api.TaskanaRole#ADMIN admin} or {@linkplain
* pro.taskana.common.api.TaskanaRole#BUSINESS_ADMIN business-admin} * pro.taskana.common.api.TaskanaRole#BUSINESS_ADMIN business-admin}
*/ */
void deleteWorkbasketAccessItem(String id) throws NotAuthorizedException; void deleteWorkbasketAccessItem(String id) throws MismatchedRoleException;
/** /**
* Deletes all {@linkplain WorkbasketAccessItem}s using the given {@linkplain * Deletes all {@linkplain WorkbasketAccessItem}s using the given {@linkplain
* WorkbasketAccessItem#getAccessId()}. * WorkbasketAccessItem#getAccessId()}.
* *
* @param accessId {@linkplain User#getId() id} of a taskana-{@linkplain User}. * @param accessId {@linkplain User#getId() id} of a taskana-{@linkplain User}.
* @throws NotAuthorizedException if the current user is not member of role {@linkplain * @throws MismatchedRoleException if the current user is not member of role {@linkplain
* pro.taskana.common.api.TaskanaRole#ADMIN admin} or {@linkplain * pro.taskana.common.api.TaskanaRole#ADMIN admin} or {@linkplain
* pro.taskana.common.api.TaskanaRole#BUSINESS_ADMIN business-admin} * pro.taskana.common.api.TaskanaRole#BUSINESS_ADMIN business-admin}
*/ */
void deleteWorkbasketAccessItemsForAccessId(String accessId) throws NotAuthorizedException; void deleteWorkbasketAccessItemsForAccessId(String accessId) throws MismatchedRoleException;
// endregion // endregion
@ -394,11 +406,11 @@ 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 {@linkplain WorkbasketAccessItemQuery} * @return a {@linkplain WorkbasketAccessItemQuery}
* @throws NotAuthorizedException if the current user is not member of role {@linkplain * @throws MismatchedRoleException if the current user is not member of role {@linkplain
* pro.taskana.common.api.TaskanaRole#ADMIN admin} or {@linkplain * pro.taskana.common.api.TaskanaRole#ADMIN admin} or {@linkplain
* pro.taskana.common.api.TaskanaRole#BUSINESS_ADMIN business-admin} * pro.taskana.common.api.TaskanaRole#BUSINESS_ADMIN business-admin}
*/ */
WorkbasketAccessItemQuery createWorkbasketAccessItemQuery() throws NotAuthorizedException; WorkbasketAccessItemQuery createWorkbasketAccessItemQuery() throws MismatchedRoleException;
// endregion // endregion
// region Permission and Authorization // region Permission and Authorization
@ -425,13 +437,13 @@ public interface WorkbasketService {
* want to access * want to access
* @param permission the needed {@linkplain WorkbasketPermission}; if more than one {@linkplain * @param permission the needed {@linkplain WorkbasketPermission}; if more than one {@linkplain
* WorkbasketPermission permission} is specified, the current user needs all of them * WorkbasketPermission permission} is specified, the current user needs all of them
* @throws NotAuthorizedException if the current user has not the requested authorization for the * @throws MismatchedWorkbasketPermissionException if the current user has not the requested
* specified {@linkplain Workbasket} * authorization for the specified {@linkplain Workbasket}
* @throws WorkbasketNotFoundException if the {@linkplain Workbasket} cannot be found for the * @throws WorkbasketNotFoundException if the {@linkplain Workbasket} cannot be found for the
* given {@linkplain Workbasket#getId() id}. * given {@linkplain Workbasket#getId() id}.
*/ */
void checkAuthorization(String workbasketId, WorkbasketPermission... permission) void checkAuthorization(String workbasketId, WorkbasketPermission... permission)
throws NotAuthorizedException, WorkbasketNotFoundException; throws WorkbasketNotFoundException, MismatchedWorkbasketPermissionException;
/** /**
* This method checks the authorization for the actual User. * This method checks the authorization for the actual User.
@ -442,13 +454,13 @@ public interface WorkbasketService {
* want to access * want to access
* @param permission the needed {@linkplain WorkbasketPermission}; if more than one {@linkplain * @param permission the needed {@linkplain WorkbasketPermission}; if more than one {@linkplain
* WorkbasketPermission permission} is specified, the current user needs all of them. * WorkbasketPermission permission} is specified, the current user needs all of them.
* @throws NotAuthorizedException if the current user has not the requested {@linkplain * @throws MismatchedWorkbasketPermissionException if the current user has not the requested
* WorkbasketPermission permission} for the specified {@linkplain Workbasket} * {@linkplain WorkbasketPermission permission} for the specified {@linkplain Workbasket}
* @throws WorkbasketNotFoundException if no {@linkplain Workbasket} can be found for the given * @throws WorkbasketNotFoundException if no {@linkplain Workbasket} can be found for the given
* {@linkplain Workbasket#getKey() key} and {@linkplain Workbasket#getDomain() domain} values. * {@linkplain Workbasket#getKey() key} and {@linkplain Workbasket#getDomain() domain} values.
*/ */
void checkAuthorization(String workbasketKey, String domain, WorkbasketPermission... permission) void checkAuthorization(String workbasketKey, String domain, WorkbasketPermission... permission)
throws NotAuthorizedException, WorkbasketNotFoundException; throws WorkbasketNotFoundException, MismatchedWorkbasketPermissionException;
// endregion // endregion

View File

@ -3,7 +3,7 @@ package pro.taskana.workbasket.api.exceptions;
import java.util.Arrays; import java.util.Arrays;
import pro.taskana.common.api.exceptions.ErrorCode; import pro.taskana.common.api.exceptions.ErrorCode;
import pro.taskana.common.api.exceptions.NotAuthorizedException; import pro.taskana.common.api.exceptions.TaskanaException;
import pro.taskana.common.internal.util.MapCreator; import pro.taskana.common.internal.util.MapCreator;
import pro.taskana.workbasket.api.WorkbasketPermission; import pro.taskana.workbasket.api.WorkbasketPermission;
import pro.taskana.workbasket.api.models.Workbasket; import pro.taskana.workbasket.api.models.Workbasket;
@ -12,7 +12,7 @@ import pro.taskana.workbasket.api.models.Workbasket;
* This exception is thrown when the current user does not have a certain {@linkplain * This exception is thrown when the current user does not have a certain {@linkplain
* WorkbasketPermission permission} on a {@linkplain Workbasket}. * WorkbasketPermission permission} on a {@linkplain Workbasket}.
*/ */
public class MismatchedWorkbasketPermissionException extends NotAuthorizedException { public class MismatchedWorkbasketPermissionException extends TaskanaException {
public static final String ERROR_KEY_KEY_DOMAIN = "WORKBASKET_WITH_KEY_MISMATCHED_PERMISSION"; public static final String ERROR_KEY_KEY_DOMAIN = "WORKBASKET_WITH_KEY_MISMATCHED_PERMISSION";
public static final String ERROR_KEY_ID = "WORKBASKET_WITH_ID_MISMATCHED_PERMISSION"; public static final String ERROR_KEY_ID = "WORKBASKET_WITH_ID_MISMATCHED_PERMISSION";

View File

@ -1,12 +1,12 @@
package pro.taskana.workbasket.api.exceptions; package pro.taskana.workbasket.api.exceptions;
import pro.taskana.common.api.exceptions.ErrorCode; import pro.taskana.common.api.exceptions.ErrorCode;
import pro.taskana.common.api.exceptions.NotFoundException; import pro.taskana.common.api.exceptions.TaskanaException;
import pro.taskana.common.internal.util.MapCreator; import pro.taskana.common.internal.util.MapCreator;
import pro.taskana.workbasket.api.models.Workbasket; import pro.taskana.workbasket.api.models.Workbasket;
/** This exception is thrown when a specific {@linkplain Workbasket} is not in the database. */ /** This exception is thrown when a specific {@linkplain Workbasket} is not in the database. */
public class WorkbasketNotFoundException extends NotFoundException { public class WorkbasketNotFoundException extends TaskanaException {
public static final String ERROR_KEY_ID = "WORKBASKET_WITH_ID_NOT_FOUND"; public static final String ERROR_KEY_ID = "WORKBASKET_WITH_ID_NOT_FOUND";
public static final String ERROR_KEY_KEY_DOMAIN = "WORKBASKET_WITH_KEY_NOT_FOUND"; public static final String ERROR_KEY_KEY_DOMAIN = "WORKBASKET_WITH_KEY_NOT_FOUND";

View File

@ -10,7 +10,7 @@ import pro.taskana.TaskanaConfiguration;
import pro.taskana.common.api.TaskanaRole; import pro.taskana.common.api.TaskanaRole;
import pro.taskana.common.api.TimeInterval; import pro.taskana.common.api.TimeInterval;
import pro.taskana.common.api.exceptions.InvalidArgumentException; import pro.taskana.common.api.exceptions.InvalidArgumentException;
import pro.taskana.common.api.exceptions.NotAuthorizedException; import pro.taskana.common.api.exceptions.MismatchedRoleException;
import pro.taskana.common.api.exceptions.SystemException; import pro.taskana.common.api.exceptions.SystemException;
import pro.taskana.common.api.exceptions.TaskanaRuntimeException; import pro.taskana.common.api.exceptions.TaskanaRuntimeException;
import pro.taskana.common.internal.InternalTaskanaEngine; import pro.taskana.common.internal.InternalTaskanaEngine;
@ -167,7 +167,7 @@ public class WorkbasketQueryImpl implements WorkbasketQuery {
@Override @Override
public WorkbasketQuery accessIdsHavePermissions( public WorkbasketQuery accessIdsHavePermissions(
List<WorkbasketPermission> permissions, String... accessIds) List<WorkbasketPermission> permissions, String... accessIds)
throws InvalidArgumentException, NotAuthorizedException { throws InvalidArgumentException, MismatchedRoleException {
taskanaEngine taskanaEngine
.getEngine() .getEngine()
.checkRoleMembership(TaskanaRole.ADMIN, TaskanaRole.BUSINESS_ADMIN, TaskanaRole.TASK_ADMIN); .checkRoleMembership(TaskanaRole.ADMIN, TaskanaRole.BUSINESS_ADMIN, TaskanaRole.TASK_ADMIN);

View File

@ -21,7 +21,7 @@ import pro.taskana.common.api.TaskanaRole;
import pro.taskana.common.api.exceptions.ConcurrencyException; import pro.taskana.common.api.exceptions.ConcurrencyException;
import pro.taskana.common.api.exceptions.DomainNotFoundException; import pro.taskana.common.api.exceptions.DomainNotFoundException;
import pro.taskana.common.api.exceptions.InvalidArgumentException; import pro.taskana.common.api.exceptions.InvalidArgumentException;
import pro.taskana.common.api.exceptions.NotAuthorizedException; import pro.taskana.common.api.exceptions.MismatchedRoleException;
import pro.taskana.common.api.exceptions.TaskanaException; import pro.taskana.common.api.exceptions.TaskanaException;
import pro.taskana.common.internal.InternalTaskanaEngine; import pro.taskana.common.internal.InternalTaskanaEngine;
import pro.taskana.common.internal.util.IdGenerator; import pro.taskana.common.internal.util.IdGenerator;
@ -82,7 +82,7 @@ public class WorkbasketServiceImpl implements WorkbasketService {
@Override @Override
public Workbasket getWorkbasket(String workbasketId) public Workbasket getWorkbasket(String workbasketId)
throws WorkbasketNotFoundException, NotAuthorizedException { throws WorkbasketNotFoundException, MismatchedWorkbasketPermissionException {
Workbasket result; Workbasket result;
try { try {
taskanaEngine.openConnection(); taskanaEngine.openConnection();
@ -109,7 +109,7 @@ public class WorkbasketServiceImpl implements WorkbasketService {
@Override @Override
public Workbasket getWorkbasket(String workbasketKey, String domain) public Workbasket getWorkbasket(String workbasketKey, String domain)
throws WorkbasketNotFoundException, NotAuthorizedException { throws WorkbasketNotFoundException, MismatchedWorkbasketPermissionException {
if (!taskanaEngine if (!taskanaEngine
.getEngine() .getEngine()
.isUserInRole( .isUserInRole(
@ -132,8 +132,8 @@ public class WorkbasketServiceImpl implements WorkbasketService {
@Override @Override
public Workbasket createWorkbasket(Workbasket newWorkbasket) public Workbasket createWorkbasket(Workbasket newWorkbasket)
throws InvalidArgumentException, NotAuthorizedException, WorkbasketAlreadyExistException, throws InvalidArgumentException, WorkbasketAlreadyExistException, DomainNotFoundException,
DomainNotFoundException { MismatchedRoleException {
taskanaEngine.getEngine().checkRoleMembership(TaskanaRole.BUSINESS_ADMIN, TaskanaRole.ADMIN); taskanaEngine.getEngine().checkRoleMembership(TaskanaRole.BUSINESS_ADMIN, TaskanaRole.ADMIN);
WorkbasketImpl workbasket = (WorkbasketImpl) newWorkbasket; WorkbasketImpl workbasket = (WorkbasketImpl) newWorkbasket;
@ -179,8 +179,8 @@ public class WorkbasketServiceImpl implements WorkbasketService {
@Override @Override
public Workbasket updateWorkbasket(Workbasket workbasketToUpdate) public Workbasket updateWorkbasket(Workbasket workbasketToUpdate)
throws InvalidArgumentException, NotAuthorizedException, WorkbasketNotFoundException, throws InvalidArgumentException, WorkbasketNotFoundException, ConcurrencyException,
ConcurrencyException { MismatchedRoleException, MismatchedWorkbasketPermissionException {
taskanaEngine.getEngine().checkRoleMembership(TaskanaRole.BUSINESS_ADMIN, TaskanaRole.ADMIN); taskanaEngine.getEngine().checkRoleMembership(TaskanaRole.BUSINESS_ADMIN, TaskanaRole.ADMIN);
WorkbasketImpl workbasketImplToUpdate = (WorkbasketImpl) workbasketToUpdate; WorkbasketImpl workbasketImplToUpdate = (WorkbasketImpl) workbasketToUpdate;
@ -251,8 +251,8 @@ public class WorkbasketServiceImpl implements WorkbasketService {
@Override @Override
public WorkbasketAccessItem createWorkbasketAccessItem(WorkbasketAccessItem workbasketAccessItem) public WorkbasketAccessItem createWorkbasketAccessItem(WorkbasketAccessItem workbasketAccessItem)
throws InvalidArgumentException, NotAuthorizedException, WorkbasketNotFoundException, throws InvalidArgumentException, WorkbasketNotFoundException,
WorkbasketAccessItemAlreadyExistException { WorkbasketAccessItemAlreadyExistException, MismatchedRoleException {
taskanaEngine.getEngine().checkRoleMembership(TaskanaRole.BUSINESS_ADMIN, TaskanaRole.ADMIN); taskanaEngine.getEngine().checkRoleMembership(TaskanaRole.BUSINESS_ADMIN, TaskanaRole.ADMIN);
WorkbasketAccessItemImpl accessItem = (WorkbasketAccessItemImpl) workbasketAccessItem; WorkbasketAccessItemImpl accessItem = (WorkbasketAccessItemImpl) workbasketAccessItem;
@ -320,7 +320,7 @@ public class WorkbasketServiceImpl implements WorkbasketService {
@Override @Override
public WorkbasketAccessItem updateWorkbasketAccessItem(WorkbasketAccessItem workbasketAccessItem) public WorkbasketAccessItem updateWorkbasketAccessItem(WorkbasketAccessItem workbasketAccessItem)
throws InvalidArgumentException, NotAuthorizedException { throws InvalidArgumentException, MismatchedRoleException {
taskanaEngine.getEngine().checkRoleMembership(TaskanaRole.BUSINESS_ADMIN, TaskanaRole.ADMIN); taskanaEngine.getEngine().checkRoleMembership(TaskanaRole.BUSINESS_ADMIN, TaskanaRole.ADMIN);
WorkbasketAccessItemImpl accessItem = (WorkbasketAccessItemImpl) workbasketAccessItem; WorkbasketAccessItemImpl accessItem = (WorkbasketAccessItemImpl) workbasketAccessItem;
@ -364,7 +364,7 @@ public class WorkbasketServiceImpl implements WorkbasketService {
} }
@Override @Override
public void deleteWorkbasketAccessItem(String accessItemId) throws NotAuthorizedException { public void deleteWorkbasketAccessItem(String accessItemId) throws MismatchedRoleException {
taskanaEngine.getEngine().checkRoleMembership(TaskanaRole.BUSINESS_ADMIN, TaskanaRole.ADMIN); taskanaEngine.getEngine().checkRoleMembership(TaskanaRole.BUSINESS_ADMIN, TaskanaRole.ADMIN);
try { try {
taskanaEngine.openConnection(); taskanaEngine.openConnection();
@ -403,7 +403,7 @@ public class WorkbasketServiceImpl implements WorkbasketService {
@Override @Override
public void checkAuthorization(String workbasketId, WorkbasketPermission... requestedPermissions) public void checkAuthorization(String workbasketId, WorkbasketPermission... requestedPermissions)
throws NotAuthorizedException, WorkbasketNotFoundException { throws WorkbasketNotFoundException, MismatchedWorkbasketPermissionException {
try { try {
taskanaEngine.openConnection(); taskanaEngine.openConnection();
@ -438,7 +438,7 @@ public class WorkbasketServiceImpl implements WorkbasketService {
@Override @Override
public void checkAuthorization( public void checkAuthorization(
String workbasketKey, String domain, WorkbasketPermission... requestedPermissions) String workbasketKey, String domain, WorkbasketPermission... requestedPermissions)
throws NotAuthorizedException, WorkbasketNotFoundException { throws WorkbasketNotFoundException, MismatchedWorkbasketPermissionException {
try { try {
taskanaEngine.openConnection(); taskanaEngine.openConnection();
@ -473,7 +473,7 @@ public class WorkbasketServiceImpl implements WorkbasketService {
@Override @Override
public List<WorkbasketAccessItem> getWorkbasketAccessItems(String workbasketId) public List<WorkbasketAccessItem> getWorkbasketAccessItems(String workbasketId)
throws NotAuthorizedException { throws MismatchedRoleException {
taskanaEngine.getEngine().checkRoleMembership(TaskanaRole.BUSINESS_ADMIN, TaskanaRole.ADMIN); taskanaEngine.getEngine().checkRoleMembership(TaskanaRole.BUSINESS_ADMIN, TaskanaRole.ADMIN);
List<WorkbasketAccessItem> result = new ArrayList<>(); List<WorkbasketAccessItem> result = new ArrayList<>();
try { try {
@ -490,8 +490,9 @@ public class WorkbasketServiceImpl implements WorkbasketService {
@Override @Override
public void setWorkbasketAccessItems( public void setWorkbasketAccessItems(
String workbasketId, List<WorkbasketAccessItem> wbAccessItems) String workbasketId, List<WorkbasketAccessItem> wbAccessItems)
throws NotAuthorizedException, WorkbasketAccessItemAlreadyExistException, throws WorkbasketAccessItemAlreadyExistException, InvalidArgumentException,
InvalidArgumentException, WorkbasketNotFoundException { WorkbasketNotFoundException, MismatchedRoleException,
MismatchedWorkbasketPermissionException {
taskanaEngine.getEngine().checkRoleMembership(TaskanaRole.BUSINESS_ADMIN, TaskanaRole.ADMIN); taskanaEngine.getEngine().checkRoleMembership(TaskanaRole.BUSINESS_ADMIN, TaskanaRole.ADMIN);
Set<WorkbasketAccessItemImpl> accessItems = Set<WorkbasketAccessItemImpl> accessItems =
@ -537,7 +538,8 @@ public class WorkbasketServiceImpl implements WorkbasketService {
} }
@Override @Override
public WorkbasketAccessItemQuery createWorkbasketAccessItemQuery() throws NotAuthorizedException { public WorkbasketAccessItemQuery createWorkbasketAccessItemQuery()
throws MismatchedRoleException {
taskanaEngine.getEngine().checkRoleMembership(TaskanaRole.ADMIN, TaskanaRole.BUSINESS_ADMIN); taskanaEngine.getEngine().checkRoleMembership(TaskanaRole.ADMIN, TaskanaRole.BUSINESS_ADMIN);
return new WorkbasketAccessItemQueryImpl(this.taskanaEngine); return new WorkbasketAccessItemQueryImpl(this.taskanaEngine);
} }
@ -560,7 +562,7 @@ public class WorkbasketServiceImpl implements WorkbasketService {
@Override @Override
public List<WorkbasketSummary> getDistributionTargets(String workbasketId) public List<WorkbasketSummary> getDistributionTargets(String workbasketId)
throws NotAuthorizedException, WorkbasketNotFoundException { throws WorkbasketNotFoundException, MismatchedWorkbasketPermissionException {
List<WorkbasketSummary> result = new ArrayList<>(); List<WorkbasketSummary> result = new ArrayList<>();
try { try {
taskanaEngine.openConnection(); taskanaEngine.openConnection();
@ -582,7 +584,7 @@ public class WorkbasketServiceImpl implements WorkbasketService {
@Override @Override
public List<WorkbasketSummary> getDistributionTargets(String workbasketKey, String domain) public List<WorkbasketSummary> getDistributionTargets(String workbasketKey, String domain)
throws NotAuthorizedException, WorkbasketNotFoundException { throws WorkbasketNotFoundException, MismatchedWorkbasketPermissionException {
List<WorkbasketSummary> result = new ArrayList<>(); List<WorkbasketSummary> result = new ArrayList<>();
try { try {
@ -605,7 +607,8 @@ public class WorkbasketServiceImpl implements WorkbasketService {
@Override @Override
public void setDistributionTargets(String sourceWorkbasketId, List<String> targetWorkbasketIds) public void setDistributionTargets(String sourceWorkbasketId, List<String> targetWorkbasketIds)
throws WorkbasketNotFoundException, NotAuthorizedException { throws WorkbasketNotFoundException, MismatchedRoleException,
MismatchedWorkbasketPermissionException {
taskanaEngine.getEngine().checkRoleMembership(TaskanaRole.BUSINESS_ADMIN, TaskanaRole.ADMIN); taskanaEngine.getEngine().checkRoleMembership(TaskanaRole.BUSINESS_ADMIN, TaskanaRole.ADMIN);
try { try {
@ -666,7 +669,8 @@ public class WorkbasketServiceImpl implements WorkbasketService {
@Override @Override
public void addDistributionTarget(String sourceWorkbasketId, String targetWorkbasketId) public void addDistributionTarget(String sourceWorkbasketId, String targetWorkbasketId)
throws NotAuthorizedException, WorkbasketNotFoundException { throws WorkbasketNotFoundException, MismatchedRoleException,
MismatchedWorkbasketPermissionException {
taskanaEngine.getEngine().checkRoleMembership(TaskanaRole.BUSINESS_ADMIN, TaskanaRole.ADMIN); taskanaEngine.getEngine().checkRoleMembership(TaskanaRole.BUSINESS_ADMIN, TaskanaRole.ADMIN);
try { try {
@ -717,7 +721,7 @@ public class WorkbasketServiceImpl implements WorkbasketService {
@Override @Override
public void removeDistributionTarget(String sourceWorkbasketId, String targetWorkbasketId) public void removeDistributionTarget(String sourceWorkbasketId, String targetWorkbasketId)
throws NotAuthorizedException { throws MismatchedRoleException, MismatchedWorkbasketPermissionException {
taskanaEngine.getEngine().checkRoleMembership(TaskanaRole.BUSINESS_ADMIN, TaskanaRole.ADMIN); taskanaEngine.getEngine().checkRoleMembership(TaskanaRole.BUSINESS_ADMIN, TaskanaRole.ADMIN);
try { try {
@ -782,8 +786,8 @@ public class WorkbasketServiceImpl implements WorkbasketService {
@Override @Override
public boolean deleteWorkbasket(String workbasketId) public boolean deleteWorkbasket(String workbasketId)
throws NotAuthorizedException, WorkbasketNotFoundException, WorkbasketInUseException, throws WorkbasketNotFoundException, WorkbasketInUseException, InvalidArgumentException,
InvalidArgumentException { MismatchedRoleException, MismatchedWorkbasketPermissionException {
taskanaEngine.getEngine().checkRoleMembership(TaskanaRole.BUSINESS_ADMIN, TaskanaRole.ADMIN); taskanaEngine.getEngine().checkRoleMembership(TaskanaRole.BUSINESS_ADMIN, TaskanaRole.ADMIN);
validateId(workbasketId); validateId(workbasketId);
@ -843,7 +847,7 @@ public class WorkbasketServiceImpl implements WorkbasketService {
} }
public BulkOperationResults<String, TaskanaException> deleteWorkbaskets( public BulkOperationResults<String, TaskanaException> deleteWorkbaskets(
List<String> workbasketsIds) throws NotAuthorizedException, InvalidArgumentException { List<String> workbasketsIds) throws InvalidArgumentException, MismatchedRoleException {
taskanaEngine.getEngine().checkRoleMembership(TaskanaRole.BUSINESS_ADMIN, TaskanaRole.ADMIN); taskanaEngine.getEngine().checkRoleMembership(TaskanaRole.BUSINESS_ADMIN, TaskanaRole.ADMIN);
@ -876,7 +880,7 @@ public class WorkbasketServiceImpl implements WorkbasketService {
@Override @Override
public List<WorkbasketSummary> getDistributionSources(String workbasketId) public List<WorkbasketSummary> getDistributionSources(String workbasketId)
throws NotAuthorizedException, WorkbasketNotFoundException { throws WorkbasketNotFoundException, MismatchedWorkbasketPermissionException {
List<WorkbasketSummary> result = new ArrayList<>(); List<WorkbasketSummary> result = new ArrayList<>();
try { try {
taskanaEngine.openConnection(); taskanaEngine.openConnection();
@ -896,7 +900,7 @@ public class WorkbasketServiceImpl implements WorkbasketService {
@Override @Override
public List<WorkbasketSummary> getDistributionSources(String workbasketKey, String domain) public List<WorkbasketSummary> getDistributionSources(String workbasketKey, String domain)
throws NotAuthorizedException, WorkbasketNotFoundException { throws WorkbasketNotFoundException, MismatchedWorkbasketPermissionException {
List<WorkbasketSummary> result = new ArrayList<>(); List<WorkbasketSummary> result = new ArrayList<>();
try { try {
@ -917,7 +921,7 @@ public class WorkbasketServiceImpl implements WorkbasketService {
@Override @Override
public void deleteWorkbasketAccessItemsForAccessId(String accessId) public void deleteWorkbasketAccessItemsForAccessId(String accessId)
throws NotAuthorizedException { throws MismatchedRoleException {
taskanaEngine.getEngine().checkRoleMembership(TaskanaRole.BUSINESS_ADMIN, TaskanaRole.ADMIN); taskanaEngine.getEngine().checkRoleMembership(TaskanaRole.BUSINESS_ADMIN, TaskanaRole.ADMIN);
try { try {
taskanaEngine.openConnection(); taskanaEngine.openConnection();
@ -1111,7 +1115,7 @@ public class WorkbasketServiceImpl implements WorkbasketService {
} }
private void markWorkbasketForDeletion(String workbasketId) private void markWorkbasketForDeletion(String workbasketId)
throws NotAuthorizedException, InvalidArgumentException { throws InvalidArgumentException, MismatchedRoleException {
taskanaEngine.getEngine().checkRoleMembership(TaskanaRole.BUSINESS_ADMIN, TaskanaRole.ADMIN); taskanaEngine.getEngine().checkRoleMembership(TaskanaRole.BUSINESS_ADMIN, TaskanaRole.ADMIN);
try { try {
taskanaEngine.openConnection(); taskanaEngine.openConnection();

View File

@ -9,7 +9,7 @@ import pro.taskana.common.api.BulkOperationResults;
import pro.taskana.common.api.ScheduledJob; import pro.taskana.common.api.ScheduledJob;
import pro.taskana.common.api.TaskanaEngine; import pro.taskana.common.api.TaskanaEngine;
import pro.taskana.common.api.exceptions.InvalidArgumentException; import pro.taskana.common.api.exceptions.InvalidArgumentException;
import pro.taskana.common.api.exceptions.NotAuthorizedException; import pro.taskana.common.api.exceptions.MismatchedRoleException;
import pro.taskana.common.api.exceptions.SystemException; import pro.taskana.common.api.exceptions.SystemException;
import pro.taskana.common.api.exceptions.TaskanaException; import pro.taskana.common.api.exceptions.TaskanaException;
import pro.taskana.common.internal.JobServiceImpl; import pro.taskana.common.internal.JobServiceImpl;
@ -91,7 +91,7 @@ public class WorkbasketCleanupJob extends AbstractTaskanaJob {
} }
private int deleteWorkbaskets(List<String> workbasketsToBeDeleted) private int deleteWorkbaskets(List<String> workbasketsToBeDeleted)
throws InvalidArgumentException, NotAuthorizedException { throws InvalidArgumentException, MismatchedRoleException {
BulkOperationResults<String, TaskanaException> results = BulkOperationResults<String, TaskanaException> results =
taskanaEngineImpl.getWorkbasketService().deleteWorkbaskets(workbasketsToBeDeleted); taskanaEngineImpl.getWorkbasketService().deleteWorkbaskets(workbasketsToBeDeleted);

View File

@ -8,7 +8,7 @@ import org.assertj.core.api.ThrowableAssert.ThrowingCallable;
import org.junit.jupiter.api.Test; import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith; import org.junit.jupiter.api.extension.ExtendWith;
import pro.taskana.common.api.exceptions.NotAuthorizedException; import pro.taskana.common.api.exceptions.MismatchedRoleException;
import pro.taskana.common.test.security.JaasExtension; import pro.taskana.common.test.security.JaasExtension;
import pro.taskana.common.test.security.WithAccessId; import pro.taskana.common.test.security.WithAccessId;
import pro.taskana.monitor.api.MonitorService; import pro.taskana.monitor.api.MonitorService;
@ -27,7 +27,7 @@ class GetCustomAttributeValuesForReportAccTest extends AbstractReportAccTest {
MONITOR_SERVICE MONITOR_SERVICE
.createWorkbasketReportBuilder() .createWorkbasketReportBuilder()
.listCustomAttributeValuesForCustomAttributeName(TaskCustomField.CUSTOM_2); .listCustomAttributeValuesForCustomAttributeName(TaskCustomField.CUSTOM_2);
assertThatThrownBy(call).isInstanceOf(NotAuthorizedException.class); assertThatThrownBy(call).isInstanceOf(MismatchedRoleException.class);
} }
@WithAccessId(user = "monitor") @WithAccessId(user = "monitor")

View File

@ -17,7 +17,7 @@ import org.junit.jupiter.api.extension.ExtendWith;
import org.junit.jupiter.api.function.ThrowingConsumer; import org.junit.jupiter.api.function.ThrowingConsumer;
import pro.taskana.common.api.exceptions.InvalidArgumentException; import pro.taskana.common.api.exceptions.InvalidArgumentException;
import pro.taskana.common.api.exceptions.NotAuthorizedException; import pro.taskana.common.api.exceptions.MismatchedRoleException;
import pro.taskana.common.test.security.JaasExtension; import pro.taskana.common.test.security.JaasExtension;
import pro.taskana.common.test.security.WithAccessId; import pro.taskana.common.test.security.WithAccessId;
import pro.taskana.monitor.api.MonitorService; import pro.taskana.monitor.api.MonitorService;
@ -45,7 +45,7 @@ class GetTaskIdsOfClassificationCategoryReportAccTest extends AbstractReportAccT
MONITOR_SERVICE MONITOR_SERVICE
.createClassificationCategoryReportBuilder() .createClassificationCategoryReportBuilder()
.listTaskIdsForSelectedItems(List.of(), TaskTimestamp.DUE); .listTaskIdsForSelectedItems(List.of(), TaskTimestamp.DUE);
assertThatThrownBy(call).isInstanceOf(NotAuthorizedException.class); assertThatThrownBy(call).isInstanceOf(MismatchedRoleException.class);
} }
@WithAccessId(user = "monitor") @WithAccessId(user = "monitor")

View File

@ -16,7 +16,7 @@ import org.junit.jupiter.api.TestFactory;
import org.junit.jupiter.api.extension.ExtendWith; import org.junit.jupiter.api.extension.ExtendWith;
import org.junit.jupiter.api.function.ThrowingConsumer; import org.junit.jupiter.api.function.ThrowingConsumer;
import pro.taskana.common.api.exceptions.NotAuthorizedException; import pro.taskana.common.api.exceptions.MismatchedRoleException;
import pro.taskana.common.test.security.JaasExtension; import pro.taskana.common.test.security.JaasExtension;
import pro.taskana.common.test.security.WithAccessId; import pro.taskana.common.test.security.WithAccessId;
import pro.taskana.monitor.api.MonitorService; import pro.taskana.monitor.api.MonitorService;
@ -45,7 +45,7 @@ class GetTaskIdsOfClassificationReportAccTest extends AbstractReportAccTest {
MONITOR_SERVICE MONITOR_SERVICE
.createClassificationReportBuilder() .createClassificationReportBuilder()
.listTaskIdsForSelectedItems(selectedItems, TaskTimestamp.DUE); .listTaskIdsForSelectedItems(selectedItems, TaskTimestamp.DUE);
assertThatThrownBy(call).isInstanceOf(NotAuthorizedException.class); assertThatThrownBy(call).isInstanceOf(MismatchedRoleException.class);
} }
@WithAccessId(user = "monitor") @WithAccessId(user = "monitor")

View File

@ -17,7 +17,7 @@ import org.junit.jupiter.api.extension.ExtendWith;
import org.junit.jupiter.api.function.ThrowingConsumer; import org.junit.jupiter.api.function.ThrowingConsumer;
import pro.taskana.common.api.exceptions.InvalidArgumentException; import pro.taskana.common.api.exceptions.InvalidArgumentException;
import pro.taskana.common.api.exceptions.NotAuthorizedException; import pro.taskana.common.api.exceptions.MismatchedRoleException;
import pro.taskana.common.test.security.JaasExtension; import pro.taskana.common.test.security.JaasExtension;
import pro.taskana.common.test.security.WithAccessId; import pro.taskana.common.test.security.WithAccessId;
import pro.taskana.monitor.api.MonitorService; import pro.taskana.monitor.api.MonitorService;
@ -47,7 +47,7 @@ class GetTaskIdsOfTaskCustomFieldValueReportAccTest extends AbstractReportAccTes
MONITOR_SERVICE MONITOR_SERVICE
.createTaskCustomFieldValueReportBuilder(TaskCustomField.CUSTOM_1) .createTaskCustomFieldValueReportBuilder(TaskCustomField.CUSTOM_1)
.listTaskIdsForSelectedItems(List.of(), TaskTimestamp.DUE); .listTaskIdsForSelectedItems(List.of(), TaskTimestamp.DUE);
assertThatThrownBy(call).isInstanceOf(NotAuthorizedException.class); assertThatThrownBy(call).isInstanceOf(MismatchedRoleException.class);
} }
@WithAccessId(user = "monitor") @WithAccessId(user = "monitor")

View File

@ -16,7 +16,7 @@ import org.junit.jupiter.api.TestFactory;
import org.junit.jupiter.api.extension.ExtendWith; import org.junit.jupiter.api.extension.ExtendWith;
import org.junit.jupiter.api.function.ThrowingConsumer; import org.junit.jupiter.api.function.ThrowingConsumer;
import pro.taskana.common.api.exceptions.NotAuthorizedException; import pro.taskana.common.api.exceptions.MismatchedRoleException;
import pro.taskana.common.test.security.JaasExtension; import pro.taskana.common.test.security.JaasExtension;
import pro.taskana.common.test.security.WithAccessId; import pro.taskana.common.test.security.WithAccessId;
import pro.taskana.monitor.api.CombinedClassificationFilter; import pro.taskana.monitor.api.CombinedClassificationFilter;
@ -44,7 +44,7 @@ class GetTaskIdsOfWorkbasketReportAccTest extends AbstractReportAccTest {
MONITOR_SERVICE MONITOR_SERVICE
.createWorkbasketReportBuilder() .createWorkbasketReportBuilder()
.listTaskIdsForSelectedItems(List.of(), TaskTimestamp.DUE); .listTaskIdsForSelectedItems(List.of(), TaskTimestamp.DUE);
assertThatThrownBy(call).isInstanceOf(NotAuthorizedException.class); assertThatThrownBy(call).isInstanceOf(MismatchedRoleException.class);
} }
@WithAccessId(user = "monitor") @WithAccessId(user = "monitor")

View File

@ -16,7 +16,7 @@ import org.junit.jupiter.api.TestFactory;
import org.junit.jupiter.api.extension.ExtendWith; import org.junit.jupiter.api.extension.ExtendWith;
import org.junit.jupiter.api.function.ThrowingConsumer; import org.junit.jupiter.api.function.ThrowingConsumer;
import pro.taskana.common.api.exceptions.NotAuthorizedException; import pro.taskana.common.api.exceptions.MismatchedRoleException;
import pro.taskana.common.test.security.JaasExtension; import pro.taskana.common.test.security.JaasExtension;
import pro.taskana.common.test.security.WithAccessId; import pro.taskana.common.test.security.WithAccessId;
import pro.taskana.monitor.api.MonitorService; import pro.taskana.monitor.api.MonitorService;
@ -37,7 +37,7 @@ class ProvideClassificationCategoryReportAccTest extends AbstractReportAccTest {
void testRoleCheck() { void testRoleCheck() {
ThrowingCallable call = ThrowingCallable call =
() -> MONITOR_SERVICE.createClassificationCategoryReportBuilder().buildReport(); () -> MONITOR_SERVICE.createClassificationCategoryReportBuilder().buildReport();
assertThatThrownBy(call).isInstanceOf(NotAuthorizedException.class); assertThatThrownBy(call).isInstanceOf(MismatchedRoleException.class);
} }
@WithAccessId(user = "monitor") @WithAccessId(user = "monitor")

View File

@ -16,7 +16,7 @@ import org.junit.jupiter.api.TestFactory;
import org.junit.jupiter.api.extension.ExtendWith; import org.junit.jupiter.api.extension.ExtendWith;
import org.junit.jupiter.api.function.ThrowingConsumer; import org.junit.jupiter.api.function.ThrowingConsumer;
import pro.taskana.common.api.exceptions.NotAuthorizedException; import pro.taskana.common.api.exceptions.MismatchedRoleException;
import pro.taskana.common.test.security.JaasExtension; import pro.taskana.common.test.security.JaasExtension;
import pro.taskana.common.test.security.WithAccessId; import pro.taskana.common.test.security.WithAccessId;
import pro.taskana.monitor.api.MonitorService; import pro.taskana.monitor.api.MonitorService;
@ -36,7 +36,7 @@ class ProvideClassificationReportAccTest extends AbstractReportAccTest {
@Test @Test
void testRoleCheck() { void testRoleCheck() {
assertThatThrownBy(() -> MONITOR_SERVICE.createClassificationReportBuilder().buildReport()) assertThatThrownBy(() -> MONITOR_SERVICE.createClassificationReportBuilder().buildReport())
.isInstanceOf(NotAuthorizedException.class); .isInstanceOf(MismatchedRoleException.class);
} }
@WithAccessId(user = "monitor") @WithAccessId(user = "monitor")

View File

@ -16,7 +16,7 @@ import org.junit.jupiter.api.TestFactory;
import org.junit.jupiter.api.extension.ExtendWith; import org.junit.jupiter.api.extension.ExtendWith;
import org.junit.jupiter.api.function.ThrowingConsumer; import org.junit.jupiter.api.function.ThrowingConsumer;
import pro.taskana.common.api.exceptions.NotAuthorizedException; import pro.taskana.common.api.exceptions.MismatchedRoleException;
import pro.taskana.common.test.security.JaasExtension; import pro.taskana.common.test.security.JaasExtension;
import pro.taskana.common.test.security.WithAccessId; import pro.taskana.common.test.security.WithAccessId;
import pro.taskana.monitor.api.MonitorService; import pro.taskana.monitor.api.MonitorService;
@ -41,7 +41,7 @@ class ProvideDetailedClassificationReportAccTest extends AbstractReportAccTest {
void testRoleCheck() { void testRoleCheck() {
ThrowingCallable call = ThrowingCallable call =
() -> MONITOR_SERVICE.createClassificationReportBuilder().buildDetailedReport(); () -> MONITOR_SERVICE.createClassificationReportBuilder().buildDetailedReport();
assertThatThrownBy(call).isInstanceOf(NotAuthorizedException.class); assertThatThrownBy(call).isInstanceOf(MismatchedRoleException.class);
} }
@WithAccessId(user = "monitor") @WithAccessId(user = "monitor")

View File

@ -16,7 +16,7 @@ import org.junit.jupiter.api.TestFactory;
import org.junit.jupiter.api.extension.ExtendWith; import org.junit.jupiter.api.extension.ExtendWith;
import org.junit.jupiter.api.function.ThrowingConsumer; import org.junit.jupiter.api.function.ThrowingConsumer;
import pro.taskana.common.api.exceptions.NotAuthorizedException; import pro.taskana.common.api.exceptions.MismatchedRoleException;
import pro.taskana.common.test.security.JaasExtension; import pro.taskana.common.test.security.JaasExtension;
import pro.taskana.common.test.security.WithAccessId; import pro.taskana.common.test.security.WithAccessId;
import pro.taskana.monitor.api.MonitorService; import pro.taskana.monitor.api.MonitorService;
@ -41,7 +41,7 @@ class ProvideTaskCustomFieldValueReportAccTest extends AbstractReportAccTest {
.createTaskCustomFieldValueReportBuilder(TaskCustomField.CUSTOM_1) .createTaskCustomFieldValueReportBuilder(TaskCustomField.CUSTOM_1)
.buildReport(); .buildReport();
}; };
assertThatThrownBy(call).isInstanceOf(NotAuthorizedException.class); assertThatThrownBy(call).isInstanceOf(MismatchedRoleException.class);
} }
@WithAccessId(user = "monitor") @WithAccessId(user = "monitor")

View File

@ -11,7 +11,7 @@ import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.TestTemplate; import org.junit.jupiter.api.TestTemplate;
import org.junit.jupiter.api.extension.ExtendWith; import org.junit.jupiter.api.extension.ExtendWith;
import pro.taskana.common.api.exceptions.NotAuthorizedException; import pro.taskana.common.api.exceptions.MismatchedRoleException;
import pro.taskana.common.test.security.JaasExtension; import pro.taskana.common.test.security.JaasExtension;
import pro.taskana.common.test.security.WithAccessId; import pro.taskana.common.test.security.WithAccessId;
import pro.taskana.monitor.api.MonitorService; import pro.taskana.monitor.api.MonitorService;
@ -34,7 +34,7 @@ class ProvideTaskStatusReportAccTest extends AbstractReportAccTest {
@Test @Test
void should_ThrowException_When_UserIsNotAuthorized() { void should_ThrowException_When_UserIsNotAuthorized() {
assertThatThrownBy(() -> MONITOR_SERVICE.createTaskStatusReportBuilder().buildReport()) assertThatThrownBy(() -> MONITOR_SERVICE.createTaskStatusReportBuilder().buildReport())
.isInstanceOf(NotAuthorizedException.class); .isInstanceOf(MismatchedRoleException.class);
} }
@WithAccessId(user = "unknown") @WithAccessId(user = "unknown")
@ -44,7 +44,7 @@ class ProvideTaskStatusReportAccTest extends AbstractReportAccTest {
@TestTemplate @TestTemplate
void should_ThrowException_When_UserIsNotAdminOrMonitor() { void should_ThrowException_When_UserIsNotAdminOrMonitor() {
assertThatThrownBy(() -> MONITOR_SERVICE.createTaskStatusReportBuilder().buildReport()) assertThatThrownBy(() -> MONITOR_SERVICE.createTaskStatusReportBuilder().buildReport())
.isInstanceOf(NotAuthorizedException.class); .isInstanceOf(MismatchedRoleException.class);
} }
@WithAccessId(user = "admin") @WithAccessId(user = "admin")

View File

@ -16,7 +16,7 @@ import org.junit.jupiter.api.TestFactory;
import org.junit.jupiter.api.extension.ExtendWith; import org.junit.jupiter.api.extension.ExtendWith;
import org.junit.jupiter.api.function.ThrowingConsumer; import org.junit.jupiter.api.function.ThrowingConsumer;
import pro.taskana.common.api.exceptions.NotAuthorizedException; import pro.taskana.common.api.exceptions.MismatchedRoleException;
import pro.taskana.common.test.security.JaasExtension; import pro.taskana.common.test.security.JaasExtension;
import pro.taskana.common.test.security.WithAccessId; import pro.taskana.common.test.security.WithAccessId;
import pro.taskana.monitor.api.CombinedClassificationFilter; import pro.taskana.monitor.api.CombinedClassificationFilter;
@ -36,7 +36,7 @@ class ProvideWorkbasketReportAccTest extends AbstractReportAccTest {
@Test @Test
void testRoleCheck() { void testRoleCheck() {
assertThatThrownBy(() -> MONITOR_SERVICE.createWorkbasketReportBuilder().buildReport()) assertThatThrownBy(() -> MONITOR_SERVICE.createWorkbasketReportBuilder().buildReport())
.isInstanceOf(NotAuthorizedException.class); .isInstanceOf(MismatchedRoleException.class);
} }
@WithAccessId(user = "monitor") @WithAccessId(user = "monitor")

View File

@ -10,7 +10,7 @@ import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith; import org.junit.jupiter.api.extension.ExtendWith;
import pro.taskana.common.api.TaskanaRole; import pro.taskana.common.api.TaskanaRole;
import pro.taskana.common.api.exceptions.NotAuthorizedException; import pro.taskana.common.api.exceptions.MismatchedRoleException;
import pro.taskana.common.test.security.JaasExtension; import pro.taskana.common.test.security.JaasExtension;
import pro.taskana.common.test.security.WithAccessId; import pro.taskana.common.test.security.WithAccessId;
@ -27,7 +27,7 @@ class TaskanaSecurityAccTest extends AbstractAccTest {
assertThat(taskanaEngine.isUserInRole(TaskanaRole.BUSINESS_ADMIN)).isFalse(); assertThat(taskanaEngine.isUserInRole(TaskanaRole.BUSINESS_ADMIN)).isFalse();
assertThat(taskanaEngine.isUserInRole(TaskanaRole.ADMIN)).isFalse(); assertThat(taskanaEngine.isUserInRole(TaskanaRole.ADMIN)).isFalse();
ThrowingCallable call = () -> taskanaEngine.checkRoleMembership(TaskanaRole.BUSINESS_ADMIN); ThrowingCallable call = () -> taskanaEngine.checkRoleMembership(TaskanaRole.BUSINESS_ADMIN);
assertThatThrownBy(call).isInstanceOf(NotAuthorizedException.class); assertThatThrownBy(call).isInstanceOf(MismatchedRoleException.class);
} }
@WithAccessId(user = "businessadmin") @WithAccessId(user = "businessadmin")
@ -50,7 +50,7 @@ class TaskanaSecurityAccTest extends AbstractAccTest {
assertThat(taskanaEngine.isUserInRole(TaskanaRole.BUSINESS_ADMIN)).isFalse(); assertThat(taskanaEngine.isUserInRole(TaskanaRole.BUSINESS_ADMIN)).isFalse();
assertThat(taskanaEngine.isUserInRole(TaskanaRole.ADMIN)).isFalse(); assertThat(taskanaEngine.isUserInRole(TaskanaRole.ADMIN)).isFalse();
ThrowingCallable call = () -> taskanaEngine.checkRoleMembership(TaskanaRole.BUSINESS_ADMIN); ThrowingCallable call = () -> taskanaEngine.checkRoleMembership(TaskanaRole.BUSINESS_ADMIN);
assertThatThrownBy(call).isInstanceOf(NotAuthorizedException.class); assertThatThrownBy(call).isInstanceOf(MismatchedRoleException.class);
} }
@WithAccessId(user = "user-1-1", groups = "businessadmin") @WithAccessId(user = "user-1-1", groups = "businessadmin")

View File

@ -22,7 +22,6 @@ import pro.taskana.task.api.CallbackState;
import pro.taskana.task.api.TaskService; import pro.taskana.task.api.TaskService;
import pro.taskana.task.api.TaskState; import pro.taskana.task.api.TaskState;
import pro.taskana.task.api.exceptions.InvalidCallbackStateException; import pro.taskana.task.api.exceptions.InvalidCallbackStateException;
import pro.taskana.task.api.exceptions.InvalidStateException;
import pro.taskana.task.api.models.Task; import pro.taskana.task.api.models.Task;
import pro.taskana.task.api.models.TaskSummary; import pro.taskana.task.api.models.TaskSummary;
import pro.taskana.task.internal.models.TaskImpl; import pro.taskana.task.internal.models.TaskImpl;
@ -72,7 +71,7 @@ class CallbackStateAccTest extends AbstractAccTest {
CallbackState.NONE, CallbackState.CLAIMED, CallbackState.CALLBACK_PROCESSING_COMPLETED CallbackState.NONE, CallbackState.CLAIMED, CallbackState.CALLBACK_PROCESSING_COMPLETED
}; };
assertThatThrownBy(call) assertThatThrownBy(call)
.isInstanceOf(InvalidStateException.class) .isInstanceOf(InvalidCallbackStateException.class)
.hasMessage( .hasMessage(
"Expected callback state of Task with id '%s' to be: '%s', but found '%s'", "Expected callback state of Task with id '%s' to be: '%s', but found '%s'",
createdTask.getId(), createdTask.getId(),
@ -85,7 +84,7 @@ class CallbackStateAccTest extends AbstractAccTest {
call = () -> taskService.forceDeleteTask(createdTask2.getId()); call = () -> taskService.forceDeleteTask(createdTask2.getId());
assertThatThrownBy(call) assertThatThrownBy(call)
.isInstanceOf(InvalidStateException.class) .isInstanceOf(InvalidCallbackStateException.class)
.hasMessage( .hasMessage(
"Expected callback state of Task with id '%s' to be: '%s', but found '%s'", "Expected callback state of Task with id '%s' to be: '%s', but found '%s'",
createdTask2.getId(), createdTask2.getId(),
@ -96,7 +95,7 @@ class CallbackStateAccTest extends AbstractAccTest {
call = () -> taskService.forceDeleteTask(createdTask3.getId()); call = () -> taskService.forceDeleteTask(createdTask3.getId());
assertThatThrownBy(call) assertThatThrownBy(call)
.isInstanceOf(InvalidStateException.class) .isInstanceOf(InvalidCallbackStateException.class)
.hasMessage( .hasMessage(
"Expected callback state of Task with id '%s' to be: '%s', but found '%s'", "Expected callback state of Task with id '%s' to be: '%s', but found '%s'",
createdTask3.getId(), createdTask3.getId(),

View File

@ -22,13 +22,13 @@ import pro.taskana.classification.api.models.Classification;
import pro.taskana.common.api.BulkOperationResults; import pro.taskana.common.api.BulkOperationResults;
import pro.taskana.common.api.WorkingDaysToDaysConverter; import pro.taskana.common.api.WorkingDaysToDaysConverter;
import pro.taskana.common.api.exceptions.InvalidArgumentException; import pro.taskana.common.api.exceptions.InvalidArgumentException;
import pro.taskana.common.api.exceptions.NotAuthorizedException;
import pro.taskana.common.api.exceptions.TaskanaException; import pro.taskana.common.api.exceptions.TaskanaException;
import pro.taskana.common.test.security.JaasExtension; import pro.taskana.common.test.security.JaasExtension;
import pro.taskana.common.test.security.WithAccessId; import pro.taskana.common.test.security.WithAccessId;
import pro.taskana.task.api.TaskService; import pro.taskana.task.api.TaskService;
import pro.taskana.task.api.exceptions.TaskNotFoundException; import pro.taskana.task.api.exceptions.TaskNotFoundException;
import pro.taskana.task.api.models.Task; import pro.taskana.task.api.models.Task;
import pro.taskana.workbasket.api.exceptions.MismatchedWorkbasketPermissionException;
/** Acceptance test for all "create task" scenarios. */ /** Acceptance test for all "create task" scenarios. */
@ExtendWith(JaasExtension.class) @ExtendWith(JaasExtension.class)
@ -343,7 +343,8 @@ class ServiceLevelPriorityAccTest extends AbstractAccTest {
assertThat(results.containsErrors()).isTrue(); assertThat(results.containsErrors()).isTrue();
assertThat(results.getFailedIds()).hasSize(3).containsAnyElementsOf(taskIds); assertThat(results.getFailedIds()).hasSize(3).containsAnyElementsOf(taskIds);
assertThat(results.getErrorMap().values()).hasOnlyElementsOfType(NotAuthorizedException.class); assertThat(results.getErrorMap().values())
.hasOnlyElementsOfType(MismatchedWorkbasketPermissionException.class);
} }
@WithAccessId(user = "admin") @WithAccessId(user = "admin")

View File

@ -9,13 +9,13 @@ import org.assertj.core.api.ThrowableAssert.ThrowingCallable;
import org.junit.jupiter.api.Test; import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith; import org.junit.jupiter.api.extension.ExtendWith;
import pro.taskana.common.api.exceptions.NotAuthorizedException;
import pro.taskana.common.test.security.JaasExtension; import pro.taskana.common.test.security.JaasExtension;
import pro.taskana.common.test.security.WithAccessId; import pro.taskana.common.test.security.WithAccessId;
import pro.taskana.task.api.TaskService; import pro.taskana.task.api.TaskService;
import pro.taskana.task.api.TaskState; import pro.taskana.task.api.TaskState;
import pro.taskana.task.api.exceptions.InvalidOwnerException; import pro.taskana.task.api.exceptions.InvalidOwnerException;
import pro.taskana.task.api.models.Task; import pro.taskana.task.api.models.Task;
import pro.taskana.workbasket.api.exceptions.MismatchedWorkbasketPermissionException;
@ExtendWith(JaasExtension.class) @ExtendWith(JaasExtension.class)
class ClaimTaskAccTest extends AbstractAccTest { class ClaimTaskAccTest extends AbstractAccTest {
@ -129,14 +129,14 @@ class ClaimTaskAccTest extends AbstractAccTest {
@Test @Test
void should_ThrowNotAuthorizedException_When_UserHasNoReadPermissionAndTaskIsReady() { void should_ThrowNotAuthorizedException_When_UserHasNoReadPermissionAndTaskIsReady() {
assertThatThrownBy(() -> taskService.claim("TKI:000000000000000000000000000000000000")) assertThatThrownBy(() -> taskService.claim("TKI:000000000000000000000000000000000000"))
.isInstanceOf(NotAuthorizedException.class); .isInstanceOf(MismatchedWorkbasketPermissionException.class);
} }
@WithAccessId(user = "user-taskrouter") @WithAccessId(user = "user-taskrouter")
@Test @Test
void should_ThrowNotAuthorizedException_When_UserHasNoReadPermissionAndTaskIsReadyForReview() { void should_ThrowNotAuthorizedException_When_UserHasNoReadPermissionAndTaskIsReadyForReview() {
assertThatThrownBy(() -> taskService.claim("TKI:500000000000000000000000000000000028")) assertThatThrownBy(() -> taskService.claim("TKI:500000000000000000000000000000000028"))
.isInstanceOf(NotAuthorizedException.class); .isInstanceOf(MismatchedWorkbasketPermissionException.class);
} }
@WithAccessId(user = "user-1-2") @WithAccessId(user = "user-1-2")

View File

@ -14,13 +14,11 @@ import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith; import org.junit.jupiter.api.extension.ExtendWith;
import pro.taskana.common.api.BulkOperationResults; import pro.taskana.common.api.BulkOperationResults;
import pro.taskana.common.api.exceptions.NotAuthorizedException;
import pro.taskana.common.api.exceptions.TaskanaException; import pro.taskana.common.api.exceptions.TaskanaException;
import pro.taskana.common.test.security.JaasExtension; import pro.taskana.common.test.security.JaasExtension;
import pro.taskana.common.test.security.WithAccessId; import pro.taskana.common.test.security.WithAccessId;
import pro.taskana.task.api.TaskService; import pro.taskana.task.api.TaskService;
import pro.taskana.task.api.TaskState; import pro.taskana.task.api.TaskState;
import pro.taskana.task.api.exceptions.InvalidStateException;
import pro.taskana.task.api.exceptions.InvalidTaskStateException; import pro.taskana.task.api.exceptions.InvalidTaskStateException;
import pro.taskana.task.api.exceptions.TaskNotFoundException; import pro.taskana.task.api.exceptions.TaskNotFoundException;
import pro.taskana.task.api.models.Task; import pro.taskana.task.api.models.Task;
@ -78,9 +76,9 @@ class SetOwnerAccTest extends AbstractAccTest {
String anyUserName = "TestUser3"; String anyUserName = "TestUser3";
assertThatThrownBy(() -> taskService.getTask(taskReadyId)) assertThatThrownBy(() -> taskService.getTask(taskReadyId))
.isInstanceOf(NotAuthorizedException.class); .isInstanceOf(MismatchedWorkbasketPermissionException.class);
assertThatThrownBy(() -> setOwner(taskReadyId, anyUserName)) assertThatThrownBy(() -> setOwner(taskReadyId, anyUserName))
.isInstanceOf(NotAuthorizedException.class); .isInstanceOf(MismatchedWorkbasketPermissionException.class);
} }
@WithAccessId(user = "user-1-2") @WithAccessId(user = "user-1-2")
@ -94,7 +92,7 @@ class SetOwnerAccTest extends AbstractAccTest {
assertThat(taskClaimed.getState()).isEqualTo(TaskState.CLAIMED); assertThat(taskClaimed.getState()).isEqualTo(TaskState.CLAIMED);
assertThat(taskClaimed.getOwner()).isEqualTo("user-1-1"); assertThat(taskClaimed.getOwner()).isEqualTo("user-1-1");
assertThatThrownBy(() -> setOwner(taskClaimedId, anyUserName)) assertThatThrownBy(() -> setOwner(taskClaimedId, anyUserName))
.isInstanceOf(InvalidStateException.class); .isInstanceOf(InvalidTaskStateException.class);
} }
@WithAccessId(user = "user-1-2") @WithAccessId(user = "user-1-2")
@ -210,7 +208,8 @@ class SetOwnerAccTest extends AbstractAccTest {
assertThat(results.getErrorMap()) assertThat(results.getErrorMap())
.hasSize(95) .hasSize(95)
.extractingFromEntries(Entry::getValue) .extractingFromEntries(Entry::getValue)
.hasOnlyElementsOfTypes(InvalidTaskStateException.class, NotAuthorizedException.class) .hasOnlyElementsOfTypes(
InvalidTaskStateException.class, MismatchedWorkbasketPermissionException.class)
.areExactly(35, invalidTaskStateException) .areExactly(35, invalidTaskStateException)
.areExactly(60, mismatchedWorkbasketPermissionException); .areExactly(60, mismatchedWorkbasketPermissionException);
} }
@ -229,7 +228,7 @@ class SetOwnerAccTest extends AbstractAccTest {
assertThat(results.getErrorMap()) assertThat(results.getErrorMap())
.hasSize(49) .hasSize(49)
.extractingFromEntries(Entry::getValue) .extractingFromEntries(Entry::getValue)
.hasOnlyElementsOfType(InvalidStateException.class); .hasOnlyElementsOfType(InvalidTaskStateException.class);
} }
private Task setOwner(String taskReadyId, String anyUserName) throws Exception { private Task setOwner(String taskReadyId, String anyUserName) throws Exception {

View File

@ -11,13 +11,13 @@ import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.TestTemplate; import org.junit.jupiter.api.TestTemplate;
import org.junit.jupiter.api.extension.ExtendWith; import org.junit.jupiter.api.extension.ExtendWith;
import pro.taskana.common.api.exceptions.NotAuthorizedException;
import pro.taskana.common.test.security.JaasExtension; import pro.taskana.common.test.security.JaasExtension;
import pro.taskana.common.test.security.WithAccessId; import pro.taskana.common.test.security.WithAccessId;
import pro.taskana.task.api.TaskState; import pro.taskana.task.api.TaskState;
import pro.taskana.task.api.exceptions.InvalidStateException; import pro.taskana.task.api.exceptions.InvalidTaskStateException;
import pro.taskana.task.api.models.Task; import pro.taskana.task.api.models.Task;
import pro.taskana.task.api.models.TaskSummary; import pro.taskana.task.api.models.TaskSummary;
import pro.taskana.workbasket.api.exceptions.MismatchedWorkbasketPermissionException;
/** Acceptance tests for all "cancel task" scenarios. */ /** Acceptance tests for all "cancel task" scenarios. */
@ExtendWith(JaasExtension.class) @ExtendWith(JaasExtension.class)
@ -85,7 +85,7 @@ class CancelTaskAccTest extends AbstractAccTest {
@Test @Test
void should_ThrowException_When_UserNotAuthorized() { void should_ThrowException_When_UserNotAuthorized() {
assertThatThrownBy(() -> taskService.cancelTask("TKI:000000000000000000000000000000000001")) assertThatThrownBy(() -> taskService.cancelTask("TKI:000000000000000000000000000000000001"))
.isInstanceOf(NotAuthorizedException.class); .isInstanceOf(MismatchedWorkbasketPermissionException.class);
} }
@WithAccessId(user = "admin") @WithAccessId(user = "admin")
@ -97,7 +97,7 @@ class CancelTaskAccTest extends AbstractAccTest {
ThrowingCallable taskanaCall = () -> taskService.cancelTask(taskSummaries.get(0).getId()); ThrowingCallable taskanaCall = () -> taskService.cancelTask(taskSummaries.get(0).getId());
assertThatThrownBy(taskanaCall).isInstanceOf(InvalidStateException.class); assertThatThrownBy(taskanaCall).isInstanceOf(InvalidTaskStateException.class);
} }
@WithAccessId(user = "user-1-2") @WithAccessId(user = "user-1-2")
@ -108,7 +108,7 @@ class CancelTaskAccTest extends AbstractAccTest {
assertThat(taskSummaries).hasSize(5); assertThat(taskSummaries).hasSize(5);
ThrowingCallable taskanaCall = () -> taskService.cancelTask(taskSummaries.get(0).getId()); ThrowingCallable taskanaCall = () -> taskService.cancelTask(taskSummaries.get(0).getId());
assertThatThrownBy(taskanaCall).isInstanceOf(InvalidStateException.class); assertThatThrownBy(taskanaCall).isInstanceOf(InvalidTaskStateException.class);
} }
@WithAccessId(user = "user-1-2") @WithAccessId(user = "user-1-2")
@ -118,6 +118,6 @@ class CancelTaskAccTest extends AbstractAccTest {
taskService.createTaskQuery().stateIn(TaskState.CANCELLED).list(); taskService.createTaskQuery().stateIn(TaskState.CANCELLED).list();
assertThat(taskSummaries).hasSize(5); assertThat(taskSummaries).hasSize(5);
ThrowingCallable taskanaCall = () -> taskService.cancelTask(taskSummaries.get(0).getId()); ThrowingCallable taskanaCall = () -> taskService.cancelTask(taskSummaries.get(0).getId());
assertThatThrownBy(taskanaCall).isInstanceOf(InvalidStateException.class); assertThatThrownBy(taskanaCall).isInstanceOf(InvalidTaskStateException.class);
} }
} }

View File

@ -11,11 +11,11 @@ import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.TestTemplate; import org.junit.jupiter.api.TestTemplate;
import org.junit.jupiter.api.extension.ExtendWith; import org.junit.jupiter.api.extension.ExtendWith;
import pro.taskana.common.api.exceptions.NotAuthorizedException; import pro.taskana.common.api.exceptions.MismatchedRoleException;
import pro.taskana.common.test.security.JaasExtension; import pro.taskana.common.test.security.JaasExtension;
import pro.taskana.common.test.security.WithAccessId; import pro.taskana.common.test.security.WithAccessId;
import pro.taskana.task.api.TaskState; import pro.taskana.task.api.TaskState;
import pro.taskana.task.api.exceptions.InvalidStateException; import pro.taskana.task.api.exceptions.InvalidTaskStateException;
import pro.taskana.task.api.models.TaskSummary; import pro.taskana.task.api.models.TaskSummary;
/** Acceptance tests for "terminate task" scenarios. */ /** Acceptance tests for "terminate task" scenarios. */
@ -74,7 +74,7 @@ class TerminateTaskAccTest extends AbstractAccTest {
assertThat(taskSummaries).hasSize(10); assertThat(taskSummaries).hasSize(10);
ThrowingCallable taskanaCall = () -> taskService.terminateTask(taskSummaries.get(0).getId()); ThrowingCallable taskanaCall = () -> taskService.terminateTask(taskSummaries.get(0).getId());
assertThatThrownBy(taskanaCall).isInstanceOf(InvalidStateException.class); assertThatThrownBy(taskanaCall).isInstanceOf(InvalidTaskStateException.class);
} }
@WithAccessId(user = "user-1-2") @WithAccessId(user = "user-1-2")
@ -84,7 +84,7 @@ class TerminateTaskAccTest extends AbstractAccTest {
ThrowingCallable taskanaCall = ThrowingCallable taskanaCall =
() -> taskService.terminateTask("TKI:000000000000000000000000000000000000"); () -> taskService.terminateTask("TKI:000000000000000000000000000000000000");
assertThatThrownBy(taskanaCall).isInstanceOf(NotAuthorizedException.class); assertThatThrownBy(taskanaCall).isInstanceOf(MismatchedRoleException.class);
} }
@WithAccessId(user = "taskadmin") @WithAccessId(user = "taskadmin")
@ -95,7 +95,7 @@ class TerminateTaskAccTest extends AbstractAccTest {
assertThat(taskSummaries).hasSize(5); assertThat(taskSummaries).hasSize(5);
ThrowingCallable taskanaCall = () -> taskService.terminateTask(taskSummaries.get(0).getId()); ThrowingCallable taskanaCall = () -> taskService.terminateTask(taskSummaries.get(0).getId());
assertThatThrownBy(taskanaCall).isInstanceOf(InvalidStateException.class); assertThatThrownBy(taskanaCall).isInstanceOf(InvalidTaskStateException.class);
} }
@WithAccessId(user = "taskadmin") @WithAccessId(user = "taskadmin")
@ -105,6 +105,6 @@ class TerminateTaskAccTest extends AbstractAccTest {
taskService.createTaskQuery().stateIn(TaskState.CANCELLED).list(); taskService.createTaskQuery().stateIn(TaskState.CANCELLED).list();
assertThat(taskSummaries).hasSize(5); assertThat(taskSummaries).hasSize(5);
ThrowingCallable taskanaCall = () -> taskService.terminateTask(taskSummaries.get(0).getId()); ThrowingCallable taskanaCall = () -> taskService.terminateTask(taskSummaries.get(0).getId());
assertThatThrownBy(taskanaCall).isInstanceOf(InvalidStateException.class); assertThatThrownBy(taskanaCall).isInstanceOf(InvalidTaskStateException.class);
} }
} }

View File

@ -27,7 +27,6 @@ import pro.taskana.classification.api.models.ClassificationSummary;
import pro.taskana.classification.internal.models.ClassificationSummaryImpl; import pro.taskana.classification.internal.models.ClassificationSummaryImpl;
import pro.taskana.common.api.TaskanaEngine; import pro.taskana.common.api.TaskanaEngine;
import pro.taskana.common.api.exceptions.InvalidArgumentException; import pro.taskana.common.api.exceptions.InvalidArgumentException;
import pro.taskana.common.api.exceptions.NotAuthorizedException;
import pro.taskana.common.test.security.JaasExtension; import pro.taskana.common.test.security.JaasExtension;
import pro.taskana.common.test.security.WithAccessId; import pro.taskana.common.test.security.WithAccessId;
import pro.taskana.task.api.TaskCustomField; import pro.taskana.task.api.TaskCustomField;
@ -42,6 +41,7 @@ import pro.taskana.task.internal.AttachmentMapper;
import pro.taskana.task.internal.models.ObjectReferenceImpl; import pro.taskana.task.internal.models.ObjectReferenceImpl;
import pro.taskana.task.internal.models.TaskImpl; import pro.taskana.task.internal.models.TaskImpl;
import pro.taskana.workbasket.api.WorkbasketService; import pro.taskana.workbasket.api.WorkbasketService;
import pro.taskana.workbasket.api.exceptions.MismatchedWorkbasketPermissionException;
import pro.taskana.workbasket.api.exceptions.WorkbasketNotFoundException; import pro.taskana.workbasket.api.exceptions.WorkbasketNotFoundException;
import pro.taskana.workbasket.api.models.Workbasket; import pro.taskana.workbasket.api.models.Workbasket;
@ -677,7 +677,7 @@ class CreateTaskAccTest extends AbstractAccTest {
createObjectReference("COMPANY_A", "SYSTEM_A", "INSTANCE_A", "VNR", "1234567")); createObjectReference("COMPANY_A", "SYSTEM_A", "INSTANCE_A", "VNR", "1234567"));
ThrowingCallable call = () -> taskService.createTask(newTask); ThrowingCallable call = () -> taskService.createTask(newTask);
assertThatThrownBy(call).isInstanceOf(NotAuthorizedException.class); assertThatThrownBy(call).isInstanceOf(MismatchedWorkbasketPermissionException.class);
} }
@WithAccessId(user = "user-1-1") @WithAccessId(user = "user-1-1")
@ -801,7 +801,7 @@ class CreateTaskAccTest extends AbstractAccTest {
createObjectReference("COMPANY_B", "SYSTEM_B", "INSTANCE_B", "VNR", "1234567")); createObjectReference("COMPANY_B", "SYSTEM_B", "INSTANCE_B", "VNR", "1234567"));
ThrowingCallable call = () -> taskService.createTask(newTask); ThrowingCallable call = () -> taskService.createTask(newTask);
assertThatThrownBy(call).isInstanceOf(NotAuthorizedException.class); assertThatThrownBy(call).isInstanceOf(MismatchedWorkbasketPermissionException.class);
} }
@WithAccessId(user = "user-1-1") @WithAccessId(user = "user-1-1")
@ -822,7 +822,7 @@ class CreateTaskAccTest extends AbstractAccTest {
Task task = taskService.newTask("TEAMLEAD-2", "DOMAIN_A"); Task task = taskService.newTask("TEAMLEAD-2", "DOMAIN_A");
ThrowingCallable call = () -> taskService.createTask(task); ThrowingCallable call = () -> taskService.createTask(task);
assertThatThrownBy(call).isInstanceOf(NotAuthorizedException.class); assertThatThrownBy(call).isInstanceOf(MismatchedWorkbasketPermissionException.class);
} }
@WithAccessId(user = "user-1-1") @WithAccessId(user = "user-1-1")

View File

@ -12,11 +12,10 @@ import org.junit.jupiter.api.TestTemplate;
import org.junit.jupiter.api.extension.ExtendWith; import org.junit.jupiter.api.extension.ExtendWith;
import pro.taskana.common.api.BulkOperationResults; import pro.taskana.common.api.BulkOperationResults;
import pro.taskana.common.api.exceptions.NotAuthorizedException; import pro.taskana.common.api.exceptions.MismatchedRoleException;
import pro.taskana.common.api.exceptions.TaskanaException; import pro.taskana.common.api.exceptions.TaskanaException;
import pro.taskana.common.test.security.JaasExtension; import pro.taskana.common.test.security.JaasExtension;
import pro.taskana.common.test.security.WithAccessId; import pro.taskana.common.test.security.WithAccessId;
import pro.taskana.task.api.exceptions.InvalidStateException;
import pro.taskana.task.api.exceptions.InvalidTaskStateException; import pro.taskana.task.api.exceptions.InvalidTaskStateException;
import pro.taskana.task.api.exceptions.TaskNotFoundException; import pro.taskana.task.api.exceptions.TaskNotFoundException;
import pro.taskana.task.api.models.Task; import pro.taskana.task.api.models.Task;
@ -32,7 +31,7 @@ class DeleteTaskAccTest extends AbstractAccTest {
ThrowingCallable call = ThrowingCallable call =
() -> taskService.deleteTask("TKI:000000000000000000000000000000000037"); () -> taskService.deleteTask("TKI:000000000000000000000000000000000037");
assertThatThrownBy(call).isInstanceOf(NotAuthorizedException.class); assertThatThrownBy(call).isInstanceOf(MismatchedRoleException.class);
} }
@WithAccessId(user = "user-taskrouter") @WithAccessId(user = "user-taskrouter")
@ -40,7 +39,7 @@ class DeleteTaskAccTest extends AbstractAccTest {
void should_ThrowNotAuthorizedException_When_UserIsMemberOfTaskRouterRole() { void should_ThrowNotAuthorizedException_When_UserIsMemberOfTaskRouterRole() {
ThrowingCallable call = ThrowingCallable call =
() -> taskService.deleteTask("TKI:000000000000000000000000000000000037"); () -> taskService.deleteTask("TKI:000000000000000000000000000000000037");
assertThatThrownBy(call).isInstanceOf(NotAuthorizedException.class); assertThatThrownBy(call).isInstanceOf(MismatchedRoleException.class);
} }
@WithAccessId(user = "admin") @WithAccessId(user = "admin")
@ -121,7 +120,7 @@ class DeleteTaskAccTest extends AbstractAccTest {
"TKI:000000000000000000000000000000000010"); "TKI:000000000000000000000000000000000010");
ThrowingCallable call = () -> taskService.deleteTasks(taskIds); ThrowingCallable call = () -> taskService.deleteTasks(taskIds);
assertThatThrownBy(call).isInstanceOf(NotAuthorizedException.class); assertThatThrownBy(call).isInstanceOf(MismatchedRoleException.class);
} }
@WithAccessId(user = "admin") @WithAccessId(user = "admin")
@ -142,7 +141,7 @@ class DeleteTaskAccTest extends AbstractAccTest {
void should_ThrowException_When_UserIsNotInAdminRole() { void should_ThrowException_When_UserIsNotInAdminRole() {
ThrowingCallable deleteTaskCall = ThrowingCallable deleteTaskCall =
() -> taskService.deleteTask("TKI:000000000000000000000000000000000041"); () -> taskService.deleteTask("TKI:000000000000000000000000000000000041");
assertThatThrownBy(deleteTaskCall).isInstanceOf(NotAuthorizedException.class); assertThatThrownBy(deleteTaskCall).isInstanceOf(MismatchedRoleException.class);
} }
@WithAccessId(user = "admin") @WithAccessId(user = "admin")
@ -151,7 +150,7 @@ class DeleteTaskAccTest extends AbstractAccTest {
Task task = taskService.getTask("TKI:000000000000000000000000000000000029"); Task task = taskService.getTask("TKI:000000000000000000000000000000000029");
ThrowingCallable call = () -> taskService.deleteTask(task.getId()); ThrowingCallable call = () -> taskService.deleteTask(task.getId());
assertThatThrownBy(call).isInstanceOf(InvalidStateException.class); assertThatThrownBy(call).isInstanceOf(InvalidTaskStateException.class);
} }
@WithAccessId(user = "admin") @WithAccessId(user = "admin")
@ -162,7 +161,7 @@ class DeleteTaskAccTest extends AbstractAccTest {
ThrowingCallable call = () -> taskService.deleteTask(task.getId()); ThrowingCallable call = () -> taskService.deleteTask(task.getId());
assertThatThrownBy(call) assertThatThrownBy(call)
.describedAs("Should not be possible to delete claimed task without force flag") .describedAs("Should not be possible to delete claimed task without force flag")
.isInstanceOf(InvalidStateException.class); .isInstanceOf(InvalidTaskStateException.class);
taskService.forceDeleteTask(task.getId()); taskService.forceDeleteTask(task.getId());

View File

@ -13,7 +13,6 @@ import org.junit.jupiter.api.extension.ExtendWith;
import pro.taskana.TaskanaConfiguration; import pro.taskana.TaskanaConfiguration;
import pro.taskana.common.api.TaskanaEngine; import pro.taskana.common.api.TaskanaEngine;
import pro.taskana.common.api.exceptions.NotAuthorizedException;
import pro.taskana.common.test.security.JaasExtension; import pro.taskana.common.test.security.JaasExtension;
import pro.taskana.common.test.security.WithAccessId; import pro.taskana.common.test.security.WithAccessId;
import pro.taskana.task.api.TaskCustomField; import pro.taskana.task.api.TaskCustomField;
@ -21,6 +20,7 @@ import pro.taskana.task.api.TaskService;
import pro.taskana.task.api.TaskState; import pro.taskana.task.api.TaskState;
import pro.taskana.task.api.exceptions.TaskNotFoundException; import pro.taskana.task.api.exceptions.TaskNotFoundException;
import pro.taskana.task.api.models.Task; import pro.taskana.task.api.models.Task;
import pro.taskana.workbasket.api.exceptions.MismatchedWorkbasketPermissionException;
/** Acceptance test for all "get task" scenarios. */ /** Acceptance test for all "get task" scenarios. */
@ExtendWith(JaasExtension.class) @ExtendWith(JaasExtension.class)
@ -133,7 +133,7 @@ class GetTaskAccTest extends AbstractAccTest {
ThrowingCallable getTaskCall = ThrowingCallable getTaskCall =
() -> taskService.getTask("TKI:000000000000000000000000000000000000"); () -> taskService.getTask("TKI:000000000000000000000000000000000000");
assertThatThrownBy(getTaskCall).isInstanceOf(NotAuthorizedException.class); assertThatThrownBy(getTaskCall).isInstanceOf(MismatchedWorkbasketPermissionException.class);
} }
@WithAccessId(user = "user-taskrouter") @WithAccessId(user = "user-taskrouter")
@ -142,7 +142,7 @@ class GetTaskAccTest extends AbstractAccTest {
ThrowingCallable getTaskCall = ThrowingCallable getTaskCall =
() -> taskService.getTask("TKI:000000000000000000000000000000000000"); () -> taskService.getTask("TKI:000000000000000000000000000000000000");
assertThatThrownBy(getTaskCall).isInstanceOf(NotAuthorizedException.class); assertThatThrownBy(getTaskCall).isInstanceOf(MismatchedWorkbasketPermissionException.class);
} }
@WithAccessId(user = "admin") @WithAccessId(user = "admin")

View File

@ -21,13 +21,11 @@ import org.junit.jupiter.api.function.ThrowingConsumer;
import pro.taskana.common.api.BulkOperationResults; import pro.taskana.common.api.BulkOperationResults;
import pro.taskana.common.api.exceptions.InvalidArgumentException; import pro.taskana.common.api.exceptions.InvalidArgumentException;
import pro.taskana.common.api.exceptions.NotAuthorizedException;
import pro.taskana.common.api.exceptions.TaskanaException; import pro.taskana.common.api.exceptions.TaskanaException;
import pro.taskana.common.internal.util.Pair; import pro.taskana.common.internal.util.Pair;
import pro.taskana.common.test.security.JaasExtension; import pro.taskana.common.test.security.JaasExtension;
import pro.taskana.common.test.security.WithAccessId; import pro.taskana.common.test.security.WithAccessId;
import pro.taskana.task.api.TaskState; import pro.taskana.task.api.TaskState;
import pro.taskana.task.api.exceptions.InvalidStateException;
import pro.taskana.task.api.exceptions.InvalidTaskStateException; import pro.taskana.task.api.exceptions.InvalidTaskStateException;
import pro.taskana.task.api.exceptions.TaskNotFoundException; import pro.taskana.task.api.exceptions.TaskNotFoundException;
import pro.taskana.task.api.models.Task; import pro.taskana.task.api.models.Task;
@ -154,7 +152,7 @@ class TransferTaskAccTest extends AbstractAccTest {
ThrowingCallable call = ThrowingCallable call =
() -> taskService.transfer(task.getId(), "WBI:100000000000000000000000000000000005"); () -> taskService.transfer(task.getId(), "WBI:100000000000000000000000000000000005");
assertThatThrownBy(call).isInstanceOf(NotAuthorizedException.class); assertThatThrownBy(call).isInstanceOf(MismatchedWorkbasketPermissionException.class);
} }
@WithAccessId(user = "user-1-1", groups = "cn=routers,cn=groups,OU=Test,O=TASKANA") @WithAccessId(user = "user-1-1", groups = "cn=routers,cn=groups,OU=Test,O=TASKANA")
@ -165,7 +163,7 @@ class TransferTaskAccTest extends AbstractAccTest {
assertThatThrownBy( assertThatThrownBy(
() -> taskService.transfer(task.getId(), "WBI:100000000000000000000000000000000005")) () -> taskService.transfer(task.getId(), "WBI:100000000000000000000000000000000005"))
.isInstanceOf(NotAuthorizedException.class); .isInstanceOf(MismatchedWorkbasketPermissionException.class);
} }
@WithAccessId(user = "teamlead-1", groups = GROUP_1_DN) @WithAccessId(user = "teamlead-1", groups = GROUP_1_DN)
@ -196,7 +194,7 @@ class TransferTaskAccTest extends AbstractAccTest {
"TKI:200000000000000000000000000000000007", "TKI:200000000000000000000000000000000007",
"WBI:100000000000000000000000000000000001"); "WBI:100000000000000000000000000000000001");
assertThatThrownBy(call) assertThatThrownBy(call)
.isInstanceOf(NotAuthorizedException.class) .isInstanceOf(MismatchedWorkbasketPermissionException.class)
.extracting(Throwable::getMessage) .extracting(Throwable::getMessage)
.asString() .asString()
.startsWith( .startsWith(
@ -212,7 +210,7 @@ class TransferTaskAccTest extends AbstractAccTest {
ThrowingCallable call = ThrowingCallable call =
() -> taskService.transfer(task.getId(), "WBI:100000000000000000000000000000000008"); () -> taskService.transfer(task.getId(), "WBI:100000000000000000000000000000000008");
assertThatThrownBy(call) assertThatThrownBy(call)
.isInstanceOf(NotAuthorizedException.class) .isInstanceOf(MismatchedWorkbasketPermissionException.class)
.extracting(Throwable::getMessage) .extracting(Throwable::getMessage)
.asString() .asString()
.startsWith( .startsWith(
@ -227,7 +225,7 @@ class TransferTaskAccTest extends AbstractAccTest {
ThrowingCallable call = ThrowingCallable call =
() -> taskService.transfer(task.getId(), "WBI:100000000000000000000000000000000005"); () -> taskService.transfer(task.getId(), "WBI:100000000000000000000000000000000005");
assertThatThrownBy(call).isInstanceOf(InvalidStateException.class); assertThatThrownBy(call).isInstanceOf(InvalidTaskStateException.class);
} }
@WithAccessId(user = "teamlead-1", groups = GROUP_1_DN) @WithAccessId(user = "teamlead-1", groups = GROUP_1_DN)
@ -333,7 +331,7 @@ class TransferTaskAccTest extends AbstractAccTest {
ThrowingCallable call = ThrowingCallable call =
() -> taskService.transferTasks("WBI:100000000000000000000000000000000010", taskIdList); () -> taskService.transferTasks("WBI:100000000000000000000000000000000010", taskIdList);
assertThatThrownBy(call) assertThatThrownBy(call)
.isInstanceOf(NotAuthorizedException.class) .isInstanceOf(MismatchedWorkbasketPermissionException.class)
.hasMessageContaining("APPEND"); .hasMessageContaining("APPEND");
} }

View File

@ -28,7 +28,6 @@ import pro.taskana.classification.api.models.ClassificationSummary;
import pro.taskana.common.api.TaskanaEngine; import pro.taskana.common.api.TaskanaEngine;
import pro.taskana.common.api.exceptions.ConcurrencyException; import pro.taskana.common.api.exceptions.ConcurrencyException;
import pro.taskana.common.api.exceptions.InvalidArgumentException; import pro.taskana.common.api.exceptions.InvalidArgumentException;
import pro.taskana.common.api.exceptions.NotAuthorizedException;
import pro.taskana.common.test.security.JaasExtension; import pro.taskana.common.test.security.JaasExtension;
import pro.taskana.common.test.security.WithAccessId; import pro.taskana.common.test.security.WithAccessId;
import pro.taskana.task.api.TaskCustomField; import pro.taskana.task.api.TaskCustomField;
@ -38,6 +37,7 @@ import pro.taskana.task.api.models.Task;
import pro.taskana.task.api.models.TaskSummary; import pro.taskana.task.api.models.TaskSummary;
import pro.taskana.task.internal.models.ObjectReferenceImpl; import pro.taskana.task.internal.models.ObjectReferenceImpl;
import pro.taskana.task.internal.models.TaskImpl; import pro.taskana.task.internal.models.TaskImpl;
import pro.taskana.workbasket.api.exceptions.MismatchedWorkbasketPermissionException;
/** Acceptance test for all "update task" scenarios. */ /** Acceptance test for all "update task" scenarios. */
@ExtendWith(JaasExtension.class) @ExtendWith(JaasExtension.class)
@ -179,7 +179,7 @@ class UpdateTaskAccTest extends AbstractAccTest {
task.setWorkbasketKey("USER-1-2"); task.setWorkbasketKey("USER-1-2");
assertThatThrownBy(() -> taskService.updateTask(task)) assertThatThrownBy(() -> taskService.updateTask(task))
.isInstanceOf(NotAuthorizedException.class); .isInstanceOf(MismatchedWorkbasketPermissionException.class);
} }
@WithAccessId(user = "user-1-1") @WithAccessId(user = "user-1-1")

View File

@ -11,10 +11,10 @@ import org.junit.jupiter.api.TestTemplate;
import org.junit.jupiter.api.extension.ExtendWith; import org.junit.jupiter.api.extension.ExtendWith;
import pro.taskana.common.api.exceptions.InvalidArgumentException; import pro.taskana.common.api.exceptions.InvalidArgumentException;
import pro.taskana.common.api.exceptions.NotAuthorizedException;
import pro.taskana.common.test.security.JaasExtension; import pro.taskana.common.test.security.JaasExtension;
import pro.taskana.common.test.security.WithAccessId; import pro.taskana.common.test.security.WithAccessId;
import pro.taskana.task.api.TaskService; import pro.taskana.task.api.TaskService;
import pro.taskana.task.api.exceptions.MismatchedTaskCommentCreatorException;
import pro.taskana.task.api.exceptions.TaskCommentNotFoundException; import pro.taskana.task.api.exceptions.TaskCommentNotFoundException;
import pro.taskana.task.api.models.TaskComment; import pro.taskana.task.api.models.TaskComment;
@ -56,7 +56,7 @@ class DeleteTaskCommentAccTest extends AbstractAccTest {
ThrowingCallable lambda = ThrowingCallable lambda =
() -> taskService.deleteTaskComment("TCI:000000000000000000000000000000000000"); () -> taskService.deleteTaskComment("TCI:000000000000000000000000000000000000");
assertThatThrownBy(lambda).isInstanceOf(NotAuthorizedException.class); assertThatThrownBy(lambda).isInstanceOf(MismatchedTaskCommentCreatorException.class);
// make sure the task comment was not deleted // make sure the task comment was not deleted
List<TaskComment> taskCommentsAfterDeletion = List<TaskComment> taskCommentsAfterDeletion =

View File

@ -12,7 +12,7 @@ import org.junit.jupiter.api.extension.ExtendWith;
import pro.taskana.common.api.exceptions.DomainNotFoundException; import pro.taskana.common.api.exceptions.DomainNotFoundException;
import pro.taskana.common.api.exceptions.InvalidArgumentException; import pro.taskana.common.api.exceptions.InvalidArgumentException;
import pro.taskana.common.api.exceptions.NotAuthorizedException; import pro.taskana.common.api.exceptions.MismatchedRoleException;
import pro.taskana.common.test.security.JaasExtension; import pro.taskana.common.test.security.JaasExtension;
import pro.taskana.common.test.security.WithAccessId; import pro.taskana.common.test.security.WithAccessId;
import pro.taskana.workbasket.api.WorkbasketPermission; import pro.taskana.workbasket.api.WorkbasketPermission;
@ -70,7 +70,7 @@ class CreateWorkbasketAccTest extends AbstractAccTest {
workbasket.setOrgLevel1("company"); workbasket.setOrgLevel1("company");
ThrowingCallable call = () -> workbasketService.createWorkbasket(workbasket); ThrowingCallable call = () -> workbasketService.createWorkbasket(workbasket);
assertThatThrownBy(call).isInstanceOf(NotAuthorizedException.class); assertThatThrownBy(call).isInstanceOf(MismatchedRoleException.class);
} }
@WithAccessId(user = "businessadmin") @WithAccessId(user = "businessadmin")

View File

@ -6,7 +6,7 @@ import acceptance.AbstractAccTest;
import org.junit.jupiter.api.TestTemplate; import org.junit.jupiter.api.TestTemplate;
import org.junit.jupiter.api.extension.ExtendWith; import org.junit.jupiter.api.extension.ExtendWith;
import pro.taskana.common.api.exceptions.NotAuthorizedException; import pro.taskana.common.api.exceptions.MismatchedRoleException;
import pro.taskana.common.test.security.JaasExtension; import pro.taskana.common.test.security.JaasExtension;
import pro.taskana.common.test.security.WithAccessId; import pro.taskana.common.test.security.WithAccessId;
import pro.taskana.workbasket.api.WorkbasketPermission; import pro.taskana.workbasket.api.WorkbasketPermission;
@ -29,6 +29,6 @@ class CreateWorkbasketAuthorizationsAccTest extends AbstractAccTest {
accessItem.setPermission(WorkbasketPermission.CUSTOM_11, true); accessItem.setPermission(WorkbasketPermission.CUSTOM_11, true);
accessItem.setPermission(WorkbasketPermission.READ, true); accessItem.setPermission(WorkbasketPermission.READ, true);
assertThatThrownBy(() -> workbasketService.createWorkbasketAccessItem(accessItem)) assertThatThrownBy(() -> workbasketService.createWorkbasketAccessItem(accessItem))
.isInstanceOf(NotAuthorizedException.class); .isInstanceOf(MismatchedRoleException.class);
} }
} }

View File

@ -12,12 +12,13 @@ import org.junit.jupiter.api.TestTemplate;
import org.junit.jupiter.api.extension.ExtendWith; import org.junit.jupiter.api.extension.ExtendWith;
import pro.taskana.common.api.exceptions.InvalidArgumentException; import pro.taskana.common.api.exceptions.InvalidArgumentException;
import pro.taskana.common.api.exceptions.NotAuthorizedException; import pro.taskana.common.api.exceptions.TaskanaException;
import pro.taskana.common.test.security.JaasExtension; import pro.taskana.common.test.security.JaasExtension;
import pro.taskana.common.test.security.WithAccessId; import pro.taskana.common.test.security.WithAccessId;
import pro.taskana.task.internal.models.TaskImpl; import pro.taskana.task.internal.models.TaskImpl;
import pro.taskana.workbasket.api.WorkbasketPermission; import pro.taskana.workbasket.api.WorkbasketPermission;
import pro.taskana.workbasket.api.WorkbasketService; import pro.taskana.workbasket.api.WorkbasketService;
import pro.taskana.workbasket.api.exceptions.MismatchedWorkbasketPermissionException;
import pro.taskana.workbasket.api.exceptions.WorkbasketInUseException; import pro.taskana.workbasket.api.exceptions.WorkbasketInUseException;
import pro.taskana.workbasket.api.exceptions.WorkbasketNotFoundException; import pro.taskana.workbasket.api.exceptions.WorkbasketNotFoundException;
import pro.taskana.workbasket.api.models.Workbasket; import pro.taskana.workbasket.api.models.Workbasket;
@ -60,7 +61,7 @@ class DeleteWorkbasketAccTest extends AbstractAccTest {
Workbasket wb = workbasketService.getWorkbasket("TEAMLEAD-2", "DOMAIN_A"); Workbasket wb = workbasketService.getWorkbasket("TEAMLEAD-2", "DOMAIN_A");
workbasketService.deleteWorkbasket(wb.getId()); workbasketService.deleteWorkbasket(wb.getId());
}; };
assertThatThrownBy(deleteWorkbasketCall).isInstanceOf(NotAuthorizedException.class); assertThatThrownBy(deleteWorkbasketCall).isInstanceOf(TaskanaException.class);
deleteWorkbasketCall = deleteWorkbasketCall =
() -> { () -> {
@ -68,13 +69,13 @@ class DeleteWorkbasketAccTest extends AbstractAccTest {
workbasketService.getWorkbasket("WBI:100000000000000000000000000000000005"); workbasketService.getWorkbasket("WBI:100000000000000000000000000000000005");
workbasketService.deleteWorkbasket(wb.getId()); workbasketService.deleteWorkbasket(wb.getId());
}; };
assertThatThrownBy(deleteWorkbasketCall).isInstanceOf(NotAuthorizedException.class); assertThatThrownBy(deleteWorkbasketCall).isInstanceOf(TaskanaException.class);
} }
@Test @Test
void should_ThrowNotAuthorizedException_When_UnauthorizedTryingToGetWorkbaskets() { void should_ThrowNotAuthorizedException_When_UnauthorizedTryingToGetWorkbaskets() {
assertThatThrownBy(() -> workbasketService.getWorkbasket("TEAMLEAD-2", "DOMAIN_A")) assertThatThrownBy(() -> workbasketService.getWorkbasket("TEAMLEAD-2", "DOMAIN_A"))
.isInstanceOf(NotAuthorizedException.class); .isInstanceOf(MismatchedWorkbasketPermissionException.class);
} }
@WithAccessId(user = "businessadmin") @WithAccessId(user = "businessadmin")

View File

@ -9,7 +9,7 @@ import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.TestTemplate; import org.junit.jupiter.api.TestTemplate;
import org.junit.jupiter.api.extension.ExtendWith; import org.junit.jupiter.api.extension.ExtendWith;
import pro.taskana.common.api.exceptions.NotAuthorizedException; import pro.taskana.common.api.exceptions.MismatchedRoleException;
import pro.taskana.common.test.security.JaasExtension; import pro.taskana.common.test.security.JaasExtension;
import pro.taskana.common.test.security.WithAccessId; import pro.taskana.common.test.security.WithAccessId;
import pro.taskana.workbasket.api.WorkbasketService; import pro.taskana.workbasket.api.WorkbasketService;
@ -30,14 +30,14 @@ class DeleteWorkbasketAuthorizationsAccTest extends AbstractAccTest {
WORKBASKET_SERVICE.deleteWorkbasketAccessItemsForAccessId("group-1"); WORKBASKET_SERVICE.deleteWorkbasketAccessItemsForAccessId("group-1");
}; };
assertThatThrownBy(deleteWorkbasketAccessItemCall).isInstanceOf(NotAuthorizedException.class); assertThatThrownBy(deleteWorkbasketAccessItemCall).isInstanceOf(MismatchedRoleException.class);
deleteWorkbasketAccessItemCall = deleteWorkbasketAccessItemCall =
() -> { () -> {
WORKBASKET_SERVICE.deleteWorkbasketAccessItem("WAI:100000000000000000000000000000000001"); WORKBASKET_SERVICE.deleteWorkbasketAccessItem("WAI:100000000000000000000000000000000001");
}; };
assertThatThrownBy(deleteWorkbasketAccessItemCall).isInstanceOf(NotAuthorizedException.class); assertThatThrownBy(deleteWorkbasketAccessItemCall).isInstanceOf(MismatchedRoleException.class);
} }
@WithAccessId(user = "admin") @WithAccessId(user = "admin")

View File

@ -10,10 +10,11 @@ import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.TestTemplate; import org.junit.jupiter.api.TestTemplate;
import org.junit.jupiter.api.extension.ExtendWith; import org.junit.jupiter.api.extension.ExtendWith;
import pro.taskana.common.api.exceptions.NotAuthorizedException; import pro.taskana.common.api.exceptions.MismatchedRoleException;
import pro.taskana.common.test.security.JaasExtension; import pro.taskana.common.test.security.JaasExtension;
import pro.taskana.common.test.security.WithAccessId; import pro.taskana.common.test.security.WithAccessId;
import pro.taskana.workbasket.api.WorkbasketService; import pro.taskana.workbasket.api.WorkbasketService;
import pro.taskana.workbasket.api.exceptions.MismatchedWorkbasketPermissionException;
import pro.taskana.workbasket.api.exceptions.WorkbasketNotFoundException; import pro.taskana.workbasket.api.exceptions.WorkbasketNotFoundException;
import pro.taskana.workbasket.api.models.WorkbasketSummary; import pro.taskana.workbasket.api.models.WorkbasketSummary;
@ -115,7 +116,7 @@ class GetDistributionTargetsAccTest extends AbstractAccTest {
workbasketService.setDistributionTargets( workbasketService.setDistributionTargets(
existingWb, List.of("WBI:100000000000000000000000000000000002")); existingWb, List.of("WBI:100000000000000000000000000000000002"));
}; };
assertThatThrownBy(call).isInstanceOf(NotAuthorizedException.class); assertThatThrownBy(call).isInstanceOf(MismatchedRoleException.class);
} }
@WithAccessId(user = "user-1-1") @WithAccessId(user = "user-1-1")
@ -129,7 +130,8 @@ class GetDistributionTargetsAccTest extends AbstractAccTest {
() -> { () -> {
workbasketService.getDistributionTargets(existingWb); workbasketService.getDistributionTargets(existingWb);
}; };
assertThatThrownBy(getDistributionTargetsCall).isInstanceOf(NotAuthorizedException.class); assertThatThrownBy(getDistributionTargetsCall)
.isInstanceOf(MismatchedWorkbasketPermissionException.class);
} }
@WithAccessId(user = "businessadmin") @WithAccessId(user = "businessadmin")
@ -167,7 +169,7 @@ class GetDistributionTargetsAccTest extends AbstractAccTest {
ThrowingCallable call = ThrowingCallable call =
() -> workbasketService.getDistributionSources("WBI:100000000000000000000000000000000004"); () -> workbasketService.getDistributionSources("WBI:100000000000000000000000000000000004");
assertThatThrownBy(call).isInstanceOf(NotAuthorizedException.class); assertThatThrownBy(call).isInstanceOf(MismatchedWorkbasketPermissionException.class);
} }
@WithAccessId(user = "user-2-2") @WithAccessId(user = "user-2-2")

View File

@ -14,12 +14,12 @@ import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.TestTemplate; import org.junit.jupiter.api.TestTemplate;
import org.junit.jupiter.api.extension.ExtendWith; import org.junit.jupiter.api.extension.ExtendWith;
import pro.taskana.common.api.exceptions.NotAuthorizedException;
import pro.taskana.common.test.security.JaasExtension; import pro.taskana.common.test.security.JaasExtension;
import pro.taskana.common.test.security.WithAccessId; import pro.taskana.common.test.security.WithAccessId;
import pro.taskana.workbasket.api.WorkbasketPermission; import pro.taskana.workbasket.api.WorkbasketPermission;
import pro.taskana.workbasket.api.WorkbasketService; import pro.taskana.workbasket.api.WorkbasketService;
import pro.taskana.workbasket.api.WorkbasketType; import pro.taskana.workbasket.api.WorkbasketType;
import pro.taskana.workbasket.api.exceptions.MismatchedWorkbasketPermissionException;
import pro.taskana.workbasket.api.exceptions.WorkbasketNotFoundException; import pro.taskana.workbasket.api.exceptions.WorkbasketNotFoundException;
import pro.taskana.workbasket.api.models.Workbasket; import pro.taskana.workbasket.api.models.Workbasket;
import pro.taskana.workbasket.api.models.WorkbasketSummary; import pro.taskana.workbasket.api.models.WorkbasketSummary;
@ -169,13 +169,13 @@ class GetWorkbasketAccTest extends AbstractAccTest {
void should_ThrowException_When_TryingToGetByIdWithoutPermissions() { void should_ThrowException_When_TryingToGetByIdWithoutPermissions() {
ThrowingCallable call = ThrowingCallable call =
() -> WORKBASKET_SERVICE.getWorkbasket("WBI:100000000000000000000000000000000001"); () -> WORKBASKET_SERVICE.getWorkbasket("WBI:100000000000000000000000000000000001");
assertThatThrownBy(call).isInstanceOf(NotAuthorizedException.class); assertThatThrownBy(call).isInstanceOf(MismatchedWorkbasketPermissionException.class);
} }
@Test @Test
void should_ThrowException_When_TryingToGetByKeyAndDomainWithoutPermissions() { void should_ThrowException_When_TryingToGetByKeyAndDomainWithoutPermissions() {
assertThatThrownBy(() -> WORKBASKET_SERVICE.getWorkbasket("GPK_KSC", "DOMAIN_A")) assertThatThrownBy(() -> WORKBASKET_SERVICE.getWorkbasket("GPK_KSC", "DOMAIN_A"))
.isInstanceOf(NotAuthorizedException.class); .isInstanceOf(MismatchedWorkbasketPermissionException.class);
} }
@WithAccessId(user = "user-1-1") @WithAccessId(user = "user-1-1")

View File

@ -7,7 +7,7 @@ import org.assertj.core.api.ThrowableAssert.ThrowingCallable;
import org.junit.jupiter.api.TestTemplate; import org.junit.jupiter.api.TestTemplate;
import org.junit.jupiter.api.extension.ExtendWith; import org.junit.jupiter.api.extension.ExtendWith;
import pro.taskana.common.api.exceptions.NotAuthorizedException; import pro.taskana.common.api.exceptions.MismatchedRoleException;
import pro.taskana.common.test.security.JaasExtension; import pro.taskana.common.test.security.JaasExtension;
import pro.taskana.common.test.security.WithAccessId; import pro.taskana.common.test.security.WithAccessId;
import pro.taskana.workbasket.api.WorkbasketService; import pro.taskana.workbasket.api.WorkbasketService;
@ -28,6 +28,7 @@ class GetWorkbasketAuthorizationsAccTest extends AbstractAccTest {
workbasketService.getWorkbasketAccessItems("WBI:100000000000000000000000000000000008"); workbasketService.getWorkbasketAccessItems("WBI:100000000000000000000000000000000008");
}; };
assertThatThrownBy(retrieveWorkbasketAccessItemCall).isInstanceOf(NotAuthorizedException.class); assertThatThrownBy(retrieveWorkbasketAccessItemCall)
.isInstanceOf(MismatchedRoleException.class);
} }
} }

View File

@ -14,7 +14,7 @@ import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith; import org.junit.jupiter.api.extension.ExtendWith;
import pro.taskana.common.api.BaseQuery.SortDirection; import pro.taskana.common.api.BaseQuery.SortDirection;
import pro.taskana.common.api.exceptions.NotAuthorizedException; import pro.taskana.common.api.exceptions.MismatchedRoleException;
import pro.taskana.common.test.security.JaasExtension; import pro.taskana.common.test.security.JaasExtension;
import pro.taskana.common.test.security.WithAccessId; import pro.taskana.common.test.security.WithAccessId;
import pro.taskana.workbasket.api.WorkbasketAccessItemQuery; import pro.taskana.workbasket.api.WorkbasketAccessItemQuery;
@ -69,7 +69,7 @@ class QueryWorkbasketAccessItemsAccTest extends AbstractAccTest {
.accessIdIn("user-1-1", "group-1") .accessIdIn("user-1-1", "group-1")
.list(); .list();
}; };
assertThatThrownBy(call).isInstanceOf(NotAuthorizedException.class); assertThatThrownBy(call).isInstanceOf(MismatchedRoleException.class);
} }
@WithAccessId(user = "businessadmin") @WithAccessId(user = "businessadmin")

View File

@ -11,7 +11,7 @@ import org.junit.jupiter.api.TestTemplate;
import org.junit.jupiter.api.extension.ExtendWith; import org.junit.jupiter.api.extension.ExtendWith;
import pro.taskana.common.api.BaseQuery.SortDirection; import pro.taskana.common.api.BaseQuery.SortDirection;
import pro.taskana.common.api.exceptions.NotAuthorizedException; import pro.taskana.common.api.exceptions.MismatchedRoleException;
import pro.taskana.common.test.security.JaasExtension; import pro.taskana.common.test.security.JaasExtension;
import pro.taskana.common.test.security.WithAccessId; import pro.taskana.common.test.security.WithAccessId;
import pro.taskana.workbasket.api.WorkbasketPermission; import pro.taskana.workbasket.api.WorkbasketPermission;
@ -66,7 +66,7 @@ class QueryWorkbasketByPermissionAccTest extends AbstractAccTest {
.accessIdsHavePermissions(List.of(WorkbasketPermission.APPEND), "user-1-1") .accessIdsHavePermissions(List.of(WorkbasketPermission.APPEND), "user-1-1")
.list(); .list();
assertThatThrownBy(call).isInstanceOf(NotAuthorizedException.class); assertThatThrownBy(call).isInstanceOf(MismatchedRoleException.class);
} }
@WithAccessId(user = "businessadmin") @WithAccessId(user = "businessadmin")

View File

@ -9,7 +9,7 @@ import org.assertj.core.api.ThrowableAssert.ThrowingCallable;
import org.junit.jupiter.api.Test; import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith; import org.junit.jupiter.api.extension.ExtendWith;
import pro.taskana.common.api.exceptions.NotAuthorizedException; import pro.taskana.common.api.exceptions.MismatchedRoleException;
import pro.taskana.common.test.security.JaasExtension; import pro.taskana.common.test.security.JaasExtension;
import pro.taskana.common.test.security.WithAccessId; import pro.taskana.common.test.security.WithAccessId;
import pro.taskana.workbasket.api.WorkbasketPermission; import pro.taskana.workbasket.api.WorkbasketPermission;
@ -35,7 +35,7 @@ class WorkbasketQueryAccTest extends AbstractAccTest {
List.of(WorkbasketPermission.TRANSFER), "teamlead-1", GROUP_1_DN, GROUP_2_DN) List.of(WorkbasketPermission.TRANSFER), "teamlead-1", GROUP_1_DN, GROUP_2_DN)
.list(); .list();
}; };
assertThatThrownBy(call).isInstanceOf(NotAuthorizedException.class); assertThatThrownBy(call).isInstanceOf(MismatchedRoleException.class);
} }
@WithAccessId(user = "unknownuser") @WithAccessId(user = "unknownuser")
@ -54,7 +54,7 @@ class WorkbasketQueryAccTest extends AbstractAccTest {
List.of(WorkbasketPermission.TRANSFER), "teamlead-1", GROUP_1_DN, GROUP_2_DN) List.of(WorkbasketPermission.TRANSFER), "teamlead-1", GROUP_1_DN, GROUP_2_DN)
.list(); .list();
}; };
assertThatThrownBy(call).isInstanceOf(NotAuthorizedException.class); assertThatThrownBy(call).isInstanceOf(MismatchedRoleException.class);
} }
@WithAccessId(user = "businessadmin") @WithAccessId(user = "businessadmin")

View File

@ -11,7 +11,7 @@ import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.TestTemplate; import org.junit.jupiter.api.TestTemplate;
import org.junit.jupiter.api.extension.ExtendWith; import org.junit.jupiter.api.extension.ExtendWith;
import pro.taskana.common.api.exceptions.NotAuthorizedException; import pro.taskana.common.api.exceptions.MismatchedRoleException;
import pro.taskana.common.test.security.JaasExtension; import pro.taskana.common.test.security.JaasExtension;
import pro.taskana.common.test.security.WithAccessId; import pro.taskana.common.test.security.WithAccessId;
import pro.taskana.workbasket.api.WorkbasketService; import pro.taskana.workbasket.api.WorkbasketService;
@ -68,21 +68,21 @@ class UpdateDistributionTargetsAccTest extends AbstractAccTest {
workbasketService.setDistributionTargets( workbasketService.setDistributionTargets(
existingWb, List.of("WBI:100000000000000000000000000000000002")); existingWb, List.of("WBI:100000000000000000000000000000000002"));
}; };
assertThatThrownBy(call).isInstanceOf(NotAuthorizedException.class); assertThatThrownBy(call).isInstanceOf(MismatchedRoleException.class);
call = call =
() -> { () -> {
workbasketService.addDistributionTarget( workbasketService.addDistributionTarget(
existingWb, "WBI:100000000000000000000000000000000002"); existingWb, "WBI:100000000000000000000000000000000002");
}; };
assertThatThrownBy(call).isInstanceOf(NotAuthorizedException.class); assertThatThrownBy(call).isInstanceOf(MismatchedRoleException.class);
call = call =
() -> { () -> {
workbasketService.removeDistributionTarget( workbasketService.removeDistributionTarget(
existingWb, "WBI:100000000000000000000000000000000002"); existingWb, "WBI:100000000000000000000000000000000002");
}; };
assertThatThrownBy(call).isInstanceOf(NotAuthorizedException.class); assertThatThrownBy(call).isInstanceOf(MismatchedRoleException.class);
} }
@WithAccessId(user = "businessadmin") @WithAccessId(user = "businessadmin")
@ -153,7 +153,7 @@ class UpdateDistributionTargetsAccTest extends AbstractAccTest {
() -> { () -> {
workbasketService.addDistributionTarget(workbasket.getId(), newTarget.getId()); workbasketService.addDistributionTarget(workbasket.getId(), newTarget.getId());
}; };
assertThatThrownBy(call).isInstanceOf(NotAuthorizedException.class); assertThatThrownBy(call).isInstanceOf(MismatchedRoleException.class);
} }
@WithAccessId(user = "businessadmin") @WithAccessId(user = "businessadmin")

View File

@ -13,7 +13,7 @@ import org.junit.jupiter.api.extension.ExtendWith;
import pro.taskana.common.api.exceptions.ConcurrencyException; import pro.taskana.common.api.exceptions.ConcurrencyException;
import pro.taskana.common.api.exceptions.InvalidArgumentException; import pro.taskana.common.api.exceptions.InvalidArgumentException;
import pro.taskana.common.api.exceptions.NotAuthorizedException; import pro.taskana.common.api.exceptions.MismatchedRoleException;
import pro.taskana.common.test.security.JaasExtension; import pro.taskana.common.test.security.JaasExtension;
import pro.taskana.common.test.security.WithAccessId; import pro.taskana.common.test.security.WithAccessId;
import pro.taskana.workbasket.api.WorkbasketCustomField; import pro.taskana.workbasket.api.WorkbasketCustomField;
@ -142,6 +142,6 @@ class UpdateWorkbasketAccTest extends AbstractAccTest {
workbasket.setName("new name"); workbasket.setName("new name");
assertThatThrownBy(() -> workbasketService.updateWorkbasket(workbasket)) assertThatThrownBy(() -> workbasketService.updateWorkbasket(workbasket))
.isInstanceOf(NotAuthorizedException.class); .isInstanceOf(MismatchedRoleException.class);
} }
} }

View File

@ -16,7 +16,7 @@ import org.junit.jupiter.api.extension.ExtendWith;
import pro.taskana.common.api.KeyDomain; import pro.taskana.common.api.KeyDomain;
import pro.taskana.common.api.exceptions.InvalidArgumentException; import pro.taskana.common.api.exceptions.InvalidArgumentException;
import pro.taskana.common.api.exceptions.NotAuthorizedException; import pro.taskana.common.api.exceptions.MismatchedRoleException;
import pro.taskana.common.test.security.JaasExtension; import pro.taskana.common.test.security.JaasExtension;
import pro.taskana.common.test.security.WithAccessId; import pro.taskana.common.test.security.WithAccessId;
import pro.taskana.task.api.TaskService; import pro.taskana.task.api.TaskService;
@ -45,7 +45,7 @@ class UpdateWorkbasketAuthorizationsAccTest extends AbstractAccTest {
"WBI:100000000000000000000000000000000008", "newAccessIdForUpdate"); "WBI:100000000000000000000000000000000008", "newAccessIdForUpdate");
assertThatThrownBy(() -> workbasketService.updateWorkbasketAccessItem(workbasketAccessItem)) assertThatThrownBy(() -> workbasketService.updateWorkbasketAccessItem(workbasketAccessItem))
.isInstanceOf(NotAuthorizedException.class); .isInstanceOf(MismatchedRoleException.class);
} }
@Test @Test

View File

@ -12,7 +12,7 @@ import org.springframework.web.bind.annotation.RestController;
import pro.taskana.common.api.TaskanaEngine; import pro.taskana.common.api.TaskanaEngine;
import pro.taskana.common.api.exceptions.DomainNotFoundException; import pro.taskana.common.api.exceptions.DomainNotFoundException;
import pro.taskana.common.api.exceptions.InvalidArgumentException; import pro.taskana.common.api.exceptions.InvalidArgumentException;
import pro.taskana.common.api.exceptions.NotAuthorizedException; import pro.taskana.common.api.exceptions.MismatchedRoleException;
import pro.taskana.common.internal.util.IdGenerator; import pro.taskana.common.internal.util.IdGenerator;
import pro.taskana.workbasket.api.WorkbasketType; import pro.taskana.workbasket.api.WorkbasketType;
import pro.taskana.workbasket.api.exceptions.WorkbasketAlreadyExistException; import pro.taskana.workbasket.api.exceptions.WorkbasketAlreadyExistException;
@ -51,8 +51,8 @@ public class TaskanaTestController {
@GetMapping(path = "/transaction") @GetMapping(path = "/transaction")
public @ResponseBody String transaction( public @ResponseBody String transaction(
@RequestParam(value = "rollback", defaultValue = "false") String rollback) @RequestParam(value = "rollback", defaultValue = "false") String rollback)
throws InvalidArgumentException, NotAuthorizedException, WorkbasketAlreadyExistException, throws InvalidArgumentException, WorkbasketAlreadyExistException, DomainNotFoundException,
DomainNotFoundException { MismatchedRoleException {
taskanaEngine.getWorkbasketService().createWorkbasket(createWorkBasket("key", "workbasket")); taskanaEngine.getWorkbasketService().createWorkbasket(createWorkBasket("key", "workbasket"));
int workbaskets = getWorkbaskets(); int workbaskets = getWorkbaskets();
@ -67,8 +67,8 @@ public class TaskanaTestController {
@GetMapping(path = "/transaction-many") @GetMapping(path = "/transaction-many")
public @ResponseBody String transactionMany( public @ResponseBody String transactionMany(
@RequestParam(value = "rollback", defaultValue = "false") String rollback) @RequestParam(value = "rollback", defaultValue = "false") String rollback)
throws InvalidArgumentException, NotAuthorizedException, WorkbasketAlreadyExistException, throws InvalidArgumentException, WorkbasketAlreadyExistException, DomainNotFoundException,
DomainNotFoundException { MismatchedRoleException {
taskanaEngine.getWorkbasketService().createWorkbasket(createWorkBasket("key1", "workbasket1")); taskanaEngine.getWorkbasketService().createWorkbasket(createWorkBasket("key1", "workbasket1"));
taskanaEngine.getWorkbasketService().createWorkbasket(createWorkBasket("key2", "workbasket2")); taskanaEngine.getWorkbasketService().createWorkbasket(createWorkBasket("key2", "workbasket2"));
taskanaEngine.getWorkbasketService().createWorkbasket(createWorkBasket("key3", "workbasket3")); taskanaEngine.getWorkbasketService().createWorkbasket(createWorkBasket("key3", "workbasket3"));
@ -84,8 +84,8 @@ public class TaskanaTestController {
@GetMapping(path = "/customdb") @GetMapping(path = "/customdb")
public @ResponseBody String transactionCustomdb( public @ResponseBody String transactionCustomdb(
@RequestParam(value = "rollback", defaultValue = "false") String rollback) @RequestParam(value = "rollback", defaultValue = "false") String rollback)
throws InvalidArgumentException, NotAuthorizedException, WorkbasketAlreadyExistException, throws InvalidArgumentException, WorkbasketAlreadyExistException, DomainNotFoundException,
DomainNotFoundException { MismatchedRoleException {
taskanaEngine.getWorkbasketService().createWorkbasket(createWorkBasket("key1", "workbasket1")); taskanaEngine.getWorkbasketService().createWorkbasket(createWorkBasket("key1", "workbasket1"));
taskanaEngine.getWorkbasketService().createWorkbasket(createWorkBasket("key2", "workbasket2")); taskanaEngine.getWorkbasketService().createWorkbasket(createWorkBasket("key2", "workbasket2"));

View File

@ -6,13 +6,13 @@ import org.springframework.transaction.annotation.Transactional;
import pro.taskana.classification.api.exceptions.ClassificationNotFoundException; import pro.taskana.classification.api.exceptions.ClassificationNotFoundException;
import pro.taskana.common.api.exceptions.InvalidArgumentException; import pro.taskana.common.api.exceptions.InvalidArgumentException;
import pro.taskana.common.api.exceptions.NotAuthorizedException;
import pro.taskana.task.api.TaskService; import pro.taskana.task.api.TaskService;
import pro.taskana.task.api.exceptions.AttachmentPersistenceException; import pro.taskana.task.api.exceptions.AttachmentPersistenceException;
import pro.taskana.task.api.exceptions.ObjectReferencePersistenceException; import pro.taskana.task.api.exceptions.ObjectReferencePersistenceException;
import pro.taskana.task.api.exceptions.TaskAlreadyExistException; import pro.taskana.task.api.exceptions.TaskAlreadyExistException;
import pro.taskana.task.api.models.Task; import pro.taskana.task.api.models.Task;
import pro.taskana.task.internal.models.ObjectReferenceImpl; import pro.taskana.task.internal.models.ObjectReferenceImpl;
import pro.taskana.workbasket.api.exceptions.MismatchedWorkbasketPermissionException;
import pro.taskana.workbasket.api.exceptions.WorkbasketNotFoundException; import pro.taskana.workbasket.api.exceptions.WorkbasketNotFoundException;
/** TODO. */ /** TODO. */
@ -27,9 +27,9 @@ public class TaskanaComponent {
} }
public void triggerRollback() public void triggerRollback()
throws NotAuthorizedException, WorkbasketNotFoundException, ClassificationNotFoundException, throws WorkbasketNotFoundException, ClassificationNotFoundException,
TaskAlreadyExistException, InvalidArgumentException, AttachmentPersistenceException, TaskAlreadyExistException, InvalidArgumentException, AttachmentPersistenceException,
ObjectReferencePersistenceException { ObjectReferencePersistenceException, MismatchedWorkbasketPermissionException {
Task task = taskService.newTask("1"); Task task = taskService.newTask("1");
task.setName("Unit Test Task"); task.setName("Unit Test Task");
ObjectReferenceImpl objRef = new ObjectReferenceImpl(); ObjectReferenceImpl objRef = new ObjectReferenceImpl();

View File

@ -11,7 +11,7 @@ import pro.taskana.classification.api.models.Classification;
import pro.taskana.classification.api.models.ClassificationSummary; import pro.taskana.classification.api.models.ClassificationSummary;
import pro.taskana.common.api.exceptions.DomainNotFoundException; import pro.taskana.common.api.exceptions.DomainNotFoundException;
import pro.taskana.common.api.exceptions.InvalidArgumentException; import pro.taskana.common.api.exceptions.InvalidArgumentException;
import pro.taskana.common.api.exceptions.NotAuthorizedException; import pro.taskana.common.api.exceptions.MismatchedRoleException;
import pro.taskana.testapi.builder.EntityBuilder.SummaryEntityBuilder; import pro.taskana.testapi.builder.EntityBuilder.SummaryEntityBuilder;
public class ClassificationBuilder public class ClassificationBuilder
@ -119,7 +119,7 @@ public class ClassificationBuilder
@Override @Override
public Classification buildAndStore(ClassificationService classificationService) public Classification buildAndStore(ClassificationService classificationService)
throws InvalidArgumentException, ClassificationAlreadyExistException, DomainNotFoundException, throws InvalidArgumentException, ClassificationAlreadyExistException, DomainNotFoundException,
MalformedServiceLevelException, NotAuthorizedException, ClassificationNotFoundException { MalformedServiceLevelException, ClassificationNotFoundException, MismatchedRoleException {
try { try {
Classification c = classificationService.createClassification(testClassification); Classification c = classificationService.createClassification(testClassification);
return classificationService.getClassification(c.getId()); return classificationService.getClassification(c.getId());

View File

@ -7,7 +7,6 @@ import java.util.Map;
import pro.taskana.classification.api.exceptions.ClassificationNotFoundException; import pro.taskana.classification.api.exceptions.ClassificationNotFoundException;
import pro.taskana.classification.api.models.ClassificationSummary; import pro.taskana.classification.api.models.ClassificationSummary;
import pro.taskana.common.api.exceptions.InvalidArgumentException; import pro.taskana.common.api.exceptions.InvalidArgumentException;
import pro.taskana.common.api.exceptions.NotAuthorizedException;
import pro.taskana.task.api.CallbackState; import pro.taskana.task.api.CallbackState;
import pro.taskana.task.api.TaskCustomField; import pro.taskana.task.api.TaskCustomField;
import pro.taskana.task.api.TaskCustomIntField; import pro.taskana.task.api.TaskCustomIntField;
@ -22,6 +21,7 @@ import pro.taskana.task.api.models.ObjectReference;
import pro.taskana.task.api.models.Task; import pro.taskana.task.api.models.Task;
import pro.taskana.task.api.models.TaskSummary; import pro.taskana.task.api.models.TaskSummary;
import pro.taskana.testapi.builder.EntityBuilder.SummaryEntityBuilder; import pro.taskana.testapi.builder.EntityBuilder.SummaryEntityBuilder;
import pro.taskana.workbasket.api.exceptions.MismatchedWorkbasketPermissionException;
import pro.taskana.workbasket.api.exceptions.WorkbasketNotFoundException; import pro.taskana.workbasket.api.exceptions.WorkbasketNotFoundException;
import pro.taskana.workbasket.api.models.WorkbasketSummary; import pro.taskana.workbasket.api.models.WorkbasketSummary;
@ -215,8 +215,9 @@ public class TaskBuilder implements SummaryEntityBuilder<TaskSummary, Task, Task
@Override @Override
public Task buildAndStore(TaskService taskService) public Task buildAndStore(TaskService taskService)
throws TaskAlreadyExistException, InvalidArgumentException, WorkbasketNotFoundException, throws TaskAlreadyExistException, InvalidArgumentException, WorkbasketNotFoundException,
ClassificationNotFoundException, NotAuthorizedException, AttachmentPersistenceException, ClassificationNotFoundException, AttachmentPersistenceException,
ObjectReferencePersistenceException, TaskNotFoundException { ObjectReferencePersistenceException, TaskNotFoundException,
MismatchedWorkbasketPermissionException {
try { try {
Task task = taskService.createTask(testTask); Task task = taskService.createTask(testTask);
return taskService.getTask(task.getId()); return taskService.getTask(task.getId());

View File

@ -3,11 +3,11 @@ package pro.taskana.testapi.builder;
import java.time.Instant; import java.time.Instant;
import pro.taskana.common.api.exceptions.InvalidArgumentException; import pro.taskana.common.api.exceptions.InvalidArgumentException;
import pro.taskana.common.api.exceptions.NotAuthorizedException;
import pro.taskana.task.api.TaskService; import pro.taskana.task.api.TaskService;
import pro.taskana.task.api.exceptions.TaskCommentNotFoundException; import pro.taskana.task.api.exceptions.TaskCommentNotFoundException;
import pro.taskana.task.api.exceptions.TaskNotFoundException; import pro.taskana.task.api.exceptions.TaskNotFoundException;
import pro.taskana.task.api.models.TaskComment; import pro.taskana.task.api.models.TaskComment;
import pro.taskana.workbasket.api.exceptions.MismatchedWorkbasketPermissionException;
public class TaskCommentBuilder implements EntityBuilder<TaskComment, TaskService> { public class TaskCommentBuilder implements EntityBuilder<TaskComment, TaskService> {
@ -49,8 +49,8 @@ public class TaskCommentBuilder implements EntityBuilder<TaskComment, TaskServic
@Override @Override
public TaskComment buildAndStore(TaskService taskService) public TaskComment buildAndStore(TaskService taskService)
throws InvalidArgumentException, TaskNotFoundException, NotAuthorizedException, throws InvalidArgumentException, TaskNotFoundException, TaskCommentNotFoundException,
TaskCommentNotFoundException { MismatchedWorkbasketPermissionException {
try { try {
TaskComment t = taskService.createTaskComment(testTaskComment); TaskComment t = taskService.createTaskComment(testTaskComment);
return taskService.getTaskComment(t.getId()); return taskService.getTaskComment(t.getId());

Some files were not shown because too many files have changed in this diff Show More