Juan Hernandez has uploaded a new change for review.

Change subject: core: Move getFQN to SetVmTicketCommand
......................................................................

core: Move getFQN to SetVmTicketCommand

The method VdcUser.getFQN() is only used in the SetVmTicketCommand. This
patch moves the method to SetVmTicketCommand to simplify the VdcUser
class.

Change-Id: If4a3a45136db9c42ab347f9722326f597afd26fd
Signed-off-by: Juan Hernandez <[email protected]>
---
M 
backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/SetVmTicketCommand.java
M 
backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/users/VdcUser.java
2 files changed, 11 insertions(+), 16 deletions(-)


  git pull ssh://gerrit.ovirt.org:29418/ovirt-engine refs/changes/23/17223/1

diff --git 
a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/SetVmTicketCommand.java
 
b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/SetVmTicketCommand.java
index def8c88..ce0903c 100644
--- 
a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/SetVmTicketCommand.java
+++ 
b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/SetVmTicketCommand.java
@@ -56,6 +56,16 @@
         return permissions;
     }
 
+    private String getConsoleUserName(VdcUser user) {
+        String domain = user.getDomainControler();
+        String name = user.getUserName();
+        if (StringUtils.isEmpty(name) || name.contains("@") || 
StringUtils.isEmpty(domain)) {
+            return name;
+        } else {
+            return name + "@" + domain;
+        }
+    }
+
     /**
      * Checks if the user needs additional permissions in order to connect
      * to the console.
@@ -121,7 +131,7 @@
         final VM vm = getVm();
         final VdcUser user = getCurrentUser();
         vm.setConsoleUserId(user.getUserId());
-        vm.setConsoleCurrentUserName(user.getFQN());
+        vm.setConsoleCurrentUserName(getConsoleUserName(user));
 
         // If the virtual machine has the allow reconnect flag or the user
         // needed additional permissions to connect to the console then we just
diff --git 
a/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/users/VdcUser.java
 
b/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/users/VdcUser.java
index 31f3282..d36a542d 100644
--- 
a/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/users/VdcUser.java
+++ 
b/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/users/VdcUser.java
@@ -105,19 +105,4 @@
     public void setAdmin(boolean isAdmin) {
         this.mIsAdmin = isAdmin;
     }
-
-    /**
-     * return the FQDN of a user in a form of user@domain. if the domain is 
empty then only return the username
-     */
-    public String getFQN() {
-        String domain = getDomainControler();
-        String username = getUserName();
-
-        // empty username or a user with empty domain will be returned as is
-        if ( (username == null || username.length() == 0) || 
username.contains("@") || (domain == null || domain.length() == 0)) {
-            return username;
-        } else {
-            return username + "@" + domain;
-        }
-    }
 }


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

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

Reply via email to