private boolean setRole(ISaikuConnection con, String[] validMondrianRolesForUser, SaikuDatasource datasource) {
if (con.getConnection() instanceof OlapConnection)
{
try {
OlapConnection c = (OlapConnection) con.getConnection();
String roles = "";
if (validMondrianRolesForUser != null && validMondrianRolesForUser.length > 0) {
for (String r : validMondrianRolesForUser) {
// lets make sure the role is actually available, just to be safe
if (c.getAvailableRoleNames().contains(r)) {
roles += r +",";
}
}
System.out.println("Setting role to datasource:" + datasource.getName() + " role: " + roles);
if (validMondrianRolesForUser != null && validMondrianRolesForUser.length == 0) {
return true;
}
else if (validMondrianRolesForUser != null && validMondrianRolesForUser.length == 1) {
c.setRoleName(validMondrianRolesForUser[0]);
} else {
SaikuMondrianHelper.setRoles(c, validMondrianRolesForUser);
}
} else {
c.setRoleName(null);
}
return true;
} catch (Exception e) {