diff options
author | Christopher Lott (cl778h) <clott@research.att.com> | 2017-06-13 14:33:51 -0400 |
---|---|---|
committer | Christopher Lott (cl778h) <clott@research.att.com> | 2017-06-13 15:09:24 -0400 |
commit | a91868b4d461d903c2e0ef78a75afe89385bc7e9 (patch) | |
tree | 22ee5f9f096e0e650cf2804c6281233c63df5ab9 /ecomp-sdk/epsdk-core/src/main | |
parent | 0b2b3270d23bc1bec003f7bda3e6b4babd41ba38 (diff) |
[PORTAL-15] RAPTOR reporting fixes
Also repairs a bug in the user-management overlay screen.
Ticket number all caps this time.
Restore epsdk-app-os pom -SNAPSHOT suffix
Change-Id: I7ef620c4ebc52259bcf474908bc4810dfd7e41e7
Signed-off-by: Christopher Lott (cl778h) <clott@research.att.com>
Diffstat (limited to 'ecomp-sdk/epsdk-core/src/main')
-rw-r--r-- | ecomp-sdk/epsdk-core/src/main/java/org/openecomp/portalsdk/core/conf/AppConfig.java | 69 | ||||
-rw-r--r-- | ecomp-sdk/epsdk-core/src/main/java/org/openecomp/portalsdk/core/util/SystemProperties.java | 10 |
2 files changed, 47 insertions, 32 deletions
diff --git a/ecomp-sdk/epsdk-core/src/main/java/org/openecomp/portalsdk/core/conf/AppConfig.java b/ecomp-sdk/epsdk-core/src/main/java/org/openecomp/portalsdk/core/conf/AppConfig.java index 95f149ae..10d71872 100644 --- a/ecomp-sdk/epsdk-core/src/main/java/org/openecomp/portalsdk/core/conf/AppConfig.java +++ b/ecomp-sdk/epsdk-core/src/main/java/org/openecomp/portalsdk/core/conf/AppConfig.java @@ -171,27 +171,23 @@ public class AppConfig extends WebMvcConfigurerAdapter implements Configurable, /** * - * Application Data Source + * Creates the Application Data Source. * * @return DataSource Object + * @throws Exception + * on failure to create data source object */ - @Bean public DataSource dataSource() throws Exception { - + systemProperties(); - - Boolean testConnectionOnCheckout = getConnectionOnCheckout(); - String preferredTestQuery = getPreferredTestQuery(); - ComboPooledDataSource dataSource = new ComboPooledDataSource(); try { dataSource.setDriverClass(SystemProperties.getProperty(SystemProperties.DB_DRIVER)); dataSource.setJdbcUrl(SystemProperties.getProperty(SystemProperties.DB_CONNECTIONURL)); dataSource.setUser(SystemProperties.getProperty(SystemProperties.DB_USERNAME)); - // dataSource.setPassword(SystemProperties.getProperty(SystemProperties.DB_PASSWOR)); - String password = SystemProperties.getProperty(SystemProperties.DB_PASSWOR); + String password = SystemProperties.getProperty(SystemProperties.DB_PASSWORD); if (SystemProperties.containsProperty(SystemProperties.DB_ENCRYPT_FLAG)) { String encryptFlag = SystemProperties.getProperty(SystemProperties.DB_ENCRYPT_FLAG); if (encryptFlag != null && encryptFlag.equalsIgnoreCase("true")) { @@ -205,9 +201,8 @@ public class AppConfig extends WebMvcConfigurerAdapter implements Configurable, .setMaxPoolSize(Integer.parseInt(SystemProperties.getProperty(SystemProperties.DB_MAX_POOL_SIZE))); dataSource.setIdleConnectionTestPeriod( Integer.parseInt(SystemProperties.getProperty(SystemProperties.IDLE_CONNECTION_TEST_PERIOD))); - dataSource.setTestConnectionOnCheckout(testConnectionOnCheckout); - dataSource.setPreferredTestQuery(preferredTestQuery); - + dataSource.setTestConnectionOnCheckout(getConnectionOnCheckout()); + dataSource.setPreferredTestQuery(getPreferredTestQuery()); } catch (Exception e) { logger.error(EELFLoggerDelegate.errorLogger, "Error initializing database, verify database settings in properties file: " @@ -217,37 +212,55 @@ public class AppConfig extends WebMvcConfigurerAdapter implements Configurable, "Error initializing database, verify database settings in properties file: " + UserUtils.getStackTrace(e), AlarmSeverityEnum.CRITICAL); - // Raise an alarm that opening a connection to the database is - // failed. + // Raise an alarm that opening a connection to the database failed. logger.logEcompError(AppMessagesEnum.BeDaoSystemError); throw e; } return dataSource; } + /** + * Gets the value of the property + * {@link SystemProperties#PREFERRED_TEST_QUERY}; defaults to "Select 1" if + * the property is not defined. + * + * @return String value that is a SQL query + */ private String getPreferredTestQuery() { - String preferredTestQueryStr = null; - try { + // Use simple default + String preferredTestQueryStr = "SELECT 1"; + if (SystemProperties.containsProperty(SystemProperties.PREFERRED_TEST_QUERY)) { preferredTestQueryStr = SystemProperties.getProperty(SystemProperties.PREFERRED_TEST_QUERY); - } catch (Exception e) { + logger.debug(EELFLoggerDelegate.debugLogger, "getPreferredTestQuery: property key {} value is {}", + SystemProperties.PREFERRED_TEST_QUERY, preferredTestQueryStr); + } else { logger.info(EELFLoggerDelegate.errorLogger, - SystemProperties.PREFERRED_TEST_QUERY + " value not found " - + UserUtils.getStackTrace(e)); + "getPreferredTestQuery: property key {} not found, using default value {}", + SystemProperties.PREFERRED_TEST_QUERY, preferredTestQueryStr); } - String preferredTestQuery = ((preferredTestQueryStr == null) ? "SELECT 1" : preferredTestQueryStr); - return preferredTestQuery; + return preferredTestQueryStr; } + /** + * Gets the value of the property + * {@link SystemProperties#TEST_CONNECTION_ON_CHECKOUT}; defaults to true if + * the property is not defined. + * + * @return Boolean value + */ private Boolean getConnectionOnCheckout() { - String testConnectionOnCheckoutStr = null; - try { - testConnectionOnCheckoutStr = SystemProperties.getProperty(SystemProperties.TEST_CONNECTION_ON_CHECKOUT); - } catch (Exception e) { + // Default to true, always test connection + boolean testConnectionOnCheckout = true; + if (SystemProperties.containsProperty(SystemProperties.TEST_CONNECTION_ON_CHECKOUT)) { + testConnectionOnCheckout = Boolean + .valueOf(SystemProperties.getProperty(SystemProperties.TEST_CONNECTION_ON_CHECKOUT)); + logger.debug(EELFLoggerDelegate.debugLogger, "getConnectionOnCheckout: property key {} value is {}", + SystemProperties.TEST_CONNECTION_ON_CHECKOUT, testConnectionOnCheckout); + } else { logger.info(EELFLoggerDelegate.errorLogger, - SystemProperties.TEST_CONNECTION_ON_CHECKOUT + " value not found " - + UserUtils.getStackTrace(e)); + "getConnectionOnCheckout: property key {} not found, using default value {}", + SystemProperties.TEST_CONNECTION_ON_CHECKOUT, testConnectionOnCheckout); } - Boolean testConnectionOnCheckout = Boolean.valueOf(testConnectionOnCheckoutStr == null ? "true":testConnectionOnCheckoutStr); return testConnectionOnCheckout; } diff --git a/ecomp-sdk/epsdk-core/src/main/java/org/openecomp/portalsdk/core/util/SystemProperties.java b/ecomp-sdk/epsdk-core/src/main/java/org/openecomp/portalsdk/core/util/SystemProperties.java index 033bb26b..2dacae84 100644 --- a/ecomp-sdk/epsdk-core/src/main/java/org/openecomp/portalsdk/core/util/SystemProperties.java +++ b/ecomp-sdk/epsdk-core/src/main/java/org/openecomp/portalsdk/core/util/SystemProperties.java @@ -74,7 +74,7 @@ public class SystemProperties { /** * Tests whether a property value is available for the specified key. * - * @param key + * @param key Property key * @return True if the key is known, otherwise false. */ public static boolean containsProperty(String key) { @@ -85,12 +85,12 @@ public class SystemProperties { * Returns the property value associated with the given key (never * {@code null}), after trimming any trailing space. * - * @throws IllegalStateException - * if the key cannot be resolved * @param key * Property key * @return Property value; the empty string if the environment was not * autowired, which should never happen. + * @throws IllegalStateException + * if the key cannot be resolved */ public static String getProperty(String key) { String value = ""; @@ -244,15 +244,17 @@ public class SystemProperties { // Hibernate Config public static final String HB_DIALECT = "hb.dialect"; public static final String HB_SHOW_SQL = "hb.show_sql"; + public static final String IDLE_CONNECTION_TEST_PERIOD = "hb.idle_connection_test_period"; // DataSource public static final String DB_DRIVER = "db.driver"; public static final String DB_CONNECTIONURL = "db.connectionURL"; public static final String DB_USERNAME = "db.userName"; + /** @deprecated this variable is used in many places so don't remove */ public static final String DB_PASSWOR = "db.password"; + public static final String DB_PASSWORD = "db.password"; public static final String DB_MIN_POOL_SIZE = "db.min_pool_size"; public static final String DB_MAX_POOL_SIZE = "db.max_pool_size"; - public static final String IDLE_CONNECTION_TEST_PERIOD = "hb.idle_connection_test_period"; public static final String TEST_CONNECTION_ON_CHECKOUT = "db.test_connection_on_checkout"; public static final String PREFERRED_TEST_QUERY = "db.preferred_test_query"; |