KEYCLOAK-1421 patched source formatting

This commit is contained in:
Vlastimil Elias 2015-06-16 09:09:14 +02:00
parent 7cff37e707
commit f5a80c3007

View file

@ -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 <a href="mailto:bill@burkecentral.com">Bill Burke</a>
* @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<String, String> getAttributes() {
if (updated != null)
return updated.getAttributes();
if (updated != null) return updated.getAttributes();
return cached.getAttributes();
}
@Override
public Set<String> 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<UserCredentialValueModel> 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<RoleModel> getRealmRoleMappings() {
if (updated != null)
return updated.getRealmRoleMappings();
if (updated != null) return updated.getRealmRoleMappings();
Set<RoleModel> roleMappings = getRoleMappings();
Set<RoleModel> realmMappings = new HashSet<RoleModel>();
for (RoleModel role : roleMappings) {
@ -260,8 +244,7 @@ public class UserAdapter implements UserModel {
@Override
public Set<RoleModel> getClientRoleMappings(ClientModel app) {
if (updated != null)
return updated.getClientRoleMappings(app);
if (updated != null) return updated.getClientRoleMappings(app);
Set<RoleModel> roleMappings = getRoleMappings();
Set<RoleModel> appMappings = new HashSet<RoleModel>();
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<RoleModel> 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<RoleModel> getRoleMappings() {
if (updated != null)
return updated.getRoleMappings();
if (updated != null) return updated.getRoleMappings();
Set<RoleModel> roles = new HashSet<RoleModel>();
for (String id : cached.getRoleMappings()) {
RoleModel roleById = keycloakSession.realms().getRoleById(id, realm);