Search in sources :

Example 11 with VulnerabilityUpdateStatus

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

the class ComponentPortlet method updateVulnerabilitiesComponent.

private void updateVulnerabilitiesComponent(ResourceRequest request, ResourceResponse response) throws PortletException, IOException {
    String componentId = request.getParameter(PortalConstants.COMPONENT_ID);
    CveSearchService.Iface cveClient = thriftClients.makeCvesearchClient();
    try {
        VulnerabilityUpdateStatus importStatus = cveClient.updateForComponent(componentId);
        JSONObject responseData = PortletUtils.importStatusToJSON(importStatus);
        PrintWriter writer = response.getWriter();
        writer.write(responseData.toString());
    } catch (TException e) {
        log.error("Error updating CVEs for component in backend.", e);
    }
}
Also used : CveSearchService(org.eclipse.sw360.datahandler.thrift.cvesearch.CveSearchService) TException(org.apache.thrift.TException) JSONObject(com.liferay.portal.kernel.json.JSONObject) VulnerabilityUpdateStatus(org.eclipse.sw360.datahandler.thrift.cvesearch.VulnerabilityUpdateStatus) PrintWriter(java.io.PrintWriter)

Example 12 with VulnerabilityUpdateStatus

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

the class ProjectPortlet method updateVulnerabilitiesProject.

private void updateVulnerabilitiesProject(ResourceRequest request, ResourceResponse response) throws PortletException, IOException {
    String projectId = request.getParameter(PortalConstants.PROJECT_ID);
    CveSearchService.Iface cveClient = thriftClients.makeCvesearchClient();
    try {
        VulnerabilityUpdateStatus importStatus = cveClient.updateForProject(projectId);
        JSONObject responseData = PortletUtils.importStatusToJSON(importStatus);
        PrintWriter writer = response.getWriter();
        writer.write(responseData.toString());
    } catch (TException e) {
        log.error("Error updating CVEs for project in backend.", e);
    }
}
Also used : CveSearchService(org.eclipse.sw360.datahandler.thrift.cvesearch.CveSearchService) WrappedTException(org.eclipse.sw360.datahandler.common.WrappedException.WrappedTException) TException(org.apache.thrift.TException) JSONFactoryUtil.createJSONObject(com.liferay.portal.kernel.json.JSONFactoryUtil.createJSONObject) JSONObject(com.liferay.portal.kernel.json.JSONObject) VulnerabilityUpdateStatus(org.eclipse.sw360.datahandler.thrift.cvesearch.VulnerabilityUpdateStatus) PrintWriter(java.io.PrintWriter)

Aggregations

VulnerabilityUpdateStatus (org.eclipse.sw360.datahandler.thrift.cvesearch.VulnerabilityUpdateStatus)11 TException (org.apache.thrift.TException)5 CveSearchService (org.eclipse.sw360.datahandler.thrift.cvesearch.CveSearchService)5 JSONObject (com.liferay.portal.kernel.json.JSONObject)4 PrintWriter (java.io.PrintWriter)4 UpdateType (org.eclipse.sw360.datahandler.thrift.cvesearch.UpdateType)4 Test (org.junit.Test)3 CommonUtils (org.eclipse.sw360.datahandler.common.CommonUtils)2 RequestStatus (org.eclipse.sw360.datahandler.thrift.RequestStatus)2 JSONFactoryUtil.createJSONObject (com.liferay.portal.kernel.json.JSONFactoryUtil.createJSONObject)1 IOException (java.io.IOException)1 java.util (java.util)1 Collectors (java.util.stream.Collectors)1 Logger (org.apache.log4j.Logger)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