Subversion Repositories general

Compare Revisions

Ignore whitespace Rev 1015 → Rev 1016

/hostadmiral/trunk/src/ak/hostadmiral/core/model/InetDomainManager.java
267,10 → 267,12
{
try {
if(editor.isSuperuser())
return HibernateUtil.currentSession().find("from InetDomain");
return HibernateUtil.currentSession().find(
"select d from InetDomain d left join fetch d.owner");
else
return HibernateUtil.currentSession().find(
"from InetDomain where owner=?", editor, Hibernate.entity(User.class));
"select d from InetDomain d left join fetch d.owner where d.owner=?",
editor, Hibernate.entity(User.class));
}
catch(HibernateException ex)
{
/hostadmiral/trunk/src/ak/hostadmiral/core/model/MailboxManager.java
3,6 → 3,7
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;
282,13 → 283,22
{
try {
if(editor.isSuperuser())
return HibernateUtil.currentSession().find("from Mailbox");
return HibernateUtil.currentSession().find(
"select mb from Mailbox mb left join fetch mb.domain as d"
+ " left join fetch mb.owner");
else
return HibernateUtil.currentSession().find(
"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) } );
// 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) } ));
}
catch(HibernateException ex)
{
/hostadmiral/trunk/src/ak/hostadmiral/core/model/MailAliasManager.java
3,6 → 3,7
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;
276,11 → 277,17
if(editor.isSuperuser())
return HibernateUtil.currentSession().find("from MailAlias");
else
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) } );
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) } ));
}
catch(HibernateException ex)
{
/hostadmiral/trunk/src/ak/hostadmiral/core/model/Mailbox.java
106,7 → 106,7
 
/**
*
* @hibernate.set cascade="all"
* @hibernate.set cascade="all" lazy="true"
* @hibernate.collection-key column="obj"
* @hibernate.collection-one-to-many class="ak.hostadmiral.core.model.PasswordStoreAbstract"
*/
/hostadmiral/trunk/src/ak/hostadmiral/core/model/MailAlias.java
113,7 → 113,7
/**
* @return Collection(MailAliasDestination)
*
* @hibernate.bag inverse="true" cascade="all-delete-orphan"
* @hibernate.bag inverse="true" cascade="all-delete-orphan" lazy="true"
* @hibernate.collection-key column="alias"
* @hibernate.collection-one-to-many class="ak.hostadmiral.core.model.MailAliasDestination"
*/
/hostadmiral/trunk/src/ak/hostadmiral/core/model/User.java
152,7 → 152,7
 
/**
*
* @hibernate.set cascade="all"
* @hibernate.set cascade="all" lazy="true"
* @hibernate.collection-key column="obj"
* @hibernate.collection-one-to-many class="ak.hostadmiral.core.model.PasswordStoreAbstract"
*/
/hostadmiral/trunk/sql/00.tables.sql
28,6 → 28,7
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
51,6 → 52,7
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
65,6 → 67,7
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');
89,6 → 92,7
constraint systemusers_name unique(name),
constraint systemusers_owner foreign key (owner) references users(id)
);
create index systemusers_owner on systemusers (owner);
 
create table domains
(
104,6 → 108,7
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
128,6 → 133,8
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
146,6 → 153,8
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
(
163,3 → 172,5
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);