2020
2121import com .cloud .event .dao .EventDao ;
2222import com .cloud .server .ManagementServer ;
23+ import com .cloud .user .AccountVO ;
24+ import com .cloud .user .dao .AccountDao ;
2325import com .cloud .utils .component .ComponentLocator ;
2426
2527public class EventUtils {
2628 private static EventDao _eventDao = ComponentLocator .getLocator (ManagementServer .Name ).getDao (EventDao .class );
29+ private static AccountDao _accountDao = ComponentLocator .getLocator (ManagementServer .Name ).getDao (AccountDao .class );
2730
28- public static Long saveEvent (Long userId , Long accountId , String type , String description ) {
31+ public static Long saveEvent (Long userId , Long accountId , Long domainId , String type , String description ) {
2932 EventVO event = new EventVO ();
3033 event .setUserId (userId );
3134 event .setAccountId (accountId );
35+ event .setDomainId (domainId );
3236 event .setType (type );
3337 event .setDescription (description );
3438 event = _eventDao .persist (event );
@@ -42,6 +46,7 @@ public static Long saveScheduledEvent(Long userId, Long accountId, String type,
4246 EventVO event = new EventVO ();
4347 event .setUserId (userId );
4448 event .setAccountId (accountId );
49+ event .setDomainId (getDomainId (accountId ));
4550 event .setType (type );
4651 event .setStartId (startEventId );
4752 event .setState (Event .State .Scheduled );
@@ -57,52 +62,20 @@ public static Long saveStartedEvent(Long userId, Long accountId, String type, St
5762 EventVO event = new EventVO ();
5863 event .setUserId (userId );
5964 event .setAccountId (accountId );
65+ event .setDomainId (getDomainId (accountId ));
6066 event .setType (type );
6167 event .setState (Event .State .Started );
6268 event .setDescription ("Starting job for " +description );
6369 event .setStartId (startEventId );
6470 event = _eventDao .persist (event );
6571 return event .getId ();
66- }
67-
68- public static Long saveStartedEvent (Long userId , Long accountId , String type , String description ) {
69- EventVO event = new EventVO ();
70- event .setUserId (userId );
71- event .setAccountId (accountId );
72- event .setType (type );
73- event .setState (Event .State .Started );
74- event .setDescription (description );
75- event = _eventDao .persist (event );
76- return event .getId ();
77- }
78-
79- public static Long saveEvent (Long userId , Long accountId , String level , String type , String description ) {
80- EventVO event = new EventVO ();
81- event .setUserId (userId );
82- event .setAccountId (accountId );
83- event .setType (type );
84- event .setDescription (description );
85- event .setLevel (level );
86- event = _eventDao .persist (event );
87- return event .getId ();
88- }
89-
90- public static Long saveEvent (Long userId , Long accountId , String level , String type , String description , String params ) {
91- EventVO event = new EventVO ();
92- event .setUserId (userId );
93- event .setAccountId (accountId );
94- event .setType (type );
95- event .setDescription (description );
96- event .setLevel (level );
97- event .setParameters (params );
98- event = _eventDao .persist (event );
99- return event .getId ();
100- }
72+ }
10173
10274 public static Long saveEvent (Long userId , Long accountId , String level , String type , String description , long startEventId ) {
10375 EventVO event = new EventVO ();
10476 event .setUserId (userId );
10577 event .setAccountId (accountId );
78+ event .setDomainId (getDomainId (accountId ));
10679 event .setType (type );
10780 event .setDescription (description );
10881 event .setLevel (level );
@@ -111,28 +84,21 @@ public static Long saveEvent(Long userId, Long accountId, String level, String t
11184 return (event != null ? event .getId () : null );
11285 }
11386
114- public static Long saveEvent (Long userId , Long accountId , String level , String type , String description , String params , long startEventId ) {
115- EventVO event = new EventVO ();
116- event .setUserId (userId );
117- event .setAccountId (accountId );
118- event .setType (type );
119- event .setDescription (description );
120- event .setLevel (level );
121- event .setParameters (params );
122- event .setStartId (startEventId );
123- event = _eventDao .persist (event );
124- return event .getId ();
125- }
126-
12787 public static Long saveCreatedEvent (Long userId , Long accountId , String level , String type , String description ) {
12888 EventVO event = new EventVO ();
12989 event .setUserId (userId );
13090 event .setAccountId (accountId );
91+ event .setDomainId (getDomainId (accountId ));
13192 event .setType (type );
13293 event .setLevel (level );
13394 event .setState (Event .State .Created );
13495 event .setDescription (description );
13596 event = _eventDao .persist (event );
13697 return event .getId ();
13798 }
99+
100+ private static long getDomainId (long accountId ){
101+ AccountVO account = _accountDao .findByIdIncludingRemoved (accountId );
102+ return account .getDomainId ();
103+ }
138104}
0 commit comments