Search in sources :

Example 1 with VendorJson

use of com.synopsys.integration.detectable.detectables.go.vendor.model.VendorJson in project synopsys-detect by blackducksoftware.

the class GoVendorJsonParser method parseVendorJson.

public DependencyGraph parseVendorJson(Gson gson, String vendorJsonContents) {
    DependencyGraph graph = new BasicDependencyGraph();
    VendorJson vendorJsonData = gson.fromJson(vendorJsonContents, VendorJson.class);
    logger.trace(String.format("vendorJsonData: %s", vendorJsonData));
    for (PackageData pkg : vendorJsonData.getPackages()) {
        if (StringUtils.isNotBlank(pkg.getPath()) && StringUtils.isNotBlank(pkg.getRevision())) {
            ExternalId dependencyExternalId = externalIdFactory.createNameVersionExternalId(Forge.GOLANG, pkg.getPath(), pkg.getRevision());
            Dependency dependency = new Dependency(pkg.getPath(), pkg.getRevision(), dependencyExternalId);
            logger.trace(String.format("dependency: %s", dependency.getExternalId().toString()));
            graph.addChildToRoot(dependency);
        } else {
            logger.debug(String.format("Omitting package path:'%s', revision:'%s' (one or both of path, revision is/are missing)", pkg.getPath(), pkg.getRevision()));
        }
    }
    return graph;
}
Also used : ExternalId(com.synopsys.integration.bdio.model.externalid.ExternalId) DependencyGraph(com.synopsys.integration.bdio.graph.DependencyGraph) BasicDependencyGraph(com.synopsys.integration.bdio.graph.BasicDependencyGraph) BasicDependencyGraph(com.synopsys.integration.bdio.graph.BasicDependencyGraph) Dependency(com.synopsys.integration.bdio.model.dependency.Dependency) VendorJson(com.synopsys.integration.detectable.detectables.go.vendor.model.VendorJson) PackageData(com.synopsys.integration.detectable.detectables.go.vendor.model.PackageData)

Aggregations

BasicDependencyGraph (com.synopsys.integration.bdio.graph.BasicDependencyGraph)1 DependencyGraph (com.synopsys.integration.bdio.graph.DependencyGraph)1 Dependency (com.synopsys.integration.bdio.model.dependency.Dependency)1 ExternalId (com.synopsys.integration.bdio.model.externalid.ExternalId)1 PackageData (com.synopsys.integration.detectable.detectables.go.vendor.model.PackageData)1 VendorJson (com.synopsys.integration.detectable.detectables.go.vendor.model.VendorJson)1