List Iso/Templates - Cleaning the code for access rights using the centralized acl layer

This commit is contained in:
nit 2011-04-21 13:36:59 +05:30
parent ea14ff5f6c
commit f55e83f607
1 changed files with 4 additions and 32 deletions

View File

@ -1628,22 +1628,8 @@ public class ManagementServerImpl implements ManagementServer {
Account account = UserContext.current().getCaller();
Long domainId = cmd.getDomainId();
String accountName = cmd.getAccountName();
if ((account == null) || (account.getType() == Account.ACCOUNT_TYPE_ADMIN)) {
// validate domainId before proceeding
if ((domainId != null) && (accountName != null)) {
if ((account != null) && !_domainDao.isChildDomain(account.getDomainId(), domainId)) {
throw new InvalidParameterValueException("Invalid domain id (" + domainId + ") given, unable to list events.");
}
Account userAccount = _accountDao.findActiveAccount(accountName, domainId);
if (userAccount != null) {
accountId = userAccount.getId();
} else {
throw new InvalidParameterValueException("Failed to list ISOs. Unable to find account " + accountName + " in domain " + domainId);
}
} else if (account != null) {
accountId = account.getId();
}
if (accountName != null && domainId != null) {
accountId = _accountMgr.finalizeOwner(account, accountName, domainId).getAccountId();
} else {
accountId = account.getId();
}
@ -1664,22 +1650,8 @@ public class ManagementServerImpl implements ManagementServer {
Account account = UserContext.current().getCaller();
Long domainId = cmd.getDomainId();
String accountName = cmd.getAccountName();
if ((account == null) || (account.getType() == Account.ACCOUNT_TYPE_ADMIN)) {
// validate domainId before proceeding
if ((domainId != null) && (accountName != null)) {
if ((account != null) && !_domainDao.isChildDomain(account.getDomainId(), domainId)) {
throw new InvalidParameterValueException("Invalid domain id (" + domainId + ") given, unable to list events.");
}
Account userAccount = _accountDao.findActiveAccount(accountName, domainId);
if (userAccount != null) {
accountId = userAccount.getId();
} else {
throw new InvalidParameterValueException("Failed to list ISOs. Unable to find account " + accountName + " in domain " + domainId);
}
} else if (account != null) {
accountId = account.getId();
}
if (accountName != null && domainId != null) {
accountId = _accountMgr.finalizeOwner(account, accountName, domainId).getAccountId();
} else {
accountId = account.getId();
}