Skip to content

Commit b40fdbb

Browse files
shwstppryadvr
authored andcommitted
api: fix account deletion event description (#3483)
Fix account deletion event description. Fixes #3109 Signed-off-by: Abhishek Kumar <abhishek.mrt22@gmail.com>
1 parent 1bf4dd3 commit b40fdbb

1 file changed

Lines changed: 6 additions & 7 deletions

File tree

api/src/main/java/org/apache/cloudstack/api/command/admin/account/DeleteAccountCmd.java

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,6 @@
1818

1919
import javax.inject.Inject;
2020

21-
import org.apache.log4j.Logger;
22-
2321
import org.apache.cloudstack.acl.SecurityChecker.AccessType;
2422
import org.apache.cloudstack.api.ACL;
2523
import org.apache.cloudstack.api.APICommand;
@@ -33,10 +31,10 @@
3331
import org.apache.cloudstack.api.response.SuccessResponse;
3432
import org.apache.cloudstack.context.CallContext;
3533
import org.apache.cloudstack.region.RegionService;
34+
import org.apache.log4j.Logger;
3635

3736
import com.cloud.event.EventTypes;
3837
import com.cloud.user.Account;
39-
import com.cloud.user.User;
4038

4139
@APICommand(name = "deleteAccount", description = "Deletes a account, and all users associated with this account", responseObject = SuccessResponse.class, entityType = {Account.class},
4240
requestHasSensitiveInfo = false, responseHasSensitiveInfo = false)
@@ -92,14 +90,15 @@ public String getEventType() {
9290

9391
@Override
9492
public String getEventDescription() {
95-
User user = _responseGenerator.findUserById(getId());
96-
return (user != null ? ("deleting User " + user.getUsername() + " (id: " + user.getId() + ") and accountId = " + user.getAccountId())
97-
: "user delete, but this user does not exist in the system");
93+
Account account = _accountService.getAccount(getId());
94+
return (account != null ? "Deleting user account " + account.getAccountName() + " (ID: " + account.getUuid() + ") and all corresponding users"
95+
: "Account delete, but this account does not exist in the system");
9896
}
9997

10098
@Override
10199
public void execute() {
102-
CallContext.current().setEventDetails("Account Id: " + getId());
100+
Account account = _accountService.getAccount(getId());
101+
CallContext.current().setEventDetails("Account ID: " + (account != null ? account.getUuid() : getId())); // Account not found is already handled by service
103102

104103
boolean result = _regionService.deleteUserAccount(this);
105104
if (result) {

0 commit comments

Comments
 (0)