Search in sources :

Example 1 with ProjectMetadata

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());
}
Also used : ProjectMetadata(org.apache.archiva.metadata.model.ProjectMetadata) ProjectVersionMetadata(org.apache.archiva.metadata.model.ProjectVersionMetadata) Test(org.junit.Test)

Example 2 with ProjectMetadata

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);
}
Also used : ProjectMetadata(org.apache.archiva.metadata.model.ProjectMetadata) Test(org.junit.Test)

Example 3 with ProjectMetadata

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);
    }
}
Also used : Path(java.nio.file.Path) ProjectMetadata(org.apache.archiva.metadata.model.ProjectMetadata) IOException(java.io.IOException) Properties(java.util.Properties) MetadataResolutionException(org.apache.archiva.metadata.repository.MetadataResolutionException)

Example 4 with ProjectMetadata

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;
}
Also used : ProjectMetadata(org.apache.archiva.metadata.model.ProjectMetadata) Node(javax.jcr.Node) MetadataRepositoryException(org.apache.archiva.metadata.repository.MetadataRepositoryException) RepositoryException(javax.jcr.RepositoryException) MetadataResolutionException(org.apache.archiva.metadata.repository.MetadataResolutionException)

Example 5 with ProjectMetadata

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);
    }
}
Also used : Repository(org.apache.archiva.metadata.repository.cassandra.model.Repository) ProjectMetadata(org.apache.archiva.metadata.model.ProjectMetadata) Namespace(org.apache.archiva.metadata.repository.cassandra.model.Namespace) Test(org.junit.Test)

Aggregations

ProjectMetadata (org.apache.archiva.metadata.model.ProjectMetadata)14 Test (org.junit.Test)6 OrderedRows (me.prettyprint.hector.api.beans.OrderedRows)3 ArtifactMetadata (org.apache.archiva.metadata.model.ArtifactMetadata)3 ProjectVersionMetadata (org.apache.archiva.metadata.model.ProjectVersionMetadata)3 MetadataRepositoryException (org.apache.archiva.metadata.repository.MetadataRepositoryException)3 MetadataResolutionException (org.apache.archiva.metadata.repository.MetadataResolutionException)3 Namespace (org.apache.archiva.metadata.repository.cassandra.model.Namespace)3 ArrayList (java.util.ArrayList)2 MetadataRepository (org.apache.archiva.metadata.repository.MetadataRepository)2 ArtifactMetadataModel (org.apache.archiva.metadata.repository.cassandra.model.ArtifactMetadataModel)2 ProjectVersionMetadataModel (org.apache.archiva.metadata.repository.cassandra.model.ProjectVersionMetadataModel)2 Repository (org.apache.archiva.metadata.repository.cassandra.model.Repository)2 RepositoryStorageRuntimeException (org.apache.archiva.metadata.repository.storage.RepositoryStorageRuntimeException)2 IOException (java.io.IOException)1 Path (java.nio.file.Path)1 Date (java.util.Date)1 Properties (java.util.Properties)1 Node (javax.jcr.Node)1 RepositoryException (javax.jcr.RepositoryException)1