diff --git a/facade/src/main/java/org/jboss/pnc/facade/deliverables/DeliverableAnalyzerManagerImpl.java b/facade/src/main/java/org/jboss/pnc/facade/deliverables/DeliverableAnalyzerManagerImpl.java
index 7fb6a7770e..cae8da07ce 100644
--- a/facade/src/main/java/org/jboss/pnc/facade/deliverables/DeliverableAnalyzerManagerImpl.java
+++ b/facade/src/main/java/org/jboss/pnc/facade/deliverables/DeliverableAnalyzerManagerImpl.java
@@ -20,7 +20,6 @@
import com.github.packageurl.MalformedPackageURLException;
import com.github.packageurl.PackageURL;
import com.github.packageurl.PackageURLBuilder;
-import lombok.Value;
import lombok.extern.slf4j.Slf4j;
import org.jboss.pnc.api.deliverablesanalyzer.dto.Artifact;
import org.jboss.pnc.api.deliverablesanalyzer.dto.ArtifactType;
@@ -29,6 +28,7 @@
import org.jboss.pnc.api.deliverablesanalyzer.dto.FinderResult;
import org.jboss.pnc.api.deliverablesanalyzer.dto.LicenseInfo;
import org.jboss.pnc.api.deliverablesanalyzer.dto.MavenArtifact;
+import org.jboss.pnc.api.deliverablesanalyzer.dto.WindowsArtifact;
import org.jboss.pnc.api.dto.Request;
import org.jboss.pnc.api.enums.DeliverableAnalyzerReportLabel;
import org.jboss.pnc.api.enums.LabelOperation;
@@ -48,7 +48,6 @@
import org.jboss.pnc.enums.RepositoryType;
import org.jboss.pnc.facade.OperationsManager;
import org.jboss.pnc.facade.deliverables.api.AnalysisResult;
-import org.jboss.pnc.facade.util.UserService;
import org.jboss.pnc.mapper.api.ArtifactMapper;
import org.jboss.pnc.mapper.api.DeliverableAnalyzerOperationMapper;
import org.jboss.pnc.model.Base32LongID;
@@ -95,6 +94,7 @@
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
+import java.util.Locale;
import java.util.Map;
import java.util.Objects;
import java.util.Optional;
@@ -543,9 +543,8 @@ private org.jboss.pnc.model.Artifact findOrCreateNotFoundArtifact(
private org.jboss.pnc.model.Artifact createArtifact(
org.jboss.pnc.model.Artifact artifact,
TargetRepository targetRepo) {
-
artifact.setTargetRepository(targetRepo);
- artifact.setPurl(createGenericPurl(artifact.getFilename().toString(), artifact.getSha256()));
+ artifact.setPurl(createGenericPurl(artifact.getFilename(), artifact.getSha256()));
org.jboss.pnc.model.Artifact savedArtifact = artifactRepository.save(artifact);
targetRepo.getArtifacts().add(savedArtifact);
return savedArtifact;
@@ -567,17 +566,12 @@ private org.jboss.pnc.model.Artifact mapBrewArtifact(
String nvr,
TargetRepository targetRepository,
User user) {
- if (artifact.getArtifactType() != ArtifactType.MAVEN) {
- throw new UnsupportedOperationException("Brew artifact " + artifact + " is not Maven!");
- }
- MavenArtifact mavenArtifact = (MavenArtifact) artifact;
-
- org.jboss.pnc.model.Artifact.Builder builder = mapArtifact(mavenArtifact, user);
- builder.identifier(createIdentifier(mavenArtifact));
- builder.filename(createFileName(mavenArtifact));
- builder.deployPath(createDeployPath(mavenArtifact));
- builder.originUrl(createBrewOriginURL(mavenArtifact, nvr));
- builder.purl(createPURL(mavenArtifact));
+ org.jboss.pnc.model.Artifact.Builder builder = mapArtifact(artifact, user);
+ builder.identifier(createIdentifier(artifact));
+ builder.filename(createFileName(artifact));
+ builder.deployPath(createDeployPath(artifact));
+ builder.originUrl(createBrewOriginURL(artifact, nvr));
+ builder.purl(createPURL(artifact));
builder.targetRepository(targetRepository);
return builder.build();
@@ -603,25 +597,45 @@ private org.jboss.pnc.model.Artifact.Builder mapArtifact(Artifact artifact, User
return builder;
}
- private static String createDeployPath(MavenArtifact mavenArt) {
- String filename = createFileName(mavenArt);
- String deployPath = "/" + mavenArt.getGroupId().replace('.', '/') + "/" + mavenArt.getArtifactId() + "/"
- + mavenArt.getVersion() + "/" + filename;
+ private static String createDeployPath(Artifact artifact) {
+ String filename = createFileName(artifact);
+ String deployPath;
+
+ if (artifact instanceof MavenArtifact) {
+ MavenArtifact mavenArtifact = (MavenArtifact) artifact;
+ deployPath = "/" + mavenArtifact.getGroupId().replace('.', '/') + "/" + mavenArtifact.getArtifactId() + "/"
+ + mavenArtifact.getVersion() + "/" + filename;
+ } else if (artifact instanceof WindowsArtifact) {
+ deployPath = "/" + filename;
+ } else {
+ throw new IllegalArgumentException("Unsupported artifact type: " + artifact.getArtifactType());
+ }
+
return deployPath;
}
- private static String createFileName(MavenArtifact mavenArt) {
- String filename = mavenArt.getArtifactId() + "-" + mavenArt.getVersion();
- if (!Strings.isEmpty(mavenArt.getClassifier())) {
- filename += "-" + mavenArt.getClassifier();
+ private static String createFileName(Artifact artifact) {
+ String filename;
+
+ if (artifact instanceof MavenArtifact) {
+ MavenArtifact mavenArtifact = (MavenArtifact) artifact;
+ filename = mavenArtifact.getArtifactId() + "-" + mavenArtifact.getVersion();
+ if (!Strings.isEmpty(mavenArtifact.getClassifier())) {
+ filename += "-" + mavenArtifact.getClassifier();
+ }
+ filename += "." + mavenArtifact.getType();
+ } else if (artifact instanceof WindowsArtifact) {
+ WindowsArtifact windowsArtifact = (WindowsArtifact) artifact;
+ filename = windowsArtifact.getFilename();
+ } else {
+ throw new IllegalArgumentException("Unsupported artifact type: " + artifact.getArtifactType());
}
- filename += "." + mavenArt.getType();
+
return filename;
}
- private String createBrewOriginURL(MavenArtifact mavenArt, String nvr) {
+ private String createBrewOriginURL(Artifact artifact, String nvr) {
String brewContentUrl = globalConfig.getBrewContentUrl();
-
Matcher matcher = NVR_PATTERN.matcher(nvr);
if (!matcher.matches()) {
throw new IllegalArgumentException("NVR " + nvr + " does not match expected format.");
@@ -629,23 +643,36 @@ private String createBrewOriginURL(MavenArtifact mavenArt, String nvr) {
String name = matcher.group(1);
String version = matcher.group(2);
String release = matcher.group(3);
-
- return brewContentUrl + "/" + name + "/" + version + "/" + release + "/maven" + createDeployPath(mavenArt);
+ return brewContentUrl + "/" + name + "/" + version + "/" + release + "/"
+ + artifact.getArtifactType().name().toLowerCase(Locale.ENGLISH) + createDeployPath(artifact);
}
- private String createPURL(MavenArtifact mavenArtifact) {
+ private String createPURL(Artifact artifact) {
try {
- PackageURLBuilder purlBuilder = PackageURLBuilder.aPackageURL()
- .withType(PackageURL.StandardTypes.MAVEN)
- .withNamespace(mavenArtifact.getGroupId())
- .withName(mavenArtifact.getArtifactId())
- .withVersion(mavenArtifact.getVersion())
- .withQualifier(
- "type",
- StringUtils.isEmpty(mavenArtifact.getType()) ? "jar" : mavenArtifact.getType());
-
- if (!StringUtils.isEmpty(mavenArtifact.getClassifier())) {
- purlBuilder.withQualifier("classifier", mavenArtifact.getClassifier());
+ PackageURLBuilder purlBuilder;
+ if (artifact instanceof MavenArtifact) {
+ MavenArtifact mavenArtifact = (MavenArtifact) artifact;
+ purlBuilder = PackageURLBuilder.aPackageURL()
+ .withType(PackageURL.StandardTypes.MAVEN)
+ .withNamespace(mavenArtifact.getGroupId())
+ .withName(mavenArtifact.getArtifactId())
+ .withVersion(mavenArtifact.getVersion())
+ .withQualifier(
+ "type",
+ StringUtils.isEmpty(mavenArtifact.getType()) ? "jar" : mavenArtifact.getType());
+
+ if (!StringUtils.isEmpty(mavenArtifact.getClassifier())) {
+ purlBuilder.withQualifier("classifier", mavenArtifact.getClassifier());
+ }
+
+ } else if (artifact instanceof WindowsArtifact) {
+ WindowsArtifact windowsArtifact = (WindowsArtifact) artifact;
+ purlBuilder = PackageURLBuilder.aPackageURL()
+ .withType(PackageURL.StandardTypes.GENERIC)
+ .withName(windowsArtifact.getName())
+ .withVersion(windowsArtifact.getVersion());
+ } else {
+ throw new IllegalArgumentException("Unsupported artifact type: " + artifact.getArtifactType());
}
return purlBuilder.build().toString();
} catch (MalformedPackageURLException e) {
@@ -673,17 +700,25 @@ private String createGenericPurl(String filename, String sha256) {
}
}
- private String createIdentifier(MavenArtifact mavenArtifact) {
- return Arrays
- .asList(
- mavenArtifact.getGroupId(),
- mavenArtifact.getArtifactId(),
- mavenArtifact.getType(),
- mavenArtifact.getVersion(),
- mavenArtifact.getClassifier())
- .stream()
- .filter(Objects::nonNull)
- .collect(Collectors.joining(":"));
+ private String createIdentifier(Artifact artifact) {
+ if (artifact instanceof MavenArtifact) {
+ MavenArtifact mavenArtifact = (MavenArtifact) artifact;
+ return Arrays
+ .asList(
+ mavenArtifact.getGroupId(),
+ mavenArtifact.getArtifactId(),
+ mavenArtifact.getType(),
+ mavenArtifact.getVersion(),
+ mavenArtifact.getClassifier())
+ .stream()
+ .filter(Objects::nonNull)
+ .collect(Collectors.joining(":"));
+ } else if (artifact instanceof WindowsArtifact) {
+ WindowsArtifact windowsArtifact = (WindowsArtifact) artifact;
+ return String.join("-", windowsArtifact.getName(), windowsArtifact.getVersion());
+ } else {
+ throw new IllegalArgumentException("Unsupported artifact type: " + artifact.getArtifactType());
+ }
}
private TargetRepository getDistributionRepository(String distURL) {
diff --git a/pom.xml b/pom.xml
index e2d89e98e0..e6b9eae71c 100644
--- a/pom.xml
+++ b/pom.xml
@@ -108,7 +108,7 @@
1.18.22
1.5.3.Final
1.1.3
- 3.0.5
+ 3.0.6-SNAPSHOT
3.0.1
1.0.1
3.0.0
@@ -1671,6 +1671,7 @@
2.12.2
../eclipse-codeStyle.xml
+ LF