Class WebdavDocumentRepository

    • Constructor Detail

      • WebdavDocumentRepository

        public WebdavDocumentRepository()
    • Method Detail

      • createAttachmentNode

        public void createAttachmentNode​(javax.jcr.Session session,
                                         SimpleDocument attachment)
                                  throws javax.jcr.RepositoryException,
                                         IOException
        Description copied from interface: WebdavRepository
        Create a new node for the specified attachment so that the file may be accessed through webdav. For an attachment, it can exist in webdav one, and only one, content language of the attachment.
        Specified by:
        createAttachmentNode in interface WebdavRepository
        Parameters:
        session - the JCR session.
        attachment - the attachment.
        Throws:
        javax.jcr.RepositoryException - if an error occurs while creating the node in the JCR.
        IOException - if an error occurs while saving the attachment content.
      • updateNodeAttachment

        public void updateNodeAttachment​(javax.jcr.Session session,
                                         SimpleDocument attachment)
                                  throws javax.jcr.RepositoryException,
                                         IOException
        Description copied from interface: WebdavRepository
        Update the node using the SimpleDocument. For an attachment, it can exist in webdav one, and only one, content language of the attachment.
        Specified by:
        updateNodeAttachment in interface WebdavRepository
        Parameters:
        session - the JCR session.
        attachment - the attachment.
        Throws:
        javax.jcr.RepositoryException - if an error occurs while updating the node in the JCR.
        IOException - if an error occurs while updating the attachment content.
      • moveNodeAttachment

        public void moveNodeAttachment​(javax.jcr.Session session,
                                       SimpleDocument attachment,
                                       String targetComponentInstanceId)
                                throws javax.jcr.RepositoryException
        Description copied from interface: WebdavRepository
        Move the specified attachment to the specified component instance id.
        Specified by:
        moveNodeAttachment in interface WebdavRepository
        Parameters:
        session - the JCR session.
        attachment - the attachment to move to another component instance identifier.
        targetComponentInstanceId - the identifier of the target component instance.
        Throws:
        javax.jcr.RepositoryException - if an error occurs while moving the node in the JCR.
      • getDocumentIdentifierNode

        protected javax.jcr.Node getDocumentIdentifierNode​(javax.jcr.Session session,
                                                           SimpleDocument attachment)
                                                    throws javax.jcr.RepositoryException
        Gets the webdav document identifier node from the specified attachment.
        Parameters:
        session - the JCR session.
        attachment - the attachment from which the webdav document identifier JCR node is searched.
        Returns:
        the node if found, null otherwise.
        Throws:
        javax.jcr.RepositoryException
      • getDocumentContentLanguageNode

        protected javax.jcr.Node getDocumentContentLanguageNode​(javax.jcr.Session session,
                                                                SimpleDocument attachment,
                                                                String language)
                                                         throws javax.jcr.RepositoryException
        Gets the webdav document content language node from the specified attachment.
        Parameters:
        session - the JCR session.
        attachment - the attachment from which the webdav document content language JCR node is searched.
        language - the aimed content language.
        Returns:
        the node if found, null otherwise.
        Throws:
        javax.jcr.RepositoryException
      • deleteAttachmentContentNode

        public void deleteAttachmentContentNode​(javax.jcr.Session session,
                                                SimpleDocument attachment,
                                                String language)
                                         throws javax.jcr.RepositoryException
        Description copied from interface: WebdavRepository
        Delete the node associated to the specified language content attachment.
        Specified by:
        deleteAttachmentContentNode in interface WebdavRepository
        Parameters:
        session - the JCR session.
        attachment - the attachment.
        language - the aimed language content to delete.
        Throws:
        javax.jcr.RepositoryException - if an error occurs while creating the content node in the JCR.
      • isNodeLocked

        public boolean isNodeLocked​(javax.jcr.Session session,
                                    SimpleDocument attachment)
                             throws javax.jcr.RepositoryException
        Description copied from interface: WebdavRepository
        Indicate if the node for the specified attachment is currently locked (for example by Office in the case of a webdav online edition).
        Specified by:
        isNodeLocked in interface WebdavRepository
        Parameters:
        session - the JCR session.
        attachment - the attachment.
        Returns:
        true if the node is locked - false otherwise.
        Throws:
        javax.jcr.RepositoryException
      • unlockLockedNode

        public boolean unlockLockedNode​(javax.jcr.Session session,
                                        SimpleDocument attachment)
                                 throws javax.jcr.RepositoryException
        Description copied from interface: WebdavRepository
        Unlock the node for the specified attachment is currently locked (for example by Office in the case of a webdav online edition).

        Nothing is done if node is already unlocked.

        Specified by:
        unlockLockedNode in interface WebdavRepository
        Parameters:
        session - the JCR session.
        attachment - the attachment.
        Returns:
        true if the node has been effectively locked - false otherwise.
        Throws:
        javax.jcr.RepositoryException
      • updateAttachmentBinaryContent

        public void updateAttachmentBinaryContent​(javax.jcr.Session session,
                                                  SimpleDocument attachment)
                                           throws javax.jcr.RepositoryException,
                                                  IOException
        Description copied from interface: WebdavRepository
        Update the file content of the specified attachment without modifying its metadata.
        Specified by:
        updateAttachmentBinaryContent in interface WebdavRepository
        Parameters:
        session - the JCR session.
        attachment - the attachment for which the file content will be updated with the related webdav content.
        Throws:
        javax.jcr.RepositoryException - if an error occurs while updating the node content in the JCR.
        IOException - if an error occurs while updating the attachment content.
      • addFolder

        protected javax.jcr.Node addFolder​(javax.jcr.Node parent,
                                           String name)
                                    throws javax.jcr.RepositoryException
        Add a folder node into the repository
        Parameters:
        parent - the parent node
        name - the name of the new node
        Returns:
        the created node.
        Throws:
        javax.jcr.RepositoryException - if an error occurs while adding the node in the JCR.
      • addExclusiveFolder

        protected javax.jcr.Node addExclusiveFolder​(javax.jcr.Node parent,
                                                    String name)
                                             throws javax.jcr.RepositoryException
        Adds a folder node into the repository and removes all others so that it exists only the folder named like specified. If the folder already exists, the existing is kept and no folder is created, but potential other existing folders are removed.
        Parameters:
        parent - the parent node
        name - the name of the new node
        Returns:
        the created or already existing node.
        Throws:
        javax.jcr.RepositoryException - if an error occurs while adding the node in the JCR.
      • addFile

        protected javax.jcr.Node addFile​(javax.jcr.Node folder,
                                         SimpleDocument attachment)
                                  throws javax.jcr.RepositoryException,
                                         IOException
        Add a file node into the repository
        Parameters:
        folder - the folder node containing the file node.
        attachment - the attachment for the file.
        Returns:
        the created node.
        Throws:
        javax.jcr.RepositoryException - if an error occurs while adding the attachment node in the JCR.
        IOException - if an error occurs while adding the file content.
      • getContentEditionLanguage

        public String getContentEditionLanguage​(javax.jcr.Session session,
                                                SimpleDocument attachment)
                                         throws javax.jcr.RepositoryException
        Description copied from interface: WebdavRepository
        Gets the current content edition language of the specified attachment. If several webdav document exists (several content languages), then the one which has the highest modified date is taken into account.
        Specified by:
        getContentEditionLanguage in interface WebdavRepository
        Parameters:
        session - the JCR session.
        attachment - the attachment.
        Returns:
        the ISO-631 code of the content edition language if the specified attachment exists in the webdav repository, null otherwise.
        Throws:
        javax.jcr.RepositoryException - if an error occurs while getting the language of the content.
      • getContentEditionSize

        public long getContentEditionSize​(javax.jcr.Session session,
                                          SimpleDocument attachment)
                                   throws javax.jcr.RepositoryException
        Description copied from interface: WebdavRepository
        Gets the current content edition size of the specified attachment. If several webdav document exists (several content languages), then the one which has the highest modified date is taken into account.
        Specified by:
        getContentEditionSize in interface WebdavRepository
        Parameters:
        session - the JCR session.
        attachment - the attachment.
        Returns:
        the content edition size in bytes if the specified attachment exists in the webdav repository, -1 otherwise.
        Throws:
        javax.jcr.RepositoryException - if an error occurs while getting the size of the content.
      • getDescriptor

        public Optional<WebdavContentDescriptor> getDescriptor​(javax.jcr.Session session,
                                                               SimpleDocument attachment)
                                                        throws javax.jcr.RepositoryException
        Description copied from interface: WebdavRepository
        Gets the current webdav descriptor of the specified attachment. If several webdav document exists (several content languages), then the one which has the highest modified date is taken into account.
        Specified by:
        getDescriptor in interface WebdavRepository
        Parameters:
        session - the JCR session.
        attachment - the attachment.
        Returns:
        the optional content edition webdav descriptor if the specified attachment exists in the webdav repository.
        Throws:
        javax.jcr.RepositoryException - on JCR access error.
      • updateContentFrom

        public void updateContentFrom​(javax.jcr.Session session,
                                      SimpleDocument document,
                                      InputStream input)
                               throws javax.jcr.RepositoryException
        Description copied from interface: WebdavRepository
        Updates a document content into the WEBDAV repository.

        If several webdav document exists (several content languages), then the one which has the highest modified date is taken into account.

        Specified by:
        updateContentFrom in interface WebdavRepository
        Parameters:
        session - the JCR session.
        document - the aimed document.
        input - the data to write.
        Throws:
        javax.jcr.RepositoryException - if an error occurs while updating the content.
      • loadContentInto

        public void loadContentInto​(javax.jcr.Session session,
                                    SimpleDocument document,
                                    OutputStream output)
                             throws javax.jcr.RepositoryException,
                                    IOException
        Description copied from interface: WebdavRepository
        Reads a document content from the WEBDAV repository and writes it into given output.

        If several webdav document exists (several content languages), then the one which has the highest modified date is taken into account.

        Specified by:
        loadContentInto in interface WebdavRepository
        Parameters:
        session - the JCR session.
        document - the aimed document.
        output - the stream to write into.
        Throws:
        javax.jcr.RepositoryException - if an error occurs while loading the content.
        IOException