Package org.jbpm.document.service.impl
Class DocumentStorageServiceImpl
- java.lang.Object
-
- org.jbpm.document.service.impl.DocumentStorageServiceImpl
-
- All Implemented Interfaces:
DocumentStorageService
public class DocumentStorageServiceImpl extends Object implements DocumentStorageService
This a Sample Implementation of the DocumentStorageService saves the uploaded files on the File System on a folder (by default /docs) and return the complete path to the file that will be stored in the form field property.Check that the user that is running the app has write permissions on the storage folder.
-
-
Constructor Summary
Constructors Constructor Description DocumentStorageServiceImpl()
DocumentStorageServiceImpl(String storagePath)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description Document
buildDocument(String name, long size, Date lastModified, Map<String,String> params)
Generates a Document instance.boolean
deleteDocument(String id)
Deletes the File identified by the given idboolean
deleteDocument(Document doc)
Deletes the File identified by the given idprotected boolean
deleteFile(File file)
protected String
generateUniquePath()
Generates a random path to store the file to avoid overwritting files with the same nameDocument
getDocument(String id)
Method to obtain a File for the given storage idFile
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 contentDocument
saveDocument(Document document, byte[] content)
Method to store the uploaded file on the system
-
-
-
Constructor Detail
-
DocumentStorageServiceImpl
public DocumentStorageServiceImpl(String storagePath)
-
DocumentStorageServiceImpl
public DocumentStorageServiceImpl()
-
-
Method Detail
-
buildDocument
public Document buildDocument(String name, long size, Date lastModified, Map<String,String> params)
Description copied from interface:DocumentStorageService
Generates a Document instance.- Specified by:
buildDocument
in interfaceDocumentStorageService
- Parameters:
name
- The document namesize
- The document sizelastModified
- The lastModified date of the documentparams
- A Mapcontaining the params to create the document. - Returns:
-
saveDocument
public Document saveDocument(Document document, byte[] content)
Description copied from interface:DocumentStorageService
Method to store the uploaded file on the system- Specified by:
saveDocument
in interfaceDocumentStorageService
- Parameters:
document
- The document to store the contentcontent
- The document content- Returns:
- A Document
-
getDocument
public Document getDocument(String id)
Description copied from interface:DocumentStorageService
Method to obtain a File for the given storage id- Specified by:
getDocument
in interfaceDocumentStorageService
- Parameters:
id
- The Document id to obtain the Document- Returns:
- The java.io.File identified with the id
-
deleteDocument
public boolean deleteDocument(String id)
Description copied from interface:DocumentStorageService
Deletes the File identified by the given id- Specified by:
deleteDocument
in interfaceDocumentStorageService
- Parameters:
id
- The Document id to delete- Returns:
- true if it was possible to remove, false if not
-
deleteDocument
public boolean deleteDocument(Document doc)
Description copied from interface:DocumentStorageService
Deletes the File identified by the given id- Specified by:
deleteDocument
in interfaceDocumentStorageService
- Parameters:
doc
- The Document to delete- Returns:
- true if it was possible to remove, false if not
-
deleteFile
protected boolean deleteFile(File file)
-
generateUniquePath
protected String generateUniquePath()
Generates a random path to store the file to avoid overwritting files with the same name- Returns:
- A String containging the path where the document is going to be stored.
-
listDocuments
public List<Document> listDocuments(Integer page, Integer pageSize)
Description copied from interface:DocumentStorageService
Lists available document with paging support.- Specified by:
listDocuments
in interfaceDocumentStorageService
- Parameters:
page
- page to be displayedpageSize
- number of elements to return- Returns:
-
loadContent
public byte[] loadContent(String id)
Description copied from interface:DocumentStorageService
Loads document content- Specified by:
loadContent
in interfaceDocumentStorageService
- Parameters:
id
- unique id of the document- Returns:
- loaded document's content
-
-