Jive Forums API (5.5.20.2-oracle) Developer Javadocs

com.jivesoftware.forum.nntp.spi
Class FArticlePostUtil

java.lang.Object
  extended by com.jivesoftware.forum.nntp.spi.FArticlePostUtil

public final class FArticlePostUtil
extends java.lang.Object

Utility class that aides the ForumSession class parse a posted article and insert it into the appropriate forum.


Field Summary
static java.lang.String MULTIPART_ALTERNATIVE
           
static java.lang.String MULTIPART_MIXED
           
static java.lang.String MULTIPART_RELATED
           
static java.lang.String TEXT_HTML
           
static java.lang.String TEXT_PLAIN
           
 
Method Summary
static ForumMessage[] createMessages(ForumSession session, MimeTools.Headers mainHeaders, MimeTools.Headers headers, java.lang.String body)
          Posts the given article with mainHeaders and body to the forum.
static ForumMessage[] parseAlternative(ForumSession session, MimeTools.Headers mainHeaders, java.util.Iterator rawArticle, java.lang.String mimeBoundary)
          Parse a multipart alternative body part searching for the start of the text/plain part.
static ForumMessage[] parseBody(ForumSession session, MimeTools.Headers mainHeaders, MimeTools.Headers headers, java.nio.charset.Charset charset, java.util.Iterator rawArticle, java.lang.String encoding, java.lang.String type)
          Parses the raw article and pushes the data as plain text into a body string.
static void parseMultipart(java.util.Iterator rawArticle, MimeTools.Headers mainHeaders, java.lang.String mimeBoundary, ForumSession session)
          Parse a multipart body part.
static void post(java.util.Iterator rawArticle, ForumSession session)
          Post the article to the appropriate forum in the given factory.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

TEXT_PLAIN

public static final java.lang.String TEXT_PLAIN
See Also:
Constant Field Values

TEXT_HTML

public static final java.lang.String TEXT_HTML
See Also:
Constant Field Values

MULTIPART_MIXED

public static final java.lang.String MULTIPART_MIXED
See Also:
Constant Field Values

MULTIPART_RELATED

public static final java.lang.String MULTIPART_RELATED
See Also:
Constant Field Values

MULTIPART_ALTERNATIVE

public static final java.lang.String MULTIPART_ALTERNATIVE
See Also:
Constant Field Values
Method Detail

post

public static void post(java.util.Iterator rawArticle,
                        ForumSession session)
                 throws PostRejectedException,
                        PostFailedException,
                        NoPermissionException
Post the article to the appropriate forum in the given factory. This method must parse the posted article, extract the proper information, and convert the data into items that Forums can accept. Forums is only interested in two things, the plain text main message, and any top level attachments.

Parameters:
rawArticle - iterator over the String lines of the raw article.
session - nntp session for updating the forum cluster.
Throws:
PostRejectedException
PostFailedException
NoPermissionException

createMessages

public static ForumMessage[] createMessages(ForumSession session,
                                            MimeTools.Headers mainHeaders,
                                            MimeTools.Headers headers,
                                            java.lang.String body)
                                     throws PostFailedException,
                                            NoPermissionException
Posts the given article with mainHeaders and body to the forum.

Parameters:
mainHeaders - the mainHeaders of the message to be posted.
body - the body of the message to be posted.
session - the nntp session to post to.
Returns:
an array of the ForumMessages created.
Throws:
NoPermissionException - if the poster did not have permission to post.
PostFailedException - if the post failed.

parseMultipart

public static void parseMultipart(java.util.Iterator rawArticle,
                                  MimeTools.Headers mainHeaders,
                                  java.lang.String mimeBoundary,
                                  ForumSession session)
                           throws PostFailedException,
                                  PostRejectedException,
                                  NoPermissionException,
                                  java.io.IOException
Parse a multipart body part. The multipart uses the given MIME boundary and the iterator should be set to the first line following the headers. The method can be recursed into, but should avoid excessive recursion.

Parameters:
rawArticle - the raw article iterator pointing at the line following the headers.
mimeBoundary - the boundary of the mime parts.
mainHeaders - the headers of the main message.
session - nntp session for updating the forum cluster.
Throws:
NoPermissionException - if the poster did not have permission to post.
java.io.IOException - if there was problems reading the attachment from the stream
PostFailedException
PostRejectedException

parseBody

public static ForumMessage[] parseBody(ForumSession session,
                                       MimeTools.Headers mainHeaders,
                                       MimeTools.Headers headers,
                                       java.nio.charset.Charset charset,
                                       java.util.Iterator rawArticle,
                                       java.lang.String encoding,
                                       java.lang.String type)
                                throws java.io.IOException,
                                       PostFailedException,
                                       PostRejectedException,
                                       NoPermissionException
Parses the raw article and pushes the data as plain text into a body string. The parser must post the message in order to properly handle uuencoded attachements.

Parameters:
session - the NNTP session for accessing the forums system.
mainHeaders - the main mainHeaders to obtain the subject etc of the article.
headers - the headers of the individual part
charset - the charset the article uses.
rawArticle - the raw article data to be added.
encoding - the encoding of the body text.
type - the type of the body (should be "text/plain" or "text/html".
Returns:
a list containing all messages parsed.
Throws:
java.io.IOException - if there was trouble reading the message data.
PostFailedException - if the posting failed.
PostRejectedException - if post rejected.
NoPermissionException - if sufficient permissions were not available to add the body to forums (redundant to UnauthorizedException).

parseAlternative

public static ForumMessage[] parseAlternative(ForumSession session,
                                              MimeTools.Headers mainHeaders,
                                              java.util.Iterator rawArticle,
                                              java.lang.String mimeBoundary)
                                       throws java.io.IOException,
                                              PostFailedException,
                                              PostRejectedException,
                                              NoPermissionException
Parse a multipart alternative body part searching for the start of the text/plain part. The parser assumse that the iterator should be set to the first line following the headers. Only text/plain parts are parsed.

Parameters:
session - the NNTP session used to query for message information.
mainHeaders - the headers of the main message.
rawArticle - The raw article iterator pointing at the line following the headers.
mimeBoundary - the boundary of the mime parts.
Returns:
list of the ForumMessage objects that were created.
Throws:
java.io.IOException - if there was trouble reading the message data.
NoPermissionException - if sufficient permissions were not available to add the body to forums (redundant to UnauthorizedException).
PostFailedException
PostRejectedException

Jive Forums Project Page

Copyright © 1999-2006 Jive Software.