Fixing the way to get properties from file

git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/information-system/resource-registry@130930 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
Luca Frosini 2016-08-01 15:35:27 +00:00
parent 2600c13a5a
commit e6809d4db7
1 changed files with 3 additions and 7 deletions

View File

@ -3,8 +3,6 @@
*/ */
package org.gcube.informationsystem.resourceregistry.dbinitialization; package org.gcube.informationsystem.resourceregistry.dbinitialization;
import java.io.File;
import java.io.FileInputStream;
import java.io.InputStream; import java.io.InputStream;
import java.util.HashMap; import java.util.HashMap;
import java.util.Map; import java.util.Map;
@ -23,7 +21,7 @@ public class DatabaseEnvironment {
private static Logger logger = LoggerFactory.getLogger(DatabaseIntializator.class); private static Logger logger = LoggerFactory.getLogger(DatabaseIntializator.class);
private static final String PROPERTY_FILENAME = "config.properties"; public static final String PROPERTY_FILENAME = "config.properties";
public static final String HOST; public static final String HOST;
public static final String HOST_VARNAME = "HOST"; public static final String HOST_VARNAME = "HOST";
@ -73,12 +71,10 @@ public class DatabaseEnvironment {
Properties properties = new Properties(); Properties properties = new Properties();
InputStream input = null; InputStream input = null;
File propertyFile = new File(PROPERTY_FILENAME);
try { try {
logger.trace("Going to load property file {}", propertyFile.getAbsolutePath()); input = DatabaseEnvironment.class.getClassLoader().getResourceAsStream(PROPERTY_FILENAME);
input = new FileInputStream(propertyFile);
// load a properties file // load a properties file
properties.load(input); properties.load(input);
@ -112,7 +108,7 @@ public class DatabaseEnvironment {
DEFAULT_PASSWORDS.put(PermissionMode.WRITER, DEFAULT_CREATED_WRITER_USER_PASSWORD); DEFAULT_PASSWORDS.put(PermissionMode.WRITER, DEFAULT_CREATED_WRITER_USER_PASSWORD);
DEFAULT_PASSWORDS.put(PermissionMode.READER, DEFAULT_CREATED_READER_USER_PASSWORD); DEFAULT_PASSWORDS.put(PermissionMode.READER, DEFAULT_CREATED_READER_USER_PASSWORD);
} catch(Exception e){ } catch(Exception e){
logger.error("Unable to load properties from {}", propertyFile); logger.error("Unable to load properties from {}", PROPERTY_FILENAME);
throw new RuntimeException("Unable to load properties", e); throw new RuntimeException("Unable to load properties", e);
} }
} }