use of org.eclipse.sw360.datahandler.thrift.cvesearch.VulnerabilityUpdateStatus in project sw360portal by sw360.
the class VulnerabilityUtils method getUpdateStatusFromUpdateMap.
public static VulnerabilityUpdateStatus getUpdateStatusFromUpdateMap(Map<UpdateType, List<Vulnerability>> statusToVulnerabilities) {
VulnerabilityUpdateStatus status = getEmptyVulnerabilityUpdateStatus();
status.requestStatus = nullToEmptyList(statusToVulnerabilities.get(UpdateType.FAILED)).size() > 0 ? RequestStatus.FAILURE : RequestStatus.SUCCESS;
for (UpdateType updateType : UpdateType.values()) {
List<String> idList = nullToEmptyList(statusToVulnerabilities.get(updateType)).stream().map(Vulnerability::getExternalId).collect(Collectors.toList());
status.statusToVulnerabilityIds.get(updateType).addAll(idList);
}
return status;
}
use of org.eclipse.sw360.datahandler.thrift.cvesearch.VulnerabilityUpdateStatus in project sw360portal by sw360.
the class VulnerabilityUtilsTest method getUpdateStatusFromUpdateMapFailure.
@Test
public void getUpdateStatusFromUpdateMapFailure() throws Exception {
VulnerabilityUpdateStatus result = getUpdateStatusFromUpdateMap(failedUpdateMap);
assertThat(result.getRequestStatus(), is(RequestStatus.FAILURE));
assertThat(result.statusToVulnerabilityIds.get(UpdateType.UPDATED), containsInAnyOrder("ue1", "ue2", "ue3"));
assertThat(result.statusToVulnerabilityIds.get(UpdateType.NEW), containsInAnyOrder("ne1", "ne2"));
assertThat(result.statusToVulnerabilityIds.get(UpdateType.OLD), containsInAnyOrder("oe1", "oe2", "oe3"));
assertThat(result.statusToVulnerabilityIds.get(UpdateType.FAILED), containsInAnyOrder("fe1", "fe2", "fe3"));
}
use of org.eclipse.sw360.datahandler.thrift.cvesearch.VulnerabilityUpdateStatus in project sw360portal by sw360.
the class VulnerabilityUtilsTest method getUpdateStatusFromUpdateMapSuccess.
@Test
public void getUpdateStatusFromUpdateMapSuccess() throws Exception {
VulnerabilityUpdateStatus result = getUpdateStatusFromUpdateMap(updateMap);
assertThat(result.getRequestStatus(), is(RequestStatus.SUCCESS));
assertThat(result.statusToVulnerabilityIds.get(UpdateType.UPDATED), containsInAnyOrder("ue1", "ue2", "ue3"));
assertThat(result.statusToVulnerabilityIds.get(UpdateType.NEW), containsInAnyOrder("ne1", "ne2"));
}
use of org.eclipse.sw360.datahandler.thrift.cvesearch.VulnerabilityUpdateStatus in project sw360portal by sw360.
the class VulnerabilityUtilsTest method getUpdateStatusFromUpdateMapEmpty.
@Test
public void getUpdateStatusFromUpdateMapEmpty() throws Exception {
VulnerabilityUpdateStatus result = getUpdateStatusFromUpdateMap(new HashMap<>());
assertThat(result.getRequestStatus(), is(RequestStatus.SUCCESS));
assertThat(result.statusToVulnerabilityIds.get(UpdateType.UPDATED), is(Collections.EMPTY_LIST));
assertThat(result.statusToVulnerabilityIds.get(UpdateType.NEW), is(Collections.EMPTY_LIST));
}
use of org.eclipse.sw360.datahandler.thrift.cvesearch.VulnerabilityUpdateStatus in project sw360portal by sw360.
the class ComponentPortlet method updateVulnerabilitiesRelease.
private void updateVulnerabilitiesRelease(ResourceRequest request, ResourceResponse response) throws PortletException, IOException {
String releaseId = request.getParameter(PortalConstants.RELEASE_ID);
CveSearchService.Iface cveClient = thriftClients.makeCvesearchClient();
try {
VulnerabilityUpdateStatus importStatus = cveClient.updateForRelease(releaseId);
JSONObject responseData = PortletUtils.importStatusToJSON(importStatus);
PrintWriter writer = response.getWriter();
writer.write(responseData.toString());
} catch (TException e) {
log.error("Error updating CVEs for release in backend.", e);
}
}
Aggregations