use of org.keycloak.storage.jpa.entity.FederatedUserGroupMembershipEntity in project keycloak by keycloak.
the class JpaUserFederatedStorageProvider method joinGroup.
@Override
public void joinGroup(RealmModel realm, String userId, GroupModel group) {
createIndex(realm, userId);
FederatedUserGroupMembershipEntity entity = new FederatedUserGroupMembershipEntity();
entity.setUserId(userId);
entity.setStorageProviderId(new StorageId(userId).getProviderId());
entity.setGroupId(group.getId());
entity.setRealmId(realm.getId());
em.persist(entity);
}
use of org.keycloak.storage.jpa.entity.FederatedUserGroupMembershipEntity in project keycloak by keycloak.
the class JpaUserFederatedStorageProvider method leaveGroup.
@Override
public void leaveGroup(RealmModel realm, String userId, GroupModel group) {
if (userId == null || group == null)
return;
TypedQuery<FederatedUserGroupMembershipEntity> query1 = em.createNamedQuery("feduserMemberOf", FederatedUserGroupMembershipEntity.class);
query1.setParameter("userId", userId);
query1.setParameter("groupId", group.getId());
TypedQuery<FederatedUserGroupMembershipEntity> query = query1;
query.setLockMode(LockModeType.PESSIMISTIC_WRITE);
List<FederatedUserGroupMembershipEntity> results = query.getResultList();
if (results.size() == 0)
return;
for (FederatedUserGroupMembershipEntity entity : results) {
em.remove(entity);
}
em.flush();
}
Aggregations