fix AccessService not returning parent obj ACL
Project: http://git-wip-us.apache.org/repos/asf/kylin/repo Commit: http://git-wip-us.apache.org/repos/asf/kylin/commit/73faf991 Tree: http://git-wip-us.apache.org/repos/asf/kylin/tree/73faf991 Diff: http://git-wip-us.apache.org/repos/asf/kylin/diff/73faf991 Branch: refs/heads/master Commit: 73faf9917a788a7875691c019501f623e91c8107 Parents: 73bd033 Author: Li Yang <[email protected]> Authored: Tue Jun 20 17:37:49 2017 +0800 Committer: Roger Shi <[email protected]> Committed: Tue Jun 20 17:58:52 2017 +0800 ---------------------------------------------------------------------- .../kylin/rest/service/AccessService.java | 20 +++++++++----------- 1 file changed, 9 insertions(+), 11 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/kylin/blob/73faf991/server-base/src/main/java/org/apache/kylin/rest/service/AccessService.java ---------------------------------------------------------------------- diff --git a/server-base/src/main/java/org/apache/kylin/rest/service/AccessService.java b/server-base/src/main/java/org/apache/kylin/rest/service/AccessService.java index 9ae372a..8b96635 100644 --- a/server-base/src/main/java/org/apache/kylin/rest/service/AccessService.java +++ b/server-base/src/main/java/org/apache/kylin/rest/service/AccessService.java @@ -19,7 +19,6 @@ package org.apache.kylin.rest.service; import java.util.ArrayList; -import java.util.Collections; import java.util.List; import org.apache.kylin.common.persistence.AclEntity; @@ -298,18 +297,16 @@ public class AccessService { } public List<AccessEntryResponse> generateAceResponses(Acl acl) { - if (null == acl) { - return Collections.emptyList(); - } - List<AccessEntryResponse> accessControlEntities = new ArrayList<AccessEntryResponse>(); + List<AccessEntryResponse> result = new ArrayList<AccessEntryResponse>(); - // Cause there is a circle reference in AccessControlEntry, it needs to - // set acl to null as a workaround. - for (AccessControlEntry ace : acl.getEntries()) { - accessControlEntities.add(new AccessEntryResponse(ace.getId(), ace.getSid(), ace.getPermission(), ace.isGranting())); + while (acl != null) { + for (AccessControlEntry ace : acl.getEntries()) { + result.add(new AccessEntryResponse(ace.getId(), ace.getSid(), ace.getPermission(), ace.isGranting())); + } + acl = acl.getParentAcl(); } - return accessControlEntities; + return result; } /** @@ -322,7 +319,8 @@ public class AccessService { Message msg = MsgPicker.getMsg(); // Can't revoke admin permission from domain object owner - if (acl.getOwner().equals(acl.getEntries().get(indexOfAce).getSid()) && BasePermission.ADMINISTRATION.equals(acl.getEntries().get(indexOfAce).getPermission())) { + if (acl.getOwner().equals(acl.getEntries().get(indexOfAce).getSid()) + && BasePermission.ADMINISTRATION.equals(acl.getEntries().get(indexOfAce).getPermission())) { throw new ForbiddenException(msg.getREVOKE_ADMIN_PERMISSION()); } }
