diff options
Diffstat (limited to 'src/main/java/org')
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 558102c5..19bc23d5 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 bdf6e70f..67bd026d 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 9b131299..7a0d8b4b 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; + } } |