[UPDATE]
- 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-94f89814c4dfmaster
parent
f4699b096a
commit
c3cbf3a90e
|
|
@ -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);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -145,48 +145,39 @@ 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
|
Permission duplicatePermission = new Permission
|
||||||
if (!multipleGrantees) {
|
(permission);
|
||||||
permission.setGrantee(grantee);
|
duplicatePermission.setGrantee(grantee);
|
||||||
grantee.addPermission(permission);
|
grantee.addPermission(duplicatePermission);
|
||||||
multipleGrantees = true;
|
|
||||||
} else {
|
|
||||||
Permission duplicatePermission = new Permission
|
|
||||||
(permission);
|
|
||||||
duplicatePermission.setGrantee(grantee);
|
|
||||||
grantee.addPermission(duplicatePermission);
|
|
||||||
|
|
||||||
CcmObject object = duplicatePermission.getObject();
|
CcmObject object = duplicatePermission.getObject();
|
||||||
long objectId = 0;
|
long objectId = 0;
|
||||||
if (object != null) {
|
if (object != null) {
|
||||||
objectId = object.getObjectId();
|
objectId = object.getObjectId();
|
||||||
}
|
|
||||||
|
|
||||||
long oldId = objectId + grantee.getRoleId();
|
|
||||||
PermissionIdMapper.map.put(oldId,
|
|
||||||
duplicatePermission.getPermissionId());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
long oldId = objectId + grantee.getRoleId();
|
||||||
|
PermissionIdMapper.map.put(oldId,
|
||||||
|
duplicatePermission.getPermissionId());
|
||||||
}
|
}
|
||||||
// if group contains no roles, new Role necessary
|
|
||||||
} else {
|
|
||||||
Group member = NgCollection.groups.get
|
|
||||||
(trunkGranteeParty.getID().longValue());
|
|
||||||
|
|
||||||
Role granteeRole = createNewRole(member);
|
|
||||||
|
|
||||||
// set grantee and opposed association
|
|
||||||
permission.setGrantee(granteeRole);
|
|
||||||
granteeRole.addPermission(permission);
|
|
||||||
}
|
}
|
||||||
|
// new Role for this group
|
||||||
|
Group member = NgCollection.groups.get
|
||||||
|
(trunkGranteeGroup.getID().longValue());
|
||||||
|
|
||||||
|
Role granteeRole = createNewRole(member);
|
||||||
|
|
||||||
|
// set grantee and opposed association
|
||||||
|
permission.setGrantee(granteeRole);
|
||||||
|
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,10 +193,10 @@ 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",
|
||||||
|
trunkPermission.getOID().toString());
|
||||||
}
|
}
|
||||||
|
|
||||||
System.err.printf("!!!Failed to convert grantee for permission %s%n",
|
|
||||||
trunkPermission.getOID().toString());
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -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;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue