From b40fdbb2f7659f631b385aaa032c7221868baea2 Mon Sep 17 00:00:00 2001 From: Abhishek Kumar Date: Fri, 12 Jul 2019 13:10:30 +0530 Subject: [PATCH] api: fix account deletion event description (#3483) Fix account deletion event description. Fixes #3109 Signed-off-by: Abhishek Kumar --- .../api/command/admin/account/DeleteAccountCmd.java | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/api/src/main/java/org/apache/cloudstack/api/command/admin/account/DeleteAccountCmd.java b/api/src/main/java/org/apache/cloudstack/api/command/admin/account/DeleteAccountCmd.java index 2a2e16dd0bd..1896f97311c 100644 --- a/api/src/main/java/org/apache/cloudstack/api/command/admin/account/DeleteAccountCmd.java +++ b/api/src/main/java/org/apache/cloudstack/api/command/admin/account/DeleteAccountCmd.java @@ -18,8 +18,6 @@ package org.apache.cloudstack.api.command.admin.account; import javax.inject.Inject; -import org.apache.log4j.Logger; - import org.apache.cloudstack.acl.SecurityChecker.AccessType; import org.apache.cloudstack.api.ACL; import org.apache.cloudstack.api.APICommand; @@ -33,10 +31,10 @@ import org.apache.cloudstack.api.response.AccountResponse; import org.apache.cloudstack.api.response.SuccessResponse; import org.apache.cloudstack.context.CallContext; import org.apache.cloudstack.region.RegionService; +import org.apache.log4j.Logger; import com.cloud.event.EventTypes; import com.cloud.user.Account; -import com.cloud.user.User; @APICommand(name = "deleteAccount", description = "Deletes a account, and all users associated with this account", responseObject = SuccessResponse.class, entityType = {Account.class}, requestHasSensitiveInfo = false, responseHasSensitiveInfo = false) @@ -92,14 +90,15 @@ public class DeleteAccountCmd extends BaseAsyncCmd { @Override public String getEventDescription() { - User user = _responseGenerator.findUserById(getId()); - return (user != null ? ("deleting User " + user.getUsername() + " (id: " + user.getId() + ") and accountId = " + user.getAccountId()) - : "user delete, but this user does not exist in the system"); + Account account = _accountService.getAccount(getId()); + return (account != null ? "Deleting user account " + account.getAccountName() + " (ID: " + account.getUuid() + ") and all corresponding users" + : "Account delete, but this account does not exist in the system"); } @Override public void execute() { - CallContext.current().setEventDetails("Account Id: " + getId()); + Account account = _accountService.getAccount(getId()); + CallContext.current().setEventDetails("Account ID: " + (account != null ? account.getUuid() : getId())); // Account not found is already handled by service boolean result = _regionService.deleteUserAccount(this); if (result) {