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);
}
Aggregations