use of com.blackducksoftware.integration.hub.bdio.model.SimpleBdioDocument in project hub-docker-inspector by blackducksoftware.
the class RestClientInspector method getSimpleBdioDocument.
private SimpleBdioDocument getSimpleBdioDocument(final String bdioString) throws IOException {
final InputStream bdioInputStream = new ByteArrayInputStream(bdioString.getBytes());
SimpleBdioDocument simpleBdioDocument = null;
try (BdioReader bdioReader = new BdioReader(new Gson(), bdioInputStream)) {
simpleBdioDocument = bdioReader.readSimpleBdioDocument();
}
return simpleBdioDocument;
}
use of com.blackducksoftware.integration.hub.bdio.model.SimpleBdioDocument in project hub-detect by blackducksoftware.
the class DetectProjectManager method createBdioFiles.
public List<File> createBdioFiles(final DetectProject detectProject) throws DetectUserFriendlyException {
final List<File> bdioFiles = new ArrayList<>();
final MutableDependencyGraph aggregateDependencyGraph = simpleBdioFactory.createMutableDependencyGraph();
if (StringUtils.isBlank(detectConfiguration.getAggregateBomName())) {
for (final String codeLocationNameString : detectProject.getCodeLocationNameStrings()) {
final DetectCodeLocation detectCodeLocation = detectProject.getDetectCodeLocation(codeLocationNameString);
final String bdioFileName = detectProject.getBdioFilename(codeLocationNameString);
final SimpleBdioDocument simpleBdioDocument = createSimpleBdioDocument(codeLocationNameString, detectProject.getProjectName(), detectProject.getProjectVersionName(), detectCodeLocation);
final File outputFile = new File(detectConfiguration.getBdioOutputDirectoryPath(), bdioFileName);
if (outputFile.exists()) {
final boolean deleteSuccess = outputFile.delete();
logger.debug(String.format("%s deleted: %b", outputFile.getAbsolutePath(), deleteSuccess));
}
writeBdioFile(outputFile, simpleBdioDocument);
bdioFiles.add(outputFile);
}
} else {
for (final DetectCodeLocation detectCodeLocation : detectProject.getDetectCodeLocations()) {
if (detectCodeLocation.getDependencyGraph() == null) {
logger.warn(String.format("Dependency graph is null for code location %s", detectCodeLocation.getSourcePath()));
continue;
}
if (detectCodeLocation.getDependencyGraph().getRootDependencies().size() <= 0) {
logger.warn(String.format("Could not find any dependencies for code location %s", detectCodeLocation.getSourcePath()));
}
aggregateDependencyGraph.addGraphAsChildrenToRoot(detectCodeLocation.getDependencyGraph());
}
final SimpleBdioDocument aggregateBdioDocument = createAggregateSimpleBdioDocument(detectProject.getProjectName(), detectProject.getProjectVersionName(), aggregateDependencyGraph);
final String filename = String.format("%s.jsonld", integrationEscapeUtil.escapeForUri(detectConfiguration.getAggregateBomName()));
final File aggregateBdioFile = new File(detectConfiguration.getOutputDirectory(), filename);
if (aggregateBdioFile.exists()) {
final boolean deleteSuccess = aggregateBdioFile.delete();
logger.debug(String.format("%s deleted: %b", aggregateBdioFile.getAbsolutePath(), deleteSuccess));
}
writeBdioFile(aggregateBdioFile, aggregateBdioDocument);
}
return bdioFiles;
}
use of com.blackducksoftware.integration.hub.bdio.model.SimpleBdioDocument in project hub-detect by blackducksoftware.
the class DetectProjectManager method createSimpleBdioDocument.
private SimpleBdioDocument createSimpleBdioDocument(final String codeLocationName, final String projectName, final String projectVersionName, final ExternalId projectExternalId, final DependencyGraph dependencyGraph) {
final SimpleBdioDocument simpleBdioDocument = simpleBdioFactory.createSimpleBdioDocument(codeLocationName, projectName, projectVersionName, projectExternalId, dependencyGraph);
final String hubDetectVersion = detectInfo.getDetectVersion();
final ToolSpdxCreator hubDetectCreator = new ToolSpdxCreator("HubDetect", hubDetectVersion);
simpleBdioDocument.billOfMaterials.creationInfo.addSpdxCreator(hubDetectCreator);
return simpleBdioDocument;
}
use of com.blackducksoftware.integration.hub.bdio.model.SimpleBdioDocument in project hub-docker-inspector by blackducksoftware.
the class RestClientInspector method deriveOutputBdioFilename.
private String deriveOutputBdioFilename(final String bdioString) throws IOException, IntegrationException {
final SimpleBdioDocument bdioDocument = getSimpleBdioDocument(bdioString);
final BdioFilename outputFilename = new BdioFilename(bdioDocument.billOfMaterials.spdxName, bdioDocument.project.name, bdioDocument.project.version, bdioDocument.project.bdioExternalIdentifier.externalIdMetaData.forge.getName());
return outputFilename.getBdioFilename();
}
Aggregations