[Major] Pass activity locator, not Activity when archiving

This commit is contained in:
Robert von Burg 2021-09-28 16:54:55 +02:00
parent 86a23fa056
commit f88a80ae1c
3 changed files with 9 additions and 8 deletions

View File

@ -147,7 +147,7 @@ public class Controller {
if (this.activity.getState().isExecuted()) {
this.executionHandler.removeFromExecution(this);
logger.info("Archiving executed activity " + this.locator + " with state " + this.activity.getState());
this.executionHandler.archiveActivity(this.realm, this.activity);
this.executionHandler.archiveActivity(this.realm, this.activity.getLocator());
return false;
}

View File

@ -217,6 +217,7 @@ public class EventBasedExecutionHandler extends ExecutionHandler {
return;
}
//noinspection SynchronizeOnNonFinalField
synchronized (this.controllers) {
Map<Locator, Controller> controllers = this.controllers.getMap(realm);
if (controllers != null)
@ -409,24 +410,24 @@ public class EventBasedExecutionHandler extends ExecutionHandler {
}
@Override
public void archiveActivity(String realm, Activity activity) {
public void archiveActivity(String realm, Locator activityLoc) {
getExecutor().execute(() -> {
try {
runAsAgent(ctx -> {
try (StrolchTransaction tx = openTx(realm, ctx.getCertificate(), ArchiveActivityCommand.class,
false)) {
ArchiveActivityCommand command = new ArchiveActivityCommand(tx);
command.setActivityLoc(activity.getLocator());
command.setActivityLoc(activityLoc);
tx.addCommand(command);
tx.commitOnClose();
}
});
} catch (Exception e) {
logger.error("Failed to archive " + activity.getLocator() + " due to " + e.getMessage(), e);
logger.error("Failed to archive " + activityLoc + " due to " + e.getMessage(), e);
if (getContainer().hasComponent(OperationsLog.class)) {
getComponent(OperationsLog.class).addMessage(
new LogMessage(realm, SYSTEM_USER_AGENT, activity.getLocator(), LogSeverity.Exception,
new LogMessage(realm, SYSTEM_USER_AGENT, activityLoc, LogSeverity.Exception,
LogMessageState.Information, ResourceBundle.getBundle("strolch-service"),
"execution.handler.failed.archive").withException(e).value("reason", e));
}

View File

@ -188,10 +188,10 @@ public abstract class ExecutionHandler extends StrolchComponent {
*
* @param realm
* the realm where the activity resides
* @param activity
* the {@link Activity}
* @param activityLoc
* the {@link Locator} of the {@link Activity} to archive
*/
public abstract void archiveActivity(String realm, Activity activity);
public abstract void archiveActivity(String realm, Locator activityLoc);
/**
* Returns the {@link Set} of {@link Locator Locators} of {@link Activity Activities} which are registered for