From 6dfdcf6a048f4c1e96ac5e6f2a575f80550ea4fe Mon Sep 17 00:00:00 2001 From: Robert von Burg Date: Wed, 14 Jun 2017 12:53:47 +0200 Subject: [PATCH] [New] Added SimpleExecution methods with LogMessage --- .../execution/policy/SimpleExecution.java | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/li.strolch.service/src/main/java/li/strolch/execution/policy/SimpleExecution.java b/li.strolch.service/src/main/java/li/strolch/execution/policy/SimpleExecution.java index aec0d79e0..99a2cee02 100644 --- a/li.strolch.service/src/main/java/li/strolch/execution/policy/SimpleExecution.java +++ b/li.strolch.service/src/main/java/li/strolch/execution/policy/SimpleExecution.java @@ -1,6 +1,8 @@ package li.strolch.execution.policy; import li.strolch.agent.api.ComponentContainer; +import li.strolch.handler.operationslog.LogMessage; +import li.strolch.handler.operationslog.OperationsLog; import li.strolch.model.State; import li.strolch.model.activity.Action; import li.strolch.persistence.api.StrolchTransaction; @@ -49,6 +51,23 @@ public class SimpleExecution extends ExecutionPolicy { setActionState(action, State.ERROR); } + protected void addMessage(LogMessage message) { + if (getContainer().hasComponent(OperationsLog.class)) { + OperationsLog operationsLog = getContainer().getComponent(OperationsLog.class); + operationsLog.addMessage(message); + } + } + + protected void toError(String realm, LogMessage message) { + addMessage(message); + getExecutionHandler().toError(realm, message.getLocator()); + } + + protected void toWarning(String realm, LogMessage message) { + addMessage(message); + getExecutionHandler().toWarning(realm, message.getLocator()); + } + @Override public void undo() { logger.error("Can not undo execution policy " + getClass());