CS-15300: Domain Admin accounts now respect the limits imposed on the domain just as a regular account.

Signed-off-by: Nitin Mehta<nitin.mehta@citrix.com>
This commit is contained in:
Deepti Dohare 2012-07-03 04:33:02 +05:30 committed by U-nitin-PC\nitin
parent 0449ae37f1
commit c8bbf04c81

View File

@ -210,12 +210,12 @@ public class ResourceLimitManagerImpl implements ResourceLimitService, Manager {
public long findCorrectResourceLimitForAccount(Account account, ResourceType type) { public long findCorrectResourceLimitForAccount(Account account, ResourceType type) {
long max = Resource.RESOURCE_UNLIMITED; // if resource limit is not found, then we treat it as unlimited long max = Resource.RESOURCE_UNLIMITED; // if resource limit is not found, then we treat it as unlimited
//no limits for Admin accounts // No limits for Root Admin accounts
if (_accountMgr.isAdmin(account.getType())) { if (_accountMgr.isRootAdmin(account.getType())) {
return max; return max;
} }
ResourceLimitVO limit = _resourceLimitDao.findByOwnerIdAndType(account.getId(), ResourceOwnerType.Account, type); ResourceLimitVO limit = _resourceLimitDao.findByOwnerIdAndType(account.getId(), ResourceOwnerType.Account, type);
// Check if limit is configured for account // Check if limit is configured for account
@ -277,8 +277,8 @@ public class ResourceLimitManagerImpl implements ResourceLimitService, Manager {
long numResources = ((count.length == 0) ? 1 : count[0]); long numResources = ((count.length == 0) ? 1 : count[0]);
Project project = null; Project project = null;
// Don't place any limits on system or admin accounts // Don't place any limits on system or root admin accounts
if (_accountMgr.isAdmin(account.getType())) { if (_accountMgr.isRootAdmin(account.getType())) {
return; return;
} }
@ -510,10 +510,17 @@ public class ResourceLimitManagerImpl implements ResourceLimitService, Manager {
if (account.getId() == Account.ACCOUNT_ID_SYSTEM) { if (account.getId() == Account.ACCOUNT_ID_SYSTEM) {
throw new InvalidParameterValueException("Can't update system account"); throw new InvalidParameterValueException("Can't update system account");
} }
//only Unlimited value is accepted if account is Admin //only Unlimited value is accepted if account is Root Admin
if (_accountMgr.isAdmin(account.getType()) && max.shortValue() != ResourceLimit.RESOURCE_UNLIMITED) { if (_accountMgr.isRootAdmin(account.getType()) && max.shortValue() != ResourceLimit.RESOURCE_UNLIMITED) {
throw new InvalidParameterValueException("Only " + ResourceLimit.RESOURCE_UNLIMITED + " limit is supported for Admin accounts"); throw new InvalidParameterValueException("Only " + ResourceLimit.RESOURCE_UNLIMITED + " limit is supported for Root Admin accounts");
}
if ((caller.getAccountId() == accountId.longValue()) &&
(caller.getType() == Account.ACCOUNT_TYPE_DOMAIN_ADMIN ||
caller.getType() == Account.ACCOUNT_TYPE_RESOURCE_DOMAIN_ADMIN)) {
// If the admin is trying to update his own account, disallow.
throw new PermissionDeniedException("Unable to update resource limit for his own account " + accountId + ", permission denied");
} }
if (account.getType() == Account.ACCOUNT_TYPE_PROJECT) { if (account.getType() == Account.ACCOUNT_TYPE_PROJECT) {