From dfecc1f448405424b7670e63acfa35d93ece010b Mon Sep 17 00:00:00 2001 From: alena Date: Thu, 30 Dec 2010 09:56:43 -0800 Subject: [PATCH] Changed account state to be in lower case. --- api/src/com/cloud/api/BaseCmd.java | 2 +- api/src/com/cloud/user/Account.java | 6 ++-- server/src/com/cloud/acl/DomainChecker.java | 2 +- server/src/com/cloud/api/ApiServer.java | 4 +-- .../async/executor/DisableUserExecutor.java | 2 +- .../cloud/server/ManagementServerImpl.java | 2 +- .../cloud/servlet/ConsoleProxyServlet.java | 6 ++-- .../com/cloud/user/AccountManagerImpl.java | 30 +++++++++---------- 8 files changed, 27 insertions(+), 27 deletions(-) diff --git a/api/src/com/cloud/api/BaseCmd.java b/api/src/com/cloud/api/BaseCmd.java index 3265fa5a8aa..26fc9adb01c 100755 --- a/api/src/com/cloud/api/BaseCmd.java +++ b/api/src/com/cloud/api/BaseCmd.java @@ -176,7 +176,7 @@ public abstract class BaseCmd { if (owner == null) { throw new InvalidParameterValueException("Invalid value for owner specified: " + accountName); } - if (owner.getState() == Account.State.Disabled || owner.getState() == Account.State.Locked) { + if (owner.getState() == Account.State.disabled || owner.getState() == Account.State.locked) { throw new PermissionDeniedException("Account disabled."); } return owner; diff --git a/api/src/com/cloud/user/Account.java b/api/src/com/cloud/user/Account.java index f506a511871..aed18150e2c 100644 --- a/api/src/com/cloud/user/Account.java +++ b/api/src/com/cloud/user/Account.java @@ -31,9 +31,9 @@ public interface Account extends ControlledEntity { } public enum State { - Disabled, - Enabled, - Locked + disabled, + enabled, + locked } public static final short ACCOUNT_TYPE_NORMAL = 0; diff --git a/server/src/com/cloud/acl/DomainChecker.java b/server/src/com/cloud/acl/DomainChecker.java index 9fa96b4216a..7742afb02af 100644 --- a/server/src/com/cloud/acl/DomainChecker.java +++ b/server/src/com/cloud/acl/DomainChecker.java @@ -49,7 +49,7 @@ public class DomainChecker extends AdapterBase implements SecurityChecker { @Override public boolean checkAccess(Account account, Domain domain) throws PermissionDeniedException { - if (account.getState() != Account.State.Enabled) { + if (account.getState() != Account.State.enabled) { throw new PermissionDeniedException(account + " is disabled."); } diff --git a/server/src/com/cloud/api/ApiServer.java b/server/src/com/cloud/api/ApiServer.java index 793901de0c8..41c3c5674c3 100755 --- a/server/src/com/cloud/api/ApiServer.java +++ b/server/src/com/cloud/api/ApiServer.java @@ -598,7 +598,7 @@ public class ApiServer implements HttpRequestHandler { user = userAcctPair.first(); Account account = userAcctPair.second(); - if (user.getState() != Account.State.Enabled || !account.getState().equals(Account.State.Enabled)) { + if (user.getState() != Account.State.enabled || !account.getState().equals(Account.State.enabled)) { s_logger.info("disabled or locked user accessing the api, userid = " + user.getId() + "; name = " + user.getUsername() + "; state: " + user.getState() + "; accountState: " + account.getState()); return false; } @@ -729,7 +729,7 @@ public class ApiServer implements HttpRequestHandler { account = _ms.findAccountById(user.getAccountId()); } - if ((user == null) || (user.getRemoved() != null) || !user.getState().equals(Account.State.Enabled) || (account == null) || !account.getState().equals(Account.State.Enabled)) { + if ((user == null) || (user.getRemoved() != null) || !user.getState().equals(Account.State.enabled) || (account == null) || !account.getState().equals(Account.State.enabled)) { s_logger.warn("Deleted/Disabled/Locked user with id=" + userId + " attempting to access public API"); return false; } diff --git a/server/src/com/cloud/async/executor/DisableUserExecutor.java b/server/src/com/cloud/async/executor/DisableUserExecutor.java index e7bc9bca5f7..7d7a7b7ba7e 100644 --- a/server/src/com/cloud/async/executor/DisableUserExecutor.java +++ b/server/src/com/cloud/async/executor/DisableUserExecutor.java @@ -130,7 +130,7 @@ public class DisableUserExecutor extends BaseAsyncJobExecutor { List allUsersByAccount = asyncMgr.getExecutorContext().getUserDao().listByAccount(user.getAccountId()); for (UserVO oneUser : allUsersByAccount) { - if (oneUser.getState().equals(Account.State.Enabled)) { + if (oneUser.getState().equals(Account.State.enabled)) { return false; } } diff --git a/server/src/com/cloud/server/ManagementServerImpl.java b/server/src/com/cloud/server/ManagementServerImpl.java index cc9772d2f3d..80316a98777 100755 --- a/server/src/com/cloud/server/ManagementServerImpl.java +++ b/server/src/com/cloud/server/ManagementServerImpl.java @@ -596,7 +596,7 @@ public class ManagementServerImpl implements ManagementServer { domainName = domain.getName(); } - if (!userAccount.getState().equalsIgnoreCase(Account.State.Enabled.toString()) || !userAccount.getAccountState().equalsIgnoreCase(Account.State.Enabled.toString())) { + if (!userAccount.getState().equalsIgnoreCase(Account.State.enabled.toString()) || !userAccount.getAccountState().equalsIgnoreCase(Account.State.enabled.toString())) { if (s_logger.isInfoEnabled()) { s_logger.info("User " + username + " in domain " + domainName + " is disabled/locked (or account is disabled/locked)"); } diff --git a/server/src/com/cloud/servlet/ConsoleProxyServlet.java b/server/src/com/cloud/servlet/ConsoleProxyServlet.java index cd59f213091..1936173b106 100644 --- a/server/src/com/cloud/servlet/ConsoleProxyServlet.java +++ b/server/src/com/cloud/servlet/ConsoleProxyServlet.java @@ -406,8 +406,8 @@ public class ConsoleProxyServlet extends HttpServlet { account = _ms.findAccountById(user.getAccountId()); } - if ((user == null) || (user.getRemoved() != null) || !user.getState().equals(Account.State.Enabled) - || (account == null) || !account.getState().equals(Account.State.Enabled)) { + if ((user == null) || (user.getRemoved() != null) || !user.getState().equals(Account.State.enabled) + || (account == null) || !account.getState().equals(Account.State.enabled)) { s_logger.warn("Deleted/Disabled/Locked user with id=" + userId + " attempting to access public API"); return false; } @@ -474,7 +474,7 @@ public class ConsoleProxyServlet extends HttpServlet { user = userAcctPair.first(); Account account = userAcctPair.second(); - if (!user.getState().equals(Account.State.Enabled) || !account.getState().equals(Account.State.Enabled)) { + if (!user.getState().equals(Account.State.enabled) || !account.getState().equals(Account.State.enabled)) { s_logger.info("disabled or locked user accessing the api, userid = " + user.getId() + "; name = " + user.getUsername() + "; state: " + user.getState() + "; accountState: " + account.getState()); return false; } diff --git a/server/src/com/cloud/user/AccountManagerImpl.java b/server/src/com/cloud/user/AccountManagerImpl.java index 918a72d6be2..e5e2c87b53e 100755 --- a/server/src/com/cloud/user/AccountManagerImpl.java +++ b/server/src/com/cloud/user/AccountManagerImpl.java @@ -747,7 +747,7 @@ public class AccountManagerImpl implements AccountManager, AccountService, Manag public boolean enableAccount(long accountId) { boolean success = false; AccountVO acctForUpdate = _accountDao.createForUpdate(); - acctForUpdate.setState(State.Enabled); + acctForUpdate.setState(State.enabled); success = _accountDao.update(Long.valueOf(accountId), acctForUpdate); return success; } @@ -756,11 +756,11 @@ public class AccountManagerImpl implements AccountManager, AccountService, Manag boolean success = false; Account account = _accountDao.findById(accountId); if (account != null) { - if (account.getState().equals(State.Locked)) { + if (account.getState().equals(State.locked)) { return true; // already locked, no-op - } else if (account.getState().equals(State.Enabled)) { + } else if (account.getState().equals(State.enabled)) { AccountVO acctForUpdate = _accountDao.createForUpdate(); - acctForUpdate.setState(State.Locked); + acctForUpdate.setState(State.locked); success = _accountDao.update(Long.valueOf(accountId), acctForUpdate); } else { if (s_logger.isInfoEnabled()) { @@ -956,11 +956,11 @@ public class AccountManagerImpl implements AccountManager, AccountService, Manag } AccountVO account = _accountDao.findById(accountId); - if ((account == null) || account.getState().equals(State.Disabled)) { + if ((account == null) || account.getState().equals(State.disabled)) { success = true; } else { AccountVO acctForUpdate = _accountDao.createForUpdate(); - acctForUpdate.setState(State.Disabled); + acctForUpdate.setState(State.disabled); success = _accountDao.update(Long.valueOf(accountId), acctForUpdate); success = (success && doDisableAccount(accountId)); @@ -1044,7 +1044,7 @@ public class AccountManagerImpl implements AccountManager, AccountService, Manag newAccount.setAccountName(accountName); newAccount.setDomainId(domainId); newAccount.setType(userType); - newAccount.setState(State.Enabled); + newAccount.setState(State.enabled); newAccount.setNetworkDomain(networkDomain); newAccount = _accountDao.persist(newAccount); accountId = newAccount.getId(); @@ -1057,7 +1057,7 @@ public class AccountManagerImpl implements AccountManager, AccountService, Manag UserVO user = new UserVO(); user.setUsername(username); user.setPassword(password); - user.setState(State.Enabled); + user.setState(State.enabled); user.setFirstname(firstName); user.setLastname(lastName); user.setAccountId(accountId.longValue()); @@ -1118,7 +1118,7 @@ public class AccountManagerImpl implements AccountManager, AccountService, Manag UserVO user = new UserVO(); user.setUsername(userName); user.setPassword(password); - user.setState(State.Enabled); + user.setState(State.enabled); user.setFirstname(firstName); user.setLastname(lastName); user.setAccountId(accountId.longValue()); @@ -1249,7 +1249,7 @@ public class AccountManagerImpl implements AccountManager, AccountService, Manag throw new PermissionDeniedException("Failed to disable user " + userId + ", permission denied."); } - boolean success = doSetUserStatus(userId, State.Disabled); + boolean success = doSetUserStatus(userId, State.disabled); if (success) { //user successfully disabled return _userAccountDao.findById(userId); @@ -1280,7 +1280,7 @@ public class AccountManagerImpl implements AccountManager, AccountService, Manag throw new PermissionDeniedException("Failed to enable user " + userId + ", permission denied."); } - success = doSetUserStatus(userId, State.Enabled); + success = doSetUserStatus(userId, State.enabled); // make sure the account is enabled too success = (success && enableAccount(user.getAccountId())); @@ -1319,16 +1319,16 @@ public class AccountManagerImpl implements AccountManager, AccountService, Manag // make sure the account is enabled too // if the user is either locked already or disabled already, don't change state...only lock currently enabled users - if (user.getState().equals(State.Locked)) { + if (user.getState().equals(State.locked)) { // already locked...no-op return _userAccountDao.findById(id); - } else if (user.getState().equals(State.Enabled)) { - success = doSetUserStatus(user.getId(), State.Locked); + } else if (user.getState().equals(State.enabled)) { + success = doSetUserStatus(user.getId(), State.locked); boolean lockAccount = true; List allUsersByAccount = _userDao.listByAccount(user.getAccountId()); for (UserVO oneUser : allUsersByAccount) { - if (oneUser.getState().equals(State.Enabled)) { + if (oneUser.getState().equals(State.enabled)) { lockAccount = false; break; }