@Service public class DefaultFileRepository extends Object implements FileRepository
FileRepository
interface - files are stored in the file system.Constructor and Description |
---|
DefaultFileRepository() |
Modifier and Type | Method and Description |
---|---|
void |
checkDirs() |
void |
commitFile(String fileId,
String fileName,
FileContentTypeExtEnum contentType,
List<String> subFolders)
Commits saving file - the file will be moved from temporary folder to the target place.
|
protected String |
getFileName(String fileName,
FileContentTypeExtEnum contentType)
Gets file name that the file will be saved with.
|
protected String |
getNewFileId()
Gets new unique file identifier.
|
boolean |
isFileIdValid(String fileId)
Is specified file ID valid identifier?
In other words is there file with specified identifier?
|
String |
saveTempFile(OutputStreamWriterCallback writerCallback)
Saves temporary file in the repository.
|
@PostConstruct public void checkDirs()
public String saveTempFile(OutputStreamWriterCallback writerCallback)
FileRepository
saveTempFile
in interface FileRepository
writerCallback
- the callback for writing file to specified output streampublic boolean isFileIdValid(String fileId)
FileRepository
isFileIdValid
in interface FileRepository
fileId
- the file IDtrue
if file is valid otherwise false
public void commitFile(String fileId, String fileName, FileContentTypeExtEnum contentType, List<String> subFolders)
FileRepository
commitFile
in interface FileRepository
fileId
- the file identifier from FileRepository.saveTempFile(OutputStreamWriterCallback)
fileName
- the original file namecontentType
- the file content typesubFolders
- the collection of sub-folders which determine where is the target folder for moving the fileprotected String getFileName(String fileName, FileContentTypeExtEnum contentType)
fileName
- the original file name (also with extension)contentType
- the content typeprotected String getNewFileId()
Copyright © 2018 Pivotal Software, Inc.. All rights reserved.