2
votes

I have a Mondrian server webapp up and running to handle MDX queries, fetch data from the OLAP cubes defined in our Mondrian Schema, and return the XMLA required by the front-end GUI application to show the queried data.

That all works, but now I'm trying to add permission Roles, and I've stumbled upon a very confusing problem.

Now I thought this would be as easy as to add another parameter "role" and send that. However, this is throwing me an odd error.

I'm using SmartGWT to connect to the Mondrian XMLA service.

    public static OlapConnection getConnection() throws Exception {
    Class.forName("org.olap4j.driver.xmla.XmlaOlap4jDriver");
    java.util.Properties p = new Properties();
    String role = "role1";
    p.put("server", "http://domain.be:8080/mondrian/xmla");
    p.put("user", "user");
    p.put("password", "password");
    p.put("role","\""+role+"\"");
    String dbUrl = "jdbc:xmla:";
    Connection connectionXMLA = DriverManager.getConnection(dbUrl, p);
    OlapWrapper wrapper = (OlapWrapper) connectionXMLA;
    OlapConnection olapConnection = wrapper.unwrap(OlapConnection.class);
    return olapConnection;

Roles are defined in the schema which also holds the cube, as this:

<Role name="role1">
<SchemaGrant access="none">
      <CubeGrant cube="VehicleSales" access="all"/>
  <CubeGrant cube="Contract" access="none"/>
</SchemaGrant>

<Role name="role2">
<SchemaGrant access="none">
      <CubeGrant cube="VehicleSales" access="none"/>
  <CubeGrant cube="Contract" access="all"/>
</SchemaGrant>

When using the "role" parameter, I get this error:

12:30:50.930 [ERROR] [smartgwtolap] 12:30:50.928:TMR9:WARN:RPCManager:org.olap4j.OlapException: XMLA

provider gave exception:

<faultcode>
    SOAP-ENV:Server.00HSBB01
</faultcode>
<faultstring>
    XMLA SOAP Body processing error
</faultstring>
<faultactor>
    Mondrian
</faultactor>
<detail>
    <XA:error xmlns:XA="mondrian sourceforge net">
        <code>
            00HSBB01
        </code>
        <desc>
            The Mondrian XML: Mondrian Error:Internal error: Rowset 'DISCOVER_PROPERTIES' does not support property 'Roles'
        </desc>
    </XA:error>
</detail>
 </SOAP-ENV:Fault>

Request was: DISCOVER_PROPERTIES &quot;role1&quot; Data undefined - response: {operationId: "listCubes_fetch", clientContext: Obj, context: Obj, transactionNum: 0, httpResponseCode: 200, httpResponseText: "//isc_RPCResponseStart-->[{"data":"org.o..."[1497], xmlHttpRequest: Obj, transport: "xmlHttpRequest", status: -1, clientOnly: undef, httpHeaders: Obj, isStructured: true, callbackArgs: null, results: Obj, data: "org.olap4j.OlapException: XMLA provider ..."[1243], invalidateCache: false, isDSResponse: true, queueStatus: -1, startRow: 0, endRow: 0, totalRows: 0} com.smartgwt.client.core.JsObject$SGWT_WARN: 12:30:50.928:TMR9:WARN:RPCManager:org.olap4j.OlapException: XMLA provider gave exception: SOAP-ENV:Server.00HSBB01 XMLA SOAP Body processing error Mondrian 00HSBB01 The Mondrian XML: Mondrian Error:Internal error: Rowset 'DISCOVER_PROPERTIES' does not support property 'Roles'
Request was: DISCOVER_PROPERTIES &quot;role1&quot; Data undefined - response: {operationId: "listCubes_fetch", clientContext: Obj, context: Obj, transactionNum: 0, httpResponseCode: 200, httpResponseText: "//isc_RPCResponseStart-->[{"data":"org.o..."[1497], xmlHttpRequest: Obj, transport: "xmlHttpRequest", status: -1, clientOnly: undef, httpHeaders: Obj, isStructured: true, callbackArgs: null, results: Obj, data: "org.olap4j.OlapException: XMLA provider ..."[1243], invalidateCache: false, isDSResponse: true, queueStatus: -1, startRow: 0, endRow: 0, totalRows: 0} at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source) at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source) at java.lang.reflect.Constructor.newInstance(Unknown Source) at com.google.gwt.dev.shell.MethodAdaptor.invoke(MethodAdaptor.java:105) at com.google.gwt.dev.shell.MethodDispatch.invoke(MethodDispatch.java:71) at com.google.gwt.dev.shell.OophmSessionHandler.invoke(OophmSessionHandler.java:172) at com.google.gwt.dev.shell.BrowserChannelServer.reactToMessages(BrowserChannelServer.java:293) at com.google.gwt.dev.shell.BrowserChannelServer.processConnection(BrowserChannelServer.java:547) at com.google.gwt.dev.shell.BrowserChannelServer.run(BrowserChannelServer.java:364) at java.lang.Thread.run(Unknown Source)

Other random parameters, such as "foo" or "bar", return no error whatsoever and are simply ignored. So "role" definitely does trigger something, but sadly not anything I can work with.

Anyone that can offer some insight? It is very much appreciated. I have found something about the Pentaho XmlaHandler which accepts a role as an argument, but this seems to be something used inside of Mondrian and not necessarily something I can immediately use in SmartGWT - I think.

Thanks for reading!

EDIT

The snippet below returns error:

java.lang.RuntimeException: org.olap4j.OlapException: Failed to obtain the database product name.

        Connection connectionXMLA = DriverManager.getConnection(dbUrl, p);
    OlapWrapper wrapper = (OlapWrapper) connectionXMLA;
    OlapConnection olapConnection = wrapper.unwrap(OlapConnection.class);
    String role = "role2";
    olapConnection.setRoleName(role);
    return olapConnection;

getAvailableRoleNames() function does return the roles specified in the schema file. If I comment out the setRoleName(role) part it works just fine.

1

1 Answers

0
votes

This isn't the way to set a role in olap4j. Try using OlapConnection.setRoleName.