Class DocumentServiceImpl
- java.lang.Object
-
- org.bonitasoft.engine.core.document.api.impl.DocumentServiceImpl
-
- All Implemented Interfaces:
DocumentService
public class DocumentServiceImpl extends java.lang.Object implements DocumentService
- Author:
- Nicolas Chabanoles, Matthieu Chaffotte, Celine Souchet, Baptiste Mesta
-
-
Field Summary
-
Fields inherited from interface org.bonitasoft.engine.core.document.api.DocumentService
DOCUMENT, DOCUMENTMAPPING, SUPERVISED_BY
-
-
Constructor Summary
Constructors Constructor Description DocumentServiceImpl(Recorder recorder, ReadPersistenceService persistenceService, SDocumentDownloadURLProvider urlProvider, ArchiveService archiveService)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidarchive(AbstractSDocumentMapping docMapping, long archiveDate)archive the specific document mapping in the archive dateSMappedDocumentattachDocumentToProcessInstance(SDocument document, long processInstanceId, java.lang.String name, java.lang.String description)Save a documentSMappedDocumentattachDocumentToProcessInstance(SDocument document, long processInstanceId, java.lang.String name, java.lang.String description, int index)Save a documentvoiddeleteArchivedDocuments(java.util.List<java.lang.Long> processInstanceIds)delete archived documents mapping and documents links to a set of processesvoiddeleteContentOfArchivedDocument(long archivedDocumentId)Remove the content of an archived document while keeping it's metadata.voiddeleteDocument(SLightDocument document)voiddeleteDocumentsFromProcessInstance(java.lang.Long processInstanceId)Delete documents from a specified process instancejava.lang.StringgenerateDocumentURL(java.lang.String name, java.lang.String contentStorageId)SAMappedDocumentgetArchivedDocument(long archivedProcessDocumentId)Retrieve an archived documentSAMappedDocumentgetArchivedVersionOfProcessDocument(long documentId)Get the archived version corresponding to a documentSLightDocumentgetDocument(long documentId)Get document by its idbyte[]getDocumentContent(java.lang.String documentId)Get document content by document idjava.util.List<SMappedDocument>getDocumentList(java.lang.String documentName, long processInstanceId, int fromIndex, int numberOfResult)Get a list of document.java.util.List<AbstractSMappedDocument>getDocumentList(java.lang.String documentName, long processInstanceId, long time)Get a list of document at a given time.java.util.List<SMappedDocument>getDocumentsOfProcessInstance(long processInstanceId, int fromIndex, int numberPerPage, java.lang.String field, OrderByType order)Get a list of documents for specific process instance, this can be used for paginationSMappedDocumentgetMappedDocument(long mappingId)Get document with mapping by its mapping idSMappedDocumentgetMappedDocument(long processInstanceId, java.lang.String documentName)Get document with mapping by its name in the specific process instanceAbstractSMappedDocumentgetMappedDocument(long processInstanceId, java.lang.String documentName, long time)Get name specified document archived in a certain time in the process instancelonggetNumberOfArchivedDocuments(QueryOptions queryOptions)Get total number of archived documents according to the query criterialonggetNumberOfArchivedDocumentsSupervisedBy(long userId, QueryOptions queryOptions)Get total number of archived documents for the specific supervisorlonggetNumberOfDocuments(QueryOptions queryOptions)Get total number of document according to the query criterialonggetNumberOfDocumentsOfProcessInstance(long processInstanceId)Get total number of documents in the specific process instancelonggetNumberOfDocumentsSupervisedBy(long userId, QueryOptions queryOptions)Get total number of documents for the specific supervisorvoidremoveCurrentVersion(long processInstanceId, java.lang.String documentName)Remove the document with the specified process instance and namevoidremoveCurrentVersion(AbstractSMappedDocument document)Remove this document.voidremoveDocument(AbstractSMappedDocument mappedDocument)java.util.List<SAMappedDocument>searchArchivedDocuments(QueryOptions queryOptions)Search all archived documents according to the query criteria.java.util.List<SAMappedDocument>searchArchivedDocumentsSupervisedBy(long userId, QueryOptions queryOptions)Search all archived documents for the specific supervisorjava.util.List<SMappedDocument>searchDocuments(QueryOptions queryOptions)Search all documents according to the query criteriajava.util.List<SMappedDocument>searchDocumentsSupervisedBy(long userId, QueryOptions queryOptions)Search all documents for the specific supervisorSMappedDocumentupdateDocument(long documentId, SDocument sDocument)update the document having the documentId with this new versionSMappedDocumentupdateDocument(AbstractSDocumentMapping documentToUpdate, SDocument sDocument)voidupdateDocumentIndex(AbstractSDocumentMapping mappedDocument, int index)update the index of a document inside the listvoidupdateDocumentOfList(AbstractSDocumentMapping mappedDocument, SDocument document, int index)
-
-
-
Constructor Detail
-
DocumentServiceImpl
public DocumentServiceImpl(Recorder recorder, ReadPersistenceService persistenceService, SDocumentDownloadURLProvider urlProvider, ArchiveService archiveService)
-
-
Method Detail
-
attachDocumentToProcessInstance
public SMappedDocument attachDocumentToProcessInstance(SDocument document, long processInstanceId, java.lang.String name, java.lang.String description) throws SObjectCreationException
Description copied from interface:DocumentServiceSave a document- Specified by:
attachDocumentToProcessInstancein interfaceDocumentService- Parameters:
document- the document to storeprocessInstanceId- the process instance id to attach the document to- Returns:
- The document image from database
- Throws:
SObjectCreationException- when the storage has failed
-
attachDocumentToProcessInstance
public SMappedDocument attachDocumentToProcessInstance(SDocument document, long processInstanceId, java.lang.String name, java.lang.String description, int index) throws SObjectCreationException, SObjectAlreadyExistsException
Description copied from interface:DocumentServiceSave a document- Specified by:
attachDocumentToProcessInstancein interfaceDocumentService- Parameters:
document- the document to storeprocessInstanceId- the process instance id to attach the document toindex- the index in the list of document- Returns:
- The document image from database
- Throws:
SObjectCreationException- when the storage has failedSObjectAlreadyExistsException
-
updateDocumentOfList
public void updateDocumentOfList(AbstractSDocumentMapping mappedDocument, SDocument document, int index) throws SObjectModificationException
- Specified by:
updateDocumentOfListin interfaceDocumentService- Parameters:
mappedDocument- the document to updatedocument- the new contentindex- the new index- Throws:
SObjectModificationException
-
updateDocumentIndex
public void updateDocumentIndex(AbstractSDocumentMapping mappedDocument, int index) throws SObjectModificationException
Description copied from interface:DocumentServiceupdate the index of a document inside the list- Specified by:
updateDocumentIndexin interfaceDocumentService- Parameters:
mappedDocument- the document to updateindex- the new index- Throws:
SObjectModificationException
-
deleteDocumentsFromProcessInstance
public void deleteDocumentsFromProcessInstance(java.lang.Long processInstanceId) throws SBonitaReadException, SObjectModificationExceptionDescription copied from interface:DocumentServiceDelete documents from a specified process instance- Specified by:
deleteDocumentsFromProcessInstancein interfaceDocumentService- Throws:
SBonitaReadExceptionSObjectModificationException
-
generateDocumentURL
public java.lang.String generateDocumentURL(java.lang.String name, java.lang.String contentStorageId)- Specified by:
generateDocumentURLin interfaceDocumentService
-
getArchivedDocument
public SAMappedDocument getArchivedDocument(long archivedProcessDocumentId) throws SObjectNotFoundException
Description copied from interface:DocumentServiceRetrieve an archived document- Specified by:
getArchivedDocumentin interfaceDocumentService- Parameters:
archivedProcessDocumentId- the id of the archived document- Returns:
- the corresponding archive
- Throws:
SObjectNotFoundException- when the archive does not exist
-
getArchivedVersionOfProcessDocument
public SAMappedDocument getArchivedVersionOfProcessDocument(long documentId) throws SObjectNotFoundException
Description copied from interface:DocumentServiceGet the archived version corresponding to a document- Specified by:
getArchivedVersionOfProcessDocumentin interfaceDocumentService- Parameters:
documentId- identifier of process document- Returns:
- the archive of the corresponding document
- Throws:
SObjectNotFoundException- when the document does not exist
-
getDocument
public SLightDocument getDocument(long documentId) throws SObjectNotFoundException, SBonitaReadException
Description copied from interface:DocumentServiceGet document by its id- Specified by:
getDocumentin interfaceDocumentService- Parameters:
documentId- identifier of document- Returns:
- an SDocumentMapping object with id corresponding to the parameter
- Throws:
SObjectNotFoundExceptionSBonitaReadException
-
getMappedDocument
public SMappedDocument getMappedDocument(long processInstanceId, java.lang.String documentName) throws SObjectNotFoundException, SBonitaReadException
Description copied from interface:DocumentServiceGet document with mapping by its name in the specific process instance- Specified by:
getMappedDocumentin interfaceDocumentService- Parameters:
processInstanceId- identifier of process instancedocumentName- name of process document- Returns:
- the corresponding SDocumentMapping object
- Throws:
SObjectNotFoundExceptionSBonitaReadException
-
getMappedDocument
public AbstractSMappedDocument getMappedDocument(long processInstanceId, java.lang.String documentName, long time) throws SObjectNotFoundException, SBonitaReadException
Description copied from interface:DocumentServiceGet name specified document archived in a certain time in the process instance- Specified by:
getMappedDocumentin interfaceDocumentService- Parameters:
processInstanceId- identifier of process instancedocumentName- name of documenttime- the archived time of document- Returns:
- an SDocumentMapping object archived in the specific time or not archived
- Throws:
SObjectNotFoundExceptionSBonitaReadException
-
getDocumentContent
public byte[] getDocumentContent(java.lang.String documentId) throws SObjectNotFoundExceptionDescription copied from interface:DocumentServiceGet document content by document id- Specified by:
getDocumentContentin interfaceDocumentService- Parameters:
documentId- identifier of the document- Returns:
- document content
- Throws:
SObjectNotFoundException
-
getMappedDocument
public SMappedDocument getMappedDocument(long mappingId) throws SObjectNotFoundException, SBonitaReadException
Description copied from interface:DocumentServiceGet document with mapping by its mapping id- Specified by:
getMappedDocumentin interfaceDocumentService- Parameters:
mappingId- identifier of the mapping of the document- Returns:
- an SDocumentMapping object with id corresponding to the parameter
- Throws:
SObjectNotFoundExceptionSBonitaReadException
-
getDocumentsOfProcessInstance
public java.util.List<SMappedDocument> getDocumentsOfProcessInstance(long processInstanceId, int fromIndex, int numberPerPage, java.lang.String field, OrderByType order) throws SBonitaReadException
Description copied from interface:DocumentServiceGet a list of documents for specific process instance, this can be used for pagination- Specified by:
getDocumentsOfProcessInstancein interfaceDocumentService- Parameters:
processInstanceId- identifier of process instancefromIndex- Index of the record to be retrieved from. First record has index 0numberPerPage- Number of result we want to get. Maximum number of result returned- Returns:
- a list of SDocumentMapping objects
- Throws:
SBonitaReadException
-
getNumberOfArchivedDocuments
public long getNumberOfArchivedDocuments(QueryOptions queryOptions) throws SBonitaReadException
Description copied from interface:DocumentServiceGet total number of archived documents according to the query criteria- Specified by:
getNumberOfArchivedDocumentsin interfaceDocumentService- Parameters:
queryOptions- a QueryOptions object containing some query conditions- Returns:
- number of archived documents
- Throws:
SBonitaReadException
-
getNumberOfArchivedDocumentsSupervisedBy
public long getNumberOfArchivedDocumentsSupervisedBy(long userId, QueryOptions queryOptions) throws SBonitaReadExceptionDescription copied from interface:DocumentServiceGet total number of archived documents for the specific supervisor- Specified by:
getNumberOfArchivedDocumentsSupervisedByin interfaceDocumentService- Parameters:
userId- identifier of supervisor userqueryOptions- a QueryOptions object containing some query conditions- Returns:
- number of archived documents for the specific supervisor
- Throws:
SBonitaReadException
-
getNumberOfDocuments
public long getNumberOfDocuments(QueryOptions queryOptions) throws SBonitaReadException
Description copied from interface:DocumentServiceGet total number of document according to the query criteria- Specified by:
getNumberOfDocumentsin interfaceDocumentService- Parameters:
queryOptions- a QueryOptions object containing some query conditions- Returns:
- number of document satisfied to the query criteria
- Throws:
SBonitaReadException
-
getNumberOfDocumentsOfProcessInstance
public long getNumberOfDocumentsOfProcessInstance(long processInstanceId) throws SBonitaReadExceptionDescription copied from interface:DocumentServiceGet total number of documents in the specific process instance- Specified by:
getNumberOfDocumentsOfProcessInstancein interfaceDocumentService- Parameters:
processInstanceId- identifier of process instance- Returns:
- number of documents in the process instance
- Throws:
SBonitaReadException
-
getNumberOfDocumentsSupervisedBy
public long getNumberOfDocumentsSupervisedBy(long userId, QueryOptions queryOptions) throws SBonitaReadExceptionDescription copied from interface:DocumentServiceGet total number of documents for the specific supervisor- Specified by:
getNumberOfDocumentsSupervisedByin interfaceDocumentService- Parameters:
userId- identifier of supervisor userqueryOptions- a QueryOptions object containing some query conditions- Returns:
- number of documents for the specific supervisor
- Throws:
SBonitaReadException
-
removeCurrentVersion
public void removeCurrentVersion(AbstractSMappedDocument document) throws SObjectModificationException
Description copied from interface:DocumentServiceRemove this document.this archive and delete mapping on the process, i.e. the content of the document itself will be kept in database, use
DocumentService.deleteContentOfArchivedDocument(long)to delete the content- Specified by:
removeCurrentVersionin interfaceDocumentService- Parameters:
document- the document mapping to remove- Throws:
SObjectModificationException
-
removeCurrentVersion
public void removeCurrentVersion(long processInstanceId, java.lang.String documentName) throws SObjectNotFoundException, SObjectModificationExceptionDescription copied from interface:DocumentServiceRemove the document with the specified process instance and namethis archive and delete mapping on the process, i.e. the content of the document itself will be kept in database, use
DocumentService.deleteContentOfArchivedDocument(long)to delete the content- Specified by:
removeCurrentVersionin interfaceDocumentService- Parameters:
processInstanceId- id of the process having the documentdocumentName- name of the document- Throws:
SObjectNotFoundExceptionSObjectModificationException
-
deleteDocument
public void deleteDocument(SLightDocument document) throws SObjectModificationException
- Specified by:
deleteDocumentin interfaceDocumentService- Throws:
SObjectModificationException
-
removeDocument
public void removeDocument(AbstractSMappedDocument mappedDocument) throws SObjectModificationException
- Specified by:
removeDocumentin interfaceDocumentService- Throws:
SObjectModificationException
-
searchArchivedDocuments
public java.util.List<SAMappedDocument> searchArchivedDocuments(QueryOptions queryOptions) throws SBonitaReadException
Description copied from interface:DocumentServiceSearch all archived documents according to the query criteria.- Specified by:
searchArchivedDocumentsin interfaceDocumentService- Parameters:
queryOptions- a QueryOptions object containing some query conditions- Returns:
- a list of SADocumentMapping objects
- Throws:
SBonitaReadException
-
searchArchivedDocumentsSupervisedBy
public java.util.List<SAMappedDocument> searchArchivedDocumentsSupervisedBy(long userId, QueryOptions queryOptions) throws SBonitaReadException
Description copied from interface:DocumentServiceSearch all archived documents for the specific supervisor- Specified by:
searchArchivedDocumentsSupervisedByin interfaceDocumentService- Parameters:
userId- identifier of supervisor userqueryOptions- a QueryOptions object containing some query conditions- Returns:
- a list of SADocumentMapping objects
- Throws:
SBonitaReadException
-
searchDocuments
public java.util.List<SMappedDocument> searchDocuments(QueryOptions queryOptions) throws SBonitaReadException
Description copied from interface:DocumentServiceSearch all documents according to the query criteria- Specified by:
searchDocumentsin interfaceDocumentService- Parameters:
queryOptions- a QueryOptions object containing some query conditions- Returns:
- a list of SDocumentMapping objects
- Throws:
SBonitaReadException
-
searchDocumentsSupervisedBy
public java.util.List<SMappedDocument> searchDocumentsSupervisedBy(long userId, QueryOptions queryOptions) throws SBonitaReadException
Description copied from interface:DocumentServiceSearch all documents for the specific supervisor- Specified by:
searchDocumentsSupervisedByin interfaceDocumentService- Parameters:
userId- identifier of supervisor userqueryOptions- a QueryOptions object containing some query conditions- Returns:
- a list of SDocumentMapping objects
- Throws:
SBonitaReadException
-
deleteArchivedDocuments
public void deleteArchivedDocuments(java.util.List<java.lang.Long> processInstanceIds) throws SBonitaReadException, SRecorderExceptionDescription copied from interface:DocumentServicedelete archived documents mapping and documents links to a set of processes- Specified by:
deleteArchivedDocumentsin interfaceDocumentService- Parameters:
processInstanceIds- ids of the source process instances- Throws:
SBonitaReadExceptionSRecorderException
-
archive
public void archive(AbstractSDocumentMapping docMapping, long archiveDate) throws SObjectModificationException
Description copied from interface:DocumentServicearchive the specific document mapping in the archive date- Specified by:
archivein interfaceDocumentService- Parameters:
docMapping- document mapping will be archivedarchiveDate- the archive time- Throws:
SObjectModificationException
-
getDocumentList
public java.util.List<SMappedDocument> getDocumentList(java.lang.String documentName, long processInstanceId, int fromIndex, int numberOfResult) throws SBonitaReadException
Description copied from interface:DocumentServiceGet a list of document. if there is no document in the list returns an empty list- Specified by:
getDocumentListin interfaceDocumentService- Parameters:
documentName- the name of the document listprocessInstanceId- the id of the process instance that contains the listfromIndex- pagination parameternumberOfResult- pagination parameter- Returns:
- the list of document
- Throws:
SBonitaReadException
-
deleteContentOfArchivedDocument
public void deleteContentOfArchivedDocument(long archivedDocumentId) throws SObjectNotFoundException, SBonitaReadException, SRecorderExceptionDescription copied from interface:DocumentServiceRemove the content of an archived document while keeping it's metadata.After calling this method you will not be able to retrieve the content of the document since it will be erased from the database. This method can be useful for keeping history of a document without overloading the database.
- Specified by:
deleteContentOfArchivedDocumentin interfaceDocumentService- Parameters:
archivedDocumentId- the id of the archived document to remove content on- Throws:
SObjectNotFoundException- if the document to delete does not existSBonitaReadExceptionSRecorderException
-
updateDocument
public SMappedDocument updateDocument(long documentId, SDocument sDocument) throws SBonitaReadException, SObjectNotFoundException, SObjectModificationException
Description copied from interface:DocumentServiceupdate the document having the documentId with this new version- Specified by:
updateDocumentin interfaceDocumentService- Parameters:
documentId- the id of the document to updatesDocument- the new version of the document @return- Throws:
SBonitaReadExceptionSObjectNotFoundExceptionSObjectModificationException
-
updateDocument
public SMappedDocument updateDocument(AbstractSDocumentMapping documentToUpdate, SDocument sDocument) throws SObjectModificationException
- Specified by:
updateDocumentin interfaceDocumentService- Parameters:
documentToUpdate- the document mapping to udpatesDocument- the value to set th emapping with- Returns:
- the updated document mapping
- Throws:
SObjectModificationException
-
getDocumentList
public java.util.List<AbstractSMappedDocument> getDocumentList(java.lang.String documentName, long processInstanceId, long time) throws SBonitaReadException
Description copied from interface:DocumentServiceGet a list of document at a given time. if there is no document in the list returns an empty list.elements are taken from archive and from non archived mapping if the process is still running
- Specified by:
getDocumentListin interfaceDocumentService- Parameters:
documentName- the name of the document listprocessInstanceId- the id of the process instance that contains the listtime- time when the list was like that- Returns:
- the list of document
- Throws:
SBonitaReadException
-
-