Skip to content

Commit

Permalink
Add OlapConnection.getAvailableRoleNames().
Browse files Browse the repository at this point in the history
git-svn-id: https://olap4j.svn.sourceforge.net/svnroot/olap4j/trunk@296 c6a108a4-781c-0410-a6c6-c2d559e19af0
  • Loading branch information
julianhyde committed Jan 7, 2010
1 parent 32990d3 commit b0ef48c
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 5 deletions.
12 changes: 11 additions & 1 deletion src/org/olap4j/OlapConnection.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
// This software is subject to the terms of the Eclipse Public License v1.0
// Agreement, available at the following URL:
// http://www.eclipse.org/legal/epl-v10.html.
// Copyright (C) 2006-2008 Julian Hyde
// Copyright (C) 2006-2010 Julian Hyde
// All Rights Reserved.
// You must accept the terms of that agreement to use this software.
*/
Expand All @@ -13,6 +13,7 @@
import org.olap4j.metadata.*;

import java.sql.Connection;
import java.util.List;
import java.util.Locale;

/**
Expand Down Expand Up @@ -114,6 +115,15 @@ public interface OlapConnection extends Connection, OlapWrapper {
*/
String getRoleName();

/**
* Returns a list of the names of roles that are available for this user to
* execute queries.
*
* @return a list of role names, or null if the available roles are not
* known
*/
List<String> getAvailableRoleNames();

/**
* Creates a Scenario.
*
Expand Down
8 changes: 7 additions & 1 deletion src/org/olap4j/driver/xmla/XmlaOlap4jConnection.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// This software is subject to the terms of the Eclipse Public License v1.0
// Agreement, available at the following URL:
// http://www.eclipse.org/legal/epl-v10.html.
// Copyright (C) 2007-2009 Julian Hyde
// Copyright (C) 2007-2010 Julian Hyde
// All Rights Reserved.
// You must accept the terms of that agreement to use this software.
*/
Expand Down Expand Up @@ -620,6 +620,12 @@ public String getRoleName() {
return roleName;
}

public List<String> getAvailableRoleNames() {
// List of available roles is not known. Could potentially add an XMLA
// call to populate this list if useful to a client.
return null;
}

public Scenario createScenario() {
throw new UnsupportedOperationException();
}
Expand Down
20 changes: 17 additions & 3 deletions testsrc/org/olap4j/ConnectionTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
// This software is subject to the terms of the Eclipse Public License v1.0
// Agreement, available at the following URL:
// http://www.eclipse.org/legal/epl-v10.html.
// Copyright (C) 2007-2009 Julian Hyde
// Copyright (C) 2007-2010 Julian Hyde
// All Rights Reserved.
// You must accept the terms of that agreement to use this software.
*/
Expand Down Expand Up @@ -291,6 +291,20 @@ public void testConnectionUnwrap() throws SQLException {
olapConnection.setLocale(Locale.getDefault());
}

// Get, set role, get available role names.
final String s = olapConnection.getRoleName(); // ok if s is null
olapConnection.setRoleName(null);
assertNull(olapConnection.getRoleName());
olapConnection.setRoleName(s);
// ok if role names list is null
final List<String> roleNames = olapConnection.getAvailableRoleNames();
if (roleNames != null && s != null) {
assertTrue(
"role name " + s + " should be in available role names "
+ roleNames,
roleNames.contains(s));
}

// Unwrap the mondrian connection.
switch (tester.getFlavor()) {
case MONDRIAN:
Expand Down Expand Up @@ -1389,7 +1403,7 @@ public void testBuildParseTree() {
}

/**
* Tests the {@link Cube#lookupMember(String[])} method.
* Tests the {@link Cube#lookupMember(String...)} method.
*/
public void testCubeLookupMember() throws Exception {
Class.forName(tester.getDriverClassName());
Expand Down Expand Up @@ -1436,7 +1450,7 @@ public void testCubeLookupMember() throws Exception {
}

/**
* Tests the {@link Cube#lookupMembers(java.util.Set, String[])} method.
* Tests the {@link Cube#lookupMembers(java.util.Set, String...)} method.
*/
public void testCubeLookupMembers() throws Exception {
Class.forName(tester.getDriverClassName());
Expand Down

0 comments on commit b0ef48c

Please sign in to comment.