public class DocumentStorageServiceImpl extends Object implements DocumentStorageService
Check that the user that is running the app has write permissions on the storage folder.
Constructor and Description |
---|
DocumentStorageServiceImpl() |
DocumentStorageServiceImpl(String storagePath) |
Modifier and Type | Method and Description |
---|---|
Document |
buildDocument(String name,
long size,
Date lastModified,
Map<String,String> params)
Generates a Document instance.
|
boolean |
deleteDocument(Document doc)
Deletes the File identified by the given id
|
boolean |
deleteDocument(String id)
Deletes the File identified by the given id
|
protected boolean |
deleteFile(File file) |
protected String |
generateUniquePath()
Generates a random path to store the file to avoid overwritting files with the same name
|
Document |
getDocument(String id)
Method to obtain a File for the given storage id
|
File |
getDocumentContent(Document doc) |
protected File |
getFileByPath(String path) |
List<Document> |
listDocuments(Integer page,
Integer pageSize)
Lists available document with paging support.
|
byte[] |
loadContent(String id)
Loads document content
|
Document |
saveDocument(Document document,
byte[] content)
Method to store the uploaded file on the system
|
public DocumentStorageServiceImpl(String storagePath)
public DocumentStorageServiceImpl()
public Document buildDocument(String name, long size, Date lastModified, Map<String,String> params)
DocumentStorageService
buildDocument
in interface DocumentStorageService
name
- The document namesize
- The document sizelastModified
- The lastModified date of the documentparams
- A Mappublic Document saveDocument(Document document, byte[] content)
DocumentStorageService
saveDocument
in interface DocumentStorageService
document
- The document to store the contentcontent
- The document contentpublic Document getDocument(String id)
DocumentStorageService
getDocument
in interface DocumentStorageService
id
- The Document id to obtain the Documentpublic boolean deleteDocument(String id)
DocumentStorageService
deleteDocument
in interface DocumentStorageService
id
- The Document id to deletepublic boolean deleteDocument(Document doc)
DocumentStorageService
deleteDocument
in interface DocumentStorageService
doc
- The Document to deleteprotected boolean deleteFile(File file)
protected String generateUniquePath()
public List<Document> listDocuments(Integer page, Integer pageSize)
DocumentStorageService
listDocuments
in interface DocumentStorageService
page
- page to be displayedpageSize
- number of elements to returnpublic byte[] loadContent(String id)
DocumentStorageService
loadContent
in interface DocumentStorageService
id
- unique id of the documentCopyright © 2001–2019 JBoss by Red Hat. All rights reserved.