context.login();
// if no exception thrown, login was successful
SessionManager.createSession( context.getSubject() );
IMailbox mailbox = SessionManager.get().getMailbox();
UserAccount account = this.userAccountDao.getUserAccountByUsername( username );
// create useraccount
if ( account == null ) {
account = createUserAccount( mailbox );
if ( getThreadLocalRequest().getLocale() != null ) {
String lang = getThreadLocalRequest().getLocale().getLanguage();
account.getPreferences().setLanguage( lang );
}
}
else {
if ( account.getIdentities() == null || account.getIdentities().size() == 0 ) {
account.addIdentity( createDefaultIdentity( mailbox ) );
}
account.setLastLogin( new Date() );
this.userAccountDao.saveUserAccount( account );
}
mailbox.setUserAccount( account );
GWTMailbox gwtMailbox = ConvertUtil.convert( mailbox );
return gwtMailbox;
}
catch (LoginException e) {