Repository: kylin Updated Branches: refs/heads/2.0-rc 3a0e92c9a -> ec208d1ff
KYLIN-1341, display model json and update project permission fix project acl data not exist error Project: http://git-wip-us.apache.org/repos/asf/kylin/repo Commit: http://git-wip-us.apache.org/repos/asf/kylin/commit/ec208d1f Tree: http://git-wip-us.apache.org/repos/asf/kylin/tree/ec208d1f Diff: http://git-wip-us.apache.org/repos/asf/kylin/diff/ec208d1f Branch: refs/heads/2.0-rc Commit: ec208d1ff353aa5252282c304821c3c4aeb4edeb Parents: 3a0e92c Author: janzhongi <jiazh...@ebay.com> Authored: Wed Jan 27 17:27:01 2016 +0800 Committer: janzhongi <jiazh...@ebay.com> Committed: Wed Jan 27 17:27:01 2016 +0800 ---------------------------------------------------------------------- .../rest/controller/ProjectController.java | 51 ++++++++++---------- webapp/app/js/controllers/cubeModel.js | 8 +-- webapp/app/partials/cubes/cube_detail.html | 7 --- webapp/app/partials/models/model_detail.html | 9 ++-- 4 files changed, 34 insertions(+), 41 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/kylin/blob/ec208d1f/server/src/main/java/org/apache/kylin/rest/controller/ProjectController.java ---------------------------------------------------------------------- diff --git a/server/src/main/java/org/apache/kylin/rest/controller/ProjectController.java b/server/src/main/java/org/apache/kylin/rest/controller/ProjectController.java index 07fcc91..81b9dd1 100644 --- a/server/src/main/java/org/apache/kylin/rest/controller/ProjectController.java +++ b/server/src/main/java/org/apache/kylin/rest/controller/ProjectController.java @@ -112,67 +112,68 @@ public class ProjectController extends BasicController { } String userName = userDetails.getUsername(); for (ProjectInstance projectInstance : projectInstances) { + if(projectInstance == null){ + continue; + } boolean hasProjectPermission = false; AclEntity ae = accessService.getAclEntity("ProjectInstance", projectInstance.getId()); Acl projectAcl = accessService.getAcl(ae); //project no Acl info will be skipped - if(projectAcl == null){ - continue; - } + if (projectAcl != null) { - //project owner has permission - if (((PrincipalSid)projectAcl.getOwner()).getPrincipal().equals(userName)) { - readableProjects.add(projectInstance); - continue; - } + //project owner has permission + if (((PrincipalSid) projectAcl.getOwner()).getPrincipal().equals(userName)) { + readableProjects.add(projectInstance); + continue; + } - //check project permission and role - for (AccessControlEntry ace : projectAcl.getEntries()) { - if( ace.getSid() instanceof PrincipalSid && ((PrincipalSid)ace.getSid()).getPrincipal().equals(userName)) { + //check project permission and role + for (AccessControlEntry ace : projectAcl.getEntries()) { + if (ace.getSid() instanceof PrincipalSid && ((PrincipalSid) ace.getSid()).getPrincipal().equals(userName)) { hasProjectPermission = true; readableProjects.add(projectInstance); break; - }else if(ace.getSid() instanceof GrantedAuthoritySid){ - String projectAuthority = ((GrantedAuthoritySid) ace.getSid()).getGrantedAuthority(); - if(userAuthority.contains(projectAuthority)){ - hasProjectPermission = true; - readableProjects.add(projectInstance); - break; + } else if (ace.getSid() instanceof GrantedAuthoritySid) { + String projectAuthority = ((GrantedAuthoritySid) ace.getSid()).getGrantedAuthority(); + if (userAuthority.contains(projectAuthority)) { + hasProjectPermission = true; + readableProjects.add(projectInstance); + break; + } + } } - } if (!hasProjectPermission) { List<CubeInstance> cubeInstances = cubeService.listAllCubes(projectInstance.getName()); for (CubeInstance cubeInstance : cubeInstances) { - if(cubeInstance == null){ + if (cubeInstance == null) { continue; } boolean hasCubePermission = false; AclEntity cubeAe = accessService.getAclEntity("CubeInstance", cubeInstance.getId()); Acl cubeAcl = accessService.getAcl(cubeAe); //cube no Acl info will not be used to filter project - if(cubeAcl == null){ + if (cubeAcl == null) { continue; } //cube owner will have permission to read project - if (((PrincipalSid)cubeAcl.getOwner()).getPrincipal().equals(userName)) { + if (((PrincipalSid) cubeAcl.getOwner()).getPrincipal().equals(userName)) { hasProjectPermission = true; break; } for (AccessControlEntry cubeAce : cubeAcl.getEntries()) { - if (cubeAce.getSid() instanceof PrincipalSid && ((PrincipalSid)cubeAce.getSid()).getPrincipal().equals(userName)) { + if (cubeAce.getSid() instanceof PrincipalSid && ((PrincipalSid) cubeAce.getSid()).getPrincipal().equals(userName)) { hasCubePermission = true; break; - } - else if(cubeAce.getSid() instanceof GrantedAuthoritySid) { + } else if (cubeAce.getSid() instanceof GrantedAuthoritySid) { String cubeAuthority = ((GrantedAuthoritySid) cubeAce.getSid()).getGrantedAuthority(); - if(userAuthority.contains(cubeAuthority)){ + if (userAuthority.contains(cubeAuthority)) { hasCubePermission = true; break; } http://git-wip-us.apache.org/repos/asf/kylin/blob/ec208d1f/webapp/app/js/controllers/cubeModel.js ---------------------------------------------------------------------- diff --git a/webapp/app/js/controllers/cubeModel.js b/webapp/app/js/controllers/cubeModel.js index b2e2c64..f0770dd 100644 --- a/webapp/app/js/controllers/cubeModel.js +++ b/webapp/app/js/controllers/cubeModel.js @@ -29,18 +29,18 @@ KylinApp.controller('CubeModelCtrl', function ($location,$scope, $modal,cubeConf }; $scope.cleanStatus = function(model){ + var _model = angular.copy(model); - if (!model) + if (!_model) { return; } - var newModel = jQuery.extend(true, {}, model); + var newModel = jQuery.extend(true, {}, _model); delete newModel.project; delete newModel.accessEntities; delete newModel.visiblePage; delete newModel.cubes; - - return newModel; + return angular.toJson(newModel,true); }; $scope.cubeConfig = cubeConfig; http://git-wip-us.apache.org/repos/asf/kylin/blob/ec208d1f/webapp/app/partials/cubes/cube_detail.html ---------------------------------------------------------------------- diff --git a/webapp/app/partials/cubes/cube_detail.html b/webapp/app/partials/cubes/cube_detail.html index 49e2578..8b1626e 100755 --- a/webapp/app/partials/cubes/cube_detail.html +++ b/webapp/app/partials/cubes/cube_detail.html @@ -21,9 +21,6 @@ <li class="{{(!cube.visiblePage || cube.visiblePage=='metadata')? 'active':''}}"> <a href="" ng-click="cube.visiblePage='metadata'">Grid</a> </li> - <!--<li class="{{cube.visiblePage=='graph'? 'active':''}}">--> - <!--<a href="" ng-click="cube.visiblePage='graph';buildGraph(cube);">Visualization</a>--> - <!--</li>--> <li class="{{cube.visiblePage=='sql'? 'active':''}}"> <a href="" ng-click="cube.visiblePage='sql';getCubeSql(cube)">SQL</a> </li> @@ -31,10 +28,6 @@ ng-if="userService.hasRole('ROLE_ADMIN') || hasPermission(cube, 16) && !newAccess"> <a href="" ng-click="cube.visiblePage='json';">JSON(Cube)</a> </li> - <!--<li class="{{cube.visiblePage=='json_model'? 'active':''}}"--> - <!--ng-if="userService.hasRole('ROLE_ADMIN') || hasPermission(cube, 16) && !newAccess">--> - <!--<a href="" ng-click="cube.visiblePage='json_model';">JSON(Model)</a>--> - <!--</li>--> <li class="{{cube.visiblePage=='access'? 'active':''}}"> <a href="" ng-click="cube.visiblePage='access';listAccess(cube, 'CubeInstance');">Access</a> </li> http://git-wip-us.apache.org/repos/asf/kylin/blob/ec208d1f/webapp/app/partials/models/model_detail.html ---------------------------------------------------------------------- diff --git a/webapp/app/partials/models/model_detail.html b/webapp/app/partials/models/model_detail.html index df42fde..1a1b3a8 100644 --- a/webapp/app/partials/models/model_detail.html +++ b/webapp/app/partials/models/model_detail.html @@ -29,8 +29,7 @@ <li class="{{modelsManager.selectedModel.visiblePage=='graph'? 'active':''}}"> <a href="" ng-click="modelsManager.selectedModel.visiblePage='graph';buildGraph(modelsManager.selectedModel);$event.stopPropagation();">Visualization</a> </li> - <li class="{{modelsManager.selectedModel.visiblePage=='json_model'? 'active':''}}" - ng-if="userService.hasRole('ROLE_ADMIN') || hasPermission(modelsManager.selectedModel, 16) && !newAccess"> + <li class="{{modelsManager.selectedModel.visiblePage=='json_model'? 'active':''}}"> <a href="" ng-click="modelsManager.selectedModel.visiblePage='json_model';">JSON</a> </li> <li class="dropdown" ng-if="userService.hasRole('ROLE_ADMIN') || hasPermission(modelsManager.selectedModel, permissions.ADMINISTRATION.mask, permissions.MANAGEMENT.mask, permissions.OPERATION.mask)"> @@ -59,9 +58,9 @@ </div> <div ng-show="modelsManager.selectedModel.visiblePage=='graph'" id="model_graph_{{modelsManager.selectedModel.name}}" class="model-detail model_graph"> </div> - <div ng-show="modelsManager.selectedModel.visiblePage=='json_model'" class="model-detail"> - <pre ng-if="!state.jsonEdit" - style="background-color: white;border: 0px">{{angular.toJson(cleanStatus(modelsManager.selectedModel), true)}}</pre> + <div ng-show="modelsManager.selectedModel.visiblePage=='json_model'" class="cube-detail"> + <pre + style="background-color: white;border: 0px">{{cleanStatus(modelsManager.selectedModel)}}</pre> </div> </div>