com.knowgate.hipermail
Class MailAccount

java.lang.Object
  extended by com.knowgate.dataobjs.DBPersist
      extended by com.knowgate.hipermail.MailAccount
All Implemented Interfaces:
java.io.Serializable, java.util.Map

public class MailAccount
extends DBPersist

See Also:
Serialized Form

Nested Class Summary
 
Nested classes/interfaces inherited from interface java.util.Map
java.util.Map.Entry<K,V>
 
Field Summary
static short ClassId
           
 
Fields inherited from class com.knowgate.dataobjs.DBPersist
AllVals, sAuditCls, sAuditUsr, sTransactId
 
Constructor Summary
MailAccount()
           
MailAccount(JDCConnection oConn, java.lang.String sGuAccount)
           
 
Method Summary
 boolean delete(JDCConnection oConn)
          Delete a register from database The deleted register will be the one matching this DBPersist primary key, as set at constructor or load() method.
static boolean delete(JDCConnection oConn, java.lang.String sGuAccount)
           
static MailAccount forUser(JDCConnection oConn, java.lang.String sGuUser)
          Get MailAccount for ACLUser Get the default mail account for an ACLUser or the first account if there is no default.
static MailAccount forUser(JDCConnection oConn, java.lang.String sGuUser, java.util.Properties oProps)
          Get MailAccount for ACLUser or create a default one If no account for given user is found at k_user_mail then one is temporaly created by using properties given at parameter oProps and taking user's tx_main_email and tx_pwd as mail address and password.
 java.util.Properties getProperties()
           
 void setProperties(java.util.Properties oProps)
           
 boolean store(JDCConnection oConn)
          Store mail account This method has a special side effect: only one mail account may be the default one for a given user.
 
Methods inherited from class com.knowgate.dataobjs.DBPersist
allcaps, allcaps, changelog, clear, clone, containsKey, containsValue, entrySet, exists, get, get, getAuditClassName, getCreationDate, getDate, getDateFormated, getDateShort, getDateTime, getDateTime24, getDecimal, getDecimalFormated, getDecimalFormated, getDouble, getDoubleFormated, getFloat, getFloatFormated, getInt, getInteger, getIntervalPart, getItemMap, getItems, getMoney, getShort, getSQLDate, getSQLTime, getString, getStringHtml, getStringNull, getTable, getTable, getTableName, getTime, getTimeOfDay, getTimestamp, getUIdFromName, isEmpty, isNull, iterator, keySet, load, load, parseXML, put, put, put, put, put, put, put, put, put, put, put, put, put, put, put, put, put, putAll, putAll, remove, remove, replace, replace, replace, replace, replace, replace, replace, replace, setAuditTransact, setAuditUser, setCreationDate, size, toLowerCase, toUpperCase, toXML, toXML, toXML, toXML, values
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface java.util.Map
equals, hashCode
 

Field Detail

ClassId

public static final short ClassId
See Also:
Constant Field Values
Constructor Detail

MailAccount

public MailAccount()

MailAccount

public MailAccount(JDCConnection oConn,
                   java.lang.String sGuAccount)
            throws java.sql.SQLException
Throws:
java.sql.SQLException
Method Detail

store

public boolean store(JDCConnection oConn)
              throws java.sql.SQLException

Store mail account

This method has a special side effect: only one mail account may be the default one for a given user. So each time that an account is stored with it bo_default flag set to 1 the other account for the same user are set to bo_default=0.
This method also calls Gadgets.checkEMail() on tx_main_email and tx_reply_mail if they do not have a valid syntax a SQLException is thrown

Overrides:
store in class DBPersist
Parameters:
oConn - JDCConnection
Returns:
boolean
Throws:
java.sql.SQLException - If tx_main_email or tx_reply_mail do not have a valid syntax

getProperties

public java.util.Properties getProperties()

setProperties

public void setProperties(java.util.Properties oProps)

forUser

public static MailAccount forUser(JDCConnection oConn,
                                  java.lang.String sGuUser)
                           throws java.sql.SQLException

Get MailAccount for ACLUser

Get the default mail account for an ACLUser or the first account if there is no default.

Parameters:
oConn - JDCConnection
sGuUser - String ACLUser GUID (from k_users.gu_user)
Returns:
MailAccount instance or null if there are no mail accounts for the given user
Throws:
java.sql.SQLException

forUser

public static MailAccount forUser(JDCConnection oConn,
                                  java.lang.String sGuUser,
                                  java.util.Properties oProps)
                           throws java.sql.SQLException

Get MailAccount for ACLUser or create a default one

If no account for given user is found at k_user_mail then one is temporaly created by using properties given at parameter oProps and taking user's tx_main_email and tx_pwd as mail address and password.

Parameters:
oConn - JDCConnection
sGuUser - String ACLUser GUID (from k_users.gu_user)
oProps - Properties usually take from an hipergate.cnf file by calling Environment.getProfile("hipergate")
Returns:
MailAccount instance or null if there is no user with the given GUID
Throws:
java.sql.SQLException

delete

public boolean delete(JDCConnection oConn)
               throws java.sql.SQLException
Description copied from class: DBPersist

Delete a register from database

The deleted register will be the one matching this DBPersist primary key, as set at constructor or load() method.

Overrides:
delete in class DBPersist
Parameters:
oConn - Database connection
Returns:
true if register was successfully erased, false if not.
Throws:
java.sql.SQLException

delete

public static boolean delete(JDCConnection oConn,
                             java.lang.String sGuAccount)
                      throws java.sql.SQLException,
                             java.io.IOException
Throws:
java.sql.SQLException
java.io.IOException