org.silverpeas.attachment
Interface AttachmentService

All Known Implementing Classes:
SimpleDocumentService, SimpleDocumentServiceWrapper

public interface AttachmentService

Author:
ehugonnet

Field Summary
static String NO_UPDATE_MODE
           
static String UPDATE_DIRECT_MODE
           
static String UPDATE_SHORTCUT_MODE
           
static String VERSION_MODE
           
 
Method Summary
 void addXmlForm(SimpleDocumentPK pk, String language, String xmlFormName)
           
 SimpleDocumentPK changeVersionState(SimpleDocumentPK pk, String comment)
          Change the management of versions of the document.
 SimpleDocumentPK cloneDocument(SimpleDocument original, String foreignCloneId)
          Clone the document to a cloned container.
 List<SimpleDocumentPK> copyAllDocuments(WAPrimaryKey resourceSourcePk, WAPrimaryKey targetDestinationPk)
          Copies all the attachment linked to a resource to another one.
 SimpleDocumentPK copyDocument(SimpleDocument original, ForeignPK targetPk)
          Copies the attachment.
 SimpleDocument createAttachment(SimpleDocument document, File content)
          Create file attached to an object who is identified by the foreignId.
 SimpleDocument createAttachment(SimpleDocument document, File content, boolean indexIt)
          Create file attached to an object who is identified by the foreignId.
 SimpleDocument createAttachment(SimpleDocument document, File content, boolean indexIt, boolean invokeCallback)
          Create file attached to an object who is identified by the foreignId.
 SimpleDocument createAttachment(SimpleDocument document, InputStream content)
          Create file attached to an object who is identified by the foreignId.
 SimpleDocument createAttachment(SimpleDocument document, InputStream content, boolean indexIt)
          Create file attached to an object who is identified by the foreignId.
 SimpleDocument createAttachment(SimpleDocument document, InputStream content, boolean indexIt, boolean invokeCallback)
          Create file attached to an object who is identified by the foreignId.
 void createIndex(SimpleDocument document)
           
 void createIndex(SimpleDocument document, Date startOfVisibilityPeriod, Date endOfVisibilityPeriod)
           
 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 document attached to a component resource.
 void deleteAttachment(SimpleDocument document)
          Delete a given attachment.
 void deleteAttachment(SimpleDocument document, boolean invokeCallback)
          Delete a given attachment.
 void deleteIndex(SimpleDocument document)
           
 SimpleDocument findExistingDocument(SimpleDocumentPK pk, String fileName, ForeignPK 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(WAPrimaryKey fk, Date startOfVisibilityPeriod, Date endOfVisibilityPeriod)
          Indexes all the documents (whatever their type) of a container.
 SimpleDocumentList<SimpleDocument> listAllDocumentsByForeignKey(WAPrimaryKey foreignKey, String lang)
          Search all documents (files, xmlform content, wysiwyg) attached to a foreign object.
 SimpleDocumentList<SimpleDocument> listDocumentsByForeignKey(WAPrimaryKey foreignKey, String lang)
          Search all files attached to a foreign object.
 SimpleDocumentList<SimpleDocument> listDocumentsByForeignKeyAndType(WAPrimaryKey foreignKey, DocumentType type, String lang)
          Search all file attached to a foreign object.
 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 alertDate, 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(ForeignPK originalForeignKey, ForeignPK cloneForeignKey, DocumentType type)
          Merges the documents of cloned container with the original documents.
 List<SimpleDocumentPK> moveAllDocuments(WAPrimaryKey resourceSourcePk, WAPrimaryKey targetDestinationPk)
           
 SimpleDocumentPK moveDocument(SimpleDocument document, ForeignPK destination)
          Moves the attachment.
 void removeContent(SimpleDocument document, String lang, boolean invokeCallback)
          To remove the content of the document in the specified language.
 void reorderAttachments(List<SimpleDocumentPK> pks)
          Reorder the attachments according to the order in the list.
 void reorderDocuments(List<SimpleDocument> documents)
          Reorder the attachments according to the order in the list.
 SimpleDocument searchDocumentById(SimpleDocumentPK primaryKey, String lang)
          Search the document.
 void switchAllowingDownloadForReaders(SimpleDocumentPK pk, boolean allowing)
          Allows or forbids the download for readers.
 void switchComponentBehaviour(String componentId, boolean toVersionning)
          Change the management of versions of the documents of a whole component (only attachments are taken into account).
 void unindexAttachmentsOfExternalObject(WAPrimaryKey foreignKey)
           
 boolean unlock(UnlockContext context)
          Release a locked file.
 void updateAttachment(SimpleDocument document, boolean indexIt, boolean invokeCallback)
          To update the document : status, metadata but not its content.
 void updateAttachment(SimpleDocument document, File content, boolean indexIt, boolean invokeCallback)
          To update a document content by updating or adding some content.
 void updateAttachment(SimpleDocument document, InputStream content, boolean indexIt, boolean invokeCallback)
          To update a document content by updating or adding some content.
 void updateIndexEntryWithDocuments(FullIndexEntry indexEntry)
          Add the documents to the index.
 

Field Detail

VERSION_MODE

static final String VERSION_MODE
See Also:
Constant Field Values

NO_UPDATE_MODE

static final String NO_UPDATE_MODE
See Also:
Constant Field Values

UPDATE_DIRECT_MODE

static final String UPDATE_DIRECT_MODE
See Also:
Constant Field Values

UPDATE_SHORTCUT_MODE

static final String UPDATE_SHORTCUT_MODE
See Also:
Constant Field Values
Method Detail

deleteAllAttachments

void deleteAllAttachments(String componentInstanceId)
                          throws AttachmentException
Deletes all the documents related to the component instance identified by the specified identifier.

Parameters:
componentInstanceId - the component instance identifier.
Throws:
AttachmentException

getBinaryContent

void getBinaryContent(File file,
                      SimpleDocumentPK pk,
                      String lang)
Writes the binary content into the specified File.

Parameters:
file - the file where the content is to be written.
pk - the id of the document.
lang - the language of the content.

getBinaryContent

void getBinaryContent(OutputStream output,
                      SimpleDocumentPK pk,
                      String lang)
Writes the binary content into the specified OutputStream.

Parameters:
output - the stream where the content is to be written.
pk - the id of the document.
lang - the language of the content.

getBinaryContent

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.

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.

addXmlForm

void addXmlForm(SimpleDocumentPK pk,
                String language,
                String xmlFormName)

cloneDocument

SimpleDocumentPK cloneDocument(SimpleDocument original,
                               String foreignCloneId)
Clone the document to a cloned container.

Parameters:
original -
foreignCloneId -
Returns:

mergeDocuments

Map<String,String> mergeDocuments(ForeignPK originalForeignKey,
                                  ForeignPK cloneForeignKey,
                                  DocumentType type)
Merges the documents of cloned container with the original documents.

Parameters:
originalForeignKey -
cloneForeignKey -
type -
Returns:
a map with the cloned document id as key and the original document id as value.

copyDocument

SimpleDocumentPK copyDocument(SimpleDocument original,
                              ForeignPK targetPk)
Copies the attachment.

Parameters:
original -
targetPk -
Returns:

copyAllDocuments

List<SimpleDocumentPK> copyAllDocuments(WAPrimaryKey resourceSourcePk,
                                        WAPrimaryKey targetDestinationPk)
Copies all the attachment linked to a resource to another one.

Parameters:
resourceSourcePk - the identifier of the resource and its location (component instance) which linked attachments must be copied.
targetDestinationPk - the identifier of the resource and its location (component instance) that will get the copied attachments.
Returns:
le list of copied attachments, empty if nothing is copied.

moveDocument

SimpleDocumentPK moveDocument(SimpleDocument document,
                              ForeignPK destination)
Moves the attachment.

Parameters:
document - to be moved.
destination - the foreign id to be moved to.
Returns:
the new document id.

moveAllDocuments

List<SimpleDocumentPK> moveAllDocuments(WAPrimaryKey resourceSourcePk,
                                        WAPrimaryKey targetDestinationPk)

createAttachment

SimpleDocument createAttachment(SimpleDocument document,
                                InputStream content)
                                throws AttachmentException
Create file attached to an object who is identified by the foreignId.

Parameters:
document - the document to be created.
content - the binary content of the document.
Returns:
the stored document.
Throws:
AttachmentException

createAttachment

SimpleDocument createAttachment(SimpleDocument document,
                                InputStream content,
                                boolean indexIt)
Create file attached to an object who is identified by the foreignId.

Parameters:
document - the document to be created.
content - the binary content of the document.
indexIt - true if the document is to be indexed - false otherwhise.
Returns:
the stored document.

createAttachment

SimpleDocument createAttachment(SimpleDocument document,
                                InputStream content,
                                boolean indexIt,
                                boolean invokeCallback)
Create file attached to an object who is identified by the foreignId.

Parameters:
document - the document to be created.
content - the binary content of the document.
indexIt - true if the document is to be indexed - false otherwise.
invokeCallback - true if the callback methods of the components must be called, false for ignoring thoose callbacks.
Returns:
the stored document.

createAttachment

SimpleDocument createAttachment(SimpleDocument document,
                                File content)
                                throws AttachmentException
Create file attached to an object who is identified by the foreignId.

Parameters:
document - the document to be created.
content - the binary content of the document.
Returns:
the stored document.
Throws:
AttachmentException

createAttachment

SimpleDocument createAttachment(SimpleDocument document,
                                File content,
                                boolean indexIt)
Create file attached to an object who is identified by the foreignId.

Parameters:
document - the document to be created.
content - the binary content of the document.
indexIt - true if the document is to be indexed, false otherwhise.
Returns:
the stored document.

createAttachment

SimpleDocument createAttachment(SimpleDocument document,
                                File content,
                                boolean indexIt,
                                boolean invokeCallback)
Create file attached to an object who is identified by the foreignId.

Parameters:
document - the document to be created.
content - the binary content of the document.
indexIt - true if the document is to be indexed, false otherwhise.
invokeCallback - true if the callback methods of the components must be called, false for ignoring thoose callbacks.
Returns:
the stored document.

createIndex

void createIndex(SimpleDocument document)
Parameters:
document -

deleteIndex

void deleteIndex(SimpleDocument document)
Parameters:
document -

createIndex

void createIndex(SimpleDocument document,
                 Date startOfVisibilityPeriod,
                 Date endOfVisibilityPeriod)
Parameters:
document -
startOfVisibilityPeriod -
endOfVisibilityPeriod -

deleteAllAttachments

void deleteAllAttachments(String resourceId,
                          String componentInstanceId)
Deletes all the document attached to a component resource.

Parameters:
resourceId - the identifier of the resource.
componentInstanceId - the identifier of the component instance into which the resource is referenced.

deleteAttachment

void deleteAttachment(SimpleDocument document)
Delete a given attachment.

Parameters:
document - the document to deleted.

deleteAttachment

void deleteAttachment(SimpleDocument document,
                      boolean invokeCallback)
Delete a given attachment.

Parameters:
document - the document to deleted.
invokeCallback - true if the callback methods of the components must be called, false for ignoring thoose callbacks.
Throws:
AttachmentException - if the attachement cannot be deleted.

removeContent

void removeContent(SimpleDocument document,
                   String lang,
                   boolean invokeCallback)
To remove the content of the document in the specified language.

Parameters:
document -
lang -
invokeCallback -

reorderAttachments

void reorderAttachments(List<SimpleDocumentPK> pks)
                        throws AttachmentException
Reorder the attachments according to the order in the list.

Parameters:
pks -
Throws:
AttachmentException

reorderDocuments

void reorderDocuments(List<SimpleDocument> documents)
                      throws AttachmentException
Reorder the attachments according to the order in the list.

Parameters:
documents -
Throws:
AttachmentException

searchDocumentById

SimpleDocument searchDocumentById(SimpleDocumentPK primaryKey,
                                  String lang)
Search the document.

Parameters:
primaryKey - the primary key of document.
lang - the lang of the document.
Returns:
java.util.Vector: a collection of AttachmentDetail
Throws:
AttachmentException - when is impossible to search

listDocumentsByForeignKey

SimpleDocumentList<SimpleDocument> listDocumentsByForeignKey(WAPrimaryKey foreignKey,
                                                             String lang)
Search all files attached to a foreign object.

Parameters:
foreignKey - : the primary key of foreign object.
lang - the language of the documents.
Returns:
the list of attached documents.
Throws:
AttachmentException - when is impossible to search

listAllDocumentsByForeignKey

SimpleDocumentList<SimpleDocument> listAllDocumentsByForeignKey(WAPrimaryKey foreignKey,
                                                                String lang)
Search all documents (files, xmlform content, wysiwyg) attached to a foreign object.

Parameters:
foreignKey - : the primary key of foreign object.
lang - the language of the documents.
Returns:
the list of attached documents.
Throws:
AttachmentException - when is impossible to search

listDocumentsByForeignKeyAndType

SimpleDocumentList<SimpleDocument> listDocumentsByForeignKeyAndType(WAPrimaryKey foreignKey,
                                                                    DocumentType type,
                                                                    String lang)
Search all file attached to a foreign object.

Parameters:
foreignKey - : the primary key of foreign object.
type - : the type of document
lang - the lang for the documents.
Returns:
the list of attached documents.
Throws:
AttachmentException - when is impossible to search

unindexAttachmentsOfExternalObject

void unindexAttachmentsOfExternalObject(WAPrimaryKey foreignKey)

updateAttachment

void updateAttachment(SimpleDocument document,
                      boolean indexIt,
                      boolean invokeCallback)
To update the document : status, metadata but not its content.

Parameters:
document -
indexIt -
invokeCallback -

updateAttachment

void updateAttachment(SimpleDocument document,
                      File content,
                      boolean indexIt,
                      boolean invokeCallback)
To update a document content by updating or adding some content.

Parameters:
document -
content -
indexIt -
invokeCallback -

updateAttachment

void updateAttachment(SimpleDocument document,
                      InputStream content,
                      boolean indexIt,
                      boolean invokeCallback)
To update a document content by updating or adding some content.

Parameters:
document -
content -
indexIt -
invokeCallback -

listDocumentsRequiringWarning

List<SimpleDocument> listDocumentsRequiringWarning(Date alertDate,
                                                   String language)
Search all the documents in an instance which are locked at the alert date.

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

List<SimpleDocument> listExpiringDocuments(Date alertDate,
                                           String language)
Search all the documents in an instance which require an alert at the specified date.

Parameters:
alertDate - 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

List<SimpleDocument> listDocumentsToUnlock(Date expiryDate,
                                           String language)
Search all the documents in an instance requiring to be unlocked at the specified date.

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.

lock

boolean lock(String attachmentId,
             String userId,
             String language)
Checkout a file to be updated by user.

Parameters:
attachmentId - the id of the attachemnt 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.

unlock

boolean unlock(UnlockContext context)
Release a locked file.

Parameters:
context - : the unlock parameters.
Returns:
false if the file is locked - true if the unlock succeeded.
Throws:
AttachmentException

changeVersionState

SimpleDocumentPK changeVersionState(SimpleDocumentPK pk,
                                    String comment)
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

Parameters:
pk - the id of the document.
comment - the comment of the versioned documetn if we are switching from simple to versioned.
Returns:
the pk to the document after is state change.

findExistingDocument

SimpleDocument findExistingDocument(SimpleDocumentPK pk,
                                    String fileName,
                                    ForeignPK foreign,
                                    String lang)
Find documents with the same name attached to the specified foreign id.

Parameters:
fileName - the name of the file.
pk - the id of the document.
lang - the language of the document.
foreign - the id of the container of the document.
Returns:
a document with the same filename - null if none is found.

listDocumentsLockedByUser

List<SimpleDocument> listDocumentsLockedByUser(String usedId,
                                               String language)
Search all the documents locked by a specific user.

Parameters:
usedId - the id of the user.
language - the language in which the documents are required.
Returns:
an ordered list of the documents.

updateIndexEntryWithDocuments

void updateIndexEntryWithDocuments(FullIndexEntry indexEntry)
Add the documents to the index.

Parameters:
indexEntry - the entry to be updated with the document indexes.

indexAllDocuments

void indexAllDocuments(WAPrimaryKey fk,
                       Date startOfVisibilityPeriod,
                       Date endOfVisibilityPeriod)
Indexes all the documents (whatever their type) of a container.

Parameters:
fk - the id of the container of the document.
startOfVisibilityPeriod - can be null.
endOfVisibilityPeriod - can be null.

switchComponentBehaviour

void switchComponentBehaviour(String componentId,
                              boolean toVersionning)
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.

Parameters:
componentId - : the id of the component switching its behaviour.
toVersionning: - if set to true all simple attachments become versioned, if false all versioned attachments become simple attachments.

switchAllowingDownloadForReaders

void switchAllowingDownloadForReaders(SimpleDocumentPK pk,
                                      boolean allowing)
Allows or forbids the download for readers.

Parameters:
pk - the id of the document.
allowing: - allowing the download for readers if true versioned attachments become simple attachments.


Copyright © 2016 Silverpeas. All Rights Reserved.