aboutsummaryrefslogtreecommitdiffstats
path: root/controlloop/common/eventmanager
diff options
context:
space:
mode:
authorTemoc Rodriguez <cr056n@att.com>2017-09-13 12:23:46 -0700
committerTemoc Rodriguez <cr056n@att.com>2017-09-14 12:31:34 -0700
commitd420472a3a9d6346cb559bbbb910d02b6e0739a2 (patch)
tree8dfa6cbf1d4bf40298470f535e80cffd658b6543 /controlloop/common/eventmanager
parentd75fd4d5cafa652fa35d6c152f114319b27f7603 (diff)
Move credential information out of persistence.xml
Move credential information out of persistence.xml. Define properties file which will contain the credentials instead. Access db using new properties file. Issue-ID: POLICY-55 Change-Id: I01ad0611c053ad4285de2a225fca7920a3b1bc8f Signed-off-by: Temoc Rodriguez <cr056n@att.com>
Diffstat (limited to 'controlloop/common/eventmanager')
-rw-r--r--controlloop/common/eventmanager/pom.xml6
-rw-r--r--controlloop/common/eventmanager/src/main/java/org/onap/policy/controlloop/eventmanager/ControlLoopOperationManager.java25
-rw-r--r--controlloop/common/eventmanager/src/main/resources/META-INF/persistence.xml6
3 files changed, 26 insertions, 11 deletions
diff --git a/controlloop/common/eventmanager/pom.xml b/controlloop/common/eventmanager/pom.xml
index a3227cbc1..93ff56cba 100644
--- a/controlloop/common/eventmanager/pom.xml
+++ b/controlloop/common/eventmanager/pom.xml
@@ -41,6 +41,12 @@
<scope>provided</scope>
</dependency>
<dependency>
+ <groupId>com.att.research.xacml</groupId>
+ <artifactId>xacml</artifactId>
+ <version>1.0.0</version>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
<groupId>org.onap.policy.drools-applications</groupId>
<artifactId>actorServiceProvider</artifactId>
<version>1.1.0-SNAPSHOT</version>
diff --git a/controlloop/common/eventmanager/src/main/java/org/onap/policy/controlloop/eventmanager/ControlLoopOperationManager.java b/controlloop/common/eventmanager/src/main/java/org/onap/policy/controlloop/eventmanager/ControlLoopOperationManager.java
index 7751a4108..503a6fbb3 100644
--- a/controlloop/common/eventmanager/src/main/java/org/onap/policy/controlloop/eventmanager/ControlLoopOperationManager.java
+++ b/controlloop/common/eventmanager/src/main/java/org/onap/policy/controlloop/eventmanager/ControlLoopOperationManager.java
@@ -20,11 +20,13 @@
package org.onap.policy.controlloop.eventmanager;
+import java.io.InputStream;
import java.io.Serializable;
import java.sql.Timestamp;
import java.time.Instant;
import java.util.AbstractMap;
import java.util.LinkedList;
+import java.util.Properties;
import javax.persistence.EntityManager;
import javax.persistence.Persistence;
@@ -37,6 +39,7 @@ import org.onap.policy.controlloop.ControlLoopException;
import org.onap.policy.controlloop.ControlLoopOperation;
import org.onap.policy.controlloop.VirtualControlLoopEvent;
import org.onap.policy.controlloop.actor.appc.APPCActorServiceProvider;
+import org.onap.policy.controlloop.actor.appclcm.AppcLcmActorServiceProvider;
import org.onap.policy.controlloop.actor.vfc.VFCActorServiceProvider;
import org.onap.policy.controlloop.policy.Policy;
import org.onap.policy.controlloop.policy.PolicyResult;
@@ -44,7 +47,6 @@ import org.onap.policy.controlloop.actor.so.SOActorServiceProvider;
import org.onap.policy.so.SOResponse;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import org.onap.policy.controlloop.actor.appclcm.AppcLcmActorServiceProvider;
public class ControlLoopOperationManager implements Serializable {
@@ -216,10 +218,10 @@ public class ControlLoopOperationManager implements Serializable {
case "SO":
SOActorServiceProvider SOAsp = new SOActorServiceProvider();
this.operationRequest = SOAsp.constructRequest((VirtualControlLoopEvent)onset, operation.operation, this.policy);
-
+
// Save the operation
this.currentOperation = operation;
-
+
return operationRequest;
case "VFC":
this.operationRequest = VFCActorServiceProvider.constructRequest((VirtualControlLoopEvent) onset, operation.operation, this.policy);
@@ -364,9 +366,9 @@ public class ControlLoopOperationManager implements Serializable {
}
return PolicyResult.FAILURE;
}
-
+
}
-
+
return null;
}
@@ -512,13 +514,24 @@ public class ControlLoopOperationManager implements Serializable {
private void storeOperationInDataBase(){
+ // DB Properties
+ Properties props = new Properties();
+ try (InputStream is = org.onap.policy.guard.PIPEngineGetHistory.class.getResourceAsStream(org.onap.policy.guard.PIPEngineGetHistory.OPS_HIST_PROPS_LOC)){
+ props.load(is);
+ } catch (Exception ex) {
+ logger.error("getCountFromDB threw: ", ex);
+ return;
+ }
String OpsHistPU = System.getProperty("OperationsHistoryPU");
if(OpsHistPU == null || !OpsHistPU.equals("TestOperationsHistoryPU")){
OpsHistPU = "OperationsHistoryPU";
}
+ else{
+ props.clear();
+ }
EntityManager em;
try{
- em = Persistence.createEntityManagerFactory(OpsHistPU).createEntityManager();
+ em = Persistence.createEntityManagerFactory(OpsHistPU, props).createEntityManager();
}catch(Exception e){
logger.error("storeOperationInDataBase threw: ", e);
return;
diff --git a/controlloop/common/eventmanager/src/main/resources/META-INF/persistence.xml b/controlloop/common/eventmanager/src/main/resources/META-INF/persistence.xml
index 27c64b60a..827e2562b 100644
--- a/controlloop/common/eventmanager/src/main/resources/META-INF/persistence.xml
+++ b/controlloop/common/eventmanager/src/main/resources/META-INF/persistence.xml
@@ -11,12 +11,8 @@
<properties>
<property name="eclipselink.ddl-generation" value="create-tables" />
<property name="javax.persistence.jdbc.driver" value="org.mariadb.jdbc.Driver" />
- <property name="javax.persistence.jdbc.url" value="jdbc:mariadb://localhost:3306/policy" />
- <property name="javax.persistence.jdbc.user" value="root" />
- <property name="javax.persistence.jdbc.password" value="aaaa" />
<property name="eclipselink.logging.level" value="WARNING" />
+ <!-- Credential and URL properties located in /guard/src/main/resources/operation_history.properties -->
</properties>
</persistence-unit>
-
-
</persistence>