diff --git a/ccm-core/src/com/arsdigita/kernel/Party.java b/ccm-core/src/com/arsdigita/kernel/Party.java index a7fce5617..0d9813c0d 100755 --- a/ccm-core/src/com/arsdigita/kernel/Party.java +++ b/ccm-core/src/com/arsdigita/kernel/Party.java @@ -323,8 +323,10 @@ public abstract class Party extends ACSObject { } /** - * Retrieves all objects of this type stored in the database. Very - * necessary for exporting all entities of the current work environment. + * Retrieves all objects of this type stored in the database. Has to + * retrieve Groups and Users separately, because Parties can not be + * instantiated due to abstract constraint. Very necessary for exporting + * all entities of the current work environment. * * @return List of all parties */ @@ -332,18 +334,35 @@ public abstract class Party extends ACSObject { List partyList = new ArrayList<>(); final Session session = SessionManager.getSession(); - DomainCollection collection = new DomainCollection(session.retrieve( - Party.BASE_DATA_OBJECT_TYPE)); + DomainCollection collection; + collection= new DomainCollection(session.retrieve(Group + .BASE_DATA_OBJECT_TYPE)); + addToPartyList(partyList, collection); + + collection = new DomainCollection(session.retrieve(User + .BASE_DATA_OBJECT_TYPE)); + addToPartyList(partyList, collection); + + collection.close(); + return partyList; + } + + /** + * Assisting method. Adds all objects of a DomainCollection to a given + * list of parties. + * + * @param partyList List of parties + * @param collection A DomainCollection + */ + private static void addToPartyList(List partyList, + DomainCollection collection) { while (collection.next()) { Party party = (Party) collection.getDomainObject(); if (party != null) { partyList.add(party); } } - - collection.close(); - return partyList; } } diff --git a/ccm-core/src/com/arsdigita/portation/conversion/core/security/PermissionConversion.java b/ccm-core/src/com/arsdigita/portation/conversion/core/security/PermissionConversion.java index 2b1eb5145..1f35a0b81 100644 --- a/ccm-core/src/com/arsdigita/portation/conversion/core/security/PermissionConversion.java +++ b/ccm-core/src/com/arsdigita/portation/conversion/core/security/PermissionConversion.java @@ -140,25 +140,29 @@ public class PermissionConversion { trunkGranteeParty).getRoles(); boolean multipleGrantees = false; while (granteeCollection.next()) { - Role role = NgCollection.roles.get(granteeCollection + Role grantee = NgCollection.roles.get(granteeCollection .getRole().getID().longValue()); // set grantee and opposed associations if (!multipleGrantees) { - permission.setGrantee(role); - role.addPermission(permission); + permission.setGrantee(grantee); + grantee.addPermission(permission); multipleGrantees = true; } else { Permission duplicatePermission = new Permission (permission); - duplicatePermission.setGrantee(role); - role.addPermission(duplicatePermission); + duplicatePermission.setGrantee(grantee); + grantee.addPermission(duplicatePermission); - long oldId = duplicatePermission.getObject().getObjectId() - + duplicatePermission.getGrantee().getRoleId(); + CcmObject object = duplicatePermission.getObject(); + long objectId = 0; + if (object != null) { + objectId = object.getObjectId(); + } + + long oldId = objectId + grantee.getRoleId(); PermissionIdMapper.map.put(oldId, duplicatePermission.getPermissionId()); - } } // grantee instance of User, new Role necessary