From 8101ffb63675a6a617c1e377efda4715aa2b53c4 Mon Sep 17 00:00:00 2001 From: Kris McQueen Date: Tue, 21 Sep 2010 18:24:18 -0700 Subject: [PATCH] Fix logic in accountAndUserValidation to correctly detect child domains and throw an exception only when the domain is not in the hierarchy. --- server/src/com/cloud/vm/UserVmManagerImpl.java | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) diff --git a/server/src/com/cloud/vm/UserVmManagerImpl.java b/server/src/com/cloud/vm/UserVmManagerImpl.java index 121e9433eb5..76497c02fe5 100644 --- a/server/src/com/cloud/vm/UserVmManagerImpl.java +++ b/server/src/com/cloud/vm/UserVmManagerImpl.java @@ -1340,16 +1340,11 @@ public class UserVmManagerImpl implements UserVmManager { } - private Long accountAndUserValidation(Long virtualMachineId,Account account, Long userId, UserVmVO vmInstance) throws ServerApiException - { - if (account != null) - { - if (!isAdmin(account.getType()) && (account.getId().longValue() != vmInstance.getAccountId())) - { + private Long accountAndUserValidation(Long virtualMachineId,Account account, Long userId, UserVmVO vmInstance) throws ServerApiException { + if (account != null) { + if (!isAdmin(account.getType()) && (account.getId().longValue() != vmInstance.getAccountId())) { throw new ServerApiException(BaseCmd.VM_INVALID_PARAM_ERROR, "unable to find a virtual machine with id " + virtualMachineId + " for this account"); - } - else if (_domainDao.isChildDomain(account.getDomainId(),vmInstance.getDomainId())) - { + } else if (!_domainDao.isChildDomain(account.getDomainId(),vmInstance.getDomainId())) { throw new ServerApiException(BaseCmd.PARAM_ERROR, "Invalid virtual machine id (" + virtualMachineId + ") given, unable to upgrade virtual machine."); } }