use of com.synopsys.integration.bdio.BdioReader in project hub-detect by blackducksoftware.
the class DockerExtractor method findCodeLocations.
private Extraction.Builder findCodeLocations(final File directoryToSearch, final File directory, final String imageName) {
final File bdioFile = detectFileFinder.findFile(directoryToSearch, DEPENDENCIES_PATTERN);
if (bdioFile != null) {
SimpleBdioDocument simpleBdioDocument = null;
try (final InputStream dockerOutputInputStream = new FileInputStream(bdioFile);
BdioReader bdioReader = new BdioReader(gson, dockerOutputInputStream)) {
simpleBdioDocument = bdioReader.readSimpleBdioDocument();
} catch (final Exception e) {
return new Extraction.Builder().exception(e);
}
if (simpleBdioDocument != null) {
final DependencyGraph dependencyGraph = bdioTransformer.transformToDependencyGraph(simpleBdioDocument.project, simpleBdioDocument.components);
final String projectName = simpleBdioDocument.project.name;
final String projectVersionName = simpleBdioDocument.project.version;
final Forge dockerForge = new Forge(ExternalId.BDIO_ID_SEPARATOR, ExternalId.BDIO_ID_SEPARATOR, simpleBdioDocument.project.bdioExternalIdentifier.forge);
final String externalIdPath = simpleBdioDocument.project.bdioExternalIdentifier.externalId;
final ExternalId projectExternalId = externalIdFactory.createPathExternalId(dockerForge, externalIdPath);
final DetectCodeLocation detectCodeLocation = new DetectCodeLocation.Builder(DetectCodeLocationType.DOCKER, directory.toString(), projectExternalId, dependencyGraph).dockerImage(imageName).build();
return new Extraction.Builder().success(detectCodeLocation).projectName(projectName).projectVersion(projectVersionName);
}
}
return new Extraction.Builder().failure("No files found matching pattern [" + DEPENDENCIES_PATTERN + "]. Expected docker-inspector to produce file in " + directory.toString());
}
Aggregations