/hostadmiral/trunk/src/ak/hostadmiral/core/model/Mailbox.java |
---|
106,7 → 106,7 |
/** |
* |
* @hibernate.set cascade="all" lazy="true" |
* @hibernate.set cascade="all" |
* @hibernate.collection-key column="obj" |
* @hibernate.collection-one-to-many class="ak.hostadmiral.core.model.PasswordStoreAbstract" |
*/ |
/hostadmiral/trunk/src/ak/hostadmiral/core/model/User.java |
---|
152,7 → 152,7 |
/** |
* |
* @hibernate.set cascade="all" lazy="true" |
* @hibernate.set cascade="all" |
* @hibernate.collection-key column="obj" |
* @hibernate.collection-one-to-many class="ak.hostadmiral.core.model.PasswordStoreAbstract" |
*/ |
/hostadmiral/trunk/src/ak/hostadmiral/core/model/MailboxManager.java |
---|
3,7 → 3,6 |
import java.util.*; |
import net.sf.hibernate.*; |
import net.sf.hibernate.type.Type; |
import ak.hostadmiral.util.CollectionUtils; |
import ak.hostadmiral.util.HibernateUtil; |
import ak.hostadmiral.util.ModelException; |
import ak.hostadmiral.util.ModelSecurityException; |
283,22 → 282,13 |
{ |
try { |
if(editor.isSuperuser()) |
return HibernateUtil.currentSession().find("from Mailbox"); |
else |
return HibernateUtil.currentSession().find( |
"select mb from Mailbox mb left join fetch mb.domain as d" |
+ " left join fetch mb.owner"); |
else |
// FIXME: any problems for big lists or by pages? |
return CollectionUtils.addUnique( |
HibernateUtil.currentSession().find( |
"select mb from Mailbox mb left join fetch mb.domain as d" |
+ " left join fetch mb.owner" |
+ " where mb.owner=?", |
new Object[] { editor }, new Type[] { Hibernate.entity(User.class) } ), |
HibernateUtil.currentSession().find( |
" select mb from Mailbox mb left join fetch mb.domain as d" |
+ " left join fetch mb.owner" |
+ " where d.owner=?", |
new Object[] { editor }, new Type[] { Hibernate.entity(User.class) } )); |
"select mb from Mailbox mb left join mb.domain as d" |
+ " where d.owner=? or mb.owner=?", |
new Object[] { editor, editor }, |
new Type[] { Hibernate.entity(User.class), Hibernate.entity(User.class) } ); |
} |
catch(HibernateException ex) |
{ |
/hostadmiral/trunk/src/ak/hostadmiral/core/model/InetDomainManager.java |
---|
267,12 → 267,10 |
{ |
try { |
if(editor.isSuperuser()) |
return HibernateUtil.currentSession().find( |
"select d from InetDomain d left join fetch d.owner"); |
return HibernateUtil.currentSession().find("from InetDomain"); |
else |
return HibernateUtil.currentSession().find( |
"select d from InetDomain d left join fetch d.owner where d.owner=?", |
editor, Hibernate.entity(User.class)); |
"from InetDomain where owner=?", editor, Hibernate.entity(User.class)); |
} |
catch(HibernateException ex) |
{ |
/hostadmiral/trunk/src/ak/hostadmiral/core/model/MailAliasManager.java |
---|
3,7 → 3,6 |
import java.util.*; |
import net.sf.hibernate.*; |
import net.sf.hibernate.type.Type; |
import ak.hostadmiral.util.CollectionUtils; |
import ak.hostadmiral.util.HibernateUtil; |
import ak.hostadmiral.util.ModelException; |
import ak.hostadmiral.util.ModelSecurityException; |
277,17 → 276,11 |
if(editor.isSuperuser()) |
return HibernateUtil.currentSession().find("from MailAlias"); |
else |
return CollectionUtils.addUnique( |
HibernateUtil.currentSession().find( |
"select a from MailAlias a left join fetch a.domain as d" |
+ " left join fetch a.owner" |
+ " where d.owner=?", |
new Object[] { editor }, new Type[] { Hibernate.entity(User.class) } ), |
HibernateUtil.currentSession().find( |
"select a from MailAlias a left join fetch a.domain as d" |
+ " left join fetch a.owner" |
+ " where a.owner=?", |
new Object[] { editor }, new Type[] { Hibernate.entity(User.class) } )); |
return HibernateUtil.currentSession().find( |
"select a from MailAlias a left join a.domain as d" |
+ " where d.owner=? or a.owner=?", |
new Object[] { editor, editor }, |
new Type[] { Hibernate.entity(User.class), Hibernate.entity(User.class) } ); |
} |
catch(HibernateException ex) |
{ |
/hostadmiral/trunk/src/ak/hostadmiral/core/model/MailAlias.java |
---|
113,7 → 113,7 |
/** |
* @return Collection(MailAliasDestination) |
* |
* @hibernate.bag inverse="true" cascade="all-delete-orphan" lazy="true" |
* @hibernate.bag inverse="true" cascade="all-delete-orphan" |
* @hibernate.collection-key column="alias" |
* @hibernate.collection-one-to-many class="ak.hostadmiral.core.model.MailAliasDestination" |
*/ |
/hostadmiral/trunk/sql/00.tables.sql |
---|
28,7 → 28,6 |
constraint passwords_prim primary key (id), |
constraint passwords_unique unique(obj, digest) |
); |
create index passwords_obj on passwords (obj); |
-- an user is allowed to: |
-- see/use an user if he is the 'boss' or is the same user |
52,7 → 51,6 |
constraint users_login unique(login), |
constraint users_boss foreign key (boss) references users(id) |
); |
create index users_boss on users (boss); |
-- login tries. "usr" is set if the user is found only |
create table userlogins |
67,7 → 65,6 |
constraint userlogins_prim primary key (id), |
constraint userlogins_user foreign key (usr) references users(id) |
); |
create index userlogins_usrs on userlogins (usr); |
-- default user admin:admin |
insert into users (id, login, superuser) values (1, 'admin', '1'); |
92,7 → 89,6 |
constraint systemusers_name unique(name), |
constraint systemusers_owner foreign key (owner) references users(id) |
); |
create index systemusers_owner on systemusers (owner); |
create table domains |
( |
108,7 → 104,6 |
constraint domains_name unique(name), |
constraint domains_owner foreign key (owner) references users(id) |
); |
create index domains_owner on domains (owner); |
-- name of mailbox = login + '@' + domain, e.g. user@example.com |
-- if mailbox has no corresponding password entries, then owner's password is used |
133,8 → 128,6 |
constraint mailboxes_owner foreign key (owner) references users(id), |
constraint mailboxes_systemuser foreign key (systemuser) references systemusers(id) |
); |
create index mailboxes_domain on mailboxes (domain); |
create index mailboxes_owner on mailboxes (owner); |
-- email address of alias = address + '@' + domain, e.g. user@example.com |
create table mailaliases |
153,8 → 146,6 |
constraint mailaliases_domain foreign key (domain) references domains(id), |
constraint mailaliases_owner foreign key (owner) references users(id) |
); |
create index mailaliases_domain on mailaliases (domain); |
create index mailaliases_owner on mailaliases (owner); |
create table mailaliasdests |
( |
172,5 → 163,3 |
constraint mailaliasdests_mailbox foreign key (mailbox) references mailboxes(id), |
constraint mailaliasdests_email check ((email isnull) or (char_length(email) > 0)) |
); |
create index mailaliasdests_alias on mailaliasdests (alias); |
create index mailaliasdests_mailbox on mailaliasdests (mailbox); |