Package com.logicaldoc.core.document
Class DocumentManagerImpl
java.lang.Object
com.logicaldoc.core.document.DocumentManagerImpl
- All Implemented Interfaces:
DocumentManager
Basic Implementation of
DocumentManager
- Since:
- 3.5
- Author:
- Marco Meschieri - LogicalDOC
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
archiveDocuments
(long[] docIds, DocumentHistory transaction) Archives all the documents in a folder's treelong
archiveFolder
(long folderId, DocumentHistory transaction) Archives all the documents in a folder's treevoid
changeIndexingStatus
(Document doc, int status) Utility method used to declare that: the document must be taken into consideration by the indexer (status =AbstractDocument.INDEX_TO_INDEX
. the document must be taken into consideration by the indexer for the metadata only(status =AbstractDocument.INDEX_TO_INDEX_METADATA
. the document must not be taken into consideration by the indexer (status =AbstractDocument.INDEX_SKIP
).void
checkin
(long docId, File file, String filename, boolean release, AbstractDocument docVO, DocumentHistory transaction) Checks in the given documentvoid
checkin
(long docId, InputStream content, String filename, boolean release, AbstractDocument docVO, DocumentHistory transaction) Checks in the given documentvoid
checkout
(long docId, DocumentHistory transaction) Checks out the given documentcopyToFolder
(Document doc, Folder folder, DocumentHistory transaction, boolean links, boolean notes) Copy a document to the specified folder.int
countPages
(Document doc) Counts the number of pages of a documentcreate
(File file, Document docVO, DocumentHistory transaction) Creates a new Document.create
(InputStream content, Document docVO, DocumentHistory transaction) Creates a new Document.createAlias
(Document doc, Folder folder, String aliasType, DocumentHistory transaction) Create an alias(shortcut) associated to the given doc to the specified folder.createTicket
(Ticket ticket, DocumentHistory transaction) Creates a new ticket.void
deleteFromIndex
(Document doc) Utility method for document removal from indexdeleteVersion
(long versionId, DocumentHistory transaction) Deletes a specific version.int
enforceFilesIntoFolderStorage
(long rootFolderId, DocumentHistory transaction) Moves all the files of the documents in the given tree from it's original location to the storage defined in the owning folderlong
index
(long docId, String content, DocumentHistory transaction) Re-indexes an existing document in the full-text index.void
lock
(long docId, int status, DocumentHistory transaction) Locks the given documentvoid
makeImmutable
(long docId, DocumentHistory transaction) Marks the document, with the given docId, as immutable and save the given document historymerge
(Collection<Document> documents, long targetFolderId, String fileName, DocumentHistory transaction) Merges a set of documents into a single PDF filevoid
moveToFolder
(Document doc, Folder folder, DocumentHistory transaction) Moves a document to the specified folder.parseDocument
(Document doc, String fileVersion) Retrieves the document's content as a stringvoid
promoteVersion
(long docId, String version, DocumentHistory transaction) Promotes an old version to the current default one.void
rename
(long docId, String newName, DocumentHistory transaction) Rename an existing document filename.replaceAlias
(long aliasId, DocumentHistory transaction) Replaces an alias with a copy of the original filevoid
replaceFile
(long docId, String fileVersion, File newFile, DocumentHistory transaction) Replaces the file of a given versionvoid
replaceFile
(long docId, String fileVersion, InputStream content, DocumentHistory transaction) Replaces the file of a given versionvoid
setConfig
(ContextProperties config) void
setDocumentDAO
(DocumentDAO documentDAO) void
setDocumentLinkDAO
(DocumentLinkDAO documentLinkDAO) void
setDocumentNoteDAO
(DocumentNoteDAO documentNoteDAO) void
setFolderDAO
(FolderDAO folderDAO) void
setIndexer
(SearchEngine indexer) void
setListenerManager
(DocumentListenerManager listenerManager) void
void
setTemplateDAO
(TemplateDAO templateDAO) void
setTicketDAO
(TicketDAO ticketDAO) void
setUserDAO
(UserDAO userDAO) void
setVersionDAO
(VersionDAO versionDAO) void
unlock
(long docId, DocumentHistory transaction) UNChecks out the given documentboolean
Tries to unprotect a document, If the password is correct, the document stays unprotected for all the duration of the session.void
update
(Document document, Document docVO, DocumentHistory transaction) Updates an existing document and marks it to be re-indexed
-
Constructor Details
-
DocumentManagerImpl
public DocumentManagerImpl()
-
-
Method Details
-
setListenerManager
-
setDocumentDAO
-
setTemplateDAO
-
setIndexer
-
setVersionDAO
-
setStorer
-
setConfig
-
replaceFile
public void replaceFile(long docId, String fileVersion, InputStream content, DocumentHistory transaction) throws IOException, PersistenceException Description copied from interface:DocumentManager
Replaces the file of a given version- Specified by:
replaceFile
in interfaceDocumentManager
- Parameters:
docId
- the document to be updatedfileVersion
- the file versioncontent
- the file to usetransaction
- entry to log the event (set the user)- Throws:
IOException
- I/O errorPersistenceException
- error at data layer
-
replaceFile
public void replaceFile(long docId, String fileVersion, File newFile, DocumentHistory transaction) throws PersistenceException, IOException Description copied from interface:DocumentManager
Replaces the file of a given version- Specified by:
replaceFile
in interfaceDocumentManager
- Parameters:
docId
- the document to be updatedfileVersion
- the file versionnewFile
- the file to usetransaction
- entry to log the event (set the user)- Throws:
PersistenceException
- error at data layerIOException
- I/O error
-
checkin
public void checkin(long docId, File file, String filename, boolean release, AbstractDocument docVO, DocumentHistory transaction) throws PersistenceException Description copied from interface:DocumentManager
Checks in the given document- Specified by:
checkin
in interfaceDocumentManager
- Parameters:
docId
- the document to be checked infile
- of the new document versionfilename
- new filename (can also be the old one)release
- True if this is a new release(eg: 2.0) rather than a subversion(eg: 1.1)docVO
- The value object containing document's metadata applied during the checkin (optional)transaction
- entry to log the event, set the user and comment- Throws:
PersistenceException
- error at data layer
-
checkin
public void checkin(long docId, InputStream content, String filename, boolean release, AbstractDocument docVO, DocumentHistory transaction) throws IOException, PersistenceException Description copied from interface:DocumentManager
Checks in the given document- Specified by:
checkin
in interfaceDocumentManager
- Parameters:
docId
- the document to be checked incontent
- input stream pointing to the new document versionfilename
- new filename (can also be the old one)release
- True if this is a new release(eg: 2.0) rather than a subversion(eg: 1.1)docVO
- The value object containing document's metadata applied during the checkin (optional)transaction
- entry to log the event, set the user and comment- Throws:
IOException
- I/O errorPersistenceException
- error at data layer
-
checkout
Description copied from interface:DocumentManager
Checks out the given document- Specified by:
checkout
in interfaceDocumentManager
- Parameters:
docId
- the document to be checked outtransaction
- entry to log the event (set the user)- Throws:
PersistenceException
- error at data layer
-
lock
Description copied from interface:DocumentManager
Locks the given document- Specified by:
lock
in interfaceDocumentManager
- Parameters:
docId
- the document to be lockedstatus
- the lock type (used to populate status attribute of the document)transaction
- entry to log the event (set the user)- Throws:
PersistenceException
- if an error occurs, this exception is thrown
-
deleteFromIndex
Utility method for document removal from index- Specified by:
deleteFromIndex
in interfaceDocumentManager
- Parameters:
doc
- the document to delete from the index
-
parseDocument
Description copied from interface:DocumentManager
Retrieves the document's content as a string- Specified by:
parseDocument
in interfaceDocumentManager
- Parameters:
doc
- the document representationfileVersion
- version of the file- Returns:
- The document's content
- Throws:
ParseException
- error in the parsing
-
index
public long index(long docId, String content, DocumentHistory transaction) throws PersistenceException, ParseException Description copied from interface:DocumentManager
Re-indexes an existing document in the full-text index.- Specified by:
index
in interfaceDocumentManager
- Parameters:
docId
- The document to be indexedcontent
- The content to use as document's body (can be null to parse the file)transaction
- entry to log the event (set the user)- Returns:
- the number of milliseconds required to parse the document
- Throws:
PersistenceException
- error at data layerParseException
- error during parsing
-
update
public void update(Document document, Document docVO, DocumentHistory transaction) throws PersistenceException Description copied from interface:DocumentManager
Updates an existing document and marks it to be re-indexed- Specified by:
update
in interfaceDocumentManager
- Parameters:
document
- The document to be updateddocVO
- value object containing the new metadatatransaction
- entry to log the event (set the user)- Throws:
PersistenceException
- if an error occurs, this exception is thrown
-
moveToFolder
public void moveToFolder(Document doc, Folder folder, DocumentHistory transaction) throws PersistenceException Description copied from interface:DocumentManager
Moves a document to the specified folder. All stores(db, file system, index) will be consequently altered.- Specified by:
moveToFolder
in interfaceDocumentManager
- Parameters:
doc
- The document to movefolder
- The target foldertransaction
- entry to log the event (set the user)- Throws:
PersistenceException
- raised if the document cannot be moved
-
create
public Document create(InputStream content, Document docVO, DocumentHistory transaction) throws PersistenceException Description copied from interface:DocumentManager
Creates a new Document. Saves the information provided. That also includes updating the search index for example.- Specified by:
create
in interfaceDocumentManager
- Parameters:
content
- The document's contentdocVO
- The value object containing the document's metadatatransaction
- The transaction metadata (remember to set the user and the comment)- Returns:
- The newly created document
- Throws:
PersistenceException
- raised if the document cannot be created
-
create
public Document create(File file, Document docVO, DocumentHistory transaction) throws PersistenceException Description copied from interface:DocumentManager
Creates a new Document. Saves the information provided. That also includes updating the search index for example.- Specified by:
create
in interfaceDocumentManager
- Parameters:
file
- The document's filedocVO
- The value object containing the document's metadatatransaction
- The trandaction metadata (remember to set the user and the comment)- Returns:
- The newly created document
- Throws:
PersistenceException
- raised if the document cannot be created
-
countPages
Description copied from interface:DocumentManager
Counts the number of pages of a document- Specified by:
countPages
in interfaceDocumentManager
- Parameters:
doc
- the document- Returns:
- the number of pages
-
copyToFolder
public Document copyToFolder(Document doc, Folder folder, DocumentHistory transaction, boolean links, boolean notes) throws PersistenceException, IOException Description copied from interface:DocumentManager
Copy a document to the specified folder.- Specified by:
copyToFolder
in interfaceDocumentManager
- Parameters:
doc
- The document to movefolder
- The target foldertransaction
- entry to log the event (set the user)links
- if links must be copied toonotes
- if notes and annotations must be copied too- Returns:
- The created document
- Throws:
PersistenceException
- error at data layerIOException
- I/O error
-
unlock
Description copied from interface:DocumentManager
UNChecks out the given document- Specified by:
unlock
in interfaceDocumentManager
- Parameters:
docId
- the document to be unchecked outtransaction
- entry to log the event- Throws:
PersistenceException
- if an error occurs, this exception is thrown
-
makeImmutable
Description copied from interface:DocumentManager
Marks the document, with the given docId, as immutable and save the given document history- Specified by:
makeImmutable
in interfaceDocumentManager
- Parameters:
docId
- identifier of the documenttransaction
- entry to log the event (set the user)- Throws:
PersistenceException
- raised if the document cannot be marked immutable
-
rename
public void rename(long docId, String newName, DocumentHistory transaction) throws PersistenceException Description copied from interface:DocumentManager
Rename an existing document filename.- Specified by:
rename
in interfaceDocumentManager
- Parameters:
docId
- The document to be renamednewName
- The new filename of the documenttransaction
- entry to log the event (set the user)- Throws:
PersistenceException
- if an error occurs, this exception is thrown
-
replaceAlias
Description copied from interface:DocumentManager
Replaces an alias with a copy of the original file- Specified by:
replaceAlias
in interfaceDocumentManager
- Parameters:
aliasId
- ID of the alias to replacetransaction
- entry to log the event (set the user)- Returns:
- The created document
- Throws:
PersistenceException
- raised if the alias cannot be replaced
-
createAlias
public Document createAlias(Document doc, Folder folder, String aliasType, DocumentHistory transaction) throws PersistenceException Description copied from interface:DocumentManager
Create an alias(shortcut) associated to the given doc to the specified folder.- Specified by:
createAlias
in interfaceDocumentManager
- Parameters:
doc
- The document for which will be created the shortcutfolder
- The target folderaliasType
- the alias type(null for the original file or pdf for it's pdf conversion)transaction
- entry to log the event (set the user)- Returns:
- The created document
- Throws:
PersistenceException
- error at data layer
-
changeIndexingStatus
Description copied from interface:DocumentManager
Utility method used to declare that:- the document must be taken into consideration by the indexer (status
=
AbstractDocument.INDEX_TO_INDEX
. - the document must be taken into consideration by the indexer for the
metadata only(status =
AbstractDocument.INDEX_TO_INDEX_METADATA
. - the document must not be taken into consideration by the indexer
(status =
AbstractDocument.INDEX_SKIP
). If the document was previously indexed it is removed from the index.
- Specified by:
changeIndexingStatus
in interfaceDocumentManager
- Parameters:
doc
- The document for which will be changed the indexer status.status
- The new document indexer status.
- the document must be taken into consideration by the indexer (status
=
-
setUserDAO
-
setFolderDAO
-
deleteVersion
public Version deleteVersion(long versionId, DocumentHistory transaction) throws PersistenceException Description copied from interface:DocumentManager
Deletes a specific version.- Specified by:
deleteVersion
in interfaceDocumentManager
- Parameters:
versionId
- The version to deletetransaction
- entry to log the event (set the user)- Returns:
- the latest version
- Throws:
PersistenceException
- If the version cannot be deleted
-
setDocumentNoteDAO
-
archiveFolder
Description copied from interface:DocumentManager
Archives all the documents in a folder's tree- Specified by:
archiveFolder
in interfaceDocumentManager
- Parameters:
folderId
- The root foldertransaction
- entry to log the event (set the user)- Returns:
- Total number of archived documents
- Throws:
PersistenceException
- raised if at least a document cannot be archived
-
archiveDocuments
public void archiveDocuments(long[] docIds, DocumentHistory transaction) throws PersistenceException Description copied from interface:DocumentManager
Archives all the documents in a folder's tree- Specified by:
archiveDocuments
in interfaceDocumentManager
- Parameters:
docIds
- Documents to be archivedtransaction
- entry to log the event (set the user)- Throws:
PersistenceException
- raised if at least a document cannot be archived
-
createTicket
public Ticket createTicket(Ticket ticket, DocumentHistory transaction) throws PersistenceException, PermissionException Description copied from interface:DocumentManager
Creates a new ticket.- Specified by:
createTicket
in interfaceDocumentManager
- Parameters:
ticket
- Value object carrying the metadata for the ticket to createtransaction
- entry to log the event (set the user)- Returns:
- The created ticket with the url property filled
- Throws:
PersistenceException
- raised if the download ticket cannot be createdPermissionException
- raised if the user does not have the download permission
-
setTicketDAO
-
unprotect
Description copied from interface:DocumentManager
Tries to unprotect a document, If the password is correct, the document stays unprotected for all the duration of the session.- Specified by:
unprotect
in interfaceDocumentManager
- Parameters:
sid
- Session identifierdocId
- The document idpassword
- The password to try- Returns:
- True if the file gets unprotected
-
promoteVersion
public void promoteVersion(long docId, String version, DocumentHistory transaction) throws PersistenceException, IOException Description copied from interface:DocumentManager
Promotes an old version to the current default one. If you promote a prior version, what it does is make it the default version again. (regardless of there being many versions).- Specified by:
promoteVersion
in interfaceDocumentManager
- Parameters:
docId
- the document to be updatedversion
- the versiontransaction
- entry to log the event (set the user)- Throws:
PersistenceException
- error at data layerIOException
- I/O error
-
enforceFilesIntoFolderStorage
public int enforceFilesIntoFolderStorage(long rootFolderId, DocumentHistory transaction) throws PersistenceException, IOException Description copied from interface:DocumentManager
Moves all the files of the documents in the given tree from it's original location to the storage defined in the owning folder- Specified by:
enforceFilesIntoFolderStorage
in interfaceDocumentManager
- Parameters:
rootFolderId
- identifier of the root of the tree to processtransaction
- informations about the transaction, optional- Returns:
- number of moved files
- Throws:
PersistenceException
- error at data layerIOException
- I/O error
-
merge
public Document merge(Collection<Document> documents, long targetFolderId, String fileName, DocumentHistory transaction) throws IOException, PersistenceException Description copied from interface:DocumentManager
Merges a set of documents into a single PDF file- Specified by:
merge
in interfaceDocumentManager
- Parameters:
documents
- the list of documents to merge(the order counts)targetFolderId
- identifier of the target folderfileName
- name of the output file(must ends with .pdf)transaction
- informations about the transaction, optional- Returns:
- the generated merged document
- Throws:
IOException
- I/O errorPersistenceException
- error at data layer
-
setDocumentLinkDAO
-