Damans227 commented on code in PR #12615:
URL: https://github.com/apache/cloudstack/pull/12615#discussion_r3624895121


##########
server/src/main/java/com/cloud/user/AccountManagerImpl.java:
##########
@@ -2100,14 +2100,30 @@ public boolean deleteUserAccount(long accountId) {
 
     protected void checkIfAccountManagesProjects(long accountId) {
         List<Long> managedProjectIds = 
_projectAccountDao.listAdministratedProjectIds(accountId);
-        if (!CollectionUtils.isEmpty(managedProjectIds)) {
-            throw new InvalidParameterValueException(String.format(
+
+        if (CollectionUtils.isEmpty(managedProjectIds)) {
+            return;
+        }
+
+        List<Long> activeManagedProjects = new ArrayList<>();
+
+        for (Long projectId : managedProjectIds) {
+            ProjectVO project = _projectDao.findById(projectId);
+            if (project != null && project.getRemoved() == null) {
+                activeManagedProjects.add(projectId);
+            }
+        }
+
+        if (!activeManagedProjects.isEmpty()) {
+            throw new InvalidParameterValueException(

Review Comment:
   Nit: this got reformatted from a single-line `String.format(...)` call to an 
oddly-broken multi-line one, inconsistent with the rest of the file's usual 
single-line style for calls this length.



##########
server/src/main/java/com/cloud/user/AccountManagerImpl.java:
##########
@@ -2100,14 +2100,30 @@ public boolean deleteUserAccount(long accountId) {
 
     protected void checkIfAccountManagesProjects(long accountId) {
         List<Long> managedProjectIds = 
_projectAccountDao.listAdministratedProjectIds(accountId);
-        if (!CollectionUtils.isEmpty(managedProjectIds)) {
-            throw new InvalidParameterValueException(String.format(
+
+        if (CollectionUtils.isEmpty(managedProjectIds)) {
+            return;
+        }
+
+        List<Long> activeManagedProjects = new ArrayList<>();
+
+        for (Long projectId : managedProjectIds) {
+            ProjectVO project = _projectDao.findById(projectId);
+            if (project != null && project.getRemoved() == null) {
+                activeManagedProjects.add(projectId);
+            }
+        }
+
+        if (!activeManagedProjects.isEmpty()) {
+            throw new InvalidParameterValueException(
+                String.format(
                     "Unable to delete account [%s], because it manages the 
following project(s): %s. Please, remove the account from these projects or 
demote it to a regular project role first.",
-                    accountId, managedProjectIds
+                    accountId, activeManagedProjects
             ));
         }
     }
 
+
     protected boolean isDeleteNeeded(AccountVO account, long accountId, 
Account caller) {

Review Comment:
   Nit: extra blank line above this method.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to