From ffe6b8abdc01a7f8df4956f4283d7aa192b0e38f Mon Sep 17 00:00:00 2001 From: Robert von Burg Date: Wed, 15 May 2019 11:32:45 +0200 Subject: [PATCH] [Fix] Archive activity after toExecution() if state is executed --- .../execution/EventBasedExecutionHandler.java | 23 +++++++++++++++---- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/li.strolch.service/src/main/java/li/strolch/execution/EventBasedExecutionHandler.java b/li.strolch.service/src/main/java/li/strolch/execution/EventBasedExecutionHandler.java index dd5e3e438..ef8db3f3a 100644 --- a/li.strolch.service/src/main/java/li/strolch/execution/EventBasedExecutionHandler.java +++ b/li.strolch.service/src/main/java/li/strolch/execution/EventBasedExecutionHandler.java @@ -334,12 +334,25 @@ public class EventBasedExecutionHandler extends ExecutionHandler { return; } - ExecuteActivityCommand command = new ExecuteActivityCommand(getContainer(), tx); - command.setActivity(activity); - command.validate(); - command.doCommand(); + if (activity.getState().isExecuted()) { - tx.commitOnClose(); + synchronized (this.registeredActivities) { + if (!this.registeredActivities.removeElement(realm, activityLoc)) + logger.warn("Activity " + activityLoc + " already removed from registered activities!"); + } + + logger.info("Archiving activity " + activityLoc + " with state " + activity.getState()); + archiveActivity(realm, activity.getLocator()); + + } else { + + ExecuteActivityCommand command = new ExecuteActivityCommand(getContainer(), tx); + command.setActivity(activity); + command.validate(); + command.doCommand(); + + tx.commitOnClose(); + } } }