Search in sources :

Example 1 with ManifestAgePathComparator

use of com.instaclustr.esop.impl.Manifest.ManifestAgePathComparator in project esop by instaclustr.

the class LocalFileRestorer method listManifests.

@Override
public List<Manifest> listManifests() throws Exception {
    assert objectMapper != null;
    final Path path = Paths.get(storageLocation.rawLocation.replaceAll("file://", ""), "manifests");
    if (!Files.exists(path))
        return Collections.emptyList();
    final List<Path> manifests = Files.list(path).sorted(new ManifestAgePathComparator()).collect(toList());
    final List<Manifest> manifestsList = new ArrayList<>();
    for (final Path manifest : manifests) {
        final Manifest read = Manifest.read(manifest, objectMapper);
        read.setManifest(new ManifestEntry(Paths.get("manifests", manifest.getFileName().toString()), manifest, Type.FILE, null));
        manifestsList.add(read);
    }
    return manifestsList;
}
Also used : Path(java.nio.file.Path) ManifestAgePathComparator(com.instaclustr.esop.impl.Manifest.ManifestAgePathComparator) ManifestEntry(com.instaclustr.esop.impl.ManifestEntry) ArrayList(java.util.ArrayList) Manifest(com.instaclustr.esop.impl.Manifest)

Aggregations

Manifest (com.instaclustr.esop.impl.Manifest)1 ManifestAgePathComparator (com.instaclustr.esop.impl.Manifest.ManifestAgePathComparator)1 ManifestEntry (com.instaclustr.esop.impl.ManifestEntry)1 Path (java.nio.file.Path)1 ArrayList (java.util.ArrayList)1