Package org.xwiki.store
Interface TemporaryAttachmentSessionsManager
-
@Unstable @Role public interface TemporaryAttachmentSessionsManager
Interface for operations related to temporary upload of attachments. The idea of this API is to allow obtaining directly a temporaryXWikiAttachment
from aPart
and to keep it in cache until it's saved. The manager is handling a separated map of attachments for eachHttpSession
.- Since:
- 14.3RC1
- Version:
- $Id: c3e3109b4648067bc9149a3a166ffdd9e754ee20 $
-
-
Method Summary
All Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description default Optional<XWikiAttachment>
getUploadedAttachment(AttachmentReference attachmentReference)
Retrieve a specific temporary attachment related to the given document reference and matching the given filename.Optional<XWikiAttachment>
getUploadedAttachment(DocumentReference documentReference, String filename)
Retrieve a specific temporary attachment related to the given document reference and matching the given filename.Collection<XWikiAttachment>
getUploadedAttachments(DocumentReference documentReference)
Retrieve all temporary attachments related to the given document reference in the current user session.boolean
removeUploadedAttachment(DocumentReference documentReference, String filename)
Search for temporary attachment related to the given document reference and matching the given filename, and remove it from the cache.boolean
removeUploadedAttachments(DocumentReference documentReference)
Remove all uploaded attachments from the cache related to the given document reference in the current user session.XWikiAttachment
uploadAttachment(DocumentReference documentReference, javax.servlet.http.Part part)
-
-
-
Method Detail
-
uploadAttachment
XWikiAttachment uploadAttachment(DocumentReference documentReference, javax.servlet.http.Part part) throws TemporaryAttachmentException
- Parameters:
documentReference
- the reference of the document that the attachment should be attached to.part
- the actual data that is uploaded.- Returns:
- an attachment that is not saved yet but cached and contains the data of the given part.
- Throws:
TemporaryAttachmentException
- if the part size exceeds the maximum upload size, or in case of problem when reading the part.
-
getUploadedAttachments
Collection<XWikiAttachment> getUploadedAttachments(DocumentReference documentReference)
Retrieve all temporary attachments related to the given document reference in the current user session.- Parameters:
documentReference
- the reference for which to retrieve temporary attachments.- Returns:
- a collection of temporary attachments or an empty collection.
-
getUploadedAttachment
Optional<XWikiAttachment> getUploadedAttachment(DocumentReference documentReference, String filename)
Retrieve a specific temporary attachment related to the given document reference and matching the given filename.- Parameters:
documentReference
- the reference for which to retrieve the temporary attachment.filename
- the filename to look for.- Returns:
- an
Optional.empty()
if the attachment cannot be found, else an optional containing the attachment
-
getUploadedAttachment
default Optional<XWikiAttachment> getUploadedAttachment(AttachmentReference attachmentReference)
Retrieve a specific temporary attachment related to the given document reference and matching the given filename. This method is only a helper togetUploadedAttachment(DocumentReference, String)
.- Parameters:
attachmentReference
- the reference of the attachment to retrieve- Returns:
- an
Optional.empty()
if the attachment cannot be found, else an optional containing the attachment - Since:
- 14.3.1, 14.4RC1
-
removeUploadedAttachment
boolean removeUploadedAttachment(DocumentReference documentReference, String filename)
Search for temporary attachment related to the given document reference and matching the given filename, and remove it from the cache.- Parameters:
documentReference
- the reference for which to retrieve the temporary attachment.filename
- the filename to look for.- Returns:
true
if the attachment have been found for deletion,false
if no matching attachment could be find.
-
removeUploadedAttachments
boolean removeUploadedAttachments(DocumentReference documentReference)
Remove all uploaded attachments from the cache related to the given document reference in the current user session.- Parameters:
documentReference
- the reference for which to retrieve the temporary attachments.- Returns:
true
if there was some temporary attachments in cache for the given document reference in the current user session,false
if there was no matching temporary attachment in cache.
-
-