Search in sources :

Example 1 with CveSearchDataTranslator

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;
}
Also used : VulnerabilityConnector(org.eclipse.sw360.cvesearch.datasink.VulnerabilityConnector) java.util(java.util) CveSearchData(org.eclipse.sw360.cvesearch.datasource.CveSearchData) CveSearchService(org.eclipse.sw360.datahandler.thrift.cvesearch.CveSearchService) Component(org.eclipse.sw360.datahandler.thrift.components.Component) Release(org.eclipse.sw360.datahandler.thrift.components.Release) CveSearchWrapper(org.eclipse.sw360.cvesearch.datasource.CveSearchWrapper) TException(org.apache.thrift.TException) IOException(java.io.IOException) VulnerabilityUpdateStatus(org.eclipse.sw360.datahandler.thrift.cvesearch.VulnerabilityUpdateStatus) Collectors(java.util.stream.Collectors) RequestStatus(org.eclipse.sw360.datahandler.thrift.RequestStatus) UpdateType(org.eclipse.sw360.datahandler.thrift.cvesearch.UpdateType) CommonUtils(org.eclipse.sw360.datahandler.common.CommonUtils) Logger(org.apache.log4j.Logger) CveSearchDataTranslator(org.eclipse.sw360.cvesearch.entitytranslation.CveSearchDataTranslator) VulnerabilityUtils(org.eclipse.sw360.cvesearch.helper.VulnerabilityUtils) CveSearchApiImpl(org.eclipse.sw360.cvesearch.datasource.CveSearchApiImpl) Project(org.eclipse.sw360.datahandler.thrift.projects.Project) VulnerabilityUpdateStatus(org.eclipse.sw360.datahandler.thrift.cvesearch.VulnerabilityUpdateStatus) CveSearchDataTranslator(org.eclipse.sw360.cvesearch.entitytranslation.CveSearchDataTranslator)

Aggregations

IOException (java.io.IOException)1 java.util (java.util)1 Collectors (java.util.stream.Collectors)1 Logger (org.apache.log4j.Logger)1 TException (org.apache.thrift.TException)1 VulnerabilityConnector (org.eclipse.sw360.cvesearch.datasink.VulnerabilityConnector)1 CveSearchApiImpl (org.eclipse.sw360.cvesearch.datasource.CveSearchApiImpl)1 CveSearchData (org.eclipse.sw360.cvesearch.datasource.CveSearchData)1 CveSearchWrapper (org.eclipse.sw360.cvesearch.datasource.CveSearchWrapper)1 CveSearchDataTranslator (org.eclipse.sw360.cvesearch.entitytranslation.CveSearchDataTranslator)1 VulnerabilityUtils (org.eclipse.sw360.cvesearch.helper.VulnerabilityUtils)1 CommonUtils (org.eclipse.sw360.datahandler.common.CommonUtils)1 RequestStatus (org.eclipse.sw360.datahandler.thrift.RequestStatus)1 Component (org.eclipse.sw360.datahandler.thrift.components.Component)1 Release (org.eclipse.sw360.datahandler.thrift.components.Release)1 CveSearchService (org.eclipse.sw360.datahandler.thrift.cvesearch.CveSearchService)1 UpdateType (org.eclipse.sw360.datahandler.thrift.cvesearch.UpdateType)1 VulnerabilityUpdateStatus (org.eclipse.sw360.datahandler.thrift.cvesearch.VulnerabilityUpdateStatus)1 Project (org.eclipse.sw360.datahandler.thrift.projects.Project)1