- excludes remove process in GroupConversion
- changes process of PermissionConverion
- new error message in PermissionIdGenerator

git-svn-id: https://svn.libreccm.org/ccm/trunk@4660 8810af33-2d31-482b-a856-94f89814c4df
master
tosmers 2017-04-05 15:09:14 +00:00
parent f4699b096a
commit c3cbf3a90e
3 changed files with 34 additions and 42 deletions

View File

@ -49,12 +49,12 @@ public class GroupConversion {
roleGroups = new ArrayList<>(); roleGroups = new ArrayList<>();
trunkGroups = com.arsdigita.kernel.Group.getAllObjectGroups(); trunkGroups = com.arsdigita.kernel.Group.getAllObjectGroups();
List<com.arsdigita.kernel.Role> trunkRoles = com.arsdigita.kernel // List<com.arsdigita.kernel.Role> trunkRoles = com.arsdigita.kernel
.Role.getAllObjectRoles(); // .Role.getAllObjectRoles();
trunkRoles.forEach(role -> roleGroups.add(role.getGroup())); // trunkRoles.forEach(role -> roleGroups.add(role.getGroup()));
// remove subgroups representing roles // remove subgroups representing roles
trunkGroups.removeAll(roleGroups); // trunkGroups.removeAll(roleGroups);
createGroupsAndSetAssociations(trunkGroups); createGroupsAndSetAssociations(trunkGroups);
} }

View File

@ -145,21 +145,13 @@ public class PermissionConversion {
com.arsdigita.kernel.Group trunkGranteeGroup = com.arsdigita.kernel.Group trunkGranteeGroup =
(com.arsdigita.kernel.Group) trunkGranteeParty; (com.arsdigita.kernel.Group) trunkGranteeParty;
RoleCollection roleCollection = ((com.arsdigita.kernel. RoleCollection roleCollection = trunkGranteeGroup.getRoles();
Group) trunkGranteeParty).getRoles();
// if group contains 1 or more roles // if group contains 1 or more roles
if (!roleCollection.isEmpty()) { if (!roleCollection.isEmpty()) {
boolean multipleGrantees = false;
while (roleCollection.next()) { while (roleCollection.next()) {
Role grantee = NgCollection.roles.get(roleCollection Role grantee = NgCollection.roles.get(roleCollection
.getRole().getID().longValue()); .getRole().getID().longValue());
// set grantee and opposed associations
if (!multipleGrantees) {
permission.setGrantee(grantee);
grantee.addPermission(permission);
multipleGrantees = true;
} else {
Permission duplicatePermission = new Permission Permission duplicatePermission = new Permission
(permission); (permission);
duplicatePermission.setGrantee(grantee); duplicatePermission.setGrantee(grantee);
@ -176,17 +168,16 @@ public class PermissionConversion {
duplicatePermission.getPermissionId()); duplicatePermission.getPermissionId());
} }
} }
// if group contains no roles, new Role necessary // new Role for this group
} else {
Group member = NgCollection.groups.get Group member = NgCollection.groups.get
(trunkGranteeParty.getID().longValue()); (trunkGranteeGroup.getID().longValue());
Role granteeRole = createNewRole(member); Role granteeRole = createNewRole(member);
// set grantee and opposed association // set grantee and opposed association
permission.setGrantee(granteeRole); permission.setGrantee(granteeRole);
granteeRole.addPermission(permission); granteeRole.addPermission(permission);
}
// grantee instance of User, new Role necessary // grantee instance of User, new Role necessary
} else if (trunkGranteeParty instanceof com.arsdigita.kernel } else if (trunkGranteeParty instanceof com.arsdigita.kernel
@ -202,13 +193,13 @@ public class PermissionConversion {
// set grantee and opposed association // set grantee and opposed association
permission.setGrantee(granteeRole); permission.setGrantee(granteeRole);
granteeRole.addPermission(permission); granteeRole.addPermission(permission);
} } else {
System.err.printf("!!!Failed to convert grantee for permission %s%n", System.err.printf("!!!Failed to convert grantee for permission %s%n",
trunkPermission.getOID().toString()); trunkPermission.getOID().toString());
} }
} }
} }
}
/** /**
* Creates a new role for a given member and sets its membership. * Creates a new role for a given member and sets its membership.

View File

@ -74,9 +74,10 @@ public class PermissionIdGenerator extends ObjectIdGenerator<String> {
b = true; b = true;
} }
// if (!(a || b)) { if (!(a || b)) {
// throw new IllegalStateException(); System.err.printf("!!!Object and Grantee are empty.. %s%n",
// } permission.getGrantedPrivilege());
}
return id; return id;
} }