Search in sources :

Example 1 with SignatureScanStatusType

use of com.synopsys.integration.detect.tool.signaturescanner.enums.SignatureScanStatusType in project synopsys-detect by blackducksoftware.

the class CreateSignatureScanReports method createReport.

public static SignatureScannerReport createReport(SignatureScanPath signatureScanPath, @Nullable ScanCommandOutput scanCommandOutput) {
    SignatureScanStatusType statusType;
    if (scanCommandOutput == null) {
        statusType = SignatureScanStatusType.FAILURE;
    } else if (scanCommandOutput.getScanExitCode().isPresent() && scanCommandOutput.getScanExitCode().get() == 2) {
        statusType = SignatureScanStatusType.SKIPPED;
    } else if (Result.FAILURE.equals(scanCommandOutput.getResult())) {
        statusType = SignatureScanStatusType.FAILURE;
    } else {
        statusType = SignatureScanStatusType.SUCCESS;
    }
    Optional<ScanCommandOutput> optionalOutput = Optional.ofNullable(scanCommandOutput);
    boolean hasOutput = optionalOutput.isPresent();
    Integer exitCode = optionalOutput.map(ScanCommandOutput::getScanExitCode).filter(Optional::isPresent).map(Optional::get).orElse(null);
    Exception exception = optionalOutput.map(ScanCommandOutput::getException).filter(Optional::isPresent).map(Optional::get).orElse(null);
    String errorMessage = optionalOutput.map(ScanCommandOutput::getErrorMessage).filter(Optional::isPresent).map(Optional::get).orElse(null);
    String codeLocationName = optionalOutput.map(CodeLocationOutput::getCodeLocationName).orElse(null);
    Integer notificationCounts = optionalOutput.map(CodeLocationOutput::getExpectedNotificationCount).orElse(null);
    return new SignatureScannerReport(signatureScanPath, statusType, exitCode, exception, errorMessage, hasOutput, codeLocationName, notificationCounts);
}
Also used : Optional(java.util.Optional) SignatureScanStatusType(com.synopsys.integration.detect.tool.signaturescanner.enums.SignatureScanStatusType) ScanCommandOutput(com.synopsys.integration.blackduck.codelocation.signaturescanner.command.ScanCommandOutput) SignatureScannerReport(com.synopsys.integration.detect.tool.signaturescanner.SignatureScannerReport)

Aggregations

ScanCommandOutput (com.synopsys.integration.blackduck.codelocation.signaturescanner.command.ScanCommandOutput)1 SignatureScannerReport (com.synopsys.integration.detect.tool.signaturescanner.SignatureScannerReport)1 SignatureScanStatusType (com.synopsys.integration.detect.tool.signaturescanner.enums.SignatureScanStatusType)1 Optional (java.util.Optional)1