Fix sonar issues
[dcaegen2/platform.git] / mod / bpgenerator / onap / src / main / java / org / onap / blueprintgenerator / service / common / DmaapService.java
index d4b2c42..09ed925 100644 (file)
@@ -4,6 +4,7 @@
  *  *  org.onap.dcae
  *  *  ================================================================================
  *  *  Copyright (c) 2020  AT&T Intellectual Property. All rights reserved.
+ *  *  Copyright (c) 2021 Nokia. 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.
@@ -35,63 +36,87 @@ import java.util.Map;
 
 /**
  * @author : Ravi Mantena
- * @date 10/16/2020
- * Application: ONAP - Blueprint Generator
- * Common ONAP Service used by ONAP and DMAAP Blueprint to add DMAAP Message and Data Routers
+ * @date 10/16/2020 Application: ONAP - Blueprint Generator Common ONAP Service to add DMAAP Message
+ * and Data Routers
  */
-
-
 @Service
 public class DmaapService {
 
     @Autowired
     private InfoService infoService;
 
-    // Method is used to create the Dmaap Message Router
-    public Map<String,Object> createDmaapMessageRouter(Map<String, LinkedHashMap<String, Object>> inputs,String config, char type, String counter, String num, boolean isDmaap) {
-
-        Map<String,Object> response = new HashMap<>();
+    /**
+     * Creates Dmaap Message Router from given inputs
+     *
+     * @param inputs Input Arguments
+     * @param config Configuration
+     * @param type BP Type
+     * @param counter Counter
+     * @param num Number Incrementor
+     * @param isDmaap Dmaap Argument
+     * @return
+     */
+    public Map<String, Object> createDmaapMessageRouter(
+        Map<String, Map<String, Object>> inputs,
+        String config,
+        char type,
+        String counter,
+        String num,
+        boolean isDmaap) {
+
+        Map<String, Object> response = new HashMap<>();
         Dmaap dmaap = new Dmaap();
 
         LinkedHashMap<String, Object> stringType = new LinkedHashMap();
         stringType.put("type", "string");
 
-        if(!isDmaap){
-            Map<String, Object> infoResponse = infoService.createMessageRouterInfo(inputs, config, type);
-            inputs = (Map<String, LinkedHashMap<String, Object>>) infoResponse.get("inputs");
+        if (!isDmaap) {
+            Map<String, Object> infoResponse = infoService
+                .createMessageRouterInfo(inputs, config, type);
+            inputs = (Map<String, Map<String, Object>>) infoResponse.get("inputs");
             dmaap.setDmaap_info(infoResponse.get("info"));
-        }
-        else{
+        } else {
             String infoType = "<<" + counter + ">>";
             dmaap.setDmaap_info(infoType);
 
             GetInput u = new GetInput();
-            u.setBpInputName(config + "_" + num +"_aaf_username");
+            u.setBpInputName(config + "_" + num + "_aaf_username");
             dmaap.setUser(u);
-            inputs.put(config + "_" + num +"_aaf_username", stringType);
+            inputs.put(config + "_" + num + "_aaf_username", stringType);
 
             GetInput p = new GetInput();
-            p.setBpInputName(config + "_" + num +"_aaf_password");
+            p.setBpInputName(config + "_" + num + "_aaf_password");
             dmaap.setPass(p);
-            inputs.put(config + "_" + num +"_aaf_password", stringType);
+            inputs.put(config + "_" + num + "_aaf_password", stringType);
         }
         response.put("dmaap", dmaap);
         response.put("inputs", inputs);
         return response;
     }
 
-    // Method is used to create the Dmaap Data Router
-    public Map<String,Object> createDmaapDataRouter(Map<String, LinkedHashMap<String, Object>> inputs, String config, String counter, boolean isDmaap) {
-
-        Map<String,Object> response = new HashMap<>();
+    /**
+     * Creates Dmaap Data Router from given inputs
+     *
+     * @param inputs Input Arguments
+     * @param config Configuration
+     * @param counter Counter
+     * @param isDmaap Dmaap Argument
+     * @return
+     */
+    public Map<String, Object> createDmaapDataRouter(
+        Map<String, Map<String, Object>> inputs,
+        String config,
+        String counter,
+        boolean isDmaap) {
+
+        Map<String, Object> response = new HashMap<>();
         Dmaap dmaap = new Dmaap();
 
-        if(!isDmaap){
+        if (!isDmaap) {
             Map<String, Object> infoResponse = infoService.createDataRouterInfo(inputs, config);
-            inputs = (Map<String, LinkedHashMap<String, Object>>) infoResponse.get("inputs");
+            inputs = (Map<String, Map<String, Object>>) infoResponse.get("inputs");
             dmaap.setDmaap_info(infoResponse.get("info"));
-        }
-        else {
+        } else {
             String infoType = "<<" + counter + ">>";
             dmaap.setDmaap_info(infoType);
         }
@@ -99,5 +124,4 @@ public class DmaapService {
         response.put("inputs", inputs);
         return response;
     }
-
 }