/hostadmiral/trunk/src/ak/hostadmiral/util/ModelUserException.java |
---|
File deleted |
/hostadmiral/trunk/src/ak/hostadmiral/core/model/UserValidator.java |
---|
File deleted |
/hostadmiral/trunk/src/ak/hostadmiral/core/model/UserValidatorAtDomain.java |
---|
File deleted |
/hostadmiral/trunk/src/ak/hostadmiral/core/model/store/hibernate/MailboxHibernate.java |
---|
193,18 → 193,12 |
throws ModelStoreException |
{ |
try { |
List countlist = HibernateUtil.sqlQuery( |
"select count(*) from (" |
+ " select mb.id from mailboxes mb" |
+ " where mb.owner=?" |
+ " union" |
+ " select mb.id from mailboxes mb" |
+ " left join domains as d on mb.domain = d.id" |
+ " where d.owner=?" |
+ ") as count_table", |
new Object[] { user.getId(), user.getId() }); |
return ((Long)countlist.get(0)).intValue(); |
return ((Integer)HibernateUtil.currentSession().iterate( |
"select count(*) from Mailbox mb left join mb.domain as d" |
+ " where d.owner=? or mb.owner=?", |
new Object[] { user, user }, |
new Type[] { Hibernate.entity(User.class), Hibernate.entity(User.class) }) |
.next()).intValue(); |
} |
catch(HibernateException ex) |
{ |
/hostadmiral/trunk/src/ak/hostadmiral/core/model/store/hibernate/MailAliasHibernate.java |
---|
178,18 → 178,12 |
throws ModelStoreException |
{ |
try { |
List countlist = HibernateUtil.sqlQuery( |
"select count(*) from (" |
+ " select a.id from mailaliases a" |
+ " where a.owner=?" |
+ " union" |
+ " select a.id from mailaliases a" |
+ " left join domains as d on a.domain = d.id" |
+ " where d.owner=?" |
+ ") as count_table", |
new Object[] { user.getId(), user.getId() }); |
return ((Long)countlist.get(0)).intValue(); |
return ((Integer)HibernateUtil.currentSession().iterate( |
"select count(*) from MailAlias a left join a.domain as d" |
+ " where d.owner=? or a.owner=?", |
new Object[] { user, user }, |
new Type[] { Hibernate.entity(User.class), Hibernate.entity(User.class) }) |
.next()).intValue(); |
} |
catch(HibernateException ex) |
{ |
/hostadmiral/trunk/src/ak/hostadmiral/core/model/UserManager.java |
---|
20,8 → 20,7 |
UserBeforeDeleteListener, |
UserDeletingListener |
{ |
private UserStore store; |
private UserValidator userValidator; |
private UserStore store; |
private Collection createdListeners = new ArrayList(); |
private Collection modifiedListeners = new ArrayList(); |
100,9 → 99,6 |
throw new ModelSecurityException(); |
} |
if(userValidator != null) |
userValidator.validateUser(editor, user); |
boolean isNew = user.isNew(); |
//user.setModUser(editor); // FIXME: disabled because hb throws exception |
379,12 → 375,6 |
Class c = Class.forName((String)params.get("store")); |
store = (UserStore)c.newInstance(); |
String userValidatorName = (String)params.get("userValidator"); |
if(userValidatorName != null) { |
Class c2 = Class.forName(userValidatorName); |
userValidator = (UserValidator)c2.newInstance(); |
} |
} |
catch(Exception ex) { |
throw new ModelException(ex); |
/hostadmiral/trunk/src/ak/hostadmiral/core/action/GeneralExceptionHandler.java |
---|
File deleted |
/hostadmiral/trunk/src/ak/hostadmiral/core/action/UserExceptionHandler.java |
---|
0,0 → 1,62 |
package ak.hostadmiral.core.action; |
import javax.servlet.ServletException; |
import javax.servlet.http.HttpServletRequest; |
import javax.servlet.http.HttpServletResponse; |
import org.apache.struts.Globals; |
import org.apache.struts.action.ActionError; |
import org.apache.struts.action.ActionErrors; |
import org.apache.struts.action.ActionMessages; |
import org.apache.struts.action.ExceptionHandler; |
import org.apache.struts.action.ActionMapping; |
import org.apache.struts.action.ActionForm; |
import org.apache.struts.action.ActionForward; |
import org.apache.struts.config.ExceptionConfig; |
import org.apache.log4j.Logger; |
import ak.strutsx.ErrorHandlerX; |
import ak.hostadmiral.util.UserException; |
import ak.hostadmiral.util.FormException; |
public final class UserExceptionHandler |
extends ExceptionHandler |
{ |
private static final Logger logger = Logger.getLogger(UserExceptionHandler.class); |
public ActionForward execute(Exception ex, ExceptionConfig config, |
ActionMapping mapping, ActionForm formInstance, |
HttpServletRequest request, HttpServletResponse response) |
throws ServletException |
{ |
if(!(ex instanceof UserException)) |
throw new ServletException("Unknown type of exception: " + ex.getClass()); |
UserException userEx = (UserException)ex; |
logger.info("begin exception handle:" + userEx.getMessage()); |
// try to get property for this exception if any |
String property = ActionMessages.GLOBAL_MESSAGE; |
if(userEx instanceof FormException) { |
FormException formEx = (FormException)userEx; |
if(formEx.getProperty() != null) |
property = formEx.getProperty(); |
} |
// create new error message |
ActionErrors errors = (ActionErrors)request.getAttribute(Globals.ERROR_KEY); |
if(errors == null) { |
errors = new ActionErrors(); |
request.setAttribute(Globals.ERROR_KEY, errors); |
} |
errors.add(property, new ActionError(userEx.getMessage(), userEx.getValues())); |
// find forward |
if(mapping.getInput() == null) |
return mapping.findForward("error"); |
else |
return mapping.getInputForward(); |
} |
} |
/hostadmiral/trunk/src/ak/hostadmiral/core/CoreResources.properties |
---|
69,11 → 69,6 |
ak.hostadmiral.page.generalError.index=start page |
ak.hostadmiral.page.generalError.back=back |
ak.hostadmiral.page.accessDenied.title=Host Admiral - access denied |
ak.hostadmiral.page.accessDenied.message=You have no permission to execute requested action. |
ak.hostadmiral.page.accessDenied.index=start page |
ak.hostadmiral.page.accessDenied.back=back |
ak.hostadmiral.page.index.title=Host Admiral |
ak.hostadmiral.page.index.password_change=change password |
ak.hostadmiral.page.index.user_list=users |
353,6 → 348,4 |
ak.hostadmiral.page.mail.alias.view.external=external redirect |
ak.hostadmiral.page.mail.alias.view.back=back |
ak.hostadmiral.core.uservalidator.atdomain.login.wrong=User login must end with name of your domain, e.g. me@example.com |
org.apache.struts.taglib.bean.format.sql.timestamp=dd-MM-yyyy HH:mm:ss.SSS |