sureshanaparti commented on code in PR #12607:
URL: https://github.com/apache/cloudstack/pull/12607#discussion_r2781896434


##########
server/src/main/java/com/cloud/user/AccountManagerImpl.java:
##########
@@ -2118,16 +2118,31 @@ public boolean deleteUserAccount(long accountId) {
         return deleteAccount(account, callerUserId, caller);
     }
 
-    protected void checkIfAccountManagesProjects(long accountId) {
-        List<Long> managedProjectIds = 
_projectAccountDao.listAdministratedProjectIds(accountId);
-        if (!CollectionUtils.isEmpty(managedProjectIds)) {
-            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
-            ));
+protected void checkIfAccountManagesProjects(long accountId) {
+    List<Long> managedProjectIds = 
_projectAccountDao.listAdministratedProjectIds(accountId);
+
+    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, activeManagedProjects
+        ));
+    }
+}
+
+

Review Comment:
   check indentation ^^^



-- 
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