Skip to content
Snippets Groups Projects
Commit d4377b88 authored by srosse's avatar srosse
Browse files

OO-1483: prevent 2x creation of PreferencesImpl, fix cache which load every time all identities

parent b38e85cf
No related branches found
No related tags found
No related merge requests found
......@@ -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;
}
/**
......
......@@ -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);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment