Allon Mureinik has uploaded a new change for review.

Change subject: core: Streamline RemoveExternalEvent canDoAction()
......................................................................

core: Streamline RemoveExternalEvent canDoAction()

Streamlined and cleaned up RemoveExternalEventCommand's canDoAction()
method by using the early return pattern and overriding
setActionMessageParameters().

A nice side effect of this cleanup was do solve the possible
NullPointerExcetion FindBugs was complaining about, as the function
would not terminate if the event was null.

Change-Id: I3d2110e40ad17aea852e1002fe1de5e576dc8248
Signed-off-by: Allon Mureinik <[email protected]>
---
M 
backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/RemoveExternalEventCommand.java
1 file changed, 11 insertions(+), 12 deletions(-)


  git pull ssh://gerrit.ovirt.org:29418/ovirt-engine refs/changes/41/11641/1

diff --git 
a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/RemoveExternalEventCommand.java
 
b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/RemoveExternalEventCommand.java
index b6fb999..b69e1f4 100644
--- 
a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/RemoveExternalEventCommand.java
+++ 
b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/RemoveExternalEventCommand.java
@@ -20,26 +20,25 @@
 
     @Override
     protected boolean canDoAction() {
-        boolean result = true;
         // check if such event exists
         AuditLog event = 
DbFacade.getInstance().getAuditLogDao().get(getParameters().getId());
         if (event == null) {
-            
addCanDoActionMessage(VdcBllMessages.ACTION_TYPE_FAILED_EXTERNAL_EVENT_NOT_FOUND);
-            result = false;
+            return 
failCanDoAction(VdcBllMessages.ACTION_TYPE_FAILED_EXTERNAL_EVENT_NOT_FOUND);
         }
         if (OVIRT.equalsIgnoreCase(event.getOrigin())) {
-            
addCanDoActionMessage(VdcBllMessages.ACTION_TYPE_FAILED_EXTERNAL_EVENT_ILLEGAL_ORIGIN);
-            result = false;
+            return 
failCanDoAction(VdcBllMessages.ACTION_TYPE_FAILED_EXTERNAL_EVENT_ILLEGAL_ORIGIN);
         }
         if (!event.getseverity().equals(AuditLogSeverity.ALERT)) {
-            
addCanDoActionMessage(VdcBllMessages.ACTION_TYPE_FAILED_EXTERNAL_EVENT_ILLRGAL_OPERATION);
-            result = false;
+            return 
failCanDoAction(VdcBllMessages.ACTION_TYPE_FAILED_EXTERNAL_EVENT_ILLRGAL_OPERATION);
         }
-        if (!result) {
-            addCanDoActionMessage(VdcBllMessages.VAR__ACTION__REMOVE);
-            addCanDoActionMessage(VdcBllMessages.VAR__TYPE__EXTERNAL_EVENT);
-        }
-        return result;
+
+        return true;
+    }
+
+    @Override
+    protected void setActionMessageParameters() {
+        addCanDoActionMessage(VdcBllMessages.VAR__ACTION__REMOVE);
+        addCanDoActionMessage(VdcBllMessages.VAR__TYPE__EXTERNAL_EVENT);
     }
 
     @Override


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

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

Reply via email to