use of org.apache.archiva.metadata.model.ProjectMetadata in project archiva by apache.
the class AbstractMetadataRepositoryTest method testGetProjectVersionOnly.
@Test
public void testGetProjectVersionOnly() throws Exception {
assertNull(repository.getProjectVersion(TEST_REPO_ID, TEST_NAMESPACE, TEST_PROJECT, TEST_PROJECT_VERSION));
assertNull(repository.getProject(TEST_REPO_ID, TEST_NAMESPACE, TEST_PROJECT));
assertThat(repository.getRootNamespaces(TEST_REPO_ID)).isNotNull().isEmpty();
ProjectVersionMetadata metadata = new ProjectVersionMetadata();
metadata.setId(TEST_PROJECT_VERSION);
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());
// test that namespace and project is also constructed
Collection<String> namespaces = repository.getRootNamespaces(TEST_REPO_ID);
assertThat(namespaces).isNotNull().isNotEmpty().hasSize(1).contains(TEST_NAMESPACE);
ProjectMetadata projectMetadata = repository.getProject(TEST_REPO_ID, TEST_NAMESPACE, TEST_PROJECT);
assertNotNull(projectMetadata);
assertEquals(TEST_PROJECT, projectMetadata.getId());
assertEquals(TEST_NAMESPACE, projectMetadata.getNamespace());
}
use of org.apache.archiva.metadata.model.ProjectMetadata in project archiva by apache.
the class AbstractMetadataRepositoryTest method testGetProjectsWithOtherNamespacesPresent.
@Test
public void testGetProjectsWithOtherNamespacesPresent() throws Exception {
ProjectMetadata projectMetadata = new ProjectMetadata();
projectMetadata.setId(TEST_PROJECT);
projectMetadata.setNamespace("org.apache.maven");
repository.updateProject(TEST_REPO_ID, projectMetadata);
repository.updateNamespace(TEST_REPO_ID, "org.apache.maven.shared");
Collection<String> projects = repository.getProjects(TEST_REPO_ID, "org.apache.maven");
assertThat(projects).isNotNull().isNotEmpty().hasSize(1).contains(TEST_PROJECT);
}
use of org.apache.archiva.metadata.model.ProjectMetadata in project archiva by apache.
the class FileMetadataRepository method getProject.
@Override
public ProjectMetadata getProject(String repoId, String namespace, String projectId) throws MetadataResolutionException {
try {
Path directory = getDirectory(repoId).resolve(namespace + "/" + projectId);
Properties properties = readOrCreateProperties(directory, PROJECT_METADATA_KEY);
ProjectMetadata project = null;
String id = properties.getProperty("id");
if (id != null) {
project = new ProjectMetadata();
project.setNamespace(properties.getProperty("namespace"));
project.setId(id);
}
return project;
} catch (IOException e) {
throw new MetadataResolutionException(e.getMessage(), e);
}
}
use of org.apache.archiva.metadata.model.ProjectMetadata in project archiva by apache.
the class JcrMetadataRepository method getProject.
@Override
public ProjectMetadata getProject(String repositoryId, String namespace, String projectId) throws MetadataResolutionException {
ProjectMetadata metadata = null;
try {
Node root = getJcrSession().getRootNode();
// basically just checking it exists
String path = getProjectPath(repositoryId, namespace, projectId);
if (root.hasNode(path)) {
metadata = new ProjectMetadata();
metadata.setId(projectId);
metadata.setNamespace(namespace);
}
} catch (RepositoryException e) {
throw new MetadataResolutionException(e.getMessage(), e);
}
return metadata;
}
use of org.apache.archiva.metadata.model.ProjectMetadata in project archiva by apache.
the class RepositoriesNamespaceTest method testMetadataRepo.
@Test
public void testMetadataRepo() throws Exception {
Repository r = null;
Namespace n = null;
try {
cmr.updateNamespace("release", "org");
r = cmr.getRepository("release");
assertThat(r).isNotNull();
assertThat(cmr.getRepositories()).isNotEmpty().hasSize(1);
assertThat(cmr.getNamespaces("release")).isNotEmpty().hasSize(1);
n = cmr.getNamespace("release", "org");
assertThat(n).isNotNull();
assertThat(n.getRepository()).isNotNull();
cmr.updateNamespace("release", "org.apache");
r = cmr.getRepository("release");
assertThat(r).isNotNull();
assertThat(cmr.getNamespaces("release")).isNotEmpty().hasSize(2);
cmr.removeNamespace("release", "org.apache");
assertThat(cmr.getNamespaces("release")).isNotEmpty().hasSize(1);
assertThat(cmr.getNamespaces("release")).containsExactly("org");
ProjectMetadata projectMetadata = new ProjectMetadata();
projectMetadata.setId("theproject");
projectMetadata.setNamespace("org");
cmr.updateProject("release", projectMetadata);
assertThat(cmr.getProjects("release", "org")).isNotEmpty().hasSize(1).containsExactly("theproject");
cmr.removeProject("release", "org", "theproject");
assertThat(cmr.getProjects("release", "org")).isEmpty();
cmr.removeRepository("release");
r = cmr.getRepository("release");
assertThat(r).isNull();
} catch (Exception e) {
logger.error(e.getMessage(), e);
throw e;
} finally {
CassandraMetadataRepositoryTest.clearReposAndNamespace(cassandraArchivaManager);
}
}
Aggregations