@Transactional public class JpaFilePersistenceServiceImpl extends java.lang.Object implements JpaFilePersistenceService
Constructor and Description |
---|
JpaFilePersistenceServiceImpl(JpaFileRepository fileRepository)
Constructor.
|
Modifier and Type | Method and Description |
---|---|
void |
createFileIfNotExists(@NotBlank(message="File path cannot be blank") java.lang.String file)
Attempt to create a file reference in the system if it doesn't already exist.
|
long |
deleteUnusedFiles(@NotNull java.time.Instant createdThreshold)
Delete all files from the database that aren't referenced which were created before the supplied created
threshold.
|
java.util.Optional<FileEntity> |
getFile(@NotBlank(message="File path cannot be blank") java.lang.String file)
Get a reference to the file entity for the given file path string.
|
java.util.Set<FileEntity> |
getFiles(@NotNull java.util.Set<java.lang.String> files)
Get all the file entity references that match the input set of file strings.
|
public JpaFilePersistenceServiceImpl(JpaFileRepository fileRepository)
fileRepository
- The repository to use to perform CRUD operations on filespublic void createFileIfNotExists(@NotBlank(message="File path cannot be blank") @NotBlank(message="File path cannot be blank") java.lang.String file)
createFileIfNotExists
in interface FilePersistenceService
file
- the file to create. Not blank.public long deleteUnusedFiles(@NotNull @NotNull java.time.Instant createdThreshold)
deleteUnusedFiles
in interface FilePersistenceService
createdThreshold
- The instant in time where files created before this time that aren't referenced
will be deleted. Inclusive@Transactional(readOnly=true) public java.util.Optional<FileEntity> getFile(@NotBlank(message="File path cannot be blank") @NotBlank(message="File path cannot be blank") java.lang.String file)
getFile
in interface JpaFilePersistenceService
file
- The path to search forOptional
or Optional.empty()
@Transactional(readOnly=true) public java.util.Set<FileEntity> getFiles(@NotNull @NotNull java.util.Set<java.lang.String> files)
getFiles
in interface JpaFilePersistenceService
files
- the file strings to search forfiles
doesn't exist in database the set
returned will consist of all other discovered files. E.G. files
is ("a", "b", "c") and only "b"
and "c" are in the database the returned set will contain "b" and "c". The method won't fail.