1   package com.atlassian.mail.server.managers;
2   
3   import com.atlassian.mail.MailException;
4   import com.atlassian.mail.server.*;
5   
6   import javax.annotation.Nullable;
7   import javax.mail.Authenticator;
8   import javax.mail.Session;
9   import java.util.List;
10  import java.util.Map;
11  import java.util.Properties;
12  
13  /**
14   * Date: Dec 9, 2002
15   */
16  public abstract class AbstractMailServerManager implements MailServerManager
17  {
18  	private MailServerConfigurationHandler mailServerConfigurationHandler;
19  
20      public void init(Map params)
21      {
22          // by default, do nothing
23      }
24  
25  	@Nullable
26      public abstract MailServer getMailServer(Long id) throws MailException;
27  
28  	@Nullable
29      public abstract MailServer getMailServer(String name) throws MailException;
30  
31      public abstract List<String> getServerNames() throws MailException;
32  
33      public abstract List<SMTPMailServer> getSmtpMailServers();
34  
35      public abstract List<PopMailServer> getPopMailServers();
36  
37      public abstract Long create(MailServer mailServer) throws MailException;
38  
39      public abstract void update(MailServer mailServer) throws MailException;
40  
41      public abstract void delete(Long mailServerId) throws MailException;
42  
43      @Nullable
44      public abstract SMTPMailServer getDefaultSMTPMailServer();
45  
46      public boolean isDefaultSMTPMailServerDefined() {
47          return getDefaultSMTPMailServer() != null;
48      }
49  
50      @Nullable
51      public abstract PopMailServer getDefaultPopMailServer();
52  
53      public Session getSession(Properties props, Authenticator auth)
54      {
55          return Session.getInstance(props, auth);
56      }
57  
58  	public synchronized void setMailServerConfigurationHandler(@Nullable MailServerConfigurationHandler mailServerConfigurationHandler) {
59  		this.mailServerConfigurationHandler = mailServerConfigurationHandler;
60  	}
61  
62  	protected synchronized MailServerConfigurationHandler getMailServerConfigurationHandler() {
63  		return mailServerConfigurationHandler;
64  	}
65  }