From a61a92b0fe61c10c704ea12df83db7f5a4aad6b1 Mon Sep 17 00:00:00 2001 From: kishan Date: Fri, 4 Mar 2011 16:59:19 +0530 Subject: [PATCH] bug 8675: Added action events for Domain commands status 8675: resolved fixed --- api/src/com/cloud/api/commands/CreateDomainCmd.java | 2 ++ api/src/com/cloud/api/commands/DeleteDomainCmd.java | 2 ++ api/src/com/cloud/api/commands/UpdateDomainCmd.java | 2 ++ server/src/com/cloud/server/ManagementServerImpl.java | 6 +++--- 4 files changed, 9 insertions(+), 3 deletions(-) diff --git a/api/src/com/cloud/api/commands/CreateDomainCmd.java b/api/src/com/cloud/api/commands/CreateDomainCmd.java index 126a4b1aeba..2b50d86c54a 100644 --- a/api/src/com/cloud/api/commands/CreateDomainCmd.java +++ b/api/src/com/cloud/api/commands/CreateDomainCmd.java @@ -27,6 +27,7 @@ import com.cloud.api.ServerApiException; import com.cloud.api.response.DomainResponse; import com.cloud.domain.Domain; import com.cloud.user.Account; +import com.cloud.user.UserContext; @Implementation(description="Creates a domain", responseObject=DomainResponse.class) public class CreateDomainCmd extends BaseCmd { @@ -74,6 +75,7 @@ public class CreateDomainCmd extends BaseCmd { @Override public void execute(){ + UserContext.current().setEventDetails("Domain Name: "+getDomainName()+((getParentDomainId()!=null)?", Parent DomainId :"+getParentDomainId():"")); Domain domain = _mgr.createDomain(this); if (domain != null) { DomainResponse response = _responseGenerator.createDomainResponse(domain); diff --git a/api/src/com/cloud/api/commands/DeleteDomainCmd.java b/api/src/com/cloud/api/commands/DeleteDomainCmd.java index 55fe622ee74..775039f15e1 100644 --- a/api/src/com/cloud/api/commands/DeleteDomainCmd.java +++ b/api/src/com/cloud/api/commands/DeleteDomainCmd.java @@ -29,6 +29,7 @@ import com.cloud.api.response.SuccessResponse; import com.cloud.domain.Domain; import com.cloud.event.EventTypes; import com.cloud.user.Account; +import com.cloud.user.UserContext; @Implementation(description="Deletes a specified domain", responseObject=SuccessResponse.class) public class DeleteDomainCmd extends BaseAsyncCmd { @@ -89,6 +90,7 @@ public class DeleteDomainCmd extends BaseAsyncCmd { @Override public void execute(){ + UserContext.current().setEventDetails("Domain Id: "+getId()); boolean result = _mgr.deleteDomain(this); if (result) { SuccessResponse response = new SuccessResponse(getCommandName()); diff --git a/api/src/com/cloud/api/commands/UpdateDomainCmd.java b/api/src/com/cloud/api/commands/UpdateDomainCmd.java index f2897fb099a..cb0a2ba2e34 100644 --- a/api/src/com/cloud/api/commands/UpdateDomainCmd.java +++ b/api/src/com/cloud/api/commands/UpdateDomainCmd.java @@ -27,6 +27,7 @@ import com.cloud.api.ServerApiException; import com.cloud.api.response.DomainResponse; import com.cloud.domain.Domain; import com.cloud.user.Account; +import com.cloud.user.UserContext; @Implementation(description="Updates a domain with a new name", responseObject=DomainResponse.class) public class UpdateDomainCmd extends BaseCmd { @@ -71,6 +72,7 @@ public class UpdateDomainCmd extends BaseCmd { @Override public void execute(){ + UserContext.current().setEventDetails("Domain Id: "+getId()); Domain domain = _mgr.updateDomain(this); if (domain != null) { DomainResponse response = _responseGenerator.createDomainResponse(domain); diff --git a/server/src/com/cloud/server/ManagementServerImpl.java b/server/src/com/cloud/server/ManagementServerImpl.java index 0872bfaadc6..eadd6b75166 100755 --- a/server/src/com/cloud/server/ManagementServerImpl.java +++ b/server/src/com/cloud/server/ManagementServerImpl.java @@ -2904,7 +2904,7 @@ public class ManagementServerImpl implements ManagementServer { return _domainDao.search(sc, searchFilter); } - @Override + @Override @ActionEvent (eventType=EventTypes.EVENT_DOMAIN_CREATE, eventDescription="creating Domain") public DomainVO createDomain(CreateDomainCmd cmd) throws InvalidParameterValueException, PermissionDeniedException { String name = cmd.getDomainName(); Long parentId = cmd.getParentDomainId(); @@ -2945,7 +2945,7 @@ public class ManagementServerImpl implements ManagementServer { } } - @Override + @Override @ActionEvent (eventType=EventTypes.EVENT_DOMAIN_DELETE, eventDescription="deleting Domain", async=true) public boolean deleteDomain(DeleteDomainCmd cmd) throws InvalidParameterValueException, PermissionDeniedException { Account account = UserContext.current().getCaller(); Long domainId = cmd.getId(); @@ -3049,7 +3049,7 @@ public class ManagementServerImpl implements ManagementServer { return success && deleteDomainSuccess; } - @Override + @Override @ActionEvent (eventType=EventTypes.EVENT_DOMAIN_UPDATE, eventDescription="updating Domain") public DomainVO updateDomain(UpdateDomainCmd cmd) throws InvalidParameterValueException, PermissionDeniedException{ Long domainId = cmd.getId(); String domainName = cmd.getDomainName();