1
2
3 package org.kuali.ole;
4
5 import org.apache.log4j.Logger;
6
7 import java.io.File;
8 import java.io.FileInputStream;
9 import java.io.IOException;
10 import java.util.Properties;
11
12
13
14
15 public class LoanUtil {
16 private static final Logger LOG = Logger.getLogger(LoanUtil.class);
17 private static LoanUtil loanUtil = new LoanUtil();
18 private String OLE_PROPERTIES_LOAN = "Loan.properties";
19 private String environment;
20
21 public static LoanUtil getLoanUtil() {
22 return loanUtil;
23 }
24
25 private Properties props;
26
27
28
29
30 private LoanUtil() {
31 props = new Properties();
32 try {
33 props.load(getClass().getResourceAsStream(OLE_PROPERTIES_LOAN));
34 } catch (Exception e) {
35 LOG.error("Unable to load the project.properties file" + e.getMessage());
36 LOG.info("Going to attempt to load from the locations set for loan.properties.home");
37 }
38 String propsDir = System.getProperty("env.properties.home");
39 String fileSeparator = System.getProperty("file.separator");
40 File userPropsFile = new File(propsDir + fileSeparator + OLE_PROPERTIES_LOAN);
41 if (userPropsFile.exists()) {
42 try {
43 props.load(new FileInputStream(userPropsFile));
44 } catch (IOException e) {
45 LOG.error(e.getMessage());
46 }
47 }
48 }
49
50
51
52
53
54
55 public String getProperty(String key) {
56 return props.getProperty(key);
57 }
58 }