@Override public void interceptComplete(AnnotatedElement element, EventVO event) { Method method = (Method) element; ActionEvent actionEvent = method.getAnnotation(ActionEvent.class); if (actionEvent != null) { UserContext ctx = UserContext.current(); long userId = ctx.getCallerUserId(); long accountId = ctx.getAccountId(); long startEventId = ctx.getStartEventId(); String eventDescription = actionEvent.eventDescription(); if (ctx.getEventDetails() != null) { eventDescription += ". " + ctx.getEventDetails(); } if (actionEvent.create()) { // This start event has to be used for subsequent events of this action startEventId = EventUtils.saveCreatedEvent( userId, accountId, EventVO.LEVEL_INFO, actionEvent.eventType(), "Successfully created entity for " + eventDescription); ctx.setStartEventId(startEventId); } else { EventUtils.saveEvent( userId, accountId, EventVO.LEVEL_INFO, actionEvent.eventType(), "Successfully completed " + eventDescription, startEventId); } } }
@Override public void interceptException(AnnotatedElement element, EventVO event) { Method method = (Method) element; ActionEvent actionEvent = method.getAnnotation(ActionEvent.class); if (actionEvent != null) { UserContext ctx = UserContext.current(); long userId = ctx.getCallerUserId(); long accountId = ctx.getAccountId(); long startEventId = ctx.getStartEventId(); String eventDescription = actionEvent.eventDescription(); if (ctx.getEventDetails() != null) { eventDescription += ". " + ctx.getEventDetails(); } if (actionEvent.create()) { long eventId = EventUtils.saveCreatedEvent( userId, accountId, EventVO.LEVEL_ERROR, actionEvent.eventType(), "Error while creating entity for " + eventDescription); ctx.setStartEventId(eventId); } else { EventUtils.saveEvent( userId, accountId, EventVO.LEVEL_ERROR, actionEvent.eventType(), "Error while " + eventDescription, startEventId); } } }