Base builder for creating a post, comment or reply: holds the common comment text, poster, posted date, website and branch, and any file attachments, and is extended by ForumPostBuilder and CommentPostBuilder for their specific post types. Defaults the poster to the current user, the posted date to now, and the website and branch to those of the current website root folder, if there is one. Never obtained directly: use ForumManager.newForumPostBuilder or ForumManager.newCommentPostBuilder to get one of the concrete subclasses, then pass it to ForumManager.createPost.
Group: Builders
Properties
| Property | Returns | Description |
|---|---|---|
| attachments | List<PostAttachmentBuilder> | Files attached to this post so far, built up by repeated calls to addAttachment or attach. |
Methods
getAttachments() · addAttachment() · attachments(Map<String,FileItem> files) · attach(FileItem fileItem) · attach(String name, InputStream in) · attach(String name, String contentSpec, String contentType, Long size) · websiteBranch(Branch b) · comment(String s) · postedByUser(Profile s) · postedDate(Date s)
getAttachments()
Returns: List<PostAttachmentBuilder>
Files attached to this post so far, built up by repeated calls to addAttachment or attach.
addAttachment()
Returns: PostAttachmentBuilder
Creates a new file attachment, adds it to this post's list of attachments, and returns it so its properties can be set. Note that attachments must already be initialised (for example via attach or attachments) before calling this directly, as it does not lazily create the list.
attachments(Map<String,FileItem> files)
Returns: T
Attaches every file in the given map, saving each one's content to content storage, and returns this builder for chaining.
| Parameter | Description |
|---|---|
files | the uploaded files to attach, keyed by form field name |
attach(FileItem fileItem)
Returns: T
Attaches an uploaded file, saving its content to content storage and detecting its content type from the file item, and returns this builder for chaining.
| Parameter | Description |
|---|---|
fileItem | the uploaded file to attach |
attach(String name, InputStream in)
Returns: T
Attaches a file from a name and content stream, saving its content to content storage and detecting its content type from the file name, and returns this builder for chaining.
| Parameter | Description |
|---|---|
name | the file name, used to detect content type and build the storage key |
in | the file's content |
attach(String name, String contentSpec, String contentType, Long size)
Returns: T
Attaches a file whose content has already been saved to content storage, and returns this builder for chaining.
| Parameter | Description |
|---|---|
name | the file name |
contentSpec | a hash-like value identifying the saved content, either an actual SHA1 file hash or a content spec returned from content storage |
contentType | the MIME type of the file |
size | the size of the file in bytes |
websiteBranch(Branch b)
Returns: T
Sets the website branch (and derives the website from it) that the post is created against, and returns this builder for chaining.
| Parameter | Description |
|---|---|
b | the website branch the post is created against |
comment(String s)
Returns: T
Sets the comment text and returns this builder for chaining.
| Parameter | Description |
|---|---|
s | the text of the post |
postedByUser(Profile s)
Returns: T
Sets the profile the post is attributed to and returns this builder for chaining. Defaults to the current user.
| Parameter | Description |
|---|---|
s | the profile posting |
postedDate(Date s)
Returns: T
Sets the date the post is recorded as being made and returns this builder for chaining. Defaults to the time the builder was created.
| Parameter | Description |
|---|---|
s | the date the post was made |