TSK-1403: Add a log message to each SPI operation in case of a thrown Exception
This commit is contained in:
parent
a0c092b3b9
commit
d7e1b5cea9
|
@ -122,7 +122,6 @@ public interface TaskanaEngine {
|
|||
*/
|
||||
CurrentUserContext getCurrentUserContext();
|
||||
|
||||
|
||||
/**
|
||||
* Connection management mode. Controls the connection handling of taskana
|
||||
*
|
||||
|
|
|
@ -5,8 +5,8 @@ import org.apache.ibatis.session.SqlSession;
|
|||
|
||||
import pro.taskana.common.api.TaskanaEngine;
|
||||
import pro.taskana.spi.history.internal.HistoryEventManager;
|
||||
import pro.taskana.spi.routing.internal.TaskRoutingManager;
|
||||
import pro.taskana.spi.task.internal.CreateTaskPreprocessorManager;
|
||||
import pro.taskana.task.internal.TaskRoutingManager;
|
||||
|
||||
/**
|
||||
* FOR INTERNAL USE ONLY.
|
||||
|
|
|
@ -51,6 +51,7 @@ import pro.taskana.monitor.api.MonitorService;
|
|||
import pro.taskana.monitor.internal.MonitorMapper;
|
||||
import pro.taskana.monitor.internal.MonitorServiceImpl;
|
||||
import pro.taskana.spi.history.internal.HistoryEventManager;
|
||||
import pro.taskana.spi.routing.internal.TaskRoutingManager;
|
||||
import pro.taskana.spi.task.internal.CreateTaskPreprocessorManager;
|
||||
import pro.taskana.task.api.TaskService;
|
||||
import pro.taskana.task.internal.AttachmentMapper;
|
||||
|
@ -58,7 +59,6 @@ import pro.taskana.task.internal.ObjectReferenceMapper;
|
|||
import pro.taskana.task.internal.TaskCommentMapper;
|
||||
import pro.taskana.task.internal.TaskMapper;
|
||||
import pro.taskana.task.internal.TaskQueryMapper;
|
||||
import pro.taskana.task.internal.TaskRoutingManager;
|
||||
import pro.taskana.task.internal.TaskServiceImpl;
|
||||
import pro.taskana.workbasket.api.WorkbasketService;
|
||||
import pro.taskana.workbasket.internal.DistributionTargetMapper;
|
||||
|
|
|
@ -7,8 +7,7 @@ import org.slf4j.Logger;
|
|||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import pro.taskana.common.api.TaskanaEngine;
|
||||
import pro.taskana.common.api.exceptions.InvalidArgumentException;
|
||||
import pro.taskana.common.api.exceptions.NotAuthorizedException;
|
||||
import pro.taskana.common.api.exceptions.SystemException;
|
||||
import pro.taskana.spi.history.api.TaskanaHistory;
|
||||
import pro.taskana.spi.history.api.events.classification.ClassificationHistoryEvent;
|
||||
import pro.taskana.spi.history.api.events.task.TaskHistoryEvent;
|
||||
|
@ -18,10 +17,9 @@ import pro.taskana.spi.history.api.events.workbasket.WorkbasketHistoryEvent;
|
|||
public final class HistoryEventManager {
|
||||
|
||||
private static final Logger LOGGER = LoggerFactory.getLogger(HistoryEventManager.class);
|
||||
private static final String SENDING_EVENT = "Sending event to history service providers: {}";
|
||||
private static HistoryEventManager singleton;
|
||||
private final ServiceLoader<TaskanaHistory> serviceLoader;
|
||||
private boolean enabled = false;
|
||||
private ServiceLoader<TaskanaHistory> serviceLoader;
|
||||
|
||||
private HistoryEventManager(TaskanaEngine taskanaEngine) {
|
||||
serviceLoader = ServiceLoader.load(TaskanaHistory.class);
|
||||
|
@ -47,18 +45,55 @@ public final class HistoryEventManager {
|
|||
}
|
||||
|
||||
public void createEvent(TaskHistoryEvent event) {
|
||||
LOGGER.debug(SENDING_EVENT, event);
|
||||
serviceLoader.forEach(historyProvider -> historyProvider.create(event));
|
||||
LOGGER.debug("Sending event to history service providers: {}", event);
|
||||
serviceLoader.forEach(
|
||||
historyProvider -> {
|
||||
try {
|
||||
historyProvider.create(event);
|
||||
} catch (Exception e) {
|
||||
LOGGER.error(
|
||||
String.format(
|
||||
"Caught an exception while trying to create TaskHistoryEvent in class %s",
|
||||
historyProvider.getClass().getName()),
|
||||
e);
|
||||
throw new SystemException(e.getMessage(), e.getCause());
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public void createEvent(WorkbasketHistoryEvent event) {
|
||||
LOGGER.debug(SENDING_EVENT, event);
|
||||
serviceLoader.forEach(historyProvider -> historyProvider.create(event));
|
||||
LOGGER.debug("Sending event to history service providers: {}", event);
|
||||
serviceLoader.forEach(
|
||||
historyProvider -> {
|
||||
try {
|
||||
historyProvider.create(event);
|
||||
} catch (Exception e) {
|
||||
LOGGER.error(
|
||||
String.format(
|
||||
"Caught an exception while trying to create WorkbasketHistoryEvent in class %s",
|
||||
historyProvider.getClass().getName()),
|
||||
e);
|
||||
throw new SystemException(e.getMessage(), e.getCause());
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public void createEvent(ClassificationHistoryEvent event) {
|
||||
LOGGER.debug(SENDING_EVENT, event);
|
||||
serviceLoader.forEach(historyProvider -> historyProvider.create(event));
|
||||
LOGGER.debug("Sending event to history service providers: {}", event);
|
||||
serviceLoader.forEach(
|
||||
historyProvider -> {
|
||||
try {
|
||||
historyProvider.create(event);
|
||||
} catch (Exception e) {
|
||||
LOGGER.error(
|
||||
String.format(
|
||||
"Caught an exception while trying to create "
|
||||
+ "ClassificationHistoryEvent in class %s",
|
||||
historyProvider.getClass().getName()),
|
||||
e);
|
||||
throw new SystemException(e.getMessage(), e.getCause());
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public void deleteEvents(List<String> taskIds) {
|
||||
|
@ -67,8 +102,13 @@ public final class HistoryEventManager {
|
|||
historyProvider -> {
|
||||
try {
|
||||
historyProvider.deleteHistoryEventsByTaskIds(taskIds);
|
||||
} catch (InvalidArgumentException | NotAuthorizedException e) {
|
||||
LOGGER.warn("Caught an exception while trying to delete HistoryEvents", e);
|
||||
} catch (Exception e) {
|
||||
LOGGER.error(
|
||||
String.format(
|
||||
"Caught an exception while trying to delete HistoryEvents in class %s",
|
||||
historyProvider.getClass().getName()),
|
||||
e);
|
||||
throw new SystemException(e.getMessage(), e.getCause());
|
||||
}
|
||||
});
|
||||
}
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
package pro.taskana.task.internal;
|
||||
package pro.taskana.spi.routing.internal;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
@ -10,6 +10,7 @@ import org.slf4j.Logger;
|
|||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import pro.taskana.common.api.TaskanaEngine;
|
||||
import pro.taskana.common.api.exceptions.SystemException;
|
||||
import pro.taskana.common.internal.util.LogSanitizer;
|
||||
import pro.taskana.spi.routing.api.TaskRoutingProvider;
|
||||
import pro.taskana.task.api.models.Task;
|
||||
|
@ -23,8 +24,8 @@ public final class TaskRoutingManager {
|
|||
private static final Logger LOGGER = LoggerFactory.getLogger(TaskRoutingManager.class);
|
||||
private static TaskRoutingManager singleton;
|
||||
private boolean enabled = false;
|
||||
private List<TaskRoutingProvider> theTaskRoutingProviders = new ArrayList<>();
|
||||
private ServiceLoader<TaskRoutingProvider> serviceLoader;
|
||||
private final List<TaskRoutingProvider> theTaskRoutingProviders = new ArrayList<>();
|
||||
private final ServiceLoader<TaskRoutingProvider> serviceLoader;
|
||||
|
||||
private TaskRoutingManager(TaskanaEngine taskanaEngine) {
|
||||
serviceLoader = ServiceLoader.load(TaskRoutingProvider.class);
|
||||
|
@ -72,7 +73,19 @@ public final class TaskRoutingManager {
|
|||
// collect in a set to see whether different workbasket ids are returned
|
||||
Set<String> workbasketIds =
|
||||
theTaskRoutingProviders.stream()
|
||||
.map(rtr -> rtr.determineWorkbasketId(task))
|
||||
.map(
|
||||
rtr -> {
|
||||
try {
|
||||
return rtr.determineWorkbasketId(task);
|
||||
} catch (Exception e) {
|
||||
LOGGER.error(
|
||||
String.format(
|
||||
"Caught Exception while trying to determine workbasket in class %s",
|
||||
rtr.getClass().getName()),
|
||||
e);
|
||||
throw new SystemException(e.getMessage(), e.getCause());
|
||||
}
|
||||
})
|
||||
.filter(Objects::nonNull)
|
||||
.collect(Collectors.toSet());
|
||||
if (workbasketIds.isEmpty()) {
|
|
@ -5,6 +5,7 @@ import java.util.ServiceLoader;
|
|||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import pro.taskana.common.api.exceptions.SystemException;
|
||||
import pro.taskana.spi.task.api.CreateTaskPreprocessor;
|
||||
import pro.taskana.task.api.models.Task;
|
||||
|
||||
|
@ -13,7 +14,7 @@ public class CreateTaskPreprocessorManager {
|
|||
private static final Logger LOGGER = LoggerFactory.getLogger(CreateTaskPreprocessorManager.class);
|
||||
private static CreateTaskPreprocessorManager singleton;
|
||||
private boolean enabled = false;
|
||||
private ServiceLoader<CreateTaskPreprocessor> serviceLoader;
|
||||
private final ServiceLoader<CreateTaskPreprocessor> serviceLoader;
|
||||
|
||||
private CreateTaskPreprocessorManager() {
|
||||
serviceLoader = ServiceLoader.load(CreateTaskPreprocessor.class);
|
||||
|
@ -41,8 +42,18 @@ public class CreateTaskPreprocessorManager {
|
|||
public Task processTaskBeforeCreation(Task taskToProcess) {
|
||||
LOGGER.debug("Sending task to CreateTaskPreprocessor providers: {}", taskToProcess);
|
||||
serviceLoader.forEach(
|
||||
createTaskPreprocessorProvider ->
|
||||
createTaskPreprocessorProvider.processTaskBeforeCreation(taskToProcess));
|
||||
createTaskPreprocessorProvider -> {
|
||||
try {
|
||||
createTaskPreprocessorProvider.processTaskBeforeCreation(taskToProcess);
|
||||
} catch (Exception e) {
|
||||
LOGGER.error(
|
||||
String.format(
|
||||
"Caught exception while processing task before creation in class %s",
|
||||
createTaskPreprocessorProvider.getClass().getName()),
|
||||
e);
|
||||
throw new SystemException(e.getMessage(), e.getCause());
|
||||
}
|
||||
});
|
||||
return taskToProcess;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -47,6 +47,7 @@ class ArchitectureTest {
|
|||
"pro.taskana.workbasket.api",
|
||||
"pro.taskana.workbasket.internal",
|
||||
"pro.taskana.spi.routing.api",
|
||||
"pro.taskana.spi.routing.internal",
|
||||
"pro.taskana.spi.task.api",
|
||||
"pro.taskana.spi.task.internal"
|
||||
);
|
||||
|
|
Loading…
Reference in New Issue