Yair Zaslavsky has uploaded a new change for review.

Change subject: engine: Added init method to command base.
......................................................................

engine: Added init method to command base.

Added init method to command base to be performed after the permission check, 
before canDoAction

Change-Id: I0c71548a8fab5538ee97c279f12a821999635950
Signed-off-by: Yair Zaslavsky <yzasl...@redhat.com>
---
M 
backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/CommandBase.java
M 
backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/errors/ErrorType.java
M 
backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/errors/VdcBllMessages.java
M backend/manager/modules/dal/src/main/resources/bundles/AppErrors.properties
M 
backend/manager/modules/restapi/jaxrs/src/main/java/org/ovirt/engine/api/restapi/util/ErrorMessageHelper.java
M 
frontend/webadmin/modules/frontend/src/main/java/org/ovirt/engine/ui/frontend/AppErrors.java
M 
frontend/webadmin/modules/userportal-gwtp/src/main/resources/org/ovirt/engine/ui/frontend/AppErrors.properties
M 
frontend/webadmin/modules/webadmin/src/main/resources/org/ovirt/engine/ui/frontend/AppErrors.properties
8 files changed, 33 insertions(+), 1 deletion(-)


  git pull ssh://gerrit.ovirt.org:29418/ovirt-engine refs/changes/10/37110/1

diff --git 
a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/CommandBase.java
 
b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/CommandBase.java
index f07815c..0921aa1 100644
--- 
a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/CommandBase.java
+++ 
b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/CommandBase.java
@@ -769,7 +769,8 @@
             Transaction transaction = TransactionSupport.suspend();
             try {
                 returnValue =
-                        isUserAuthorizedToRunAction() && 
isBackwardsCompatible() && validateInputs() && acquireLock()
+                        isUserAuthorizedToRunAction() && init() && 
isBackwardsCompatible() && validateInputs()
+                                && acquireLock()
                                 && canDoAction()
                                 && internalValidateAndSetQuota();
                 if (!returnValue && 
getReturnValue().getCanDoActionMessages().size() > 0) {
@@ -1050,6 +1051,24 @@
         return checkPermissions(permSubjects);
     }
 
+    private boolean init() {
+        if (initImpl() == false) {
+            log.error("An error has occurred during command initialization");
+            addCanDoActionMessage(VdcBllMessages.FAILED_TO_INITIALIZE);
+            return false;
+        }
+        return true;
+    }
+
+    /**
+     * This method should be inherited by subclasses that would like to 
perform initialization after permission check
+     * 
+     * @return
+     */
+    protected boolean initImpl() {
+        return true;
+    }
+
     protected boolean checkPermissions(final List<PermissionSubject> 
permSubjects) {
         for (PermissionSubject permSubject : permSubjects) {
             if (!checkSinglePermission(permSubject, 
getReturnValue().getCanDoActionMessages())) {
diff --git 
a/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/errors/ErrorType.java
 
b/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/errors/ErrorType.java
index 8333efa..c8fb981 100644
--- 
a/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/errors/ErrorType.java
+++ 
b/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/errors/ErrorType.java
@@ -49,4 +49,8 @@
     DATA_CORRUPTION,
 
     ATTESTATION_SERVER_ERROR,
+    /**
+     * Error in initialization of command
+     */
+    INITIALIZATION_ERROR,
 }
diff --git 
a/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/errors/VdcBllMessages.java
 
b/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/errors/VdcBllMessages.java
index c748e41..abc5524 100644
--- 
a/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/errors/VdcBllMessages.java
+++ 
b/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/errors/VdcBllMessages.java
@@ -477,6 +477,7 @@
     ACTION_TYPE_FAILED_VM_FROM_POOL_CANNOT_BE_STATELESS(ErrorType.CONFLICT),
     DIRECTORY_COMPUTER_WITH_THE_SAME_NAME_ALREADY_EXITS(ErrorType.CONFLICT),
     USER_NOT_AUTHORIZED_TO_PERFORM_ACTION(ErrorType.NO_PERMISSION),
+    FAILED_TO_INITIALIZE(ErrorType.INITIALIZATION_ERROR),
     ERROR_CANNOT_REMOVE_LAST_SUPER_USER_ROLE(ErrorType.CONFLICT),
     ERROR_CANNOT_REMOVE_ROLE_ATTACHED_TO_PERMISSION(ErrorType.CONFLICT),
     ERROR_CANNOT_REMOVE_ROLE_INVALID_ROLE_ID(ErrorType.BAD_PARAMETERS),
diff --git 
a/backend/manager/modules/dal/src/main/resources/bundles/AppErrors.properties 
b/backend/manager/modules/dal/src/main/resources/bundles/AppErrors.properties
index 5e9cddf..aa7749a 100644
--- 
a/backend/manager/modules/dal/src/main/resources/bundles/AppErrors.properties
+++ 
b/backend/manager/modules/dal/src/main/resources/bundles/AppErrors.properties
@@ -415,6 +415,7 @@
 USER_CANNOT_ATTACH_TO_VM_ALREADY_ATTACHED=User is already attached to VM
 USER_CANNOT_ATTACH_TO_VM_NOT_ATTACHED=The user is not attached to this VM.
 USER_FAILED_TO_AUTHENTICATE=Login failed. Please verify your login information 
or contact the system administrator.
+INITIALIZATION_ERROR=Request failed during initialization phase at engine.
 USER_FAILED_TO_AUTHENTICATE_TIMED_OUT=Login failed. A timeout has occurred to 
one or more of the servers that participate in the login process.
 USER_FAILED_TO_AUTHENTICATE_SERVER_IS_NOT_AVAILABLE=Login failed. One or more 
servers that are needed for completion of the login process is not available.
 USER_FAILED_TO_AUTHENTICATE_KERBEROS_ERROR=Login failed. Client not found in 
kerberos database. Please verify your login information or contact the system 
administrator.
diff --git 
a/backend/manager/modules/restapi/jaxrs/src/main/java/org/ovirt/engine/api/restapi/util/ErrorMessageHelper.java
 
b/backend/manager/modules/restapi/jaxrs/src/main/java/org/ovirt/engine/api/restapi/util/ErrorMessageHelper.java
index 448df1e..a6246df 100644
--- 
a/backend/manager/modules/restapi/jaxrs/src/main/java/org/ovirt/engine/api/restapi/util/ErrorMessageHelper.java
+++ 
b/backend/manager/modules/restapi/jaxrs/src/main/java/org/ovirt/engine/api/restapi/util/ErrorMessageHelper.java
@@ -72,6 +72,8 @@
             return Status.BAD_REQUEST;
         case INCOMPATIBLE_VERSION:
             return Status.BAD_REQUEST;
+        case INITIALIZATION_ERROR:
+            return Status.BAD_REQUEST;
         case ATTESTATION_SERVER_ERROR:
             return Status.BAD_REQUEST;
         default:
diff --git 
a/frontend/webadmin/modules/frontend/src/main/java/org/ovirt/engine/ui/frontend/AppErrors.java
 
b/frontend/webadmin/modules/frontend/src/main/java/org/ovirt/engine/ui/frontend/AppErrors.java
index 01a49e9..897ad3b 100644
--- 
a/frontend/webadmin/modules/frontend/src/main/java/org/ovirt/engine/ui/frontend/AppErrors.java
+++ 
b/frontend/webadmin/modules/frontend/src/main/java/org/ovirt/engine/ui/frontend/AppErrors.java
@@ -1180,6 +1180,9 @@
     @DefaultStringValue("Login failed. Please verify your login information or 
contact the system administrator.")
     String USER_FAILED_TO_AUTHENTICATE();
 
+    @DefaultStringValue("Request failed during initialization phase at 
engine.")
+    String INITIALIZATION_ERROR();
+
     @DefaultStringValue("Login failed. One or more servers that are needed for 
completion of the login process is not available.")
     String USER_FAILED_TO_AUTHENTICATE_SERVER_IS_NOT_AVAILABLE();
 
diff --git 
a/frontend/webadmin/modules/userportal-gwtp/src/main/resources/org/ovirt/engine/ui/frontend/AppErrors.properties
 
b/frontend/webadmin/modules/userportal-gwtp/src/main/resources/org/ovirt/engine/ui/frontend/AppErrors.properties
index 03e3fe9..c3f235f 100644
--- 
a/frontend/webadmin/modules/userportal-gwtp/src/main/resources/org/ovirt/engine/ui/frontend/AppErrors.properties
+++ 
b/frontend/webadmin/modules/userportal-gwtp/src/main/resources/org/ovirt/engine/ui/frontend/AppErrors.properties
@@ -378,6 +378,7 @@
 USER_CANNOT_ATTACH_TO_VM_ALREADY_ATTACHED=User is already attached to VM
 USER_CANNOT_ATTACH_TO_VM_NOT_ATTACHED=The user is not attached to this VM.
 USER_FAILED_TO_AUTHENTICATE=Login failed. Please verify your login information 
or contact the system administrator.
+INITIALIZATION_ERROR=Request failed during initialization phase at engine.
 USER_FAILED_TO_AUTHENTICATE_TIMED_OUT=Login failed. A timeout has occurred to 
one or more of the servers that participate in the login process.
 USER_FAILED_TO_AUTHENTICATE_SERVER_IS_NOT_AVAILABLE=Login failed. One or more 
servers that are needed for completion of the login process is not available.
 USER_FAILED_TO_AUTHENTICATE_KERBEROS_ERROR=Login failed. Client not found in 
kerberos database. Please verify your login information or contact the system 
administrator.
diff --git 
a/frontend/webadmin/modules/webadmin/src/main/resources/org/ovirt/engine/ui/frontend/AppErrors.properties
 
b/frontend/webadmin/modules/webadmin/src/main/resources/org/ovirt/engine/ui/frontend/AppErrors.properties
index 5eb6b4c..c5a971e 100644
--- 
a/frontend/webadmin/modules/webadmin/src/main/resources/org/ovirt/engine/ui/frontend/AppErrors.properties
+++ 
b/frontend/webadmin/modules/webadmin/src/main/resources/org/ovirt/engine/ui/frontend/AppErrors.properties
@@ -417,6 +417,7 @@
 USER_CANNOT_ATTACH_TO_VM_ALREADY_ATTACHED=User is already attached to VM
 USER_CANNOT_ATTACH_TO_VM_NOT_ATTACHED=The user is not attached to this VM.
 USER_FAILED_TO_AUTHENTICATE=Login failed. Please verify your login information 
or contact the system administrator.
+INITIALIZATION_ERROR=Request failed during initialization phase at engine.
 USER_FAILED_TO_AUTHENTICATE_TIMED_OUT=Login failed. A timeout has occurred to 
one or more of the servers that participate in the login process.
 USER_FAILED_TO_AUTHENTICATE_SERVER_IS_NOT_AVAILABLE=Login failed. One or more 
servers that are needed for completion of the login process is not available.
 USER_FAILED_TO_AUTHENTICATE_KERBEROS_ERROR=Login failed. Client not found in 
kerberos database. Please verify your login information or contact the system 
administrator.


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

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

Reply via email to