mysticfall / pivot4j

Pivot4J provides a common API for OLAP servers which can be used to build an analytical service frontend with pivot style GUI.
Other
128 stars 101 forks source link

Error on get catalogs for granted cubes (pentaho plugin) #201

Closed mariogaitan closed 8 years ago

mariogaitan commented 8 years ago

For pentaho plugin, when a granted cube is assigned to a user without permissions, just a blank tab appear for create a new report... Below I show what appears in log file. By the way, you have a great software, thanks!!! I temporary fix this problem in class org.pivot4j.pentaho.datasource.PentahoDataSourceManager, in function public List getCatalogs():

    @Override
    public List<CatalogInfo> getCatalogs() {
        List<MondrianCatalog> catalogs = catalogService.listCatalogs(session,
                false);
        List<CatalogInfo> result = new LinkedList<CatalogInfo>();
        for (MondrianCatalog catalog : catalogs) {
            List<CubeInfo> cubes = Collections.emptyList();
            try {
                cubes = getCubes(catalog.getName());
            } catch(Exception e) {
                /*IGNORE EXCEPTION BECAUSE, THERE COULD BE MORE VALID CATALOGS*/
            }
            if (!cubes.isEmpty()) {
                result.add(new CatalogInfo(catalog.getName(),
                        catalog.getName(), catalog.getDefinition()));
            }
        }

        return result;
    }

LOG FILE:

Caused by: java.lang.reflect.InvocationTargetException
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:606)
    at org.apache.catalina.core.DefaultInstanceManager.postConstruct(DefaultInstanceManager.java:205)
    at org.apache.catalina.core.DefaultInstanceManager.newInstance(DefaultInstanceManager.java:145)
    at org.apache.catalina.core.DefaultInstanceManager.newInstance(DefaultInstanceManager.java:136)
    at org.apache.myfaces.config.annotation.Tomcat7AnnotationLifecycleProvider.postConstruct(Tomcat7AnnotationLifecyclePro
vider.java:94)
    at org.apache.myfaces.config.ManagedBeanBuilder.buildManagedBean(ManagedBeanBuilder.java:213)
    ... 95 more
Caused by: javax.faces.FacesException: org.pentaho.platform.api.engine.PentahoAccessControlException: MondrianOneToOneUserRoleListMapper.ERROR_001_ - Access is denied because the roles of this user don't correspond to any present in the Mondrian schema requested.
    at org.pivot4j.pentaho.datasource.PentahoDataSourceManager.createDataSource(PentahoDataSourceManager.java:284)
    at org.pivot4j.pentaho.datasource.PentahoDataSourceManager.getCubes(PentahoDataSourceManager.java:144)
    at org.pivot4j.pentaho.datasource.PentahoDataSourceManager.getCatalogs(PentahoDataSourceManager.java:108)
    at org.pivot4j.analytics.state.ViewStateHolder.createNewState(ViewStateHolder.java:247)
    at org.pivot4j.analytics.ui.RepositoryHandler.initialize(RepositoryHandler.java:81)
    ... 104 more
Caused by: org.pentaho.platform.api.engine.PentahoAccessControlException: MondrianOneToOneUserRoleListMapper.ERROR_001_ - Access is denied because the roles of this user don't correspond to any present in the Mondrian schema requested.
    at org.pentaho.platform.plugin.action.mondrian.mapper.MondrianOneToOneUserRoleListMapper.mapRoles(MondrianOneToOneUserRoleListMapper.java:77)
    at org.pentaho.platform.plugin.action.mondrian.mapper.MondrianAbstractPlatformUserRoleMapper.mapConnectionRoles(MondrianAbstractPlatformUserRoleMapper.java:187)
    at org.pivot4j.pentaho.datasource.PentahoDataSourceManager.createDataSource(PentahoDataSourceManager.java:273)
    ... 108 more
mysticfall commented 8 years ago

As we already handle PentahoAccessControlException in the createDataSource method, I just changed it not to rethrow the error.

It might work in a slightly different way than the one you proposed (like showing empty catalogs), but it won't interrupt with the functionality like before.

Please let me know if it does not work as expected. I'll build a new snapshot now, and it will be included in the next version of Pentaho plugin.

Thanks much for the report!