Clearspace API (1.7.0) Core Javadocs

com.jivesoftware.community
Interface AttachmentContentResource

All Known Subinterfaces:
BlogPost, Document, ForumMessage

public interface AttachmentContentResource

A base interface defining attachments methods.


Method Summary
 Attachment createAttachment(java.lang.String name, java.lang.String contentType, java.io.InputStream data, java.io.File file)
          Creates a new attachment for the object.
 void deleteAttachment(Attachment attachment)
          Deletes an attachment that belongs to the object.
 Attachment getAttachment(long attachmentID)
          Returns the attachment corresponding to the attachmentID.
 int getAttachmentCount()
          Returns the number of attachments the object has.
 JiveIterator<Attachment> getAttachments()
          Returns an Iterable for the object's attachments.
 

Method Detail

getAttachmentCount

int getAttachmentCount()
Returns the number of attachments the object has.

Returns:
the number of attachments the object has.

getAttachments

JiveIterator<Attachment> getAttachments()
Returns an Iterable for the object's attachments.

Returns:
an Iterable of Attachment objects for the object.
See Also:
Attachment

getAttachment

Attachment getAttachment(long attachmentID)
                         throws java.lang.IllegalArgumentException,
                                AttachmentNotFoundException
Returns the attachment corresponding to the attachmentID.

Parameters:
attachmentID - the id of the attachment to retrieve.
Returns:
the attachment.
Throws:
java.lang.IllegalArgumentException - if the attachment doesn't exist or belong to the object.
AttachmentNotFoundException - if the attachment cannot be found

createAttachment

Attachment createAttachment(java.lang.String name,
                            java.lang.String contentType,
                            java.io.InputStream data,
                            java.io.File file)
                            throws java.lang.IllegalStateException,
                                   AttachmentException,
                                   UnauthorizedException
Creates a new attachment for the object. Each attachment has a name, content type and binary data. Rules about who can create attachments and what kind attachments are allowed are controlled via an AttachmentManager.

Parameters:
name - the name of the new attachment, usually the file name.
contentType - the content type of the attachment.
data - an InputStream that contains the binary data of the attachment. The stream will never be closed so you must close it manually after calling this method.
file - object if it is available. Null value is allowed when missing the File instance
Returns:
an Attachment object representing the new attachment created.
Throws:
AttachmentException - if an error occurred while creating the attachment.
UnauthorizedException - if not allowed to create attachments.
java.lang.IllegalStateException - if the object hasn't yet been saved.
See Also:
Attachment, AttachmentManager

deleteAttachment

void deleteAttachment(Attachment attachment)
                      throws AttachmentException,
                             UnauthorizedException
Deletes an attachment that belongs to the object. Only administrators or the creator of the object are allowed to call this method.

Parameters:
attachment - the attachment to delete.
Throws:
java.lang.IllegalArgumentException - if the attachment doesn't belong to the object.
UnauthorizedException - if not authorized to delete the attachment.
AttachmentException - if there was an error deleting the attachment.

Clearspace Project Page

Copyright © 1999-2007 Jive Software.