public class DocumentStorageServiceImpl extends Object implements DocumentStorageService
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) |
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()
Copyright © 2001–2018 JBoss by Red Hat. All rights reserved.