Class SimpleDocumentService
- java.lang.Object
-
- org.silverpeas.core.contribution.attachment.SimpleDocumentService
-
- All Implemented Interfaces:
ComponentInstanceDeletion
,VolatileResourceCleaner
,AttachmentService
,DocumentIndexing
@Service public class SimpleDocumentService extends Object implements AttachmentService, ComponentInstanceDeletion, VolatileResourceCleaner
- Author:
- ehugonnet
-
-
Field Summary
-
Fields inherited from interface org.silverpeas.core.contribution.attachment.AttachmentService
VERSION_MODE
-
-
Constructor Summary
Constructors Constructor Description SimpleDocumentService()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addXmlForm(SimpleDocumentPK pk, String language, String xmlFormName)
SimpleDocumentPK
changeVersionState(SimpleDocumentPK pk, String comment)
Change the management of versions of the document.void
cleanVolatileResources(String volatileResourceId, String componentInstanceIdentifier)
Cleans the resources referenced with the given resource identifier and linked to the component instance represented by the given identifier.SimpleDocumentPK
cloneDocument(SimpleDocument original, String foreignCloneId)
Clones the given document and attached it to the specified resource.List<org.silverpeas.kernel.util.Pair<SimpleDocumentPK,SimpleDocumentPK>>
copyAllDocuments(ResourceReference sourceResource, ResourceReference destinationResource)
Copies all the attachments linked to the given source resource to the specified destination one.SimpleDocumentPK
copyDocument(SimpleDocument original, ResourceReference targetResource)
Copies the specified document to another existing resource.SimpleDocument
createAttachment(SimpleDocument document, File content)
Creates the attachment and saves the content of the specified document.SimpleDocument
createAttachment(SimpleDocument document, File content, boolean indexIt)
Creates the attachment, saves the content of the specified document and indexes it if asked.SimpleDocument
createAttachment(SimpleDocument document, File content, boolean indexIt, boolean notify)
Creates the attachment, saves the content of the specified document, indexes it if asked, and notifies about the creation.SimpleDocument
createAttachment(SimpleDocument document, InputStream content)
Creates the attachment and saves the content of the specified document.SimpleDocument
createAttachment(SimpleDocument document, InputStream content, boolean indexIt)
Creates the attachment, saves the content of the specified document and indexes it if asked.SimpleDocument
createAttachment(SimpleDocument document, InputStream content, boolean indexIt, boolean notify)
Creates the attachment, saves the content of the specified document, indexes it if asked, and notifies about the creation.void
createIndex(SimpleDocument document)
Indexes the specified document.void
createIndex(SimpleDocument document, Date startOfVisibility, Date endOfVisibility)
Creates an index on the specified document with a period of time of visibility.void
delete(String componentInstanceId)
Deletes the resources belonging to the specified component instance.void
deleteAllAttachments(String componentInstanceId)
Deletes all the documents related to the component instance identified by the specified identifier.void
deleteAllAttachments(String resourceId, String componentInstanceId)
Deletes all the documents attached to a resource.void
deleteAttachment(SimpleDocument document)
Deletes the given document and notifies about this deletion.void
deleteAttachment(SimpleDocument document, boolean notify)
Deletes the given document and notifies about this deletion is asked.void
deleteIndex(SimpleDocument document)
Deletes any index on the specified document.SimpleDocument
findExistingDocument(SimpleDocumentPK pk, String fileName, ResourceReference foreign, String lang)
Find documents with the same name attached to the specified foreign id.void
getBinaryContent(File file, SimpleDocumentPK pk, String lang)
Writes the binary content into the specified File.void
getBinaryContent(OutputStream output, SimpleDocumentPK pk, String lang)
Writes the binary content into the specified OutputStream.void
getBinaryContent(OutputStream output, SimpleDocumentPK pk, String lang, long contentOffset, long contentLength)
Writes the binary content contained between begin and end indexes into the specified OutputStream.void
indexAllDocuments(ResourceReference resource, Date startOfVisibilityPeriod, Date endOfVisibilityPeriod)
Indexes all the documents (whatever their type) of the given resource.SimpleDocumentList<SimpleDocument>
listAllDocumentsByForeignKey(ResourceReference foreignKey, String lang)
Search all the documents (whatever their type: files, xmlform content, wysiwyg, ...) attached to the specified resource and in the given language.SimpleDocumentList<SimpleDocument>
listDocumentsByForeignKey(ResourceReference foreignKey, String lang)
Search all the documents of type files attached to the specified resource and in the given language.SimpleDocumentList<SimpleDocument>
listDocumentsByForeignKeyAndType(ResourceReference foreignKey, DocumentType type, String lang)
Search all the documents attached to the specified resource, for a given type of document, and in the specified language.List<SimpleDocument>
listDocumentsLockedByUser(String usedId, String language)
Search all the documents locked by a specific user.List<SimpleDocument>
listDocumentsRequiringWarning(Date alertDate, String language)
Search all the documents in an instance which are locked at the alert date.List<SimpleDocument>
listDocumentsToUnlock(Date expiryDate, String language)
Search all the documents in an instance requiring to be unlocked at the specified date.List<SimpleDocument>
listExpiringDocuments(Date expiryDate, String language)
Search all the documents in an instance which require an alert at the specified date.boolean
lock(String attachmentId, String userId, String language)
Checkout a file to be updated by user.Map<String,String>
mergeDocuments(ResourceReference originalResource, ResourceReference clonedResource, DocumentType type)
Merges the documents of the cloned resource with their original counterparts.List<SimpleDocumentPK>
moveAllDocuments(ResourceReference sourceResource, ResourceReference destinationResource)
Moves all the attachments linked to the specified resource to the another one.SimpleDocumentPK
moveDocument(SimpleDocument document, ResourceReference destination)
Moves the specified document to the given resource.void
removeContent(SimpleDocument document, String lang, boolean notify)
Removes the content of the specified document in the given language.void
reorderAttachments(List<SimpleDocumentPK> pks)
Reorders the documents referenced in the given list according their order in the list.void
reorderDocuments(List<SimpleDocument> documents)
Reorders the documents in the given list according their order in the list.SimpleDocument
searchDocumentById(SimpleDocumentPK docPk, String lang)
Search the document with the given identifier and in the specified language.void
switchAllowingDownloadForReaders(SimpleDocumentPK pk, boolean allowing)
Allows or forbids the download for readers.void
switchComponentBehaviour(String componentId, boolean versioned)
Change the management of versions of the documents of a whole component (only attachments are taken into account).void
switchEnableDisplayAsContent(SimpleDocumentPK pk, boolean enable)
Enables or not the display of the content of an attachment.void
switchEnableEditSimultaneously(SimpleDocumentPK pk, boolean enable)
Enables or not the simultaneous edition of the content of an attachment.void
unindexAttachmentsOfExternalObject(ResourceReference externalResource)
Remove indexes on all the attachments of the specified resource.boolean
unlock(UnlockContext context)
Release a locked file.void
updateAttachment(SimpleDocument document, boolean indexIt, boolean notify)
Updates the specified whole document: status, metadata but not its content.void
updateAttachment(SimpleDocument document, File content, boolean indexIt, boolean notify)
Updates the specified whole document with its content either by updating the given content or by adding it among its others contents.void
updateAttachment(SimpleDocument document, InputStream in, boolean indexIt, boolean notify)
Updates the specified whole document with its content either by updating the given content or by adding it among its others contents.void
updateIndexEntryWithDocuments(FullIndexEntry indexEntry)
Add the documents to the index.
-
-
-
Method Detail
-
deleteAllAttachments
public void deleteAllAttachments(String componentInstanceId)
Description copied from interface:AttachmentService
Deletes all the documents related to the component instance identified by the specified identifier.- Specified by:
deleteAllAttachments
in interfaceAttachmentService
- Parameters:
componentInstanceId
- the component instance identifier.
-
cleanVolatileResources
public void cleanVolatileResources(String volatileResourceId, String componentInstanceIdentifier)
Description copied from interface:VolatileResourceCleaner
Cleans the resources referenced with the given resource identifier and linked to the component instance represented by the given identifier.- Specified by:
cleanVolatileResources
in interfaceVolatileResourceCleaner
- Parameters:
volatileResourceId
- a resource identifier.componentInstanceIdentifier
- a component instance identifier.
-
createIndex
public void createIndex(SimpleDocument document)
Description copied from interface:AttachmentService
Indexes the specified document.- Specified by:
createIndex
in interfaceAttachmentService
- Parameters:
document
- the document
-
deleteIndex
public void deleteIndex(SimpleDocument document)
Description copied from interface:AttachmentService
Deletes any index on the specified document.- Specified by:
deleteIndex
in interfaceAttachmentService
- Parameters:
document
- the document.
-
createIndex
public void createIndex(SimpleDocument document, Date startOfVisibility, Date endOfVisibility)
Description copied from interface:AttachmentService
Creates an index on the specified document with a period of time of visibility.- Specified by:
createIndex
in interfaceAttachmentService
- Parameters:
document
- the document to index.startOfVisibility
- the date at which the document should be visible.endOfVisibility
- the date at which the document shouldn't be anymore visible.
-
unindexAttachmentsOfExternalObject
public void unindexAttachmentsOfExternalObject(ResourceReference externalResource)
Description copied from interface:AttachmentService
Remove indexes on all the attachments of the specified resource.- Specified by:
unindexAttachmentsOfExternalObject
in interfaceAttachmentService
- Parameters:
externalResource
- a reference to the resource.
-
addXmlForm
@PreventAttachmentHugeProcess public void addXmlForm(@SourcePK SimpleDocumentPK pk, String language, String xmlFormName)
- Specified by:
addXmlForm
in interfaceAttachmentService
-
createAttachment
@PreventAttachmentHugeProcess @SimulationActionProcess(elementLister=AttachmentSimulationElementLister.class) @Action(CREATE) public SimpleDocument createAttachment(@SourceObject @TargetPK SimpleDocument document, InputStream content)
Description copied from interface:AttachmentService
Creates the attachment and saves the content of the specified document. The created document is indexed and a notification about the creation is sent.The filename returned by
SimpleDocument.getFilename()
is normalized in order to get only single character encoding and no more combined characters. The normalized filename is set to the given document.- Specified by:
createAttachment
in interfaceAttachmentService
- Parameters:
document
- the document to be created.content
- the binary content of the document.- Returns:
- the stored document.
-
createAttachment
@PreventAttachmentHugeProcess @SimulationActionProcess(elementLister=AttachmentSimulationElementLister.class) @Action(CREATE) public SimpleDocument createAttachment(@SourceObject @TargetPK SimpleDocument document, InputStream content, boolean indexIt)
Description copied from interface:AttachmentService
Creates the attachment, saves the content of the specified document and indexes it if asked. Once the attachment created, a notification about this creation is then sent.The filename returned by
SimpleDocument.getFilename()
is normalized in order to get only single character encoding and no more combined characters. The normalized filename is set to the given document.- Specified by:
createAttachment
in interfaceAttachmentService
- Parameters:
document
- the document to be created.content
- the binary content of the document.indexIt
- true if the document has to be indexed, false otherwise.- Returns:
- the stored document.
-
createAttachment
@PreventAttachmentHugeProcess @SimulationActionProcess(elementLister=AttachmentSimulationElementLister.class) @Action(CREATE) public SimpleDocument createAttachment(@SourceObject @TargetPK SimpleDocument document, InputStream content, boolean indexIt, boolean notify)
Description copied from interface:AttachmentService
Creates the attachment, saves the content of the specified document, indexes it if asked, and notifies about the creation.The filename returned by
SimpleDocument.getFilename()
is normalized in order to get only single character encoding and no more combined characters. The normalized filename is set to the given document.- Specified by:
createAttachment
in interfaceAttachmentService
- Parameters:
document
- the document to be created.content
- the binary content of the document.indexIt
- true if the document has to be indexed, false otherwise.notify
- true if a notification about the creation has to be sent, false otherwise.- Returns:
- the stored document.
-
deleteAttachment
@PreventAttachmentHugeProcess public void deleteAttachment(@SourceObject SimpleDocument document)
Description copied from interface:AttachmentService
Deletes the given document and notifies about this deletion.- Specified by:
deleteAttachment
in interfaceAttachmentService
- Parameters:
document
- the document to delete.
-
deleteAllAttachments
public void deleteAllAttachments(String resourceId, String componentInstanceId)
Description copied from interface:AttachmentService
Deletes all the documents attached to a resource.- Specified by:
deleteAllAttachments
in interfaceAttachmentService
- Parameters:
resourceId
- the identifier of the resource.componentInstanceId
- the identifier of the component instance into which the resource is located.
-
deleteAttachment
@PreventAttachmentHugeProcess public void deleteAttachment(@SourceObject SimpleDocument document, boolean notify)
Description copied from interface:AttachmentService
Deletes the given document and notifies about this deletion is asked.- Specified by:
deleteAttachment
in interfaceAttachmentService
- Parameters:
document
- the document to delete.notify
- true if a notification about the deletion has to be sent. False otherwise.
-
searchDocumentById
public SimpleDocument searchDocumentById(SimpleDocumentPK docPk, String lang)
Description copied from interface:AttachmentService
Search the document with the given identifier and in the specified language.- Specified by:
searchDocumentById
in interfaceAttachmentService
- Parameters:
docPk
- the identifier of the document to search.lang
- the ISO-631 code of a language.- Returns:
- the document or null if no such document exists.
-
listAllDocumentsByForeignKey
public SimpleDocumentList<SimpleDocument> listAllDocumentsByForeignKey(ResourceReference foreignKey, String lang)
Description copied from interface:AttachmentService
Search all the documents (whatever their type: files, xmlform content, wysiwyg, ...) attached to the specified resource and in the given language.- Specified by:
listAllDocumentsByForeignKey
in interfaceAttachmentService
- Parameters:
foreignKey
- a reference to the resource.lang
- the ISO-631 code of a language.- Returns:
- the list of documents attached to the specified resource.
-
listDocumentsByForeignKey
public SimpleDocumentList<SimpleDocument> listDocumentsByForeignKey(ResourceReference foreignKey, String lang)
Description copied from interface:AttachmentService
Search all the documents of type files attached to the specified resource and in the given language.- Specified by:
listDocumentsByForeignKey
in interfaceAttachmentService
- Parameters:
foreignKey
- a reference to the resource.lang
- the ISO-631 code of a language.- Returns:
- the list of documents of type files attached to the specified resource.
-
updateAttachment
@PreventAttachmentHugeProcess @SimulationActionProcess(elementLister=AttachmentSimulationElementLister.class) @Action(UPDATE) public void updateAttachment(@SourceObject @TargetPK SimpleDocument document, boolean indexIt, boolean notify)
Description copied from interface:AttachmentService
Updates the specified whole document: status, metadata but not its content.The filename returned by
SimpleDocument.getFilename()
is normalized in order to get only single character encoding and no more combined characters. The normalized filename is set to given document.- Specified by:
updateAttachment
in interfaceAttachmentService
- Parameters:
document
- the document to update.indexIt
- true if the document change has to be indexed. False otherwise.notify
- true if a notification about the update has to be sent. False otherwise.
-
updateAttachment
@PreventAttachmentHugeProcess @SimulationActionProcess(elementLister=AttachmentSimulationElementLister.class) @Action(UPDATE) public void updateAttachment(@SourceObject @TargetPK SimpleDocument document, InputStream in, boolean indexIt, boolean notify)
Description copied from interface:AttachmentService
Updates the specified whole document with its content either by updating the given content or by adding it among its others contents.The filename returned by
SimpleDocument.getFilename()
is normalized in order to get only single character encoding and no more combined characters. The normalized filename is set to given document.- Specified by:
updateAttachment
in interfaceAttachmentService
- Parameters:
document
- the document to update.in
- the content to update or to add (in the case of multi-languages support).indexIt
- true if the change has to be indexed. False otherwise.notify
- true if a notification about the update has to be sent. False otherwise.
-
removeContent
@PreventAttachmentHugeProcess public void removeContent(@SourceObject SimpleDocument document, String lang, boolean notify)
Description copied from interface:AttachmentService
Removes the content of the specified document in the given language.- Specified by:
removeContent
in interfaceAttachmentService
- Parameters:
document
- the document.lang
- the ISO-631 code of a language.notify
- true if a notification about the content deletion has to be sent. False otherwise. If the document has again content (in others languages), an document update event is sent. Otherwise a deletion event is sent.
-
cloneDocument
@PreventAttachmentHugeProcess public SimpleDocumentPK cloneDocument(@SourceObject SimpleDocument original, String foreignCloneId)
Description copied from interface:AttachmentService
Clones the given document and attached it to the specified resource. The document is attached to a resource that has been cloned; hence this method is to clone the document in order to attach it to the cloned resource. The difference between a clone and a copy is the clone maintains a link with its original counterpart: any changes performed in one is synchronized with the other.- Specified by:
cloneDocument
in interfaceAttachmentService
- Parameters:
original
- the document to clone.foreignCloneId
- the identifier of the resource to which the document is attached.- Returns:
- the identifier of the cloned document.
-
copyDocument
@PreventAttachmentHugeProcess @SimulationActionProcess(elementLister=AttachmentSimulationElementLister.class) @Action(COPY) public SimpleDocumentPK copyDocument(@SourceObject SimpleDocument original, @TargetPK ResourceReference targetResource)
Description copied from interface:AttachmentService
Copies the specified document to another existing resource. The difference between a copy with a clone is the copy is detached to the original document from which it has been copied. So any changes in one isn't reported to the other one.- Specified by:
copyDocument
in interfaceAttachmentService
- Parameters:
original
- the document to copy.targetResource
- the resource to which the copy of the document has to be attached.- Returns:
- the identifier of the copy.
-
copyAllDocuments
@PreventAttachmentHugeProcess @SimulationActionProcess(elementLister=AttachmentSimulationElementLister.class) @Action(COPY) public List<org.silverpeas.kernel.util.Pair<SimpleDocumentPK,SimpleDocumentPK>> copyAllDocuments(@SourcePK ResourceReference sourceResource, @TargetPK ResourceReference destinationResource)
Description copied from interface:AttachmentService
Copies all the attachments linked to the given source resource to the specified destination one.- Specified by:
copyAllDocuments
in interfaceAttachmentService
- Parameters:
sourceResource
- the reference of the resource (identifier and component instance) from which the attachments must be copied.destinationResource
- the reference of the resource (identifier and component instance) to which attachments will be copied.- Returns:
- le list of copied attachments, empty if nothing is copied.
-
reorderAttachments
public void reorderAttachments(List<SimpleDocumentPK> pks)
Description copied from interface:AttachmentService
Reorders the documents referenced in the given list according their order in the list.- Specified by:
reorderAttachments
in interfaceAttachmentService
- Parameters:
pks
- a list of document identifiers.
-
reorderDocuments
public void reorderDocuments(List<SimpleDocument> documents)
Description copied from interface:AttachmentService
Reorders the documents in the given list according their order in the list.- Specified by:
reorderDocuments
in interfaceAttachmentService
- Parameters:
documents
- the documents to reorder.
-
getBinaryContent
public void getBinaryContent(OutputStream output, SimpleDocumentPK pk, String lang)
Description copied from interface:AttachmentService
Writes the binary content into the specified OutputStream.- Specified by:
getBinaryContent
in interfaceAttachmentService
- Parameters:
output
- the stream where the content is to be written.pk
- the id of the document.lang
- the language of the content.
-
getBinaryContent
public void getBinaryContent(OutputStream output, SimpleDocumentPK pk, String lang, long contentOffset, long contentLength)
Description copied from interface:AttachmentService
Writes the binary content contained between begin and end indexes into the specified OutputStream.- Specified by:
getBinaryContent
in interfaceAttachmentService
- Parameters:
output
- the stream where the content is to be written.pk
- the id of the document.lang
- the language of the content.contentOffset
- number of bytes to skip from input content before copying into output.contentLength
- number of bytes to copy.
-
listDocumentsRequiringWarning
public List<SimpleDocument> listDocumentsRequiringWarning(Date alertDate, String language)
Description copied from interface:AttachmentService
Search all the documents in an instance which are locked at the alert date.- Specified by:
listDocumentsRequiringWarning
in interfaceAttachmentService
- Parameters:
alertDate
- the date when a warning is required.language
- the language in which the documents are required.- Returns:
- an ordered list of the documents.
-
listExpiringDocuments
public List<SimpleDocument> listExpiringDocuments(Date expiryDate, String language)
Description copied from interface:AttachmentService
Search all the documents in an instance which require an alert at the specified date.- Specified by:
listExpiringDocuments
in interfaceAttachmentService
- Parameters:
expiryDate
- the date when the document reservation should alter.language
- the language in which the documents are required.- Returns:
- an ordered list of the documents.
-
listDocumentsToUnlock
public List<SimpleDocument> listDocumentsToUnlock(Date expiryDate, String language)
Description copied from interface:AttachmentService
Search all the documents in an instance requiring to be unlocked at the specified date.- Specified by:
listDocumentsToUnlock
in interfaceAttachmentService
- Parameters:
expiryDate
- the date when the document reservation should expire.language
- the language in which the documents are required.- Returns:
- an ordered list of the documents.
-
updateAttachment
@PreventAttachmentHugeProcess @SimulationActionProcess(elementLister=AttachmentSimulationElementLister.class) @Action(UPDATE) public void updateAttachment(@SourceObject @TargetPK SimpleDocument document, File content, boolean indexIt, boolean notify)
Description copied from interface:AttachmentService
Updates the specified whole document with its content either by updating the given content or by adding it among its others contents.The filename returned by
SimpleDocument.getFilename()
is normalized in order to get only single character encoding and no more combined characters. The normalized filename is set to given document.- Specified by:
updateAttachment
in interfaceAttachmentService
- Parameters:
document
- the document to update.content
- the content to update or to add (in the case of multi-languages support).indexIt
- true if the change has to be indexed. False otherwise.notify
- true if a notification about the update has to be sent. False otherwise.
-
getBinaryContent
public void getBinaryContent(File file, SimpleDocumentPK pk, String lang)
Description copied from interface:AttachmentService
Writes the binary content into the specified File.- Specified by:
getBinaryContent
in interfaceAttachmentService
- Parameters:
file
- the file where the content is to be written.pk
- the id of the document.lang
- the language of the content.
-
createAttachment
@PreventAttachmentHugeProcess @SimulationActionProcess(elementLister=AttachmentSimulationElementLister.class) @Action(CREATE) public SimpleDocument createAttachment(@SourceObject @TargetPK SimpleDocument document, File content)
Description copied from interface:AttachmentService
Creates the attachment and saves the content of the specified document. The created document is indexed and a notification about the creation is sent.The filename returned by
SimpleDocument.getFilename()
is normalized in order to get only single character encoding and no more combined characters. The normalized filename is set to the given document.- Specified by:
createAttachment
in interfaceAttachmentService
- Parameters:
document
- the document to be created.content
- the binary content of the document.- Returns:
- the stored document.
-
createAttachment
@PreventAttachmentHugeProcess @SimulationActionProcess(elementLister=AttachmentSimulationElementLister.class) @Action(CREATE) public SimpleDocument createAttachment(@SourceObject @TargetPK SimpleDocument document, File content, boolean indexIt)
Description copied from interface:AttachmentService
Creates the attachment, saves the content of the specified document and indexes it if asked. Once the attachment created, a notification about this creation is then sent.The filename returned by
SimpleDocument.getFilename()
is normalized in order to get only single character encoding and no more combined characters. The normalized filename is set to the given document.- Specified by:
createAttachment
in interfaceAttachmentService
- Parameters:
document
- the document to be created.content
- the binary content of the document.indexIt
- true if the document has to be indexed, false otherwise.- Returns:
- the stored document.
-
createAttachment
@PreventAttachmentHugeProcess @SimulationActionProcess(elementLister=AttachmentSimulationElementLister.class) @Action(CREATE) public SimpleDocument createAttachment(@SourceObject @TargetPK SimpleDocument document, File content, boolean indexIt, boolean notify)
Description copied from interface:AttachmentService
Creates the attachment, saves the content of the specified document, indexes it if asked, and notifies about the creation.The filename returned by
SimpleDocument.getFilename()
is normalized in order to get only single character encoding and no more combined characters. The normalized filename is set to the given document.- Specified by:
createAttachment
in interfaceAttachmentService
- Parameters:
document
- the document to be created.content
- the binary content of the document.indexIt
- true if the document has to be indexed, false otherwise.notify
- true if a notification about the creation has to be sent, false otherwise.- Returns:
- the stored document.
-
unlock
public boolean unlock(UnlockContext context)
Description copied from interface:AttachmentService
Release a locked file.- Specified by:
unlock
in interfaceAttachmentService
- Parameters:
context
- : the unlock parameters.- Returns:
- false if the file is locked - true if the unlock succeeded.
-
lock
public boolean lock(String attachmentId, String userId, String language)
Description copied from interface:AttachmentService
Checkout a file to be updated by user.- Specified by:
lock
in interfaceAttachmentService
- Parameters:
attachmentId
- the id of the attachment to be locked.userId
- : the user locking and modifying the attachment.language
- the language of the attachment.- Returns:
- false if the attachment is already checkout - true if the attachment was successfully checked out.
-
changeVersionState
@PreventAttachmentHugeProcess public SimpleDocumentPK changeVersionState(@SourcePK SimpleDocumentPK pk, String comment)
Description copied from interface:AttachmentService
Change the management of versions of the document. If the document is currently with version management, then all history is removed and the document becomes a simple document with no more version management. If the document has no version management then a new public version is created and the document becomes a document with a version history management. F- Specified by:
changeVersionState
in interfaceAttachmentService
- Parameters:
pk
- the id of the document.comment
- the comment of the versioned document if we are switching from simple to versioned.- Returns:
- the pk to the document after is state change.
-
findExistingDocument
public SimpleDocument findExistingDocument(SimpleDocumentPK pk, String fileName, ResourceReference foreign, String lang)
Description copied from interface:AttachmentService
Find documents with the same name attached to the specified foreign id.- Specified by:
findExistingDocument
in interfaceAttachmentService
- Parameters:
pk
- the id of the document.fileName
- the name of the file.foreign
- the id of the container of the document.lang
- the language of the document.- Returns:
- a document with the same filename - null if none is found.
-
listDocumentsByForeignKeyAndType
public SimpleDocumentList<SimpleDocument> listDocumentsByForeignKeyAndType(ResourceReference foreignKey, DocumentType type, String lang)
Description copied from interface:AttachmentService
Search all the documents attached to the specified resource, for a given type of document, and in the specified language.- Specified by:
listDocumentsByForeignKeyAndType
in interfaceAttachmentService
- Parameters:
foreignKey
- a reference to the resource.type
- the type of the documents to search.lang
- the ISO-621 code of a language.- Returns:
- the list of documents attached to the specified resource.
-
listDocumentsLockedByUser
public List<SimpleDocument> listDocumentsLockedByUser(String usedId, String language)
Description copied from interface:AttachmentService
Search all the documents locked by a specific user.- Specified by:
listDocumentsLockedByUser
in interfaceAttachmentService
- Parameters:
usedId
- the id of the user.language
- the language in which the documents are required.- Returns:
- an ordered list of the documents.
-
moveDocument
@PreventAttachmentHugeProcess @SimulationActionProcess(elementLister=AttachmentSimulationElementLister.class) @Action(MOVE) public SimpleDocumentPK moveDocument(@SourceObject SimpleDocument document, @TargetPK ResourceReference destination)
Description copied from interface:AttachmentService
Moves the specified document to the given resource.- Specified by:
moveDocument
in interfaceAttachmentService
- Parameters:
document
- the document to be moved.destination
- the resource to which the document has to be attached.- Returns:
- the new document identifier once moved.
-
moveAllDocuments
@PreventAttachmentHugeProcess @SimulationActionProcess(elementLister=AttachmentSimulationElementLister.class) @Action(MOVE) public List<SimpleDocumentPK> moveAllDocuments(@SourcePK ResourceReference sourceResource, @TargetPK ResourceReference destinationResource)
Description copied from interface:AttachmentService
Moves all the attachments linked to the specified resource to the another one.- Specified by:
moveAllDocuments
in interfaceAttachmentService
- Parameters:
sourceResource
- the reference of the resource (identifier and component instance) from which linked attachments must be moved.destinationResource
- the reference of the resource (identifier and component instance) that will get the moved attachments.- Returns:
- le list of moved attachments, empty if nothing is moved.
-
updateIndexEntryWithDocuments
public void updateIndexEntryWithDocuments(FullIndexEntry indexEntry)
Description copied from interface:AttachmentService
Add the documents to the index.- Specified by:
updateIndexEntryWithDocuments
in interfaceAttachmentService
- Specified by:
updateIndexEntryWithDocuments
in interfaceDocumentIndexing
- Parameters:
indexEntry
- the entry to be updated with the document indexes.
-
indexAllDocuments
public void indexAllDocuments(ResourceReference resource, Date startOfVisibilityPeriod, Date endOfVisibilityPeriod)
Description copied from interface:AttachmentService
Indexes all the documents (whatever their type) of the given resource.- Specified by:
indexAllDocuments
in interfaceAttachmentService
- Parameters:
resource
- the resource.startOfVisibilityPeriod
- the start date of the document visibility. It can be null.endOfVisibilityPeriod
- the end date of the document visibility. It can be null.
-
mergeDocuments
@PreventAttachmentHugeProcess public Map<String,String> mergeDocuments(@SourcePK ResourceReference originalResource, @TargetPK ResourceReference clonedResource, DocumentType type)
Description copied from interface:AttachmentService
Merges the documents of the cloned resource with their original counterparts.- Specified by:
mergeDocuments
in interfaceAttachmentService
- Parameters:
originalResource
- the original resource.clonedResource
- the cloned resource.type
- the type of the documents to merge.- Returns:
- a map with the cloned document identifier as key and the original document identifier as value.
-
switchComponentBehaviour
@AttachmentHugeProcess public void switchComponentBehaviour(@SourceObject String componentId, boolean versioned)
Description copied from interface:AttachmentService
Change the management of versions of the documents of a whole component (only attachments are taken into account). If the document is currently with version management, then all history is removed and the document becomes a simple document with no more version management. If the document has no version management then a new public version is created and the document becomes a document with a version history management.- Specified by:
switchComponentBehaviour
in interfaceAttachmentService
- Parameters:
componentId
- the id of the component switching its behaviour.versioned
- if set to true all simple attachments become versioned, if false all versioned attachments become simple attachments.
-
switchAllowingDownloadForReaders
@PreventAttachmentHugeProcess public void switchAllowingDownloadForReaders(@SourcePK SimpleDocumentPK pk, boolean allowing)
Description copied from interface:AttachmentService
Allows or forbids the download for readers.- Specified by:
switchAllowingDownloadForReaders
in interfaceAttachmentService
- Parameters:
pk
- the id of the document.allowing
- : allowing the download for readers if true versioned attachments become simple attachments.
-
switchEnableDisplayAsContent
@PreventAttachmentHugeProcess public void switchEnableDisplayAsContent(@SourcePK SimpleDocumentPK pk, boolean enable)
Description copied from interface:AttachmentService
Enables or not the display of the content of an attachment.- Specified by:
switchEnableDisplayAsContent
in interfaceAttachmentService
- Parameters:
pk
- the id of the document.enable
- enable the display if true
-
switchEnableEditSimultaneously
@PreventAttachmentHugeProcess public void switchEnableEditSimultaneously(@SourcePK SimpleDocumentPK pk, boolean enable)
Description copied from interface:AttachmentService
Enables or not the simultaneous edition of the content of an attachment.- Specified by:
switchEnableEditSimultaneously
in interfaceAttachmentService
- Parameters:
pk
- the id of the document.enable
- enable edition simultaneously if true
-
delete
public void delete(String componentInstanceId)
Description copied from interface:ComponentInstanceDeletion
Deletes the resources belonging to the specified component instance. This method is invoked by Silverpeas when a component instance is being deleted.- Specified by:
delete
in interfaceComponentInstanceDeletion
- Parameters:
componentInstanceId
- the unique identifier of a component instance.
-
-