use of com.synopsys.integration.detect.workflow.status.Status in project synopsys-detect by blackducksoftware.
the class DetectableTool method extract.
public DetectableToolResult extract() {
// TODO: Move docker/bazel out of detectable and drop this notion of a detctable tool. Will simplify this logic and make this unneccessary.
DetectableResult extractable;
try {
extractable = detectable.extractable();
} catch (DetectableException e) {
extractable = new ExceptionDetectableResult(e);
}
if (!extractable.getPassed()) {
logger.error(String.format("Was not extractable: %s", extractable.toDescription()));
statusEventPublisher.publishIssue(new DetectIssue(DetectIssueType.DETECTABLE_TOOL, "Detectable Tool Issue", Arrays.asList(extractable.toDescription())));
statusEventPublisher.publishStatusSummary(new Status(name, StatusType.FAILURE));
exitCodePublisher.publishExitCode(ExitCodeType.FAILURE_GENERAL_ERROR, extractable.toDescription());
return DetectableToolResult.failed(extractable);
}
logger.debug("Extractable passed.");
ExtractionEnvironment extractionEnvironment = extractionEnvironmentProvider.createExtractionEnvironment(name);
Extraction extraction;
try {
extraction = detectable.extract(extractionEnvironment);
} catch (ExecutableFailedException | ExecutableRunnerException | JsonSyntaxException | IOException | CycleDetectedException | DetectableException | MissingExternalIdException | ParserConfigurationException | SAXException e) {
extraction = new Extraction.Builder().exception(e).build();
}
if (!extraction.isSuccess()) {
logger.error("Extraction was not success.");
List<String> errorMessages = collectErrorMessages(extraction);
statusEventPublisher.publishIssue(new DetectIssue(DetectIssueType.DETECTABLE_TOOL, "Detectable Tool Issue", errorMessages));
statusEventPublisher.publishStatusSummary(new Status(name, StatusType.FAILURE));
exitCodePublisher.publishExitCode(new ExitCodeRequest(ExitCodeType.FAILURE_GENERAL_ERROR, extraction.getDescription()));
return DetectableToolResult.failed();
} else {
logger.debug("Extraction success.");
statusEventPublisher.publishStatusSummary(new Status(name, StatusType.SUCCESS));
}
Map<CodeLocation, DetectCodeLocation> detectCodeLocationMap = codeLocationConverter.toDetectCodeLocation(sourcePath, extraction, sourcePath, name);
List<DetectCodeLocation> detectCodeLocations = new ArrayList<>(detectCodeLocationMap.values());
DockerTargetData dockerTargetData = DockerTargetData.fromExtraction(extraction);
DetectToolProjectInfo projectInfo = null;
if (StringUtils.isNotBlank(extraction.getProjectName()) || StringUtils.isNotBlank(extraction.getProjectVersion())) {
NameVersion nameVersion = new NameVersion(extraction.getProjectName(), extraction.getProjectVersion());
projectInfo = new DetectToolProjectInfo(detectTool, nameVersion);
}
logger.debug("Tool finished.");
return DetectableToolResult.success(detectCodeLocations, projectInfo, dockerTargetData);
}
use of com.synopsys.integration.detect.workflow.status.Status in project synopsys-detect by blackducksoftware.
the class BinaryUploadOperation method uploadBinaryScanFile.
public CodeLocationCreationData<BinaryScanBatchOutput> uploadBinaryScanFile(File binaryScanFile, BinaryScanUploadService binaryScanUploadService, NameVersion projectNameVersion) throws DetectUserFriendlyException {
String codeLocationName = codeLocationNameManager.createBinaryScanCodeLocationName(binaryScanFile, projectNameVersion.getName(), projectNameVersion.getVersion());
try {
logger.info("Preparing to upload binary scan file: " + binaryScanFile.getAbsolutePath());
BinaryScan binaryScan = new BinaryScan(binaryScanFile, projectNameVersion.getName(), projectNameVersion.getVersion(), codeLocationName);
BinaryScanBatch binaryScanBatch = new BinaryScanBatch(binaryScan);
CodeLocationCreationData<BinaryScanBatchOutput> codeLocationCreationData = binaryScanUploadService.uploadBinaryScan(binaryScanBatch);
BinaryScanBatchOutput binaryScanBatchOutput = codeLocationCreationData.getOutput();
// The throwExceptionForError() in BinaryScanBatchOutput has a bug, so doing that work here
throwExceptionForError(binaryScanBatchOutput);
logger.info("Successfully uploaded binary scan file: " + binaryScanFile.getAbsolutePath());
statusEventPublisher.publishStatusSummary(new Status(STATUS_KEY, StatusType.SUCCESS));
return codeLocationCreationData;
} catch (IntegrationException e) {
statusEventPublisher.publishStatusSummary(new Status(STATUS_KEY, StatusType.FAILURE));
throw new DetectUserFriendlyException("Failed to upload binary scan file.", e, ExitCodeType.FAILURE_BLACKDUCK_CONNECTIVITY);
}
}
Aggregations