Package com.logicaldoc.core.document
Class DocumentManagerImpl
- java.lang.Object
-
- com.logicaldoc.core.document.DocumentManagerImpl
-
- All Implemented Interfaces:
DocumentManager
public class DocumentManagerImpl extends Object implements DocumentManager
Basic Implementation ofDocumentManager- Since:
- 3.5
- Author:
- Marco Meschieri - LogicalDOC
-
-
Constructor Summary
Constructors Constructor Description DocumentManagerImpl()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidarchiveDocuments(long[] docIds, DocumentHistory transaction)Archives all the documents in a folder's treelongarchiveFolder(long folderId, DocumentHistory transaction)Archives all the documents in a folder's treevoidchangeIndexingStatus(Document doc, int status)Utility method used to declare that: a document must be taken into consideration by the indexer (status = AbstractDocument.INDEX_TO_INDEX). a document must not be taken into consideration by the indexer (status = AbstractDocument.INDEX_SKIP).voidcheckin(long docId, File file, String filename, boolean release, AbstractDocument docVO, DocumentHistory transaction)Checks in the given documentvoidcheckin(long docId, InputStream content, String filename, boolean release, AbstractDocument docVO, DocumentHistory transaction)Checks in the given documentvoidcheckout(long docId, DocumentHistory transaction)Checks out the given documentDocumentcopyToFolder(Document doc, Folder folder, DocumentHistory transaction)Copy a document to the specified folder.Documentcreate(File file, Document docVO, DocumentHistory transaction)Creates a new Document.Documentcreate(InputStream content, Document docVO, DocumentHistory transaction)Creates a new Document.DocumentcreateAlias(Document doc, Folder folder, String aliasType, DocumentHistory transaction)Create an alias(shortcut) associated to the given doc to the specified folder.TicketcreateDownloadTicket(long docId, String suffix, Integer expireHours, Date expireDate, Integer maxDownloads, String urlPrefix, DocumentHistory transaction)Creates a new download ticket.voiddeleteFromIndex(Document doc)Utility method for document removal from indexVersiondeleteVersion(long versionId, DocumentHistory transaction)Deletes a specific version.voidlock(long docId, int status, DocumentHistory transaction)Locks the given documentvoidmakeImmutable(long docId, DocumentHistory transaction)Marks the document, with the given docId, as immutable and save the given document historyvoidmoveToFolder(Document doc, Folder folder, DocumentHistory transaction)Moves a document to the specified folder.StringparseDocument(Document doc, String fileVersion)Retrieves the document's content as a stringvoidpromoteVersion(long docId, String version, DocumentHistory transaction)Promotes an old version to the current default one.longreindex(long docId, String content)Re-indexes an existing document in the full-text index.voidrename(Document doc, String newName, DocumentHistory transaction)Rename an existing document filename.DocumentreplaceAlias(long aliasId, DocumentHistory transaction)Replaces an alias with a copy of the original filevoidreplaceFile(long docId, String fileVersion, File newFile, DocumentHistory transaction)Replaces the file of a given versionvoidreplaceFile(long docId, String fileVersion, InputStream content, DocumentHistory transaction)Replaces the file of a given versionvoidsetConfig(ContextProperties config)voidsetDocumentDAO(DocumentDAO documentDAO)voidsetDocumentNoteDAO(DocumentNoteDAO documentNoteDAO)voidsetFolderDAO(FolderDAO folderDAO)voidsetIndexer(SearchEngine indexer)voidsetListenerManager(DocumentListenerManager listenerManager)voidsetStorer(Storer storer)voidsetTemplateDAO(TemplateDAO templateDAO)voidsetTicketDAO(TicketDAO ticketDAO)voidsetUserDAO(UserDAO userDAO)voidsetVersionDAO(VersionDAO versionDAO)voidunlock(long docId, DocumentHistory transaction)UNChecks out the given documentbooleanunprotect(String sid, long docId, String password)Tries to unprotect a document, If the password is correct, the document stays unprotected for all the duration of the session.voidupdate(Document doc, Document docVO, DocumentHistory transaction)Updates an existing document and marks it to be re-indexed
-
-
-
Method Detail
-
setListenerManager
public void setListenerManager(DocumentListenerManager listenerManager)
-
setDocumentDAO
public void setDocumentDAO(DocumentDAO documentDAO)
-
setTemplateDAO
public void setTemplateDAO(TemplateDAO templateDAO)
-
setIndexer
public void setIndexer(SearchEngine indexer)
-
replaceFile
public void replaceFile(long docId, String fileVersion, InputStream content, DocumentHistory transaction) throws ExceptionDescription copied from interface:DocumentManagerReplaces the file of a given version- Specified by:
replaceFilein interfaceDocumentManager- Parameters:
docId- the document to be updatedfileVersion- the file versioncontent- the file to usetransaction- entry to log the event (set the user)- Throws:
Exception- if an error occurs, this exception is thrown
-
replaceFile
public void replaceFile(long docId, String fileVersion, File newFile, DocumentHistory transaction) throws ExceptionDescription copied from interface:DocumentManagerReplaces the file of a given version- Specified by:
replaceFilein interfaceDocumentManager- Parameters:
docId- the document to be updatedfileVersion- the file versionnewFile- the file to usetransaction- entry to log the event (set the user)- Throws:
Exception- if an error occurs, this exception is thrown
-
checkin
public void checkin(long docId, File file, String filename, boolean release, AbstractDocument docVO, DocumentHistory transaction) throws ExceptionDescription copied from interface:DocumentManagerChecks in the given document- Specified by:
checkinin 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:
Exception- if an error occurs, this exception is thrown
-
checkin
public void checkin(long docId, InputStream content, String filename, boolean release, AbstractDocument docVO, DocumentHistory transaction) throws ExceptionDescription copied from interface:DocumentManagerChecks in the given document- Specified by:
checkinin 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:
Exception- if an error occurs, this exception is thrown
-
checkout
public void checkout(long docId, DocumentHistory transaction) throws ExceptionDescription copied from interface:DocumentManagerChecks out the given document- Specified by:
checkoutin interfaceDocumentManager- Parameters:
docId- the document to be checked outtransaction- entry to log the event (set the user)- Throws:
Exception- if an error occurs, this exception is thrown
-
lock
public void lock(long docId, int status, DocumentHistory transaction) throws ExceptionDescription copied from interface:DocumentManagerLocks the given document- Specified by:
lockin 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:
Exception- if an error occurs, this exception is thrown
-
deleteFromIndex
public void deleteFromIndex(Document doc)
Utility method for document removal from index- Specified by:
deleteFromIndexin interfaceDocumentManager- Parameters:
doc- the document to delete from the index
-
parseDocument
public String parseDocument(Document doc, String fileVersion)
Retrieves the document's content as a string- Specified by:
parseDocumentin interfaceDocumentManager- Parameters:
doc- The document representationfileVersion- version fo the file- Returns:
- The document's content
-
reindex
public long reindex(long docId, String content) throws ExceptionDescription copied from interface:DocumentManagerRe-indexes an existing document in the full-text index.- Specified by:
reindexin interfaceDocumentManager- Parameters:
docId- The document to be indexedcontent- The content to use as document's body (can be null to parse the file)- Returns:
- the number of milliseconds required to parse the document
- Throws:
Exception- if an error occurs, this exception is thrown
-
update
public void update(Document doc, Document docVO, DocumentHistory transaction) throws Exception
Description copied from interface:DocumentManagerUpdates an existing document and marks it to be re-indexed- Specified by:
updatein interfaceDocumentManager- Parameters:
doc- The document to be updateddocVO- value object containing the new metadatatransaction- entry to log the event (set the user)- Throws:
Exception- if an error occurs, this exception is thrown
-
moveToFolder
public void moveToFolder(Document doc, Folder folder, DocumentHistory transaction) throws Exception
Description copied from interface:DocumentManagerMoves a document to the specified folder. All stores(db, file system, index) will be consequently altered.- Specified by:
moveToFolderin interfaceDocumentManager- Parameters:
doc- The document to movefolder- The target foldertransaction- entry to log the event (set the user)- Throws:
Exception- raised if the document cannot be moved
-
create
public Document create(InputStream content, Document docVO, DocumentHistory transaction) throws Exception
Description copied from interface:DocumentManagerCreates a new Document. Saves the information provided. That also includes updating the search index for example.- Specified by:
createin 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:
Exception- raised if the document cannot be created
-
create
public Document create(File file, Document docVO, DocumentHistory transaction) throws Exception
Description copied from interface:DocumentManagerCreates a new Document. Saves the information provided. That also includes updating the search index for example.- Specified by:
createin 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:
Exception- raised if the document cannot be created
-
copyToFolder
public Document copyToFolder(Document doc, Folder folder, DocumentHistory transaction) throws Exception
Description copied from interface:DocumentManagerCopy a document to the specified folder.- Specified by:
copyToFolderin interfaceDocumentManager- Parameters:
doc- The document to movefolder- The target foldertransaction- entry to log the event (set the user)- Returns:
- The created document
- Throws:
Exception- raised if the document cannot be copied
-
unlock
public void unlock(long docId, DocumentHistory transaction) throws ExceptionDescription copied from interface:DocumentManagerUNChecks out the given document- Specified by:
unlockin interfaceDocumentManager- Parameters:
docId- the document to be unchecked outtransaction- entry to log the event- Throws:
Exception- if an error occurs, this exception is thrown
-
makeImmutable
public void makeImmutable(long docId, DocumentHistory transaction) throws ExceptionDescription copied from interface:DocumentManagerMarks the document, with the given docId, as immutable and save the given document history- Specified by:
makeImmutablein interfaceDocumentManager- Parameters:
docId- identifier of the documenttransaction- entry to log the event (set the user)- Throws:
Exception- raised if the document cannot be marked immutable
-
rename
public void rename(Document doc, String newName, DocumentHistory transaction) throws Exception
Description copied from interface:DocumentManagerRename an existing document filename.- Specified by:
renamein interfaceDocumentManager- Parameters:
doc- The document to be renamednewName- The new filename of the documenttransaction- entry to log the event (set the user)- Throws:
Exception- if an error occurs, this exception is thrown
-
replaceAlias
public Document replaceAlias(long aliasId, DocumentHistory transaction) throws Exception
Description copied from interface:DocumentManagerReplaces an alias with a copy of the original file- Specified by:
replaceAliasin interfaceDocumentManager- Parameters:
aliasId- ID of the alias to replacetransaction- entry to log the event (set the user)- Returns:
- The created document
- Throws:
Exception- raised if the alias cannot be replaced
-
createAlias
public Document createAlias(Document doc, Folder folder, String aliasType, DocumentHistory transaction) throws Exception
Description copied from interface:DocumentManagerCreate an alias(shortcut) associated to the given doc to the specified folder.- Specified by:
createAliasin 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:
Exception- raised if the alias cannot be created
-
setVersionDAO
public void setVersionDAO(VersionDAO versionDAO)
-
setStorer
public void setStorer(Storer storer)
- Specified by:
setStorerin interfaceDocumentManager
-
setConfig
public void setConfig(ContextProperties config)
-
changeIndexingStatus
public void changeIndexingStatus(Document doc, int status)
Description copied from interface:DocumentManagerUtility method used to declare that:- a document must be taken into consideration by the indexer (status = AbstractDocument.INDEX_TO_INDEX).
- a 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.
- AbstractDocument.INDEX_TO_INDEX
- AbstractDocument.INDEX_SKIP
- Specified by:
changeIndexingStatusin interfaceDocumentManager- Parameters:
doc- The document for which will be changed the indexer status.status- The new document indexer status.
-
setUserDAO
public void setUserDAO(UserDAO userDAO)
-
setFolderDAO
public void setFolderDAO(FolderDAO folderDAO)
-
deleteVersion
public Version deleteVersion(long versionId, DocumentHistory transaction) throws Exception
Description copied from interface:DocumentManagerDeletes a specific version.- Specified by:
deleteVersionin interfaceDocumentManager- Parameters:
versionId- The version to deletetransaction- entry to log the event (set the user)- Returns:
- the latest version
- Throws:
Exception- If the version cannot be deleted
-
setDocumentNoteDAO
public void setDocumentNoteDAO(DocumentNoteDAO documentNoteDAO)
-
archiveFolder
public long archiveFolder(long folderId, DocumentHistory transaction) throws ExceptionDescription copied from interface:DocumentManagerArchives all the documents in a folder's tree- Specified by:
archiveFolderin interfaceDocumentManager- Parameters:
folderId- The root foldertransaction- entry to log the event (set the user)- Returns:
- Total number of archived documents
- Throws:
Exception- raised if at least a document cannot be archived
-
archiveDocuments
public void archiveDocuments(long[] docIds, DocumentHistory transaction) throws ExceptionDescription copied from interface:DocumentManagerArchives all the documents in a folder's tree- Specified by:
archiveDocumentsin interfaceDocumentManager- Parameters:
docIds- Documents to be archivedtransaction- entry to log the event (set the user)- Throws:
Exception- raised if at least a document cannot be archived
-
createDownloadTicket
public Ticket createDownloadTicket(long docId, String suffix, Integer expireHours, Date expireDate, Integer maxDownloads, String urlPrefix, DocumentHistory transaction) throws Exception
Description copied from interface:DocumentManagerCreates a new download ticket.- Specified by:
createDownloadTicketin interfaceDocumentManager- Parameters:
docId- The document idsuffix- can be null or 'conversion.pdf'expireHours- expiration time expressed in hoursexpireDate- exact expiration date expressed in the format yyyy-MM-ddmaxDownloads- maximum number of admitted downloadsurlPrefix- prefiz of the url, by default the general setting 'server.url' will be usedtransaction- entry to log the event (set the user)- Returns:
- The created ticket with the url property filled
- Throws:
Exception- raised if the download ticket cannot be created
-
setTicketDAO
public void setTicketDAO(TicketDAO ticketDAO)
-
unprotect
public boolean unprotect(String sid, long docId, String password)
Description copied from interface:DocumentManagerTries to unprotect a document, If the password is correct, the document stays unprotected for all the duration of the session.- Specified by:
unprotectin 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 ExceptionDescription copied from interface:DocumentManagerPromotes 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:
promoteVersionin interfaceDocumentManager- Parameters:
docId- the document to be updatedversion- the versiontransaction- entry to log the event (set the user)- Throws:
Exception- if an error occurs, this exception is thrown
-
-