summaryrefslogtreecommitdiffstats
path: root/src/main
diff options
context:
space:
mode:
authorsebdet <sebastien.determe@intl.att.com>2021-01-24 18:12:36 +0100
committersebdet <sebastien.determe@intl.att.com>2021-02-15 10:13:43 +0100
commiteb8e3f1dd891ac98f1bbaf35a2a0679146785236 (patch)
treec7768442c40667e2d2ee49247e28c1b532b497cd /src/main
parent9d04a9cc8c6f4b12ae60cc0d4d42f71085f72328 (diff)
Add New UI component for policies list
Add new Ui components to list policies + the small refactoring of React Routes Issue-ID: POLICY-2925 Signed-off-by: sebdet <sebastien.determe@intl.att.com> Change-Id: I784d7c144a3a3af98a9d62b5d40b5172dbdaed47 Signed-off-by: sebdet <sebastien.determe@intl.att.com>
Diffstat (limited to 'src/main')
-rw-r--r--src/main/java/org/onap/policy/clamp/policy/pdpgroup/PoliciesPdpMerger.java15
-rw-r--r--src/main/resources/clds/camel/rest/clamp-api-v2.xml2
2 files changed, 10 insertions, 7 deletions
diff --git a/src/main/java/org/onap/policy/clamp/policy/pdpgroup/PoliciesPdpMerger.java b/src/main/java/org/onap/policy/clamp/policy/pdpgroup/PoliciesPdpMerger.java
index 4b94355ee..0bd45cd33 100644
--- a/src/main/java/org/onap/policy/clamp/policy/pdpgroup/PoliciesPdpMerger.java
+++ b/src/main/java/org/onap/policy/clamp/policy/pdpgroup/PoliciesPdpMerger.java
@@ -42,19 +42,22 @@ public class PoliciesPdpMerger {
* This method extract the content of a policy without knowing the key (policy Id).
* This JsonElement normally contains only the policy ID then the content,
* there is only one member in the Json element.
+ * As this is not really practical to use this method remove that
+ * nested Json.
*
* @param policyJsonElement The policy as JsonElement
* @return It return the content as JsonObject
*/
public static JsonObject getPolicyContentOutOfJsonElement(JsonElement policyJsonElement) {
- return policyJsonElement.getAsJsonObject()
- .get(((String) policyJsonElement.getAsJsonObject().keySet().toArray()[0])).getAsJsonObject();
+ mergeJsonElement(policyJsonElement.getAsJsonObject(), policyJsonElement.getAsJsonObject()
+ .remove(((String) policyJsonElement.getAsJsonObject().keySet().toArray()[0])).getAsJsonObject());
+ return policyJsonElement.getAsJsonObject();
}
/**
* This method merges 2 JsonElement together. If the jsonToMerge is null nothign is changed.
*
- * @param json The initial json that will received the data
+ * @param json The initial json that will received the data
* @param jsonToMerge The json that will be added to the first json object
*/
public static void mergeJsonElement(JsonObject json, JsonObject jsonToMerge) {
@@ -69,16 +72,16 @@ public class PoliciesPdpMerger {
*
* @param jsonPoliciesList The Json containing the policies from the PEF
* @param pdpGroupsJson The json containing the PDP groups info from the PEF
- * @return It returns a String containing the policies list enriched with PdpGroup info
+ * @return It returns a JsonObject containing the policies list enriched with PdpGroup info
*/
- public static String mergePoliciesAndPdpGroupStates(String jsonPoliciesList, String pdpGroupsJson) {
+ public static JsonObject mergePoliciesAndPdpGroupStates(String jsonPoliciesList, String pdpGroupsJson) {
PdpGroups pdpGroups = JsonUtils.GSON.fromJson(pdpGroupsJson, PdpGroups.class);
JsonObject policiesListJson =
JsonUtils.GSON.fromJson(jsonPoliciesList, JsonObject.class).get("topology_template")
.getAsJsonObject();
StreamSupport.stream(policiesListJson.get("policies").getAsJsonArray().spliterator(), true)
.forEach(policyJson -> enrichOnePolicy(pdpGroups, getPolicyContentOutOfJsonElement(policyJson)));
- return policiesListJson.toString();
+ return policiesListJson;
}
/**
diff --git a/src/main/resources/clds/camel/rest/clamp-api-v2.xml b/src/main/resources/clds/camel/rest/clamp-api-v2.xml
index 011c24a9d..e1f138b1d 100644
--- a/src/main/resources/clds/camel/rest/clamp-api-v2.xml
+++ b/src/main/resources/clds/camel/rest/clamp-api-v2.xml
@@ -1317,7 +1317,7 @@
</doTry>
</route>
</get>
- <get uri="/v2/policies/list" outType="java.lang.String" produces="application/json">
+ <get uri="/v2/policies/list" outType="com.google.gson.JsonObject" produces="application/json">
<route>
<removeHeaders pattern="*"/>
<doTry>