From a9591cecd6530be51515124472fec2e0ed24b8db Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jacobo=20Aragunde=20P=C3=A9rez?= Date: Thu, 8 Nov 2012 17:25:55 +0100 Subject: [PATCH] Bug #1556: Use an enum to express the value of UserAuthenticationType field. Using an enum instead of a simple String will make easier for us to change the value of this field. FEA: ItEr77S04BugFixing --- .../web/users/UserCRUDController.java | 22 ++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-) diff --git a/libreplan-webapp/src/main/java/org/libreplan/web/users/UserCRUDController.java b/libreplan-webapp/src/main/java/org/libreplan/web/users/UserCRUDController.java index 54195e70e..57fd415b3 100644 --- a/libreplan-webapp/src/main/java/org/libreplan/web/users/UserCRUDController.java +++ b/libreplan-webapp/src/main/java/org/libreplan/web/users/UserCRUDController.java @@ -447,12 +447,28 @@ public class UserCRUDController extends BaseCRUDController implements return isLdapUser() || isUserDefaultAdmin(); } - public String getAuthenticationType() { + public enum UserAuthenticationType { + + EMPTY(""), DATABASE(_("Database")), LDAP(_("LDAP")); + + private String name; + + private UserAuthenticationType(String name) { + this.name = name; + } + + public String toString() { + return name; + } + } + + public UserAuthenticationType getAuthenticationType() { User user = getUser(); if (user != null) { - return _(user.getUserType()); + return user.isLibrePlanUser() ? UserAuthenticationType.DATABASE + : UserAuthenticationType.LDAP; } - return ""; + return UserAuthenticationType.EMPTY; } }