Search in sources :

Example 71 with ItemSelector

use of org.apache.archiva.repository.content.ItemSelector in project archiva by apache.

the class ManagedDefaultRepositoryContentTest method testNewItemStreamWithNamespace2.

@Test
public void testNewItemStreamWithNamespace2() {
    ItemSelector selector = ArchivaItemSelector.builder().withNamespace("org.apache.maven").recurse().build();
    Stream<? extends ContentItem> stream = repoContent.newItemStream(selector, false);
    List<? extends ContentItem> result = stream.collect(Collectors.toList());
    assertEquals(170, result.size());
    assertEquals(92, result.stream().filter(a -> a instanceof DataItem).count());
}
Also used : ArchivaItemSelector(org.apache.archiva.repository.content.base.ArchivaItemSelector) ItemSelector(org.apache.archiva.repository.content.ItemSelector) DataItem(org.apache.archiva.repository.content.DataItem) Test(org.junit.Test)

Example 72 with ItemSelector

use of org.apache.archiva.repository.content.ItemSelector in project archiva by apache.

the class ManagedDefaultRepositoryContentTest method testArtifactListWithNamespaceSelectorRecursive.

@Test
public void testArtifactListWithNamespaceSelectorRecursive() {
    ItemSelector selector = ArchivaItemSelector.builder().withNamespace("org.multilevel").recurse().build();
    List<? extends Artifact> results = repoContent.getArtifacts(selector);
    checkArtifactListWithNamespaceSelectorRecursive(results);
}
Also used : ArchivaItemSelector(org.apache.archiva.repository.content.base.ArchivaItemSelector) ItemSelector(org.apache.archiva.repository.content.ItemSelector) Test(org.junit.Test)

Example 73 with ItemSelector

use of org.apache.archiva.repository.content.ItemSelector in project archiva by apache.

the class ManagedDefaultRepositoryContentTest method testGetArtifactListWithVersionSelector2.

@Test
public void testGetArtifactListWithVersionSelector2() {
    ItemSelector selector = ArchivaItemSelector.builder().withNamespace("org.apache.axis2").withProjectId("axis2").withVersion("1.3-SNAPSHOT").build();
    List<? extends Artifact> results = repoContent.getArtifacts(selector);
    checkArtifactListWithVersionSelector2(results);
}
Also used : ArchivaItemSelector(org.apache.archiva.repository.content.base.ArchivaItemSelector) ItemSelector(org.apache.archiva.repository.content.ItemSelector) Test(org.junit.Test)

Example 74 with ItemSelector

use of org.apache.archiva.repository.content.ItemSelector in project archiva by apache.

the class MavenContentHelperTest method assertExtension.

private void assertExtension(String expectedExtension, String type, String extension) {
    ItemSelector selector = ArchivaItemSelector.builder().withType(type).withExtension(extension).build();
    assertEquals(expectedExtension, MavenContentHelper.getArtifactExtension(selector));
}
Also used : ArchivaItemSelector(org.apache.archiva.repository.content.base.ArchivaItemSelector) ItemSelector(org.apache.archiva.repository.content.ItemSelector)

Example 75 with ItemSelector

use of org.apache.archiva.repository.content.ItemSelector in project archiva by apache.

the class DefaultFileUploadService method savePomFile.

protected void savePomFile(String repositoryId, FileMetadata fileMetadata, String groupId, String artifactId, String version, String packaging) throws ArchivaRestServiceException {
    log.debug("Saving POM");
    try {
        boolean fixChecksums = !(archivaAdministration.getKnownContentConsumers().contains("create-missing-checksums"));
        org.apache.archiva.repository.ManagedRepository repository = repositoryRegistry.getManagedRepository(repositoryId);
        ItemSelector selector = ArchivaItemSelector.builder().withNamespace(groupId).withProjectId(artifactId).withArtifactId(artifactId).withArtifactVersion(version).withExtension(packaging).build();
        StorageAsset pomPath = repository.getContent().getItem(selector).getAsset();
        StorageAsset targetPath = pomPath.getParent();
        String pomFilename = pomPath.getName();
        if (StringUtils.isNotEmpty(fileMetadata.getClassifier())) {
            pomFilename = StringUtils.remove(pomFilename, "-" + fileMetadata.getClassifier());
        }
        pomFilename = FilenameUtils.removeExtension(pomFilename) + ".pom";
        copyFile(Paths.get(fileMetadata.getServerFileName()), targetPath, pomFilename, fixChecksums);
        triggerAuditEvent(repository.getId(), targetPath.resolve(pomFilename).toString(), AuditEvent.UPLOAD_FILE);
        queueRepositoryTask(repository.getId(), targetPath.resolve(pomFilename));
        log.debug("Finished Saving POM");
    } catch (IOException ie) {
        log.error("IOException for POM {}", ie.getMessage());
        throw new ArchivaRestServiceException("Error encountered while uploading pom file: " + ie.getMessage(), Response.Status.INTERNAL_SERVER_ERROR.getStatusCode(), ie);
    } catch (RepositoryAdminException e) {
        log.error("RepositoryAdminException for POM {}", e.getMessage());
        throw new ArchivaRestServiceException("RepositoryAdmin exception: " + e.getMessage(), Response.Status.INTERNAL_SERVER_ERROR.getStatusCode(), e);
    }
}
Also used : ItemSelector(org.apache.archiva.repository.content.ItemSelector) ArchivaItemSelector(org.apache.archiva.repository.content.base.ArchivaItemSelector) StorageAsset(org.apache.archiva.repository.storage.StorageAsset) ArchivaRestServiceException(org.apache.archiva.rest.api.services.ArchivaRestServiceException) IOException(java.io.IOException) RepositoryAdminException(org.apache.archiva.admin.model.RepositoryAdminException)

Aggregations

ItemSelector (org.apache.archiva.repository.content.ItemSelector)76 ArchivaItemSelector (org.apache.archiva.repository.content.base.ArchivaItemSelector)74 Test (org.junit.Test)41 Path (java.nio.file.Path)16 Artifact (org.apache.archiva.repository.content.Artifact)16 StorageAsset (org.apache.archiva.repository.storage.StorageAsset)13 ManagedRepositoryContent (org.apache.archiva.repository.ManagedRepositoryContent)12 BaseRepositoryContentLayout (org.apache.archiva.repository.content.BaseRepositoryContentLayout)12 LayoutException (org.apache.archiva.repository.content.LayoutException)12 IOException (java.io.IOException)11 ContentItem (org.apache.archiva.repository.content.ContentItem)11 Project (org.apache.archiva.repository.content.Project)11 ArchivaContentItem (org.apache.archiva.repository.content.base.ArchivaContentItem)10 Namespace (org.apache.archiva.repository.content.Namespace)9 Version (org.apache.archiva.repository.content.Version)9 VersionComparator (org.apache.archiva.common.utils.VersionComparator)8 EditableManagedRepository (org.apache.archiva.repository.EditableManagedRepository)7 List (java.util.List)6 Collectors (java.util.stream.Collectors)6 Stream (java.util.stream.Stream)6