TSK-2016: replaced MapCreator methods with Map#of calls
This commit is contained in:
parent
2592a7f562
commit
d3b59dfd6a
|
@ -1,6 +1,6 @@
|
|||
package pro.taskana.common.api.exceptions;
|
||||
|
||||
import pro.taskana.common.internal.util.MapCreator;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* This exception is thrown when an attempt is made to update an object that has already been
|
||||
|
@ -16,7 +16,7 @@ public class ConcurrencyException extends TaskanaException {
|
|||
String.format(
|
||||
"The entity with id '%s' cannot be updated since it has been modified while editing.",
|
||||
entityId),
|
||||
ErrorCode.of(ERROR_KEY, MapCreator.of("entityId", entityId)));
|
||||
ErrorCode.of(ERROR_KEY, Map.of("entityId", ensureNullIsHandled(entityId))));
|
||||
this.entityId = entityId;
|
||||
}
|
||||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
package pro.taskana.common.api.exceptions;
|
||||
|
||||
import pro.taskana.common.internal.util.MapCreator;
|
||||
import java.util.Map;
|
||||
|
||||
/** This exception is thrown when the specified domain is not found in the configuration. */
|
||||
public class DomainNotFoundException extends TaskanaException {
|
||||
|
@ -11,7 +11,7 @@ public class DomainNotFoundException extends TaskanaException {
|
|||
public DomainNotFoundException(String domain) {
|
||||
super(
|
||||
String.format("Domain '%s' does not exist in the configuration", domain),
|
||||
ErrorCode.of(ERROR_KEY, MapCreator.of("domain", domain)));
|
||||
ErrorCode.of(ERROR_KEY, Map.of("domain", ensureNullIsHandled(domain))));
|
||||
this.domain = domain;
|
||||
}
|
||||
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
package pro.taskana.common.api.exceptions;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.Map;
|
||||
import pro.taskana.common.api.TaskanaRole;
|
||||
import pro.taskana.common.internal.util.MapCreator;
|
||||
|
||||
/**
|
||||
* This exception is thrown when the current user is not in a certain {@linkplain TaskanaRole role}
|
||||
|
@ -19,7 +19,11 @@ public class NotAuthorizedException extends TaskanaException {
|
|||
String.format(
|
||||
"Not authorized. The current user '%s' is not member of role(s) '%s'.",
|
||||
currentUserId, Arrays.toString(roles)),
|
||||
ErrorCode.of(ERROR_KEY, MapCreator.of("roles", roles, "currentUserId", currentUserId)));
|
||||
ErrorCode.of(
|
||||
ERROR_KEY,
|
||||
Map.ofEntries(
|
||||
Map.entry("roles", ensureNullIsHandled(roles)),
|
||||
Map.entry("currentUserId", ensureNullIsHandled(currentUserId)))));
|
||||
|
||||
this.currentUserId = currentUserId;
|
||||
this.roles = roles;
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
package pro.taskana.common.api.exceptions;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
/** common base class for TASKANA's checked exceptions. */
|
||||
public class TaskanaException extends Exception {
|
||||
|
||||
|
@ -18,6 +20,10 @@ public class TaskanaException extends Exception {
|
|||
return errorCode;
|
||||
}
|
||||
|
||||
protected static Serializable ensureNullIsHandled(Serializable o) {
|
||||
return o == null ? "null" : o;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return getClass().getSimpleName()
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
package pro.taskana.common.api.exceptions;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
/** The common base class for TASKANA's runtime exceptions. */
|
||||
public class TaskanaRuntimeException extends RuntimeException {
|
||||
|
||||
|
@ -18,6 +20,10 @@ public class TaskanaRuntimeException extends RuntimeException {
|
|||
return errorCode;
|
||||
}
|
||||
|
||||
protected static Serializable ensureNullIsHandled(Serializable o) {
|
||||
return o == null ? "null" : o;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return getClass().getSimpleName()
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
package pro.taskana.common.api.exceptions;
|
||||
|
||||
import pro.taskana.common.internal.util.MapCreator;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* This exception is thrown when the database name doesn't match to one of the desired databases.
|
||||
|
@ -13,7 +13,8 @@ public class UnsupportedDatabaseException extends TaskanaRuntimeException {
|
|||
public UnsupportedDatabaseException(String databaseProductName) {
|
||||
super(
|
||||
String.format("Database '%s' is not supported", databaseProductName),
|
||||
ErrorCode.of(ERROR_KEY, MapCreator.of("databaseProductName", databaseProductName)));
|
||||
ErrorCode.of(
|
||||
ERROR_KEY, Map.of("databaseProductName", ensureNullIsHandled(databaseProductName))));
|
||||
this.databaseProductName = databaseProductName;
|
||||
}
|
||||
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
package pro.taskana.common.api.exceptions;
|
||||
|
||||
import java.util.Map;
|
||||
import pro.taskana.common.api.CustomHoliday;
|
||||
import pro.taskana.common.internal.util.MapCreator;
|
||||
|
||||
/** This exception is thrown when an entry for the {@linkplain CustomHoliday} has a wrong format. */
|
||||
public class WrongCustomHolidayFormatException extends TaskanaRuntimeException {
|
||||
|
@ -15,7 +15,7 @@ public class WrongCustomHolidayFormatException extends TaskanaRuntimeException {
|
|||
"Wrong format for custom holiday entry '%s'! The format should be 'dd.MM' "
|
||||
+ "i.e. 01.05 for the first of May.",
|
||||
customHoliday),
|
||||
ErrorCode.of(ERROR_KEY, MapCreator.of("customHoliday", customHoliday)));
|
||||
ErrorCode.of(ERROR_KEY, Map.of("customHoliday", ensureNullIsHandled(customHoliday))));
|
||||
this.customHoliday = customHoliday;
|
||||
}
|
||||
|
||||
|
|
|
@ -1,57 +0,0 @@
|
|||
package pro.taskana.common.internal.util;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
/* This class will be removed once we fully migrate from JDK8*/
|
||||
public class MapCreator {
|
||||
|
||||
private MapCreator() {
|
||||
throw new IllegalStateException("Utility class");
|
||||
}
|
||||
|
||||
public static <K, V> Map<K, V> of() {
|
||||
return Collections.emptyMap();
|
||||
}
|
||||
|
||||
public static <K, V> Map<K, V> of(K k1, V v1) {
|
||||
Map<K, V> map = new HashMap<>();
|
||||
map.put(k1, v1);
|
||||
return map;
|
||||
}
|
||||
|
||||
public static <K, V> Map<K, V> of(K k1, V v1, K k2, V v2) {
|
||||
Map<K, V> map = new HashMap<>();
|
||||
map.put(k1, v1);
|
||||
map.put(k2, v2);
|
||||
return map;
|
||||
}
|
||||
|
||||
public static <K, V> Map<K, V> of(K k1, V v1, K k2, V v2, K k3, V v3) {
|
||||
Map<K, V> map = new HashMap<>();
|
||||
map.put(k1, v1);
|
||||
map.put(k2, v2);
|
||||
map.put(k3, v3);
|
||||
return map;
|
||||
}
|
||||
|
||||
public static <K, V> Map<K, V> of(K k1, V v1, K k2, V v2, K k3, V v3, K k4, V v4) {
|
||||
Map<K, V> map = new HashMap<>();
|
||||
map.put(k1, v1);
|
||||
map.put(k2, v2);
|
||||
map.put(k3, v3);
|
||||
map.put(k4, v4);
|
||||
return map;
|
||||
}
|
||||
|
||||
public static <K, V> Map<K, V> of(K k1, V v1, K k2, V v2, K k3, V v3, K k4, V v4, K k5, V v5) {
|
||||
Map<K, V> map = new HashMap<>();
|
||||
map.put(k1, v1);
|
||||
map.put(k2, v2);
|
||||
map.put(k3, v3);
|
||||
map.put(k4, v4);
|
||||
map.put(k5, v5);
|
||||
return map;
|
||||
}
|
||||
}
|
|
@ -70,7 +70,6 @@ import pro.taskana.common.internal.Interval;
|
|||
import pro.taskana.common.internal.TaskanaEngineImpl;
|
||||
import pro.taskana.common.internal.jobs.JobScheduler;
|
||||
import pro.taskana.common.internal.logging.LoggingAspect;
|
||||
import pro.taskana.common.internal.util.MapCreator;
|
||||
import pro.taskana.common.internal.workingtime.HolidaySchedule;
|
||||
import pro.taskana.common.internal.workingtime.WorkingTimeCalculatorImpl;
|
||||
import pro.taskana.testapi.TaskanaIntegrationTest;
|
||||
|
@ -225,7 +224,7 @@ class ArchitectureTest {
|
|||
.should()
|
||||
.onlyDependOnClassesThat(
|
||||
resideOutsideOfPackage("..pro.taskana..internal..")
|
||||
.or(assignableTo(LoggingAspect.class).or(assignableTo(MapCreator.class))))
|
||||
.or(assignableTo(LoggingAspect.class)))
|
||||
.check(importedClasses);
|
||||
}
|
||||
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
package pro.taskana.classification.api.exceptions;
|
||||
|
||||
import java.util.Map;
|
||||
import pro.taskana.classification.api.models.Classification;
|
||||
import pro.taskana.common.api.exceptions.ErrorCode;
|
||||
import pro.taskana.common.api.exceptions.TaskanaException;
|
||||
import pro.taskana.common.internal.util.MapCreator;
|
||||
|
||||
/**
|
||||
* This exception is thrown when a {@linkplain Classification} does already exits, but was tried to
|
||||
|
@ -23,7 +23,11 @@ public class ClassificationAlreadyExistException extends TaskanaException {
|
|||
public ClassificationAlreadyExistException(String key, String domain) {
|
||||
super(
|
||||
String.format("A Classification with key '%s' already exists in domain '%s'.", key, domain),
|
||||
ErrorCode.of(ERROR_KEY, MapCreator.of("classificationKey", key, "domain", domain)));
|
||||
ErrorCode.of(
|
||||
ERROR_KEY,
|
||||
Map.ofEntries(
|
||||
Map.entry("classificationKey", ensureNullIsHandled(key)),
|
||||
Map.entry("domain", ensureNullIsHandled(domain)))));
|
||||
classificationKey = key;
|
||||
this.domain = domain;
|
||||
}
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
package pro.taskana.classification.api.exceptions;
|
||||
|
||||
import java.util.Map;
|
||||
import pro.taskana.classification.api.models.Classification;
|
||||
import pro.taskana.common.api.exceptions.ErrorCode;
|
||||
import pro.taskana.common.api.exceptions.TaskanaException;
|
||||
import pro.taskana.common.internal.util.MapCreator;
|
||||
import pro.taskana.task.api.models.Attachment;
|
||||
import pro.taskana.task.api.models.Task;
|
||||
|
||||
|
@ -28,11 +28,9 @@ public class ClassificationInUseException extends TaskanaException {
|
|||
classification.getId(), classification.getKey(), classification.getDomain()),
|
||||
ErrorCode.of(
|
||||
ERROR_KEY,
|
||||
MapCreator.of(
|
||||
"classificationKey",
|
||||
classification.getKey(),
|
||||
"domain",
|
||||
classification.getDomain())),
|
||||
Map.ofEntries(
|
||||
Map.entry("classificationKey", ensureNullIsHandled(classification.getKey())),
|
||||
Map.entry("domain", ensureNullIsHandled(classification.getDomain())))),
|
||||
cause);
|
||||
classificationKey = classification.getKey();
|
||||
domain = classification.getDomain();
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
package pro.taskana.classification.api.exceptions;
|
||||
|
||||
import java.util.Map;
|
||||
import pro.taskana.classification.api.models.Classification;
|
||||
import pro.taskana.common.api.exceptions.ErrorCode;
|
||||
import pro.taskana.common.api.exceptions.TaskanaException;
|
||||
import pro.taskana.common.internal.util.MapCreator;
|
||||
|
||||
/** Thrown if a specific {@linkplain Classification} is not in the database. */
|
||||
public class ClassificationNotFoundException extends TaskanaException {
|
||||
|
@ -17,7 +17,8 @@ public class ClassificationNotFoundException extends TaskanaException {
|
|||
public ClassificationNotFoundException(String classificationId) {
|
||||
super(
|
||||
String.format("Classification with id '%s' wasn't found", classificationId),
|
||||
ErrorCode.of(ERROR_KEY_ID, MapCreator.of("classificationId", classificationId)));
|
||||
ErrorCode.of(
|
||||
ERROR_KEY_ID, Map.of("classificationId", ensureNullIsHandled(classificationId))));
|
||||
this.classificationId = classificationId;
|
||||
classificationKey = null;
|
||||
domain = null;
|
||||
|
@ -28,7 +29,10 @@ public class ClassificationNotFoundException extends TaskanaException {
|
|||
String.format(
|
||||
"Classification with key '%s' and domain '%s' could not be found", key, domain),
|
||||
ErrorCode.of(
|
||||
ERROR_KEY_KEY_DOMAIN, MapCreator.of("classificationKey", key, "domain", domain)));
|
||||
ERROR_KEY_KEY_DOMAIN,
|
||||
Map.ofEntries(
|
||||
Map.entry("classificationKey", ensureNullIsHandled(key)),
|
||||
Map.entry("domain", ensureNullIsHandled(domain)))));
|
||||
this.classificationKey = key;
|
||||
this.domain = domain;
|
||||
classificationId = null;
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
package pro.taskana.classification.api.exceptions;
|
||||
|
||||
import java.util.Map;
|
||||
import pro.taskana.classification.api.models.Classification;
|
||||
import pro.taskana.common.api.exceptions.ErrorCode;
|
||||
import pro.taskana.common.api.exceptions.TaskanaException;
|
||||
import pro.taskana.common.internal.util.MapCreator;
|
||||
|
||||
/**
|
||||
* This exception is thrown when the {@linkplain Classification#getServiceLevel() service level} of
|
||||
|
@ -30,13 +30,10 @@ public class MalformedServiceLevelException extends TaskanaException {
|
|||
serviceLevel, classificationKey, domain),
|
||||
ErrorCode.of(
|
||||
ERROR_KEY,
|
||||
MapCreator.of(
|
||||
"classificationKey",
|
||||
classificationKey,
|
||||
"domain",
|
||||
domain,
|
||||
"serviceLevel",
|
||||
serviceLevel)));
|
||||
Map.ofEntries(
|
||||
Map.entry("classificationKey", classificationKey),
|
||||
Map.entry("domain", domain),
|
||||
Map.entry("serviceLevel", serviceLevel))));
|
||||
this.serviceLevel = serviceLevel;
|
||||
this.classificationKey = classificationKey;
|
||||
this.domain = domain;
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
package pro.taskana.spi.history.api.exceptions;
|
||||
|
||||
import java.util.Map;
|
||||
import pro.taskana.common.api.exceptions.ErrorCode;
|
||||
import pro.taskana.common.api.exceptions.TaskanaException;
|
||||
import pro.taskana.common.internal.util.MapCreator;
|
||||
import pro.taskana.spi.history.api.events.task.TaskHistoryEvent;
|
||||
|
||||
/**
|
||||
|
@ -17,7 +17,7 @@ public class TaskanaHistoryEventNotFoundException extends TaskanaException {
|
|||
public TaskanaHistoryEventNotFoundException(String historyEventId) {
|
||||
super(
|
||||
String.format("TaskHistoryEvent with id '%s' was not found", historyEventId),
|
||||
ErrorCode.of(ERROR_KEY, MapCreator.of("historyEventId", historyEventId)));
|
||||
ErrorCode.of(ERROR_KEY, Map.of("historyEventId", ensureNullIsHandled(historyEventId))));
|
||||
this.historyEventId = historyEventId;
|
||||
}
|
||||
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
package pro.taskana.task.api.exceptions;
|
||||
|
||||
import java.util.Map;
|
||||
import pro.taskana.common.api.exceptions.ErrorCode;
|
||||
import pro.taskana.common.api.exceptions.TaskanaException;
|
||||
import pro.taskana.common.internal.util.MapCreator;
|
||||
import pro.taskana.task.api.models.Attachment;
|
||||
import pro.taskana.task.api.models.Task;
|
||||
|
||||
|
@ -24,7 +24,11 @@ public class AttachmentPersistenceException extends TaskanaException {
|
|||
"Cannot insert Attachment with id '%s' for Task with id '%s' "
|
||||
+ "because it already exists.",
|
||||
attachmentId, taskId),
|
||||
ErrorCode.of(ERROR_KEY, MapCreator.of("attachmentId", attachmentId, "taskId", taskId)),
|
||||
ErrorCode.of(
|
||||
ERROR_KEY,
|
||||
Map.ofEntries(
|
||||
Map.entry("attachmentId", ensureNullIsHandled(attachmentId)),
|
||||
Map.entry("taskId", ensureNullIsHandled(taskId)))),
|
||||
cause);
|
||||
this.attachmentId = attachmentId;
|
||||
this.taskId = taskId;
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
package pro.taskana.task.api.exceptions;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.Map;
|
||||
import pro.taskana.common.api.exceptions.ErrorCode;
|
||||
import pro.taskana.common.api.exceptions.TaskanaException;
|
||||
import pro.taskana.common.internal.util.MapCreator;
|
||||
import pro.taskana.task.api.CallbackState;
|
||||
import pro.taskana.task.api.models.Task;
|
||||
import pro.taskana.task.internal.models.MinimalTaskSummary;
|
||||
|
@ -27,13 +27,10 @@ public class InvalidCallbackStateException extends TaskanaException {
|
|||
taskId, Arrays.toString(requiredCallbackStates), taskCallbackState),
|
||||
ErrorCode.of(
|
||||
ERROR_KEY,
|
||||
MapCreator.of(
|
||||
"taskId",
|
||||
taskId,
|
||||
"taskCallbackState",
|
||||
taskCallbackState,
|
||||
"requiredCallbackStates",
|
||||
requiredCallbackStates)));
|
||||
Map.ofEntries(
|
||||
Map.entry("taskId", ensureNullIsHandled(taskId)),
|
||||
Map.entry("taskCallbackState", ensureNullIsHandled(taskCallbackState)),
|
||||
Map.entry("requiredCallbackStates", ensureNullIsHandled(requiredCallbackStates)))));
|
||||
this.taskId = taskId;
|
||||
this.taskCallbackState = taskCallbackState;
|
||||
this.requiredCallbackStates = requiredCallbackStates;
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
package pro.taskana.task.api.exceptions;
|
||||
|
||||
import java.util.Map;
|
||||
import pro.taskana.common.api.exceptions.ErrorCode;
|
||||
import pro.taskana.common.api.exceptions.TaskanaException;
|
||||
import pro.taskana.common.internal.util.MapCreator;
|
||||
import pro.taskana.task.api.models.Task;
|
||||
|
||||
/** This exception is thrown when the current user is not the owner of the {@linkplain Task}. */
|
||||
|
@ -14,7 +14,7 @@ public class InvalidOwnerException extends TaskanaException {
|
|||
public InvalidOwnerException(String currentUserId, String taskId) {
|
||||
super(
|
||||
String.format("User '%s' is not owner of Task '%s'", currentUserId, taskId),
|
||||
ErrorCode.of(ERROR_KEY, MapCreator.of("taskId", taskId, "currentUserId", currentUserId)));
|
||||
ErrorCode.of(ERROR_KEY, Map.of("taskId", taskId, "currentUserId", currentUserId)));
|
||||
this.taskId = taskId;
|
||||
this.currentUserId = currentUserId;
|
||||
}
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
package pro.taskana.task.api.exceptions;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.Map;
|
||||
import pro.taskana.common.api.exceptions.ErrorCode;
|
||||
import pro.taskana.common.api.exceptions.TaskanaException;
|
||||
import pro.taskana.common.internal.util.MapCreator;
|
||||
import pro.taskana.task.api.TaskState;
|
||||
import pro.taskana.task.api.models.Task;
|
||||
|
||||
|
@ -26,13 +26,10 @@ public class InvalidTaskStateException extends TaskanaException {
|
|||
taskId, taskState, Arrays.toString(requiredTaskStates)),
|
||||
ErrorCode.of(
|
||||
ERROR_KEY,
|
||||
MapCreator.of(
|
||||
"taskId",
|
||||
taskId,
|
||||
"taskState",
|
||||
taskState,
|
||||
"requiredTaskStates",
|
||||
requiredTaskStates)));
|
||||
Map.ofEntries(
|
||||
Map.entry("taskId", taskId),
|
||||
Map.entry("taskState", taskState),
|
||||
Map.entry("requiredTaskStates", requiredTaskStates))));
|
||||
|
||||
this.taskId = taskId;
|
||||
this.taskState = taskState;
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
package pro.taskana.task.api.exceptions;
|
||||
|
||||
import java.util.Map;
|
||||
import pro.taskana.common.api.exceptions.ErrorCode;
|
||||
import pro.taskana.common.api.exceptions.TaskanaException;
|
||||
import pro.taskana.common.internal.util.MapCreator;
|
||||
import pro.taskana.task.api.models.TaskComment;
|
||||
|
||||
/**
|
||||
|
@ -22,7 +22,9 @@ public class NotAuthorizedOnTaskCommentException extends TaskanaException {
|
|||
currentUserId, taskCommentId),
|
||||
ErrorCode.of(
|
||||
ERROR_KEY,
|
||||
MapCreator.of("currentUserId", currentUserId, "taskCommentId", taskCommentId)));
|
||||
Map.ofEntries(
|
||||
Map.entry("currentUserId", ensureNullIsHandled(currentUserId)),
|
||||
Map.entry("taskCommentId", ensureNullIsHandled(taskCommentId)))));
|
||||
|
||||
this.currentUserId = currentUserId;
|
||||
this.taskCommentId = taskCommentId;
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
package pro.taskana.task.api.exceptions;
|
||||
|
||||
import java.util.Map;
|
||||
import pro.taskana.common.api.exceptions.ErrorCode;
|
||||
import pro.taskana.common.api.exceptions.TaskanaException;
|
||||
import pro.taskana.common.internal.util.MapCreator;
|
||||
import pro.taskana.task.api.models.ObjectReference;
|
||||
import pro.taskana.task.api.models.Task;
|
||||
|
||||
|
@ -26,7 +26,10 @@ public class ObjectReferencePersistenceException extends TaskanaException {
|
|||
+ "because it already exists.",
|
||||
objectReferenceId, taskId),
|
||||
ErrorCode.of(
|
||||
ERROR_KEY, MapCreator.of("objectReferenceId", objectReferenceId, "taskId", taskId)),
|
||||
ERROR_KEY,
|
||||
Map.ofEntries(
|
||||
Map.entry("objectReferenceId", ensureNullIsHandled(objectReferenceId)),
|
||||
Map.entry("taskId", ensureNullIsHandled(taskId)))),
|
||||
cause);
|
||||
this.objectReferenceId = objectReferenceId;
|
||||
this.taskId = taskId;
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
package pro.taskana.task.api.exceptions;
|
||||
|
||||
import java.util.Map;
|
||||
import pro.taskana.common.api.exceptions.ErrorCode;
|
||||
import pro.taskana.common.api.exceptions.TaskanaException;
|
||||
import pro.taskana.common.internal.util.MapCreator;
|
||||
import pro.taskana.task.api.models.Task;
|
||||
|
||||
/**
|
||||
|
@ -17,7 +17,7 @@ public class TaskAlreadyExistException extends TaskanaException {
|
|||
public TaskAlreadyExistException(String externalId) {
|
||||
super(
|
||||
String.format("Task with external id '%s' already exists", externalId),
|
||||
ErrorCode.of(ERROR_KEY, MapCreator.of("externalTaskId", externalId)));
|
||||
ErrorCode.of(ERROR_KEY, Map.of("externalTaskId", ensureNullIsHandled(externalId))));
|
||||
this.externalId = externalId;
|
||||
}
|
||||
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
package pro.taskana.task.api.exceptions;
|
||||
|
||||
import java.util.Map;
|
||||
import pro.taskana.common.api.exceptions.ErrorCode;
|
||||
import pro.taskana.common.api.exceptions.TaskanaException;
|
||||
import pro.taskana.common.internal.util.MapCreator;
|
||||
import pro.taskana.task.api.models.TaskComment;
|
||||
|
||||
/** This exception is thrown when a specific {@linkplain TaskComment} is not in the database. */
|
||||
|
@ -14,7 +14,7 @@ public class TaskCommentNotFoundException extends TaskanaException {
|
|||
public TaskCommentNotFoundException(String taskCommentId) {
|
||||
super(
|
||||
String.format("TaskComment with id '%s' was not found", taskCommentId),
|
||||
ErrorCode.of(ERROR_KEY, MapCreator.of("taskCommentId", taskCommentId)));
|
||||
ErrorCode.of(ERROR_KEY, Map.of("taskCommentId", ensureNullIsHandled(taskCommentId))));
|
||||
this.taskCommentId = taskCommentId;
|
||||
}
|
||||
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
package pro.taskana.task.api.exceptions;
|
||||
|
||||
import java.util.Map;
|
||||
import pro.taskana.common.api.exceptions.ErrorCode;
|
||||
import pro.taskana.common.api.exceptions.TaskanaException;
|
||||
import pro.taskana.common.internal.util.MapCreator;
|
||||
import pro.taskana.task.api.models.Task;
|
||||
|
||||
/** This exception is thrown when a specific {@linkplain Task} is not in the database. */
|
||||
|
@ -14,7 +14,7 @@ public class TaskNotFoundException extends TaskanaException {
|
|||
public TaskNotFoundException(String taskId) {
|
||||
super(
|
||||
String.format("Task with id '%s' was not found.", taskId),
|
||||
ErrorCode.of(ERROR_KEY, MapCreator.of("taskId", taskId)));
|
||||
ErrorCode.of(ERROR_KEY, Map.of("taskId", ensureNullIsHandled(taskId))));
|
||||
this.taskId = taskId;
|
||||
}
|
||||
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
package pro.taskana.user.api.exceptions;
|
||||
|
||||
import java.util.Map;
|
||||
import pro.taskana.common.api.exceptions.ErrorCode;
|
||||
import pro.taskana.common.api.exceptions.TaskanaException;
|
||||
import pro.taskana.common.internal.util.MapCreator;
|
||||
import pro.taskana.user.api.models.User;
|
||||
|
||||
/**
|
||||
|
@ -16,7 +16,7 @@ public class UserAlreadyExistException extends TaskanaException {
|
|||
public UserAlreadyExistException(String userId, Exception cause) {
|
||||
super(
|
||||
String.format("User with id '%s' already exists.", userId),
|
||||
ErrorCode.of(ERROR_KEY, MapCreator.of("userId", userId)),
|
||||
ErrorCode.of(ERROR_KEY, Map.of("userId", ensureNullIsHandled(userId))),
|
||||
cause);
|
||||
this.userId = userId;
|
||||
}
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
package pro.taskana.user.api.exceptions;
|
||||
|
||||
import java.util.Map;
|
||||
import pro.taskana.common.api.exceptions.ErrorCode;
|
||||
import pro.taskana.common.api.exceptions.TaskanaException;
|
||||
import pro.taskana.common.internal.util.MapCreator;
|
||||
import pro.taskana.user.api.models.User;
|
||||
|
||||
/**
|
||||
|
@ -16,7 +16,7 @@ public class UserNotFoundException extends TaskanaException {
|
|||
public UserNotFoundException(String userId) {
|
||||
super(
|
||||
String.format("User with id '%s' was not found.", userId),
|
||||
ErrorCode.of(ERROR_KEY, MapCreator.of("userId", userId)));
|
||||
ErrorCode.of(ERROR_KEY, Map.of("userId", ensureNullIsHandled(userId))));
|
||||
this.userId = userId;
|
||||
}
|
||||
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
package pro.taskana.workbasket.api.exceptions;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.Map;
|
||||
import pro.taskana.common.api.exceptions.ErrorCode;
|
||||
import pro.taskana.common.api.exceptions.TaskanaException;
|
||||
import pro.taskana.common.internal.util.MapCreator;
|
||||
import pro.taskana.workbasket.api.WorkbasketPermission;
|
||||
import pro.taskana.workbasket.api.models.Workbasket;
|
||||
|
||||
|
@ -30,13 +30,10 @@ public class NotAuthorizedOnWorkbasketException extends TaskanaException {
|
|||
currentUserId, Arrays.toString(requiredPermissions), workbasketId),
|
||||
ErrorCode.of(
|
||||
ERROR_KEY_ID,
|
||||
MapCreator.of(
|
||||
"currentUserId",
|
||||
currentUserId,
|
||||
"workbasketId",
|
||||
workbasketId,
|
||||
"requiredPermissions",
|
||||
requiredPermissions)));
|
||||
Map.ofEntries(
|
||||
Map.entry("currentUserId", ensureNullIsHandled(currentUserId)),
|
||||
Map.entry("workbasketId", ensureNullIsHandled(workbasketId)),
|
||||
Map.entry("requiredPermissions", ensureNullIsHandled(requiredPermissions)))));
|
||||
|
||||
this.currentUserId = currentUserId;
|
||||
this.requiredPermissions = requiredPermissions;
|
||||
|
@ -57,15 +54,11 @@ public class NotAuthorizedOnWorkbasketException extends TaskanaException {
|
|||
currentUserId, Arrays.toString(requiredPermissions), workbasketKey, domain),
|
||||
ErrorCode.of(
|
||||
ERROR_KEY_KEY_DOMAIN,
|
||||
MapCreator.of(
|
||||
"currentUserId",
|
||||
currentUserId,
|
||||
"workbasketKey",
|
||||
workbasketKey,
|
||||
"domain",
|
||||
domain,
|
||||
"requiredPermissions",
|
||||
requiredPermissions)));
|
||||
Map.ofEntries(
|
||||
Map.entry("currentUserId", ensureNullIsHandled(currentUserId)),
|
||||
Map.entry("workbasketKey", ensureNullIsHandled(workbasketKey)),
|
||||
Map.entry("domain", ensureNullIsHandled(domain)),
|
||||
Map.entry("requiredPermissions", ensureNullIsHandled(requiredPermissions)))));
|
||||
|
||||
this.currentUserId = currentUserId;
|
||||
this.requiredPermissions = requiredPermissions;
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
package pro.taskana.workbasket.api.exceptions;
|
||||
|
||||
import java.util.Map;
|
||||
import pro.taskana.common.api.exceptions.ErrorCode;
|
||||
import pro.taskana.common.api.exceptions.TaskanaException;
|
||||
import pro.taskana.common.internal.util.MapCreator;
|
||||
import pro.taskana.workbasket.api.models.WorkbasketAccessItem;
|
||||
|
||||
/**
|
||||
|
@ -20,7 +20,11 @@ public class WorkbasketAccessItemAlreadyExistException extends TaskanaException
|
|||
String.format(
|
||||
"WorkbasketAccessItem with access id '%s' and workbasket id '%s' already exists.",
|
||||
accessId, workbasketId),
|
||||
ErrorCode.of(ERROR_KEY, MapCreator.of("accessId", accessId, "workbasketId", workbasketId)));
|
||||
ErrorCode.of(
|
||||
ERROR_KEY,
|
||||
Map.ofEntries(
|
||||
Map.entry("accessId", ensureNullIsHandled(accessId)),
|
||||
Map.entry("workbasketId", ensureNullIsHandled(workbasketId)))));
|
||||
this.accessId = accessId;
|
||||
this.workbasketId = workbasketId;
|
||||
}
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
package pro.taskana.workbasket.api.exceptions;
|
||||
|
||||
import java.util.Map;
|
||||
import pro.taskana.common.api.exceptions.ErrorCode;
|
||||
import pro.taskana.common.api.exceptions.TaskanaException;
|
||||
import pro.taskana.common.internal.util.MapCreator;
|
||||
import pro.taskana.workbasket.api.models.Workbasket;
|
||||
|
||||
/**
|
||||
|
@ -18,7 +18,11 @@ public class WorkbasketAlreadyExistException extends TaskanaException {
|
|||
public WorkbasketAlreadyExistException(String key, String domain) {
|
||||
super(
|
||||
String.format("A Workbasket with key '%s' already exists in domain '%s'.", key, domain),
|
||||
ErrorCode.of(ERROR_KEY, MapCreator.of("workbasketKey", key, "domain", domain)));
|
||||
ErrorCode.of(
|
||||
ERROR_KEY,
|
||||
Map.ofEntries(
|
||||
Map.entry("workbasketKey", ensureNullIsHandled(key)),
|
||||
Map.entry("domain", ensureNullIsHandled(domain)))));
|
||||
this.key = key;
|
||||
this.domain = domain;
|
||||
}
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
package pro.taskana.workbasket.api.exceptions;
|
||||
|
||||
import java.util.Map;
|
||||
import pro.taskana.common.api.exceptions.ErrorCode;
|
||||
import pro.taskana.common.api.exceptions.TaskanaException;
|
||||
import pro.taskana.common.internal.util.MapCreator;
|
||||
import pro.taskana.workbasket.api.models.Workbasket;
|
||||
|
||||
/**
|
||||
|
@ -19,7 +19,7 @@ public class WorkbasketInUseException extends TaskanaException {
|
|||
String.format(
|
||||
"Workbasket '%s' contains non-completed Tasks and can't be marked for deletion.",
|
||||
workbasketId),
|
||||
ErrorCode.of(ERROR_KEY, MapCreator.of("workbasketId", workbasketId)));
|
||||
ErrorCode.of(ERROR_KEY, Map.of("workbasketId", ensureNullIsHandled(workbasketId))));
|
||||
this.workbasketId = workbasketId;
|
||||
}
|
||||
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
package pro.taskana.workbasket.api.exceptions;
|
||||
|
||||
import java.util.Map;
|
||||
import pro.taskana.common.api.exceptions.ErrorCode;
|
||||
import pro.taskana.common.api.exceptions.TaskanaException;
|
||||
import pro.taskana.common.internal.util.MapCreator;
|
||||
import pro.taskana.workbasket.api.models.Workbasket;
|
||||
|
||||
/**
|
||||
|
@ -19,7 +19,7 @@ public class WorkbasketMarkedForDeletionException extends TaskanaException {
|
|||
String.format(
|
||||
"Workbasket with id '%s' could not be deleted, but was marked for deletion.",
|
||||
workbasketId),
|
||||
ErrorCode.of(ERROR_KEY, MapCreator.of("workbasketId", workbasketId)));
|
||||
ErrorCode.of(ERROR_KEY, Map.of("workbasketId", ensureNullIsHandled(workbasketId))));
|
||||
this.workbasketId = workbasketId;
|
||||
}
|
||||
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
package pro.taskana.workbasket.api.exceptions;
|
||||
|
||||
import java.util.Map;
|
||||
import pro.taskana.common.api.exceptions.ErrorCode;
|
||||
import pro.taskana.common.api.exceptions.TaskanaException;
|
||||
import pro.taskana.common.internal.util.MapCreator;
|
||||
import pro.taskana.workbasket.api.models.Workbasket;
|
||||
|
||||
/** This exception is thrown when a specific {@linkplain Workbasket} is not in the database. */
|
||||
|
@ -17,7 +17,7 @@ public class WorkbasketNotFoundException extends TaskanaException {
|
|||
public WorkbasketNotFoundException(String id) {
|
||||
super(
|
||||
String.format("Workbasket with id '%s' was not found.", id),
|
||||
ErrorCode.of(ERROR_KEY_ID, MapCreator.of("workbasketId", id)));
|
||||
ErrorCode.of(ERROR_KEY_ID, Map.of("workbasketId", ensureNullIsHandled(id))));
|
||||
this.id = id;
|
||||
key = null;
|
||||
domain = null;
|
||||
|
@ -26,7 +26,11 @@ public class WorkbasketNotFoundException extends TaskanaException {
|
|||
public WorkbasketNotFoundException(String key, String domain) {
|
||||
super(
|
||||
String.format("Workbasket with key '%s' and domain '%s' was not found.", key, domain),
|
||||
ErrorCode.of(ERROR_KEY_KEY_DOMAIN, MapCreator.of("workbasketKey", key, "domain", domain)));
|
||||
ErrorCode.of(
|
||||
ERROR_KEY_KEY_DOMAIN,
|
||||
Map.ofEntries(
|
||||
Map.entry("workbasketKey", ensureNullIsHandled(key)),
|
||||
Map.entry("domain", ensureNullIsHandled(domain)))));
|
||||
id = null;
|
||||
this.key = key;
|
||||
this.domain = domain;
|
||||
|
|
|
@ -45,7 +45,6 @@ import pro.taskana.common.api.exceptions.TaskanaException;
|
|||
import pro.taskana.common.api.exceptions.TaskanaRuntimeException;
|
||||
import pro.taskana.common.api.exceptions.UnsupportedDatabaseException;
|
||||
import pro.taskana.common.api.exceptions.WrongCustomHolidayFormatException;
|
||||
import pro.taskana.common.internal.util.MapCreator;
|
||||
import pro.taskana.common.rest.models.ExceptionRepresentationModel;
|
||||
import pro.taskana.spi.history.api.exceptions.TaskanaHistoryEventNotFoundException;
|
||||
import pro.taskana.task.api.exceptions.AttachmentPersistenceException;
|
||||
|
@ -190,8 +189,7 @@ public class TaskanaRestExceptionHandler extends ResponseEntityExceptionHandler
|
|||
ErrorCode errorCode =
|
||||
wrongQueryParameters.length != 0
|
||||
? ErrorCode.of(
|
||||
ERROR_KEY_QUERY_MALFORMED,
|
||||
MapCreator.of("malformedQueryParameters", wrongQueryParameters))
|
||||
ERROR_KEY_QUERY_MALFORMED, Map.of("malformedQueryParameters", wrongQueryParameters))
|
||||
: null;
|
||||
|
||||
return buildResponse(errorCode, ex, request, HttpStatus.BAD_REQUEST);
|
||||
|
|
Loading…
Reference in New Issue