X-Git-Url: https://gerrit.onap.org/r/gitweb?a=blobdiff_plain;f=mod%2Fruntimeapi%2Fruntime-web%2Fsrc%2Fmain%2Fjava%2Forg%2Fonap%2Fdcae%2Fruntime%2Fweb%2Fservice%2FBlueprintInventory.java;h=d63deeb58f25f7a03c7b35542009944af7e3f367;hb=4371989e7a50d015b6eefa074d4988033223551b;hp=bb6839cfaae938bb5867767b07fa46dbc80efd03;hpb=a1f590d75dc29759d2abaa14915c70838abdc9c2;p=dcaegen2%2Fplatform.git diff --git a/mod/runtimeapi/runtime-web/src/main/java/org/onap/dcae/runtime/web/service/BlueprintInventory.java b/mod/runtimeapi/runtime-web/src/main/java/org/onap/dcae/runtime/web/service/BlueprintInventory.java index bb6839c..d63deeb 100644 --- a/mod/runtimeapi/runtime-web/src/main/java/org/onap/dcae/runtime/web/service/BlueprintInventory.java +++ b/mod/runtimeapi/runtime-web/src/main/java/org/onap/dcae/runtime/web/service/BlueprintInventory.java @@ -1,6 +1,6 @@ /*- * ============LICENSE_START======================================================= - * Copyright (C) 2019 AT&T Intellectual Property. All rights reserved. + * Copyright (C) 2021 AT&T Intellectual Property. All rights reserved. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -17,6 +17,7 @@ */ package org.onap.dcae.runtime.web.service; +import org.json.JSONException; import org.onap.dcae.runtime.core.FlowGraphParser.BlueprintVessel; import org.onap.dcae.runtime.web.models.DashboardConfig; import org.json.JSONObject; @@ -39,19 +40,19 @@ public class BlueprintInventory { Logger logger = LoggerFactory.getLogger(BlueprintInventory.class); + private RestTemplate restTemplate = new RestTemplate(); + public void distributeToInventory(List blueprints) { for (BlueprintVessel bpv : blueprints) { JSONObject body = prepareBlueprintJsonObject(bpv.name, bpv.version, bpv.blueprint); postToDashboard(body); logger.info(String.format("Distributed: %s", bpv.toString())); - //System.out.println(bpv.blueprint); } } // Should work with inventory too! private boolean postToDashboard(JSONObject blueprintJsonObject){ //1. setup - RestTemplate restTemplate = new RestTemplate(); HttpHeaders headers = new HttpHeaders(); headers.setContentType(MediaType.APPLICATION_JSON); // NOTE: This commented out line is to be used for dcae dashboard api and not inventory @@ -73,12 +74,16 @@ public class BlueprintInventory { private JSONObject prepareBlueprintJsonObject(String blueprintName, int version, String blueprintContent) { JSONObject blueprintJsonObject = new JSONObject(); - blueprintJsonObject.put("owner","dcae_mod"); - blueprintJsonObject.put("typeName",blueprintName); - blueprintJsonObject.put("typeVersion",version); - blueprintJsonObject.put("blueprintTemplate",blueprintContent); - blueprintJsonObject.put("application","DCAE"); - blueprintJsonObject.put("component","dcae"); + try { + blueprintJsonObject.put("owner","dcae_mod"); + blueprintJsonObject.put("typeName",blueprintName); + blueprintJsonObject.put("typeVersion",version); + blueprintJsonObject.put("blueprintTemplate",blueprintContent); + blueprintJsonObject.put("application","DCAE"); + blueprintJsonObject.put("component","dcae"); + } catch (JSONException e) { + e.printStackTrace(); + } return blueprintJsonObject; }