Skip to content

Commit dfecc1f

Browse files
committed
Changed account state to be in lower case.
1 parent 0a3895a commit dfecc1f

8 files changed

Lines changed: 27 additions & 27 deletions

File tree

‎api/src/com/cloud/api/BaseCmd.java‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -176,7 +176,7 @@ protected Account getValidOwner(String accountName, Long domainId) {
176176
if (owner == null) {
177177
throw new InvalidParameterValueException("Invalid value for owner specified: " + accountName);
178178
}
179-
if (owner.getState() == Account.State.Disabled || owner.getState() == Account.State.Locked) {
179+
if (owner.getState() == Account.State.disabled || owner.getState() == Account.State.locked) {
180180
throw new PermissionDeniedException("Account disabled.");
181181
}
182182
return owner;

‎api/src/com/cloud/user/Account.java‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,9 +31,9 @@ public enum Type {
3131
}
3232

3333
public enum State {
34-
Disabled,
35-
Enabled,
36-
Locked
34+
disabled,
35+
enabled,
36+
locked
3737
}
3838

3939
public static final short ACCOUNT_TYPE_NORMAL = 0;

‎server/src/com/cloud/acl/DomainChecker.java‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ protected DomainChecker() {
4949

5050
@Override
5151
public boolean checkAccess(Account account, Domain domain) throws PermissionDeniedException {
52-
if (account.getState() != Account.State.Enabled) {
52+
if (account.getState() != Account.State.enabled) {
5353
throw new PermissionDeniedException(account + " is disabled.");
5454
}
5555

‎server/src/com/cloud/api/ApiServer.java‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -598,7 +598,7 @@ public boolean verifyRequest(Map<String, Object[]> requestParameters, Long userI
598598
user = userAcctPair.first();
599599
Account account = userAcctPair.second();
600600

601-
if (user.getState() != Account.State.Enabled || !account.getState().equals(Account.State.Enabled)) {
601+
if (user.getState() != Account.State.enabled || !account.getState().equals(Account.State.enabled)) {
602602
s_logger.info("disabled or locked user accessing the api, userid = " + user.getId() + "; name = " + user.getUsername() + "; state: " + user.getState() + "; accountState: " + account.getState());
603603
return false;
604604
}
@@ -729,7 +729,7 @@ public boolean verifyUser(Long userId) {
729729
account = _ms.findAccountById(user.getAccountId());
730730
}
731731

732-
if ((user == null) || (user.getRemoved() != null) || !user.getState().equals(Account.State.Enabled) || (account == null) || !account.getState().equals(Account.State.Enabled)) {
732+
if ((user == null) || (user.getRemoved() != null) || !user.getState().equals(Account.State.enabled) || (account == null) || !account.getState().equals(Account.State.enabled)) {
733733
s_logger.warn("Deleted/Disabled/Locked user with id=" + userId + " attempting to access public API");
734734
return false;
735735
}

‎server/src/com/cloud/async/executor/DisableUserExecutor.java‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@ private boolean needToDisableAccount(UserVO user) {
130130

131131
List<UserVO> allUsersByAccount = asyncMgr.getExecutorContext().getUserDao().listByAccount(user.getAccountId());
132132
for (UserVO oneUser : allUsersByAccount) {
133-
if (oneUser.getState().equals(Account.State.Enabled)) {
133+
if (oneUser.getState().equals(Account.State.enabled)) {
134134
return false;
135135
}
136136
}

‎server/src/com/cloud/server/ManagementServerImpl.java‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -596,7 +596,7 @@ private UserAccount getUserAccount(String username, String password, Long domain
596596
domainName = domain.getName();
597597
}
598598

599-
if (!userAccount.getState().equalsIgnoreCase(Account.State.Enabled.toString()) || !userAccount.getAccountState().equalsIgnoreCase(Account.State.Enabled.toString())) {
599+
if (!userAccount.getState().equalsIgnoreCase(Account.State.enabled.toString()) || !userAccount.getAccountState().equalsIgnoreCase(Account.State.enabled.toString())) {
600600
if (s_logger.isInfoEnabled()) {
601601
s_logger.info("User " + username + " in domain " + domainName + " is disabled/locked (or account is disabled/locked)");
602602
}

‎server/src/com/cloud/servlet/ConsoleProxyServlet.java‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -406,8 +406,8 @@ public boolean verifyUser(Long userId) {
406406
account = _ms.findAccountById(user.getAccountId());
407407
}
408408

409-
if ((user == null) || (user.getRemoved() != null) || !user.getState().equals(Account.State.Enabled)
410-
|| (account == null) || !account.getState().equals(Account.State.Enabled)) {
409+
if ((user == null) || (user.getRemoved() != null) || !user.getState().equals(Account.State.enabled)
410+
|| (account == null) || !account.getState().equals(Account.State.enabled)) {
411411
s_logger.warn("Deleted/Disabled/Locked user with id=" + userId + " attempting to access public API");
412412
return false;
413413
}
@@ -474,7 +474,7 @@ private boolean verifyRequest(Map<String, Object[]> requestParameters) {
474474
user = userAcctPair.first();
475475
Account account = userAcctPair.second();
476476

477-
if (!user.getState().equals(Account.State.Enabled) || !account.getState().equals(Account.State.Enabled)) {
477+
if (!user.getState().equals(Account.State.enabled) || !account.getState().equals(Account.State.enabled)) {
478478
s_logger.info("disabled or locked user accessing the api, userid = " + user.getId() + "; name = " + user.getUsername() + "; state: " + user.getState() + "; accountState: " + account.getState());
479479
return false;
480480
}

‎server/src/com/cloud/user/AccountManagerImpl.java‎

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -747,7 +747,7 @@ private boolean doSetUserStatus(long userId, State state) {
747747
public boolean enableAccount(long accountId) {
748748
boolean success = false;
749749
AccountVO acctForUpdate = _accountDao.createForUpdate();
750-
acctForUpdate.setState(State.Enabled);
750+
acctForUpdate.setState(State.enabled);
751751
success = _accountDao.update(Long.valueOf(accountId), acctForUpdate);
752752
return success;
753753
}
@@ -756,11 +756,11 @@ private boolean lockAccountInternal(long accountId) {
756756
boolean success = false;
757757
Account account = _accountDao.findById(accountId);
758758
if (account != null) {
759-
if (account.getState().equals(State.Locked)) {
759+
if (account.getState().equals(State.locked)) {
760760
return true; // already locked, no-op
761-
} else if (account.getState().equals(State.Enabled)) {
761+
} else if (account.getState().equals(State.enabled)) {
762762
AccountVO acctForUpdate = _accountDao.createForUpdate();
763-
acctForUpdate.setState(State.Locked);
763+
acctForUpdate.setState(State.locked);
764764
success = _accountDao.update(Long.valueOf(accountId), acctForUpdate);
765765
} else {
766766
if (s_logger.isInfoEnabled()) {
@@ -956,11 +956,11 @@ public boolean disableAccount(long accountId) {
956956
}
957957

958958
AccountVO account = _accountDao.findById(accountId);
959-
if ((account == null) || account.getState().equals(State.Disabled)) {
959+
if ((account == null) || account.getState().equals(State.disabled)) {
960960
success = true;
961961
} else {
962962
AccountVO acctForUpdate = _accountDao.createForUpdate();
963-
acctForUpdate.setState(State.Disabled);
963+
acctForUpdate.setState(State.disabled);
964964
success = _accountDao.update(Long.valueOf(accountId), acctForUpdate);
965965

966966
success = (success && doDisableAccount(accountId));
@@ -1044,7 +1044,7 @@ public UserAccount createAccount(CreateAccountCmd cmd) {
10441044
newAccount.setAccountName(accountName);
10451045
newAccount.setDomainId(domainId);
10461046
newAccount.setType(userType);
1047-
newAccount.setState(State.Enabled);
1047+
newAccount.setState(State.enabled);
10481048
newAccount.setNetworkDomain(networkDomain);
10491049
newAccount = _accountDao.persist(newAccount);
10501050
accountId = newAccount.getId();
@@ -1057,7 +1057,7 @@ public UserAccount createAccount(CreateAccountCmd cmd) {
10571057
UserVO user = new UserVO();
10581058
user.setUsername(username);
10591059
user.setPassword(password);
1060-
user.setState(State.Enabled);
1060+
user.setState(State.enabled);
10611061
user.setFirstname(firstName);
10621062
user.setLastname(lastName);
10631063
user.setAccountId(accountId.longValue());
@@ -1118,7 +1118,7 @@ public UserVO createUser(CreateUserCmd cmd){
11181118
UserVO user = new UserVO();
11191119
user.setUsername(userName);
11201120
user.setPassword(password);
1121-
user.setState(State.Enabled);
1121+
user.setState(State.enabled);
11221122
user.setFirstname(firstName);
11231123
user.setLastname(lastName);
11241124
user.setAccountId(accountId.longValue());
@@ -1249,7 +1249,7 @@ public UserAccount disableUser(DisableUserCmd cmd) throws InvalidParameterValueE
12491249
throw new PermissionDeniedException("Failed to disable user " + userId + ", permission denied.");
12501250
}
12511251

1252-
boolean success = doSetUserStatus(userId, State.Disabled);
1252+
boolean success = doSetUserStatus(userId, State.disabled);
12531253
if (success) {
12541254
//user successfully disabled
12551255
return _userAccountDao.findById(userId);
@@ -1280,7 +1280,7 @@ public UserAccount enableUser(EnableUserCmd cmd) throws InvalidParameterValueExc
12801280
throw new PermissionDeniedException("Failed to enable user " + userId + ", permission denied.");
12811281
}
12821282

1283-
success = doSetUserStatus(userId, State.Enabled);
1283+
success = doSetUserStatus(userId, State.enabled);
12841284

12851285
// make sure the account is enabled too
12861286
success = (success && enableAccount(user.getAccountId()));
@@ -1319,16 +1319,16 @@ public UserAccount lockUser(LockUserCmd cmd) {
13191319

13201320
// make sure the account is enabled too
13211321
// if the user is either locked already or disabled already, don't change state...only lock currently enabled users
1322-
if (user.getState().equals(State.Locked)) {
1322+
if (user.getState().equals(State.locked)) {
13231323
// already locked...no-op
13241324
return _userAccountDao.findById(id);
1325-
} else if (user.getState().equals(State.Enabled)) {
1326-
success = doSetUserStatus(user.getId(), State.Locked);
1325+
} else if (user.getState().equals(State.enabled)) {
1326+
success = doSetUserStatus(user.getId(), State.locked);
13271327

13281328
boolean lockAccount = true;
13291329
List<UserVO> allUsersByAccount = _userDao.listByAccount(user.getAccountId());
13301330
for (UserVO oneUser : allUsersByAccount) {
1331-
if (oneUser.getState().equals(State.Enabled)) {
1331+
if (oneUser.getState().equals(State.enabled)) {
13321332
lockAccount = false;
13331333
break;
13341334
}

0 commit comments

Comments
 (0)