public String getVersion() { return gav.getVersion(); } }
public String getVersion() { return gav.getVersion(); }
public static String getName(GAV gav) { return String.format("%s-%s-%s", gav.getArtifactId(), gav.getVersion(), UUID.randomUUID() .toString().substring(0, 5)); }
private static Set<ProductArtifact> mapProducts(Set<ProductArtifacts> products, GAV gav, VersionParser versionParser) { VersionComparator comparator = new VersionComparator(versionParser); return products.stream() .flatMap(e -> e.getArtifacts().stream() .map(x -> toProductArtifact(e.getProduct(), x, gav.getVersion(), comparator))) .collect(Collectors.toCollection(() -> new TreeSet<>(Comparator.comparing(ProductArtifact::getArtifact)))); }
private CompletableFuture<VersionAnalysisResult> analyzeVersions(VersionParser versionParser, String version, CompletableFuture<Set<ProductArtifacts>> availableArtifacts) { VersionAnalyzer va = new VersionAnalyzer(versionParser); return availableArtifacts.thenApply(pas-> { List<String> versions = pas.stream() .flatMap(as -> as.getArtifacts().stream()) .map(a -> a.getGav().getVersion()) .collect(Collectors.toList()); return va.analyseVersions(version, versions); }); }
private static Set<ProductArtifacts> getBuilt(Set<ProductArtifacts> a, VersionAnalysisResult v) { return v.getBestMatchVersion().map(b -> AggregatedProductProvider .filterArtifacts(a, x -> b.equals(x.getGav().getVersion()))) .orElse(Collections.emptySet()); }
@Override public Optional<InputStream> getPomStream(GAV gav) throws RepositoryException { StringBuilder query = new StringBuilder(); try { query.append(config.getAproxServer()); query.append("/api/group/"); query.append(config.getAproxGroupPublic()).append('/'); query.append(gav.getGroupId().replace(".", "/")).append("/"); query.append(gav.getArtifactId()).append('/'); query.append(gav.getVersion()).append('/'); query.append(gav.getArtifactId()).append('-').append(gav.getVersion()).append(".pom"); URLConnection connection = new URL(query.toString()).openConnection(); return Optional.of(connection.getInputStream()); } catch (FileNotFoundException ex) { return Optional.empty(); } catch (IOException e) { throw new RepositoryException("Failed to obtain pom for " + gav + " from repository on url " + query, e); } }
@Override public CompletableFuture<Map<Product, Set<String>>> getVersions(GA ga) { return CompletableFuture.supplyAsync(() -> getArtifacts(ga.getGroupId(), ga.getArtifactId(), Optional.empty()).stream() .collect(Collectors.toMap(ProductArtifacts::getProduct, x -> x.getArtifacts().stream() .map(y -> y.getGav().getVersion()) .collect(Collectors.toSet())))); }
public BuiltReportModule(GAV gav) { this.groupId = gav.getGroupId(); this.artifactId = gav.getArtifactId(); this.version = gav.getVersion(); }
public Report(GAV gav, List<String> availableVersions, String bestMatchVersion, boolean dependencyVersionsSatisfied, List<Report> dependencies, boolean blacklisted, List<RestProductInput> whitelisted, int notBuiltDependencies) { this(gav.getGroupId(), gav.getArtifactId(), gav.getVersion(), availableVersions, bestMatchVersion, dependencyVersionsSatisfied, dependencies, blacklisted, whitelisted, notBuiltDependencies); }
public GAVAvailableVersions(GAV gav, Set<String> availableVersions) { this(gav.getGroupId(), gav.getArtifactId(), gav.getVersion(), availableVersions); } }
@Override public String toString() { return getGroupId() + ":" + getArtifactId() + ":" + getVersion(); }
public GAVBestMatchVersion(GAV gav, String bestMatchVersion) { this(gav.getGroupId(), gav.getArtifactId(), gav.getVersion(), bestMatchVersion); }
public RestGavProducts(GAV gav, Set<RestProductInput> products) { this(gav.getGroupId(), gav.getArtifactId(), gav.getVersion(), products); }
@Override public List<WhiteArtifact> getArtifacts(GAV gav) { return getArtifacts(gav.getGroupId(), gav.getArtifactId(), gav.getVersion()); }
@Override public Optional<BlackArtifact> getArtifact(GAV gav) { return getArtifact(gav.getGroupId(), gav.getArtifactId(), gav.getVersion()); }
@Override public boolean isArtifactPresent(GAV gav) { return isArtifactPresent(gav.getGroupId(), gav.getArtifactId(), gav.getVersion()); }
@Override public Set<BuiltReportModule> getBuiltReport(SCMLocator scml) throws ScmException, PomAnalysisException, CommunicationException { VersionParser versionParser = new VersionParser(VersionParser.DEFAULT_SUFFIX); Map<GA, Set<GAV>> dependenciesOfModules = scmConnector.getDependenciesOfModules( scml.getScmUrl(), scml.getRevision(), scml.getPomPath(), scml.getRepositories()); Set<CompletableFuture<BuiltReportModule>> builtSet = new HashSet<>(); for (Map.Entry<GA, Set<GAV>> e : dependenciesOfModules.entrySet()) { for (GAV gav : e.getValue()) { CompletableFuture<Set<ProductArtifacts>> artifacts = productProvider.getArtifacts(gav.getGA()); artifacts = filterBuiltArtifacts(artifacts); builtSet.add(analyzeVersions(versionParser, gav.getVersion(), artifacts) .thenApply(v -> toBuiltReportModule(gav, v))); } } return joinFutures(builtSet); }
private CompletableFuture<Void> fillArtifactReport(ArtifactReport report, Set<Product> products) { GAV gav = report.getGav(); CompletableFuture<Set<ProductArtifacts>> artifacts = productProvider.getArtifacts(gav .getGA()); artifacts = filterProductArtifacts(products, artifacts); report.setBlacklisted(blackArtifactService.isArtifactPresent(gav)); VersionParser parser = new VersionParser(VersionParser.DEFAULT_SUFFIX); CompletableFuture<Void> fillVersions = analyzeVersions(parser, gav.getVersion(), artifacts) .thenAccept(v -> { report.setAvailableVersions(v.getAvailableVersions()); report.setBestMatchVersion(v.getBestMatchVersion()); }); CompletableFuture<Void> fillWhitelist = artifacts.thenAccept(pas -> { List<Product> whiteProducts = pas.stream() .map(pa -> pa.getProduct()) .filter(p -> !UNKNOWN.equals(p)) .collect(Collectors.toList()); report.setWhitelisted(whiteProducts); }); return CompletableFuture.allOf(fillVersions, fillWhitelist); }
private static ProductArtifact toProductArtifact(Product p, Artifact a, String origVersion, VersionComparator comparator) { ProductArtifact ret = new ProductArtifact(); ret.setArtifact(a.getGav()); ret.setProductName(p.getName()); ret.setProductVersion(p.getVersion()); ret.setSupportStatus(p.getStatus()); ret.setDifferenceType(comparator.difference(origVersion, a.getGav().getVersion()) .toString()); return ret; }