KEYCLOAK-2114

This commit is contained in:
Bill Burke 2015-11-25 10:13:44 -05:00
parent 067cb120f8
commit b04b124351
5 changed files with 25 additions and 0 deletions

View file

@ -24,6 +24,7 @@ module.controller('GroupListCtrl', function($scope, $route, realm, groups, Group
$scope.paste = function(selected) { $scope.paste = function(selected) {
if (selected == null) return; if (selected == null) return;
if ($scope.cutNode == null) return; if ($scope.cutNode == null) return;
if (selected.id == $scope.cutNode.id) return;
if (selected.id == 'realm') { if (selected.id == 'realm') {
Groups.save({realm: realm.realm}, {id:$scope.cutNode.id}, function() { Groups.save({realm: realm.realm}, {id:$scope.cutNode.id}, function() {
$route.reload(); $route.reload();

View file

@ -104,6 +104,9 @@ public class GroupAdapter implements GroupModel {
@Override @Override
public void setParent(GroupModel parent) { public void setParent(GroupModel parent) {
if (parent == null) group.setParent(null); if (parent == null) group.setParent(null);
else if (parent.getId().equals(getId())) {
return;
}
else { else {
GroupEntity parentEntity = toEntity(parent, em); GroupEntity parentEntity = toEntity(parent, em);
group.setParent(parentEntity); group.setParent(parentEntity);
@ -112,11 +115,17 @@ public class GroupAdapter implements GroupModel {
@Override @Override
public void addChild(GroupModel subGroup) { public void addChild(GroupModel subGroup) {
if (subGroup.getId().equals(getId())) {
return;
}
subGroup.setParent(this); subGroup.setParent(this);
} }
@Override @Override
public void removeChild(GroupModel subGroup) { public void removeChild(GroupModel subGroup) {
if (subGroup.getId().equals(getId())) {
return;
}
subGroup.setParent(null); subGroup.setParent(null);
} }

View file

@ -1994,6 +1994,9 @@ public class RealmAdapter implements RealmModel {
@Override @Override
public void moveGroup(GroupModel group, GroupModel toParent) { public void moveGroup(GroupModel group, GroupModel toParent) {
if (toParent != null && group.getId().equals(toParent.getId())) {
return;
}
if (group.getParentId() != null) { if (group.getParentId() != null) {
group.getParent().removeChild(group); group.getParent().removeChild(group);
} }

View file

@ -223,6 +223,9 @@ public class GroupAdapter extends AbstractMongoAdapter<MongoGroupEntity> impleme
@Override @Override
public void setParent(GroupModel parent) { public void setParent(GroupModel parent) {
if (parent == null) group.setParentId(null); if (parent == null) group.setParentId(null);
else if (parent.getId().equals(getId())) {
return;
}
else { else {
group.setParentId(parent.getId()); group.setParentId(parent.getId());
} }
@ -232,6 +235,9 @@ public class GroupAdapter extends AbstractMongoAdapter<MongoGroupEntity> impleme
@Override @Override
public void addChild(GroupModel subGroup) { public void addChild(GroupModel subGroup) {
if (subGroup.getId().equals(getId())) {
return;
}
subGroup.setParent(this); subGroup.setParent(this);
updateGroup(); updateGroup();
@ -239,6 +245,9 @@ public class GroupAdapter extends AbstractMongoAdapter<MongoGroupEntity> impleme
@Override @Override
public void removeChild(GroupModel subGroup) { public void removeChild(GroupModel subGroup) {
if (subGroup.getId().equals(getId())) {
return;
}
subGroup.setParent(null); subGroup.setParent(null);
updateGroup(); updateGroup();

View file

@ -636,6 +636,9 @@ public class RealmAdapter extends AbstractMongoAdapter<MongoRealmEntity> impleme
@Override @Override
public void moveGroup(GroupModel group, GroupModel toParent) { public void moveGroup(GroupModel group, GroupModel toParent) {
if (toParent != null && group.getId().equals(toParent.getId())) {
return;
}
if (group.getParentId() != null) { if (group.getParentId() != null) {
group.getParent().removeChild(group); group.getParent().removeChild(group);
} }