diff --git a/model/invalidation-cache/model-adapters/src/main/java/org/keycloak/models/cache/UserAdapter.java b/model/invalidation-cache/model-adapters/src/main/java/org/keycloak/models/cache/UserAdapter.java
index aedaf254d2..95b82fab7b 100755
--- a/model/invalidation-cache/model-adapters/src/main/java/org/keycloak/models/cache/UserAdapter.java
+++ b/model/invalidation-cache/model-adapters/src/main/java/org/keycloak/models/cache/UserAdapter.java
@@ -1,21 +1,21 @@
package org.keycloak.models.cache;
+import org.keycloak.models.ClientModel;
+import org.keycloak.models.UserConsentModel;
+import org.keycloak.models.KeycloakSession;
+import org.keycloak.models.RealmModel;
+import org.keycloak.models.RoleContainerModel;
+import org.keycloak.models.RoleModel;
+import org.keycloak.models.UserCredentialModel;
+import org.keycloak.models.UserCredentialValueModel;
+import org.keycloak.models.UserModel;
+import org.keycloak.models.cache.entities.CachedUser;
+
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
-import org.keycloak.models.ClientModel;
-import org.keycloak.models.KeycloakSession;
-import org.keycloak.models.RealmModel;
-import org.keycloak.models.RoleContainerModel;
-import org.keycloak.models.RoleModel;
-import org.keycloak.models.UserConsentModel;
-import org.keycloak.models.UserCredentialModel;
-import org.keycloak.models.UserCredentialValueModel;
-import org.keycloak.models.UserModel;
-import org.keycloak.models.cache.entities.CachedUser;
-
/**
* @author Bill Burke
* @version $Revision: 1 $
@@ -38,22 +38,18 @@ public class UserAdapter implements UserModel {
if (updated == null) {
userProviderCache.registerUserInvalidation(realm, getId());
updated = userProviderCache.getDelegate().getUserById(getId(), realm);
- if (updated == null)
- throw new IllegalStateException("Not found in database");
+ if (updated == null) throw new IllegalStateException("Not found in database");
}
}
-
@Override
public String getId() {
- if (updated != null)
- return updated.getId();
+ if (updated != null) return updated.getId();
return cached.getId();
}
@Override
public String getUsername() {
- if (updated != null)
- return updated.getUsername();
+ if (updated != null) return updated.getUsername();
return cached.getUsername();
}
@@ -76,15 +72,13 @@ public class UserAdapter implements UserModel {
@Override
public boolean isEnabled() {
- if (updated != null)
- return updated.isEnabled();
+ if (updated != null) return updated.isEnabled();
return cached.isEnabled();
}
@Override
public boolean isTotp() {
- if (updated != null)
- return updated.isTotp();
+ if (updated != null) return updated.isTotp();
return cached.isTotp();
}
@@ -108,22 +102,19 @@ public class UserAdapter implements UserModel {
@Override
public String getAttribute(String name) {
- if (updated != null)
- return updated.getAttribute(name);
+ if (updated != null) return updated.getAttribute(name);
return cached.getAttributes().get(name);
}
@Override
public Map getAttributes() {
- if (updated != null)
- return updated.getAttributes();
+ if (updated != null) return updated.getAttributes();
return cached.getAttributes();
}
@Override
public Set getRequiredActions() {
- if (updated != null)
- return updated.getRequiredActions();
+ if (updated != null) return updated.getRequiredActions();
return cached.getRequiredActions();
}
@@ -153,8 +144,7 @@ public class UserAdapter implements UserModel {
@Override
public String getFirstName() {
- if (updated != null)
- return updated.getFirstName();
+ if (updated != null) return updated.getFirstName();
return cached.getFirstName();
}
@@ -166,8 +156,7 @@ public class UserAdapter implements UserModel {
@Override
public String getLastName() {
- if (updated != null)
- return updated.getLastName();
+ if (updated != null) return updated.getLastName();
return cached.getLastName();
}
@@ -179,8 +168,7 @@ public class UserAdapter implements UserModel {
@Override
public String getEmail() {
- if (updated != null)
- return updated.getEmail();
+ if (updated != null) return updated.getEmail();
return cached.getEmail();
}
@@ -192,8 +180,7 @@ public class UserAdapter implements UserModel {
@Override
public boolean isEmailVerified() {
- if (updated != null)
- return updated.isEmailVerified();
+ if (updated != null) return updated.isEmailVerified();
return cached.isEmailVerified();
}
@@ -217,8 +204,7 @@ public class UserAdapter implements UserModel {
@Override
public List getCredentialsDirectly() {
- if (updated != null)
- return updated.getCredentialsDirectly();
+ if (updated != null) return updated.getCredentialsDirectly();
return cached.getCredentials();
}
@@ -230,8 +216,7 @@ public class UserAdapter implements UserModel {
@Override
public String getFederationLink() {
- if (updated != null)
- return updated.getFederationLink();
+ if (updated != null) return updated.getFederationLink();
return cached.getFederationLink();
}
@@ -239,12 +224,11 @@ public class UserAdapter implements UserModel {
public void setFederationLink(String link) {
getDelegateForUpdate();
updated.setFederationLink(link);
- }
+ }
@Override
public Set getRealmRoleMappings() {
- if (updated != null)
- return updated.getRealmRoleMappings();
+ if (updated != null) return updated.getRealmRoleMappings();
Set roleMappings = getRoleMappings();
Set realmMappings = new HashSet();
for (RoleModel role : roleMappings) {
@@ -260,8 +244,7 @@ public class UserAdapter implements UserModel {
@Override
public Set getClientRoleMappings(ClientModel app) {
- if (updated != null)
- return updated.getClientRoleMappings(app);
+ if (updated != null) return updated.getClientRoleMappings(app);
Set roleMappings = getRoleMappings();
Set appMappings = new HashSet();
for (RoleModel role : roleMappings) {
@@ -277,15 +260,12 @@ public class UserAdapter implements UserModel {
@Override
public boolean hasRole(RoleModel role) {
- if (updated != null)
- return updated.hasRole(role);
- if (cached.getRoleMappings().contains(role.getId()))
- return true;
+ if (updated != null) return updated.hasRole(role);
+ if (cached.getRoleMappings().contains(role.getId())) return true;
Set mappings = getRoleMappings();
- for (RoleModel mapping : mappings) {
- if (mapping.hasRole(role))
- return true;
+ for (RoleModel mapping: mappings) {
+ if (mapping.hasRole(role)) return true;
}
return false;
}
@@ -298,8 +278,7 @@ public class UserAdapter implements UserModel {
@Override
public Set getRoleMappings() {
- if (updated != null)
- return updated.getRoleMappings();
+ if (updated != null) return updated.getRoleMappings();
Set roles = new HashSet();
for (String id : cached.getRoleMappings()) {
RoleModel roleById = keycloakSession.realms().getRoleById(id, realm);