Commit 41c0f5af authored by Matija Obreza's avatar Matija Obreza
Browse files

Added RepositoryService#streamFiles method

- Streamed RepositoryFile data
parent 65d3619b
......@@ -19,6 +19,7 @@ package org.genesys.filerepository.persistence;
import java.util.Collection;
import java.util.List;
import java.util.UUID;
import java.util.stream.Stream;
import org.genesys.filerepository.RepositoryPersistence;
import org.genesys.filerepository.model.RepositoryFile;
......@@ -49,6 +50,16 @@ public interface RepositoryFilePersistence extends RepositoryPersistence<Reposit
*/
List<RepositoryFile> findByPath(String repositoryPath);
/**
* Stream by path.
*
* @param repositoryPath the root repository path (includes all subpaths)
* @return the list
*/
@Query("select rf from RepositoryFile rf where rf.path like ?1%")
Stream<RepositoryFile> streamByBasePath(String repositoryPath);
/**
* List repository files at specified paths.
*
......
......@@ -20,6 +20,7 @@ import java.io.IOException;
import java.nio.file.Path;
import java.util.List;
import java.util.UUID;
import java.util.stream.Stream;
import org.genesys.filerepository.InvalidRepositoryFileDataException;
import org.genesys.filerepository.InvalidRepositoryPathException;
......@@ -116,6 +117,14 @@ public interface RepositoryService {
*/
List<RepositoryFile> getFiles(String repositoryPath);
/**
* Stream file info at the specified repository path.
*
* @param repositoryPath the repository path
* @return the files
*/
Stream<RepositoryFile> streamFiles(String repositoryPath);
/**
* Update file metadata. The update is based on the record UUID.
*
......
......@@ -27,6 +27,7 @@ import java.util.ArrayList;
import java.util.List;
import java.util.UUID;
import java.util.stream.Collectors;
import java.util.stream.Stream;
import javax.imageio.ImageIO;
......@@ -302,6 +303,11 @@ public class RepositoryServiceImpl implements RepositoryService, InitializingBea
return repositoryFiles;
}
@Override
public Stream<RepositoryFile> streamFiles(String repositoryPath) {
return repositoryFilePersistence.streamByBasePath(repositoryPath);
}
/*
* (non-Javadoc)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment