Package com.xpn.xwiki.api
Class Attachment
- java.lang.Object
-
- com.xpn.xwiki.api.Api
-
- com.xpn.xwiki.api.Attachment
-
public class Attachment extends Api
-
-
Constructor Summary
Constructors Constructor Description Attachment(Document doc, XWikiAttachment attachment, XWikiContext context)
-
Method Summary
All Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description XWikiAttachment
getAttachment()
Attachment
getAttachmentRevision(String rev)
Allow to easily access any revision of an attachment.String
getAuthor()
String
getComment()
byte[]
getContent()
byte[]
getContentAsBytes()
String
getContentAsString()
String
getContentAsString(String charset)
InputStream
getContentInputStream()
Date
getDate()
long
getDocId()
Document
getDocument()
String
getFilename()
int
getFilesize()
Deprecated.since 9.0RC1, usegetLongSize()
insteadlong
getId()
long
getLongSize()
String
getMimeType()
org.suigeneris.jrcs.rcs.Version
getRCSVersion()
AttachmentReference
getReference()
String
getVersion()
List<org.suigeneris.jrcs.rcs.Version>
getVersionList()
Get a list of attachment versions from 1.1 to the current.org.suigeneris.jrcs.rcs.Version[]
getVersions()
Get an array containing the versions of the attachment.boolean
isImage()
-
Methods inherited from class com.xpn.xwiki.api.Api
convert, convert, convert, convertAttachments, getAuthorizationManager, getContextualAuthorizationManager, getXWikiContext, hasAccess, hasAccessLevel, hasAdminRights, hasProgrammingRights, hasWikiAdminRights
-
-
-
-
Constructor Detail
-
Attachment
public Attachment(Document doc, XWikiAttachment attachment, XWikiContext context)
-
-
Method Detail
-
getDocument
public Document getDocument()
- Returns:
- the document the file is attached to
-
getId
public long getId()
- Returns:
- the document Id of the attachment
-
getDocId
public long getDocId()
- Returns:
- the id of the document the file is attached to
-
getFilesize
@Deprecated public int getFilesize()
Deprecated.since 9.0RC1, usegetLongSize()
instead- Returns:
- the Attachment size
-
getLongSize
public long getLongSize()
- Returns:
- the number of bytes in this attachment content
- Since:
- 9.0RC1
-
getFilename
public String getFilename()
- Returns:
- the attachment name
-
getAuthor
public String getAuthor()
- Returns:
- the login of the person who attach the file
-
getVersion
public String getVersion()
- Returns:
- the last version number of the document
-
getRCSVersion
public org.suigeneris.jrcs.rcs.Version getRCSVersion()
- Returns:
- the RCS object version of the document
-
getComment
public String getComment()
- Returns:
- the list of comments
-
getDate
public Date getDate()
- Returns:
- the date of the last uploaded version
-
getContent
public byte[] getContent() throws XWikiException
- Returns:
- the content of the attachment
- Throws:
XWikiException
-
getContentAsBytes
public byte[] getContentAsBytes() throws XWikiException
- Throws:
XWikiException
-
getContentInputStream
public InputStream getContentInputStream()
-
getContentAsString
public String getContentAsString() throws XWikiException
- Throws:
XWikiException
-
getContentAsString
public String getContentAsString(String charset) throws XWikiException
- Throws:
XWikiException
-
getVersions
public org.suigeneris.jrcs.rcs.Version[] getVersions() throws XWikiException
Get an array containing the versions of the attachment. Versions are represented as a JRCS Version object. This gets versions directly from the database which is slower thangetVersionList()
. WARNING: If there is an error loading content from the database, a single element array will be returned containing only the current version of the attachment. Consider usinggetVersionList()
instead.- Returns:
- an array of Versions.
- Throws:
XWikiException
- this will never happen.
-
getVersionList
public List<org.suigeneris.jrcs.rcs.Version> getVersionList() throws XWikiException
Get a list of attachment versions from 1.1 to the current. Versions are represented as a JRCS Version object. This gets versions by counting backward from the current version to 1.1 which will be correct as long as the database is in a consistant state.- Returns:
- a list of Versions.
- Throws:
XWikiException
- this will never happen.
-
getAttachment
public XWikiAttachment getAttachment()
- Returns:
- the XWikiAttachment object (without the wrapping) if you have the programming right
- See Also:
XWikiAttachment
-
getMimeType
public String getMimeType()
- Returns:
- the mimetype of the attachment
-
isImage
public boolean isImage()
- Returns:
- true if it's an image
-
getAttachmentRevision
public Attachment getAttachmentRevision(String rev) throws XWikiException
Allow to easily access any revision of an attachment.- Parameters:
rev
- Version to access, in the "Major.minor" format.- Returns:
- Attachment API object, or
null
if the requested version does not exist. - Throws:
XWikiException
- In case of an error.
-
getReference
public AttachmentReference getReference()
- Returns:
- the reference of this attachment
- Since:
- 11.5RC1
-
-