kylin-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From billy...@apache.org
Subject kylin git commit: KYLIN-3223 - Query for the list of hybrid cubes results in NPE
Date Fri, 09 Feb 2018 02:51:27 GMT
Repository: kylin
Updated Branches:
  refs/heads/master 50435e114 -> 0655dbc38


KYLIN-3223 - Query for the list of hybrid cubes results in NPE

Signed-off-by: Billy Liu <billyliu@apache.org>


Project: http://git-wip-us.apache.org/repos/asf/kylin/repo
Commit: http://git-wip-us.apache.org/repos/asf/kylin/commit/0655dbc3
Tree: http://git-wip-us.apache.org/repos/asf/kylin/tree/0655dbc3
Diff: http://git-wip-us.apache.org/repos/asf/kylin/diff/0655dbc3

Branch: refs/heads/master
Commit: 0655dbc383790f61ef9b04cd23b6b6ebf5f2ff6e
Parents: 50435e1
Author: Seva Ostapenko <seva@anovadata.com>
Authored: Thu Feb 8 16:27:50 2018 -0500
Committer: Billy Liu <billyliu@apache.org>
Committed: Fri Feb 9 10:51:17 2018 +0800

----------------------------------------------------------------------
 .../kylin/rest/service/HybridService.java       | 49 ++++++++++++++------
 1 file changed, 34 insertions(+), 15 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/kylin/blob/0655dbc3/server-base/src/main/java/org/apache/kylin/rest/service/HybridService.java
----------------------------------------------------------------------
diff --git a/server-base/src/main/java/org/apache/kylin/rest/service/HybridService.java b/server-base/src/main/java/org/apache/kylin/rest/service/HybridService.java
index de20e7c..eebc991 100644
--- a/server-base/src/main/java/org/apache/kylin/rest/service/HybridService.java
+++ b/server-base/src/main/java/org/apache/kylin/rest/service/HybridService.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.commons.lang.StringUtils;
@@ -35,6 +34,7 @@ import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Component;
+import org.springframework.security.access.AccessDeniedException;
 
 @Component("hybridService")
 public class HybridService extends BasicService {
@@ -113,32 +113,51 @@ public class HybridService extends BasicService {
     }
 
     public List<HybridInstance> listHybrids(final String projectName, final String
modelName) {
-        aclEvaluate.checkProjectReadPermission(projectName);
-        ProjectInstance project = (null != projectName) ? getProjectManager().getProject(projectName)
: null;
-        List<HybridInstance> hybridsInProject = new ArrayList<HybridInstance>();
-
+        List<HybridInstance> allHybrids = new ArrayList<HybridInstance>();
         if (StringUtils.isEmpty(projectName)) {
-            hybridsInProject = new ArrayList(getHybridManager().listHybridInstances());
-        } else if (project == null) {
-            return Collections.emptyList();
+            List<ProjectInstance> allProjectInstances = getProjectManager().listAllProjects();
+            List<ProjectInstance> readableProjects = new ArrayList<ProjectInstance>();
+            for (ProjectInstance projectInstance : allProjectInstances) {
+                if (projectInstance == null) {
+                    continue;
+                }
+                boolean hasReadAccess = false;
+                try {
+                    hasReadAccess = aclEvaluate.hasProjectReadPermission(projectInstance);
+                } catch (AccessDeniedException e) {
+                    //ignore to continue
+                }
+                if (hasReadAccess) {
+                    readableProjects.add(projectInstance);
+                }
+            }
+            for (ProjectInstance projectInstance : readableProjects) {
+                List<RealizationEntry> realizationEntries = projectInstance.getRealizationEntries(RealizationType.HYBRID);
+                if (realizationEntries != null) {
+                    for (RealizationEntry entry : realizationEntries) {
+                        HybridInstance instance = getHybridManager().getHybridInstance(entry.getRealization());
+                        allHybrids.add(instance);
+                    }
+                }
+            }
         } else {
-            List<RealizationEntry> realizationEntries = project.getRealizationEntries(RealizationType.HYBRID);
+            aclEvaluate.checkProjectReadPermission(projectName);
+            ProjectInstance projectInstance = getProjectManager().getProject(projectName);
+            List<RealizationEntry> realizationEntries = projectInstance.getRealizationEntries(RealizationType.HYBRID);
             if (realizationEntries != null) {
                 for (RealizationEntry entry : realizationEntries) {
                     HybridInstance instance = getHybridManager().getHybridInstance(entry.getRealization());
-                    hybridsInProject.add(instance);
+                    allHybrids.add(instance);
                 }
             }
         }
 
-        DataModelDesc model = (null != modelName) ? getDataModelManager().getDataModelDesc(modelName)
: null;
         if (StringUtils.isEmpty(modelName)) {
-            return hybridsInProject;
-        } else if (model == null) {
-            return Collections.emptyList();
+            return allHybrids;
         } else {
+            DataModelDesc model = getMetadataManager().getDataModelDesc(modelName);
             List<HybridInstance> hybridsInModel = new ArrayList<HybridInstance>();
-            for (HybridInstance hybridInstance : hybridsInProject) {
+            for (HybridInstance hybridInstance : allHybrids) {
                 boolean hybridInModel = false;
                 for (RealizationEntry entry : hybridInstance.getRealizationEntries()) {
                     CubeDesc cubeDesc = getCubeDescManager().getCubeDesc(entry.getRealization());


Mime
View raw message