Java Code Examples for org.keycloak.representations.idm.GroupRepresentation#getName()

The following examples show how to use org.keycloak.representations.idm.GroupRepresentation#getName() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: GroupImportService.java    From keycloak-config-cli with Apache License 2.0 5 votes vote down vote up
private void createOrUpdateRealmGroup(String realm, GroupRepresentation group) {
    String groupName = group.getName();

    Optional<GroupRepresentation> maybeGroup = groupRepository.tryToFindGroupByName(realm, groupName);

    if (maybeGroup.isPresent()) {
        updateGroupIfNecessary(realm, group);
    } else {
        logger.debug("Create group '{}' in realm '{}'", groupName, realm);
        createGroup(realm, group);
    }
}
 
Example 2
Source File: GroupImportService.java    From keycloak-config-cli with Apache License 2.0 5 votes vote down vote up
private void updateGroupIfNecessary(String realm, GroupRepresentation group) {
    GroupRepresentation existingGroup = groupRepository.getGroupByName(realm, group.getName());
    GroupRepresentation patchedGroup = CloneUtil.patch(existingGroup, group);
    String groupName = existingGroup.getName();

    if (isGroupEqual(existingGroup, patchedGroup)) {
        logger.debug("No need to update group '{}' in realm '{}'", groupName, realm);
    } else {
        logger.debug("Update group '{}' in realm '{}'", groupName, realm);
        updateGroup(realm, group, patchedGroup);
    }
}
 
Example 3
Source File: GroupImportService.java    From keycloak-config-cli with Apache License 2.0 5 votes vote down vote up
public void updateSubGroupIfNecessary(String realm, String parentGroupId, GroupRepresentation subGroup) {
    String subGroupName = subGroup.getName();
    GroupRepresentation existingSubGroup = groupRepository.getSubGroupByName(realm, parentGroupId, subGroupName);

    GroupRepresentation patchedSubGroup = CloneUtil.patch(existingSubGroup, subGroup);

    if (CloneUtil.deepEquals(existingSubGroup, patchedSubGroup)) {
        logger.debug("No need to update subGroup '{}' in group with id '{}' in realm '{}'", subGroupName, parentGroupId, realm);
    } else {
        logger.debug("Update subGroup '{}' in group with id '{}' in realm '{}'", subGroupName, parentGroupId, realm);

        updateGroup(realm, subGroup, patchedSubGroup);
    }
}
 
Example 4
Source File: GroupsPartialImport.java    From keycloak with Apache License 2.0 4 votes vote down vote up
@Override
public String getName(GroupRepresentation group) {
    return group.getName();
}