Remove dead code
[clamp.git] / src / main / java / org / onap / clamp / clds / client / DcaeInventoryServices.java
index 7f20919..0ebaab5 100644 (file)
@@ -29,20 +29,13 @@ import com.att.eelf.configuration.EELFManager;
 \r
 import java.io.IOException;\r
 import java.util.Date;\r
-import java.util.List;\r
 \r
 import org.json.simple.JSONArray;\r
 import org.json.simple.JSONObject;\r
 import org.json.simple.parser.JSONParser;\r
 import org.json.simple.parser.ParseException;\r
 import org.onap.clamp.clds.config.ClampProperties;\r
-import org.onap.clamp.clds.dao.CldsDao;\r
-import org.onap.clamp.clds.model.CldsEvent;\r
-import org.onap.clamp.clds.model.CldsModel;\r
-import org.onap.clamp.clds.model.DcaeEvent;\r
 import org.onap.clamp.clds.model.dcae.DcaeInventoryResponse;\r
-import org.onap.clamp.clds.model.properties.Global;\r
-import org.onap.clamp.clds.model.properties.ModelProperties;\r
 import org.onap.clamp.clds.util.JsonUtils;\r
 import org.onap.clamp.clds.util.LoggingUtils;\r
 import org.onap.clamp.util.HttpConnectionManager;\r
@@ -62,93 +55,17 @@ public class DcaeInventoryServices {
     public static final String DCAE_INVENTORY_RETRY_INTERVAL = "dcae.intentory.retry.interval";\r
     public static final String DCAE_INVENTORY_RETRY_LIMIT = "dcae.intentory.retry.limit";\r
     private final ClampProperties refProp;\r
-    private final CldsDao cldsDao;\r
     private final HttpConnectionManager httpConnectionManager;\r
 \r
     /**\r
      * Constructor.\r
      */\r
     @Autowired\r
-    public DcaeInventoryServices(ClampProperties refProp, CldsDao cldsDao,\r
-                                 HttpConnectionManager httpConnectionManager) {\r
+    public DcaeInventoryServices(ClampProperties refProp, HttpConnectionManager httpConnectionManager) {\r
         this.refProp = refProp;\r
-        this.cldsDao = cldsDao;\r
         this.httpConnectionManager = httpConnectionManager;\r
     }\r
 \r
-    /**\r
-     * Set the event inventory.\r
-     *\r
-     * @param cldsModel\r
-     *        The CldsModel\r
-     * @param userId\r
-     *        The user ID\r
-     * @throws ParseException\r
-     *         In case of DCAE Json parse exception\r
-     */\r
-    public void setEventInventory(CldsModel cldsModel, String userId) throws InterruptedException {\r
-        String artifactName = cldsModel.getControlName();\r
-        DcaeEvent dcaeEvent = new DcaeEvent();\r
-        DcaeInventoryResponse dcaeResponse = null;\r
-        Date startTime = new Date();\r
-        LoggingUtils.setTargetContext("DCAE", "setEventInventory");\r
-        if (artifactName != null) {\r
-            artifactName = artifactName + ".yml";\r
-        }\r
-        try {\r
-            // Below are the properties required for calling the dcae inventory\r
-            ModelProperties prop = new ModelProperties(cldsModel.getName(), cldsModel.getControlName(), null,\r
-                                                       false, "{}", cldsModel.getPropText());\r
-            Global global = prop.getGlobal();\r
-            String invariantServiceUuid = global.getService();\r
-            List<String> resourceUuidList = global.getResourceVf();\r
-            String resourceUuid = "";\r
-            if (resourceUuidList != null && !resourceUuidList.isEmpty()) {\r
-                resourceUuid = resourceUuidList.get(0);\r
-            }\r
-            /* Inventory service url is called in this method */\r
-            dcaeResponse = getDcaeInformation(artifactName, invariantServiceUuid, resourceUuid);\r
-            /* set dcae events */\r
-            dcaeEvent.setArtifactName(artifactName);\r
-            dcaeEvent.setEvent(DcaeEvent.EVENT_DISTRIBUTION);\r
-            LoggingUtils.setResponseContext("0", "Set inventory success", this.getClass().getName());\r
-        } catch (ParseException e) {\r
-            LoggingUtils.setResponseContext("900", "Set inventory failed", this.getClass().getName());\r
-            LoggingUtils.setErrorContext("900", "Set inventory error");\r
-            logger.error("Error during JSON decoding", e);\r
-        } catch (IOException ex) {\r
-            LoggingUtils.setResponseContext("900", "Set inventory failed", this.getClass().getName());\r
-            LoggingUtils.setErrorContext("900", "Set inventory error");\r
-            logger.error("Error during DCAE communication", ex);\r
-        } finally {\r
-            LoggingUtils.setTimeContext(startTime, new Date());\r
-            metricsLogger.info("setEventInventory complete");\r
-        }\r
-        this.analyzeAndSaveDcaeResponse(dcaeResponse, cldsModel, dcaeEvent, userId);\r
-    }\r
-\r
-    private void analyzeAndSaveDcaeResponse(DcaeInventoryResponse dcaeResponse, CldsModel cldsModel,\r
-        DcaeEvent dcaeEvent, String userId) {\r
-        if (dcaeResponse != null) {\r
-            logger.info("Dcae Response for query on inventory: " + dcaeResponse);\r
-            String oldTypeId = cldsModel.getTypeId();\r
-            if (dcaeResponse.getTypeId() != null) {\r
-                cldsModel.setTypeId(dcaeResponse.getTypeId());\r
-            }\r
-            if (dcaeResponse.getTypeName() != null) {\r
-                cldsModel.setTypeName(dcaeResponse.getTypeName());\r
-            }\r
-            if (oldTypeId == null || !cldsModel.getEvent().getActionCd().equalsIgnoreCase(CldsEvent.ACTION_DISTRIBUTE)\r
-                || cldsModel.getEvent().getActionCd().equalsIgnoreCase(CldsEvent.ACTION_SUBMITDCAE)) {\r
-                CldsEvent.insEvent(cldsDao, dcaeEvent.getControlName(), userId, dcaeEvent.getCldsActionCd(),\r
-                    CldsEvent.ACTION_STATE_RECEIVED, null);\r
-            }\r
-            cldsModel.save(cldsDao, userId);\r
-        } else {\r
-            logger.info(cldsModel.getName() + " Model is not present in Dcae Inventory Service.");\r
-        }\r
-    }\r
-\r
     private int getTotalCountFromDcaeInventoryResponse(String responseStr) throws ParseException {\r
         JSONParser parser = new JSONParser();\r
         Object obj0 = parser.parse(responseStr);\r
@@ -169,23 +86,18 @@ public class DcaeInventoryServices {
     /**\r
      * DO a query to DCAE to get some Information.\r
      *\r
-     * @param artifactName\r
-     *        The artifact Name\r
-     * @param serviceUuid\r
-     *        The service UUID\r
-     * @param resourceUuid\r
-     *        The resource UUID\r
+     * @param artifactName The artifact Name\r
+     * @param serviceUuid  The service UUID\r
+     * @param resourceUuid The resource UUID\r
      * @return The DCAE inventory for the artifact in DcaeInventoryResponse\r
-     * @throws IOException\r
-     *         In case of issues with the stream\r
-     * @throws ParseException\r
-     *         In case of issues with the Json parsing\r
+     * @throws IOException    In case of issues with the stream\r
+     * @throws ParseException In case of issues with the Json parsing\r
      */\r
     public DcaeInventoryResponse getDcaeInformation(String artifactName, String serviceUuid, String resourceUuid)\r
-        throws IOException, ParseException, InterruptedException {\r
+            throws IOException, ParseException, InterruptedException {\r
         LoggingUtils.setTargetContext("DCAE", "getDcaeInformation");\r
         String queryString = "?asdcResourceId=" + resourceUuid + "&asdcServiceId=" + serviceUuid + "&typeName="\r
-            + artifactName;\r
+                + artifactName;\r
         String fullUrl = refProp.getStringValue(DCAE_INVENTORY_URL) + "/dcae-service-types" + queryString;\r
         logger.info("Dcae Inventory Service full url - " + fullUrl);\r
         DcaeInventoryResponse response = queryDcaeInventory(fullUrl);\r
@@ -196,7 +108,7 @@ public class DcaeInventoryServices {
     }\r
 \r
     private DcaeInventoryResponse queryDcaeInventory(String fullUrl)\r
-        throws IOException, InterruptedException, ParseException {\r
+            throws IOException, InterruptedException, ParseException {\r
         int retryInterval = 0;\r
         int retryLimit = 1;\r
         if (refProp.getStringValue(DCAE_INVENTORY_RETRY_LIMIT) != null) {\r
@@ -215,7 +127,7 @@ public class DcaeInventoryServices {
                 return getItemsFromDcaeInventoryResponse(response);\r
             }\r
             logger.info(\r
-                "Dcae inventory totalCount returned is 0, so waiting " + retryInterval + "ms before retrying ...");\r
+                    "Dcae inventory totalCount returned is 0, so waiting " + retryInterval + "ms before retrying ...");\r
             // wait for a while and try to connect to DCAE again\r
             Thread.sleep(retryInterval);\r
         }\r