Search in sources :

Example 31 with PermanentException

use of com.hp.octane.integrations.exceptions.PermanentException in project octane-ci-java-sdk by MicroFocus.

the class VulnerabilitiesServiceImpl method processPushVulnerabilitiesQueueItem.

private boolean processPushVulnerabilitiesQueueItem(VulnerabilitiesQueueItem queueItem) {
    try {
        // if this is the first time in the queue , check if vulnerabilities relevant to octane, and if not remove it from the queue.
        if (!queueItem.isRelevant()) {
            Date relevant = vulnerabilitiesPreflightRequest(queueItem.getJobId(), queueItem.getBuildId());
            if (relevant != null) {
                logger.debug(configurer.octaneConfiguration.getLocationForLog() + queueItem.toString() + " , Relevant:" + relevant);
                // set queue item value relevancy to true and continue
                queueItem.setRelevant(true);
                // for backward compatibility with Octane - if baselineDate is 2000-01-01 it means that we didn't get it from octane and we need to discard it
                if (relevant.compareTo(DateUtils.getDateFromUTCString("2000-01-01", "yyyy-MM-dd")) > 0) {
                    queueItem.setBaselineDate(relevant);
                }
            } else {
                // return with true to silently proceed to the next item
                return true;
            }
        }
        InputStream vulnerabilitiesStream = null;
        if (queueItem.getToolType().equals(ToolType.SONAR)) {
            vulnerabilitiesStream = sonarVulnerabilitiesService.getVulnerabilitiesScanResultStream(queueItem);
        } else if (queueItem.getToolType().equals(ToolType.SSC)) {
            logger.debug(configurer.octaneConfiguration.getLocationForLog() + "SSC flow as expected");
            vulnerabilitiesStream = sscService.getVulnerabilitiesScanResultStream(queueItem);
        } else if (queueItem.getToolType().equals(ToolType.FOD)) {
            logger.debug(configurer.octaneConfiguration.getLocationForLog() + "Handling FOD queueItem");
            vulnerabilitiesStream = fodService.getVulnerabilitiesScanResultStream(queueItem);
        }
        if (vulnerabilitiesStream == null) {
            return false;
        } else {
            pushVulnerabilities(vulnerabilitiesStream, queueItem.getJobId(), queueItem.getBuildId());
            return true;
        }
    } catch (IOException e) {
        throw new PermanentException(e);
    }
}
Also used : InputStream(java.io.InputStream) PermanentException(com.hp.octane.integrations.exceptions.PermanentException) IOException(java.io.IOException) Date(java.util.Date)

Aggregations

PermanentException (com.hp.octane.integrations.exceptions.PermanentException)31 TemporaryException (com.hp.octane.integrations.exceptions.TemporaryException)19 IOException (java.io.IOException)15 OctaneResponse (com.hp.octane.integrations.dto.connectivity.OctaneResponse)10 OctaneRequest (com.hp.octane.integrations.dto.connectivity.OctaneRequest)8 InputStream (java.io.InputStream)6 URISyntaxException (java.net.URISyntaxException)6 URIBuilder (org.apache.http.client.utils.URIBuilder)6 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)5 RequestTimeoutException (com.hp.octane.integrations.exceptions.RequestTimeoutException)5 HashMap (java.util.HashMap)5 CloseableHttpResponse (org.apache.http.client.methods.CloseableHttpResponse)5 InterruptedIOException (java.io.InterruptedIOException)4 HttpGet (org.apache.http.client.methods.HttpGet)4 OctaneRestClient (com.hp.octane.integrations.services.rest.OctaneRestClient)3 LinkedHashMap (java.util.LinkedHashMap)3 JsonNode (com.fasterxml.jackson.databind.JsonNode)2 OctaneSDKGeneralException (com.hp.octane.integrations.exceptions.OctaneSDKGeneralException)2 List (java.util.List)2 HttpEntity (org.apache.http.HttpEntity)2