Search in sources :

Example 1 with ImportStatus

use of org.eclipse.sw360.datahandler.thrift.importstatus.ImportStatus in project sw360portal by sw360.

the class ComponentPortlet method updateAllVulnerabilities.

private void updateAllVulnerabilities(ResourceRequest request, ResourceResponse response) throws PortletException, IOException {
    CveSearchService.Iface cveClient = thriftClients.makeCvesearchClient();
    try {
        VulnerabilityUpdateStatus importStatus = cveClient.fullUpdate();
        JSONObject responseData = PortletUtils.importStatusToJSON(importStatus);
        PrintWriter writer = response.getWriter();
        writer.write(responseData.toString());
    } catch (TException e) {
        log.error("Error occurred with full update of CVEs 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 2 with ImportStatus

use of org.eclipse.sw360.datahandler.thrift.importstatus.ImportStatus 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);
    }
}
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 3 with ImportStatus

use of org.eclipse.sw360.datahandler.thrift.importstatus.ImportStatus 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 4 with ImportStatus

use of org.eclipse.sw360.datahandler.thrift.importstatus.ImportStatus in project sw360portal by sw360.

the class ProjectImportPortlet method importBdpProjects.

private void importBdpProjects(User user, List<String> selectedIds, JSONObject responseData, RemoteCredentials remoteCredentials) throws PortletException, IOException {
    ImportStatus importStatus = importDatasources(selectedIds, user, remoteCredentials);
    JSONObject jsonFailedIds = JSONFactoryUtil.createJSONObject();
    JSONArray jsonSuccessfulIds = JSONFactoryUtil.createJSONArray();
    if (importStatus.isSetRequestStatus() && importStatus.getRequestStatus().equals(RequestStatus.SUCCESS)) {
        importStatus.getFailedIds().forEach(jsonFailedIds::put);
        importStatus.getSuccessfulIds().forEach(jsonSuccessfulIds::put);
        responseData.put(ProjectImportConstants.RESPONSE__FAILED_IDS, jsonFailedIds);
        responseData.put(ProjectImportConstants.RESPONSE__SUCCESSFUL_IDS, jsonSuccessfulIds);
    }
    if (isImportSuccessful(importStatus)) {
        responseData.put(ProjectImportConstants.RESPONSE__STATUS, ProjectImportConstants.RESPONSE__SUCCESS);
    } else if (importStatus.isSetRequestStatus() && importStatus.getRequestStatus().equals(RequestStatus.SUCCESS)) {
        responseData.put(ProjectImportConstants.RESPONSE__STATUS, ProjectImportConstants.RESPONSE__FAILURE);
    } else {
        responseData.put(ProjectImportConstants.RESPONSE__STATUS, ProjectImportConstants.RESPONSE__GENERAL_FAILURE);
    }
}
Also used : JSONObject(com.liferay.portal.kernel.json.JSONObject) ImportStatus(org.eclipse.sw360.datahandler.thrift.importstatus.ImportStatus) JSONArray(com.liferay.portal.kernel.json.JSONArray)

Example 5 with ImportStatus

use of org.eclipse.sw360.datahandler.thrift.importstatus.ImportStatus 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

JSONObject (com.liferay.portal.kernel.json.JSONObject)5 PrintWriter (java.io.PrintWriter)4 TException (org.apache.thrift.TException)4 CveSearchService (org.eclipse.sw360.datahandler.thrift.cvesearch.CveSearchService)4 VulnerabilityUpdateStatus (org.eclipse.sw360.datahandler.thrift.cvesearch.VulnerabilityUpdateStatus)4 JSONArray (com.liferay.portal.kernel.json.JSONArray)1 JSONFactoryUtil.createJSONObject (com.liferay.portal.kernel.json.JSONFactoryUtil.createJSONObject)1 WrappedTException (org.eclipse.sw360.datahandler.common.WrappedException.WrappedTException)1 ImportStatus (org.eclipse.sw360.datahandler.thrift.importstatus.ImportStatus)1