Skip to content

Commit

Permalink
chore: light improvements on readability
Browse files Browse the repository at this point in the history
(cherry picked from commit 4e8d594)
  • Loading branch information
befc authored and smmribeiro committed Dec 9, 2024
1 parent 4da843b commit 180052b
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -116,8 +116,7 @@ public static IPentahoConnection getConnection( final String datasourceType, Pro
IPentahoConnection connection = null;
try {
//Validate if properties connection name is system DB and do not allow connection
if ( isSystemConnection( properties ) &&
!hasSystemDataSourcePermission( session ) ) {
if ( isSystemConnection( properties ) && !hasSystemDataSourcePermission( session ) ) {
throw new ObjectFactoryException( "Missing required permissions to make connection" );
}
connection = PentahoSystem.getObjectFactory().get( IPentahoConnection.class, key, session );
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -553,7 +553,7 @@ public boolean isClosed() {
*
* @see org.pentaho.connection.IPentahoConnection#isReadOnly()
*
* Right now this archetecture only support selects (read only)
* Right now this architecture only support selects (read only)
*/
public boolean isReadOnly() {
return true;
Expand All @@ -572,9 +572,8 @@ public IPentahoResultSet getResultSet() {
}

void initDataSource( IDatabaseConnection databaseConnection ) {
DataSource dataSource = null;
try {
dataSource = PooledDatasourceHelper.setupPooledDataSource( databaseConnection );
DataSource dataSource = PooledDatasourceHelper.setupPooledDataSource( databaseConnection );
nativeConnection = captureConnection( dataSource.getConnection() );
} catch ( Exception e ) {
logger.error( "Can't get connection from Pool", e );
Expand All @@ -584,11 +583,11 @@ void initDataSource( IDatabaseConnection databaseConnection ) {
public boolean connect( final Properties props ) {
close();
String jndiName = props.getProperty( IPentahoConnection.JNDI_NAME_KEY );
if ( ( jndiName != null ) && ( jndiName.length() > 0 ) ) {
if ( jndiName != null && !jndiName.isEmpty() ) {
initWithJNDI( jndiName );
} else {
String connectionName = props.getProperty( IPentahoConnection.CONNECTION_NAME );
if ( ( connectionName != null ) && ( connectionName.length() > 0 ) ) {
if ( connectionName != null && !connectionName.isEmpty() ) {
IDatabaseConnection databaseConnection = (IDatabaseConnection) props.get( IPentahoConnection.CONNECTION );
initDataSource( databaseConnection );
} else {
Expand All @@ -598,7 +597,7 @@ public boolean connect( final Properties props ) {
String password = props.getProperty( IPentahoConnection.PASSWORD_KEY );
init( driver, provider, userName, password );
String query = props.getProperty( IPentahoConnection.QUERY_KEY );
if ( ( query != null ) && ( query.length() > 0 ) ) {
if ( query != null && !query.isEmpty() ) {
try {
executeQuery( query );
} catch ( Exception e ) {
Expand All @@ -607,7 +606,7 @@ public boolean connect( final Properties props ) {
}
}
}
return ( ( nativeConnection != null ) && !isClosed() );
return ( nativeConnection != null && !isClosed() );
}

public int execute( final String query ) throws SQLException {
Expand Down

0 comments on commit 180052b

Please sign in to comment.