Remove redundant information from cache entries

Closes #37034

Signed-off-by: Alexander Schwartz <aschwart@redhat.com>
This commit is contained in:
Alexander Schwartz
2025-02-04 11:02:21 +01:00
committed by Pedro Igor
parent 757f46a75a
commit 7bcc2c4b28
7 changed files with 7 additions and 26 deletions

View File

@@ -12,19 +12,16 @@ import java.util.Set;
public class ClientListQuery extends AbstractRevisioned implements ClientQuery {
private final Set<String> clients;
private final String realm;
private final String realmName;
public ClientListQuery(Long revisioned, String id, RealmModel realm, Set<String> clients) {
super(revisioned, id);
this.realm = realm.getId();
this.realmName = realm.getName();
this.clients = clients;
}
public ClientListQuery(Long revisioned, String id, RealmModel realm, String client) {
super(revisioned, id);
this.realm = realm.getId();
this.realmName = realm.getName();
this.clients = new HashSet<>();
this.clients.add(client);
}
@@ -43,7 +40,7 @@ public class ClientListQuery extends AbstractRevisioned implements ClientQuery {
public String toString() {
return "ClientListQuery{" +
"id='" + getId() + "'" +
"realmName='" + realmName + '\'' +
"realm='" + realm + '\'' +
'}';
}
}

View File

@@ -24,13 +24,11 @@ import java.util.Set;
public class ClientScopeListQuery extends AbstractRevisioned implements ClientScopeQuery {
private final Set<String> clientScopes;
private final String realm;
private final String realmName;
private String clientUuid;
public ClientScopeListQuery(Long revisioned, String id, RealmModel realm, Set<String> clientScopes) {
super(revisioned, id);
this.realm = realm.getId();
this.realmName = realm.getName();
this.clientScopes = clientScopes;
}
@@ -58,7 +56,7 @@ public class ClientScopeListQuery extends AbstractRevisioned implements ClientSc
public String toString() {
return "ClientScopeListQuery{" +
"id='" + getId() + "'" +
", realmName='" + realmName + '\'' +
", realm='" + realm + '\'' +
", clientUuid='" + clientUuid + '\'' +
'}';
}

View File

@@ -14,13 +14,11 @@ import java.util.stream.Collectors;
*/
public class GroupListQuery extends AbstractRevisioned implements GroupQuery {
private final String realm;
private final String realmName;
private final Map<String, Set<String>> searchKeys;
public GroupListQuery(Long revisioned, String id, RealmModel realm, String searchKey, Set<String> result) {
super(revisioned, id);
this.realm = realm.getId();
this.realmName = realm.getName();
this.searchKeys = new HashMap<>();
this.searchKeys.put(searchKey, result);
}
@@ -28,7 +26,6 @@ public class GroupListQuery extends AbstractRevisioned implements GroupQuery {
public GroupListQuery(Long revisioned, String id, RealmModel realm, String searchKey, Set<String> result, GroupListQuery previous) {
super(revisioned, id);
this.realm = realm.getId();
this.realmName = realm.getName();
this.searchKeys = new HashMap<>();
this.searchKeys.putAll(previous.searchKeys);
this.searchKeys.put(searchKey, result);
@@ -37,7 +34,6 @@ public class GroupListQuery extends AbstractRevisioned implements GroupQuery {
public GroupListQuery(Long revisioned, String id, RealmModel realm, Set<String> ids) {
super(revisioned, id);
this.realm = realm.getId();
this.realmName = realm.getName();
this.searchKeys = new HashMap<>();
this.searchKeys.put(id, ids);
}
@@ -66,7 +62,7 @@ public class GroupListQuery extends AbstractRevisioned implements GroupQuery {
public String toString() {
return "GroupListQuery{" +
"id='" + getId() + "'" +
"realmName='" + realmName + '\'' +
"realm='" + realm + '\'' +
'}';
}
}

View File

@@ -21,13 +21,11 @@ import org.keycloak.models.RealmModel;
public class GroupNameQuery extends AbstractRevisioned implements InRealm {
private final String realm;
private final String realmName;
private final String groupId;
public GroupNameQuery(Long revisioned, String id, String groupId, RealmModel realm) {
super(revisioned, id);
this.realm = realm.getId();
this.realmName = realm.getName();
this.groupId = groupId;
}
@@ -43,7 +41,7 @@ public class GroupNameQuery extends AbstractRevisioned implements InRealm {
public String toString() {
return "GroupNameQuery{" +
"id='" + getId() + "'" +
"realmName='" + realmName + '\'' +
"realm='" + realm + '\'' +
'}';
}
}

View File

@@ -27,13 +27,11 @@ import java.util.Set;
public class RoleByNameQuery extends AbstractRevisioned implements RoleQuery, InClient {
private final String role;
private final String realm;
private final String realmName;
private String client;
public RoleByNameQuery(Long revisioned, String id, RealmModel realm, String role) {
super(revisioned, id);
this.realm = realm.getId();
this.realmName = realm.getName();
this.role = role;
}
@@ -65,7 +63,7 @@ public class RoleByNameQuery extends AbstractRevisioned implements RoleQuery, In
public String toString() {
return "RoleNameQuery{" +
"id='" + getId() + "'" +
", realmName='" + realmName + '\'' +
", realm='" + realm + '\'' +
", clientUuid='" + client + '\'' +
'}';
}

View File

@@ -12,20 +12,17 @@ import java.util.Set;
public class RoleListQuery extends AbstractRevisioned implements RoleQuery, InClient {
private final Set<String> roles;
private final String realm;
private final String realmName;
private String client;
public RoleListQuery(Long revisioned, String id, RealmModel realm, Set<String> roles) {
super(revisioned, id);
this.realm = realm.getId();
this.realmName = realm.getName();
this.roles = roles;
}
public RoleListQuery(Long revisioned, String id, RealmModel realm, String role) {
super(revisioned, id);
this.realm = realm.getId();
this.realmName = realm.getName();
this.roles = new HashSet<>();
this.roles.add(role);
}
@@ -59,7 +56,7 @@ public class RoleListQuery extends AbstractRevisioned implements RoleQuery, InCl
public String toString() {
return "RoleListQuery{" +
"id='" + getId() + "'" +
", realmName='" + realmName + '\'' +
", realm='" + realm + '\'' +
", clientUuid='" + client + '\'' +
'}';
}

View File

@@ -12,19 +12,16 @@ import java.util.Set;
public class UserListQuery extends AbstractRevisioned implements UserQuery {
private final Set<String> users;
private final String realm;
private final String realmName;
public UserListQuery(Long revisioned, String id, RealmModel realm, Set<String> users) {
super(revisioned, id);
this.realm = realm.getId();
this.realmName = realm.getName();
this.users = users;
}
public UserListQuery(Long revisioned, String id, RealmModel realm, String user) {
super(revisioned, id);
this.realm = realm.getId();
this.realmName = realm.getName();
this.users = new HashSet<>();
this.users.add(user);
}
@@ -43,7 +40,7 @@ public class UserListQuery extends AbstractRevisioned implements UserQuery {
public String toString() {
return "UserListQuery{" +
"id='" + getId() + "'" +
"realmName='" + realmName + '\'' +
"realm='" + realm + '\'' +
'}';
}
}