use of org.apache.archiva.metadata.model.Dependency in project archiva by apache.
the class Maven2RepositoryMetadataResolverMRM1411Test method testGetProjectVersionMetadataWithParentSnapshotVersion.
@Test
public void testGetProjectVersionMetadataWithParentSnapshotVersion() throws Exception {
copyTestArtifactWithParent("target/test-classes/com/example/test/test-snapshot-artifact-module-a", "target/test-repository/com/example/test/test-snapshot-artifact-module-a");
// copyTestArtifactWithParent( "target/test-classes/com/example/test/test-snapshot-artifact-root",
// "target/test-repository/com/example/test/test-snapshot-artifact-root" );
ProjectVersionMetadata metadata = storage.readProjectVersionMetadata(new ReadMetadataRequest(TEST_REPO_ID, "com.example.test", "test-snapshot-artifact-module-a", "1.1-SNAPSHOT"));
MavenProjectFacet facet = (MavenProjectFacet) metadata.getFacet(MavenProjectFacet.FACET_ID);
assertEquals("jar", facet.getPackaging());
assertEquals("com.example.test", facet.getParent().getGroupId());
assertEquals("test-snapshot-artifact-root", facet.getParent().getArtifactId());
assertEquals("1.1-SNAPSHOT", facet.getParent().getVersion());
assertEquals("test-snapshot-artifact-module-a", facet.getArtifactId());
assertEquals("com.example.test", facet.getGroupId());
assertNull(metadata.getCiManagement());
assertNotNull(metadata.getDescription());
checkApacheLicense(metadata);
assertEquals("1.1-SNAPSHOT", metadata.getId());
assertEquals("Test Snapshot Artifact :: Module A", metadata.getName());
String path = "test-snapshot-artifact/trunk/test-snapshot-artifact-module-a";
assertEquals(TEST_SCM_CONN_BASE + path, metadata.getScm().getConnection());
assertEquals(TEST_SCM_DEV_CONN_BASE + path, metadata.getScm().getDeveloperConnection());
assertEquals(TEST_SCM_URL_BASE + path, metadata.getScm().getUrl());
List<Dependency> dependencies = metadata.getDependencies();
assertEquals(2, dependencies.size());
assertDependency(dependencies.get(0), "commons-io", "commons-io", "1.4");
assertDependency(dependencies.get(1), "junit", "junit", "3.8.1", "test");
List<String> paths = new ArrayList<>();
paths.add("target/test-repository/com/example/test/test-snapshot-artifact-module-a");
paths.add("target/test-repository/com/example/test/test-snapshot-artifact-root");
deleteTestArtifactWithParent(paths);
}
use of org.apache.archiva.metadata.model.Dependency in project archiva by apache.
the class CassandraMetadataRepository method getDependencies.
protected List<Dependency> getDependencies(String projectVersionMetadataKey) {
List<Dependency> dependencies = new ArrayList<>();
QueryResult<OrderedRows<String, String, String>> result = //
HFactory.createRangeSlicesQuery(cassandraArchivaManager.getKeyspace(), ss, ss, ss).setColumnFamily(//
cassandraArchivaManager.getDependencyFamilyName()).setColumnNames(//
"projectVersionMetadataModel.key").setRowCount(//
Integer.MAX_VALUE).addEqualsExpression("projectVersionMetadataModel.key", //
projectVersionMetadataKey).execute();
for (Row<String, String, String> row : result.get()) {
ColumnFamilyResult<String, String> columnFamilyResult = this.dependencyTemplate.queryColumns(row.getKey());
Dependency dependency = new Dependency();
dependency.setClassifier(columnFamilyResult.getString("classifier"));
dependency.setOptional(Boolean.parseBoolean(columnFamilyResult.getString("optional")));
dependency.setScope(columnFamilyResult.getString("scope"));
dependency.setSystemPath(columnFamilyResult.getString("systemPath"));
dependency.setType(columnFamilyResult.getString("type"));
dependency.setArtifactId(columnFamilyResult.getString(ARTIFACT_ID.toString()));
dependency.setGroupId(columnFamilyResult.getString(GROUP_ID.toString()));
dependency.setVersion(columnFamilyResult.getString(VERSION.toString()));
dependencies.add(dependency);
}
return dependencies;
}
use of org.apache.archiva.metadata.model.Dependency in project archiva by apache.
the class CassandraMetadataRepository method recordDependencies.
protected void recordDependencies(String projectVersionMetadataKey, List<Dependency> dependencies, String repositoryId) {
if (dependencies == null || dependencies.isEmpty()) {
return;
}
Mutator<String> dependencyMutator = this.dependencyTemplate.createMutator();
for (Dependency dependency : dependencies) {
// we don't care about the key as the real used one with the projectVersionMetadata
String keyDependency = UUID.randomUUID().toString();
String cfDependency = cassandraArchivaManager.getDependencyFamilyName();
addInsertion(dependencyMutator, keyDependency, cfDependency, "projectVersionMetadataModel.key", projectVersionMetadataKey);
addInsertion(dependencyMutator, keyDependency, cfDependency, REPOSITORY_NAME.toString(), repositoryId);
addInsertion(dependencyMutator, keyDependency, cfDependency, "classifier", dependency.getClassifier());
addInsertion(dependencyMutator, keyDependency, cfDependency, "optional", Boolean.toString(dependency.isOptional()));
addInsertion(dependencyMutator, keyDependency, cfDependency, "scope", dependency.getScope());
addInsertion(dependencyMutator, keyDependency, cfDependency, "systemPath", dependency.getSystemPath());
addInsertion(dependencyMutator, keyDependency, cfDependency, "type", dependency.getType());
addInsertion(dependencyMutator, keyDependency, cfDependency, ARTIFACT_ID.toString(), dependency.getArtifactId());
addInsertion(dependencyMutator, keyDependency, cfDependency, GROUP_ID.toString(), dependency.getGroupId());
addInsertion(dependencyMutator, keyDependency, cfDependency, VERSION.toString(), dependency.getVersion());
}
dependencyMutator.execute();
}
use of org.apache.archiva.metadata.model.Dependency in project archiva by apache.
the class AbstractMetadataRepositoryTest method testUpdateProjectVersionMetadataWithAllElements.
@Test
public void testUpdateProjectVersionMetadataWithAllElements() throws Exception {
ProjectVersionMetadata metadata = new ProjectVersionMetadata();
metadata.setId(TEST_PROJECT_VERSION);
metadata.setName("project name");
metadata.setDescription("project description");
metadata.setUrl("the url");
MailingList mailingList = new MailingList();
mailingList.setName("Foo List");
mailingList.setUnsubscribeAddress("UnsubscribeAddress");
mailingList.setSubscribeAddress("SubscribeAddress");
mailingList.setPostAddress("PostAddress");
mailingList.setMainArchiveUrl("MainArchiveUrl");
mailingList.setOtherArchives(Arrays.asList("other archive"));
metadata.setMailingLists(Arrays.asList(mailingList));
Scm scm = new Scm();
scm.setConnection("connection");
scm.setDeveloperConnection("dev conn");
scm.setUrl("url");
metadata.setScm(scm);
CiManagement ci = new CiManagement();
ci.setSystem("system");
ci.setUrl("ci url");
metadata.setCiManagement(ci);
IssueManagement tracker = new IssueManagement();
tracker.setSystem("system");
tracker.setUrl("issue tracker url");
metadata.setIssueManagement(tracker);
metadata.setOrganization(TEST_ORGANIZATION);
License l = new License();
l.setName("license name");
l.setUrl("license url");
metadata.addLicense(l);
Dependency d = new Dependency();
d.setArtifactId("artifactId");
d.setClassifier("classifier");
d.setGroupId("groupId");
d.setScope("scope");
d.setSystemPath("system path");
d.setType("type");
d.setVersion("version");
d.setOptional(true);
metadata.addDependency(d);
repository.updateProjectVersion(TEST_REPO_ID, TEST_NAMESPACE, TEST_PROJECT, metadata);
metadata = repository.getProjectVersion(TEST_REPO_ID, TEST_NAMESPACE, TEST_PROJECT, TEST_PROJECT_VERSION);
assertEquals(TEST_PROJECT_VERSION, metadata.getId());
assertEquals(TEST_PROJECT_VERSION, metadata.getVersion());
assertEquals("project name", metadata.getName());
assertEquals("project description", metadata.getDescription());
assertEquals("the url", metadata.getUrl());
assertEquals("connection", metadata.getScm().getConnection());
assertEquals("dev conn", metadata.getScm().getDeveloperConnection());
assertEquals("url", metadata.getScm().getUrl());
assertEquals("system", metadata.getCiManagement().getSystem());
assertEquals("ci url", metadata.getCiManagement().getUrl());
assertEquals("system", metadata.getIssueManagement().getSystem());
assertEquals("issue tracker url", metadata.getIssueManagement().getUrl());
assertEquals(TEST_ORGANIZATION.getName(), metadata.getOrganization().getName());
assertEquals(TEST_ORGANIZATION.getUrl(), metadata.getOrganization().getUrl());
assertEquals(1, metadata.getMailingLists().size());
MailingList retrievedMailingList = metadata.getMailingLists().get(0);
assertEquals(mailingList.getName(), retrievedMailingList.getName());
assertEquals(mailingList.getMainArchiveUrl(), retrievedMailingList.getMainArchiveUrl());
assertEquals(mailingList.getPostAddress(), retrievedMailingList.getPostAddress());
assertEquals(mailingList.getSubscribeAddress(), retrievedMailingList.getSubscribeAddress());
assertEquals(mailingList.getUnsubscribeAddress(), retrievedMailingList.getUnsubscribeAddress());
//
assertThat(retrievedMailingList.getOtherArchives()).isNotNull().isNotEmpty().hasSize(//
1).contains("other archive");
assertEquals(1, metadata.getLicenses().size());
l = metadata.getLicenses().get(0);
assertEquals("license name", l.getName());
assertEquals("license url", l.getUrl());
assertEquals(1, metadata.getDependencies().size());
d = metadata.getDependencies().get(0);
assertEquals("artifactId", d.getArtifactId());
assertEquals("classifier", d.getClassifier());
assertEquals("groupId", d.getGroupId());
assertEquals("scope", d.getScope());
assertEquals("system path", d.getSystemPath());
assertEquals("type", d.getType());
assertEquals("version", d.getVersion());
assertTrue(d.isOptional());
}
use of org.apache.archiva.metadata.model.Dependency in project archiva by apache.
the class FileMetadataRepository method getProjectVersion.
@Override
public ProjectVersionMetadata getProjectVersion(String repoId, String namespace, String projectId, String projectVersion) throws MetadataResolutionException {
try {
Path directory = getDirectory(repoId).resolve(namespace + "/" + projectId + "/" + projectVersion);
Properties properties = readOrCreateProperties(directory, PROJECT_VERSION_METADATA_KEY);
String id = properties.getProperty("id");
ProjectVersionMetadata versionMetadata = null;
if (id != null) {
versionMetadata = new ProjectVersionMetadata();
versionMetadata.setId(id);
versionMetadata.setName(properties.getProperty("name"));
versionMetadata.setDescription(properties.getProperty("description"));
versionMetadata.setUrl(properties.getProperty("url"));
versionMetadata.setIncomplete(Boolean.valueOf(properties.getProperty("incomplete", "false")));
String scmConnection = properties.getProperty("scm.connection");
String scmDeveloperConnection = properties.getProperty("scm.developerConnection");
String scmUrl = properties.getProperty("scm.url");
if (scmConnection != null || scmDeveloperConnection != null || scmUrl != null) {
Scm scm = new Scm();
scm.setConnection(scmConnection);
scm.setDeveloperConnection(scmDeveloperConnection);
scm.setUrl(scmUrl);
versionMetadata.setScm(scm);
}
String ciSystem = properties.getProperty("ci.system");
String ciUrl = properties.getProperty("ci.url");
if (ciSystem != null || ciUrl != null) {
CiManagement ci = new CiManagement();
ci.setSystem(ciSystem);
ci.setUrl(ciUrl);
versionMetadata.setCiManagement(ci);
}
String issueSystem = properties.getProperty("issue.system");
String issueUrl = properties.getProperty("issue.url");
if (issueSystem != null || issueUrl != null) {
IssueManagement issueManagement = new IssueManagement();
issueManagement.setSystem(issueSystem);
issueManagement.setUrl(issueUrl);
versionMetadata.setIssueManagement(issueManagement);
}
String orgName = properties.getProperty("org.name");
String orgUrl = properties.getProperty("org.url");
if (orgName != null || orgUrl != null) {
Organization org = new Organization();
org.setName(orgName);
org.setUrl(orgUrl);
versionMetadata.setOrganization(org);
}
boolean done = false;
int i = 0;
while (!done) {
String licenseName = properties.getProperty("license." + i + ".name");
String licenseUrl = properties.getProperty("license." + i + ".url");
if (licenseName != null || licenseUrl != null) {
License license = new License();
license.setName(licenseName);
license.setUrl(licenseUrl);
versionMetadata.addLicense(license);
} else {
done = true;
}
i++;
}
done = false;
i = 0;
while (!done) {
String mailingListName = properties.getProperty("mailingList." + i + ".name");
if (mailingListName != null) {
MailingList mailingList = new MailingList();
mailingList.setName(mailingListName);
mailingList.setMainArchiveUrl(properties.getProperty("mailingList." + i + ".archive"));
String p = properties.getProperty("mailingList." + i + ".otherArchives");
if (p != null && p.length() > 0) {
mailingList.setOtherArchives(Arrays.asList(p.split(",")));
} else {
mailingList.setOtherArchives(Collections.emptyList());
}
mailingList.setPostAddress(properties.getProperty("mailingList." + i + ".post"));
mailingList.setSubscribeAddress(properties.getProperty("mailingList." + i + ".subscribe"));
mailingList.setUnsubscribeAddress(properties.getProperty("mailingList." + i + ".unsubscribe"));
versionMetadata.addMailingList(mailingList);
} else {
done = true;
}
i++;
}
done = false;
i = 0;
while (!done) {
String dependencyArtifactId = properties.getProperty("dependency." + i + ".artifactId");
if (dependencyArtifactId != null) {
Dependency dependency = new Dependency();
dependency.setArtifactId(dependencyArtifactId);
dependency.setGroupId(properties.getProperty("dependency." + i + ".groupId"));
dependency.setClassifier(properties.getProperty("dependency." + i + ".classifier"));
dependency.setOptional(Boolean.valueOf(properties.getProperty("dependency." + i + ".optional")));
dependency.setScope(properties.getProperty("dependency." + i + ".scope"));
dependency.setSystemPath(properties.getProperty("dependency." + i + ".systemPath"));
dependency.setType(properties.getProperty("dependency." + i + ".type"));
dependency.setVersion(properties.getProperty("dependency." + i + ".version"));
dependency.setOptional(Boolean.valueOf(properties.getProperty("dependency." + i + ".optional")));
versionMetadata.addDependency(dependency);
} else {
done = true;
}
i++;
}
String facetIds = properties.getProperty("facetIds", "");
if (facetIds.length() > 0) {
for (String facetId : facetIds.split(",")) {
MetadataFacetFactory factory = metadataFacetFactories.get(facetId);
if (factory == null) {
log.error("Attempted to load unknown project version metadata facet: {}", facetId);
} else {
MetadataFacet facet = factory.createMetadataFacet();
Map<String, String> map = new HashMap<>();
for (Object key : new ArrayList<>(properties.keySet())) {
String property = (String) key;
if (property.startsWith(facet.getFacetId())) {
map.put(property.substring(facet.getFacetId().length() + 1), properties.getProperty(property));
}
}
facet.fromProperties(map);
versionMetadata.addFacet(facet);
}
}
}
updateProjectVersionFacets(versionMetadata, properties);
}
return versionMetadata;
} catch (IOException e) {
throw new MetadataResolutionException(e.getMessage(), e);
}
}
Aggregations