CLOUDSTACK-8816: Project UUID is not showing for some of operations in RabbitMQ.

This commit is contained in:
Rajani Karuturi 2015-09-09 12:18:08 +05:30
parent b12d4730a6
commit 3bd53521e8
5 changed files with 22 additions and 2 deletions

View File

@ -21,6 +21,7 @@ import java.util.Map;
import java.util.Stack;
import java.util.UUID;
import com.cloud.projects.Project;
import org.apache.log4j.Logger;
import org.apache.log4j.NDC;
@ -59,6 +60,7 @@ public class CallContext {
private User user;
private long userId;
private final Map<Object, Object> context = new HashMap<Object, Object>();
private Project project;
static EntityManager s_entityMgr;
@ -314,6 +316,14 @@ public class CallContext {
this.eventDescription = eventDescription;
}
public Project getProject() {
return this.project;
}
public void setProject(Project project) {
this.project = project;
}
/**
* Whether to display the event to the end user.
* @return true - if the event is to be displayed to the end user, false otherwise.

View File

@ -21,6 +21,8 @@ import java.util.Map;
import javax.annotation.PostConstruct;
import javax.inject.Inject;
import com.cloud.projects.Project;
import com.cloud.utils.db.EntityManager;
import org.apache.log4j.Logger;
import org.apache.cloudstack.acl.ControlledEntity;
@ -54,6 +56,9 @@ public class ApiDispatcher {
@Inject
AccountManager _accountMgr;
@Inject
EntityManager _entityMgr;
@Inject()
protected DispatchChainFactory dispatchChainFactory;
@ -102,6 +107,10 @@ public class ApiDispatcher {
final CallContext ctx = CallContext.current();
ctx.setEventDisplayEnabled(cmd.isDisplay());
if(params.get(ApiConstants.PROJECT_ID) != null) {
Project project = _entityMgr.findByUuidIncludingRemoved(Project.class, params.get(ApiConstants.PROJECT_ID));
ctx.setProject(project);
}
// TODO This if shouldn't be here. Use polymorphism and move it to validateSpecificParameters
if (cmd instanceof BaseAsyncCmd) {

View File

@ -84,7 +84,7 @@ public class ActionEventInterceptor implements ComponentMethodInterceptor, Metho
for (ActionEvent actionEvent : getActionEvents(method)) {
CallContext ctx = CallContext.current();
long userId = ctx.getCallingUserId();
long accountId = ctx.getCallingAccountId();
long accountId = ctx.getProject() != null ? ctx.getProject().getProjectAccountId() : ctx.getCallingAccountId(); //This should be the entity owner id rather than the Calling User Account Id.
long startEventId = ctx.getStartEventId();
String eventDescription = getEventDescription(actionEvent, ctx);
String eventType = getEventType(actionEvent, ctx);

View File

@ -120,7 +120,7 @@ public class ActionEventUtils {
public static void onStartedActionEventFromContext(String eventType, String eventDescription, boolean eventDisplayEnabled) {
CallContext ctx = CallContext.current();
long userId = ctx.getCallingUserId();
long accountId = ctx.getCallingAccountId();
long accountId = ctx.getProject() != null ? ctx.getProject().getProjectAccountId() : ctx.getCallingAccountId(); //This should be the entity owner id rather than the Calling User Account Id.
long startEventId = ctx.getStartEventId();
if (!eventType.equals(""))

View File

@ -222,6 +222,7 @@ public class ProjectManagerImpl extends ManagerBase implements ProjectManager {
if (project != null) {
CallContext.current().setEventDetails("Project id=" + project.getId());
CallContext.current().putContextParameter(Project.class, project.getUuid());
}
//Increment resource count