@Override public void update(final AccountModelDao account, final boolean treatNullValueAsReset, final InternalCallContext context) { super.update(account, context); final AccountModelDao currentAccount = getById(account.getId(), context); final Long accountRecordId = getRecordId(account.getId(), context); final long tenantRecordId = context == null ? InternalCallContextFactory.INTERNAL_TENANT_RECORD_ID : context.getTenantRecordId(); final AccountChangeInternalEvent changeEvent = new DefaultAccountChangeEvent(account.getId(), currentAccount, account, accountRecordId, tenantRecordId, UUID.randomUUID(), clock.getUTCNow()); if (changeEvent.hasChanges()) { try { eventBus.post(changeEvent); } catch (final EventBusException ex) { Assert.fail(ex.toString()); } } }
@Override public void postFromTransaction(final BusEvent event, final Connection connection) throws EventBusException { checkInitialized("postFromTransaction"); try { delegate.postWithException(event); } catch (final com.google.common.eventbus.EventBusException e) { throw new EventBusException(e.getMessage(), e); } }
private void checkInitialized(final String operation) throws EventBusException { if (!isInitialized.get()) { throw new EventBusException(String.format("Attempting operation %s on an non initialized bus", operation)); } }
@Override public void post(final BusEvent event) throws EventBusException { checkInitialized("post"); try { delegate.postWithException(event); } catch (final com.google.common.eventbus.EventBusException e) { throw new EventBusException(e.getMessage(), e); } }
@Override public void create(final AccountModelDao account, final InternalCallContext context) throws AccountApiException { super.create(account, context); try { final Long accountRecordId = getRecordId(account.getId(), context); final long tenantRecordId = context == null ? InternalCallContextFactory.INTERNAL_TENANT_RECORD_ID : context.getTenantRecordId(); eventBus.post(new DefaultAccountCreationEvent(new DefaultAccountData(account), account.getId(), accountRecordId, tenantRecordId, UUID.randomUUID())); } catch (final EventBusException ex) { Assert.fail(ex.toString()); } }