Class DocumentRepository

    • Constructor Detail

      • DocumentRepository

        public DocumentRepository()
    • Method Detail

      • prepareComponentAttachments

        public void prepareComponentAttachments​(String instanceId,
                                                String folder)
                                         throws javax.jcr.RepositoryException
        Throws:
        javax.jcr.RepositoryException
      • prepareComponentAttachments

        protected javax.jcr.Node prepareComponentAttachments​(javax.jcr.Session session,
                                                             String instanceId,
                                                             String folder)
                                                      throws javax.jcr.RepositoryException
        Throws:
        javax.jcr.RepositoryException
      • createDocument

        public SimpleDocumentPK createDocument​(javax.jcr.Session session,
                                               SimpleDocument document)
                                        throws javax.jcr.RepositoryException
        Create file attached to an object who is identified by "PK" SimpleDocument object contains an attribute who identifie the link by a foreign key.
        Parameters:
        session -
        document -
        Returns:
        Throws:
        javax.jcr.RepositoryException
      • moveDocument

        public SimpleDocumentPK moveDocument​(javax.jcr.Session session,
                                             SimpleDocument document,
                                             ResourceReference destination)
                                      throws javax.jcr.RepositoryException
        Move the document to another attached object.
        Parameters:
        session -
        document -
        destination -
        Returns:
        Throws:
        javax.jcr.RepositoryException
      • copyDocument

        public SimpleDocumentPK copyDocument​(javax.jcr.Session session,
                                             SimpleDocument document,
                                             ResourceReference destination)
                                      throws javax.jcr.RepositoryException
        Copy the document to another attached object.
        Parameters:
        session -
        document -
        destination - the foreingId holding reference to the copy.
        Returns:
        Throws:
        javax.jcr.RepositoryException
      • copyDocument

        public SimpleDocumentPK copyDocument​(javax.jcr.Session session,
                                             HistorisedDocument document,
                                             ResourceReference destination)
                                      throws javax.jcr.RepositoryException
        Copy the document to another attached object.
        Parameters:
        session -
        document -
        destination - the foreingId holding reference to the copy.
        Returns:
        Throws:
        javax.jcr.RepositoryException
      • updateDocument

        public void updateDocument​(javax.jcr.Session session,
                                   SimpleDocument document,
                                   boolean updateLastModifiedData)
                            throws javax.jcr.RepositoryException
        Create file attached to an object who is identified by "PK" SimpleDocument object contains an attribute who identifie the link by a foreign key.
        Parameters:
        session -
        document -
        updateLastModifiedData -
        Throws:
        javax.jcr.RepositoryException
      • saveForbiddenDownloadForRoles

        public void saveForbiddenDownloadForRoles​(javax.jcr.Session session,
                                                  SimpleDocument document)
                                           throws javax.jcr.RepositoryException
        Save the optional slv:forbiddenDownloadForRoles simple document property (MIXIN). This saving works with versionable documents without changing the major and minor version. This property is transverse between all versions.
        Parameters:
        session -
        document -
        Throws:
        javax.jcr.RepositoryException
      • saveDisplayableAsContent

        public void saveDisplayableAsContent​(javax.jcr.Session session,
                                             SimpleDocument document)
                                      throws javax.jcr.RepositoryException
        Save the optional slv:displayableAsContent simple document property (MIXIN). This saving works with versionable documents without changing the major and minor version. This property is transverse between all versions.
        Parameters:
        session -
        document -
        Throws:
        javax.jcr.RepositoryException
      • saveEditableSimultaneously

        public void saveEditableSimultaneously​(javax.jcr.Session session,
                                               SimpleDocument document)
                                        throws javax.jcr.RepositoryException
        Save the optional slv:editableSimultaneously simple document property (MIXIN). This saving works with versionable documents without changing the major and minor version. This property is transverse between all versions.
        Parameters:
        session -
        document -
        Throws:
        javax.jcr.RepositoryException
      • setClone

        public void setClone​(javax.jcr.Session session,
                             SimpleDocument original,
                             SimpleDocument clone)
                      throws javax.jcr.RepositoryException
        Add the document's clone id to the document even if it is locked. This saving works with versionable documents without changing the major and minor version. This property is transverse between all versions.
        Parameters:
        session - the JCR session.
        original - the original document to be cloned.
        clone - the cone of the original document.
        Throws:
        javax.jcr.RepositoryException
      • setOrder

        public void setOrder​(javax.jcr.Session session,
                             SimpleDocument document)
                      throws javax.jcr.RepositoryException
        Update the document order. This is a unique operation since the order property is not versionable. This saving works with versionable documents without changing the major and minor version. This property is transverse between all versions.
        Throws:
        javax.jcr.RepositoryException
      • deleteDocument

        public void deleteDocument​(javax.jcr.Session session,
                                   SimpleDocumentPK documentPk)
                            throws javax.jcr.RepositoryException
        Delete a file attached to an object who is identified by "PK" SimpleDocument object contains an attribute who identifie the link by a foreign key.
        Parameters:
        session -
        documentPk -
        Throws:
        javax.jcr.RepositoryException
      • changeVersionState

        public SimpleDocumentPK changeVersionState​(javax.jcr.Session session,
                                                   SimpleDocumentPK documentPk,
                                                   String comment)
                                            throws javax.jcr.RepositoryException,
                                                   IOException
        Change the management of versions of the document if the document is checkouted. 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:
        session -
        documentPk - the id of the document.
        comment -
        Throws:
        javax.jcr.RepositoryException
        IOException
      • findDocumentById

        public SimpleDocument findDocumentById​(javax.jcr.Session session,
                                               SimpleDocumentPK documentPk,
                                               String lang)
                                        throws javax.jcr.RepositoryException
        Parameters:
        session -
        documentPk -
        lang -
        Returns:
        Throws:
        javax.jcr.RepositoryException
      • findDocumentByOldSilverpeasId

        public SimpleDocument findDocumentByOldSilverpeasId​(javax.jcr.Session session,
                                                            String instanceId,
                                                            long oldSilverpeasId,
                                                            boolean versioned,
                                                            String lang)
                                                     throws javax.jcr.RepositoryException
        Parameters:
        session -
        instanceId -
        oldSilverpeasId -
        versioned -
        lang -
        Returns:
        Throws:
        javax.jcr.RepositoryException
      • listDocumentsByForeignId

        public SimpleDocumentList<SimpleDocument> listDocumentsByForeignId​(javax.jcr.Session session,
                                                                           String instanceId,
                                                                           String foreignId,
                                                                           String language)
                                                                    throws javax.jcr.RepositoryException
        Search all the documents of type attachment in an instance with the specified foreignId.
        Parameters:
        session - the current JCR session.
        instanceId - the component id containing the documents.
        foreignId - the id of the container owning the documents.
        language - the language in which the documents are required.
        Returns:
        an ordered list of the documents.
        Throws:
        javax.jcr.RepositoryException
      • listAllDocumentsByForeignId

        public SimpleDocumentList<SimpleDocument> listAllDocumentsByForeignId​(javax.jcr.Session session,
                                                                              String instanceId,
                                                                              String foreignId,
                                                                              String language)
                                                                       throws javax.jcr.RepositoryException
        Search all the documents of any type in an instance with the specified foreignId.
        Parameters:
        session - the current JCR session.
        instanceId - the component id containing the documents.
        foreignId - the id of the container owning the documents.
        language - the language in which the documents are required.
        Returns:
        an ordered list of the documents.
        Throws:
        javax.jcr.RepositoryException
      • listDocumentsByForeignIdAndType

        public SimpleDocumentList<SimpleDocument> listDocumentsByForeignIdAndType​(javax.jcr.Session session,
                                                                                  String instanceId,
                                                                                  String foreignId,
                                                                                  DocumentType type,
                                                                                  String language)
                                                                           throws javax.jcr.RepositoryException
        Search all the documents in an instance with the specified foreignId.
        Parameters:
        session - the current JCR session.
        instanceId - the component id containing the documents.
        foreignId - the id of the container owning the documents.
        type - thetype of required documents.
        language - the language in which the documents are required.
        Returns:
        an ordered list of the documents.
        Throws:
        javax.jcr.RepositoryException
      • listDocumentsByComponentIdAndType

        public List<SimpleDocument> listDocumentsByComponentIdAndType​(javax.jcr.Session session,
                                                                      String instanceId,
                                                                      DocumentType type,
                                                                      String language)
                                                               throws javax.jcr.RepositoryException
        Search all the documents in an instance with the specified type.
        Parameters:
        session - the current JCR session.
        instanceId - the component id containing the documents.
        type - thetype of required documents.
        language - the language in which the documents are required.
        Returns:
        an ordered list of the documents.
        Throws:
        javax.jcr.RepositoryException
      • listAllDocumentsByComponentId

        public List<SimpleDocument> listAllDocumentsByComponentId​(javax.jcr.Session session,
                                                                  String instanceId,
                                                                  String language)
                                                           throws javax.jcr.RepositoryException
        Search all the documents related to the component instance identified by the specified identifier.
        Parameters:
        session - the current JCR session.
        instanceId - the component id containing the documents.
        language - the language in which the documents are required.
        Returns:
        an ordered list of the documents.
        Throws:
        javax.jcr.RepositoryException
      • listComponentDocumentsByOwner

        public List<SimpleDocument> listComponentDocumentsByOwner​(javax.jcr.Session session,
                                                                  String instanceId,
                                                                  String owner,
                                                                  String language)
                                                           throws javax.jcr.RepositoryException
        Search all the documents in an instance with the specified owner.
        Parameters:
        session - the current JCR session.
        instanceId - the component id containing the documents.
        owner - the id of the user owning the document.
        language - the language in which the documents are required.
        Returns:
        an ordered list of the documents.
        Throws:
        javax.jcr.RepositoryException
      • listDocumentsLockedByUser

        public List<SimpleDocument> listDocumentsLockedByUser​(javax.jcr.Session session,
                                                              String usedId,
                                                              String language)
                                                       throws javax.jcr.RepositoryException
        Throws:
        javax.jcr.RepositoryException
      • listExpiringDocuments

        public List<SimpleDocument> listExpiringDocuments​(javax.jcr.Session session,
                                                          Date expiryDate,
                                                          String language)
                                                   throws javax.jcr.RepositoryException
        Search all the documents in an instance which are expiring at the specified date.
        Parameters:
        session - the current JCR session.
        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.
        Throws:
        javax.jcr.RepositoryException
      • listDocumentsRequiringWarning

        public List<SimpleDocument> listDocumentsRequiringWarning​(javax.jcr.Session session,
                                                                  Date alertDate,
                                                                  String language)
                                                           throws javax.jcr.RepositoryException
        Search all the documents in an instance which are locked at the alert date.
        Parameters:
        session - the current JCR session.
        alertDate - the date when the document reservation should send an alert.
        language - the language in which the documents are required.
        Returns:
        an ordered list of the documents.
        Throws:
        javax.jcr.RepositoryException
      • listDocumentsToUnlock

        public List<SimpleDocument> listDocumentsToUnlock​(javax.jcr.Session session,
                                                          Date expiryDate,
                                                          String language)
                                                   throws javax.jcr.RepositoryException
        Search all the documents in an instance requiring to be unlocked at the specified date.
        Parameters:
        session - the current JCR session.
        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.
        Throws:
        javax.jcr.RepositoryException
      • addContent

        public void addContent​(javax.jcr.Session session,
                               SimpleDocumentPK documentPk,
                               SimpleAttachment attachment)
                        throws javax.jcr.RepositoryException
        Add the content.
        Parameters:
        session - the current JCR session.
        documentPk - the document which content is to be added.
        attachment - the attachment metadata.
        Throws:
        javax.jcr.RepositoryException
      • getContent

        public InputStream getContent​(javax.jcr.Session session,
                                      SimpleDocumentPK pk,
                                      String lang)
                               throws javax.jcr.RepositoryException,
                                      IOException
        Get the content.
        Parameters:
        session - the current JCR session.
        pk - the document which content is to be added.
        lang - the content language.
        Returns:
        the attachment binary content.
        Throws:
        javax.jcr.RepositoryException
        IOException
      • removeContent

        public boolean removeContent​(javax.jcr.Session session,
                                     SimpleDocumentPK documentPk,
                                     String language)
                              throws javax.jcr.RepositoryException
        Remove the content for the specified language. If no other content exists, then the document node is deleted.
        Parameters:
        session - the current JCR session.
        documentPk - the document which content is to be removed.
        language - the language of the content which is to be removed.
        Returns:
        false if the document has no child node after the content remove, true otherwise.
        Throws:
        javax.jcr.RepositoryException
      • lock

        public boolean lock​(javax.jcr.Session session,
                            SimpleDocument document,
                            String owner)
                     throws javax.jcr.RepositoryException
        Lock a document if it is versionned to create a new work in progress version.
        Parameters:
        session -
        document -
        owner - the user locking the node.
        Returns:
        true if node has be checked out - false otherwise.
        Throws:
        javax.jcr.RepositoryException
      • unlock

        public SimpleDocument unlock​(javax.jcr.Session session,
                                     SimpleDocument document,
                                     boolean restore)
                              throws javax.jcr.RepositoryException
        Unlock a document if it is versionned to create a new version or to restore a previous one. By using this method, the metadata of the content are always updated.
        Parameters:
        session - the current JCR open session to perform actions.
        document - the document data from which all needed identifiers are retrieved.
        restore - true to restore the previous version if any.
        Returns:
        the result of unlock(Session, SimpleDocument, boolean, boolean) execution.
        Throws:
        javax.jcr.RepositoryException
      • unlockFromContentDeletion

        public SimpleDocument unlockFromContentDeletion​(javax.jcr.Session session,
                                                        SimpleDocument document)
                                                 throws javax.jcr.RepositoryException
        Unlock a document if it is versionned from a context into which a language content has just been deleted. This method does not update the metadata of the content in order to obtain an efficient content deletion.
        Parameters:
        session - the current JCR open session to perform actions.
        document - the document data from which all needed identifiers are retrieved.
        Returns:
        the result of unlock(Session, SimpleDocument, boolean, boolean) execution.
        Throws:
        javax.jcr.RepositoryException
      • setVersionnable

        public void setVersionnable​(javax.jcr.Session session,
                                    SimpleDocumentPK documentPk)
                             throws javax.jcr.RepositoryException
        Add the version feature to an existing document. If the document has already the version feature, nothing is done.
        Parameters:
        session -
        documentPk -
        Throws:
        javax.jcr.RepositoryException
      • removeVersionnable

        public void removeVersionnable​(javax.jcr.Session session,
                                       SimpleDocumentPK documentPk)
                                throws javax.jcr.RepositoryException
        Remove the version feature to an existing document. If the document doesn't have already the version feature, nothing is done.
        Parameters:
        session -
        documentPk -
        Throws:
        javax.jcr.RepositoryException
      • fillNodeName

        public void fillNodeName​(javax.jcr.Session session,
                                 SimpleDocument document)
                          throws javax.jcr.RepositoryException
        Throws:
        javax.jcr.RepositoryException
      • deleteContent

        public void deleteContent​(javax.jcr.Node documentNode,
                                  String instanceId)
                           throws javax.jcr.RepositoryException
        Throws:
        javax.jcr.RepositoryException
      • mergeAttachment

        public void mergeAttachment​(javax.jcr.Session session,
                                    SimpleDocument attachment,
                                    SimpleDocument clone)
                             throws javax.jcr.RepositoryException
        Throws:
        javax.jcr.RepositoryException