Merge pull request #3562 from ssilvert/overwrite-client-role-fails

KEYCLOAK-3042: NPE when trying to overwrite client role
This commit is contained in:
Stian Thorgersen 2016-12-02 14:06:27 +01:00 committed by GitHub
commit 8842d88058
2 changed files with 14 additions and 1 deletions

View file

@ -103,6 +103,11 @@ public class ClientRolesPartialImport {
return;
}
RoleModel role = client.getRole(getName(roleRep));
if (role == null) {
// role might not exist if client was just created as part of the
// partial import
return;
}
client.removeRole(role);
}

View file

@ -2638,13 +2638,21 @@ module.controller('RealmImportCtrl', function($scope, realm, $route,
$scope.itemCount = function(section) {
if (!$scope.importing) return 0;
if ($scope.hasRealmRoles() && (section === 'roles.realm')) return $scope.fileContent.roles.realm.length;
if ($scope.hasClientRoles() && (section === 'roles.client')) return Object.keys($scope.fileContent.roles.client).length;
if ($scope.hasClientRoles() && (section === 'roles.client')) return clientRolesCount($scope.fileContent.roles.client);
if (!$scope.fileContent.hasOwnProperty(section)) return 0;
return $scope.fileContent[section].length;
}
clientRolesCount = function(clientRoles) {
var total = 0;
for (var clientName in clientRoles) {
total += clientRoles[clientName].length;
}
return total;
}
$scope.hasResources = function() {
return ($scope.importUsers && $scope.hasArray('users')) ||
($scope.importGroups && $scope.hasArray('groups')) ||