Skip to content

Commit

Permalink
Sonar cloud issue fix
Browse files Browse the repository at this point in the history
  • Loading branch information
fugerit79 committed Sep 15, 2023
1 parent 03e158f commit c54d8e7
Show file tree
Hide file tree
Showing 50 changed files with 411 additions and 285 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,11 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [Unreleased]

### Changed

- fj-daogen-version set to 1.2.1 in module fj-core-jvfs
- ImplFinder interface methods does not throw any exception now

## [8.3.1] - 2023-09-15

### Changed
Expand Down
2 changes: 1 addition & 1 deletion fj-core-jvfs/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
</organization>

<properties>
<fj-daogen-version>1.1.9</fj-daogen-version>
<fj-daogen-version>1.2.1</fj-daogen-version>
<gen.base.dir>${project.basedir}</gen.base.dir>
<generated.source.daogen>target/generated-sources/daogen</generated.source.daogen>
</properties>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ public class UnsafeHelper {

private UnsafeHelper() {}

private final static Logger logger = LoggerFactory.getLogger( UnsafeHelper.class );
private static final Logger logger = LoggerFactory.getLogger( UnsafeHelper.class );

public static final String UNSAFE_TRUE = BooleanUtils.BOOLEAN_TRUE;
public static final String UNSAFE_FALSE = BooleanUtils.BOOLEAN_FALSE;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -279,7 +279,7 @@ public GenericListCatalogConfig( String attTagDataList, String attTagData ) {
*
* @param <T> the type of the elements in catalog
* @param is the input stream to load from
* @param config the instance to be configured
* @param config the instance to be configured (will be configured by side effect too)
* @return the configured instance
* @throws ConfigRuntimeException in case of issues during loading
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,17 +25,17 @@ public class PropertyHolder extends BasicIdConfigType {
public static final String UNSAFE_FALSE = "false";
public static final String UNSAFE_WARN = "warn";

public final static String MODE_CLASS_LOADER = "classloader";
public final static String MODE_CL = "cl";
public static final String MODE_CLASS_LOADER = "classloader";
public static final String MODE_CL = "cl";

public final static String MODE_FILE = "file";
public static final String MODE_FILE = "file";

/**
* When this mode is used, you must define in PATH reference to other holders in the same catalog, semicolon separated.
* For instace if props-01 and props-02 are two holder in the same catalog :
* path="props01;props-02"
*/
public final static String MODE_MULTI = "multi";
public static final String MODE_MULTI = "multi";

/**
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,10 @@
import org.fugerit.java.core.db.dao.DAOException;
import org.fugerit.java.core.db.metadata.DataBaseInfo;
import org.fugerit.java.core.function.UnsafeSupplier;
import org.fugerit.java.core.lang.helpers.BooleanUtils;
import org.fugerit.java.core.lang.helpers.StringUtils;
import org.fugerit.java.core.log.BasicLogObject;
import org.fugerit.java.core.util.PropsIO;
import org.fugerit.java.core.xml.dom.DOMUtils;
import org.fugerit.java.core.xml.dom.SearchDOM;
import org.w3c.dom.Element;
Expand Down Expand Up @@ -175,11 +177,11 @@ public Connection getConnection() throws DAOException {
/**
* Parse a configuration Element looking for ConnectionFactory configuration
*
* @param cfConfig the Element
* @return the CfConfig
* @throws Exception in case of issues
* @param cfConfig the Element
* @return the CfConfig
* @throws DAOException in case of issues
*/
public static CfConfig parseCfConfig( Element cfConfig ) throws Exception {
public static CfConfig parseCfConfig( Element cfConfig ) throws DAOException {
CfConfig config = new CfConfig();
SearchDOM searchDOM = SearchDOM.newInstance( true , true );
List<Element> cfConfigEntryList = searchDOM.findAllTags( cfConfig , "cf-config-entry" );
Expand Down Expand Up @@ -215,21 +217,6 @@ public static String getDriverInfo( ConnectionFactory cf ) throws DAOException {
});
}

/**
* Helper method to create a property with prefix
*
* @param prefix the prefix
* @param name the property base name
* @return the property full name ( prefix-name, or name if prefix == null)
*/
private static String getParamName( String prefix, String name ) {
String res = name;
if ( StringUtils.isNotEmpty( prefix ) ) {
res = prefix+"-"+name;
}
return res;
}

/**
* Creates a ConnectionFactory from a property object
*
Expand All @@ -256,25 +243,24 @@ public static ConnectionFactory newInstance( Properties props, String propsPrefi
}
ConnectionFactory cf = null;
String prefix = props.getProperty( PROP_CF_MODE_DC_PREFIX, propsPrefix );
String mode = props.getProperty( getParamName( prefix, PROP_CF_MODE ) );
Properties prefixProps = props;
if ( StringUtils.isNotEmpty( prefix ) ) {
prefixProps = PropsIO.subProps( props , prefix+"-" );
log.info( "subProps : {} -> {}", prefix, prefixProps );
}
String mode = prefixProps.getProperty( PROP_CF_MODE );
log.info( "ConnectionFactory.newInstance() mode : {}", mode );
if ( PROP_CF_MODE_DC.equalsIgnoreCase( mode ) ) {
if ( "true".equalsIgnoreCase( props.getProperty( getParamName( prefix, PROP_CF_EXT_POOLED ) ) ) ) {
int sc = Integer.parseInt( props.getProperty( getParamName( prefix, PROP_CF_EXT_POOLED_SC ), "3" ) );
int ic = Integer.parseInt( props.getProperty( getParamName( prefix, PROP_CF_EXT_POOLED_IC ), "10" ) );
int mc = Integer.parseInt( props.getProperty( getParamName( prefix, PROP_CF_EXT_POOLED_MC ), "30" ) );
cf = new DbcpConnectionFactory( props.getProperty( getParamName( prefix, PROP_CF_MODE_DC_DRV ) ),
props.getProperty( getParamName( prefix, PROP_CF_MODE_DC_URL ) ),
props.getProperty( getParamName( prefix, PROP_CF_MODE_DC_USR ) ),
props.getProperty( getParamName( prefix, PROP_CF_MODE_DC_PWD ) ), sc, ic, mc, cl );
if ( BooleanUtils.isTrue( prefixProps.getProperty(PROP_CF_EXT_POOLED ) ) ) {
cf = new DbcpConnectionFactory(prefixProps, cl);
} else {
cf = newInstance( props.getProperty( getParamName( prefix, PROP_CF_MODE_DC_DRV ) ),
props.getProperty( getParamName( prefix, PROP_CF_MODE_DC_URL ) ),
props.getProperty( getParamName( prefix, PROP_CF_MODE_DC_USR ) ),
props.getProperty( getParamName( prefix, PROP_CF_MODE_DC_PWD ) ), cl );
cf = newInstance( prefixProps.getProperty( PROP_CF_MODE_DC_DRV ),
prefixProps.getProperty(PROP_CF_MODE_DC_URL ),
prefixProps.getProperty(PROP_CF_MODE_DC_USR ),
prefixProps.getProperty(PROP_CF_MODE_DC_PWD ), cl );
}
} else if ( PROP_CF_MODE_DS.equalsIgnoreCase( mode ) || PROP_CF_MODE_DS2.equalsIgnoreCase( mode ) ) {
String dsName = props.getProperty( PROP_CF_MODE_DS_NAME );
String dsName = prefixProps.getProperty( PROP_CF_MODE_DS_NAME );
log.info( "dsName -> {}", dsName );
cf = newInstance( dsName );
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
package org.fugerit.java.core.db.connect;

import java.sql.Connection;
import java.util.Properties;

import org.apache.commons.dbcp2.BasicDataSource;
import org.fugerit.java.core.db.dao.DAOException;
Expand All @@ -36,41 +37,30 @@ public class DbcpConnectionFactory extends ConnectionFactoryImpl {
private BasicDataSource dataSource;

/**
* Constructor
*
* @param drv driver type
* @param url jdbc url
* @param usr user
* @param pwd password
* @param init initial connection
* @param min minimum connection
* @param max maximum connection
* @throws DAOException in case of issues
* @param cfProps connections parameters
* @throws DAOException in case of issues
*/
public DbcpConnectionFactory( String drv, String url, String usr, String pwd, int init, int min, int max ) throws DAOException {
this(drv, url, usr, pwd, init, min, max, null);
public DbcpConnectionFactory( Properties cfProps ) throws DAOException {
this(cfProps, null);
}

/**
* Constructor
*
* @param drv driver type
* @param url jdbc url
* @param usr user
* @param pwd password
* @param init initial connection
* @param min minimum connection
* @param max maximum connection
* @param cl the class loader
* @throws DAOException in case of issues
* @param cfProps connections parameters
* @param cl to use for driver class loading
* @throws DAOException in case of issues
*/
public DbcpConnectionFactory( String drv, String url, String usr, String pwd, int init, int min, int max, ClassLoader cl ) throws DAOException {
public DbcpConnectionFactory( Properties cfProps, ClassLoader cl ) throws DAOException {
DAOException.apply( () -> {
int init = Integer.parseInt( cfProps.getProperty( PROP_CF_EXT_POOLED_SC , "3" ) );
int min = Integer.parseInt( cfProps.getProperty( PROP_CF_EXT_POOLED_IC , "10" ) );
int max = Integer.parseInt( cfProps.getProperty( PROP_CF_EXT_POOLED_MC , "30" ) );
this.dataSource = new BasicDataSource();
this.dataSource.setDriverClassName( drv );
this.dataSource.setUrl( url );
this.dataSource.setUsername( usr );
this.dataSource.setPassword( pwd );
this.dataSource.setDriverClassName( cfProps.getProperty( PROP_CF_MODE_DC_DRV ) );
this.dataSource.setUrl( cfProps.getProperty( PROP_CF_MODE_DC_URL ) );
this.dataSource.setUsername( cfProps.getProperty( PROP_CF_MODE_DC_USR ) );
this.dataSource.setPassword( cfProps.getProperty( PROP_CF_MODE_DC_PWD ) );
this.dataSource.setMaxTotal( max );
this.dataSource.setMaxIdle( min );
this.dataSource.setInitialSize( init );
Expand Down
6 changes: 3 additions & 3 deletions fj-core/src/main/java/org/fugerit/java/core/db/dao/OpDAO.java
Original file line number Diff line number Diff line change
Expand Up @@ -65,9 +65,9 @@ public static <T> OpDAO<T> newUpdateOp( String sql, FieldList fl ) {
return op;
}

public final static int TYPE_UPDATE = 0;
public final static int TYPE_QUERY = 1;
public final static int TYPE_EXECUTE = 2;
public static final int TYPE_UPDATE = 0;
public static final int TYPE_QUERY = 1;
public static final int TYPE_EXECUTE = 2;

private String sql;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ public class IdGeneratorFacade {

private IdGeneratorFacade() {}

private final static Properties SEQ_TYPES = PropsIO.loadFromClassLoaderSafe( "core/dao/idgen/seq_generator.properties" );
private static final Properties SEQ_TYPES = PropsIO.loadFromClassLoaderSafe( "core/dao/idgen/seq_generator.properties" );

public static BasicSeqIdGenerator sequenceGenerator( DAOContext context, String sequenceName ) throws DAOException {
return sequenceGenerator( context.getConnection(), sequenceName );
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,14 @@

public class SimpleServiceResult<T> {

public final static int DEFAULT_OK = Result.RESULT_CODE_OK;
public final static int DEFAULT_KO = Result.RESULT_CODE_KO;
public static final int DEFAULT_OK = Result.RESULT_CODE_OK;
public static final int DEFAULT_KO = Result.RESULT_CODE_KO;

public final static String INFO_RESULT = "result";
public final static String INFO_RESULT_MESSAGE = "resultMessage";
public static final String INFO_RESULT = "result";
public static final String INFO_RESULT_MESSAGE = "resultMessage";

public final static String INFO_ESITO_OK_NO_DATA_FOUND = String.valueOf( 2 );
public final static String INFO_ESITO_OK_MULTIPLE_RESULTS = String.valueOf( 3 );
public static final String INFO_ESITO_OK_NO_DATA_FOUND = String.valueOf( 2 );
public static final String INFO_ESITO_OK_MULTIPLE_RESULTS = String.valueOf( 3 );

public void addInfoEsito( String result, String resultMessage ) {
this.getInfo().put( INFO_RESULT , result );
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,6 @@ public static int indentifyDB( String productName ) {
dbType = DB_POSTGRESQL;
log.info( "IdGenerator configured for : POSTGRESQL ({}) was ({})", dbType, name );
} else {
dbType = DB_UNKNOWN;
log.info( "Unknown db type ({})", dbType );
}
return dbType;
Expand Down
Loading

0 comments on commit c54d8e7

Please sign in to comment.