📄 javamailgateway.java
字号:
MimeMultipart mp2 = (MimeMultipart) o;
body.append(getTextParts(mp2));
}
else {
String s = "";
if ((s = part.getFileName()) != null) {
body.append("[").append(s).append("]");
}
}
}
}
return body.toString();
}
protected void cleanup() {
/* does nothing, subclass may override as necessary */
}
/**
* get the protocol
*
* @return the current protocol
*/
public String getProtocol() {
return protocol;
}
/**
* set the protocol
*
* @param protocol the protocol to use
*/
public void setProtocol(String protocol) {
if (protocol != null && !protocol.equals("")) {
this.protocol = protocol;
}
}
/**
* get the server port
*
* @return the current port setting
*/
public int getPort() {
return port;
}
/**
* set the server port
*
* @param port the new port setting
*/
public void setPort(int port) {
// check for valid port - I believe ports
// stop at 2^16
if (port > 1 && port < 65536) {
this.port = port;
}
}
/**
* get the server host
*
* @return the current host setting (IP or name)
*/
public String getHost() {
return host;
}
/**
* set the server host
*
* @param host the new host setting
*/
public void setHost(String host) {
if (host != null && !host.equals("")) {
this.host = host;
}
}
/**
* Returns the username.
*
* @return the current username
*/
public String getUsername() {
return username;
}
/**
* Sets the username.
*
* @param username the username to use
*/
public void setUsername(String username) {
this.username = username;
}
/**
* Returns the password.
*
* @return the current password
*/
public String getPassword() {
return password;
}
/**
* Sets the password.
*
* @param password The password to use
*/
public void setPassword(String password) {
this.password = password;
}
/**
* Returns the name of the mailbox.
*
* @return the current mailbox
*/
public String getMailbox() {
return mailbox;
}
/**
* Sets the name of the mailbox.
*
* @param mailbox The mailbox to use
*/
public void setMailbox(String mailbox) {
if (mailbox != null) {
this.mailbox = mailbox;
}
}
/**
* 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.
*
* @return the message body that will be used for temporary fake parent
* messages.
*/
public String getTemporaryParentBody() {
return 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 <tt>temporaryParentBody</tt>. 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.<p>
*
* On subsequent imports when a real parent message is found, the fake
* data will be replaced with the correct subject and body.<p>
*
* @param temporaryParentBody the message body that will be used for
* temporary fake parent messages.
*/
public void setTemporaryParentBody(String temporaryParentBody) {
if (temporaryParentBody != null) {
this.temporaryParentBody = temporaryParentBody;
}
}
/**
* Returns true if data will be deleted from the store after being read.
* When false, no data will be deleted from the store.
*
* @return true if data will be deleted from the store after being read.
*/
public boolean isDeleteEnabled() {
return deleteEnabled;
}
/**
* Sets whether data will be deleted from the store after being read.
* When false, no data will be deleted from the store.
*
* @param deleteEnabled true if data should be deleted from the store after
* being read.
*/
public void setDeleteEnabled(boolean deleteEnabled) {
this.deleteEnabled = deleteEnabled;
}
/**
* From email address to send mail from for export
* Used in the case of anonymous users/users who hide
* their information
*
* @return the current sender
*/
public String getDefaultFromAddress() {
return defaultFromAddress;
}
/**
* set the from email address for message export
*
* @param address
*/
public void setDefaultFromAddress(String address) {
if ("".equals(address)) {
address = null;
}
this.defaultFromAddress = address;
}
/**
* True if a user's privacy setting on their email address should be obeyed
* when exporting messages.
*
* @return true if email privacy settings will be respected.
*/
public boolean isEmailPrefEnabled() {
return emailPrefEnabled;
}
/**
* set the whether to honour a user's privacy setting when exporting messages
*
* @param address
*/
public void setEmailPrefEnabled(boolean enabled) {
this.emailPrefEnabled = enabled;
}
/**
* True if debug is enabled, false otherwise
*/
public boolean isDebugEnabled() {
return debugEnabled;
}
/**
* Set whether debug is enabled or not
*
* @param boolean true to debug, false otherwise
*/
public void setDebugEnabled(boolean debugEnabled) {
this.debugEnabled = debugEnabled;
}
/**
* Small class to cache insert's so that we can do them all at once and
* not incur penalties for continuously invalidating the message & thread
* caches because of constant inserts.
*
* Allows for the setting of a parent message & thread in children even
* though the parent may not yet be in the database. The parent will
* automatically update it's children with the correct thread and parent
* after inserting itself into the database
*/
private class InsertCacheItem {
private ForumThread thread = null;
private ForumMessage parent = null;
private ForumMessage message = null;
private Forum forum = null;
private ArrayList children = new ArrayList();
public InsertCacheItem(Forum forum, ForumThread thread, ForumMessage parent,
ForumMessage message)
{
this.forum = forum;
this.thread = thread;
this.parent = parent;
this.message = message;
}
public boolean containsMessage(String messageId) {
if (message != null && message.getProperty(gatewayMessageId).equals(messageId)) {
return true;
}
else {
return false;
}
}
public void insert() {
try {
if (thread != null && parent != null && message != null) {
thread.addMessage(parent, message);
}
else if (thread == null && parent != null && message != null) {
thread = factory.createThread(parent);
forum.addThread(thread);
thread.addMessage(parent, message);
}
else if (thread == null && parent == null && message != null) {
thread = factory.createThread(message);
forum.addThread(thread);
}
if (children.size() > 0) {
Iterator kids = children.iterator();
while (kids.hasNext()) {
InsertCacheItem child = (InsertCacheItem) kids.next();
child.setThread(thread);
child.setParent(message);
}
}
}
catch (UnauthorizedException e) { /* do nothing */ }
catch (Exception e) {
e.printStackTrace();
}
}
public void setThread(ForumThread thread) {
this.thread = thread;
}
public void setParent(ForumMessage parent) {
this.parent = parent;
}
public void addChild(InsertCacheItem child) {
this.children.add(child);
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -