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 void
archive(AbstractSDocumentMapping docMapping, long archiveDate)
archive the specific document mapping in the archive dateSMappedDocument
attachDocumentToProcessInstance(SDocument document, long processInstanceId, java.lang.String name, java.lang.String description)
Save a documentSMappedDocument
attachDocumentToProcessInstance(SDocument document, long processInstanceId, java.lang.String name, java.lang.String description, int index)
Save a documentvoid
deleteArchivedDocuments(java.util.List<java.lang.Long> processInstanceIds)
delete archived documents mapping and documents links to a set of processesvoid
deleteContentOfArchivedDocument(long archivedDocumentId)
Remove the content of an archived document while keeping it's metadata.void
deleteDocument(SLightDocument document)
void
deleteDocumentsFromProcessInstance(java.lang.Long processInstanceId)
Delete documents from a specified process instancejava.lang.String
generateDocumentURL(java.lang.String name, java.lang.String contentStorageId)
SAMappedDocument
getArchivedDocument(long archivedProcessDocumentId)
Retrieve an archived documentSAMappedDocument
getArchivedVersionOfProcessDocument(long documentId)
Get the archived version corresponding to a documentSLightDocument
getDocument(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 paginationSMappedDocument
getMappedDocument(long mappingId)
Get document with mapping by its mapping idSMappedDocument
getMappedDocument(long processInstanceId, java.lang.String documentName)
Get document with mapping by its name in the specific process instanceAbstractSMappedDocument
getMappedDocument(long processInstanceId, java.lang.String documentName, long time)
Get name specified document archived in a certain time in the process instancelong
getNumberOfArchivedDocuments(QueryOptions queryOptions)
Get total number of archived documents according to the query criterialong
getNumberOfArchivedDocumentsSupervisedBy(long userId, QueryOptions queryOptions)
Get total number of archived documents for the specific supervisorlong
getNumberOfDocuments(QueryOptions queryOptions)
Get total number of document according to the query criterialong
getNumberOfDocumentsOfProcessInstance(long processInstanceId)
Get total number of documents in the specific process instancelong
getNumberOfDocumentsSupervisedBy(long userId, QueryOptions queryOptions)
Get total number of documents for the specific supervisorvoid
removeCurrentVersion(long processInstanceId, java.lang.String documentName)
Remove the document with the specified process instance and namevoid
removeCurrentVersion(AbstractSMappedDocument document)
Remove this document.void
removeDocument(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 supervisorSMappedDocument
updateDocument(long documentId, SDocument sDocument)
update the document having the documentId with this new versionSMappedDocument
updateDocument(AbstractSDocumentMapping documentToUpdate, SDocument sDocument)
void
updateDocumentIndex(AbstractSDocumentMapping mappedDocument, int index)
update the index of a document inside the listvoid
updateDocumentOfList(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:DocumentService
Save a document- Specified by:
attachDocumentToProcessInstance
in 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:DocumentService
Save a document- Specified by:
attachDocumentToProcessInstance
in 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:
updateDocumentOfList
in 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:DocumentService
update the index of a document inside the list- Specified by:
updateDocumentIndex
in interfaceDocumentService
- Parameters:
mappedDocument
- the document to updateindex
- the new index- Throws:
SObjectModificationException
-
deleteDocumentsFromProcessInstance
public void deleteDocumentsFromProcessInstance(java.lang.Long processInstanceId) throws SBonitaReadException, SObjectModificationException
Description copied from interface:DocumentService
Delete documents from a specified process instance- Specified by:
deleteDocumentsFromProcessInstance
in interfaceDocumentService
- Throws:
SBonitaReadException
SObjectModificationException
-
generateDocumentURL
public java.lang.String generateDocumentURL(java.lang.String name, java.lang.String contentStorageId)
- Specified by:
generateDocumentURL
in interfaceDocumentService
-
getArchivedDocument
public SAMappedDocument getArchivedDocument(long archivedProcessDocumentId) throws SObjectNotFoundException
Description copied from interface:DocumentService
Retrieve an archived document- Specified by:
getArchivedDocument
in 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:DocumentService
Get the archived version corresponding to a document- Specified by:
getArchivedVersionOfProcessDocument
in 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:DocumentService
Get document by its id- Specified by:
getDocument
in interfaceDocumentService
- Parameters:
documentId
- identifier of document- Returns:
- an SDocumentMapping object with id corresponding to the parameter
- Throws:
SObjectNotFoundException
SBonitaReadException
-
getMappedDocument
public SMappedDocument getMappedDocument(long processInstanceId, java.lang.String documentName) throws SObjectNotFoundException, SBonitaReadException
Description copied from interface:DocumentService
Get document with mapping by its name in the specific process instance- Specified by:
getMappedDocument
in interfaceDocumentService
- Parameters:
processInstanceId
- identifier of process instancedocumentName
- name of process document- Returns:
- the corresponding SDocumentMapping object
- Throws:
SObjectNotFoundException
SBonitaReadException
-
getMappedDocument
public AbstractSMappedDocument getMappedDocument(long processInstanceId, java.lang.String documentName, long time) throws SObjectNotFoundException, SBonitaReadException
Description copied from interface:DocumentService
Get name specified document archived in a certain time in the process instance- Specified by:
getMappedDocument
in 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:
SObjectNotFoundException
SBonitaReadException
-
getDocumentContent
public byte[] getDocumentContent(java.lang.String documentId) throws SObjectNotFoundException
Description copied from interface:DocumentService
Get document content by document id- Specified by:
getDocumentContent
in 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:DocumentService
Get document with mapping by its mapping id- Specified by:
getMappedDocument
in interfaceDocumentService
- Parameters:
mappingId
- identifier of the mapping of the document- Returns:
- an SDocumentMapping object with id corresponding to the parameter
- Throws:
SObjectNotFoundException
SBonitaReadException
-
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:DocumentService
Get a list of documents for specific process instance, this can be used for pagination- Specified by:
getDocumentsOfProcessInstance
in 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:DocumentService
Get total number of archived documents according to the query criteria- Specified by:
getNumberOfArchivedDocuments
in 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:DocumentService
Get total number of archived documents for the specific supervisor- Specified by:
getNumberOfArchivedDocumentsSupervisedBy
in 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:DocumentService
Get total number of document according to the query criteria- Specified by:
getNumberOfDocuments
in 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:DocumentService
Get total number of documents in the specific process instance- Specified by:
getNumberOfDocumentsOfProcessInstance
in 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:DocumentService
Get total number of documents for the specific supervisor- Specified by:
getNumberOfDocumentsSupervisedBy
in 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:DocumentService
Remove 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:
removeCurrentVersion
in interfaceDocumentService
- Parameters:
document
- the document mapping to remove- Throws:
SObjectModificationException
-
removeCurrentVersion
public void removeCurrentVersion(long processInstanceId, java.lang.String documentName) throws SObjectNotFoundException, SObjectModificationException
Description copied from interface:DocumentService
Remove 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:
removeCurrentVersion
in interfaceDocumentService
- Parameters:
processInstanceId
- id of the process having the documentdocumentName
- name of the document- Throws:
SObjectNotFoundException
SObjectModificationException
-
deleteDocument
public void deleteDocument(SLightDocument document) throws SObjectModificationException
- Specified by:
deleteDocument
in interfaceDocumentService
- Throws:
SObjectModificationException
-
removeDocument
public void removeDocument(AbstractSMappedDocument mappedDocument) throws SObjectModificationException
- Specified by:
removeDocument
in interfaceDocumentService
- Throws:
SObjectModificationException
-
searchArchivedDocuments
public java.util.List<SAMappedDocument> searchArchivedDocuments(QueryOptions queryOptions) throws SBonitaReadException
Description copied from interface:DocumentService
Search all archived documents according to the query criteria.- Specified by:
searchArchivedDocuments
in 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:DocumentService
Search all archived documents for the specific supervisor- Specified by:
searchArchivedDocumentsSupervisedBy
in 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:DocumentService
Search all documents according to the query criteria- Specified by:
searchDocuments
in 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:DocumentService
Search all documents for the specific supervisor- Specified by:
searchDocumentsSupervisedBy
in 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, SRecorderException
Description copied from interface:DocumentService
delete archived documents mapping and documents links to a set of processes- Specified by:
deleteArchivedDocuments
in interfaceDocumentService
- Parameters:
processInstanceIds
- ids of the source process instances- Throws:
SBonitaReadException
SRecorderException
-
archive
public void archive(AbstractSDocumentMapping docMapping, long archiveDate) throws SObjectModificationException
Description copied from interface:DocumentService
archive the specific document mapping in the archive date- Specified by:
archive
in 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:DocumentService
Get a list of document. if there is no document in the list returns an empty list- Specified by:
getDocumentList
in 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:DocumentService
Remove 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:
deleteContentOfArchivedDocument
in interfaceDocumentService
- Parameters:
archivedDocumentId
- the id of the archived document to remove content on- Throws:
SObjectNotFoundException
- if the document to delete does not existSBonitaReadException
SRecorderException
-
updateDocument
public SMappedDocument updateDocument(long documentId, SDocument sDocument) throws SBonitaReadException, SObjectNotFoundException, SObjectModificationException
Description copied from interface:DocumentService
update the document having the documentId with this new version- Specified by:
updateDocument
in interfaceDocumentService
- Parameters:
documentId
- the id of the document to updatesDocument
- the new version of the document @return- Throws:
SBonitaReadException
SObjectNotFoundException
SObjectModificationException
-
updateDocument
public SMappedDocument updateDocument(AbstractSDocumentMapping documentToUpdate, SDocument sDocument) throws SObjectModificationException
- Specified by:
updateDocument
in 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:DocumentService
Get 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:
getDocumentList
in 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
-
-