Jive Forums API (5.5.20.2-oracle) Developer Javadocs

com.jivesoftware.forum.gateway
Class NewsgroupImporter

java.lang.Object
  extended by com.jivesoftware.forum.gateway.NewsgroupImporter
All Implemented Interfaces:
GatewayImporter

public class NewsgroupImporter
extends java.lang.Object
implements GatewayImporter

A gateway for the import of messages from a newsgroup.


Nested Class Summary
protected  class NewsgroupImporter.NNTPImporter
          An extension of the JavaMailGateway class
 
Nested classes/interfaces inherited from interface com.jivesoftware.forum.gateway.GatewayImporter
GatewayImporter.Stats
 
Field Summary
protected static java.util.Map forumLock
           
protected  NewsgroupImporter.NNTPImporter gateway
           
static java.lang.String GATEWAY_MESSAGE_ID
          Used to flag messages in the forum with a message id specific to this gateway.
static java.lang.String GATEWAY_PARENT_ID
          Used to flag messages in the forum with a parent id specific to this gateway.
protected static java.util.Map serverSemaphores
           
 
Constructor Summary
NewsgroupImporter(ForumFactory factory, Forum forum, GatewaySettings gatewaySettings)
          Create an instance
 
Method Summary
 java.lang.String getDefaultCharacterSet()
          Returns the character set that will be used to decode inbound messages that have no explicit character set defined.
 java.lang.String getEmptySubject()
          Returns the string to be used in place of an empty subject.
 java.lang.String getHost()
          Returns the NNTP host (eg news.example.com).
 java.util.Date getLastImport()
          Returns the Last date this importer completed
 int getLastMessageNumberSeen()
          Used by the gateway to keep track of the last message seen.
 java.lang.String getNewsgroup()
          Retrieves the newsgroup that the gateway is going to use.
 java.lang.String getPassword()
          Retrieves the password to be used in connecting to the NNTP server.
 int getPort()
          Returns the port number that will be used when connecting to the NNTP server.
 java.lang.String getReplyPrefixes()
          Returns a comma seperated of prefixes that will be stripped from messages when attempting to find a parent message via subject line matching.
 GatewayImporter.Stats getStats()
           
 java.lang.String getTemporaryParentBody()
          Returns the body that will be used when creating temporary parent messages.
 java.lang.String getUsername()
          Retrieves the username set for this gateway.
 void importData(java.util.Date afterDate)
          Import data from the data source into the specified forum.
 boolean isAttachmentsEnabled()
          By default attachments are allowed by this gateway.
 boolean isDebugEnabled()
          Returns true if debugging is turned on for the NNTP transport layer.
 boolean isEmailToUserMappingEnabled()
          True if email address -> user mapping is enabled, false otherwise.
 boolean isImportHtmlEnabled()
          True if if the importation of html email is enabled, false otherwise.
 boolean isImporting()
           
 boolean isSubjectParentageCheckEnabled()
          Returns whether parentage checks will be done using subject line matching or not.
 void setAttachmentsEnabled(boolean attachmentsEnabled)
          Sets whether this gateway allows the import of attachments or not.
 void setDebugEnabled(boolean debugEnabled)
          Toggles NNTP transport layer debugging on or off.
 void setDefaultCharacterSet(java.lang.String defaultCharacterSet)
          Sets the character set that will be used to decode inbound messages that have no explicit character set defined.
 void setEmailToUserMappingEnabled(boolean emailToUserMappingEnabled)
          Sets whether email address -> user mapping is enabled, false otherwise.
 void setEmptySubject(java.lang.String emptySubject)
          Sets the string to be used in place of an empty subject.
 void setHost(java.lang.String host)
          Sets the NNTP host (eg news.example.com).
 void setImportHtmlEnabled(boolean importHtmlEnabled)
          Sets whether the importation of html email is enabled.
 void setImporting(boolean importing)
           
 void setLastMessageNumberSeen(int messageNumber)
          Used by the gateway to keep track of the last message seen.
 void setNewsgroup(java.lang.String newsgroup)
          Sets the newsgroup that this gateway is going to use.
 void setPassword(java.lang.String password)
          Sets the password to be used in connecting to the NNTP server.
 void setPort(int port)
          Set the port to use when connecting to the NNTP server.
 void setReplyPrefixes(java.lang.String replyPrefixes)
          Sets the possible prefixes that will be stripped from messages when attempting to find a parent message via subject line matching.
 void setSubjectParentageCheckEnabled(boolean subjectParentageCheckEnabled)
          Sets whether parentage checks will be done using subject line matching or not.
 void setTemporaryParentBody(java.lang.String temporaryParentBody)
          Sets the body that will be used when creating temporary parent messages.
 void setUsername(java.lang.String username)
          Sets the username to be used in connecting to the NNTP server.
 void stop()
          Stop a running import.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

gateway

protected NewsgroupImporter.NNTPImporter gateway

GATEWAY_MESSAGE_ID

public static final java.lang.String GATEWAY_MESSAGE_ID
Used to flag messages in the forum with a message id specific to this gateway.

See Also:
Constant Field Values

GATEWAY_PARENT_ID

public static final java.lang.String GATEWAY_PARENT_ID
Used to flag messages in the forum with a parent id specific to this gateway.

See Also:
Constant Field Values

forumLock

protected static java.util.Map forumLock

serverSemaphores

protected static java.util.Map serverSemaphores
Constructor Detail

NewsgroupImporter

public NewsgroupImporter(ForumFactory factory,
                         Forum forum,
                         GatewaySettings gatewaySettings)
                  throws java.lang.IllegalStateException
Create an instance

Throws:
java.lang.IllegalStateException
Method Detail

importData

public void importData(java.util.Date afterDate)
                throws GatewayException
Description copied from interface: GatewayImporter
Import data from the data source into the specified forum. For example, a concrete implementation of this interface might poll a newsgroup and add new messages to the forum.

Specified by:
importData in interface GatewayImporter
Parameters:
afterDate - the oldest cutoff date for data to import.
Throws:
GatewayException

stop

public void stop()
          throws GatewayException
Description copied from interface: GatewayImporter
Stop a running import.

Specified by:
stop in interface GatewayImporter
Throws:
GatewayException

getStats

public GatewayImporter.Stats getStats()
Specified by:
getStats in interface GatewayImporter

getUsername

public java.lang.String getUsername()
Retrieves the username set for this gateway. Default is null.

Returns:
username the username to be used in connecting to the NNTP server.

setUsername

public void setUsername(java.lang.String username)
Sets the username to be used in connecting to the NNTP server.

Parameters:
username - the username to be used in connecting to the NNTP server.

getPassword

public java.lang.String getPassword()
Retrieves the password to be used in connecting to the NNTP server. Default is null.

Returns:
the password to be used in connecting to the NNTP server.

setPassword

public void setPassword(java.lang.String password)
Sets the password to be used in connecting to the NNTP server.

Parameters:
password - the password to use be used in connecting to the NNTP server.

getPort

public int getPort()
Returns the port number that will be used when connecting to the NNTP server. The default is 119, the standard NNTP port number.

Returns:
the port number that will be used when connecting to the NNTP server.

setPort

public void setPort(int port)
Set the port to use when connecting to the NNTP server. The default is port 119; for ssl the normal port to use is 993.

Parameters:
port - the port to use when connecting to the NNTP server. The default is port 119.

getHost

public java.lang.String getHost()
Returns the NNTP host (eg news.example.com). The host is null by default, but must be set before gateway imports can execute.

Returns:
the NNTP host (eg news.example.com).

setHost

public void setHost(java.lang.String host)
Sets the NNTP host (eg news.example.com). The host is null by default, but must be set before gateway imports can execute.

Parameters:
host - the NNTP host (eg news.example.com) to use.

getNewsgroup

public java.lang.String getNewsgroup()
Retrieves the newsgroup that the gateway is going to use.

Returns:
the newsgroup that the gateway will use.

setNewsgroup

public void setNewsgroup(java.lang.String newsgroup)
Sets the newsgroup that this gateway is going to use.

Parameters:
newsgroup - the newsgroup the gateway is going to use.

getTemporaryParentBody

public java.lang.String getTemporaryParentBody()
Returns the body that will be used when creating temporary parent messages. It's possible with email accounts and mailing lists to get a response to a message before getting the original message. If this happens and only the child message is available at the time of the gateway import, Jive must still have a way to establish a correct parent/child relationship. Therefore, a temporary fake parent message is created using an extrapolated subject from the child, and a body with the value temporaryParentBody. By default, this value will be the empty String. However, you may wish to create a short message that explains the nature of the fake parent message to the user.

On subsequent imports when a real parent message is found, the fake data will be replaced with the correct subject and body.

Returns:
the message body that will be used for temporary fake parent messages.

setTemporaryParentBody

public void setTemporaryParentBody(java.lang.String temporaryParentBody)
Sets the body that will be used when creating temporary parent messages. It's possible with email accounts and mailing lists to get a response to a message before getting the original message. If this happens and only the child message is available at the time of the gateway import, Jive must still have a way to establish a correct parent/child relationship. Therefore, a temporary fake parent message is created using an extrapolated subject from the child, and a body with the value temporaryParentBody. By default, this value will be the empty String. However, you may wish to create a short message that explains the nature of the fake parent message to the user.

On subsequent imports when a real parent message is found, the fake data will be replaced with the correct subject and body.

Parameters:
temporaryParentBody - the message body that will be used for temporary fake parent messages.

isDebugEnabled

public boolean isDebugEnabled()
Returns true if debugging is turned on for the NNTP transport layer. Debug information is written to System.out.err.

Returns:
true if NNTP debugging is turned on, false otherwise.

setDebugEnabled

public void setDebugEnabled(boolean debugEnabled)
Toggles NNTP transport layer debugging on or off. Debug information is written to System.out

Parameters:
debugEnabled - true if NNTP debugging should be enabled, false otherwise.

setLastMessageNumberSeen

public void setLastMessageNumberSeen(int messageNumber)
Used by the gateway to keep track of the last message seen. This allows for fast updates since we can ask the NNTP server for only the messages newer than the message associated with this message number.

It is *highly* recommended not to set this yourself.

Parameters:
messageNumber - the last message number seen by this gateway.

getLastMessageNumberSeen

public int getLastMessageNumberSeen()
Used by the gateway to keep track of the last message seen. This allows for fast updates since we can ask the NNTP server for only the messages newer than the message associated with this message number.

It is *highly* recommended not to set this but rather let the gateway handle it itself.

Returns:
the last message number seen by this gateway.

isAttachmentsEnabled

public boolean isAttachmentsEnabled()
By default attachments are allowed by this gateway.

Returns:
whether this gateway will allow attachments or not.

setAttachmentsEnabled

public void setAttachmentsEnabled(boolean attachmentsEnabled)
Sets whether this gateway allows the import of attachments or not. If true attachments are allowed, otherwise attachments will be stripped before importing a message.

Parameters:
attachmentsEnabled - true is attachments are allowed, false otherwise.

isEmailToUserMappingEnabled

public boolean isEmailToUserMappingEnabled()
True if email address -> user mapping is enabled, false otherwise.

Returns:
True if email address -> user mapping is enabled, false otherwise.

setEmailToUserMappingEnabled

public void setEmailToUserMappingEnabled(boolean emailToUserMappingEnabled)
Sets whether email address -> user mapping is enabled, false otherwise.

Parameters:
emailToUserMappingEnabled - True if email address -> user mapping is enabled, false otherwise.

isImportHtmlEnabled

public boolean isImportHtmlEnabled()
True if if the importation of html email is enabled, false otherwise.

Returns:
True if if the importation of html email is enabled, false otherwise.

setImportHtmlEnabled

public void setImportHtmlEnabled(boolean importHtmlEnabled)
Sets whether the importation of html email is enabled. If it is, html email will be imported as the message body, otherwise it will be imported as an attachment.

Parameters:
importHtmlEnabled - True if the importation of html email is enabled, false otherwise.

getDefaultCharacterSet

public java.lang.String getDefaultCharacterSet()
Returns the character set that will be used to decode inbound messages that have no explicit character set defined. Default is "ISO-8859-1".

Returns:
the character set that will be used to decode inbound messages that have no explicit character set defined.

setDefaultCharacterSet

public void setDefaultCharacterSet(java.lang.String defaultCharacterSet)
Sets the character set that will be used to decode inbound messages that have no explicit character set defined.

Parameters:
defaultCharacterSet - the character set that will be used to decode inbound messages that have no explicit character set defined.

getReplyPrefixes

public java.lang.String getReplyPrefixes()
Returns a comma seperated of prefixes that will be stripped from messages when attempting to find a parent message via subject line matching. Prefixes are lowercase and the default array contains 're:' and 'aw:'

Returns:
a comma seperated list of prefixes that will be stripped from messages when attempting to find a parent message via subject line matching

setReplyPrefixes

public void setReplyPrefixes(java.lang.String replyPrefixes)
Sets the possible prefixes that will be stripped from messages when attempting to find a parent message via subject line matching. Prefixes are lowercase and the default array contains 're:' and 'aw:'

Parameters:
replyPrefixes - an comma seperated string of lowercase prefixes

isSubjectParentageCheckEnabled

public boolean isSubjectParentageCheckEnabled()
Returns whether parentage checks will be done using subject line matching or not.

Returns:
whether parentage checks will be done using subject line matching or not.

setSubjectParentageCheckEnabled

public void setSubjectParentageCheckEnabled(boolean subjectParentageCheckEnabled)
Sets whether parentage checks will be done using subject line matching or not.

Parameters:
subjectParentageCheckEnabled - true if parentage checks will be done using subject line matching, false otherwise.

getEmptySubject

public java.lang.String getEmptySubject()
Returns the string to be used in place of an empty subject. Default is [No Subject].

Returns:
the string to be used in place of an empty subject.

setEmptySubject

public void setEmptySubject(java.lang.String emptySubject)
Sets the string to be used in place of an empty subject. Default is [No Subject].

Parameters:
emptySubject - the string to be used in place of an empty subject.

getLastImport

public java.util.Date getLastImport()
Description copied from interface: GatewayImporter
Returns the Last date this importer completed

Specified by:
getLastImport in interface GatewayImporter
Returns:
the last date this importer completed

isImporting

public boolean isImporting()
Specified by:
isImporting in interface GatewayImporter

setImporting

public void setImporting(boolean importing)
Specified by:
setImporting in interface GatewayImporter

Jive Forums Project Page

Copyright © 1999-2006 Jive Software.