Merge pull request #3562 from ssilvert/overwrite-client-role-fails
KEYCLOAK-3042: NPE when trying to overwrite client role
This commit is contained in:
commit
8842d88058
2 changed files with 14 additions and 1 deletions
|
@ -103,6 +103,11 @@ public class ClientRolesPartialImport {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
RoleModel role = client.getRole(getName(roleRep));
|
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);
|
client.removeRole(role);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -2638,13 +2638,21 @@ module.controller('RealmImportCtrl', function($scope, realm, $route,
|
||||||
$scope.itemCount = function(section) {
|
$scope.itemCount = function(section) {
|
||||||
if (!$scope.importing) return 0;
|
if (!$scope.importing) return 0;
|
||||||
if ($scope.hasRealmRoles() && (section === 'roles.realm')) return $scope.fileContent.roles.realm.length;
|
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;
|
if (!$scope.fileContent.hasOwnProperty(section)) return 0;
|
||||||
|
|
||||||
return $scope.fileContent[section].length;
|
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() {
|
$scope.hasResources = function() {
|
||||||
return ($scope.importUsers && $scope.hasArray('users')) ||
|
return ($scope.importUsers && $scope.hasArray('users')) ||
|
||||||
($scope.importGroups && $scope.hasArray('groups')) ||
|
($scope.importGroups && $scope.hasArray('groups')) ||
|
||||||
|
|
Loading…
Reference in a new issue