use of org.apache.archiva.metadata.model.MailingList in project archiva by apache.
the class AbstractMetadataRepositoryTest method testUpdateProjectVersionMetadataWithNoOtherArchives.
@Test
public void testUpdateProjectVersionMetadataWithNoOtherArchives() throws Exception {
ProjectVersionMetadata metadata = new ProjectVersionMetadata();
metadata.setId(TEST_PROJECT_VERSION);
MailingList mailingList = new MailingList();
mailingList.setName("Foo List");
mailingList.setOtherArchives(Collections.<String>emptyList());
metadata.setMailingLists(Arrays.asList(mailingList));
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());
List<MailingList> mailingLists = metadata.getMailingLists();
assertThat(mailingLists).isNotNull().isNotEmpty().hasSize(1);
mailingList = metadata.getMailingLists().get(0);
assertEquals("Foo List", mailingList.getName());
List<String> others = mailingList.getOtherArchives();
assertThat(others).isNotNull().isEmpty();
}
use of org.apache.archiva.metadata.model.MailingList in project archiva by apache.
the class FileMetadataRepository method updateProjectVersion.
@Override
public void updateProjectVersion(String repoId, String namespace, String projectId, ProjectVersionMetadata versionMetadata) {
try {
updateProject(repoId, namespace, projectId);
Path directory = getDirectory(repoId).resolve(namespace + "/" + projectId + "/" + versionMetadata.getId());
Properties properties = readOrCreateProperties(directory, PROJECT_VERSION_METADATA_KEY);
// remove properties that are not references or artifacts
for (Object key : new ArrayList<>(properties.keySet())) {
String name = (String) key;
if (!name.contains(":") && !name.equals("facetIds")) {
properties.remove(name);
}
// clear the facet contents so old properties are no longer written
clearMetadataFacetProperties(versionMetadata.getFacetList(), properties, "");
}
properties.setProperty("id", versionMetadata.getId());
setProperty(properties, "name", versionMetadata.getName());
setProperty(properties, "description", versionMetadata.getDescription());
setProperty(properties, "url", versionMetadata.getUrl());
setProperty(properties, "incomplete", String.valueOf(versionMetadata.isIncomplete()));
if (versionMetadata.getScm() != null) {
setProperty(properties, "scm.connection", versionMetadata.getScm().getConnection());
setProperty(properties, "scm.developerConnection", versionMetadata.getScm().getDeveloperConnection());
setProperty(properties, "scm.url", versionMetadata.getScm().getUrl());
}
if (versionMetadata.getCiManagement() != null) {
setProperty(properties, "ci.system", versionMetadata.getCiManagement().getSystem());
setProperty(properties, "ci.url", versionMetadata.getCiManagement().getUrl());
}
if (versionMetadata.getIssueManagement() != null) {
setProperty(properties, "issue.system", versionMetadata.getIssueManagement().getSystem());
setProperty(properties, "issue.url", versionMetadata.getIssueManagement().getUrl());
}
if (versionMetadata.getOrganization() != null) {
setProperty(properties, "org.name", versionMetadata.getOrganization().getName());
setProperty(properties, "org.url", versionMetadata.getOrganization().getUrl());
}
int i = 0;
for (License license : versionMetadata.getLicenses()) {
setProperty(properties, "license." + i + ".name", license.getName());
setProperty(properties, "license." + i + ".url", license.getUrl());
i++;
}
i = 0;
for (MailingList mailingList : versionMetadata.getMailingLists()) {
setProperty(properties, "mailingList." + i + ".archive", mailingList.getMainArchiveUrl());
setProperty(properties, "mailingList." + i + ".name", mailingList.getName());
setProperty(properties, "mailingList." + i + ".post", mailingList.getPostAddress());
setProperty(properties, "mailingList." + i + ".unsubscribe", mailingList.getUnsubscribeAddress());
setProperty(properties, "mailingList." + i + ".subscribe", mailingList.getSubscribeAddress());
setProperty(properties, "mailingList." + i + ".otherArchives", join(mailingList.getOtherArchives()));
i++;
}
i = 0;
ProjectVersionReference reference = new ProjectVersionReference();
reference.setNamespace(namespace);
reference.setProjectId(projectId);
reference.setProjectVersion(versionMetadata.getId());
reference.setReferenceType(ProjectVersionReference.ReferenceType.DEPENDENCY);
for (Dependency dependency : versionMetadata.getDependencies()) {
setProperty(properties, "dependency." + i + ".classifier", dependency.getClassifier());
setProperty(properties, "dependency." + i + ".scope", dependency.getScope());
setProperty(properties, "dependency." + i + ".systemPath", dependency.getSystemPath());
setProperty(properties, "dependency." + i + ".artifactId", dependency.getArtifactId());
setProperty(properties, "dependency." + i + ".groupId", dependency.getGroupId());
setProperty(properties, "dependency." + i + ".version", dependency.getVersion());
setProperty(properties, "dependency." + i + ".type", dependency.getType());
setProperty(properties, "dependency." + i + ".optional", String.valueOf(dependency.isOptional()));
updateProjectReference(repoId, dependency.getGroupId(), dependency.getArtifactId(), dependency.getVersion(), reference);
i++;
}
Set<String> facetIds = new LinkedHashSet<>(versionMetadata.getFacetIds());
facetIds.addAll(Arrays.asList(properties.getProperty("facetIds", "").split(",")));
properties.setProperty("facetIds", join(facetIds));
updateProjectVersionFacets(versionMetadata, properties);
writeProperties(properties, directory, PROJECT_VERSION_METADATA_KEY);
} catch (IOException e) {
log.error("Could not update project version {}, {}, {}: {}", repoId, namespace, versionMetadata.getId(), e.getMessage(), e);
}
}
use of org.apache.archiva.metadata.model.MailingList in project archiva by apache.
the class CassandraMetadataRepository method recordMailingList.
protected void recordMailingList(String projectVersionMetadataKey, List<MailingList> mailingLists) {
if (mailingLists == null || mailingLists.isEmpty()) {
return;
}
Mutator<String> mailingMutator = this.mailingListTemplate.createMutator();
for (MailingList mailingList : mailingLists) {
// we don't care about the key as the real used one with the projectVersionMetadata
String keyMailingList = UUID.randomUUID().toString();
String cfMailingList = cassandraArchivaManager.getMailingListFamilyName();
addInsertion(mailingMutator, keyMailingList, cfMailingList, "projectVersionMetadataModel.key", projectVersionMetadataKey);
addInsertion(mailingMutator, keyMailingList, cfMailingList, NAME.toString(), mailingList.getName());
addInsertion(mailingMutator, keyMailingList, cfMailingList, "mainArchiveUrl", mailingList.getMainArchiveUrl());
addInsertion(mailingMutator, keyMailingList, cfMailingList, "postAddress", mailingList.getPostAddress());
addInsertion(mailingMutator, keyMailingList, cfMailingList, "subscribeAddress", mailingList.getSubscribeAddress());
addInsertion(mailingMutator, keyMailingList, cfMailingList, "unsubscribeAddress", mailingList.getUnsubscribeAddress());
int idx = 0;
for (String otherArchive : mailingList.getOtherArchives()) {
addInsertion(mailingMutator, keyMailingList, cfMailingList, "otherArchive." + idx, otherArchive);
idx++;
}
}
mailingMutator.execute();
}
use of org.apache.archiva.metadata.model.MailingList 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.MailingList in project archiva by apache.
the class CassandraMetadataRepository method getMailingLists.
protected List<MailingList> getMailingLists(String projectVersionMetadataKey) {
List<MailingList> mailingLists = new ArrayList<>();
QueryResult<OrderedRows<String, String, String>> result = //
HFactory.createRangeSlicesQuery(cassandraArchivaManager.getKeyspace(), ss, ss, ss).setColumnFamily(//
cassandraArchivaManager.getMailingListFamilyName()).setColumnNames(//
NAME.toString()).setRowCount(//
Integer.MAX_VALUE).addEqualsExpression("projectVersionMetadataModel.key", //
projectVersionMetadataKey).execute();
for (Row<String, String, String> row : result.get()) {
ColumnFamilyResult<String, String> columnFamilyResult = this.mailingListTemplate.queryColumns(row.getKey());
MailingList mailingList = new MailingList();
mailingList.setName(columnFamilyResult.getString(NAME.toString()));
mailingList.setMainArchiveUrl(columnFamilyResult.getString("mainArchiveUrl"));
mailingList.setPostAddress(columnFamilyResult.getString("postAddress"));
mailingList.setSubscribeAddress(columnFamilyResult.getString("subscribeAddress"));
mailingList.setUnsubscribeAddress(columnFamilyResult.getString("unsubscribeAddress"));
List<String> otherArchives = new ArrayList<>();
for (String columnName : columnFamilyResult.getColumnNames()) {
if (StringUtils.startsWith(columnName, "otherArchive.")) {
otherArchives.add(columnFamilyResult.getString(columnName));
}
}
mailingList.setOtherArchives(otherArchives);
mailingLists.add(mailingList);
}
return mailingLists;
}
Aggregations