/hostadmiral/trunk/src/ak/hostadmiral/core/model/InetDomainModifiedListener.java |
---|
0,0 → 1,21 |
package ak.hostadmiral.core.model; |
import java.util.Collection; |
import ak.hostadmiral.util.ModelException; |
public interface InetDomainModifiedListener |
{ |
/** |
* called if some domain is just changed. |
* |
* @param editor who is doing the operation |
* @param domain the domain in its new state |
* @param oldDomain copy of domain as it was before the operation |
* @throws ModelException in case of any *fatal* errors, |
* Note: throw it on fatal errors only, because database transaction |
* will be rolled back but any other InetDomainCreatedListeners might be already called |
* and (possible) they will not restore their original state. |
*/ |
public void inetDomainModified(User editor, InetDomain domain, InetDomain oldDomain) |
throws ModelException; |
} |
/hostadmiral/trunk/src/ak/hostadmiral/core/model/UserManager.java |
---|
236,7 → 236,7 |
public void delete(User editor, User user) |
throws ModelException |
{ |
// chech rights |
// check rights |
if(!user.deleteableBy(editor)) |
throw new ModelSecurityException(); |
/hostadmiral/trunk/src/ak/hostadmiral/core/model/SystemUserDeletedListener.java |
---|
0,0 → 1,20 |
package ak.hostadmiral.core.model; |
import java.util.Collection; |
import ak.hostadmiral.util.ModelException; |
public interface SystemUserDeletedListener |
{ |
/** |
* called if some system user is just deleted. |
* |
* @param editor who is doing the operation |
* @param systemUser the system user deleted |
* @throws ModelException in case of any *fatal* errors, |
* Note: throw it on fatal errors only, because database transaction |
* will be rolled back but any other SystemUserDeletedListeners might be already called |
* and (possible) they will not restore their original state. |
*/ |
public void systemUserDeleted(User editor, SystemUser systemUser) |
throws ModelException; |
} |
/hostadmiral/trunk/src/ak/hostadmiral/core/model/SystemUserCreatedListener.java |
---|
0,0 → 1,20 |
package ak.hostadmiral.core.model; |
import java.util.Collection; |
import ak.hostadmiral.util.ModelException; |
public interface SystemUserCreatedListener |
{ |
/** |
* called if new system user is just created. |
* |
* @param editor who is doing the operation |
* @param systemUser the new system user |
* @throws ModelException in case of any *fatal* errors, |
* Note: throw it on fatal errors only, because database transaction |
* will be rolled back but any other SystemUserCreatedListeners might be already called |
* and (possible) they will not restore their original state. |
*/ |
public void systemUserCreated(User editor, SystemUser systemUser) |
throws ModelException; |
} |
/hostadmiral/trunk/src/ak/hostadmiral/core/model/InetDomainManager.java |
---|
41,7 → 41,10 |
register(); |
} |
private Collection createdListeners = new ArrayList(); |
private Collection modifiedListeners = new ArrayList(); |
private Collection beforeDeleteListeners = new ArrayList(); |
private Collection deletedListeners = new ArrayList(); |
private InetDomainManager() |
{ |
128,6 → 131,8 |
if(!domain.editableBy(editor)) |
throw new ModelSecurityException(); |
boolean isNew = domain.isNew(); |
//domain.setModUser(editor); // FIXME |
try { |
137,18 → 142,64 |
{ |
throw new ModelException(ex); |
} |
// inform listeners |
if(isNew) { |
for(Iterator i = createdListeners.iterator(); i.hasNext(); ) { |
InetDomainCreatedListener listener = (InetDomainCreatedListener)i.next(); |
listener.inetDomainCreated(editor, domain); |
} |
} |
else { |
InetDomain oldDomain = domain.getOrigin(); |
if(oldDomain == null) oldDomain = domain; |
for(Iterator i = modifiedListeners.iterator(); i.hasNext(); ) { |
InetDomainModifiedListener listener = (InetDomainModifiedListener)i.next(); |
listener.inetDomainModified(editor, domain, oldDomain); |
} |
} |
} |
public void addBeforeDeleteListener(SystemUserBeforeDeleteListener listener) |
public void addCreatedListener(InetDomainCreatedListener listener) |
{ |
createdListeners.add(listener); |
} |
public void removeCreatedListener(InetDomainCreatedListener listener) |
{ |
createdListeners.remove(listener); |
} |
public void addModifiedListener(InetDomainModifiedListener listener) |
{ |
modifiedListeners.add(listener); |
} |
public void removeModifiedListener(InetDomainModifiedListener listener) |
{ |
modifiedListeners.remove(listener); |
} |
public void addBeforeDeleteListener(InetDomainBeforeDeleteListener listener) |
{ |
beforeDeleteListeners.add(listener); |
} |
public void removeBeforeDeleteListener(SystemUserBeforeDeleteListener listener) |
public void removeBeforeDeleteListener(InetDomainBeforeDeleteListener listener) |
{ |
beforeDeleteListeners.remove(listener); |
} |
public void addDeletedListener(InetDomainDeletedListener listener) |
{ |
deletedListeners.add(listener); |
} |
public void removeDeletedListener(InetDomainDeletedListener listener) |
{ |
deletedListeners.remove(listener); |
} |
public Collection beforeDelete(User editor, InetDomain domain, Collection known) |
throws ModelException |
{ |
167,9 → 218,14 |
public void delete(User editor, InetDomain domain) |
throws ModelException |
{ |
// check rights |
if(!domain.deleteableBy(editor)) |
throw new ModelSecurityException(); |
// backup copy |
InetDomain oldDomain = new InetDomain(domain); |
// delete it |
try { |
HibernateUtil.currentSession().delete(domain); |
178,7 → 234,13 |
{ |
throw new ModelException(ex); |
} |
// inform listeners |
for(Iterator i = deletedListeners.iterator(); i.hasNext(); ) { |
InetDomainDeletedListener listener = (InetDomainDeletedListener)i.next(); |
listener.inetDomainDeleted(editor, oldDomain); |
} |
} |
public Collection listInetDomains(User editor) |
throws ModelException |
/hostadmiral/trunk/src/ak/hostadmiral/core/model/InetDomain.java |
---|
12,11 → 12,30 |
{ |
private String name; |
private User owner; |
private InetDomain origin; // save original object state before any changes |
protected InetDomain() |
{ |
} |
protected InetDomain(InetDomain origin) |
{ |
super(origin); |
this.name = origin.name; |
this.owner = origin.owner; |
} |
protected InetDomain getOrigin() |
{ |
return origin; |
} |
protected void backupMe() |
{ |
if(origin == null) |
origin = new InetDomain(this); |
} |
/** |
* |
* @hibernate.property |
37,6 → 56,7 |
if(!editableBy(editor)) |
throw new ModelSecurityException(); |
backupMe(); |
this.name = name; |
} |
60,6 → 80,7 |
if(!editableBy(editor)) |
throw new ModelSecurityException(); |
backupMe(); |
this.owner = owner; |
} |
/hostadmiral/trunk/src/ak/hostadmiral/core/model/MailAliasManager.java |
---|
8,8 → 8,19 |
import ak.hostadmiral.util.ModelSecurityException; |
public class MailAliasManager |
implements UserBeforeDeleteListener |
{ |
private static MailAliasManager mailAliasManager = null; |
private static boolean registered = false; |
public static MailAliasManager getInstance() |
{ |
if(mailAliasManager == null) |
mailAliasManager = new MailAliasManager(); |
return mailAliasManager; |
} |
protected static void register() |
{ |
synchronized(MailAliasManager.class) { |
31,8 → 42,14 |
register(); |
} |
private Collection createdListeners = new ArrayList(); |
private Collection modifiedListeners = new ArrayList(); |
private Collection beforeDeleteListeners = new ArrayList(); |
private Collection deletedListeners = new ArrayList(); |
private MailAliasManager() |
{ |
UserManager.getInstance().addBeforeDeleteListener(this); |
} |
public MailAlias create(User editor) |
121,6 → 138,8 |
if(!mailAlias.editableBy(editor)) |
throw new ModelSecurityException(); |
boolean isNew = mailAlias.isNew(); |
//mailAlias.setModUser(editor); // FIXME |
try { |
130,14 → 149,90 |
{ |
throw new ModelException(ex); |
} |
// inform listeners |
if(isNew) { |
for(Iterator i = createdListeners.iterator(); i.hasNext(); ) { |
MailAliasCreatedListener listener = (MailAliasCreatedListener)i.next(); |
listener.mailAliasCreated(editor, mailAlias); |
} |
} |
else { |
MailAlias oldMailAlias = mailAlias.getOrigin(); |
if(oldMailAlias == null) oldMailAlias = mailAlias; |
for(Iterator i = modifiedListeners.iterator(); i.hasNext(); ) { |
MailAliasModifiedListener listener = (MailAliasModifiedListener)i.next(); |
listener.mailAliasModified(editor, mailAlias, oldMailAlias); |
} |
} |
} |
public void addCreatedListener(MailAliasCreatedListener listener) |
{ |
createdListeners.add(listener); |
} |
public void removeCreatedListener(MailAliasCreatedListener listener) |
{ |
createdListeners.remove(listener); |
} |
public void addModifiedListener(MailAliasModifiedListener listener) |
{ |
modifiedListeners.add(listener); |
} |
public void removeModifiedListener(MailAliasModifiedListener listener) |
{ |
modifiedListeners.remove(listener); |
} |
public void addBeforeDeleteListener(MailAliasBeforeDeleteListener listener) |
{ |
beforeDeleteListeners.add(listener); |
} |
public void removeBeforeDeleteListener(MailAliasBeforeDeleteListener listener) |
{ |
beforeDeleteListeners.remove(listener); |
} |
public void addDeletedListener(MailAliasDeletedListener listener) |
{ |
deletedListeners.add(listener); |
} |
public void removeDeletedListener(MailAliasDeletedListener listener) |
{ |
deletedListeners.remove(listener); |
} |
public Collection beforeDelete(User editor, MailAlias mailAlias, Collection known) |
throws ModelException |
{ |
Collection cascade = new ArrayList(); |
for(Iterator i = beforeDeleteListeners.iterator(); i.hasNext(); ) { |
MailAliasBeforeDeleteListener listener = (MailAliasBeforeDeleteListener)i.next(); |
Collection subcascade = listener.mailAliasBeforeDelete(editor, mailAlias, known); |
if(subcascade != null) |
cascade.addAll(subcascade); |
} |
return cascade; |
} |
public void delete(User editor, MailAlias mailAlias) |
throws ModelException |
{ |
// check rights |
if(!mailAlias.deleteableBy(editor)) |
throw new ModelSecurityException(); |
// backup copy |
MailAlias oldMailAlias = new MailAlias(mailAlias); |
// delete it |
try { |
HibernateUtil.currentSession().delete(mailAlias); |
} |
145,7 → 240,13 |
{ |
throw new ModelException(ex); |
} |
// inform listeners |
for(Iterator i = deletedListeners.iterator(); i.hasNext(); ) { |
MailAliasDeletedListener listener = (MailAliasDeletedListener)i.next(); |
listener.mailAliasDeleted(editor, oldMailAlias); |
} |
} |
public Collection listMailAliases(User editor) |
throws ModelException |
190,16 → 291,47 |
} |
} |
private static MailAliasManager mailAliasManager = null; |
public Collection userBeforeDelete(User editor, User user, Collection known) |
throws ModelException |
{ |
Collection mailAliases; |
public static MailAliasManager getInstance() |
try { |
mailAliases = HibernateUtil.currentSession().find( |
"from MailAlias where owner = ?", |
user, Hibernate.entity(User.class) ); |
} |
catch(HibernateException ex) |
{ |
if(mailAliasManager == null) |
mailAliasManager = new MailAliasManager(); |
throw new ModelException(ex); |
} |
return mailAliasManager; |
return iterateBeforeDelete(editor, mailAliases, known); |
} |
private Collection iterateBeforeDelete(User editor, Collection mailAliases, Collection known) |
throws ModelException |
{ |
Collection cascade = new ArrayList(); |
for(Iterator i = mailAliases.iterator(); i.hasNext(); ) { |
MailAlias mailAlias = (MailAlias)i.next(); |
if(mailAlias.viewableBy(editor)) { |
if(mailAlias.deleteableBy(editor)) |
cascade.add(new CascadeDeleteElement(mailAlias, CascadeDeleteElement.DELETE, |
this.beforeDelete(editor, mailAlias, known))); |
else |
cascade.add(new CascadeDeleteElement(mailAlias, CascadeDeleteElement.FORBIDDEN, |
null)); |
} |
else { |
cascade.add(new CascadeDeleteElement(MailAlias.createLimitedCopy(mailAlias), |
CascadeDeleteElement.FORBIDDEN, null)); |
} |
} |
return cascade; |
} |
public static final Comparator ADDRESS_COMPARATOR = new AddressComparator(); |
private static class AddressComparator |
/hostadmiral/trunk/src/ak/hostadmiral/core/model/MailboxDeletedListener.java |
---|
0,0 → 1,20 |
package ak.hostadmiral.core.model; |
import java.util.Collection; |
import ak.hostadmiral.util.ModelException; |
public interface MailboxDeletedListener |
{ |
/** |
* called if some mailbox is just deleted. |
* |
* @param editor who is doing the operation |
* @param mailbox the mailbox deleted |
* @throws ModelException in case of any *fatal* errors, |
* Note: throw it on fatal errors only, because database transaction |
* will be rolled back but any other MailboxDeletedListeners might be already called |
* and (possible) they will not restore their original state. |
*/ |
public void mailboxDeleted(User editor, Mailbox mailbox) |
throws ModelException; |
} |
/hostadmiral/trunk/src/ak/hostadmiral/core/model/MailboxCreatedListener.java |
---|
0,0 → 1,20 |
package ak.hostadmiral.core.model; |
import java.util.Collection; |
import ak.hostadmiral.util.ModelException; |
public interface MailboxCreatedListener |
{ |
/** |
* called if new mailbox is just created. |
* |
* @param editor who is doing the operation |
* @param mailbox the new mailbox |
* @throws ModelException in case of any *fatal* errors, |
* Note: throw it on fatal errors only, because database transaction |
* will be rolled back but any other MailboxCreatedListeners might be already called |
* and (possible) they will not restore their original state. |
*/ |
public void mailboxCreated(User editor, Mailbox mailbox) |
throws ModelException; |
} |
/hostadmiral/trunk/src/ak/hostadmiral/core/model/SystemUserModifiedListener.java |
---|
0,0 → 1,21 |
package ak.hostadmiral.core.model; |
import java.util.Collection; |
import ak.hostadmiral.util.ModelException; |
public interface SystemUserModifiedListener |
{ |
/** |
* called if some system user is just changed. |
* |
* @param editor who is doing the operation |
* @param systemUser the system user in its new state |
* @param oldSystemUser copy of system user as it was before the operation |
* @throws ModelException in case of any *fatal* errors, |
* Note: throw it on fatal errors only, because database transaction |
* will be rolled back but any other SystemUserCreatedListeners might be already called |
* and (possible) they will not restore their original state. |
*/ |
public void systemUserModified(User editor, SystemUser systemUser, SystemUser oldSystemUser) |
throws ModelException; |
} |
/hostadmiral/trunk/src/ak/hostadmiral/core/model/MailboxModifiedListener.java |
---|
0,0 → 1,21 |
package ak.hostadmiral.core.model; |
import java.util.Collection; |
import ak.hostadmiral.util.ModelException; |
public interface MailboxModifiedListener |
{ |
/** |
* called if some mailbox is just changed. |
* |
* @param editor who is doing the operation |
* @param mailbox the mailbox in its new state |
* @param oldMailbox copy of mailbox as it was before the operation |
* @throws ModelException in case of any *fatal* errors, |
* Note: throw it on fatal errors only, because database transaction |
* will be rolled back but any other MailboxCreatedListeners might be already called |
* and (possible) they will not restore their original state. |
*/ |
public void mailboxModified(User editor, Mailbox mailbox, Mailbox oldMailbox) |
throws ModelException; |
} |
/hostadmiral/trunk/src/ak/hostadmiral/core/model/MailAliasModifiedListener.java |
---|
0,0 → 1,21 |
package ak.hostadmiral.core.model; |
import java.util.Collection; |
import ak.hostadmiral.util.ModelException; |
public interface MailAliasModifiedListener |
{ |
/** |
* called if some mail alias is just changed. |
* |
* @param editor who is doing the operation |
* @param mailAlias the mail alias in its new state |
* @param oldMailAlias copy of mail alias as it was before the operation |
* @throws ModelException in case of any *fatal* errors, |
* Note: throw it on fatal errors only, because database transaction |
* will be rolled back but any other MailAliasCreatedListeners might be already called |
* and (possible) they will not restore their original state. |
*/ |
public void mailAliasModified(User editor, MailAlias mailAlias, MailAlias oldMailAlias) |
throws ModelException; |
} |
/hostadmiral/trunk/src/ak/hostadmiral/core/model/SystemUserManager.java |
---|
41,7 → 41,10 |
register(); |
} |
private Collection createdListeners = new ArrayList(); |
private Collection modifiedListeners = new ArrayList(); |
private Collection beforeDeleteListeners = new ArrayList(); |
private Collection deletedListeners = new ArrayList(); |
private SystemUserManager() |
{ |
167,6 → 170,8 |
if(!systemUser.editableBy(editor)) |
throw new ModelSecurityException(); |
boolean isNew = systemUser.isNew(); |
//systemUser.setModUser(editor); // FIXME |
try { |
176,8 → 181,44 |
{ |
throw new ModelException(ex); |
} |
// inform listeners |
if(isNew) { |
for(Iterator i = createdListeners.iterator(); i.hasNext(); ) { |
SystemUserCreatedListener listener = (SystemUserCreatedListener)i.next(); |
listener.systemUserCreated(editor, systemUser); |
} |
} |
else { |
SystemUser oldSystemUser = systemUser.getOrigin(); |
if(oldSystemUser == null) oldSystemUser = systemUser; |
for(Iterator i = modifiedListeners.iterator(); i.hasNext(); ) { |
SystemUserModifiedListener listener = (SystemUserModifiedListener)i.next(); |
listener.systemUserModified(editor, systemUser, oldSystemUser); |
} |
} |
} |
public void addCreatedListener(SystemUserCreatedListener listener) |
{ |
createdListeners.add(listener); |
} |
public void removeCreatedListener(SystemUserCreatedListener listener) |
{ |
createdListeners.remove(listener); |
} |
public void addModifiedListener(SystemUserModifiedListener listener) |
{ |
modifiedListeners.add(listener); |
} |
public void removeModifiedListener(SystemUserModifiedListener listener) |
{ |
modifiedListeners.remove(listener); |
} |
public void addBeforeDeleteListener(SystemUserBeforeDeleteListener listener) |
{ |
beforeDeleteListeners.add(listener); |
188,6 → 229,16 |
beforeDeleteListeners.remove(listener); |
} |
public void addDeletedListener(SystemUserDeletedListener listener) |
{ |
deletedListeners.add(listener); |
} |
public void removeDeletedListener(SystemUserDeletedListener listener) |
{ |
deletedListeners.remove(listener); |
} |
public Collection beforeDelete(User editor, SystemUser user, Collection known) |
throws ModelException |
{ |
206,9 → 257,14 |
public void delete(User editor, SystemUser systemUser) |
throws ModelException |
{ |
// check rights |
if(!systemUser.deleteableBy(editor)) |
throw new ModelSecurityException(); |
// backup copy |
SystemUser oldSystemUser = new SystemUser(systemUser); |
// delete it |
try { |
HibernateUtil.currentSession().delete(systemUser); |
} |
216,7 → 272,13 |
{ |
throw new ModelException(ex); |
} |
// inform listeners |
for(Iterator i = deletedListeners.iterator(); i.hasNext(); ) { |
SystemUserDeletedListener listener = (SystemUserDeletedListener)i.next(); |
listener.systemUserDeleted(editor, oldSystemUser); |
} |
} |
public Collection listSystemUsers(User editor) |
throws ModelException |
/hostadmiral/trunk/src/ak/hostadmiral/core/model/SystemUser.java |
---|
14,11 → 14,31 |
private Integer uid; |
private String name; |
private User owner; |
private SystemUser origin; // save original object state before any changes |
protected SystemUser() |
{ |
} |
protected SystemUser(SystemUser origin) |
{ |
super(origin); |
this.uid = origin.uid; |
this.name = origin.name; |
this.owner = origin.owner; |
} |
protected SystemUser getOrigin() |
{ |
return origin; |
} |
protected void backupMe() |
{ |
if(origin == null) |
origin = new SystemUser(this); |
} |
/** |
* |
* @hibernate.property |
/hostadmiral/trunk/src/ak/hostadmiral/core/model/InetDomainDeletedListener.java |
---|
0,0 → 1,20 |
package ak.hostadmiral.core.model; |
import java.util.Collection; |
import ak.hostadmiral.util.ModelException; |
public interface InetDomainDeletedListener |
{ |
/** |
* called if some domain is just deleted. |
* |
* @param editor who is doing the operation |
* @param domain the domain deleted |
* @throws ModelException in case of any *fatal* errors, |
* Note: throw it on fatal errors only, because database transaction |
* will be rolled back but any other InetDomainDeletedListeners might be already called |
* and (possible) they will not restore their original state. |
*/ |
public void inetDomainDeleted(User editor, InetDomain domain) |
throws ModelException; |
} |
/hostadmiral/trunk/src/ak/hostadmiral/core/model/InetDomainCreatedListener.java |
---|
0,0 → 1,20 |
package ak.hostadmiral.core.model; |
import java.util.Collection; |
import ak.hostadmiral.util.ModelException; |
public interface InetDomainCreatedListener |
{ |
/** |
* called if new domain is just created. |
* |
* @param editor who is doing the operation |
* @param domain the new domain |
* @throws ModelException in case of any *fatal* errors, |
* Note: throw it on fatal errors only, because database transaction |
* will be rolled back but any other InetDomainCreatedListeners might be already called |
* and (possible) they will not restore their original state. |
*/ |
public void inetDomainCreated(User editor, InetDomain domain) |
throws ModelException; |
} |
/hostadmiral/trunk/src/ak/hostadmiral/core/model/MailboxManager.java |
---|
44,7 → 44,10 |
register(); |
} |
private Collection createdListeners = new ArrayList(); |
private Collection modifiedListeners = new ArrayList(); |
private Collection beforeDeleteListeners = new ArrayList(); |
private Collection deletedListeners = new ArrayList(); |
private MailboxManager() |
{ |
137,6 → 140,8 |
if(!mailbox.editableBy(editor)) |
throw new ModelSecurityException(); |
boolean isNew = mailbox.isNew(); |
//mailbox.setModUser(editor); // FIXME |
try { |
146,8 → 151,44 |
{ |
throw new ModelException(ex); |
} |
// inform listeners |
if(isNew) { |
for(Iterator i = createdListeners.iterator(); i.hasNext(); ) { |
MailboxCreatedListener listener = (MailboxCreatedListener)i.next(); |
listener.mailboxCreated(editor, mailbox); |
} |
} |
else { |
Mailbox oldMailbox = mailbox.getOrigin(); |
if(oldMailbox == null) oldMailbox = mailbox; |
for(Iterator i = modifiedListeners.iterator(); i.hasNext(); ) { |
MailboxModifiedListener listener = (MailboxModifiedListener)i.next(); |
listener.mailboxModified(editor, mailbox, oldMailbox); |
} |
} |
} |
public void addCreatedListener(MailboxCreatedListener listener) |
{ |
createdListeners.add(listener); |
} |
public void removeCreatedListener(MailboxCreatedListener listener) |
{ |
createdListeners.remove(listener); |
} |
public void addModifiedListener(MailboxModifiedListener listener) |
{ |
modifiedListeners.add(listener); |
} |
public void removeModifiedListener(MailboxModifiedListener listener) |
{ |
modifiedListeners.remove(listener); |
} |
public void addBeforeDeleteListener(MailboxBeforeDeleteListener listener) |
{ |
beforeDeleteListeners.add(listener); |
158,6 → 199,16 |
beforeDeleteListeners.remove(listener); |
} |
public void addDeletedListener(MailboxDeletedListener listener) |
{ |
deletedListeners.add(listener); |
} |
public void removeDeletedListener(MailboxDeletedListener listener) |
{ |
deletedListeners.remove(listener); |
} |
public Collection beforeDelete(User editor, Mailbox mailbox, Collection known) |
throws ModelException |
{ |
176,9 → 227,14 |
public void delete(User editor, Mailbox mailbox) |
throws ModelException |
{ |
// check rights |
if(!mailbox.deleteableBy(editor)) |
throw new ModelSecurityException(); |
// backup copy |
Mailbox oldMailbox = new Mailbox(mailbox); |
// delete it |
try { |
HibernateUtil.currentSession().delete(mailbox); |
} |
186,7 → 242,13 |
{ |
throw new ModelException(ex); |
} |
// inform listeners |
for(Iterator i = deletedListeners.iterator(); i.hasNext(); ) { |
MailboxDeletedListener listener = (MailboxDeletedListener)i.next(); |
listener.mailboxDeleted(editor, oldMailbox); |
} |
} |
public Collection listMailboxes(User editor) |
throws ModelException |
/hostadmiral/trunk/src/ak/hostadmiral/core/model/MailAliasDestinationManager.java |
---|
8,6 → 8,9 |
public class MailAliasDestinationManager |
{ |
// FIXME create, delete and modify listeners are not implemented, bacause |
// all operations are done via MailAliasManager. Do we need them? |
private static boolean registered = false; |
protected static void register() |
{ |
/hostadmiral/trunk/src/ak/hostadmiral/core/model/MailAliasDeletedListener.java |
---|
0,0 → 1,20 |
package ak.hostadmiral.core.model; |
import java.util.Collection; |
import ak.hostadmiral.util.ModelException; |
public interface MailAliasDeletedListener |
{ |
/** |
* called if some mail alias is just deleted. |
* |
* @param editor who is doing the operation |
* @param mailAlias the mail alias deleted |
* @throws ModelException in case of any *fatal* errors, |
* Note: throw it on fatal errors only, because database transaction |
* will be rolled back but any other MailAliasDeletedListeners might be already called |
* and (possible) they will not restore their original state. |
*/ |
public void mailAliasDeleted(User editor, MailAlias mailAlias) |
throws ModelException; |
} |
/hostadmiral/trunk/src/ak/hostadmiral/core/model/MailAliasCreatedListener.java |
---|
0,0 → 1,20 |
package ak.hostadmiral.core.model; |
import java.util.Collection; |
import ak.hostadmiral.util.ModelException; |
public interface MailAliasCreatedListener |
{ |
/** |
* called if new mail alias is just created. |
* |
* @param editor who is doing the operation |
* @param mailAlias the new mail alias |
* @throws ModelException in case of any *fatal* errors, |
* Note: throw it on fatal errors only, because database transaction |
* will be rolled back but any other MailAliasCreatedListeners might be already called |
* and (possible) they will not restore their original state. |
*/ |
public void mailAliasCreated(User editor, MailAlias mailAlias) |
throws ModelException; |
} |
/hostadmiral/trunk/src/ak/hostadmiral/core/model/Mailbox.java |
---|
18,11 → 18,35 |
private Boolean virusCheck; |
private Boolean spamCheck; |
private SystemUser systemUser; |
private Mailbox origin; // save original object state before any changes |
protected Mailbox() |
{ |
} |
protected Mailbox(Mailbox origin) |
{ |
super(origin); |
this.login = origin.login; |
this.password = origin.password; |
this.domain = origin.domain; |
this.owner = origin.owner; |
this.virusCheck = origin.virusCheck; |
this.spamCheck = origin.spamCheck; |
this.systemUser = origin.systemUser; |
} |
protected Mailbox getOrigin() |
{ |
return origin; |
} |
protected void backupMe() |
{ |
if(origin == null) |
origin = new Mailbox(this); |
} |
/** |
* |
* @hibernate.property |
43,6 → 67,7 |
if(!editableBy(editor)) |
throw new ModelSecurityException(); |
backupMe(); |
this.login = login; |
} |
66,6 → 91,7 |
if(password == null) |
throw new NullPointerException("Null password"); |
backupMe(); |
this.password = Digest.encode(password); |
} |
89,6 → 115,7 |
if(!editableBy(editor)) |
throw new ModelSecurityException(); |
backupMe(); |
this.domain = domain; |
} |
112,6 → 139,7 |
if(!editableBy(editor)) |
throw new ModelSecurityException(); |
backupMe(); |
this.owner = owner; |
} |
135,6 → 163,7 |
if(!editableBy(editor)) |
throw new ModelSecurityException(); |
backupMe(); |
this.virusCheck = virusCheck; |
} |
158,6 → 187,7 |
if(!editableBy(editor)) |
throw new ModelSecurityException(); |
backupMe(); |
this.spamCheck = spamCheck; |
} |
181,6 → 211,7 |
if(!editableBy(editor)) |
throw new ModelSecurityException(); |
backupMe(); |
this.systemUser = systemUser; |
} |
225,9 → 256,10 |
protected static Mailbox createLimitedCopy(Mailbox origin) |
{ |
Mailbox u = new Mailbox(); |
u.setLogin(origin.getLogin()); |
u.setDomain(origin.getDomain()); |
return u; |
Mailbox m = new Mailbox(); |
m.setLogin(origin.getLogin()); |
m.setDomain(origin.getDomain()); |
m.setOwner(origin.getOwner()); |
return m; |
} |
} |
/hostadmiral/trunk/src/ak/hostadmiral/core/model/MailAlias.java |
---|
15,11 → 15,32 |
private InetDomain domain; |
private User owner; |
private Collection destinations; // Collection(MailAliasDestintion) |
private MailAlias origin; // save original object state before any changes |
protected MailAlias() |
{ |
} |
protected MailAlias(MailAlias origin) |
{ |
super(origin); |
this.address = origin.address; |
this.domain = origin.domain; |
this.owner = origin.owner; |
this.destinations = origin.destinations; // FIXME: or make a copy? |
} |
protected MailAlias getOrigin() |
{ |
return origin; |
} |
protected void backupMe() |
{ |
if(origin == null) |
origin = new MailAlias(this); |
} |
/** |
* |
* @hibernate.property |
166,4 → 187,13 |
return editor.isSuperuser() |
|| InetDomainManager.getInstance().areInetDomainsAvailable(editor); |
} |
protected static MailAlias createLimitedCopy(MailAlias origin) |
{ |
MailAlias m = new MailAlias(); |
m.setAddress(origin.getAddress()); |
m.setDomain(origin.getDomain()); |
m.setOwner(origin.getOwner()); |
return m; |
} |
} |