1 | /*
|
---|
2 | * To change this template, choose Tools | Templates
|
---|
3 | * and open the template in the editor.
|
---|
4 | */
|
---|
5 | package gov.hhs.fha.nhinc.subscription.dte;
|
---|
6 |
|
---|
7 | import gov.hhs.fha.nhinc.common.subscription.CommunityType;
|
---|
8 | import gov.hhs.fha.nhinc.properties.PropertyAccessException;
|
---|
9 | import gov.hhs.fha.nhinc.properties.PropertyAccessor;
|
---|
10 | import gov.hhs.fha.nhinc.subscription.*;
|
---|
11 |
|
---|
12 | /**
|
---|
13 | *
|
---|
14 | * @author rayj
|
---|
15 | */
|
---|
16 | public class Configuration {
|
---|
17 |
|
---|
18 | private static org.apache.commons.logging.Log log = org.apache.commons.logging.LogFactory.getLog(Configuration.class);
|
---|
19 |
|
---|
20 | public static CommunityType getMyCommunity() {
|
---|
21 | CommunityType myCommunity = new CommunityType();
|
---|
22 | myCommunity.setId(getMyCommunityId());
|
---|
23 | myCommunity.setName(getMyCommunityName());
|
---|
24 | return myCommunity;
|
---|
25 | }
|
---|
26 |
|
---|
27 | public static String getMyCommunityId() {
|
---|
28 | return getSetting("gateway", "localHomeCommunityId");
|
---|
29 | }
|
---|
30 |
|
---|
31 | public static String getMyCommunityName() {
|
---|
32 | return getSetting("gateway", "localHomeCommunityDescription");
|
---|
33 | }
|
---|
34 |
|
---|
35 | public static String getlocalNotificationConsumerEndpointAddress() {
|
---|
36 | log.info("### Retriving NotificationConsumerEndpointAddress");
|
---|
37 | return getSetting("gateway", "NotificationConsumerEndpointAddress");
|
---|
38 | }
|
---|
39 |
|
---|
40 | private static String getSetting(String propertyFile, String propertyName) {
|
---|
41 | String setting = "";
|
---|
42 | try {
|
---|
43 | log.info("looking up " + propertyFile + "." + propertyName);
|
---|
44 | setting = PropertyAccessor.getProperty(propertyFile, propertyName);
|
---|
45 | log.info(propertyFile + "." + propertyName + "=" + setting);
|
---|
46 | } catch (PropertyAccessException ex) {
|
---|
47 | log.error("Exception while reading property " + propertyFile + "." + propertyName + " from property file [" + ex.getMessage() + "]");
|
---|
48 | }
|
---|
49 | return setting;
|
---|
50 | }
|
---|
51 | }
|
---|