/hostadmiral/branches/hibernate3/src/ak/hostadmiral/listener/tcp/TcpListener.java |
---|
0,0 → 1,369 |
package ak.hostadmiral.listener.tcp; |
import java.util.Map; |
import java.util.Collection; |
import java.util.Iterator; |
import java.io.Writer; |
import java.io.BufferedWriter; |
import java.io.OutputStreamWriter; |
import java.io.Reader; |
import java.io.BufferedReader; |
import java.io.InputStreamReader; |
import java.net.Socket; |
import ak.hostadmiral.util.ModelException; |
import ak.hostadmiral.util.ConfigInit; |
import ak.hostadmiral.util.ConfigUtils; |
import ak.hostadmiral.core.model.*; |
import org.apache.log4j.Logger; |
public class TcpListener |
implements |
ConfigInit, |
UserCreatedListener, |
UserModifiedListener, |
UserDeletedListener, |
InetDomainCreatedListener, |
InetDomainModifiedListener, |
InetDomainDeletedListener, |
SystemUserCreatedListener, |
SystemUserModifiedListener, |
SystemUserDeletedListener, |
MailboxCreatedListener, |
MailboxModifiedListener, |
MailboxDeletedListener, |
MailAliasCreatedListener, |
MailAliasModifiedListener, |
MailAliasDeletedListener |
{ |
private static final Logger logger = Logger.getLogger(TcpListener.class); |
private static String hostname; |
private static int port; |
private static String password; |
protected static Object lock = new Object(); |
public static final String PROTOCOL_NAME = "HostAdmiral_TcpListener"; |
public static final String PROTOCOL_VER_MAJ = "1"; |
public static final String PROTOCOL_VER_MIN = "0"; |
public static final String PASSWORD_DIGEST = "crypt"; |
public void init(Map params) |
throws ModelException |
{ |
ConfigUtils cfg = new ConfigUtils(params); |
// save params |
setHostname(cfg.getString("hostname", "127.0.0.1", true, false)); |
setPort(cfg.getInteger("port", null, false).intValue()); |
setPassword(cfg.getString("password", null, true, true)); |
// register listeners |
UserManager.getInstance().addCreatedListener(this); |
UserManager.getInstance().addModifiedListener(this); |
UserManager.getInstance().addDeletedListener(this); |
InetDomainManager.getInstance().addCreatedListener(this); |
InetDomainManager.getInstance().addModifiedListener(this); |
InetDomainManager.getInstance().addDeletedListener(this); |
SystemUserManager.getInstance().addCreatedListener(this); |
SystemUserManager.getInstance().addModifiedListener(this); |
SystemUserManager.getInstance().addDeletedListener(this); |
MailboxManager.getInstance().addCreatedListener(this); |
MailboxManager.getInstance().addModifiedListener(this); |
MailboxManager.getInstance().addDeletedListener(this); |
MailAliasManager.getInstance().addCreatedListener(this); |
MailAliasManager.getInstance().addModifiedListener(this); |
MailAliasManager.getInstance().addDeletedListener(this); |
} |
public static String getHostname() |
{ |
return hostname; |
} |
public static void setHostname(String hostname_) |
{ |
hostname = hostname_; |
} |
public static int getPort() |
{ |
return port; |
} |
public static void setPort(int port_) |
{ |
port = port_; |
} |
public static void setPassword(String password_) |
{ |
password = password_; |
} |
protected static String escape(String s) |
{ |
// FIXME: any other problem characters? optimize it? |
s = s.replaceAll("\\\\", "\\\\\\\\"); |
s = s.replaceAll("\0", "\\\\0"); |
s = s.replaceAll("\t", "\\\\t"); |
s = s.replaceAll("\n", "\\\\n"); |
s = s.replaceAll("\r", "\\\\r"); |
return s; |
} |
protected static void send(String message) |
throws ModelException |
{ |
synchronized(lock) { |
try { |
Socket socket = new Socket(hostname, port); |
// send request |
Writer out = new BufferedWriter(new OutputStreamWriter(socket.getOutputStream(), "UTF-8")); |
out.write(PROTOCOL_NAME + " " + PROTOCOL_VER_MAJ + "." + PROTOCOL_VER_MIN + "\n"); |
if(password != null) { |
out.write("password=" + password + "\n"); |
} |
out.write(message); |
out.write("\n\n"); |
out.flush(); |
socket.shutdownOutput(); |
// get response |
BufferedReader in = new BufferedReader( |
new InputStreamReader(socket.getInputStream())); |
String line; |
boolean headerDone = false; |
boolean codeDone = false; |
while((line = in.readLine()) != null) { |
if(!headerDone) { |
if(!line.matches("^" + PROTOCOL_NAME + " " + PROTOCOL_VER_MAJ + "\\.\\d+$")) |
throw new ModelException( |
"Wrong response: wrong header in [" + line + "]"); |
headerDone = true; |
} |
else if(!codeDone) { |
if(line.length() < 3) |
throw new ModelException( |
"Wrong response: code too short [" + line + "]"); |
if(line.length() >= 4 && line.charAt(3) != ' ') |
throw new ModelException( |
"Wrong response: cannot get code from [" + line + "]"); |
int code; |
try { |
code = Integer.parseInt(line.substring(0, 3)); |
} |
catch(NumberFormatException ex) { |
throw new ModelException( |
"Wrong response: cannot parse code from [" + line + "]"); |
} |
String response = (line.length() >= 5) ? line.substring(4) : null; |
if(code >= 200 && code < 300) { |
logger.info("Response from backend [" + line + "]"); |
} |
else if(code >= 400 && code < 600) { |
throw new ModelException( |
"Error from backend [" + line + "]"); |
} |
codeDone = true; |
} |
else { |
if(!line.equals("")) |
throw new ModelException( |
"Wrong response: no more lines expected [" + line + "]"); |
} |
} |
// done |
socket.close(); |
} |
catch(Exception ex) { |
logger.error("Cannot send message over TCP", ex); |
throw new ModelException("Cannot send message over TCP:" + ex.getMessage()); |
// FIMXE: or just throw "internal server error" message? |
} |
} |
} |
//=== user ==================================================================================== |
public void userCreated(User editor, User user) |
throws ModelException |
{ |
send("user\tcreate\tlogin=" + escape(user.getLogin()) |
+ "\tpassword=" + escape(user.getPassword(editor, PASSWORD_DIGEST)) |
+ "\tenabled=" + user.getEnabled() |
+ "\tcomment=" + escape(user.getComment())); |
} |
public void userModified(User editor, User user, User oldUser) |
throws ModelException |
{ |
send("user\tmodify\toldLogin=" + escape(oldUser.getLogin()) |
+ "\tlogin=" + escape(user.getLogin()) |
+ "\tpassword=" + escape(user.getPassword(editor, PASSWORD_DIGEST)) |
+ "\tenabled=" + user.getEnabled() |
+ "\tcomment=" + escape(user.getComment())); |
} |
public void userDeleted(User editor, User user) |
throws ModelException |
{ |
send("user\tdelete\tlogin=" + escape(user.getLogin())); |
} |
//=== inet domain ============================================================================= |
public void inetDomainCreated(User editor, InetDomain domain) |
throws ModelException |
{ |
send("inetDomain\tcreate\tname=" + escape(domain.getName()) |
+ "\tenabled=" + domain.getEnabled() |
+ "\tcomment=" + escape(domain.getComment())); |
} |
public void inetDomainModified(User editor, InetDomain domain, InetDomain oldDomain) |
throws ModelException |
{ |
send("inetDomain\tmodify\toldName=" + escape(oldDomain.getName()) |
+ "\tname=" + escape(domain.getName()) |
+ "\tenabled=" + domain.getEnabled() |
+ "\tcomment=" + escape(domain.getComment())); |
} |
public void inetDomainDeleted(User editor, InetDomain domain) |
throws ModelException |
{ |
send("inetDomain\tdelete\tname=" + escape(domain.getName())); |
} |
//=== system user ============================================================================= |
public void systemUserCreated(User editor, SystemUser systemUser) |
throws ModelException |
{ |
send("systemUser\tcreate\tuid=" + systemUser.getUid() |
+ "\tname=" + escape(systemUser.getName()) |
+ "\tenabled=" + systemUser.getEnabled() |
+ "\tcomment=" + escape(systemUser.getComment())); |
} |
public void systemUserModified(User editor, SystemUser systemUser, SystemUser oldSystemUser) |
throws ModelException |
{ |
send("systemUser\tmodify\toldUid=" + oldSystemUser.getUid() |
+ "\toldName=" + escape(oldSystemUser.getName()) |
+ "\tuid=" + systemUser.getUid() |
+ "\tname=" + escape(systemUser.getName()) |
+ "\tenabled=" + systemUser.getEnabled() |
+ "\tcomment=" + escape(systemUser.getComment())); |
} |
public void systemUserDeleted(User editor, SystemUser systemUser) |
throws ModelException |
{ |
send("systemUser\tdelete\tuid=" + systemUser.getUid() |
+ "\tname=" + escape(systemUser.getName())); |
} |
//=== mailbox ================================================================================= |
public void mailboxCreated(User editor, Mailbox mailbox) |
throws ModelException |
{ |
send("mailbox\tcreate\tlogin=" + escape(mailbox.getLogin()) |
+ "\tpassword=" + escape(mailbox.getPassword(editor, PASSWORD_DIGEST)) |
+ "\tdomain=" + escape(mailbox.getDomain().getName()) |
+ "\tvirusCheck=" + mailbox.getVirusCheck() |
+ "\tspamCheck=" + mailbox.getSpamCheck() |
+ "\tsystemUser=" + (mailbox.getSystemUser() == null |
? "" : mailbox.getSystemUser().getUid().toString()) |
+ "\tenabled=" + mailbox.getEnabled() |
+ "\tcomment=" + escape(mailbox.getComment())); |
} |
public void mailboxModified(User editor, Mailbox mailbox, Mailbox oldMailbox) |
throws ModelException |
{ |
send("mailbox\tmodify\toldLogin=" + escape(oldMailbox.getLogin()) |
+ "\toldDomain=" + escape(oldMailbox.getDomain().getName()) |
+ "\tlogin=" + escape(mailbox.getLogin()) |
+ "\tpassword=" + escape(mailbox.getPassword(editor, PASSWORD_DIGEST)) |
+ "\tdomain=" + escape(mailbox.getDomain().getName()) |
+ "\tvirusCheck=" + mailbox.getVirusCheck() |
+ "\tspamCheck=" + mailbox.getSpamCheck() |
+ "\tsystemUser=" + (mailbox.getSystemUser() == null |
? "" : mailbox.getSystemUser().getUid().toString()) |
+ "\tenabled=" + mailbox.getEnabled() |
+ "\tcomment=" + escape(mailbox.getComment())); |
} |
public void mailboxDeleted(User editor, Mailbox mailbox) |
throws ModelException |
{ |
send("mailbox\tdelete\tlogin=" + escape(mailbox.getLogin()) |
+ "\tdomain=" + escape(mailbox.getDomain().getName())); |
} |
//=== mail alias ============================================================================== |
private String formMailAliasDestinations(User editor, MailAlias mailAlias) |
throws ModelException |
{ |
StringBuffer b = new StringBuffer(); |
Collection dests = mailAlias.getDestinations(editor); |
if(dests != null) { |
for(Iterator i = dests.iterator(); i.hasNext(); ) { |
MailAliasDestination d = (MailAliasDestination)i.next(); |
b.append("\n\t"); |
if(d.getMailbox() != null) |
b.append(escape(d.getMailbox().getLogin())).append("@").append(escape(d.getMailbox().getDomain().getName())); |
else |
b.append(escape(d.getEmail())); |
} |
} |
return b.toString(); |
} |
public void mailAliasCreated(User editor, MailAlias mailAlias) |
throws ModelException |
{ |
send("mailAlias\tcreate\taddress=" + escape(mailAlias.getAddress()) |
+ "\tdomain=" + escape(mailAlias.getDomain().getName()) |
+ "\tenabled=" + mailAlias.getEnabled() |
+ "\tcomment=" + escape(mailAlias.getComment()) |
+ formMailAliasDestinations(editor, mailAlias)); |
} |
public void mailAliasModified(User editor, MailAlias mailAlias, MailAlias oldMailAlias) |
throws ModelException |
{ |
send("mailAlias\tmodify\toldAddress=" + escape(oldMailAlias.getAddress()) |
+ "\toldDomain=" + escape(oldMailAlias.getDomain().getName()) |
+ "\taddress=" + escape(mailAlias.getAddress()) |
+ "\tdomain=" + escape(mailAlias.getDomain().getName()) |
+ "\tenabled=" + mailAlias.getEnabled() |
+ "\tcomment=" + escape(mailAlias.getComment()) |
+ formMailAliasDestinations(editor, mailAlias)); |
} |
public void mailAliasDeleted(User editor, MailAlias mailAlias) |
throws ModelException |
{ |
send("mailAlias\tdelete\taddress=" + escape(mailAlias.getAddress()) |
+ "\tdomain=" + escape(mailAlias.getDomain().getName())); |
} |
} |
/hostadmiral/branches/hibernate3/src/ak/hostadmiral/listener/uservalidatoratdomain/UserValidatorAtDomain.java |
---|
0,0 → 1,52 |
package ak.hostadmiral.listener.uservalidatoratdomain; |
import java.util.Map; |
import java.util.Collection; |
import java.util.Iterator; |
import ak.hostadmiral.core.model.User; |
import ak.hostadmiral.core.model.UserManager; |
import ak.hostadmiral.core.model.UserValidateListener; |
import ak.hostadmiral.core.model.InetDomain; |
import ak.hostadmiral.core.model.InetDomainManager; |
import ak.hostadmiral.util.ConfigInit; |
import ak.hostadmiral.util.ModelException; |
import ak.hostadmiral.util.ModelUserException; |
import ak.hostadmiral.util.ResourceManager; |
public class UserValidatorAtDomain |
implements |
ConfigInit, |
UserValidateListener |
{ |
public void init(Map params) |
{ |
UserManager.getInstance().addValidateListener(this); |
ResourceManager.getInstance().addResource( |
"ak.hostadmiral.listener.uservalidatoratdomain.UserValidatorAtDomainMessages"); |
} |
public void userValidate(User editor, User user, User oldUser) |
throws ModelException |
{ |
// superuser |
if(editor.isSuperuser()) return; |
// login not changed |
if(oldUser.getLogin() != null && user.getLogin().equals(oldUser.getLogin())) |
return; |
// go through all domains |
Collection domains = InetDomainManager.getInstance().listInetDomains(editor); |
for(Iterator i = domains.iterator(); i.hasNext(); ) { |
InetDomain domain = (InetDomain)i.next(); |
if(user.getLogin().endsWith("@" + domain.getName())) |
return; |
} |
// nothing found |
throw new ModelUserException( |
"ak.hostadmiral.listener.uservalidatoratdomain.login.wrong"); |
} |
} |
/hostadmiral/branches/hibernate3/src/ak/hostadmiral/listener/uservalidatoratdomain/UserValidatorAtDomainMessages.properties |
---|
0,0 → 1,0 |
ak.hostadmiral.listener.uservalidatoratdomain.login.wrong=User login must be inside one of your domains, e.g. user@example.com |
/hostadmiral/branches/hibernate3/src/ak/hostadmiral/listener/file/FileListener.java |
---|
0,0 → 1,283 |
package ak.hostadmiral.listener.file; |
import java.util.Map; |
import java.util.Collection; |
import java.util.Iterator; |
import java.io.Writer; |
import java.io.BufferedWriter; |
import java.io.FileWriter; |
import ak.hostadmiral.util.ModelException; |
import ak.hostadmiral.util.ConfigInit; |
import ak.hostadmiral.core.model.*; |
import org.apache.log4j.Logger; |
public class FileListener |
implements |
ConfigInit, |
UserCreatedListener, |
UserModifiedListener, |
UserDeletedListener, |
InetDomainCreatedListener, |
InetDomainModifiedListener, |
InetDomainDeletedListener, |
SystemUserCreatedListener, |
SystemUserModifiedListener, |
SystemUserDeletedListener, |
MailboxCreatedListener, |
MailboxModifiedListener, |
MailboxDeletedListener, |
MailAliasCreatedListener, |
MailAliasModifiedListener, |
MailAliasDeletedListener |
{ |
private static final Logger logger = Logger.getLogger(FileListener.class); |
private static String fileName; |
protected static Object lock = new Object(); |
public static final String PROTOCOL_NAME = "HostAdmiral_FileListener"; |
public static final String PROTOCOL_VERSION = "0.1"; |
public void init(Map params) |
{ |
setFileName(((String[])params.get("fileName"))[0]); |
UserManager.getInstance().addCreatedListener(this); |
UserManager.getInstance().addModifiedListener(this); |
UserManager.getInstance().addDeletedListener(this); |
InetDomainManager.getInstance().addCreatedListener(this); |
InetDomainManager.getInstance().addModifiedListener(this); |
InetDomainManager.getInstance().addDeletedListener(this); |
SystemUserManager.getInstance().addCreatedListener(this); |
SystemUserManager.getInstance().addModifiedListener(this); |
SystemUserManager.getInstance().addDeletedListener(this); |
MailboxManager.getInstance().addCreatedListener(this); |
MailboxManager.getInstance().addModifiedListener(this); |
MailboxManager.getInstance().addDeletedListener(this); |
MailAliasManager.getInstance().addCreatedListener(this); |
MailAliasManager.getInstance().addModifiedListener(this); |
MailAliasManager.getInstance().addDeletedListener(this); |
} |
public static String getFileName() |
{ |
return fileName; |
} |
public static void setFileName(String fileName_) |
{ |
fileName = fileName_; |
} |
protected static String escape(String s) |
{ |
// FIXME: any other problem characters? optimize it? |
s = s.replaceAll("\0", "\\\\0"); |
s = s.replaceAll("\\\\", "\\\\\\\\"); |
s = s.replaceAll("\t", "\\\\t"); |
s = s.replaceAll("\n", "\\\\n"); |
s = s.replaceAll("\r", "\\\\r"); |
return s; |
} |
protected static void send(String message) |
throws ModelException |
{ |
synchronized(lock) { |
try { |
Writer out = new BufferedWriter(new FileWriter(fileName)); |
if(PROTOCOL_NAME != null) { |
out.write(PROTOCOL_NAME); |
out.write(" "); |
} |
if(PROTOCOL_VERSION != null) { |
out.write(PROTOCOL_VERSION); |
out.write("\n"); |
} |
out.write(message); |
out.write("\n\n"); |
out.close(); |
} |
catch(Exception ex) { |
logger.error("Cannot save message to file", ex); |
throw new ModelException("Cannot save message to file:" + ex.getMessage()); |
// FIMXE: or just throw "internal server error" message? |
} |
} |
} |
//=== user ==================================================================================== |
public void userCreated(User editor, User user) |
throws ModelException |
{ |
send("user\tcreate\t" + escape(user.getLogin()) + "\t" |
+ escape(/* FIXME user.getPassword() */ "") + "\t" |
+ user.getEnabled() + "\t" |
+ escape(user.getComment())); |
} |
public void userModified(User editor, User user, User oldUser) |
throws ModelException |
{ |
send("user\tmodify\t" + escape(oldUser.getLogin()) + "\t" |
+ escape(user.getLogin()) + "\t" |
+ escape(/* FIXME user.getPassword() */ "") + "\t" |
+ user.getEnabled() + "\t" |
+ escape(user.getComment())); |
} |
public void userDeleted(User editor, User user) |
throws ModelException |
{ |
send("user\tdelete\t" + escape(user.getLogin())); |
} |
//=== inet domain ============================================================================= |
public void inetDomainCreated(User editor, InetDomain domain) |
throws ModelException |
{ |
send("inetDomain\tcreate\t" + escape(domain.getName()) + "\t" |
+ domain.getEnabled() + "\t" |
+ escape(domain.getComment())); |
} |
public void inetDomainModified(User editor, InetDomain domain, InetDomain oldDomain) |
throws ModelException |
{ |
send("inetDomain\tmodify\t" + escape(oldDomain.getName()) + "\t" |
+ escape(domain.getName()) + "\t" |
+ domain.getEnabled() + "\t" |
+ escape(domain.getComment())); |
} |
public void inetDomainDeleted(User editor, InetDomain domain) |
throws ModelException |
{ |
send("inetDomain\tdelete\t" + escape(domain.getName())); |
} |
//=== system user ============================================================================= |
public void systemUserCreated(User editor, SystemUser systemUser) |
throws ModelException |
{ |
send("systemUser\tcreate\t" + systemUser.getUid() + "\t" |
+ escape(systemUser.getName()) + "\t" |
+ systemUser.getEnabled() + "\t" |
+ escape(systemUser.getComment())); |
} |
public void systemUserModified(User editor, SystemUser systemUser, SystemUser oldSystemUser) |
throws ModelException |
{ |
send("systemUser\tmodify\t" + oldSystemUser.getUid() + "\t" |
+ escape(oldSystemUser.getName()) + "\t" |
+ systemUser.getUid() + "\t" |
+ escape(systemUser.getName()) + "\t" |
+ systemUser.getEnabled() + "\t" |
+ escape(systemUser.getComment())); |
} |
public void systemUserDeleted(User editor, SystemUser systemUser) |
throws ModelException |
{ |
send("systemUser\tdelete\t" + systemUser.getUid() + "\t" + escape(systemUser.getName())); |
} |
//=== mailbox ================================================================================= |
public void mailboxCreated(User editor, Mailbox mailbox) |
throws ModelException |
{ |
send("mailbox\tcreate\t" + escape(mailbox.getLogin()) + "\t" |
+ escape(/* FIXME user.getPassword() */ "") + "\t" |
+ escape(mailbox.getDomain().getName()) + "\t" |
+ mailbox.getVirusCheck() + "\t" |
+ mailbox.getSpamCheck() + "\t" |
+ (mailbox.getSystemUser() == null ? "" : mailbox.getSystemUser().getUid().toString()) |
+ "\t" |
+ mailbox.getEnabled() + "\t" |
+ escape(mailbox.getComment())); |
} |
public void mailboxModified(User editor, Mailbox mailbox, Mailbox oldMailbox) |
throws ModelException |
{ |
send("mailbox\tmodify\t" + escape(oldMailbox.getLogin()) + "\t" |
+ escape(oldMailbox.getDomain().getName()) + "\t" |
+ escape(mailbox.getLogin()) + "\t" |
+ escape(/* FIXME user.getPassword() */ "") + "\t" |
+ escape(mailbox.getDomain().getName()) + "\t" |
+ mailbox.getVirusCheck() + "\t" |
+ mailbox.getSpamCheck() + "\t" |
+ (mailbox.getSystemUser() == null ? "" : mailbox.getSystemUser().getUid().toString()) |
+ "\t" |
+ mailbox.getEnabled() + "\t" |
+ escape(mailbox.getComment())); |
} |
public void mailboxDeleted(User editor, Mailbox mailbox) |
throws ModelException |
{ |
send("mailbox\tdelete\t" + escape(mailbox.getLogin()) + "\t" |
+ escape(mailbox.getDomain().getName())); |
} |
//=== mail alias ============================================================================== |
private String formMailAliasDestinations(User editor, MailAlias mailAlias) |
throws ModelException |
{ |
StringBuffer b = new StringBuffer(); |
Collection dests = mailAlias.getDestinations(editor); |
if(dests != null) { |
for(Iterator i = dests.iterator(); i.hasNext(); ) { |
MailAliasDestination d = (MailAliasDestination)i.next(); |
b.append("\n\t"); |
if(d.getMailbox() != null) |
b.append(escape(d.getMailbox().getLogin())).append("@").append(escape(d.getMailbox().getDomain().getName())); |
else |
b.append(escape(d.getEmail())); |
} |
} |
return b.toString(); |
} |
public void mailAliasCreated(User editor, MailAlias mailAlias) |
throws ModelException |
{ |
send(" mailAlias\tcreate\t" + escape(mailAlias.getAddress()) + "\t" |
+ escape(mailAlias.getDomain().getName()) + "\t" |
+ mailAlias.getEnabled() + "\t" |
+ escape(mailAlias.getComment()) |
+ formMailAliasDestinations(editor, mailAlias)); |
} |
public void mailAliasModified(User editor, MailAlias mailAlias, MailAlias oldMailAlias) |
throws ModelException |
{ |
send(" mailAlias\tmodify\t" + escape(oldMailAlias.getAddress()) + "\t" |
+ escape(oldMailAlias.getDomain().getName()) + "\t" |
+ escape(mailAlias.getAddress()) + "\t" |
+ escape(mailAlias.getDomain().getName()) + "\t" |
+ mailAlias.getEnabled() + "\t" |
+ escape(mailAlias.getComment()) |
+ formMailAliasDestinations(editor, mailAlias)); |
} |
public void mailAliasDeleted(User editor, MailAlias mailAlias) |
throws ModelException |
{ |
send(" mailAlias\tdelete\t" + escape(mailAlias.getAddress())+ "\t" |
+ escape(mailAlias.getDomain().getName())); |
} |
} |
/hostadmiral/branches/hibernate3/src/ak/hostadmiral/listener/dummy/DummyListener.java |
---|
0,0 → 1,165 |
package ak.hostadmiral.listener.dummy; |
import java.util.Map; |
import ak.hostadmiral.util.ModelException; |
import ak.hostadmiral.util.ConfigInit; |
import ak.hostadmiral.core.model.*; |
public class DummyListener |
implements |
ConfigInit, |
UserCreatedListener, |
UserModifiedListener, |
UserDeletedListener, |
InetDomainCreatedListener, |
InetDomainModifiedListener, |
InetDomainDeletedListener, |
SystemUserCreatedListener, |
SystemUserModifiedListener, |
SystemUserDeletedListener, |
MailboxCreatedListener, |
MailboxModifiedListener, |
MailboxDeletedListener, |
MailAliasCreatedListener, |
MailAliasModifiedListener, |
MailAliasDeletedListener |
{ |
public void init(Map params) |
{ |
UserManager.getInstance().addCreatedListener(this); |
UserManager.getInstance().addModifiedListener(this); |
UserManager.getInstance().addDeletedListener(this); |
InetDomainManager.getInstance().addCreatedListener(this); |
InetDomainManager.getInstance().addModifiedListener(this); |
InetDomainManager.getInstance().addDeletedListener(this); |
SystemUserManager.getInstance().addCreatedListener(this); |
SystemUserManager.getInstance().addModifiedListener(this); |
SystemUserManager.getInstance().addDeletedListener(this); |
MailboxManager.getInstance().addCreatedListener(this); |
MailboxManager.getInstance().addModifiedListener(this); |
MailboxManager.getInstance().addDeletedListener(this); |
MailAliasManager.getInstance().addCreatedListener(this); |
MailAliasManager.getInstance().addModifiedListener(this); |
MailAliasManager.getInstance().addDeletedListener(this); |
} |
//=== user ==================================================================================== |
public void userCreated(User editor, User user) |
throws ModelException |
{ |
System.out.println("DummyListener.userCreated: " |
+ user + " by " + editor); |
} |
public void userModified(User editor, User user, User oldUser) |
throws ModelException |
{ |
System.out.println("DummyListener.userModified: from " + oldUser |
+ " to " + user + " by " + editor); |
} |
public void userDeleted(User editor, User user) |
throws ModelException |
{ |
System.out.println("DummyListener.userDeleted: " |
+ user + " by " + editor); |
} |
//=== inet domain ============================================================================= |
public void inetDomainCreated(User editor, InetDomain domain) |
throws ModelException |
{ |
System.out.println("DummyListener.inetDomainCreated: " |
+ domain + " by " + editor); |
} |
public void inetDomainModified(User editor, InetDomain domain, InetDomain oldDomain) |
throws ModelException |
{ |
System.out.println("DummyListener.inetDomainModified: from " + oldDomain |
+ " to " + domain + " by " + editor); |
} |
public void inetDomainDeleted(User editor, InetDomain domain) |
throws ModelException |
{ |
System.out.println("DummyListener.inetDomainDeleted: " |
+ domain + " by " + editor); |
} |
//=== system user ============================================================================= |
public void systemUserCreated(User editor, SystemUser systemUser) |
throws ModelException |
{ |
System.out.println("DummyListener.systemUserCreated: " |
+ systemUser + " by " + editor); |
} |
public void systemUserModified(User editor, SystemUser systemUser, SystemUser oldSystemUser) |
throws ModelException |
{ |
System.out.println("DummyListener.systemUserModified: from " + oldSystemUser |
+ " to " + systemUser + " by " + editor); |
} |
public void systemUserDeleted(User editor, SystemUser systemUser) |
throws ModelException |
{ |
System.out.println("DummyListener.systemUserDeleted: " |
+ systemUser + " by " + editor); |
} |
//=== mailbox ================================================================================= |
public void mailboxCreated(User editor, Mailbox mailbox) |
throws ModelException |
{ |
System.out.println("DummyListener.mailboxCreated: " |
+ mailbox + " by " + editor); |
} |
public void mailboxModified(User editor, Mailbox mailbox, Mailbox oldMailbox) |
throws ModelException |
{ |
System.out.println("DummyListener.mailboxModified: from " + oldMailbox |
+ " to " + mailbox + " by " + editor); |
} |
public void mailboxDeleted(User editor, Mailbox mailbox) |
throws ModelException |
{ |
System.out.println("DummyListener.mailboxDeleted: " |
+ mailbox + " by " + editor); |
} |
//=== mail alias ============================================================================== |
public void mailAliasCreated(User editor, MailAlias mailAlias) |
throws ModelException |
{ |
System.out.println("DummyListener.mailAliasCreated: " |
+ mailAlias + " by " + editor); |
} |
public void mailAliasModified(User editor, MailAlias mailAlias, MailAlias oldMailAlias) |
throws ModelException |
{ |
System.out.println("DummyListener.mailAliasModified: from " + oldMailAlias |
+ " to " + mailAlias + " by " + editor); |
} |
public void mailAliasDeleted(User editor, MailAlias mailAlias) |
throws ModelException |
{ |
System.out.println("DummyListener.mailAliasDeleted: " |
+ mailAlias + " by " + editor); |
} |
} |