summaryrefslogtreecommitdiffstats
path: root/src/main/java/org
diff options
context:
space:
mode:
authorXue Gao <xg353y@intl.att.com>2020-01-29 13:58:14 +0000
committerGerrit Code Review <gerrit@onap.org>2020-01-29 13:58:14 +0000
commitb8587538b6d4495977ebde95c21ba659136f43da (patch)
treeab0448f2e74c6aff9f25e88aa9dea115eab074ed /src/main/java/org
parent05db0f21630449ddaaa2f29f8c26685b94c261da (diff)
parent4593656e1f168c067e2a37389aeaa67889c1c173 (diff)
Merge "Create a camel route that would retrieve all the DCAE blueprints"
Diffstat (limited to 'src/main/java/org')
-rw-r--r--src/main/java/org/onap/clamp/clds/model/dcae/DcaeInventoryCache.java2
-rw-r--r--src/main/java/org/onap/clamp/clds/model/dcae/DcaeInventoryResponse.java11
-rw-r--r--src/main/java/org/onap/clamp/loop/components/external/DcaeComponent.java33
3 files changed, 32 insertions, 14 deletions
diff --git a/src/main/java/org/onap/clamp/clds/model/dcae/DcaeInventoryCache.java b/src/main/java/org/onap/clamp/clds/model/dcae/DcaeInventoryCache.java
index 558102c5d..19bc23d5e 100644
--- a/src/main/java/org/onap/clamp/clds/model/dcae/DcaeInventoryCache.java
+++ b/src/main/java/org/onap/clamp/clds/model/dcae/DcaeInventoryCache.java
@@ -36,7 +36,7 @@ import java.util.concurrent.ConcurrentHashMap;
*/
public class DcaeInventoryCache {
- private Map<String, Set<DcaeInventoryResponse>> blueprintsMap = new ConcurrentHashMap<>();
+ private static Map<String, Set<DcaeInventoryResponse>> blueprintsMap = new ConcurrentHashMap<>();
/**
* Add Dcae inventory response.
diff --git a/src/main/java/org/onap/clamp/clds/model/dcae/DcaeInventoryResponse.java b/src/main/java/org/onap/clamp/clds/model/dcae/DcaeInventoryResponse.java
index bdf6e70f5..67bd026d0 100644
--- a/src/main/java/org/onap/clamp/clds/model/dcae/DcaeInventoryResponse.java
+++ b/src/main/java/org/onap/clamp/clds/model/dcae/DcaeInventoryResponse.java
@@ -53,9 +53,6 @@ public class DcaeInventoryResponse implements Comparable<DcaeInventoryResponse>
@Expose
private String asdcResourceId;
- @Expose
- private String selfLink;
-
public String getTypeName() {
return typeName;
}
@@ -96,14 +93,6 @@ public class DcaeInventoryResponse implements Comparable<DcaeInventoryResponse>
this.asdcResourceId = asdcResourceId;
}
- public String getSelfLink() {
- return selfLink;
- }
-
- public void setSelfLink(String selfLink) {
- this.selfLink = selfLink;
- }
-
@Override
public int compareTo(DcaeInventoryResponse otherResponse) {
int thisResourceId = Integer.parseInt(this.asdcResourceId);
diff --git a/src/main/java/org/onap/clamp/loop/components/external/DcaeComponent.java b/src/main/java/org/onap/clamp/loop/components/external/DcaeComponent.java
index 9b131299b..7a0d8b4b3 100644
--- a/src/main/java/org/onap/clamp/loop/components/external/DcaeComponent.java
+++ b/src/main/java/org/onap/clamp/loop/components/external/DcaeComponent.java
@@ -24,10 +24,17 @@
package org.onap.clamp.loop.components.external;
import com.google.gson.JsonObject;
-
+import java.util.Iterator;
+import java.util.LinkedList;
+import java.util.List;
import java.util.UUID;
-
import org.apache.camel.Exchange;
+import org.json.simple.JSONArray;
+import org.json.simple.JSONObject;
+import org.json.simple.parser.JSONParser;
+import org.json.simple.parser.ParseException;
+
+import org.onap.clamp.clds.model.dcae.DcaeInventoryResponse;
import org.onap.clamp.clds.model.dcae.DcaeOperationStatusResponse;
import org.onap.clamp.clds.util.JsonUtils;
import org.onap.clamp.loop.Loop;
@@ -164,4 +171,26 @@ public class DcaeComponent extends ExternalComponent {
}
return this.getState();
}
+
+ /**
+ * Convert the json response to a DcaeInventoryResponse.
+ *
+ * @param responseBody The DCAE response Json paylaod
+ * @return list of DcaeInventoryResponse
+ * @throws ParseException In case of issues with the Json parsing
+ */
+ public static List<DcaeInventoryResponse> convertToDcaeInventoryResponse(String responseBody)
+ throws ParseException {
+ JSONParser parser = new JSONParser();
+ JSONObject jsonObj = (JSONObject) parser.parse(responseBody);
+ JSONArray itemsArray = (JSONArray) jsonObj.get("items");
+ Iterator it = itemsArray.iterator();
+ List<DcaeInventoryResponse> inventoryResponseList = new LinkedList<>();
+ while (it.hasNext()) {
+ JSONObject item = (JSONObject) it.next();
+ DcaeInventoryResponse response = JsonUtils.GSON.fromJson(item.toString(), DcaeInventoryResponse.class);
+ inventoryResponseList.add(response);
+ }
+ return inventoryResponseList;
+ }
}