@Override @Transactional public UpdateNotificationDto<EndpointGroupDto> removeTopicFromEndpointGroup(String id, String topicId) { validateSqlId(id, "Can't remove endpoint group topics " + topicId + ". Incorrect endpoint group id." + id); UpdateNotificationDto<EndpointGroupDto> dto = null; EndpointGroup endpointGroup = endpointGroupDao.removeTopicFromEndpointGroup(id, topicId); if (endpointGroup != null) { dto = new UpdateNotificationDto<>(); HistoryDto history = addHistory(endpointGroup.toDto(), ChangeType.REMOVE_TOPIC, topicId); if (history != null) { dto.setAppId(history.getApplicationId()); dto.setAppSeqNumber(history.getSequenceNumber()); } dto.setChangeType(ChangeType.REMOVE_TOPIC); dto.setTopicId(topicId); dto.setGroupId(endpointGroup.getId().toString()); dto.setPayload(endpointGroup.toDto()); } else { LOG.debug("Can't remove topic [{}] from endpoint group [{}]", topicId, id); } return dto; }
@Override @Transactional public UpdateNotificationDto<EndpointGroupDto> addTopicToEndpointGroup(String id, String topicId) { validateSqlId(id, "Can't add topics " + topicId + " to endpoint group . Incorrect endpoint group id." + id); UpdateNotificationDto<EndpointGroupDto> dto = null; EndpointGroup endpointGroup = endpointGroupDao.addTopicToEndpointGroup(id, topicId); if (endpointGroup != null) { dto = new UpdateNotificationDto<>(); HistoryDto history = addHistory(endpointGroup.toDto(), ChangeType.ADD_TOPIC, topicId); if (history != null) { dto.setAppId(history.getApplicationId()); dto.setAppSeqNumber(history.getSequenceNumber()); } dto.setChangeType(ChangeType.ADD_TOPIC); dto.setTopicId(topicId); dto.setGroupId(endpointGroup.getId().toString()); dto.setPayload(endpointGroup.toDto()); } else { LOG.debug("Can't add topic [{}] to endpoint group [{}]", topicId, id); } return dto; }
EndpointGroupDto groupDto = endpointGroup.toDto(); HistoryDto historyDto = addHistory(groupDto, ChangeType.REMOVE_GROUP); changeDto = new ChangeNotificationDto();