Search in sources :

Example 6 with ArtifactContentEntry

use of org.apache.archiva.rest.api.model.ArtifactContentEntry in project archiva by apache.

the class DefaultBrowseService method getSmallerDepthEntries.

private List<ArtifactContentEntry> getSmallerDepthEntries(Map<String, ArtifactContentEntry> entries) {
    int smallestDepth = Integer.MAX_VALUE;
    Map<Integer, List<ArtifactContentEntry>> perDepthList = new HashMap<>();
    for (Map.Entry<String, ArtifactContentEntry> entry : entries.entrySet()) {
        ArtifactContentEntry current = entry.getValue();
        if (current.getDepth() < smallestDepth) {
            smallestDepth = current.getDepth();
        }
        List<ArtifactContentEntry> currentList = perDepthList.get(current.getDepth());
        if (currentList == null) {
            currentList = new ArrayList<>();
            currentList.add(current);
            perDepthList.put(current.getDepth(), currentList);
        } else {
            currentList.add(current);
        }
    }
    return perDepthList.get(smallestDepth);
}
Also used : HashMap(java.util.HashMap) ArtifactContentEntry(org.apache.archiva.rest.api.model.ArtifactContentEntry) List(java.util.List) ArrayList(java.util.ArrayList) VersionsList(org.apache.archiva.rest.api.model.VersionsList) Map(java.util.Map) HashMap(java.util.HashMap)

Example 7 with ArtifactContentEntry

use of org.apache.archiva.rest.api.model.ArtifactContentEntry in project archiva by apache.

the class ArtifactContentEntriesTests method readArtifactContentEntriesOnlyFiles.

@Test
public void readArtifactContentEntriesOnlyFiles() throws Exception {
    Path file = Paths.get(getBasedir(), "src/test/repo-with-osgi/commons-logging/commons-logging/1.1/commons-logging-1.1.jar");
    List<ArtifactContentEntry> artifactContentEntries = browseService.readFileEntries(file, "org/apache/commons/logging/impl/", "foo");
    log.info("artifactContentEntries: {}", artifactContentEntries);
    assertThat(artifactContentEntries).isNotNull().isNotEmpty().hasSize(16).contains(new ArtifactContentEntry("org/apache/commons/logging/impl/AvalonLogger.class", true, 5, "foo"));
}
Also used : Path(java.nio.file.Path) ArtifactContentEntry(org.apache.archiva.rest.api.model.ArtifactContentEntry) Test(org.junit.Test)

Example 8 with ArtifactContentEntry

use of org.apache.archiva.rest.api.model.ArtifactContentEntry in project archiva by apache.

the class ArtifactContentEntriesTests method readArtifactContentEntriesRootPathNull.

@Test
public void readArtifactContentEntriesRootPathNull() throws Exception {
    Path file = Paths.get(getBasedir(), "src/test/repo-with-osgi/commons-logging/commons-logging/1.1/commons-logging-1.1.jar");
    List<ArtifactContentEntry> artifactContentEntries = browseService.readFileEntries(file, null, "foo");
    log.info("artifactContentEntries: {}", artifactContentEntries);
    assertThat(artifactContentEntries).isNotNull().isNotEmpty().hasSize(2).contains(new ArtifactContentEntry("org", false, 0, "foo"), new ArtifactContentEntry("META-INF", false, 0, "foo"));
}
Also used : Path(java.nio.file.Path) ArtifactContentEntry(org.apache.archiva.rest.api.model.ArtifactContentEntry) Test(org.junit.Test)

Example 9 with ArtifactContentEntry

use of org.apache.archiva.rest.api.model.ArtifactContentEntry in project archiva by apache.

the class ArtifactContentEntriesTests method readArtifactContentEntriesRootPathEmpty.

@Test
public void readArtifactContentEntriesRootPathEmpty() throws Exception {
    Path file = Paths.get(getBasedir(), "src/test/repo-with-osgi/commons-logging/commons-logging/1.1/commons-logging-1.1.jar");
    List<ArtifactContentEntry> artifactContentEntries = browseService.readFileEntries(file, "", "foo");
    log.info("artifactContentEntries: {}", artifactContentEntries);
    assertThat(artifactContentEntries).isNotNull().isNotEmpty().hasSize(2).contains(new ArtifactContentEntry("org", false, 0, "foo"), new ArtifactContentEntry("META-INF", false, 0, "foo"));
}
Also used : Path(java.nio.file.Path) ArtifactContentEntry(org.apache.archiva.rest.api.model.ArtifactContentEntry) Test(org.junit.Test)

Example 10 with ArtifactContentEntry

use of org.apache.archiva.rest.api.model.ArtifactContentEntry in project archiva by apache.

the class ArtifactContentEntriesTests method readArtifactContentEntriesSecondDepthOnlyOneDirectory.

@Test
public void readArtifactContentEntriesSecondDepthOnlyOneDirectory() throws Exception {
    Path file = Paths.get(getBasedir(), "src/test/repo-with-osgi/commons-logging/commons-logging/1.1/commons-logging-1.1.jar");
    List<ArtifactContentEntry> artifactContentEntries = browseService.readFileEntries(file, "org", "foo");
    log.info("artifactContentEntries: {}", artifactContentEntries);
    assertThat(artifactContentEntries).isNotNull().isNotEmpty().hasSize(1).contains(new ArtifactContentEntry("org/apache", false, 1, "foo"));
}
Also used : Path(java.nio.file.Path) ArtifactContentEntry(org.apache.archiva.rest.api.model.ArtifactContentEntry) Test(org.junit.Test)

Aggregations

ArtifactContentEntry (org.apache.archiva.rest.api.model.ArtifactContentEntry)11 Test (org.junit.Test)9 Path (java.nio.file.Path)6 BrowseService (org.apache.archiva.rest.api.services.BrowseService)3 ArrayList (java.util.ArrayList)2 HashMap (java.util.HashMap)2 Map (java.util.Map)2 List (java.util.List)1 JarEntry (java.util.jar.JarEntry)1 JarFile (java.util.jar.JarFile)1 VersionsList (org.apache.archiva.rest.api.model.VersionsList)1