added pom URL as part of patch for issue #196 and improved the URL provided for the jar file itself

Former-commit-id: 8f485f53031a7e244d4a8f8d0c055e6b38fca746
This commit is contained in:
Jeremy Long
2015-02-18 20:09:42 -05:00
parent 40beec2e40
commit a28c2819fa

View File

@@ -24,6 +24,11 @@ package org.owasp.dependencycheck.data.nexus;
*/ */
public class MavenArtifact { public class MavenArtifact {
/**
* The base URL for download artifacts from Central.
*/
private final String CENTRAL_CONTENT_URL = "http://search.maven.org/remotecontent?filepath=";
/** /**
* The groupId * The groupId
*/ */
@@ -43,6 +48,10 @@ public class MavenArtifact {
* The artifact url. This may change depending on which Nexus server the search took place. * The artifact url. This may change depending on which Nexus server the search took place.
*/ */
private String artifactUrl; private String artifactUrl;
/**
* The url to download the POM from.
*/
private String pomUrl;
/** /**
* Creates an empty MavenArtifact. * Creates an empty MavenArtifact.
@@ -58,9 +67,32 @@ public class MavenArtifact {
* @param version the version * @param version the version
*/ */
public MavenArtifact(String groupId, String artifactId, String version) { public MavenArtifact(String groupId, String artifactId, String version) {
setGroupId(groupId); this.groupId = groupId;
setArtifactId(artifactId); this.artifactId = artifactId;
setVersion(version); this.version = version;
}
/**
* Creates a MavenArtifact with the given attributes.
*
* @param groupId the groupId
* @param artifactId the artifactId
* @param version the version
* @param jarAvailable if the jar file is available from central
* @param pomAvailable if the pom file is available from central
*/
public MavenArtifact(String groupId, String artifactId, String version, boolean jarAvailable, boolean pomAvailable) {
this.groupId = groupId;
this.artifactId = artifactId;
this.version = version;
if (jarAvailable) {
//org/springframework/spring-core/3.2.0.RELEASE/spring-core-3.2.0.RELEASE.pom
this.artifactUrl = this.CENTRAL_CONTENT_URL + groupId.replace('.', '/') + "/" + artifactId.replace('.', '/') + "/" + version + "/" + artifactId + "-" + version + ".jar";
}
if (pomAvailable) {
//org/springframework/spring-core/3.2.0.RELEASE/spring-core-3.2.0.RELEASE.pom
this.pomUrl = this.CENTRAL_CONTENT_URL + groupId.replace('.', '/') + "/" + artifactId.replace('.', '/') + "/" + version + "/" + artifactId + "-" + version + ".pom";
}
} }
/** /**
@@ -72,10 +104,10 @@ public class MavenArtifact {
* @param url the artifactLink url * @param url the artifactLink url
*/ */
public MavenArtifact(String groupId, String artifactId, String version, String url) { public MavenArtifact(String groupId, String artifactId, String version, String url) {
setGroupId(groupId); this.groupId = groupId;
setArtifactId(artifactId); this.artifactId = artifactId;
setVersion(version); this.version = version;
setArtifactUrl(url); this.artifactUrl = url;
} }
/** /**
@@ -159,6 +191,25 @@ public class MavenArtifact {
public String getArtifactUrl() { public String getArtifactUrl() {
return artifactUrl; return artifactUrl;
} }
/**
* Get the value of pomUrl.
*
* @return the value of pomUrl
*/
public String getPomUrl() {
return pomUrl;
}
/**
* Set the value of pomUrl.
*
* @param pomUrl new value of pomUrl
*/
public void setPomUrl(String pomUrl) {
this.pomUrl = pomUrl;
}
} }
// vim: cc=120:sw=4:ts=4:sts=4 // vim: cc=120:sw=4:ts=4:sts=4