summaryrefslogtreecommitdiffstats
path: root/controlloop/common/guard
diff options
context:
space:
mode:
Diffstat (limited to 'controlloop/common/guard')
-rw-r--r--controlloop/common/guard/pom.xml7
-rw-r--r--controlloop/common/guard/src/main/java/org/onap/policy/guard/PIPEngineGetHistory.java21
-rw-r--r--controlloop/common/guard/src/main/java/org/onap/policy/guard/PolicyGuardXacmlHelper.java2
-rw-r--r--controlloop/common/guard/src/main/java/org/onap/policy/guard/impl/PNFTargetLock.java2
-rw-r--r--controlloop/common/guard/src/main/java/org/onap/policy/guard/impl/VMTargetLock.java2
-rw-r--r--controlloop/common/guard/src/main/java/org/onap/policy/guard/impl/VNFTargetLock.java2
-rw-r--r--controlloop/common/guard/src/main/resources/operation_history.properties26
7 files changed, 48 insertions, 14 deletions
diff --git a/controlloop/common/guard/pom.xml b/controlloop/common/guard/pom.xml
index 2b173c36c..e0283589a 100644
--- a/controlloop/common/guard/pom.xml
+++ b/controlloop/common/guard/pom.xml
@@ -13,17 +13,10 @@
<version>1.1.0-SNAPSHOT</version>
<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>com.att.research.xacml</groupId>
<artifactId>xacml-pdp</artifactId>
<version>1.0.0</version>
- <scope>provided</scope>
</dependency>
<dependency>
<groupId>junit</groupId>
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..afb847e09 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);
@@ -372,7 +387,7 @@ public class PIPEngineGetHistory extends StdConfigurableEngine{
try {
diff = now - dateUtil.init(timeWindow).getMs();
} catch (Exception ex) {
- System.err.println("PIP thread got Exception " + ex.getLocalizedMessage());
+ logger.error("PIP thread got Exception " + ex);
return -1;
}
diff --git a/controlloop/common/guard/src/main/java/org/onap/policy/guard/PolicyGuardXacmlHelper.java b/controlloop/common/guard/src/main/java/org/onap/policy/guard/PolicyGuardXacmlHelper.java
index dbaf711c4..5ecb44162 100644
--- a/controlloop/common/guard/src/main/java/org/onap/policy/guard/PolicyGuardXacmlHelper.java
+++ b/controlloop/common/guard/src/main/java/org/onap/policy/guard/PolicyGuardXacmlHelper.java
@@ -140,7 +140,7 @@ public class PolicyGuardXacmlHelper {
} catch (Exception e) {
String message = "Parsing Content-Type: " + connection.getContentType() + ", error=" + e.getMessage();
- logger.error("{}: callRESTfulPDP threw: ", message);
+ logger.error("{}: callRESTfulPDP threw: ", message, e);
}
} else {
diff --git a/controlloop/common/guard/src/main/java/org/onap/policy/guard/impl/PNFTargetLock.java b/controlloop/common/guard/src/main/java/org/onap/policy/guard/impl/PNFTargetLock.java
index ea966ea55..62ddb0d71 100644
--- a/controlloop/common/guard/src/main/java/org/onap/policy/guard/impl/PNFTargetLock.java
+++ b/controlloop/common/guard/src/main/java/org/onap/policy/guard/impl/PNFTargetLock.java
@@ -38,7 +38,7 @@ public class PNFTargetLock implements TargetLock, Serializable {
private final TargetType targetType;
private final String target;
private final UUID requestID;
- private final LockCallback callback;
+ private final transient LockCallback callback;
public PNFTargetLock (TargetType type, String target, UUID requestID, LockCallback callback) {
this.lockID = UUID.randomUUID();
diff --git a/controlloop/common/guard/src/main/java/org/onap/policy/guard/impl/VMTargetLock.java b/controlloop/common/guard/src/main/java/org/onap/policy/guard/impl/VMTargetLock.java
index 1de105ce4..0a7556bc9 100644
--- a/controlloop/common/guard/src/main/java/org/onap/policy/guard/impl/VMTargetLock.java
+++ b/controlloop/common/guard/src/main/java/org/onap/policy/guard/impl/VMTargetLock.java
@@ -37,7 +37,7 @@ public class VMTargetLock implements TargetLock, Serializable {
private final TargetType targetType;
private final String target;
private final UUID requestID;
- private final LockCallback callback;
+ private final transient LockCallback callback;
public VMTargetLock(TargetType targetType, String target, UUID requestID, LockCallback callback) {
this.lockID = UUID.randomUUID();
diff --git a/controlloop/common/guard/src/main/java/org/onap/policy/guard/impl/VNFTargetLock.java b/controlloop/common/guard/src/main/java/org/onap/policy/guard/impl/VNFTargetLock.java
index 1350d5c54..b6e49b578 100644
--- a/controlloop/common/guard/src/main/java/org/onap/policy/guard/impl/VNFTargetLock.java
+++ b/controlloop/common/guard/src/main/java/org/onap/policy/guard/impl/VNFTargetLock.java
@@ -38,7 +38,7 @@ public class VNFTargetLock implements TargetLock, Serializable {
private final TargetType targetType;
private final String target;
private final UUID requestID;
- private final LockCallback callback;
+ private final transient LockCallback callback;
public VNFTargetLock (TargetType type, String target, UUID requestID, LockCallback callback) {
this.lockID = UUID.randomUUID();
diff --git a/controlloop/common/guard/src/main/resources/operation_history.properties b/controlloop/common/guard/src/main/resources/operation_history.properties
new file mode 100644
index 000000000..8c374a85b
--- /dev/null
+++ b/controlloop/common/guard/src/main/resources/operation_history.properties
@@ -0,0 +1,26 @@
+#/*-
+# * ============LICENSE_START=======================================================
+# * guard
+# * ================================================================================
+# * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+# * ================================================================================
+# * Licensed under the Apache License, Version 2.0 (the "License");
+# * you may not use this file except in compliance with the License.
+# * You may obtain a copy of the License at
+# *
+# * http://www.apache.org/licenses/LICENSE-2.0
+# *
+# * Unless required by applicable law or agreed to in writing, software
+# * distributed under the License is distributed on an "AS IS" BASIS,
+# * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# * See the License for the specific language governing permissions and
+# * limitations under the License.
+# * ============LICENSE_END=========================================================
+# */
+
+#
+# Maria DB Operation History Credentials
+#
+javax.persistence.jdbc.user=root
+javax.persistence.jdbc.password=aaaa
+javax.persistence.jdbc.url=jdbc:mariadb://localhost:3306/policy