Skip to content

Commit 100dc36

Browse files
alexoughsgmurali-reddy
authored andcommitted
CLOUDSTACK-3190
1 parent 462e6d9 commit 100dc36

1 file changed

Lines changed: 25 additions & 4 deletions

File tree

server/src/com/cloud/event/ActionEventUtils.java

Lines changed: 25 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
import javax.annotation.PostConstruct;
2626
import javax.inject.Inject;
2727

28+
import com.cloud.domain.Domain;
2829
import org.apache.log4j.Logger;
2930
import org.springframework.beans.factory.NoSuchBeanDefinitionException;
3031

@@ -171,10 +172,12 @@ private static void publishOnEventBus(long userId, long accountId, String eventC
171172
// get the entity details for which ActionEvent is generated
172173
String entityType = null;
173174
String entityUuid = null;
174-
CallContext context = CallContext.current();
175-
if (context != null) {
176-
entityType = (String)context.getContextParameter(EntityType);
177-
entityUuid = (String)context.getContextParameter(EntityUuid);
175+
Class entityKey = getEntityKey(eventType);
176+
if (entityKey != null)
177+
{
178+
CallContext context = CallContext.current();
179+
entityUuid = (String)context.getContextParameter(entityKey);
180+
if (entityUuid != null) entityType = entityKey.getName();
178181
}
179182

180183
org.apache.cloudstack.framework.events.Event event =
@@ -216,4 +219,22 @@ private static long getDomainId(long accountId) {
216219
}
217220
return account.getDomainId();
218221
}
222+
223+
private static Class getEntityKey(String eventType)
224+
{
225+
if (eventType.startsWith("DOMAIN."))
226+
{
227+
return Domain.class;
228+
}
229+
else if (eventType.startsWith("ACCOUNT."))
230+
{
231+
return Account.class;
232+
}
233+
else if (eventType.startsWith("USER."))
234+
{
235+
return User.class;
236+
}
237+
238+
return null;
239+
}
219240
}

0 commit comments

Comments
 (0)