Allon Mureinik has uploaded a new change for review.

Change subject: core: Streamline MoveVmCommand.canDoAction
......................................................................

core: Streamline MoveVmCommand.canDoAction

MoveVmCommand's constructor uses getVm().getStoragePoolId(), so it is
safe to assume that the VM is not null in the canDoAction() method.

This method removes this redundant check from canDoAction(), and moves
all the initializer logic from it to the constructor, where it belongs.

Change-Id: I047f744cdaf8f7b1b5a788c9435642eb05ed6919
Signed-off-by: Allon Mureinik <amure...@redhat.com>
---
M 
backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/MoveVmCommand.java
1 file changed, 3 insertions(+), 11 deletions(-)


  git pull ssh://gerrit.ovirt.org:29418/ovirt-engine refs/changes/21/11321/1

diff --git 
a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/MoveVmCommand.java
 
b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/MoveVmCommand.java
index 2145a1e..c552ddb 100644
--- 
a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/MoveVmCommand.java
+++ 
b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/MoveVmCommand.java
@@ -42,6 +42,7 @@
         setVmId(parameters.getContainerId());
         parameters.setEntityId(getVmId());
         setStoragePoolId(getVm().getStoragePoolId());
+        setDescription(getVmName());
     }
 
     @Override
@@ -57,17 +58,9 @@
 
     @Override
     protected boolean canDoAction() {
-        boolean retValue = true;
-        if (getVm() == null) {
-            retValue = false;
-            
addCanDoActionMessage(VdcBllMessages.ACTION_TYPE_FAILED_VM_NOT_FOUND);
-        } else {
-            setDescription(getVmName());
-        }
-
         SnapshotsValidator snapshotValidator = new SnapshotsValidator();
-        retValue = retValue
-                && validate(snapshotValidator.vmNotDuringSnapshot(getVmId()))
+        boolean retValue =
+                validate(snapshotValidator.vmNotDuringSnapshot(getVmId()))
                 && validate(snapshotValidator.vmNotInPreview(getVmId()))
                 && validate(new VmValidator(getVm()).vmDown());
 
@@ -87,7 +80,6 @@
                                 false,
                                 true,
                                 diskImages);
-        setStoragePoolId(getVm().getStoragePoolId());
 
         ensureDomainMap(diskImages, getParameters().getStorageDomainId());
         for(DiskImage disk : diskImages) {


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

Gerrit-MessageType: newchange
Gerrit-Change-Id: I047f744cdaf8f7b1b5a788c9435642eb05ed6919
Gerrit-PatchSet: 1
Gerrit-Project: ovirt-engine
Gerrit-Branch: master
Gerrit-Owner: Allon Mureinik <amure...@redhat.com>
_______________________________________________
Engine-patches mailing list
Engine-patches@ovirt.org
http://lists.ovirt.org/mailman/listinfo/engine-patches

Reply via email to