Class WebdavDocumentRepository
- java.lang.Object
-
- org.silverpeas.core.contribution.attachment.webdav.impl.WebdavDocumentRepository
-
- All Implemented Interfaces:
WebdavRepository
@Repository public class WebdavDocumentRepository extends Object implements WebdavRepository
-
-
Constructor Summary
Constructors Constructor Description WebdavDocumentRepository()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected javax.jcr.Node
addExclusiveFolder(javax.jcr.Node parent, String name)
Adds a folder node into the repository and removes all others so that it exists only the folder named like specified.protected javax.jcr.Node
addFile(javax.jcr.Node folder, SimpleDocument attachment)
Add a file node into the repositoryprotected javax.jcr.Node
addFolder(javax.jcr.Node parent, String name)
Add a folder node into the repositoryvoid
createAttachmentNode(javax.jcr.Session session, SimpleDocument attachment)
Create a new node for the specified attachment so that the file may be accessed through webdav.void
deleteAttachmentContentNode(javax.jcr.Session session, SimpleDocument attachment, String language)
Delete the node associated to the specified language content attachment.void
deleteAttachmentNode(javax.jcr.Session session, SimpleDocument attachment)
Delete the node associated to the specified attachment.String
getContentEditionLanguage(javax.jcr.Session session, SimpleDocument attachment)
Gets the current content edition language of the specified attachment.long
getContentEditionSize(javax.jcr.Session session, SimpleDocument attachment)
Gets the current content edition size of the specified attachment.Optional<WebdavContentDescriptor>
getDescriptor(javax.jcr.Session session, SimpleDocument attachment)
Gets the current webdav descriptor of the specified attachment.protected javax.jcr.Node
getDocumentContentLanguageNode(javax.jcr.Session session, SimpleDocument attachment, String language)
Gets the webdav document content language node from the specified attachment.protected javax.jcr.Node
getDocumentIdentifierNode(javax.jcr.Session session, SimpleDocument attachment)
Gets the webdav document identifier node from the specified attachment.boolean
isNodeLocked(javax.jcr.Session session, SimpleDocument attachment)
Indicate if the node for the specified attachment is currently locked (for example by Office in the case of a webdav online edition).void
loadContentInto(javax.jcr.Session session, SimpleDocument document, OutputStream output)
Reads a document content from the WEBDAV repository and writes it into given output.void
moveNodeAttachment(javax.jcr.Session session, SimpleDocument attachment, String targetComponentInstanceId)
Move the specified attachment to the specified component instance id.void
updateAttachmentBinaryContent(javax.jcr.Session session, SimpleDocument attachment)
Update the file content of the specified attachment without modifying its metadata.void
updateContentFrom(javax.jcr.Session session, SimpleDocument document, InputStream input)
Updates a document content into the WEBDAV repository.void
updateNodeAttachment(javax.jcr.Session session, SimpleDocument attachment)
Update the node using theSimpleDocument
.
-
-
-
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 interfaceWebdavRepository
- Parameters:
session
- the JCR session.attachment
- the attachment.- Throws:
javax.jcr.RepositoryException
IOException
-
updateNodeAttachment
public void updateNodeAttachment(javax.jcr.Session session, SimpleDocument attachment) throws javax.jcr.RepositoryException, IOException
Description copied from interface:WebdavRepository
Update the node using theSimpleDocument
. For an attachment, it can exist in webdav one, and only one, content language of the attachment.- Specified by:
updateNodeAttachment
in interfaceWebdavRepository
- Parameters:
session
- the JCR session.attachment
- the attachment.- Throws:
javax.jcr.RepositoryException
IOException
-
moveNodeAttachment
public void moveNodeAttachment(javax.jcr.Session session, SimpleDocument attachment, String targetComponentInstanceId) throws javax.jcr.RepositoryException, IOException
Description copied from interface:WebdavRepository
Move the specified attachment to the specified component instance id.- Specified by:
moveNodeAttachment
in interfaceWebdavRepository
- 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
IOException
-
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
-
deleteAttachmentNode
public void deleteAttachmentNode(javax.jcr.Session session, SimpleDocument attachment) throws javax.jcr.RepositoryException
Description copied from interface:WebdavRepository
Delete the node associated to the specified attachment. All contents will be removed. If a specific content (language) must be removed, then useWebdavRepository.deleteAttachmentContentNode(Session, SimpleDocument, String)
method.- Specified by:
deleteAttachmentNode
in interfaceWebdavRepository
- Parameters:
session
- the JCR session.attachment
- the attachment.- 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 interfaceWebdavRepository
- Parameters:
session
- the JCR session.attachment
- the attachment.language
- the aimed language content to delete.- Throws:
javax.jcr.RepositoryException
-
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 interfaceWebdavRepository
- Parameters:
session
- the JCR session.attachment
- the attachment.- Returns:
- true if the node is 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 interfaceWebdavRepository
- Parameters:
session
- the JCR session.attachment
- the attachment for which the file content will be updated with the ralated webdav content.- Throws:
javax.jcr.RepositoryException
IOException
-
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 nodename
- the name of the new node- Returns:
- the created node.
- Throws:
javax.jcr.RepositoryException
-
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 nodename
- the name of the new node- Returns:
- the created or already existing node.
- Throws:
javax.jcr.RepositoryException
-
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
IOException
-
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 interfaceWebdavRepository
- Parameters:
session
- the JCR session.attachment
- the attachment.- Returns:
- the content edition language if the specified attachment exists in the webdav repository, null otherwise.
- Throws:
javax.jcr.RepositoryException
-
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 interfaceWebdavRepository
- Parameters:
session
- the JCR session.attachment
- the attachment.- Returns:
- the content edition size if the specified attachment exists in the webdav repository, -1 otherwise.
- Throws:
javax.jcr.RepositoryException
-
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 interfaceWebdavRepository
- 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 interfaceWebdavRepository
- Parameters:
session
- the JCR session.document
- the aimed document.input
- the data to write.- Throws:
javax.jcr.RepositoryException
-
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 interfaceWebdavRepository
- Parameters:
session
- the JCR session.document
- the aimed document.output
- the stream to write into.- Throws:
javax.jcr.RepositoryException
IOException
-
-