use of com.blackducksoftware.integration.hub.detect.workflow.status.DetectorStatus in project hub-detect by blackducksoftware.
the class DetectorManager method runDetectors.
public DetectorToolResult runDetectors() throws DetectUserFriendlyException {
List<DetectorEvaluation> detectorEvaluations = new ArrayList<>();
// search
SearchResult searchResult = searchManager.performSearch();
eventSystem.publishEvent(Event.SearchCompleted, searchResult);
detectorEvaluations.addAll(searchResult.getDetectorEvaluations());
// prepare
PreparationResult preparationResult = preparationManager.prepareExtractions(detectorEvaluations);
eventSystem.publishEvent(Event.PreparationsCompleted, preparationResult);
// extract
ExtractionResult extractionResult = extractionManager.performExtractions(detectorEvaluations);
eventSystem.publishEvent(Event.ExtractionsCompleted, extractionResult);
// create results
DetectorToolResult detectorToolResult = new DetectorToolResult();
detectorToolResult.evaluatedDetectors = detectorEvaluations;
detectorToolResult.bomToolCodeLocations = extractionResult.getDetectCodeLocations();
detectorToolResult.applicableDetectorTypes = searchResult.getApplicableBomTools();
detectorToolResult.failedDetectorTypes.addAll(preparationResult.getFailedBomToolTypes());
detectorToolResult.failedDetectorTypes.addAll(extractionResult.getFailedBomToolTypes());
detectorToolResult.succesfullDetectorTypes.addAll(preparationResult.getSuccessfulBomToolTypes());
detectorToolResult.succesfullDetectorTypes.addAll(extractionResult.getSuccessfulBomToolTypes());
detectorToolResult.succesfullDetectorTypes.removeIf(it -> detectorToolResult.failedDetectorTypes.contains(it));
// post status
Map<DetectorType, StatusType> detectorStatus = new HashMap<>();
detectorToolResult.succesfullDetectorTypes.forEach(it -> detectorStatus.put(it, StatusType.SUCCESS));
detectorToolResult.failedDetectorTypes.forEach(it -> detectorStatus.put(it, StatusType.FAILURE));
detectorStatus.forEach((detector, status) -> eventSystem.publishEvent(Event.StatusSummary, new DetectorStatus(detector, status)));
return detectorToolResult;
}
use of com.blackducksoftware.integration.hub.detect.workflow.status.DetectorStatus in project hub-detect by blackducksoftware.
the class BdioManager method createBdioFiles.
public BdioResult createBdioFiles(String aggregateName, NameVersion projectNameVersion, List<DetectCodeLocation> codeLocations) throws DetectUserFriendlyException {
DetectBdioWriter detectBdioWriter = new DetectBdioWriter(simpleBdioFactory, detectInfo);
if (StringUtils.isBlank(aggregateName)) {
logger.info("Creating BDIO code locations.");
final BdioCodeLocationResult codeLocationResult = bdioCodeLocationCreator.createFromDetectCodeLocations(codeLocations, projectNameVersion);
codeLocationResult.getFailedBomToolGroupTypes().forEach(it -> eventSystem.publishEvent(Event.StatusSummary, new DetectorStatus(it, StatusType.FAILURE)));
logger.info("Creating BDIO files from code locations.");
CodeLocationBdioCreator codeLocationBdioCreator = new CodeLocationBdioCreator(detectBdioWriter, simpleBdioFactory);
final List<UploadTarget> uploadTargets = codeLocationBdioCreator.createBdioFiles(directoryManager.getBdioOutputDirectory(), codeLocationResult.getBdioCodeLocations(), projectNameVersion);
return new BdioResult(uploadTargets);
} else {
logger.info("Creating aggregate BDIO file.");
AggregateBdioCreator aggregateBdioCreator = new AggregateBdioCreator(simpleBdioFactory, integrationEscapeUtil, codeLocationNameManager, detectConfiguration, detectBdioWriter);
final Optional<UploadTarget> uploadTarget = aggregateBdioCreator.createAggregateBdioFile(directoryManager.getSourceDirectory(), directoryManager.getBdioOutputDirectory(), codeLocations, projectNameVersion);
if (uploadTarget.isPresent()) {
return new BdioResult(Arrays.asList(uploadTarget.get()));
} else {
return new BdioResult(Collections.emptyList());
}
}
}
Aggregations