Search in sources :

Example 16 with IOlapServiceException

use of org.pentaho.platform.plugin.action.olap.IOlapServiceException 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);
    }
}
Also used : IOlapConnectionFilter(org.pentaho.platform.plugin.action.olap.IOlapConnectionFilter) SQLException(java.sql.SQLException) Connection(java.sql.Connection) RolapConnection(mondrian.rolap.RolapConnection) OlapConnection(org.olap4j.OlapConnection) MDXConnection(org.pentaho.platform.plugin.services.connections.mondrian.MDXConnection) IOlapServiceException(org.pentaho.platform.plugin.action.olap.IOlapServiceException) Olap4jServerInfo(org.pentaho.platform.plugin.services.importexport.legacy.MondrianCatalogRepositoryHelper.Olap4jServerInfo) RolapConnectionProperties(mondrian.rolap.RolapConnectionProperties) Properties(java.util.Properties)

Example 17 with IOlapServiceException

use of org.pentaho.platform.plugin.action.olap.IOlapServiceException in project pentaho-platform by pentaho.

the class OlapServiceImpl method flush.

/**
 * Flushes a single schema from the cache.
 */
public void flush(IPentahoSession session, String name) {
    final Lock writeLock = cacheLock.writeLock();
    writeLock.lock();
    try (OlapConnection connection = getConnection(name, session)) {
        final RolapConnection rc = connection.unwrap(RolapConnection.class);
        rc.getCacheControl(null).flushSchema(rc.getSchema());
    } catch (Exception e) {
        LOG.warn(Messages.getInstance().getErrorString("MondrianCatalogHelper.ERROR_0019_FAILED_TO_FLUSH", name), e);
        throw new IOlapServiceException(Messages.getInstance().getErrorString("MondrianCatalogHelper.ERROR_0019_FAILED_TO_FLUSH", name));
    } finally {
        writeLock.unlock();
    }
}
Also used : RolapConnection(mondrian.rolap.RolapConnection) OlapConnection(org.olap4j.OlapConnection) IOlapServiceException(org.pentaho.platform.plugin.action.olap.IOlapServiceException) PentahoAccessControlException(org.pentaho.platform.api.engine.PentahoAccessControlException) FileSystemException(org.apache.commons.vfs2.FileSystemException) OlapException(org.olap4j.OlapException) SQLException(java.sql.SQLException) IOlapServiceException(org.pentaho.platform.plugin.action.olap.IOlapServiceException) ReadWriteLock(java.util.concurrent.locks.ReadWriteLock) ReentrantReadWriteLock(java.util.concurrent.locks.ReentrantReadWriteLock) Lock(java.util.concurrent.locks.Lock)

Aggregations

IOlapServiceException (org.pentaho.platform.plugin.action.olap.IOlapServiceException)17 Test (org.junit.Test)8 SQLException (java.sql.SQLException)6 Matchers.anyString (org.mockito.Matchers.anyString)6 Properties (java.util.Properties)5 RolapConnectionProperties (mondrian.rolap.RolapConnectionProperties)5 FileSystemException (org.apache.commons.vfs2.FileSystemException)5 OlapException (org.olap4j.OlapException)5 PentahoAccessControlException (org.pentaho.platform.api.engine.PentahoAccessControlException)5 Lock (java.util.concurrent.locks.Lock)4 ReadWriteLock (java.util.concurrent.locks.ReadWriteLock)4 ReentrantReadWriteLock (java.util.concurrent.locks.ReentrantReadWriteLock)4 RolapConnection (mondrian.rolap.RolapConnection)4 OlapConnection (org.olap4j.OlapConnection)4 IPentahoSession (org.pentaho.platform.api.engine.IPentahoSession)4 RepositoryFilePermission (org.pentaho.platform.api.repository2.unified.RepositoryFilePermission)3 InputStream (java.io.InputStream)2 Connection (java.sql.Connection)2 Callable (java.util.concurrent.Callable)2 IOlapConnectionFilter (org.pentaho.platform.plugin.action.olap.IOlapConnectionFilter)2