Warning: Attempt to read property "date" on null in /home/www/websvn.26th.net/html/blame.php on line 247

Warning: Attempt to read property "msg" on null in /home/www/websvn.26th.net/html/blame.php on line 247

Deprecated: preg_replace(): Passing null to parameter #3 ($subject) of type array|string is deprecated in /home/www/websvn.26th.net/html/blame.php on line 247
WebSVN – general – Blame – /hostadmiral/trunk/src/ak/hostadmiral/core/model/MailAliasDestinationManager.java/ – Rev 899

Subversion Repositories general

Rev

Go to most recent revision | Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
899 dev 1
package ak.webcontrol.core.model;
2
 
3
import java.util.*;
4
import net.sf.hibernate.*;
5
import ak.webcontrol.util.HibernateUtil;
6
import ak.webcontrol.util.ModelException;
7
 
8
public class MailAliasDestinationManager
9
{
10
	private static boolean registered = false;
11
	protected static void register()
12
	{
13
		synchronized(MailAliasDestinationManager.class) {
14
			if(registered) return;
15
 
16
			registered = true;
17
			try {
18
				HibernateUtil.getConfiguration().addResource(
19
					"/ak/webcontrol/core/model/MailAliasDestination.hbm.xml");
20
			}
21
			catch(Exception ex) {
22
				ex.printStackTrace();
23
				throw new RuntimeException(ex.getMessage());
24
			}
25
		}
26
	}
27
 
28
	static {
29
		register();
30
	}
31
 
32
	private MailAliasDestinationManager()
33
	{
34
	}
35
 
36
	public MailAliasDestination create()
37
	{
38
		return new MailAliasDestination();
39
	}
40
 
41
	public MailAliasDestination get(Long id)
42
		throws ModelException
43
	{
44
		try {
45
			return (MailAliasDestination)HibernateUtil.currentSession()
46
				.load(MailAliasDestination.class, id);
47
		}
48
		catch(HibernateException ex)
49
		{
50
			throw new ModelException(ex);
51
		}
52
	}
53
 
54
	public void save(MailAliasDestination mailAliasDestination)
55
		throws ModelException
56
	{
57
		try {
58
			HibernateUtil.currentSession().saveOrUpdate(mailAliasDestination);
59
		}
60
		catch(HibernateException ex)
61
		{
62
			throw new ModelException(ex);
63
		}
64
	}
65
 
66
	public void delete(MailAliasDestination mailAliasDestination)
67
		throws ModelException
68
	{
69
		try {
70
			HibernateUtil.currentSession().delete(mailAliasDestination);
71
		}
72
		catch(HibernateException ex)
73
		{
74
			throw new ModelException(ex);
75
		}
76
	}
77
 
78
	public Collection listMailAliasesDestination()
79
	{
80
		return null;
81
	}
82
 
83
	public Collection listMailAliasesDestination(MailAlias alias)
84
		throws ModelException
85
	{
86
		try {
87
			return HibernateUtil.currentSession().find(
88
				"from MailAliasDestination where alias=?",
89
				alias, Hibernate.entity(MailAlias.class));
90
		}
91
		catch(HibernateException ex)
92
		{
93
			throw new ModelException(ex);
94
		}
95
	}
96
 
97
	private static MailAliasDestinationManager mailAliasDestinationManager = null;
98
 
99
	public static MailAliasDestinationManager getInstance()
100
	{
101
		if(mailAliasDestinationManager == null)
102
			mailAliasDestinationManager = new MailAliasDestinationManager();
103
 
104
		return mailAliasDestinationManager;
105
	}
106
 
107
	public static final Comparator EMAIL_COMPARATOR = new EmailComparator();
108
 
109
	private static class EmailComparator
110
		implements Comparator
111
	{
112
		public int compare(Object o1, Object o2)
113
		{
114
			if(!(o1 instanceof MailAliasDestination) || !(o2 instanceof MailAliasDestination))
115
				throw new ClassCastException("not a MailAliasDestination");
116
 
117
		    MailAliasDestination a1 = (MailAliasDestination)o1;
118
		    MailAliasDestination a2 = (MailAliasDestination)o2;
119
 
120
		    if(a1 == null && a2 == null)
121
		    	return 0;
122
		    else if(a1 == null && a2 != null)
123
		    	return -1;
124
		    else if(a1 != null && a2 == null)
125
		    	return 1;
126
		    else
127
		    	return a1.getEmail().compareToIgnoreCase(a2.getEmail());
128
		}
129
 
130
		public boolean equals(Object obj)
131
		{
132
			return (obj instanceof EmailComparator);
133
		}
134
	}
135
}