Martin Mucha has uploaded a new change for review.

Change subject: core: Added SerialMultipleActionsRunner
......................................................................

core: Added SerialMultipleActionsRunner

There are Commands written in a way disallowing separating method
calls of 'canDoAction'and 'execute'. Calling all 'canDoAction' methods
prior to calling first 'execute' yields bad results, therefore,
canDoAction have to be called prior to respective execute method.

Change-Id: I460879f1dfd5f165e58049314d08dd45d8dbfc4a
Signed-off-by: Martin Mucha <[email protected]>
---
M 
backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/MultipleActionsRunner.java
A 
backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/SerialMultipleActionsRunner.java
2 files changed, 41 insertions(+), 1 deletion(-)


  git pull ssh://gerrit.ovirt.org:29418/ovirt-engine refs/changes/92/35192/1

diff --git 
a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/MultipleActionsRunner.java
 
b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/MultipleActionsRunner.java
index 17dff8e..990e510 100644
--- 
a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/MultipleActionsRunner.java
+++ 
b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/MultipleActionsRunner.java
@@ -23,7 +23,7 @@
     private final List<VdcActionParametersBase> parameters;
     private final ArrayList<CommandBase<?>> commands = new 
ArrayList<CommandBase<?>>();
     protected boolean isInternal;
-    private boolean isWaitForResult = false;
+    protected boolean isWaitForResult = false;
 
     /**
      * Execute the actions only if CanDo of all the requests returns true
diff --git 
a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/SerialMultipleActionsRunner.java
 
b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/SerialMultipleActionsRunner.java
new file mode 100644
index 0000000..900ffe6
--- /dev/null
+++ 
b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/SerialMultipleActionsRunner.java
@@ -0,0 +1,40 @@
+package org.ovirt.engine.core.bll;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.ovirt.engine.core.bll.context.CommandContext;
+import org.ovirt.engine.core.common.action.VdcActionParametersBase;
+import org.ovirt.engine.core.common.action.VdcActionType;
+import org.ovirt.engine.core.common.action.VdcReturnValueBase;
+import org.ovirt.engine.core.utils.CorrelationIdTracker;
+
+public class SerialMultipleActionsRunner extends MultipleActionsRunner {
+
+    public SerialMultipleActionsRunner(VdcActionType actionType,
+            List<VdcActionParametersBase> parameters,
+            CommandContext commandContext, boolean isInternal) {
+        super(actionType, parameters, commandContext, isInternal);
+    }
+
+    @Override
+    protected void invokeCommands(ArrayList<VdcReturnValueBase> returnValues) {
+        //TODO MM: maybe this could be extracted as a method in parent class 
to avoid duplicity.
+        if (isWaitForResult) {
+            invokeSyncCommands();
+        } else {
+            invokeCommands();
+        }
+    }
+
+    @Override
+    protected void runCommands() {
+        for (CommandBase<?> command : getCommands()) {
+            CorrelationIdTracker.setCorrelationId(command.getCorrelationId());
+            command.canDoActionOnly();
+            if (command.getReturnValue().getCanDoAction()) {
+                executeValidatedCommand(command);
+            }
+        }
+    }
+}


-- 
To view, visit http://gerrit.ovirt.org/35192
To unsubscribe, visit http://gerrit.ovirt.org/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I460879f1dfd5f165e58049314d08dd45d8dbfc4a
Gerrit-PatchSet: 1
Gerrit-Project: ovirt-engine
Gerrit-Branch: master
Gerrit-Owner: Martin Mucha <[email protected]>
_______________________________________________
Engine-patches mailing list
[email protected]
http://lists.ovirt.org/mailman/listinfo/engine-patches

Reply via email to