KEYCLOAK-3042: NPE when trying to overwrite client role

This commit is contained in:
Stan Silvert 2016-11-29 15:43:48 -05:00
parent 334aa37b7f
commit 83063a5740
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')) ||