use of com.blackducksoftware.integration.hub.alert.audit.repository.relation.AuditNotificationRelation in project hub-alert by blackducksoftware.
the class AuditEntryActions method resendNotification.
public List<AuditEntryRestModel> resendNotification(final Long id) throws IntegrationException, IllegalArgumentException {
AuditEntryEntity auditEntryEntity = null;
auditEntryEntity = auditEntryRepository.findOne(id);
if (auditEntryEntity == null) {
throw new AlertException("No audit entry with the provided id exists.");
}
final List<AuditNotificationRelation> relations = auditNotificationRepository.findByAuditEntryId(auditEntryEntity.getId());
final List<Long> notificationIds = relations.stream().map(relation -> relation.getNotificationId()).collect(Collectors.toList());
final List<NotificationModel> notifications = notificationManager.findByIds(notificationIds);
final Long commonConfigId = auditEntryEntity.getCommonConfigId();
final CommonDistributionConfigEntity commonConfigEntity = commonDistributionRepository.findOne(commonConfigId);
if (notifications == null || notifications.isEmpty()) {
throw new IllegalArgumentException("The notification for this entry was purged. To edit the purge schedule, please see the Scheduling Configuration.");
}
if (commonConfigEntity == null) {
throw new IllegalArgumentException("The job for this entry was deleted, can not re-send this entry.");
}
final Collection<ProjectData> projectDataList = projectDataFactory.createProjectDataCollection(notifications);
for (final ProjectData projectData : projectDataList) {
final AbstractChannelEvent event = channelEventFactory.createEvent(commonConfigId, commonConfigEntity.getDistributionType(), projectData);
event.setAuditEntryId(auditEntryEntity.getId());
channelTemplateManager.sendEvent(event);
}
return get();
}
Aggregations