@Override public ApplicationDto editApplication(ApplicationDto application) throws ControlServiceException { ApplicationDto storedApplication = applicationService .findAppByApplicationToken(application.getApplicationToken()); if (storedApplication != null) { application.setId(storedApplication.getId()); } boolean update = !isEmpty(application.getId()); ApplicationDto appDto = applicationService.saveApp(application); if (update) { LOG.info("[{}] Broadcasting notification about application {} update.", application.getId(), application.getApplicationToken()); Notification thriftNotification = new Notification(); thriftNotification.setAppId(appDto.getId()); thriftNotification.setAppSeqNumber(appDto.getSequenceNumber()); thriftNotification.setOp(Operation.APP_UPDATE); controlZkService.sendEndpointNotification(thriftNotification); } return appDto; }
private <T> Notification toNotification(UpdateNotificationDto<T> notification) { Notification thriftNotification = new Notification(); thriftNotification.setAppId(notification.getAppId()); thriftNotification.setAppSeqNumber(notification.getAppSeqNumber()); thriftNotification.setGroupId(notification.getGroupId()); thriftNotification.setGroupSeqNumber(notification.getGroupSeqNumber()); thriftNotification.setTopicId(notification.getTopicId()); thriftNotification.setOp(getOperation(notification.getChangeType())); T payload = notification.getPayload(); if (payload != null) { if (payload instanceof NotificationDto) { NotificationDto dto = (NotificationDto) payload; thriftNotification.setNotificationId(dto.getId()); } } return thriftNotification; }
/** * Notify endpoints. * * @param notification the notification * @param profileFilter the profile filter * @param configuration the configuration */ private void notifyEndpoints(ChangeNotificationDto notification, ProfileFilterDto profileFilter, ConfigurationDto configuration) { Notification thriftNotification = new Notification(); thriftNotification.setAppId(notification.getAppId()); thriftNotification.setAppSeqNumber(notification.getAppSeqNumber()); thriftNotification.setGroupId(notification.getGroupId()); thriftNotification.setGroupSeqNumber(notification.getGroupSeqNumber()); if (profileFilter != null) { thriftNotification.setProfileFilterId(profileFilter.getId()); thriftNotification.setProfileFilterSeqNumber(profileFilter.getSequenceNumber()); } if (configuration != null) { thriftNotification.setConfigurationId(configuration.getId()); thriftNotification.setConfigurationSeqNumber(configuration.getSequenceNumber()); } controlZkService.sendEndpointNotification(thriftNotification); }
unsetAppSeqNumber(); } else { setAppSeqNumber((Integer)value);