Class DocumentServiceImpl
java.lang.Object
org.bonitasoft.engine.core.document.api.impl.DocumentServiceImpl
- All Implemented Interfaces:
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
ConstructorsConstructorDescriptionDocumentServiceImpl(Recorder recorder, ReadPersistenceService persistenceService, SDocumentDownloadURLProvider urlProvider, ArchiveService archiveService) -
Method Summary
Modifier and TypeMethodDescriptionvoidarchive(AbstractSDocumentMapping docMapping, long archiveDate) archive the specific document mapping in the archive dateattachDocumentToProcessInstance(SDocument document, long processInstanceId, String name, String description) Save a documentattachDocumentToProcessInstance(SDocument document, long processInstanceId, String name, String description, int index) Save a documentvoiddeleteArchivedDocuments(List<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(long documentId) Delete a document by its id.voiddeleteDocument(SLightDocument document) Delete the given document.voiddeleteDocumentContentsForProcessInstance(Long processInstanceId) Delete the document content of a process instance.voiddeleteDocumentsFromProcessInstance(Long processInstanceId) Delete documents and their associated mappings to a specified process instance.voiddeleteMappedDocument(AbstractSMappedDocument mappedDocument) Delete the given document mapping without removing the document content.generateDocumentURL(String name, String contentStorageId) getArchivedDocument(long archivedProcessDocumentId) Retrieve an archived documentgetArchivedVersionOfProcessDocument(long documentId) Get the archived version corresponding to a documentgetDocument(long documentId) Get document by its idbyte[]getDocumentContent(String documentId) Get document content by document idgetDocumentList(String documentName, long processInstanceId, int fromIndex, int numberOfResult) Get a list of document.getDocumentList(String documentName, long processInstanceId, long time) Get a list of document at a given time.getDocumentsOfProcessInstance(long processInstanceId, int fromIndex, int numberPerPage, String field, OrderByType order) Get a list of documents for specific process instance, this can be used for paginationgetMappedDocument(long mappingId) Get document with mapping by its mapping idgetMappedDocument(long processInstanceId, String documentName) Get document with mapping by its name in the specific process instancegetMappedDocument(long processInstanceId, 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, String documentName) Remove the document with the specified process instance and name.voidremoveCurrentVersion(AbstractSMappedDocument document) Remove this document.searchArchivedDocuments(QueryOptions queryOptions) Search all archived documents according to the query criteria.searchArchivedDocumentsSupervisedBy(long userId, QueryOptions queryOptions) Search all archived documents for the specific supervisorsearchDocuments(QueryOptions queryOptions) Search all documents according to the query criteriasearchDocumentsSupervisedBy(long userId, QueryOptions queryOptions) Search all documents for the specific supervisorupdateDocument(long documentId, SDocument sDocument) update the document having the documentId with this new versionupdateDocument(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 Details
-
DocumentServiceImpl
public DocumentServiceImpl(Recorder recorder, ReadPersistenceService persistenceService, SDocumentDownloadURLProvider urlProvider, ArchiveService archiveService)
-
-
Method Details
-
attachDocumentToProcessInstance
public SMappedDocument attachDocumentToProcessInstance(SDocument document, long processInstanceId, String name, 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, String name, 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(Long processInstanceId) throws SBonitaReadException, SObjectModificationException, SObjectNotFoundException Description copied from interface:DocumentServiceDelete documents and their associated mappings to a specified process instance.- Specified by:
deleteDocumentsFromProcessInstancein interfaceDocumentService- Parameters:
processInstanceId- the id of the process instance to delete documents from- Throws:
SBonitaReadException- if an error occurred while getting the documents or their mappingsSObjectModificationException- if an error occurred during the deletionSObjectNotFoundException- if an element does not exist
-
deleteDocumentContentsForProcessInstance
public void deleteDocumentContentsForProcessInstance(Long processInstanceId) throws SBonitaReadException, SObjectModificationException, SObjectNotFoundException Description copied from interface:DocumentServiceDelete the document content of a process instance. It only deletes the content, not the document mapping. Note that to reach the document content, the document mapping must still exist at the time of call: indeed, this is the only way to reach the content from the process instance. So if you need to call this method and also delete the document mappings, ensure this method is called first.- Specified by:
deleteDocumentContentsForProcessInstancein interfaceDocumentService- Parameters:
processInstanceId- the process instance id to delete the document contents from- Throws:
SBonitaReadExceptionSObjectModificationExceptionSObjectNotFoundException
-
generateDocumentURL
- 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, 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, 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
Description 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 List<SMappedDocument> getDocumentsOfProcessInstance(long processInstanceId, int fromIndex, int numberPerPage, 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
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 SBonitaReadException Description 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
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 SBonitaReadException Description 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 SBonitaReadException Description 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 archives and deletes mapping to 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, String documentName) throws SObjectNotFoundException, SObjectModificationException Description copied from interface:DocumentServiceRemove the document with the specified process instance and name.This archives and deletes mapping to 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(long documentId) throws SObjectNotFoundException, SBonitaReadException, SObjectModificationException Description copied from interface:DocumentServiceDelete a document by its id. It does not delete potential mappings, which might throw an error if they are not deleted beforehand.- Specified by:
deleteDocumentin interfaceDocumentService- Parameters:
documentId- the id of the document to delete- Throws:
SObjectNotFoundException- if the document to delete does not existSBonitaReadException- if an error occurred while getting the documentSObjectModificationException- if an error occurred during the deletion
-
deleteDocument
Description copied from interface:DocumentServiceDelete the given document. It does not delete potential mappings, which might throw an error if they are not deleted beforehand.- Specified by:
deleteDocumentin interfaceDocumentService- Parameters:
document- the document to delete- Throws:
SObjectModificationException- if an error occurred during the deletion
-
deleteMappedDocument
public void deleteMappedDocument(AbstractSMappedDocument mappedDocument) throws SObjectModificationException Description copied from interface:DocumentServiceDelete the given document mapping without removing the document content.- Specified by:
deleteMappedDocumentin interfaceDocumentService- Parameters:
mappedDocument- the document mapping to delete- Throws:
SObjectModificationException- if an error occurred during the deletion
-
searchArchivedDocuments
public 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 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
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 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(List<Long> processInstanceIds) throws SBonitaReadException, SRecorderException Description 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 List<SMappedDocument> getDocumentList(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, SRecorderException Description 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 List<AbstractSMappedDocument> getDocumentList(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
-