Skip to content

Commit 4ea4e07

Browse files
committed
Dubey, Sukreeto | BDSHR-1242 | Reading properties from openmrs-data-directory.
1 parent 6d95871 commit 4ea4e07

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

src/main/java/org/bahmni/module/terminology/infrastructure/config/TRFeedProperties.java

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,12 @@
44
import org.apache.log4j.Logger;
55
import org.bahmni.module.terminology.util.StringUtil;
66
import org.ict4h.atomfeed.client.AtomFeedProperties;
7+
import org.openmrs.util.OpenmrsUtil;
78
import org.springframework.stereotype.Component;
89

910
import javax.annotation.PostConstruct;
1011
import javax.annotation.Resource;
12+
import java.io.File;
1113
import java.io.FileInputStream;
1214
import java.util.Properties;
1315

@@ -17,7 +19,7 @@
1719
@Component
1820
public class TRFeedProperties extends AtomFeedProperties {
1921

20-
private static final String PATH_TO_PROPERTIES = "/.OpenMRS/tr_atomfeed_properties.properties";
22+
private static final String TR_FEED_PROPERTIES_FILENAME = "tr_atomfeed_properties.properties";
2123

2224
@Resource(name = "terminologyFeedProperties")
2325
private Properties defaultProperties;
@@ -40,12 +42,12 @@ public class TRFeedProperties extends AtomFeedProperties {
4042
public void init() {
4143
try {
4244
Properties feedProperties = new Properties();
43-
String name = StringUtil.removeSuffix(System.getProperty("user.home"), "/") + PATH_TO_PROPERTIES;
44-
FileInputStream file = new FileInputStream(name);
45+
File propertiesFile = new File(OpenmrsUtil.getApplicationDataDirectory(), TR_FEED_PROPERTIES_FILENAME);
46+
FileInputStream file = new FileInputStream(propertiesFile);
4547
feedProperties.load(file);
4648
atomFeedProperties = feedProperties;
4749
} catch (Exception ignored) {
48-
Logger.getLogger(TRFeedProperties.class).info("Atom feed property file not found in " + System.getProperty("user.home") + PATH_TO_PROPERTIES + " Using defaults");
50+
Logger.getLogger(TRFeedProperties.class).info("Atom feed property file not found in " + System.getProperty("user.home") + TR_FEED_PROPERTIES_FILENAME + " Using defaults");
4951
atomFeedProperties = defaultProperties;
5052
}
5153
}

0 commit comments

Comments
 (0)