Clearspace API (2.5.29) Core Javadocs

com.jivesoftware.community
Interface Attachment

All Superinterfaces:
JiveObject

public interface Attachment
extends JiveObject

An object that encapsulates an attachment. Each attachment has a unique ID and is made up of three parts: binary data (read and written using an InputStream), a name, and content type. An attachment might have a name "stockchart.gif" and corresponding content type of "image/gif". A full listing of possible content types can be found at: ftp://ftp.iana.org/in-notes/iana/assignments/media-types/

The storage mechanism of attachments is controlled via the StorageManager; the default implementation puts attachments in the database.


Field Summary
static String BLOCKED
           
static String QUEUED
           
static String STATUS
           
 
Method Summary
 AttachmentContentResource getAttachmentContentResource()
          Returns the AttachmentContentResource of the attachment.
 int getContentObjectType()
          Returns the object type of this attachments content object.
 String getContentType()
          Returns the content type of the attachment.
 Date getCreationDate()
          Returns the date the attachment was created.
 InputStream getData()
          Returns a InputStream for the binary contents of the attachment, or null if the attachment is scheduled for virus scanning, and has not yet been scanned.
 int getDownloadCount()
          Returns the number of times the attachment has been downloaded.
 Date getModificationDate()
          Returns the date the attachment was last modified.
 String getName()
          Returns the name of the attachment.
 Map<String,String> getProperties()
          Retrieve a map of all the extended properties for the attachment.
 long getSize()
          Returns the size of the attachment in bytes.
 InputStream getUnfilteredData()
          Returns a InputStream for the binary contents of the attachment.
 void setName(String name)
          Sets the name of the attachment.
 
Methods inherited from interface com.jivesoftware.community.JiveObject
getID, getObjectType
 

Field Detail

STATUS

static final String STATUS
See Also:
Constant Field Values

QUEUED

static final String QUEUED
See Also:
Constant Field Values

BLOCKED

static final String BLOCKED
See Also:
Constant Field Values
Method Detail

getAttachmentContentResource

AttachmentContentResource getAttachmentContentResource()
Returns the AttachmentContentResource of the attachment.

Returns:
the AttachmentContentResource which contains the attachment.

getContentType

String getContentType()
Returns the content type of the attachment. For example, the content type of an image attachment might be "image/gif" or "image/jpeg".

Returns:
the attachment content type.

getName

String getName()
Returns the name of the attachment. Most often, the attachment name is the original name of the file that created the attachment, such as "report.doc"

Returns:
the name of the attachment.

setName

void setName(String name)
             throws UnauthorizedException
Sets the name of the attachment. Most often, the attachment name is the original name of the file that created the attachment, such as "report.doc"

Parameters:
name - the new name of the attachment.
Throws:
UnauthorizedException - if not allowed to modify the attachment

getSize

long getSize()
Returns the size of the attachment in bytes.

Returns:
the size of the attachment.

getData

InputStream getData()
                    throws IOException
Returns a InputStream for the binary contents of the attachment, or null if the attachment is scheduled for virus scanning, and has not yet been scanned. The stream should be closed after reading the attachment is completed. The InputStream will already be buffered, so there is no advantage to using additional buffering.

Returns:
the binary contents of the attachment.
Throws:
IOException - if an error occurs reading the attachment from storage.

getUnfilteredData

InputStream getUnfilteredData()
                              throws IOException
Returns a InputStream for the binary contents of the attachment. The stream should be closed after reading the attachment is completed. The InputStream will already be buffered, so there is no advantage to using additional buffering. This method bypasses the virus scanning check.

Returns:
the binary contents of the attachment.
Throws:
IOException - if an error occurs reading the attachment from storage.

getCreationDate

Date getCreationDate()
Returns the date the attachment was created.

Returns:
the date the attachment was created.

getModificationDate

Date getModificationDate()
Returns the date the attachment was last modified.

Returns:
the date the attachment was last modified.

getDownloadCount

int getDownloadCount()
Returns the number of times the attachment has been downloaded.

Returns:
the number of times the attachment has been downloaded.

getProperties

Map<String,String> getProperties()
Retrieve a map of all the extended properties for the attachment. Each attachment can have an arbitrary number of extended properties. This allows for enhanced functionality that is not part of the base interface. The map is alterable if the user is authorized to modify the document, however only a mapping of key -> value is allowed. Null keys and values are not allowed.

Returns:
a map of attachment extended properties.

getContentObjectType

int getContentObjectType()
Returns the object type of this attachments content object.

Returns:
the object type of this attachments content object.

Clearspace Project Page

Copyright © 1999-2007 Jive Software.