summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJim Hahn <jrh3@att.com>2019-04-16 18:08:54 -0400
committerJim Hahn <jrh3@att.com>2019-04-16 18:14:31 -0400
commit7eb4d548638b2a01c51377bda33ad611d876efd1 (patch)
treeff40c6a129d6b93f5ae434459fce0bcae91f01f6
parent75d559ba9f136bdfd7460805085026e7c5cb3fbd (diff)
Add missing fields to initial subgroups
Some required fields were missing from the subgroups in the inital DB. Also added code to validate what is initially loaded into the DB. Change-Id: Iffa56a5a0dee833691d1bb7859b075c3b4d86595 Issue-ID: POLICY-1542 Signed-off-by: Jim Hahn <jrh3@att.com>
-rw-r--r--main/src/main/java/org/onap/policy/pap/main/startstop/PapDatabaseInitializer.java7
-rw-r--r--main/src/main/resources/PapDb.json12
2 files changed, 14 insertions, 5 deletions
diff --git a/main/src/main/java/org/onap/policy/pap/main/startstop/PapDatabaseInitializer.java b/main/src/main/java/org/onap/policy/pap/main/startstop/PapDatabaseInitializer.java
index 7c1e2e8f..affe1e9f 100644
--- a/main/src/main/java/org/onap/policy/pap/main/startstop/PapDatabaseInitializer.java
+++ b/main/src/main/java/org/onap/policy/pap/main/startstop/PapDatabaseInitializer.java
@@ -1,6 +1,7 @@
/*-
* ============LICENSE_START=======================================================
* Copyright (C) 2019 Nordix Foundation.
+ * Modifications Copyright (C) 2019 AT&T Intellectual Property.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -21,7 +22,7 @@
package org.onap.policy.pap.main.startstop;
import java.util.List;
-
+import org.onap.policy.common.parameters.ValidationResult;
import org.onap.policy.common.utils.coder.CoderException;
import org.onap.policy.common.utils.coder.StandardCoder;
import org.onap.policy.common.utils.resources.ResourceUtils;
@@ -71,6 +72,10 @@ public class PapDatabaseInitializer {
final List<PdpGroup> pdpGroupsFromDb = databaseProvider.getPdpGroups(
pdpGroupsToCreate.getGroups().get(0).getName());
if (pdpGroupsFromDb.isEmpty()) {
+ ValidationResult result = pdpGroupsToCreate.validatePapRest();
+ if (!result.isValid()) {
+ throw new PolicyPapException(result.getResult());
+ }
databaseProvider.createPdpGroups(pdpGroupsToCreate.getGroups());
LOGGER.debug("Created initial pdpGroup in DB - {}", pdpGroupsToCreate);
} else {
diff --git a/main/src/main/resources/PapDb.json b/main/src/main/resources/PapDb.json
index c6452cc1..6df3fc9f 100644
--- a/main/src/main/resources/PapDb.json
+++ b/main/src/main/resources/PapDb.json
@@ -15,7 +15,8 @@
}
],
"currentInstanceCount": 0,
- "desiredInstanceCount": 1
+ "desiredInstanceCount": 1,
+ "policies": []
},
{
"pdpType": "drools",
@@ -26,7 +27,8 @@
}
],
"currentInstanceCount": 0,
- "desiredInstanceCount": 1
+ "desiredInstanceCount": 1,
+ "policies": []
},
{
"pdpType": "apex",
@@ -37,7 +39,8 @@
}
],
"currentInstanceCount": 0,
- "desiredInstanceCount": 1
+ "desiredInstanceCount": 1,
+ "policies": []
}
]
},
@@ -56,7 +59,8 @@
}
],
"currentInstanceCount": 0,
- "desiredInstanceCount": 1
+ "desiredInstanceCount": 1,
+ "policies": []
}
]
}