aboutsummaryrefslogtreecommitdiffstats
path: root/src/main/java
diff options
context:
space:
mode:
authorVidyashree-Huawei <vidyashree.rama@huawei.com>2020-01-22 17:25:46 +0530
committerVidyashree-Huawei <vidyashree.rama@huawei.com>2020-01-29 14:40:39 +0530
commit4593656e1f168c067e2a37389aeaa67889c1c173 (patch)
tree3f78537a494fb32b3aed1e32e74c79887839219b /src/main/java
parent33fc823baeda6d4e872614b146ab865823a3ca0f (diff)
Create a camel route that would retrieve all the DCAE blueprints
Retreive all the DCAE blueprints and update DcaeInventoryCache Change-Id: Ia03a89c1871119a208094c014e5cb8aa8b4f71d3 Issue-ID: CLAMP-573 Signed-off-by: Vidyashree-Huawei <vidyashree.rama@huawei.com>
Diffstat (limited to 'src/main/java')
-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;
+ }
}