diff options
author | Jorge Hernandez <jh1730@att.com> | 2017-09-14 21:35:26 +0000 |
---|---|---|
committer | Gerrit Code Review <gerrit@onap.org> | 2017-09-14 21:35:26 +0000 |
commit | 8ba1edd2ff587c0d42fe8892c5285c705c9faa59 (patch) | |
tree | b1a6f98f0ae98c694d96aa248212b35df4a798fa /controlloop/common/guard/src/main/java | |
parent | 4803c9d0e7d67cac1008093970154468a5479413 (diff) | |
parent | d420472a3a9d6346cb559bbbb910d02b6e0739a2 (diff) |
Merge "Move credential information out of persistence.xml"
Diffstat (limited to 'controlloop/common/guard/src/main/java')
-rw-r--r-- | controlloop/common/guard/src/main/java/org/onap/policy/guard/PIPEngineGetHistory.java | 19 |
1 files changed, 17 insertions, 2 deletions
diff --git a/controlloop/common/guard/src/main/java/org/onap/policy/guard/PIPEngineGetHistory.java b/controlloop/common/guard/src/main/java/org/onap/policy/guard/PIPEngineGetHistory.java index 3e93bd761..6be59d668 100644 --- a/controlloop/common/guard/src/main/java/org/onap/policy/guard/PIPEngineGetHistory.java +++ b/controlloop/common/guard/src/main/java/org/onap/policy/guard/PIPEngineGetHistory.java @@ -20,6 +20,8 @@ package org.onap.policy.guard; +import java.io.IOException; +import java.io.InputStream; import java.math.BigInteger; import java.sql.Timestamp; import java.util.Collection; @@ -64,7 +66,8 @@ public class PIPEngineGetHistory extends StdConfigurableEngine{ private static final Logger logger = LoggerFactory.getLogger(PIPEngineGetHistory.class); - public static final String DEFAULT_DESCRIPTION = "PIP for retrieving Operations History from DB"; + public static final String DEFAULT_DESCRIPTION = "PIP for retrieving Operations History from DB"; + public static final String OPS_HIST_PROPS_LOC = "/operation_history.properties"; // // Base issuer string. The issuer in the policy will also contain time window information @@ -305,13 +308,25 @@ public class PIPEngineGetHistory extends StdConfigurableEngine{ private static int getCountFromDB(String actor, String operation, String target, String timeWindow){ + // DB Properties + Properties props = new Properties(); + try (InputStream is = org.onap.policy.guard.PIPEngineGetHistory.class.getResourceAsStream(OPS_HIST_PROPS_LOC)){ + props.load(is); + } catch (IOException ex) { + logger.error("getCountFromDB threw: ", ex); + return -1; + } + EntityManager em = null; String OpsHistPU = System.getProperty("OperationsHistoryPU"); if(OpsHistPU == null || !OpsHistPU.equals("TestOperationsHistoryPU")){ OpsHistPU = "OperationsHistoryPU"; } + else{ + props.clear(); + } try{ - em = Persistence.createEntityManagerFactory(OpsHistPU).createEntityManager(); + em = Persistence.createEntityManagerFactory(OpsHistPU, props).createEntityManager(); }catch(Exception ex){ logger.error("PIP thread got Exception. Can't connect to Operations History DB -- {}", OpsHistPU); logger.error("getCountFromDB threw: ", ex); |