use of org.eclipse.sw360.cvesearch.entitytranslation.CveSearchDataTranslator in project sw360portal by sw360.
the class CveSearchHandler method updateForRelease.
private VulnerabilityUpdateStatus updateForRelease(Release release) {
Optional<List<CveSearchData>> cveSearchDatas = cveSearchWrapper.searchForRelease(release);
if (!cveSearchDatas.isPresent()) {
return new VulnerabilityUpdateStatus().setRequestStatus(RequestStatus.FAILURE);
}
CveSearchDataTranslator cveSearchDataTranslator = new CveSearchDataTranslator();
List<CveSearchDataTranslator.VulnerabilityWithRelation> translated = cveSearchDatas.get().stream().map(cveSearchDataTranslator).map(vulnerabilityWithRelation -> {
vulnerabilityWithRelation.relation.setReleaseId(release.getId());
return vulnerabilityWithRelation;
}).collect(Collectors.toList());
VulnerabilityUpdateStatus updateStatus = getEmptyVulnerabilityUpdateStatus();
for (CveSearchDataTranslator.VulnerabilityWithRelation vulnerabilityWithRelation : translated) {
updateStatus = vulnerabilityConnector.addOrUpdate(vulnerabilityWithRelation.vulnerability, vulnerabilityWithRelation.relation, updateStatus);
}
return updateStatus;
}
Aggregations