com.openexchange.mail.api
Class MailConfig

java.lang.Object
  extended by com.openexchange.mail.api.MailConfig
Direct Known Subclasses:
TransportConfig

public abstract class MailConfig
extends java.lang.Object

MailConfig - The user-specific mail properties; e.g. containing user's login data.

Provides access to global mail properties.

Author:
Thorben Betten

Nested Class Summary
static class MailConfig.BoolCapVal
           
static class MailConfig.LoginSource
           
static class MailConfig.PasswordSource
           
static class MailConfig.ServerSource
           
 
Method Summary
 boolean equals(java.lang.Object obj)
           
 int getAccountId()
          Gets the account ID.
abstract  MailCapabilities getCapabilities()
          Gets the mail system's capabilities
static
<C extends MailConfig>
C
getConfig(java.lang.Class<? extends C> clazz, C mailConfig, com.openexchange.session.Session session, int accountId)
          Gets the user-specific mail configuration.
 java.lang.String getLogin()
          Gets the login.
static java.lang.String getMailLogin(com.openexchange.mailaccount.MailAccount mailAccount, java.lang.String userLoginInfo)
          Gets the mail login with respect to configured login source.
abstract  IMailProperties getMailProperties()
          Gets the mail properties for this mail configuration.
static java.lang.String getMailServerURL(com.openexchange.mailaccount.MailAccount mailAccount)
          Gets the mail server URL appropriate to configured mail server source.
static java.lang.String getMailServerURL(com.openexchange.session.Session session, int accountId)
          Gets the mail server URL appropriate to configured mail server source.
static PartModifier getPartModifier()
          Gets the part modifier.
 java.lang.String getPassword()
          Gets the password.
abstract  int getPort()
          Gets the optional port of the server.
abstract  java.lang.String getServer()
          Gets the host name or IP address of the server.
static int[] getUserIDsByMailLogin(java.lang.String pattern, boolean isDefaultAccount, java.net.InetSocketAddress server, com.openexchange.groupware.contexts.Context ctx)
          Resolves the user IDs by specified pattern dependent on configuration's setting for mail login source.
 int hashCode()
           
abstract  boolean isSecure()
          Checks if a secure connection shall be established.
static java.lang.String[] parseProtocol(java.lang.String server)
          Parses protocol out of specified server string according to URL specification; e.g.
 void setAccountId(int accountId)
          Sets the account ID (externally).
 void setLogin(java.lang.String login)
          Sets the login (externally).
abstract  void setMailProperties(IMailProperties mailProperties)
          Sets the mail properties for this mail configuration.
 void setPassword(java.lang.String password)
          Sets the password (externally).
abstract  void setPort(int port)
          Sets the port (externally).
abstract  void setSecure(boolean secure)
          Sets (externally) whether a secure connection should be established or not.
abstract  void setServer(java.lang.String server)
          Sets the host name or IP address of the server (externally).
static boolean usePartModifier()
          Checks if a part modifier shall be used, that is PartModifier.getInstance() is not null and not assignment-compatible to DummyPartModifier (which does nothing at all).
 
Methods inherited from class java.lang.Object
getClass, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

getConfig

public static final <C extends MailConfig> C getConfig(java.lang.Class<? extends C> clazz,
                                                       C mailConfig,
                                                       com.openexchange.session.Session session,
                                                       int accountId)
                                            throws MailException
Gets the user-specific mail configuration.

Type Parameters:
C - The return value type
Parameters:
clazz - The mail configuration type
mailConfig - A newly created mail configuration
session - The session providing needed user data
accountId - The mail account ID
Returns:
The user-specific mail configuration
Throws:
MailException - If user-specific mail configuration cannot be determined

getMailLogin

public static final java.lang.String getMailLogin(com.openexchange.mailaccount.MailAccount mailAccount,
                                                  java.lang.String userLoginInfo)
Gets the mail login with respect to configured login source.

Parameters:
mailAccount - The mail account used to determine the login
userLoginInfo - The login information of the user
Returns:
The mail login of specified user

getMailServerURL

public static final java.lang.String getMailServerURL(com.openexchange.mailaccount.MailAccount mailAccount)
Gets the mail server URL appropriate to configured mail server source.

Parameters:
mailAccount - The user
Returns:
The appropriate mail server URL or null

getMailServerURL

public static final java.lang.String getMailServerURL(com.openexchange.session.Session session,
                                                      int accountId)
                                               throws MailException
Gets the mail server URL appropriate to configured mail server source.

Parameters:
session - The user session
accountId - The account ID
Returns:
The appropriate mail server URL or null
Throws:
MailException - If mail server URL cannot be returned

getPartModifier

public static final PartModifier getPartModifier()
Gets the part modifier.

Returns:
the part modifier.

getUserIDsByMailLogin

public static int[] getUserIDsByMailLogin(java.lang.String pattern,
                                          boolean isDefaultAccount,
                                          java.net.InetSocketAddress server,
                                          com.openexchange.groupware.contexts.Context ctx)
                                   throws com.openexchange.groupware.AbstractOXException
Resolves the user IDs by specified pattern dependent on configuration's setting for mail login source.

Parameters:
pattern - The pattern
server - The server address
ctx - The context
Returns:
The user IDs from specified pattern dependent on configuration's setting for mail login source
Throws:
com.openexchange.groupware.AbstractOXException - If resolving user by specified pattern fails

parseProtocol

public static final java.lang.String[] parseProtocol(java.lang.String server)
Parses protocol out of specified server string according to URL specification; e.g. mailprotocol://dev.myhost.com:1234

Parameters:
server - The server string
Returns:
An array of String with length 2. The first element is the protocol and the second the server. If no protocol pattern could be found null is returned; meaning no protocol is present in specified server string.

usePartModifier

public static final boolean usePartModifier()
Checks if a part modifier shall be used, that is PartModifier.getInstance() is not null and not assignment-compatible to DummyPartModifier (which does nothing at all).

Returns:
true if part modifier shall be used; otherwise false

equals

public boolean equals(java.lang.Object obj)
Overrides:
equals in class java.lang.Object

getAccountId

public int getAccountId()
Gets the account ID.

Returns:
The account ID

getCapabilities

public abstract MailCapabilities getCapabilities()
Gets the mail system's capabilities

Returns:
The mail system's capabilities

getLogin

public final java.lang.String getLogin()
Gets the login.

Returns:
the login

getPassword

public final java.lang.String getPassword()
Gets the password.

Returns:
the password

getPort

public abstract int getPort()
Gets the optional port of the server.

Returns:
The optional port of the server obtained via getServer() or -1 if no port needed.

getServer

public abstract java.lang.String getServer()
Gets the host name or IP address of the server.

Returns:
The host name or IP address of the server.

hashCode

public int hashCode()
Overrides:
hashCode in class java.lang.Object

isSecure

public abstract boolean isSecure()
Checks if a secure connection shall be established.

Returns:
true if a secure connection shall be established; otherwise false

setAccountId

public void setAccountId(int accountId)
Sets the account ID (externally).

Parameters:
accountId - The account ID

setLogin

public void setLogin(java.lang.String login)
Sets the login (externally).

Parameters:
login - The login

setPassword

public void setPassword(java.lang.String password)
Sets the password (externally).

Parameters:
password - The password

setPort

public abstract void setPort(int port)
Sets the port (externally).

Parameters:
port - The port

setSecure

public abstract void setSecure(boolean secure)
Sets (externally) whether a secure connection should be established or not.

Parameters:
secure - true if a secure connection should be established; otherwise false

setServer

public abstract void setServer(java.lang.String server)
Sets the host name or IP address of the server (externally).

Parameters:
server - The host name or IP address of the server

getMailProperties

public abstract IMailProperties getMailProperties()
Gets the mail properties for this mail configuration.

Returns:
The mail properties for this mail configuration

setMailProperties

public abstract void setMailProperties(IMailProperties mailProperties)
Sets the mail properties for this mail configuration.

Parameters:
mailProperties - The mail properties for this mail configuration