Search in sources :

Example 11 with UpdateType

use of org.eclipse.sw360.datahandler.thrift.cvesearch.UpdateType in project sw360portal by sw360.

the class VulnerabilityUtils method reduceVulnerabilityUpdateStatus.

public static VulnerabilityUpdateStatus reduceVulnerabilityUpdateStatus(VulnerabilityUpdateStatus... statuses) {
    VulnerabilityUpdateStatus resultStatus = getEmptyVulnerabilityUpdateStatus();
    RequestStatus requestStatus = Arrays.stream(statuses).map(VulnerabilityUpdateStatus::getRequestStatus).reduce(RequestStatus.SUCCESS, CommonUtils::reduceRequestStatus);
    resultStatus.setRequestStatus(requestStatus);
    for (UpdateType updateType : UpdateType.values()) {
        for (VulnerabilityUpdateStatus status : statuses) {
            if (status.isSetStatusToVulnerabilityIds()) {
                resultStatus.statusToVulnerabilityIds.get(updateType).addAll(nullToEmptyList(status.statusToVulnerabilityIds.get(updateType)));
            }
        }
    }
    return resultStatus;
}
Also used : CommonUtils(org.eclipse.sw360.datahandler.common.CommonUtils) VulnerabilityUpdateStatus(org.eclipse.sw360.datahandler.thrift.cvesearch.VulnerabilityUpdateStatus) UpdateType(org.eclipse.sw360.datahandler.thrift.cvesearch.UpdateType) RequestStatus(org.eclipse.sw360.datahandler.thrift.RequestStatus)

Example 12 with UpdateType

use of org.eclipse.sw360.datahandler.thrift.cvesearch.UpdateType 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;
}
Also used : VulnerabilityUpdateStatus(org.eclipse.sw360.datahandler.thrift.cvesearch.VulnerabilityUpdateStatus) UpdateType(org.eclipse.sw360.datahandler.thrift.cvesearch.UpdateType)

Aggregations

UpdateType (org.eclipse.sw360.datahandler.thrift.cvesearch.UpdateType)11 Vulnerability (org.eclipse.sw360.datahandler.thrift.vulnerabilities.Vulnerability)9 Test (org.junit.Test)6 RequestStatus (org.eclipse.sw360.datahandler.thrift.RequestStatus)3 VulnerabilityUpdateStatus (org.eclipse.sw360.datahandler.thrift.cvesearch.VulnerabilityUpdateStatus)2 CommonUtils (org.eclipse.sw360.datahandler.common.CommonUtils)1 Before (org.junit.Before)1