diff --git a/src/main/java/org/olat/user/UserImpl.java b/src/main/java/org/olat/user/UserImpl.java index 4b11e710465c359681bcaa98024915e0a23d18a3..40f13d1fc67e2697dc8cb2cf9b729145aa6fb8d2 100644 --- a/src/main/java/org/olat/user/UserImpl.java +++ b/src/main/java/org/olat/user/UserImpl.java @@ -76,16 +76,19 @@ public class UserImpl extends PersistentObject implements User { * still null. */ protected UserImpl() { - super(); - this.preferences = new PreferencesImpl(); + // } UserImpl(String firstName, String lastName, String eMail) { - super(); - if (firstName != null) getUserProperties().put(UserConstants.FIRSTNAME, firstName); - if (lastName != null) getUserProperties().put(UserConstants.LASTNAME, lastName); - if (eMail != null) getUserProperties().put(UserConstants.EMAIL, eMail); - this.preferences = new PreferencesImpl(); + if (firstName != null) { + getUserProperties().put(UserConstants.FIRSTNAME, firstName); + } + if (lastName != null) { + getUserProperties().put(UserConstants.LASTNAME, lastName); + } + if (eMail != null) { + getUserProperties().put(UserConstants.EMAIL, eMail); + } } /** @@ -114,7 +117,10 @@ public class UserImpl extends PersistentObject implements User { * @see User#getPreferences() */ public Preferences getPreferences(){ - return this.preferences; + if(preferences == null) { + preferences = new PreferencesImpl(); + } + return preferences; } /** diff --git a/src/main/java/org/olat/user/UserManagerImpl.java b/src/main/java/org/olat/user/UserManagerImpl.java index 796c793bc9dedbe40c58eeee23fdd911d1b1f1e4..fb8f78c4f5a05d1bb813f1cbf31203cf463ef211 100644 --- a/src/main/java/org/olat/user/UserManagerImpl.java +++ b/src/main/java/org/olat/user/UserManagerImpl.java @@ -121,15 +121,20 @@ public class UserManagerImpl extends UserManager { /** * @see org.olat.user.UserManager#createAndPersistUser(java.lang.String, java.lang.String, java.lang.String) */ + @Override public User createAndPersistUser(String firstName, String lastName, String email) { User user = new UserImpl(firstName, lastName, email); + user.getPreferences(); dbInstance.getCurrentEntityManager().persist(user); return user; } - // fxdiff: check also for emails in change-workflow + /* + * check also for emails in change-workflow(non-Javadoc) + * @see org.olat.user.UserManager#isEmailInUse(java.lang.String) + */ + @Override public boolean isEmailInUse(String email) { - DB db = DBFactory.getInstance(); String[] emailProperties = {UserConstants.EMAIL, UserConstants.INSTITUTIONALEMAIL}; for(String emailProperty:emailProperties) { StringBuilder sb = new StringBuilder(); @@ -139,7 +144,7 @@ public class UserManagerImpl extends UserManager { .append("']=:email_value"); String query = sb.toString(); - DBQuery dbq = db.createQuery(query); + DBQuery dbq = dbInstance.createQuery(query); dbq.setString("email_value", email); Number countEmail = (Number)dbq.uniqueResult(); if(countEmail.intValue() > 0) { @@ -544,7 +549,7 @@ public class UserManagerImpl extends UserManager { } } - List<IdentityShort> identities = securityManager.loadIdentityShortByKeys(identityKeys); + List<IdentityShort> identities = securityManager.loadIdentityShortByKeys(newIdentityKeys); for(IdentityShort identity:identities) { String fullName = getUserDisplayName(identity); updateUsernameCache(identity.getKey(), identity.getName(), fullName);