3 * * ============LICENSE_START=======================================================
5 * * ================================================================================
6 * * Copyright (c) 2020 AT&T Intellectual Property. All rights reserved.
7 * * ================================================================================
8 * * Licensed under the Apache License, Version 2.0 (the "License");
9 * * you may not use this file except in compliance with the License.
10 * * You may obtain a copy of the License at
12 * * http://www.apache.org/licenses/LICENSE-2.0
14 * * Unless required by applicable law or agreed to in writing, software
15 * * distributed under the License is distributed on an "AS IS" BASIS,
16 * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17 * * See the License for the specific language governing permissions and
18 * * limitations under the License.
19 * * ============LICENSE_END=========================================================
24 package org.onap.blueprintgenerator.service.common;
26 import org.onap.blueprintgenerator.model.common.Dmaap;
27 import org.onap.blueprintgenerator.model.common.GetInput;
28 import org.onap.blueprintgenerator.service.InfoService;
29 import org.springframework.beans.factory.annotation.Autowired;
30 import org.springframework.stereotype.Service;
32 import java.util.HashMap;
33 import java.util.LinkedHashMap;
37 * @author : Ravi Mantena
39 * Application: ONAP - Blueprint Generator
40 * Common ONAP Service used by ONAP and DMAAP Blueprint to add DMAAP Message and Data Routers
45 public class DmaapService {
48 private InfoService infoService;
50 // Method is used to create the Dmaap Message Router
51 public Map<String,Object> createDmaapMessageRouter(Map<String, LinkedHashMap<String, Object>> inputs,String config, char type, String counter, String num, boolean isDmaap) {
53 Map<String,Object> response = new HashMap<>();
54 Dmaap dmaap = new Dmaap();
56 LinkedHashMap<String, Object> stringType = new LinkedHashMap();
57 stringType.put("type", "string");
60 Map<String, Object> infoResponse = infoService.createMessageRouterInfo(inputs, config, type);
61 inputs = (Map<String, LinkedHashMap<String, Object>>) infoResponse.get("inputs");
62 dmaap.setDmaap_info(infoResponse.get("info"));
65 String infoType = "<<" + counter + ">>";
66 dmaap.setDmaap_info(infoType);
68 GetInput u = new GetInput();
69 u.setBpInputName(config + "_" + num +"_aaf_username");
71 inputs.put(config + "_" + num +"_aaf_username", stringType);
73 GetInput p = new GetInput();
74 p.setBpInputName(config + "_" + num +"_aaf_password");
76 inputs.put(config + "_" + num +"_aaf_password", stringType);
78 response.put("dmaap", dmaap);
79 response.put("inputs", inputs);
83 // Method is used to create the Dmaap Data Router
84 public Map<String,Object> createDmaapDataRouter(Map<String, LinkedHashMap<String, Object>> inputs, String config, String counter, boolean isDmaap) {
86 Map<String,Object> response = new HashMap<>();
87 Dmaap dmaap = new Dmaap();
90 Map<String, Object> infoResponse = infoService.createDataRouterInfo(inputs, config);
91 inputs = (Map<String, LinkedHashMap<String, Object>>) infoResponse.get("inputs");
92 dmaap.setDmaap_info(infoResponse.get("info"));
95 String infoType = "<<" + counter + ">>";
96 dmaap.setDmaap_info(infoType);
98 response.put("dmaap", dmaap);
99 response.put("inputs", inputs);