From f55e83f607273b7264dbc3f4c134d63866ba7bf8 Mon Sep 17 00:00:00 2001 From: nit Date: Thu, 21 Apr 2011 13:36:59 +0530 Subject: [PATCH] List Iso/Templates - Cleaning the code for access rights using the centralized acl layer --- .../cloud/server/ManagementServerImpl.java | 36 +++---------------- 1 file changed, 4 insertions(+), 32 deletions(-) diff --git a/server/src/com/cloud/server/ManagementServerImpl.java b/server/src/com/cloud/server/ManagementServerImpl.java index afc1562f5cb..c2dfdd6bd80 100755 --- a/server/src/com/cloud/server/ManagementServerImpl.java +++ b/server/src/com/cloud/server/ManagementServerImpl.java @@ -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(); }