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