Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Map storage: Extract commonly used methods to utility class #9025

Closed
hmlnarik opened this issue Dec 7, 2021 · 0 comments · Fixed by #9026
Closed

Map storage: Extract commonly used methods to utility class #9025

hmlnarik opened this issue Dec 7, 2021 · 0 comments · Fixed by #9026
Assignees
Labels
area/storage Indicates an issue that touches storage (change in data layout or data manipulation) kind/enhancement Categorizes a PR related to an enhancement
Milestone

Comments

@hmlnarik
Copy link
Contributor

hmlnarik commented Dec 7, 2021

Methods for mutual translating entity interface to model and to name are being used in other storages as well and so should be extracted from ConcurrentHashMapStorageProviderFactory to a separate utility class:

public static final Map<Class<?>, String> MODEL_TO_NAME = new HashMap<>();
static {
MODEL_TO_NAME.put(AuthenticatedClientSessionModel.class, "client-sessions");
MODEL_TO_NAME.put(ClientScopeModel.class, "client-scopes");
MODEL_TO_NAME.put(ClientModel.class, "clients");
MODEL_TO_NAME.put(GroupModel.class, "groups");
MODEL_TO_NAME.put(RealmModel.class, "realms");
MODEL_TO_NAME.put(RoleModel.class, "roles");
MODEL_TO_NAME.put(RootAuthenticationSessionModel.class, "auth-sessions");
MODEL_TO_NAME.put(UserLoginFailureModel.class, "user-login-failures");
MODEL_TO_NAME.put(UserModel.class, "users");
MODEL_TO_NAME.put(UserSessionModel.class, "user-sessions");
// authz
MODEL_TO_NAME.put(PermissionTicket.class, "authz-permission-tickets");
MODEL_TO_NAME.put(Policy.class, "authz-policies");
MODEL_TO_NAME.put(ResourceServer.class, "authz-resource-servers");
MODEL_TO_NAME.put(Resource.class, "authz-resources");
MODEL_TO_NAME.put(org.keycloak.authorization.model.Scope.class, "authz-scopes");
}
public static final Map<Class<?>, Class<? extends AbstractEntity>> MODEL_TO_VALUE_TYPE = new HashMap<>();
static {
MODEL_TO_VALUE_TYPE.put(AuthenticatedClientSessionModel.class, MapAuthenticatedClientSessionEntity.class);
MODEL_TO_VALUE_TYPE.put(ClientScopeModel.class, MapClientScopeEntity.class);
MODEL_TO_VALUE_TYPE.put(ClientModel.class, MapClientEntity.class);
MODEL_TO_VALUE_TYPE.put(GroupModel.class, MapGroupEntity.class);
MODEL_TO_VALUE_TYPE.put(RealmModel.class, MapRealmEntity.class);
MODEL_TO_VALUE_TYPE.put(RoleModel.class, MapRoleEntity.class);
MODEL_TO_VALUE_TYPE.put(RootAuthenticationSessionModel.class, MapRootAuthenticationSessionEntity.class);
MODEL_TO_VALUE_TYPE.put(UserLoginFailureModel.class, MapUserLoginFailureEntity.class);
MODEL_TO_VALUE_TYPE.put(UserModel.class, MapUserEntity.class);
MODEL_TO_VALUE_TYPE.put(UserSessionModel.class, MapUserSessionEntity.class);
// authz
MODEL_TO_VALUE_TYPE.put(PermissionTicket.class, MapPermissionTicketEntity.class);
MODEL_TO_VALUE_TYPE.put(Policy.class, MapPolicyEntity.class);
MODEL_TO_VALUE_TYPE.put(ResourceServer.class, MapResourceServerEntity.class);
MODEL_TO_VALUE_TYPE.put(Resource.class, MapResourceEntity.class);
MODEL_TO_VALUE_TYPE.put(org.keycloak.authorization.model.Scope.class, MapScopeEntity.class);
}

@hmlnarik hmlnarik added kind/enhancement Categorizes a PR related to an enhancement area/storage Indicates an issue that touches storage (change in data layout or data manipulation) labels Dec 7, 2021
@hmlnarik hmlnarik self-assigned this Dec 7, 2021
hmlnarik added a commit to hmlnarik/keycloak that referenced this issue Dec 7, 2021
hmlnarik added a commit that referenced this issue Dec 7, 2021
@stianst stianst added this to the 16.0.0 milestone Dec 10, 2021
domids pushed a commit to domids/keycloak that referenced this issue Jan 11, 2022
domids pushed a commit to domids/keycloak that referenced this issue Jan 11, 2022
laskasn pushed a commit to eosc-kc/keycloak that referenced this issue Jan 20, 2022
@stianst stianst modified the milestones: 15.1.0, 17.0.0 Feb 2, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/storage Indicates an issue that touches storage (change in data layout or data manipulation) kind/enhancement Categorizes a PR related to an enhancement
Projects
Status: Done
Development

Successfully merging a pull request may close this issue.

2 participants