@Override public List<WhiteArtifact> getArtifacts(String groupId, String artifactId, String version) { // Black listed artifacts can't be queried if (blackArtifactService.isArtifactPresent(groupId, artifactId, version)) { return new ArrayList<>(); } String osgi = VersionParser.getOSGiVersion(version); List<WhiteArtifact> whites = new ArrayList<>(); Optional<WhiteArtifact> origArtifact = whiteArtifactDAO.findArtifact(groupId, artifactId, version); Optional<WhiteArtifact> normArtifact = whiteArtifactDAO.findArtifact(groupId, artifactId, osgi); origArtifact.ifPresent(x -> whites.add(x)); if (!normArtifact.equals(origArtifact)) { normArtifact.ifPresent(x -> whites.add(x)); } List<WhiteArtifact> nonDupWhites = new ArrayList<>(new LinkedHashSet<>(whites)); return nonDupWhites; }
@Override public org.jboss.da.listings.api.service.ArtifactService.ArtifactStatus addArtifact( String groupId, String artifactId, String version) { String osgiVersion = VersionParser.getOSGiVersion(version); GA ga = gaDAO.findOrCreate(groupId, artifactId); BlackArtifact artifact = new BlackArtifact(ga, osgiVersion, currentUser()); if (blackArtifactDAO.findArtifact(groupId, artifactId, osgiVersion).isPresent()) { return ArtifactStatus.NOT_MODIFIED; } Set<WhiteArtifact> whites = new HashSet<>(); Optional<WhiteArtifact> rhA = whiteArtifactDAO.findArtifact(groupId, artifactId, osgiVersion); rhA.ifPresent(x -> whites.add(rhA.get())); Optional<WhiteArtifact> a = whiteArtifactDAO.findArtifact(groupId, artifactId, version); a.ifPresent(x -> whites.add(a.get())); ArtifactStatus status = ArtifactStatus.ADDED; if(!whites.isEmpty()){ status = ArtifactStatus.WAS_WHITELISTED; } blackArtifactDAO.create(artifact); return status; }
private WhiteArtifact createArtifact(String groupId, String artifactId, String version) { SuffixedVersion parsedVersion = versionParser.parse(version); final boolean is3rdParty = !parsedVersion.isSuffixed(); final String osgiVersion = VersionParser.getOSGiVersion(version); GA ga = gaDAO.findOrCreate(groupId, artifactId); WhiteArtifact a = new WhiteArtifact(ga, version, currentUser(), osgiVersion, is3rdParty); whiteArtifactDAO.create(a); return a; }