use of org.pentaho.platform.plugin.action.olap.IOlapConnectionFilter in project pentaho-platform by pentaho.
the class OlapServiceImpl method makeOlap4jConnection.
private OlapConnection makeOlap4jConnection(String name) {
final Olap4jServerInfo olapServerInfo = getHelper().getOlap4jServerInfo(name);
assert olapServerInfo != null;
// Make sure the driver is present
try {
Class.forName(olapServerInfo.className);
} catch (ClassNotFoundException e) {
throw new IOlapServiceException(e);
}
// As per the JDBC specs, we can set the user/pass into
// connection properties called 'user' and 'password'.
final Properties newProps = new Properties(olapServerInfo.properties);
// First, apply the filters.
for (IOlapConnectionFilter filter : this.filters) {
filter.filterProperties(newProps);
}
// so as not to expose this.
if (olapServerInfo.user != null) {
newProps.put("user", olapServerInfo.user);
}
if (olapServerInfo.password != null) {
newProps.put("password", olapServerInfo.password);
}
try {
final Connection conn = DriverManager.getConnection(olapServerInfo.URL, newProps);
return conn.unwrap(OlapConnection.class);
} catch (SQLException e) {
throw new IOlapServiceException(e);
}
}
Aggregations