org.apache.james.rrt.lib
Class AbstractRecipientRewriteTable

java.lang.Object
  extended by org.apache.james.rrt.lib.AbstractRecipientRewriteTable
All Implemented Interfaces:
Configurable, LogEnabled, RecipientRewriteTable

public abstract class AbstractRecipientRewriteTable
extends Object
implements RecipientRewriteTable, LogEnabled, Configurable


Nested Class Summary
 
Nested classes/interfaces inherited from interface org.apache.james.rrt.api.RecipientRewriteTable
RecipientRewriteTable.ErrorMappingException
 
Field Summary
 
Fields inherited from interface org.apache.james.rrt.api.RecipientRewriteTable
ALIASDOMAIN_PREFIX, ERROR_PREFIX, REGEX_PREFIX, WILDCARD
 
Constructor Summary
AbstractRecipientRewriteTable()
           
 
Method Summary
 void addAddressMapping(String user, String domain, String address)
           
 void addAliasDomainMapping(String aliasDomain, String realDomain)
           
 void addErrorMapping(String user, String domain, String error)
           
 void addMapping(String user, String domain, String mapping)
           
protected abstract  void addMappingInternal(String user, String domain, String mapping)
          Add new mapping
 void addRegexMapping(String user, String domain, String regex)
           
 void configure(org.apache.commons.configuration.HierarchicalConfiguration config)
           
protected  void doConfigure(org.apache.commons.configuration.HierarchicalConfiguration conf)
          Override to handle config
 Map<String,Collection<String>> getAllMappings()
           
protected abstract  Map<String,Collection<String>> getAllMappingsInternal()
          Return a Map which holds all Mappings
protected  String getFixedDomain(String domain)
          Fix the domain for the given argument.
protected  String getFixedUser(String user)
          Return user String for the given argument.
protected  org.slf4j.Logger getLogger()
           
 Collection<String> getMappings(String user, String domain)
           
 Collection<String> getMappings(String user, String domain, int mappingLimit)
           
 Collection<String> getUserDomainMappings(String user, String domain)
           
protected abstract  Collection<String> getUserDomainMappingsInternal(String user, String domain)
          Return Collection of all mappings for the given username and domain
protected abstract  String mapAddressInternal(String user, String domain)
          Override to map virtual recipients to real recipients, both local and non-local.
 void removeAddressMapping(String user, String domain, String address)
           
 void removeAliasDomainMapping(String aliasDomain, String realDomain)
           
 void removeErrorMapping(String user, String domain, String error)
           
 void removeMapping(String user, String domain, String mapping)
           
protected abstract  void removeMappingInternal(String user, String domain, String mapping)
          Remove mapping
 void removeRegexMapping(String user, String domain, String regex)
           
 void setDomainList(DomainList domainList)
           
 void setLog(org.slf4j.Logger logger)
           
 void setMappingLimit(int mappingLimit)
          Set the mappingLimit
 void setRecursiveMapping(boolean recursive)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

AbstractRecipientRewriteTable

public AbstractRecipientRewriteTable()
Method Detail

setDomainList

public void setDomainList(DomainList domainList)

configure

public void configure(org.apache.commons.configuration.HierarchicalConfiguration config)
               throws org.apache.commons.configuration.ConfigurationException
Specified by:
configure in interface Configurable
Throws:
org.apache.commons.configuration.ConfigurationException
See Also:
Configurable.configure(HierarchicalConfiguration)

setLog

public void setLog(org.slf4j.Logger logger)
Specified by:
setLog in interface LogEnabled

doConfigure

protected void doConfigure(org.apache.commons.configuration.HierarchicalConfiguration conf)
                    throws org.apache.commons.configuration.ConfigurationException
Override to handle config

Parameters:
conf -
Throws:
org.apache.commons.configuration.ConfigurationException

setRecursiveMapping

public void setRecursiveMapping(boolean recursive)

setMappingLimit

public void setMappingLimit(int mappingLimit)
                     throws IllegalArgumentException
Set the mappingLimit

Parameters:
mappingLimit - the mappingLimit
Throws:
IllegalArgumentException - get thrown if mappingLimit smaller then 1 is used

getMappings

public Collection<String> getMappings(String user,
                                      String domain)
                               throws RecipientRewriteTable.ErrorMappingException,
                                      RecipientRewriteTableException
Specified by:
getMappings in interface RecipientRewriteTable
Throws:
RecipientRewriteTable.ErrorMappingException
RecipientRewriteTableException
See Also:
RecipientRewriteTable.getMappings(String, String)

getMappings

public Collection<String> getMappings(String user,
                                      String domain,
                                      int mappingLimit)
                               throws RecipientRewriteTable.ErrorMappingException,
                                      RecipientRewriteTableException
Throws:
RecipientRewriteTable.ErrorMappingException
RecipientRewriteTableException

addRegexMapping

public void addRegexMapping(String user,
                            String domain,
                            String regex)
                     throws RecipientRewriteTableException
Specified by:
addRegexMapping in interface RecipientRewriteTable
Throws:
RecipientRewriteTableException
See Also:
RecipientRewriteTable.addRegexMapping(java.lang.String, java.lang.String, java.lang.String)

removeRegexMapping

public void removeRegexMapping(String user,
                               String domain,
                               String regex)
                        throws RecipientRewriteTableException
Specified by:
removeRegexMapping in interface RecipientRewriteTable
Throws:
RecipientRewriteTableException
See Also:
RecipientRewriteTable.removeRegexMapping(java.lang.String, java.lang.String, java.lang.String)

addAddressMapping

public void addAddressMapping(String user,
                              String domain,
                              String address)
                       throws RecipientRewriteTableException
Specified by:
addAddressMapping in interface RecipientRewriteTable
Throws:
RecipientRewriteTableException
See Also:
RecipientRewriteTable.addAddressMapping(java.lang.String, java.lang.String, java.lang.String)

removeAddressMapping

public void removeAddressMapping(String user,
                                 String domain,
                                 String address)
                          throws RecipientRewriteTableException
Specified by:
removeAddressMapping in interface RecipientRewriteTable
Throws:
RecipientRewriteTableException
See Also:
RecipientRewriteTable.removeAddressMapping(java.lang.String, java.lang.String, java.lang.String)

addErrorMapping

public void addErrorMapping(String user,
                            String domain,
                            String error)
                     throws RecipientRewriteTableException
Specified by:
addErrorMapping in interface RecipientRewriteTable
Throws:
RecipientRewriteTableException
See Also:
RecipientRewriteTable.addErrorMapping(java.lang.String, java.lang.String, java.lang.String)

removeErrorMapping

public void removeErrorMapping(String user,
                               String domain,
                               String error)
                        throws RecipientRewriteTableException
Specified by:
removeErrorMapping in interface RecipientRewriteTable
Throws:
RecipientRewriteTableException
See Also:
RecipientRewriteTable.removeErrorMapping(java.lang.String, java.lang.String, java.lang.String)

addMapping

public void addMapping(String user,
                       String domain,
                       String mapping)
                throws RecipientRewriteTableException
Specified by:
addMapping in interface RecipientRewriteTable
Throws:
RecipientRewriteTableException
See Also:
RecipientRewriteTable.addMapping(java.lang.String, java.lang.String, java.lang.String)

removeMapping

public void removeMapping(String user,
                          String domain,
                          String mapping)
                   throws RecipientRewriteTableException
Specified by:
removeMapping in interface RecipientRewriteTable
Throws:
RecipientRewriteTableException
See Also:
RecipientRewriteTable.removeMapping(java.lang.String, java.lang.String, java.lang.String)

getAllMappings

public Map<String,Collection<String>> getAllMappings()
                                              throws RecipientRewriteTableException
Specified by:
getAllMappings in interface RecipientRewriteTable
Throws:
RecipientRewriteTableException
See Also:
RecipientRewriteTable.getAllMappings()

getUserDomainMappings

public Collection<String> getUserDomainMappings(String user,
                                                String domain)
                                         throws RecipientRewriteTableException
Specified by:
getUserDomainMappings in interface RecipientRewriteTable
Throws:
RecipientRewriteTableException
See Also:
RecipientRewriteTable.getUserDomainMappings(java.lang.String, java.lang.String)

addAliasDomainMapping

public void addAliasDomainMapping(String aliasDomain,
                                  String realDomain)
                           throws RecipientRewriteTableException
Specified by:
addAliasDomainMapping in interface RecipientRewriteTable
Throws:
RecipientRewriteTableException
See Also:
RecipientRewriteTable.addAliasDomainMapping(java.lang.String, java.lang.String)

removeAliasDomainMapping

public void removeAliasDomainMapping(String aliasDomain,
                                     String realDomain)
                              throws RecipientRewriteTableException
Specified by:
removeAliasDomainMapping in interface RecipientRewriteTable
Throws:
RecipientRewriteTableException
See Also:
RecipientRewriteTable.removeAliasDomainMapping(java.lang.String, java.lang.String)

getLogger

protected org.slf4j.Logger getLogger()

addMappingInternal

protected abstract void addMappingInternal(String user,
                                           String domain,
                                           String mapping)
                                    throws RecipientRewriteTableException
Add new mapping

Parameters:
user - the user
domain - the domain
mapping - the mapping
Throws:
InvalidMappingException
RecipientRewriteTableException

removeMappingInternal

protected abstract void removeMappingInternal(String user,
                                              String domain,
                                              String mapping)
                                       throws RecipientRewriteTableException
Remove mapping

Parameters:
user - the user
domain - the domain
mapping - the mapping
Throws:
InvalidMappingException
RecipientRewriteTableException

getUserDomainMappingsInternal

protected abstract Collection<String> getUserDomainMappingsInternal(String user,
                                                                    String domain)
                                                             throws RecipientRewriteTableException
Return Collection of all mappings for the given username and domain

Parameters:
user - the user
domain - the domain
Returns:
Collection which hold the mappings
Throws:
RecipientRewriteTableException

getAllMappingsInternal

protected abstract Map<String,Collection<String>> getAllMappingsInternal()
                                                                  throws RecipientRewriteTableException
Return a Map which holds all Mappings

Returns:
Map
Throws:
RecipientRewriteTableException

mapAddressInternal

protected abstract String mapAddressInternal(String user,
                                             String domain)
                                      throws RecipientRewriteTableException
Override to map virtual recipients to real recipients, both local and non-local. Each key in the provided map corresponds to a potential virtual recipient, stored as a MailAddress object. Translate virtual recipients to real recipients by mapping a string containing the address of the real recipient as a value to a key. Leave the value null if no mapping should be performed. Multiple recipients may be specified by delineating the mapped string with commas, semi-colons or colons.

Parameters:
user - the mapping of virtual to real recipients, as MailAddresses to Strings.
Throws:
RecipientRewriteTableException

getFixedUser

protected String getFixedUser(String user)
Return user String for the given argument. If give value is null, return a wildcard.

Parameters:
user - the given user String
Returns:
fixedUser the fixed user String
Throws:
InvalidMappingException - get thrown on invalid argument

getFixedDomain

protected String getFixedDomain(String domain)
Fix the domain for the given argument. If give value is null, return a wildcard.

Parameters:
domain - the given domain String
Returns:
fixedDomain the fixed domain String
Throws:
InvalidMappingException - get thrown on invalid argument


Copyright © 2002-2012 The Apache Software Foundation. All Rights Reserved.