summaryrefslogtreecommitdiffstats
path: root/mod/bpgenerator/onap/src/main/java/org/onap/blueprintgenerator/service/common
diff options
context:
space:
mode:
Diffstat (limited to 'mod/bpgenerator/onap/src/main/java/org/onap/blueprintgenerator/service/common')
-rw-r--r--mod/bpgenerator/onap/src/main/java/org/onap/blueprintgenerator/service/common/AppConfigService.java166
-rw-r--r--mod/bpgenerator/onap/src/main/java/org/onap/blueprintgenerator/service/common/CommonUtils.java152
-rw-r--r--mod/bpgenerator/onap/src/main/java/org/onap/blueprintgenerator/service/common/ComponentSpecService.java66
-rw-r--r--mod/bpgenerator/onap/src/main/java/org/onap/blueprintgenerator/service/common/DmaapService.java103
-rw-r--r--mod/bpgenerator/onap/src/main/java/org/onap/blueprintgenerator/service/common/ExternalCertificateDataFactoryService.java50
-rw-r--r--mod/bpgenerator/onap/src/main/java/org/onap/blueprintgenerator/service/common/ExternalCertificateParametersFactoryService.java71
-rw-r--r--mod/bpgenerator/onap/src/main/java/org/onap/blueprintgenerator/service/common/ExternalTlsInfoFactoryService.java87
-rw-r--r--mod/bpgenerator/onap/src/main/java/org/onap/blueprintgenerator/service/common/ImportsService.java98
-rw-r--r--mod/bpgenerator/onap/src/main/java/org/onap/blueprintgenerator/service/common/InterfacesService.java67
-rw-r--r--mod/bpgenerator/onap/src/main/java/org/onap/blueprintgenerator/service/common/NodeService.java222
-rw-r--r--mod/bpgenerator/onap/src/main/java/org/onap/blueprintgenerator/service/common/PgaasNodeService.java138
-rw-r--r--mod/bpgenerator/onap/src/main/java/org/onap/blueprintgenerator/service/common/PolicyNodeService.java99
-rw-r--r--mod/bpgenerator/onap/src/main/java/org/onap/blueprintgenerator/service/common/PropertiesService.java259
-rw-r--r--mod/bpgenerator/onap/src/main/java/org/onap/blueprintgenerator/service/common/QuotationService.java59
-rw-r--r--mod/bpgenerator/onap/src/main/java/org/onap/blueprintgenerator/service/common/ResourceConfigService.java98
-rw-r--r--mod/bpgenerator/onap/src/main/java/org/onap/blueprintgenerator/service/common/StartInputsService.java97
-rw-r--r--mod/bpgenerator/onap/src/main/java/org/onap/blueprintgenerator/service/common/StartService.java65
17 files changed, 1897 insertions, 0 deletions
diff --git a/mod/bpgenerator/onap/src/main/java/org/onap/blueprintgenerator/service/common/AppConfigService.java b/mod/bpgenerator/onap/src/main/java/org/onap/blueprintgenerator/service/common/AppConfigService.java
new file mode 100644
index 0000000..c6d744c
--- /dev/null
+++ b/mod/bpgenerator/onap/src/main/java/org/onap/blueprintgenerator/service/common/AppConfigService.java
@@ -0,0 +1,166 @@
+/*
+ *
+ * * ============LICENSE_START=======================================================
+ * * org.onap.dcae
+ * * ================================================================================
+ * * Copyright (c) 2020 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.
+ * * You may obtain a copy of the License at
+ * *
+ * * http://www.apache.org/licenses/LICENSE-2.0
+ * *
+ * * Unless required by applicable law or agreed to in writing, software
+ * * distributed under the License is distributed on an "AS IS" BASIS,
+ * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * * See the License for the specific language governing permissions and
+ * * limitations under the License.
+ * * ============LICENSE_END=========================================================
+ *
+ *
+ */
+
+package org.onap.blueprintgenerator.service.common;
+
+import org.onap.blueprintgenerator.constants.Constants;
+import org.onap.blueprintgenerator.model.common.Appconfig;
+import org.onap.blueprintgenerator.model.common.Dmaap;
+import org.onap.blueprintgenerator.model.common.GetInput;
+import org.onap.blueprintgenerator.model.componentspec.OnapComponentSpec;
+import org.onap.blueprintgenerator.model.componentspec.common.Calls;
+import org.onap.blueprintgenerator.model.componentspec.common.Parameters;
+import org.onap.blueprintgenerator.model.componentspec.common.Publishes;
+import org.onap.blueprintgenerator.model.componentspec.common.Subscribes;
+import org.onap.blueprintgenerator.service.base.BlueprintHelperService;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+
+import java.util.HashMap;
+import java.util.LinkedHashMap;
+import java.util.Map;
+import java.util.TreeMap;
+
+/**
+ * @author : Ravi Mantena
+ * @date 10/16/2020
+ * Application: ONAP - Blueprint Generator
+ * Common ONAP Service used by ONAP and DMAAP Blueprint to create App Config
+ */
+
+
+@Service("onapAppConfigService")
+public class AppConfigService {
+
+ @Autowired
+ private DmaapService dmaapService;
+
+ @Autowired
+ private BlueprintHelperService blueprintHelperService;
+
+ public Map<String,Object> createAppconfig(Map<String, LinkedHashMap<String, Object>> inputs, OnapComponentSpec onapComponentSpec, String override, boolean isDmaap) {
+
+ Map<String,Object> response = new HashMap<>();
+ Appconfig appconfig = new Appconfig();
+
+ Calls[] call = new Calls[0];
+ appconfig.setService_calls(call);
+
+ Map<String, Dmaap> streamPublishes = new TreeMap<>();
+ if(onapComponentSpec.getStreams() != null) {
+ if (onapComponentSpec.getStreams().getPublishes() != null) {
+ for (Publishes publishes : onapComponentSpec.getStreams().getPublishes()) {
+ if (blueprintHelperService.isDataRouterType(publishes.getType())) {
+ String config = publishes.getConfig_key();
+ String name = config + Constants._FEED;
+ Map<String, Object> dmaapDataRouterResponse = dmaapService.createDmaapDataRouter(inputs, config, name, isDmaap);
+ inputs = (Map<String, LinkedHashMap<String, Object>>) dmaapDataRouterResponse.get("inputs");
+ Dmaap dmaap = (Dmaap) dmaapDataRouterResponse.get("dmaap");
+ dmaap.setType(publishes.getType());
+ streamPublishes.put(config, dmaap);
+ } else if (blueprintHelperService.isMessageRouterType(publishes.getType())) {
+ String config = publishes.getConfig_key();
+ String name = config + Constants._TOPIC;
+ Map<String, Object> dmaapDataRouterResponse = dmaapService.createDmaapMessageRouter(inputs, config, 'p', name, name, isDmaap);
+ inputs = (Map<String, LinkedHashMap<String, Object>>) dmaapDataRouterResponse.get("inputs");
+ Dmaap dmaap = (Dmaap) dmaapDataRouterResponse.get("dmaap");
+ dmaap.setType(publishes.getType());
+ streamPublishes.put(config, dmaap);
+ }
+ }
+ }
+ }
+
+ Map<String, Dmaap> streamSubscribes = new TreeMap<>();
+
+ if(onapComponentSpec.getStreams() != null) {
+ if (onapComponentSpec.getStreams().getSubscribes() != null) {
+ for (Subscribes subscribes : onapComponentSpec.getStreams().getSubscribes()) {
+ if (blueprintHelperService.isDataRouterType(subscribes.getType())) {
+ String config = subscribes.getConfig_key();
+ String name = config + Constants._FEED;
+ Map<String, Object> dmaapDataRouterResponse = dmaapService.createDmaapDataRouter(inputs, config, name, isDmaap);
+ inputs = (Map<String, LinkedHashMap<String, Object>>) dmaapDataRouterResponse.get("inputs");
+ Dmaap dmaap = (Dmaap) dmaapDataRouterResponse.get("dmaap");
+ dmaap.setType(subscribes.getType());
+ streamSubscribes.put(config, dmaap);
+ } else if (blueprintHelperService.isMessageRouterType(subscribes.getType())) {
+ String config = subscribes.getConfig_key();
+ String name = config + Constants._TOPIC;
+ Map<String, Object> dmaapDataRouterResponse = dmaapService.createDmaapMessageRouter(inputs, config, 's', name, name, isDmaap);
+ inputs = (Map<String, LinkedHashMap<String, Object>>) dmaapDataRouterResponse.get("inputs");
+ Dmaap dmaap = (Dmaap) dmaapDataRouterResponse.get("dmaap");
+ dmaap.setType(subscribes.getType());
+ streamSubscribes.put(config, dmaap);
+ }
+ }
+ }
+ }
+
+ appconfig.setStreams_publishes(streamPublishes);
+ appconfig.setStreams_subscribes(streamSubscribes);
+
+ Map<String, Object> parameters = new TreeMap<>();
+ for(Parameters p: onapComponentSpec.getParameters()) {
+ String pName = p.getName();
+ if(p.isSourced_at_deployment()) {
+ GetInput paramInput = new GetInput();
+ paramInput.setBpInputName(pName);
+ parameters.put(pName, paramInput);
+ if(!"".equals(p.getValue())) {
+ LinkedHashMap<String, Object> pInputs = blueprintHelperService.createStringInput( p.getValue());
+ inputs.put(pName, pInputs);
+ } else {
+ LinkedHashMap<String, Object> pInputs = new LinkedHashMap<>();
+ pInputs.put("type", "string");
+ inputs.put(pName, pInputs);
+ }
+ } else {
+ if("string".equals(p.getType())) {
+ String val =(String) p.getValue();
+ val = '"' + val + '"';
+ parameters.put(pName, val);
+ }
+ else {
+ parameters.put(pName, p.getValue());
+ // Updated code to resolve the issue of missing \ for collector.schema.file
+ //parameters.put(pName, pName.equals("collector.schema.file") ? ((String)p.getValue()).replace("\"", "\\\"") : p.getValue());
+ }
+ }
+ }
+ if(override != null) {
+ GetInput ov = new GetInput();
+ ov.setBpInputName(Constants.SERVICE_COMPONENT_NAME_OVERRIDE);
+ parameters.put(Constants.SERVICE_COMPONENT_NAME_OVERRIDE, ov);
+ LinkedHashMap<String, Object> over = blueprintHelperService.createStringInput( override);
+ inputs.put(Constants.SERVICE_COMPONENT_NAME_OVERRIDE, over);
+ }
+ appconfig.setParams(parameters);
+
+ response.put("appconfig", appconfig);
+ response.put("inputs", inputs);
+ return response;
+
+ }
+
+}
diff --git a/mod/bpgenerator/onap/src/main/java/org/onap/blueprintgenerator/service/common/CommonUtils.java b/mod/bpgenerator/onap/src/main/java/org/onap/blueprintgenerator/service/common/CommonUtils.java
new file mode 100644
index 0000000..97ed47f
--- /dev/null
+++ b/mod/bpgenerator/onap/src/main/java/org/onap/blueprintgenerator/service/common/CommonUtils.java
@@ -0,0 +1,152 @@
+/*
+ *
+ * * ============LICENSE_START=======================================================
+ * * org.onap.dcae
+ * * ================================================================================
+ * * Copyright (c) 2020 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.
+ * * You may obtain a copy of the License at
+ * *
+ * * http://www.apache.org/licenses/LICENSE-2.0
+ * *
+ * * Unless required by applicable law or agreed to in writing, software
+ * * distributed under the License is distributed on an "AS IS" BASIS,
+ * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * * See the License for the specific language governing permissions and
+ * * limitations under the License.
+ * * ============LICENSE_END=========================================================
+ *
+ *
+ */
+
+package org.onap.blueprintgenerator.service.common;
+
+
+
+import org.apache.commons.cli.CommandLineParser;
+import org.apache.commons.cli.HelpFormatter;
+import org.apache.commons.cli.ParseException;
+import org.apache.commons.cli.DefaultParser;
+import org.apache.commons.cli.Options;
+import org.apache.commons.cli.CommandLine;
+import org.onap.blueprintgenerator.model.common.Input;
+
+import org.springframework.stereotype.Service;
+import org.springframework.util.StringUtils;
+
+import static java.lang.System.exit;
+
+/**
+ * @author : Ravi Mantena
+ * @date 10/16/2020
+ * Application: ONAP - Blueprint Generator
+ * Common ONAP Service used by ONAP and DMAAP Blueprint to Print Instructions and Parse Inputs
+ */
+
+
+@Service("onapCommonUtilsService")
+public class CommonUtils {
+
+ public void printInstructions() {
+ System.out.println("OPTIONS:");
+ System.out.println("-i OR --component-spec: The path of the ONAP Blueprint INPUT JSON SPEC FILE (Required)");
+ System.out.println("-p OR --blueprint-path: The path of the ONAP Blueprint OUTPUT where it will be saved (Required)");
+ System.out.println("-n OR --blueprint-name: The NAME of the ONAP Blueprint OUTPUT that will be created (Optional)");
+ System.out.println("-t OR --imports: The path of the ONAP Blueprint IMPORT FILE (Optional)");
+ System.out.println("-o OR --service-name-override: The Value used to OVERRIDE the SERVICE NAME of the ONAP Blueprint (Optional)");
+ System.out.println("-d OR --dmaap-plugin: The option to create a ONAP Blueprint with DMAAP Plugin (Optional)");
+ System.out.println("Syntax to run from command line: \n For Blueprint : java -jar target/<JAR Filename>.jar app ONAP -i componentspec -p OutputBlueprintPath -n Blueprintname -d \n For PolicyCreate: java -jar target/<JAR Filename>.jar app ONAP -type policycreate -i componentspec -p OutputPolicyPath");
+ }
+
+ public Input parseInputs(String[] args) {
+ String[] modArgs = new String[args.length];
+ for(int i=0; i<args.length; i++){
+ if(args[i].contains("--component-spec"))
+ modArgs[i] = "-_component_spec";
+ else if(args[i].contains("--blueprint-path"))
+ modArgs[i] = "-_blueprint_path";
+ else if(args[i].contains("--blueprint-name"))
+ modArgs[i] = "-_blueprint_name";
+ else if(args[i].contains("--imports"))
+ modArgs[i] = "-_imports";
+ else if(args[i].contains("--service-name-override"))
+ modArgs[i] = "-_service_name_override";
+ else if(args[i].contains("--dmaap-plugin"))
+ modArgs[i] = "-_dmaap_plugin";
+ else
+ modArgs[i] = args[i];
+ }
+ String commands = " ";
+ for (String s : modArgs) {
+
+ commands = commands + " " + s;
+ }
+
+ //checks if the required inputs are present or not
+ if (!(commands.contains(" -i ")|| commands.contains(" -_component_spec "))
+ && !(commands.contains(" -p ") || commands.contains(" -_blueprint_path ") ) ) {
+ System.out.println("\n Please enter the ONAP Blueprint required inputs for: \n -i (The path of the ONAP Blueprint INPUT JSON SPEC FILE), \n -p (The path of the ONAP Blueprint OUTPUT where it will be saved)");
+ exit(-1);
+ }
+
+
+ CommandLineParser parser = new DefaultParser();
+ HelpFormatter formatter = new HelpFormatter();
+
+ Options options = new Options();
+
+ options.addOption("i", "Spec", true, "ComponentSpec Input File of the ONAP Blueprint");
+ options.addOption("_component_spec", "Spec", true, "ComponentSpec Input File of the ONAP Blueprint");
+ options.addOption("p", "Path", true, "Path of the ONAP Blueprint OUTPUT");
+ options.addOption("_blueprint_path", "Path", true, "Path of the ONAP Blueprint OUTPUT");
+ options.addOption("n", "name", true, "NAME of the ONAP Blueprint OUTPUT");
+ options.addOption("_blueprint_name", "name", true, "NAME of the ONAP Blueprint OUTPUT");
+ options.addOption("t", "Import File", true, "Import file for the OUTPUT Blueprint Imports");
+ options.addOption("_imports", "Import File", true, "Import file for the OUTPUT Blueprint Imports");
+ options.addOption("o", "Service name Override", true, "Value used to override the OUTPUT Blueprint service name");
+ options.addOption("_service_name_override", "Service name Override", true, "Value used to override the OUTPUT Blueprint service name");
+ options.addOption("d", "Dmaap Plugin", false, "Flag used to indicate ONAP Blueprint OUTPUT uses the DMaaP plugin");
+ options.addOption("_dmaap_plugin", "Dmaap Plugin", false, "Flag used to indicate ONAP Blueprint OUTPUT uses the DMaaP plugin");
+
+ Input input = new Input();
+ try {
+ CommandLine commandLine = parser.parse(options, modArgs);
+ input.setComponentSpecPath(commandLine.getOptionValue("i") == null ? commandLine.getOptionValue("_component_spec") : commandLine.getOptionValue("i"));
+ input.setOutputPath(commandLine.getOptionValue("p") == null ? commandLine.getOptionValue("_blueprint_path") : commandLine.getOptionValue("p"));
+ input.setBluePrintName(commandLine.getOptionValue("n") == null ? commandLine.getOptionValue("_blueprint_name") : commandLine.getOptionValue("n"));
+ input.setImportPath(commandLine.getOptionValue("t") == null ? commandLine.getOptionValue("_imports") : commandLine.getOptionValue("t"));
+ input.setBpType((commands.contains(" -d ") || commands.contains(" -_dmaap_plugin ") ) ? "d" : "o");
+ input.setServiceNameOverride(commandLine.getOptionValue("o") == null ? commandLine.getOptionValue("_service_name_override") == null ? "" : commandLine.getOptionValue("_service_name_override") : commandLine.getOptionValue("o"));
+ } catch (ParseException ex) {
+ ex.printStackTrace();
+ System.out.println(ex.getMessage());
+ formatter.printHelp("Required/Valid Inputs to create ONAP Blueprint are not provided", options);
+ exit(-1);
+ }
+ if (StringUtils.isEmpty(input.getComponentSpecPath())) {
+ System.out.println("The path of the ONAP Blueprint INPUT JSON SPEC FILE is not specified");
+ exit(-1);
+ }
+ if (StringUtils.isEmpty(input.getOutputPath())) {
+ System.out.println("The path of the ONAP Blueprint OUTPUT where it will be saved is not specified");
+ exit(-1);
+ }
+ if (commands.contains(" -n ") || commands.contains(" -_blueprint_name ")) {
+ if (StringUtils.isEmpty(input.getBluePrintName())) {
+ System.out.println("The NAME of the ONAP Blueprint OUTPUT that will be created is not specified");
+ exit(-1);
+ }
+ }
+ if (commands.contains(" -t ")|| commands.contains(" -_imports ")) {
+ if (StringUtils.isEmpty(input.getImportPath())) {
+ System.out.println("The path of the ONAP Blueprint Imports File is not specified");
+ exit(-1);
+ }
+ }
+
+ return input;
+ }
+
+}
diff --git a/mod/bpgenerator/onap/src/main/java/org/onap/blueprintgenerator/service/common/ComponentSpecService.java b/mod/bpgenerator/onap/src/main/java/org/onap/blueprintgenerator/service/common/ComponentSpecService.java
new file mode 100644
index 0000000..e8d648d
--- /dev/null
+++ b/mod/bpgenerator/onap/src/main/java/org/onap/blueprintgenerator/service/common/ComponentSpecService.java
@@ -0,0 +1,66 @@
+/*
+ *
+ * * ============LICENSE_START=======================================================
+ * * org.onap.dcae
+ * * ================================================================================
+ * * Copyright (c) 2020 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.
+ * * You may obtain a copy of the License at
+ * *
+ * * http://www.apache.org/licenses/LICENSE-2.0
+ * *
+ * * Unless required by applicable law or agreed to in writing, software
+ * * distributed under the License is distributed on an "AS IS" BASIS,
+ * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * * See the License for the specific language governing permissions and
+ * * limitations under the License.
+ * * ============LICENSE_END=========================================================
+ *
+ *
+ */
+
+package org.onap.blueprintgenerator.service.common;
+
+import org.onap.blueprintgenerator.exception.ComponentSpecException;
+import org.onap.blueprintgenerator.model.componentspec.OnapComponentSpec;
+import com.fasterxml.jackson.databind.ObjectMapper;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.beans.factory.annotation.Qualifier;
+import org.springframework.stereotype.Service;
+
+import java.io.File;
+
+/**
+ * @author : Ravi Mantena
+ * @date 10/16/2020
+ * Application: ONAP - Blueprint Generator
+ * Common ONAP Service used by ONAP and DMAAP Blueprint to create Component Spec from File
+ */
+
+
+@Service("onapComponentSpecService")
+public class ComponentSpecService {
+
+ @Qualifier("objectMapper")
+ @Autowired
+ private ObjectMapper componentMapper;
+
+ @Qualifier("yamlObjectMapper")
+ @Autowired
+ private ObjectMapper yamlComponentMapper;
+
+ public OnapComponentSpec createComponentSpecFromFile(String componentSpecPath) {
+ OnapComponentSpec componentSpec;
+ try {
+ if(!componentSpecPath.endsWith(".json"))
+ componentMapper = yamlComponentMapper;
+ componentSpec = componentMapper.readValue(new File(componentSpecPath), OnapComponentSpec.class);
+ } catch (Exception ex) {
+ throw new ComponentSpecException("Unable to create ONAP Component Spec from the input file: "+ componentSpecPath, ex);
+ }
+ return componentSpec;
+ }
+
+}
diff --git a/mod/bpgenerator/onap/src/main/java/org/onap/blueprintgenerator/service/common/DmaapService.java b/mod/bpgenerator/onap/src/main/java/org/onap/blueprintgenerator/service/common/DmaapService.java
new file mode 100644
index 0000000..d4b2c42
--- /dev/null
+++ b/mod/bpgenerator/onap/src/main/java/org/onap/blueprintgenerator/service/common/DmaapService.java
@@ -0,0 +1,103 @@
+/*
+ *
+ * * ============LICENSE_START=======================================================
+ * * org.onap.dcae
+ * * ================================================================================
+ * * Copyright (c) 2020 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.
+ * * You may obtain a copy of the License at
+ * *
+ * * http://www.apache.org/licenses/LICENSE-2.0
+ * *
+ * * Unless required by applicable law or agreed to in writing, software
+ * * distributed under the License is distributed on an "AS IS" BASIS,
+ * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * * See the License for the specific language governing permissions and
+ * * limitations under the License.
+ * * ============LICENSE_END=========================================================
+ *
+ *
+ */
+
+package org.onap.blueprintgenerator.service.common;
+
+import org.onap.blueprintgenerator.model.common.Dmaap;
+import org.onap.blueprintgenerator.model.common.GetInput;
+import org.onap.blueprintgenerator.service.InfoService;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+
+import java.util.HashMap;
+import java.util.LinkedHashMap;
+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
+ */
+
+
+@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<>();
+ 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");
+ dmaap.setDmaap_info(infoResponse.get("info"));
+ }
+ else{
+ String infoType = "<<" + counter + ">>";
+ dmaap.setDmaap_info(infoType);
+
+ GetInput u = new GetInput();
+ u.setBpInputName(config + "_" + num +"_aaf_username");
+ dmaap.setUser(u);
+ inputs.put(config + "_" + num +"_aaf_username", stringType);
+
+ GetInput p = new GetInput();
+ p.setBpInputName(config + "_" + num +"_aaf_password");
+ dmaap.setPass(p);
+ 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<>();
+ Dmaap dmaap = new Dmaap();
+
+ if(!isDmaap){
+ Map<String, Object> infoResponse = infoService.createDataRouterInfo(inputs, config);
+ inputs = (Map<String, LinkedHashMap<String, Object>>) infoResponse.get("inputs");
+ dmaap.setDmaap_info(infoResponse.get("info"));
+ }
+ else {
+ String infoType = "<<" + counter + ">>";
+ dmaap.setDmaap_info(infoType);
+ }
+ response.put("dmaap", dmaap);
+ response.put("inputs", inputs);
+ return response;
+ }
+
+}
diff --git a/mod/bpgenerator/onap/src/main/java/org/onap/blueprintgenerator/service/common/ExternalCertificateDataFactoryService.java b/mod/bpgenerator/onap/src/main/java/org/onap/blueprintgenerator/service/common/ExternalCertificateDataFactoryService.java
new file mode 100644
index 0000000..ab48ada
--- /dev/null
+++ b/mod/bpgenerator/onap/src/main/java/org/onap/blueprintgenerator/service/common/ExternalCertificateDataFactoryService.java
@@ -0,0 +1,50 @@
+/*
+ *
+ * * ============LICENSE_START=======================================================
+ * * org.onap.dcae
+ * * ================================================================================
+ * * Copyright (c) 2020 Nokia. All rights reserved.
+ * * Copyright (c) 2020 AT&T. 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.
+ * * You may obtain a copy of the License at
+ * *
+ * * http://www.apache.org/licenses/LICENSE-2.0
+ * *
+ * * Unless required by applicable law or agreed to in writing, software
+ * * distributed under the License is distributed on an "AS IS" BASIS,
+ * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * * See the License for the specific language governing permissions and
+ * * limitations under the License.
+ * * ============LICENSE_END=========================================================
+ *
+ *
+ */
+
+package org.onap.blueprintgenerator.service.common;
+
+import org.onap.blueprintgenerator.constants.Constants;
+import org.onap.blueprintgenerator.model.common.GetInput;
+import org.springframework.stereotype.Service;
+
+/**
+ * @author : Ravi Mantena
+ * @date 10/16/2020
+ * Application: ONAP - Blueprint Generator
+ * Common ONAP Service used by ONAP and DMAAP Blueprint to add External Certificate Data Factory
+ */
+
+
+@Service
+public abstract class ExternalCertificateDataFactoryService {
+
+ // Method to concatenate Constant with field
+ protected static GetInput createPrefixedGetInput(String fieldName) {
+ return new GetInput(addPrefix(fieldName));
+ }
+
+ // Method to concatenate the Constant INPUT_PREFIX to the input field
+ protected static String addPrefix(String fieldName) { return Constants.INPUT_PREFIX + fieldName; }
+
+}
diff --git a/mod/bpgenerator/onap/src/main/java/org/onap/blueprintgenerator/service/common/ExternalCertificateParametersFactoryService.java b/mod/bpgenerator/onap/src/main/java/org/onap/blueprintgenerator/service/common/ExternalCertificateParametersFactoryService.java
new file mode 100644
index 0000000..b739e4b
--- /dev/null
+++ b/mod/bpgenerator/onap/src/main/java/org/onap/blueprintgenerator/service/common/ExternalCertificateParametersFactoryService.java
@@ -0,0 +1,71 @@
+/*
+ *
+ * * ============LICENSE_START=======================================================
+ * * org.onap.dcae
+ * * ================================================================================
+ * * Copyright (c) 2020 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.
+ * * You may obtain a copy of the License at
+ * *
+ * * http://www.apache.org/licenses/LICENSE-2.0
+ * *
+ * * Unless required by applicable law or agreed to in writing, software
+ * * distributed under the License is distributed on an "AS IS" BASIS,
+ * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * * See the License for the specific language governing permissions and
+ * * limitations under the License.
+ * * ============LICENSE_END=========================================================
+ *
+ *
+ */
+
+package org.onap.blueprintgenerator.service.common;
+
+import org.onap.blueprintgenerator.constants.Constants;
+import org.onap.blueprintgenerator.model.common.ExternalCertificateParameters;
+import org.onap.blueprintgenerator.service.base.BlueprintHelperService;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+
+import java.util.LinkedHashMap;
+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 External Certificate Parameters
+ */
+
+
+@Service
+public class ExternalCertificateParametersFactoryService extends ExternalCertificateDataFactoryService {
+
+ @Autowired
+ private BlueprintHelperService blueprintHelperService;
+
+ // method to create external certificate parameters
+ public ExternalCertificateParameters create() {
+ ExternalCertificateParameters externalCertificateParameters = new ExternalCertificateParameters();
+ externalCertificateParameters.setCommonName(createPrefixedGetInput(Constants.COMMON_NAME_FIELD));
+ externalCertificateParameters.setSans(createPrefixedGetInput(Constants.SANS_FIELD));
+ return externalCertificateParameters;
+ }
+
+ // method to create input list for external certificate parameters factory
+ public Map<String, LinkedHashMap<String, Object>> createInputList() {
+ Map<String, LinkedHashMap<String, Object>> retInputs = new LinkedHashMap<>();
+
+ LinkedHashMap<String, Object> commonNameInputMap = blueprintHelperService.createStringInput("Common name which should be present in certificate.",Constants.DEFAULT_COMMON_NAME);
+ retInputs.put(addPrefix(Constants.COMMON_NAME_FIELD), commonNameInputMap);
+
+ LinkedHashMap<String, Object> sansInputMap = blueprintHelperService.createStringInput("\"List of Subject Alternative Names (SANs) which should be present in certificate. " +
+ "Delimiter - : Should contain a common_name value and other FQDNs under which the given " +"component is accessible.\"",Constants.DEFAULT_SANS);
+ retInputs.put(addPrefix(Constants.SANS_FIELD), sansInputMap);
+
+ return retInputs;
+ }
+
+}
diff --git a/mod/bpgenerator/onap/src/main/java/org/onap/blueprintgenerator/service/common/ExternalTlsInfoFactoryService.java b/mod/bpgenerator/onap/src/main/java/org/onap/blueprintgenerator/service/common/ExternalTlsInfoFactoryService.java
new file mode 100644
index 0000000..10364ab
--- /dev/null
+++ b/mod/bpgenerator/onap/src/main/java/org/onap/blueprintgenerator/service/common/ExternalTlsInfoFactoryService.java
@@ -0,0 +1,87 @@
+/*
+ *
+ * * ============LICENSE_START=======================================================
+ * * org.onap.dcae
+ * * ================================================================================
+ * * Copyright (c) 2020 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.
+ * * You may obtain a copy of the License at
+ * *
+ * * http://www.apache.org/licenses/LICENSE-2.0
+ * *
+ * * Unless required by applicable law or agreed to in writing, software
+ * * distributed under the License is distributed on an "AS IS" BASIS,
+ * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * * See the License for the specific language governing permissions and
+ * * limitations under the License.
+ * * ============LICENSE_END=========================================================
+ *
+ *
+ */
+
+package org.onap.blueprintgenerator.service.common;
+
+import org.onap.blueprintgenerator.constants.Constants;
+import org.onap.blueprintgenerator.model.common.ExternalTlsInfo;
+import org.onap.blueprintgenerator.model.componentspec.OnapComponentSpec;
+import org.onap.blueprintgenerator.service.base.BlueprintHelperService;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+
+import java.util.HashMap;
+import java.util.LinkedHashMap;
+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 External TLS Info
+ */
+
+
+@Service
+public class ExternalTlsInfoFactoryService extends ExternalCertificateDataFactoryService {
+
+ @Autowired
+ private ExternalCertificateParametersFactoryService externalCertificateParametersFactoryService;
+
+ @Autowired
+ private BlueprintHelperService blueprintHelperService;
+
+ //Method to create External TLS Info from Component Spec
+ public ExternalTlsInfo createFromComponentSpec(OnapComponentSpec cs) {
+ ExternalTlsInfo externalTlsInfoBp = new ExternalTlsInfo();
+ Map<String, Object> tlsInfoCs = cs.getAuxilary().getTls_info();
+
+ externalTlsInfoBp.setExternalCertDirectory((String) tlsInfoCs.get(Constants.CERT_DIRECTORY_FIELD));
+ externalTlsInfoBp.setUseExternalTls(createPrefixedGetInput(Constants.USE_EXTERNAL_TLS_FIELD));
+ externalTlsInfoBp.setCaName(createPrefixedGetInput(Constants.CA_NAME_FIELD));
+ externalTlsInfoBp.setCertType(createPrefixedGetInput(Constants.CERT_TYPE_FIELD));
+ externalTlsInfoBp.setExternalCertificateParameters(externalCertificateParametersFactoryService.create());
+
+ return externalTlsInfoBp;
+ }
+
+ //Method to create Input List for External TLS Info from Component Spec
+ public Map<String, LinkedHashMap<String, Object>> createInputListFromComponentSpec(OnapComponentSpec cs) {
+
+ Map<String, LinkedHashMap<String, Object>> retInputs = new HashMap<>();
+
+ Map<String, Object> externalTlsInfoCs = cs.getAuxilary().getTls_info();
+ LinkedHashMap<String, Object> useTlsFlagInput = blueprintHelperService.createBooleanInput("Flag to indicate external tls enable/disable.",externalTlsInfoCs.get(Constants.USE_EXTERNAL_TLS_FIELD));
+ retInputs.put(addPrefix(Constants.USE_EXTERNAL_TLS_FIELD), useTlsFlagInput);
+
+ LinkedHashMap<String, Object> caNameInputMap = blueprintHelperService.createStringInput("Name of Certificate Authority configured on CertService side.",Constants.DEFAULT_CA);
+ retInputs.put(addPrefix(Constants.CA_NAME_FIELD), caNameInputMap);
+
+ LinkedHashMap<String, Object> certTypeInputMap = blueprintHelperService.createStringInput("Format of provided certificates",Constants.DEFAULT_CERT_TYPE);
+ retInputs.put(addPrefix(Constants.CERT_TYPE_FIELD), certTypeInputMap);
+
+ retInputs.putAll(externalCertificateParametersFactoryService.createInputList());
+ return retInputs;
+ }
+
+}
diff --git a/mod/bpgenerator/onap/src/main/java/org/onap/blueprintgenerator/service/common/ImportsService.java b/mod/bpgenerator/onap/src/main/java/org/onap/blueprintgenerator/service/common/ImportsService.java
new file mode 100644
index 0000000..cb9c03c
--- /dev/null
+++ b/mod/bpgenerator/onap/src/main/java/org/onap/blueprintgenerator/service/common/ImportsService.java
@@ -0,0 +1,98 @@
+/*
+ *
+ * * ============LICENSE_START=======================================================
+ * * org.onap.dcae
+ * * ================================================================================
+ * * Copyright (c) 2020 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.
+ * * You may obtain a copy of the License at
+ * *
+ * * http://www.apache.org/licenses/LICENSE-2.0
+ * *
+ * * Unless required by applicable law or agreed to in writing, software
+ * * distributed under the License is distributed on an "AS IS" BASIS,
+ * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * * See the License for the specific language governing permissions and
+ * * limitations under the License.
+ * * ============LICENSE_END=========================================================
+ *
+ *
+ */
+
+package org.onap.blueprintgenerator.service.common;
+
+import com.fasterxml.jackson.databind.ObjectMapper;
+import org.onap.blueprintgenerator.model.common.Imports;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.beans.factory.annotation.Qualifier;
+import org.springframework.beans.factory.annotation.Value;
+import org.springframework.stereotype.Service;
+
+import java.io.File;
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * @author : Ravi Mantena
+ * @date 10/16/2020
+ * Application: DCAE/ONAP - Blueprint Generator
+ * Common Module: Used by ONAP Blueprint Application
+ * Service: For Imports
+ */
+
+@Service
+public class ImportsService {
+
+ @Value("${imports.onap.types}")
+ private String importsOnapTypes;
+
+ @Value("${imports.onap.K8s.plugintypes}")
+ private String importsOnapK8sPlugintypes;
+
+ @Value("${imports.onap.K8s.dcaepolicyplugin}")
+ private String importsOnapK8sDcaepolicyplugin;
+
+ @Value("${imports.dmaap.dmaapplugin}")
+ private String importsDmaapDmaapplugin;
+
+ @Value("${import.Postgres}")
+ private String importPostgres;
+
+ @Value("${import.Clamp}")
+ private String importClamp;
+
+
+ @Qualifier("yamlObjectMapper")
+ @Autowired
+ protected ObjectMapper yamlObjectMapper;
+
+ public List<String> createImports(String bpType) {
+ List<String> imports = new ArrayList<>();
+ if (bpType.equals("o")) {
+ imports.add(importsOnapTypes);
+ imports.add(importsOnapK8sPlugintypes);
+ imports.add(importsOnapK8sDcaepolicyplugin);
+ imports.add(importPostgres);
+ imports.add(importClamp);
+ }
+ else {
+ imports.add(importsOnapTypes);
+ imports.add(importsOnapK8sPlugintypes);
+ imports.add(importsDmaapDmaapplugin);
+ imports.add(importPostgres);
+ imports.add(importClamp);
+ }
+ return imports;
+ }
+
+ public List<String> createImportsFromFile(String path) throws IOException {
+ File importPath = new File(path);
+ Imports imports = yamlObjectMapper.readValue(importPath, Imports.class);
+ imports.getImports().removeIf(String::isBlank);
+ return imports.getImports();
+ }
+
+}
diff --git a/mod/bpgenerator/onap/src/main/java/org/onap/blueprintgenerator/service/common/InterfacesService.java b/mod/bpgenerator/onap/src/main/java/org/onap/blueprintgenerator/service/common/InterfacesService.java
new file mode 100644
index 0000000..bfd14a4
--- /dev/null
+++ b/mod/bpgenerator/onap/src/main/java/org/onap/blueprintgenerator/service/common/InterfacesService.java
@@ -0,0 +1,67 @@
+/*
+ *
+ * * ============LICENSE_START=======================================================
+ * * org.onap.dcae
+ * * ================================================================================
+ * * Copyright (c) 2020 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.
+ * * You may obtain a copy of the License at
+ * *
+ * * http://www.apache.org/licenses/LICENSE-2.0
+ * *
+ * * Unless required by applicable law or agreed to in writing, software
+ * * distributed under the License is distributed on an "AS IS" BASIS,
+ * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * * See the License for the specific language governing permissions and
+ * * limitations under the License.
+ * * ============LICENSE_END=========================================================
+ *
+ *
+ */
+
+package org.onap.blueprintgenerator.service.common;
+
+import org.onap.blueprintgenerator.model.common.Interfaces;
+import org.onap.blueprintgenerator.model.common.Start;
+import org.onap.blueprintgenerator.model.componentspec.OnapComponentSpec;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+
+import java.util.HashMap;
+import java.util.LinkedHashMap;
+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 Interfaces
+ */
+
+
+@Service
+public class InterfacesService {
+
+ @Autowired
+ private StartService startService;
+
+ // Method to create Interface to include Start and Start inputs sections in BP
+ public Map<String,Object> createInterface(Map<String, LinkedHashMap<String, Object>> inputs, OnapComponentSpec onapComponentSpec){
+
+ Map<String,Object> response = new HashMap<>();
+ Interfaces interfaces = new Interfaces();
+
+ Map<String, Object> startResponse = startService.createStart(inputs, onapComponentSpec);
+ inputs = (Map<String, LinkedHashMap<String, Object>>) startResponse.get("inputs");
+
+ interfaces.setStart((Start) startResponse.get("start"));
+
+ response.put("interfaces", interfaces);
+ response.put("inputs", inputs);
+ return response;
+ }
+
+}
+
diff --git a/mod/bpgenerator/onap/src/main/java/org/onap/blueprintgenerator/service/common/NodeService.java b/mod/bpgenerator/onap/src/main/java/org/onap/blueprintgenerator/service/common/NodeService.java
new file mode 100644
index 0000000..b8da0d7
--- /dev/null
+++ b/mod/bpgenerator/onap/src/main/java/org/onap/blueprintgenerator/service/common/NodeService.java
@@ -0,0 +1,222 @@
+/*
+ *
+ * * ============LICENSE_START=======================================================
+ * * org.onap.dcae
+ * * ================================================================================
+ * * Copyright (c) 2020 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.
+ * * You may obtain a copy of the License at
+ * *
+ * * http://www.apache.org/licenses/LICENSE-2.0
+ * *
+ * * Unless required by applicable law or agreed to in writing, software
+ * * distributed under the License is distributed on an "AS IS" BASIS,
+ * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * * See the License for the specific language governing permissions and
+ * * limitations under the License.
+ * * ============LICENSE_END=========================================================
+ *
+ *
+ */
+
+package org.onap.blueprintgenerator.service.common;
+
+import org.onap.blueprintgenerator.constants.Constants;
+import org.onap.blueprintgenerator.model.common.GetInput;
+import org.onap.blueprintgenerator.model.common.Interfaces;
+import org.onap.blueprintgenerator.model.common.Node;
+import org.onap.blueprintgenerator.model.common.Properties;
+import org.onap.blueprintgenerator.model.componentspec.OnapComponentSpec;
+import org.onap.blueprintgenerator.model.componentspec.common.Publishes;
+import org.onap.blueprintgenerator.model.componentspec.common.Subscribes;
+import org.onap.blueprintgenerator.service.base.BlueprintHelperService;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+
+import java.util.LinkedHashMap;
+import java.util.Map;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.TreeMap;
+import java.util.List;
+
+
+/**
+ * @author : Ravi Mantena
+ * @date 10/16/2020
+ * Application: ONAP - Blueprint Generator
+ * Common ONAP Service used by ONAP and DMAAP Blueprint to add ONAP/DMAAP/Feed/Topic Nodes
+ */
+
+
+@Service
+public class NodeService {
+
+ @Autowired
+ private InterfacesService interfacesService;
+
+ @Autowired
+ private PolicyNodeService policyNodeService;
+
+ @Autowired
+ private PgaasNodeService pgaasNodeService;
+
+ @Autowired
+ private PropertiesService propertiesService;
+
+ @Autowired
+ private BlueprintHelperService blueprintHelperService;
+
+ // method to create Onap Node to include interface
+ public Map<String,Object> createOnapNode(Map<String, LinkedHashMap<String, Object>> inputs, OnapComponentSpec onapComponentSpec, String override) {
+
+ Map<String,Object> response = new HashMap<>();
+ Node onapNode = new Node();
+
+ Map<String, Object> onapResponse = interfacesService.createInterface(inputs, onapComponentSpec);
+ inputs = (Map<String, LinkedHashMap<String, Object>>) onapResponse.get("inputs");
+
+ Map<String, Interfaces> interfaces = new TreeMap<>();
+ interfaces.put(Constants.CLOUDIFY_INTERFACES_LEFECYCLE, (Interfaces) onapResponse.get("interfaces"));
+ onapNode.setInterfaces(interfaces);
+
+ onapNode.setType(Constants.DCAE_NODES_CONTAINERIZED_SERVICE_COMPONENT);
+
+ List<Map<String, String>> relationships = new ArrayList();
+
+ if(onapComponentSpec.getPolicyInfo() != null){
+ List<Map<String, String>> policyRelationshipsList = policyNodeService.getPolicyRelationships(onapComponentSpec);
+ relationships.addAll(policyRelationshipsList);
+ }
+
+ if(onapComponentSpec.getAuxilary().getDatabases() != null){
+ List<Map<String, String>> pgaasRelationshipsList = pgaasNodeService.getPgaasNodeRelationships(onapComponentSpec);
+ relationships.addAll(pgaasRelationshipsList);
+ }
+
+ onapNode.setRelationships(relationships);
+
+ Map<String, Object> propertiesResponse = propertiesService.createOnapProperties(inputs, onapComponentSpec, override);
+ inputs = (Map<String, LinkedHashMap<String, Object>>) propertiesResponse.get("inputs");
+ onapNode.setProperties((org.onap.blueprintgenerator.model.common.Properties)propertiesResponse.get("properties"));
+
+ response.put("onapNode", onapNode);
+ response.put("inputs", inputs);
+ return response;
+ }
+
+ // method to create Dmaap Node to include interface
+ public Map<String,Object> createDmaapNode(OnapComponentSpec onapComponentSpec, Map<String, LinkedHashMap<String, Object>> inputs, String override) {
+
+ Map<String,Object> response = new HashMap<>();
+ Node dmaapNode = new Node();
+
+ dmaapNode.setType(Constants.DCAE_NODES_CONTAINERIZED_SERVICE_COMPONENT_USING_DMAAP);
+
+ Map<String, Object> dmaapResponse = interfacesService.createInterface(inputs, onapComponentSpec);
+ inputs = (Map<String, LinkedHashMap<String, Object>>) dmaapResponse.get("inputs");
+
+ Map<String, Interfaces> interfaces = new TreeMap<>();
+ interfaces.put(Constants.CLOUDIFY_INTERFACES_LEFECYCLE, (Interfaces) dmaapResponse.get("interfaces"));
+ dmaapNode.setInterfaces(interfaces);
+
+ List<Map<String, String>> relationships = new ArrayList();
+
+ if(onapComponentSpec.getStreams().getPublishes() != null) {
+ for(Publishes publishes: onapComponentSpec.getStreams().getPublishes()) {
+ Map<String, String> pubRelations = new LinkedHashMap();
+ if(blueprintHelperService.isMessageRouterType(publishes.getType())){
+ pubRelations.put("type", Constants.PUBLISH_EVENTS);
+ pubRelations.put("target", publishes.getConfig_key() + Constants._TOPIC);
+ } else if(blueprintHelperService.isDataRouterType(publishes.getType())){
+ pubRelations.put("type", Constants.PUBLISH_FILES);
+ pubRelations.put("target", publishes.getConfig_key() + Constants._FEED);
+ }
+ relationships.add(pubRelations);
+ }
+ }
+
+ if(onapComponentSpec.getStreams().getSubscribes() != null) {
+ for(Subscribes subscribes: onapComponentSpec.getStreams().getSubscribes()) {
+ Map<String, String> subRelations = new LinkedHashMap();
+ if(blueprintHelperService.isMessageRouterType(subscribes.getType())){
+ subRelations.put("type", Constants.SUBSCRIBE_TO_EVENTS);
+ subRelations.put("target", subscribes.getConfig_key() + Constants._TOPIC);
+ } else if(blueprintHelperService.isDataRouterType(subscribes.getType())){
+ subRelations.put("type", Constants.SUBSCRIBE_TO_FILES);
+ subRelations.put("target", subscribes.getConfig_key() + Constants._FEED);
+ }
+ relationships.add(subRelations);
+ }
+ }
+
+ if(onapComponentSpec.getPolicyInfo() != null){
+ List<Map<String, String>> policyRelationshipsList = policyNodeService.getPolicyRelationships(onapComponentSpec);
+ relationships.addAll(policyRelationshipsList);
+ }
+
+ if(onapComponentSpec.getAuxilary().getDatabases() != null){
+ List<Map<String, String>> pgaasRelationshipsList = pgaasNodeService.getPgaasNodeRelationships(onapComponentSpec);
+ relationships.addAll(pgaasRelationshipsList);
+ }
+
+ dmaapNode.setRelationships(relationships);
+
+ Map<String, Object> propertiesResponse = propertiesService.createDmaapProperties(inputs, onapComponentSpec, override);
+ inputs = (Map<String, LinkedHashMap<String, Object>>) propertiesResponse.get("inputs");
+ dmaapNode.setProperties((org.onap.blueprintgenerator.model.common.Properties)propertiesResponse.get("properties"));
+
+ response.put("dmaapNode", dmaapNode);
+ response.put("inputs", inputs);
+ return response;
+ }
+
+ // method to create Feed Node for Streams
+ public Map<String,Object> createFeedNode(Map<String, LinkedHashMap<String, Object>> inputs, String name){
+ Map<String,Object> response = new HashMap<>();
+ Node feedNode = new Node();
+
+ LinkedHashMap<String, Object> stringType = new LinkedHashMap();
+ stringType.put("type", "string");
+
+ feedNode.setType(Constants.FEED);
+
+ org.onap.blueprintgenerator.model.common.Properties props = new org.onap.blueprintgenerator.model.common.Properties();
+ GetInput topicInput = new GetInput();
+ topicInput.setBpInputName(name + "_name");
+ props.setFeed_name(topicInput);
+ props.setUseExisting(true);
+ inputs.put(name + "_name", stringType);
+ feedNode.setProperties(props);
+
+ response.put("feedNode", feedNode);
+ response.put("inputs", inputs);
+ return response;
+ }
+
+ // method to create Topic Node for Streams
+ public Map<String,Object> createTopicNode(Map<String, LinkedHashMap<String, Object>> inputs, String name){
+ Map<String,Object> response = new HashMap<>();
+ Node topicNode = new Node();
+
+ LinkedHashMap<String, Object> stringType = new LinkedHashMap();
+ stringType.put("type", "string");
+
+ topicNode.setType(Constants.TOPIC);
+
+ org.onap.blueprintgenerator.model.common.Properties props = new Properties();
+ GetInput topicInput = new GetInput();
+ topicInput.setBpInputName(name + "_name");
+ props.setTopic_name(topicInput);
+ inputs.put(name + "_name", stringType);
+ topicNode.setProperties(props);
+
+ response.put("topicNode", topicNode);
+ response.put("inputs", inputs);
+ return response;
+ }
+
+
+}
diff --git a/mod/bpgenerator/onap/src/main/java/org/onap/blueprintgenerator/service/common/PgaasNodeService.java b/mod/bpgenerator/onap/src/main/java/org/onap/blueprintgenerator/service/common/PgaasNodeService.java
new file mode 100644
index 0000000..ff45701
--- /dev/null
+++ b/mod/bpgenerator/onap/src/main/java/org/onap/blueprintgenerator/service/common/PgaasNodeService.java
@@ -0,0 +1,138 @@
+/*
+ *
+ * * ============LICENSE_START=======================================================
+ * * org.onap.dcae
+ * * ================================================================================
+ * * Copyright (c) 2020 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.
+ * * You may obtain a copy of the License at
+ * *
+ * * http://www.apache.org/licenses/LICENSE-2.0
+ * *
+ * * Unless required by applicable law or agreed to in writing, software
+ * * distributed under the License is distributed on an "AS IS" BASIS,
+ * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * * See the License for the specific language governing permissions and
+ * * limitations under the License.
+ * * ============LICENSE_END=========================================================
+ *
+ *
+ */
+
+package org.onap.blueprintgenerator.service.common;
+
+import org.onap.blueprintgenerator.constants.Constants;
+import org.onap.blueprintgenerator.exception.DatabasesNotFoundException;
+
+
+import org.onap.blueprintgenerator.model.common.Node;
+import org.onap.blueprintgenerator.model.common.PgaasNode;
+import org.onap.blueprintgenerator.model.common.GetInput;
+import org.onap.blueprintgenerator.model.common.PgaasNodeProperties;
+import org.onap.blueprintgenerator.model.common.GetAttribute;
+import org.onap.blueprintgenerator.model.componentspec.OnapComponentSpec;
+import org.onap.blueprintgenerator.service.base.BlueprintHelperService;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+
+import java.util.Arrays;
+import java.util.LinkedHashMap;
+import java.util.Map;
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * @author : Ravi Mantena
+ * @date 10/16/2020
+ * Application: ONAP - Blueprint Generator
+ * Common ONAP Service used by ONAP and DMAAP Blueprint to add Pgaas Node
+ */
+
+
+@Service
+public class PgaasNodeService {
+
+ @Autowired
+ private BlueprintHelperService blueprintHelperService;
+
+ // method to create Pgaas Nodes and Inputs for Databases
+ public void addPgaasNodesAndInputs(OnapComponentSpec onapComponentSpec, Map<String, Node> nodeTemplate, Map<String, LinkedHashMap<String, Object>> inputs) {
+ Map<String, String> databases = onapComponentSpec.getAuxilary().getDatabases();
+ for(Map.Entry<String, String> database : databases.entrySet()){
+ addPgaasNode(database, nodeTemplate);
+ addPgaasInputs(database, inputs);
+ }
+ }
+
+ private void addPgaasInputs(Map.Entry<String, String> database, Map<String, LinkedHashMap<String, Object>> inputs) {
+ inputs.put(database.getKey() + Constants.NAME_POSTFIX, blueprintHelperService.createStringInput( "db name", ""));
+ inputs.put(database.getKey() + Constants.WRITER_FQDN_POSTFIX, blueprintHelperService.createStringInput( "db writerfqdn", ""));
+ }
+
+ private void addPgaasNode(Map.Entry<String, String> database, Map<String, Node> nodeTemplate) {
+ PgaasNode pgaasNode = new PgaasNode();
+ String dbName = database.getKey();
+ pgaasNode.setType(Constants.PGAAS_NODE_TYPE);
+ pgaasNode.setPgaasNodeProperties(buildPgaasNodeProperties(dbName));
+ nodeTemplate.put(dbName + Constants.PGAAS_NODE_NAME_POSTFIX , pgaasNode);
+ }
+
+ private PgaasNodeProperties buildPgaasNodeProperties(String dbName) {
+ PgaasNodeProperties pgaasNodeProperties = new PgaasNodeProperties();
+
+ GetInput nameValue = new GetInput();
+ nameValue.setBpInputName(dbName + Constants.NAME_POSTFIX);
+ pgaasNodeProperties.setName(nameValue);
+
+ GetInput writerfqdnValue = new GetInput();
+ writerfqdnValue.setBpInputName(dbName + Constants.WRITER_FQDN_POSTFIX);
+ pgaasNodeProperties.setWriterfqdn(writerfqdnValue);
+
+ pgaasNodeProperties.setUseExisting(Constants.USE_EXISTING);
+
+ return pgaasNodeProperties;
+ }
+
+ // method to create Pgaas Node Relationships for Databases
+ public List<Map<String, String>> getPgaasNodeRelationships(OnapComponentSpec onapComponentSpec) {
+ List<Map<String, String>> relationships = new ArrayList<>();
+ for(Map.Entry<String, String> database : onapComponentSpec.getAuxilary().getDatabases().entrySet()){
+ Map<String, String> relationship = new LinkedHashMap<>();
+ relationship.put("type", Constants.DB_RELATIONSHIP_TYPE);
+ relationship.put("target", database.getKey() + Constants.PGAAS_NODE_NAME_POSTFIX);
+ relationships.add(relationship);
+ }
+ return relationships;
+ }
+
+ // method to create Env Variables for Databases
+ public Map<String, Object> getEnvVariables(Map<String, String> databases) {
+ Map<String, Object> envVariables = new LinkedHashMap<>();
+ for(Map.Entry<String, String> database : databases.entrySet()){
+ String name = database.getKey().toUpperCase();
+ envVariables.put("<<", "*envs");
+
+ GetInput nameValue = new GetInput();
+ nameValue.setBpInputName(name.toLowerCase() + Constants.NAME_POSTFIX);
+ envVariables.put(name + "_DB_NAME", nameValue);
+
+ GetAttribute adminHostValue = buildGetAttributeValue(name.toLowerCase(), "admin", "host");
+ envVariables.put( name.toUpperCase() + "_DB_ADMIN_HOST", adminHostValue);
+
+ GetAttribute adminUserValue = buildGetAttributeValue(name.toLowerCase(), "admin", "user");
+ envVariables.put( name.toUpperCase() + "_DB_ADMIN_USER", adminUserValue);
+
+ GetAttribute adminPasswordValue = buildGetAttributeValue(name.toLowerCase(), "admin", "password");
+ envVariables.put( name.toUpperCase() + "_DB_ADMIN_PASS", adminPasswordValue);
+ }
+ return envVariables;
+ }
+
+ private GetAttribute buildGetAttributeValue(String dbName, String owner, String type) {
+ GetAttribute attribute = new GetAttribute();
+ attribute.setAttribute(Arrays.asList(dbName + Constants.PGAAS_NODE_NAME_POSTFIX, owner, type));
+ return attribute;
+ }
+}
diff --git a/mod/bpgenerator/onap/src/main/java/org/onap/blueprintgenerator/service/common/PolicyNodeService.java b/mod/bpgenerator/onap/src/main/java/org/onap/blueprintgenerator/service/common/PolicyNodeService.java
new file mode 100644
index 0000000..7f6c63d
--- /dev/null
+++ b/mod/bpgenerator/onap/src/main/java/org/onap/blueprintgenerator/service/common/PolicyNodeService.java
@@ -0,0 +1,99 @@
+/*
+ *
+ * * ============LICENSE_START=======================================================
+ * * org.onap.dcae
+ * * ================================================================================
+ * * Copyright (c) 2020 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.
+ * * You may obtain a copy of the License at
+ * *
+ * * http://www.apache.org/licenses/LICENSE-2.0
+ * *
+ * * Unless required by applicable law or agreed to in writing, software
+ * * distributed under the License is distributed on an "AS IS" BASIS,
+ * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * * See the License for the specific language governing permissions and
+ * * limitations under the License.
+ * * ============LICENSE_END=========================================================
+ *
+ *
+ */
+
+package org.onap.blueprintgenerator.service.common;
+
+import org.onap.blueprintgenerator.constants.Constants;
+import org.onap.blueprintgenerator.model.common.GetInput;
+import org.onap.blueprintgenerator.model.common.Node;
+import org.onap.blueprintgenerator.model.common.PolicyNode;
+import org.onap.blueprintgenerator.model.common.PolicyNodeProperties;
+import org.onap.blueprintgenerator.model.componentspec.OnapComponentSpec;
+import org.onap.blueprintgenerator.model.componentspec.TypePolicy;
+import org.onap.blueprintgenerator.service.base.BlueprintHelperService;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+
+import java.util.ArrayList;
+import java.util.LinkedHashMap;
+import java.util.List;
+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 Policy Node
+ */
+
+
+@Service("onapPolicyNodeService")
+public class PolicyNodeService {
+
+ @Autowired
+ private BlueprintHelperService blueprintHelperService;
+
+ // Method to add Policy Nodes and Inputs
+ public void addPolicyNodesAndInputs(OnapComponentSpec onapComponentSpec, Map<String, Node> nodeTemplate, Map<String, LinkedHashMap<String, Object>> inputs) {
+ List<TypePolicy> policyList = onapComponentSpec.getPolicyInfo().getTypePolicyList();
+ for(TypePolicy policy: policyList){
+ addPolicyNodesToNodeTemplate(policy, nodeTemplate);
+ addPolicyInputs(policy, inputs);
+ }
+ }
+
+ private void addPolicyInputs(TypePolicy policy, Map<String, LinkedHashMap<String, Object>> inputs) {
+ String defaultValue = policy.getPolicy_id();
+ defaultValue = defaultValue != null ? defaultValue : "";
+ inputs.put(policy.getNode_label() + "_policy_id", blueprintHelperService.createStringInput("policy_id", defaultValue));
+ }
+
+ private void addPolicyNodesToNodeTemplate(TypePolicy policy, Map<String, Node> nodeTemplate) {
+ PolicyNode policyNode = new PolicyNode();
+ policyNode.setType(Constants.POLICY_NODE_TYPE);
+ policyNode.setPolicyNodeProperties(getPolicyNodeProperties(policy));
+ nodeTemplate.put(policy.getNode_label(), policyNode);
+ }
+
+ private PolicyNodeProperties getPolicyNodeProperties(TypePolicy policy) {
+ PolicyNodeProperties policyNodeProperties = new PolicyNodeProperties();
+ GetInput policyIdGetInput = new GetInput();
+ policyIdGetInput.setBpInputName(policy.getNode_label() + "_policy_id");
+ policyNodeProperties.setPolicyId(policyIdGetInput);
+ policyNodeProperties.setPolicyModelId(policy.getPolicy_model_id());
+ return policyNodeProperties;
+ }
+
+ // Method to add Policy Relationships
+ public List<Map<String, String>> getPolicyRelationships(OnapComponentSpec onapComponentSpec) {
+ List<Map<String, String>> relationships = new ArrayList<>();
+ List<TypePolicy> policyList = onapComponentSpec.getPolicyInfo().getTypePolicyList();
+ for(TypePolicy policy: policyList){
+ Map<String, String> relationship = new LinkedHashMap<>();
+ relationship.put("type", Constants.POLICY_RELATIONSHIP_TYPE);
+ relationship.put("target", policy.getNode_label());
+ relationships.add(relationship);
+ }
+ return relationships;
+ }
+}
diff --git a/mod/bpgenerator/onap/src/main/java/org/onap/blueprintgenerator/service/common/PropertiesService.java b/mod/bpgenerator/onap/src/main/java/org/onap/blueprintgenerator/service/common/PropertiesService.java
new file mode 100644
index 0000000..e858d88
--- /dev/null
+++ b/mod/bpgenerator/onap/src/main/java/org/onap/blueprintgenerator/service/common/PropertiesService.java
@@ -0,0 +1,259 @@
+/*
+ *
+ * * ============LICENSE_START=======================================================
+ * * org.onap.dcae
+ * * ================================================================================
+ * * Copyright (c) 2020 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.
+ * * You may obtain a copy of the License at
+ * *
+ * * http://www.apache.org/licenses/LICENSE-2.0
+ * *
+ * * Unless required by applicable law or agreed to in writing, software
+ * * distributed under the License is distributed on an "AS IS" BASIS,
+ * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * * See the License for the specific language governing permissions and
+ * * limitations under the License.
+ * * ============LICENSE_END=========================================================
+ *
+ *
+ */
+
+package org.onap.blueprintgenerator.service.common;
+
+import org.onap.blueprintgenerator.constants.Constants;
+import org.onap.blueprintgenerator.model.common.Appconfig;
+import org.onap.blueprintgenerator.model.common.GetInput;
+import org.onap.blueprintgenerator.model.common.ResourceConfig;
+import org.onap.blueprintgenerator.model.componentspec.OnapAuxilary;
+import org.onap.blueprintgenerator.model.componentspec.OnapComponentSpec;
+import org.onap.blueprintgenerator.model.componentspec.common.Publishes;
+import org.onap.blueprintgenerator.model.componentspec.common.Subscribes;
+import org.onap.blueprintgenerator.model.dmaap.Streams;
+import org.onap.blueprintgenerator.model.dmaap.TlsInfo;
+import org.onap.blueprintgenerator.service.base.BlueprintHelperService;
+import org.onap.blueprintgenerator.service.dmaap.StreamsService;
+import org.onap.blueprintgenerator.model.common.Properties;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+
+import java.util.LinkedHashMap;
+import java.util.Map;
+import java.util.HashMap;
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * @author : Ravi Mantena
+ * @date 10/16/2020
+ * Application: ONAP - Blueprint Generator
+ * Common ONAP Service used by ONAP and DMAAP Blueprint to create Properties Node
+ */
+
+
+
+@Service("onapPropertiesService")
+public class PropertiesService {
+
+ @Autowired
+ private AppConfigService appConfigService;
+
+ @Autowired
+ private ResourceConfigService resourceConfigService;
+
+ @Autowired
+ private StreamsService streamsService;
+
+ @Autowired
+ private ExternalTlsInfoFactoryService externalTlsInfoFactoryService;
+
+ @Autowired
+ private BlueprintHelperService blueprintHelperService;
+
+ // Method to create ONAP properties
+ public Map<String,Object> createOnapProperties(Map<String, LinkedHashMap<String, Object>> inputs, OnapComponentSpec onapComponentSpec, String override) {
+ Map<String,Object> response = new HashMap<>();
+ org.onap.blueprintgenerator.model.common.Properties properties = new org.onap.blueprintgenerator.model.common.Properties();
+
+ GetInput image = new GetInput();
+ image.setBpInputName("image");
+ properties.setImage(image);
+
+ LinkedHashMap<String, Object> img = new LinkedHashMap<>();
+ inputs.put("image", blueprintHelperService.createStringInput(onapComponentSpec.getArtifacts()[0].getUri()));
+
+
+ GetInput location = new GetInput();
+ location.setBpInputName("location_id");
+ properties.setLocation_id(location);
+
+ LinkedHashMap<String, Object> locMap = new LinkedHashMap();
+ inputs.put("location_id", blueprintHelperService.createStringInput(Constants.EMPTY_VALUE));
+
+ properties.setLog_info(onapComponentSpec.getAuxilary().getLog_info());
+
+ GetInput replica = new GetInput();
+ replica.setBpInputName("replicas");
+ properties.setReplicas(replica);
+
+ LinkedHashMap<String, Object> replicas = blueprintHelperService.createIntegerInput("number of instances", 1);
+ inputs.put("replicas", replicas);
+
+ OnapAuxilary onapAuxilary = onapComponentSpec.getAuxilary();
+
+ properties.setDocker_config(onapAuxilary);
+
+ Map<String, Object> appConfigResponse = appConfigService.createAppconfig(inputs, onapComponentSpec, override, false);
+ inputs = (Map<String, LinkedHashMap<String, Object>>) appConfigResponse.get("inputs");
+ properties.setApplication_config((Appconfig) appConfigResponse.get("appconfig"));
+
+ GetInput always_pull_image = new GetInput();
+ always_pull_image.setBpInputName("always_pull_image");
+
+ properties.setAlways_pull_image(always_pull_image);
+
+ LinkedHashMap<String, Object> inputAlwaysPullImage = blueprintHelperService.createBooleanInput("Set to true if the image should always be pulled",true);
+ inputs.put("always_pull_image", inputAlwaysPullImage);
+
+ String sType = onapComponentSpec.getSelf().getName();
+ sType = sType.replace('.', '-');
+ properties.setService_component_type(sType);
+
+ Map<String, Object> tls_info = onapComponentSpec.getAuxilary().getTls_info();
+ if(tls_info != null) {
+ addTlsInfo(onapComponentSpec, inputs, properties);
+ if (tls_info.get(Constants.USE_EXTERNAL_TLS_FIELD) != null) {
+ inputs.putAll(addExternalTlsInfo(onapComponentSpec,properties));
+ }
+ }
+
+ Map<String, Object> resourceConfigResponse = resourceConfigService.createResourceConfig(inputs, onapComponentSpec.getSelf().getName());
+ inputs = (Map<String, LinkedHashMap<String, Object>>) resourceConfigResponse.get("inputs");
+ properties.setResource_config((ResourceConfig) resourceConfigResponse.get("resourceConfig"));
+
+ response.put("properties", properties);
+ response.put("inputs", inputs);
+ return response;
+ }
+
+ // Method to create Dmaap properties
+ public Map<String,Object> createDmaapProperties(Map<String, LinkedHashMap<String, Object>> inputs, OnapComponentSpec onapComponentSpec, String override) {
+ Map<String,Object> response = new HashMap<>();
+ org.onap.blueprintgenerator.model.common.Properties properties = new org.onap.blueprintgenerator.model.common.Properties();
+
+ GetInput image = new GetInput();
+ image.setBpInputName("tag_version");
+ properties.setImage(image);
+
+ LinkedHashMap<String, Object> img = new LinkedHashMap<>();
+ inputs.put("tag_version", blueprintHelperService.createStringInput(onapComponentSpec.getArtifacts()[0].getUri()));
+
+ GetInput location = new GetInput();
+ location.setBpInputName("location_id");
+ properties.setLocation_id(location);
+
+ LinkedHashMap<String, Object> locMap = new LinkedHashMap();
+ inputs.put("location_id", blueprintHelperService.createStringInput(Constants.EMPTY_VALUE));
+
+ properties.setLog_info(onapComponentSpec.getAuxilary().getLog_info());
+
+ String sType = onapComponentSpec.getSelf().getName();
+ sType = sType.replace('.', '-');
+ properties.setService_component_type(sType);
+
+ Map<String, Object> tls_info = onapComponentSpec.getAuxilary().getTls_info();
+ if(tls_info != null) {
+ addTlsInfo(onapComponentSpec, inputs, properties);
+ if (tls_info.get(Constants.USE_EXTERNAL_TLS_FIELD) != null) {
+ inputs.putAll(addExternalTlsInfo(onapComponentSpec,properties));
+ }
+ }
+
+ GetInput replica = new GetInput();
+ replica.setBpInputName("replicas");
+ properties.setReplicas(replica);
+
+ LinkedHashMap<String, Object> rep = blueprintHelperService.createIntegerInput( "number of instances", 1);
+ inputs.put("replicas", rep);
+
+ OnapAuxilary onapAuxilary = onapComponentSpec.getAuxilary();
+
+ properties.setDocker_config(onapAuxilary);
+
+ Map<String, Object> appConfigResponse = appConfigService.createAppconfig(inputs, onapComponentSpec, override, true);
+ inputs = (Map<String, LinkedHashMap<String, Object>>) appConfigResponse.get("inputs");
+ properties.setApplication_config((Appconfig) appConfigResponse.get("appconfig"));
+
+
+ List<Streams> pubStreams = new ArrayList();
+ if(onapComponentSpec.getStreams() != null) {
+ if (onapComponentSpec.getStreams().getPublishes() != null) {
+ for (Publishes publishes : onapComponentSpec.getStreams().getPublishes()) {
+ if (blueprintHelperService.isMessageRouterType(publishes.getType())) {
+ String topic = publishes.getConfig_key() + Constants._TOPIC;
+ Map<String, Object> streamsMessageRouterResponse = streamsService.createStreams(inputs, topic, publishes.getType(), publishes.getConfig_key(), publishes.getRoute(), 'p');
+ inputs = (Map<String, LinkedHashMap<String, Object>>) streamsMessageRouterResponse.get("inputs");
+ pubStreams.add((Streams) streamsMessageRouterResponse.get("streams"));
+ } else if (blueprintHelperService.isDataRouterType(publishes.getType())) {
+ String feed = publishes.getConfig_key() + Constants._FEED;
+ Map<String, Object> streamsDataRouterResponse = streamsService.createStreams(inputs, feed, publishes.getType(), publishes.getConfig_key(), publishes.getRoute(), 'p');
+ inputs = (Map<String, LinkedHashMap<String, Object>>) streamsDataRouterResponse.get("inputs");
+ pubStreams.add((Streams) streamsDataRouterResponse.get("streams"));
+ }
+ }
+ }
+ }
+
+ ArrayList<Streams> subStreams = new ArrayList();
+ if(onapComponentSpec.getStreams() != null) {
+ if (onapComponentSpec.getStreams().getSubscribes() != null) {
+ for (Subscribes subscribes : onapComponentSpec.getStreams().getSubscribes()) {
+ if (blueprintHelperService.isMessageRouterType(subscribes.getType())) {
+ String topic = subscribes.getConfig_key() + Constants._TOPIC;
+ Map<String, Object> streamsMessageRouterResponse = streamsService.createStreams(inputs, topic, subscribes.getType(), subscribes.getConfig_key(), subscribes.getRoute(), 's');
+ inputs = (Map<String, LinkedHashMap<String, Object>>) streamsMessageRouterResponse.get("inputs");
+ subStreams.add((Streams) streamsMessageRouterResponse.get("streams"));
+ } else if (blueprintHelperService.isDataRouterType(subscribes.getType())) {
+ String feed = subscribes.getConfig_key() + Constants._FEED;
+ Map<String, Object> streamsDataRouterResponse = streamsService.createStreams(inputs, feed, subscribes.getType(), subscribes.getConfig_key(), subscribes.getRoute(), 's');
+ inputs = (Map<String, LinkedHashMap<String, Object>>) streamsDataRouterResponse.get("inputs");
+ subStreams.add((Streams) streamsDataRouterResponse.get("streams"));
+ }
+ }
+ }
+ }
+
+ if(!pubStreams.isEmpty())
+ properties.setStreams_publishes(pubStreams);
+
+ if(!subStreams.isEmpty())
+ properties.setStreams_subscribes(subStreams);
+
+ Map<String, Object> resourceConfigResponse = resourceConfigService.createResourceConfig(inputs, onapComponentSpec.getSelf().getName());
+ inputs = (Map<String, LinkedHashMap<String, Object>>) resourceConfigResponse.get("inputs");
+ properties.setResource_config((ResourceConfig) resourceConfigResponse.get("resourceConfig"));
+
+ response.put("properties", properties);
+ response.put("inputs", inputs);
+ return response;
+ }
+
+ private void addTlsInfo(OnapComponentSpec onapComponentSpec, Map<String, LinkedHashMap<String, Object>> inputs, Properties properties) {
+ TlsInfo tlsInfo = new TlsInfo();
+ tlsInfo.setCertDirectory((String) onapComponentSpec.getAuxilary().getTls_info().get("cert_directory"));
+ GetInput useTLSFlag = new GetInput();
+ useTLSFlag.setBpInputName("use_tls");
+ tlsInfo.setUseTls(useTLSFlag);
+ properties.setTls_info(tlsInfo);
+ LinkedHashMap<String, Object> useTlsFlagInput = blueprintHelperService.createBooleanInput("flag to indicate tls enable/disable",onapComponentSpec.getAuxilary().getTls_info().get("use_tls"));
+ inputs.put("use_tls", useTlsFlagInput);
+ }
+
+ private Map<String, LinkedHashMap<String, Object>> addExternalTlsInfo(OnapComponentSpec onapComponentSpec, Properties properties) {
+ properties.setExternal_cert(externalTlsInfoFactoryService.createFromComponentSpec(onapComponentSpec));
+ return externalTlsInfoFactoryService.createInputListFromComponentSpec(onapComponentSpec);
+ }
+
+}
diff --git a/mod/bpgenerator/onap/src/main/java/org/onap/blueprintgenerator/service/common/QuotationService.java b/mod/bpgenerator/onap/src/main/java/org/onap/blueprintgenerator/service/common/QuotationService.java
new file mode 100644
index 0000000..c79ec56
--- /dev/null
+++ b/mod/bpgenerator/onap/src/main/java/org/onap/blueprintgenerator/service/common/QuotationService.java
@@ -0,0 +1,59 @@
+/*
+ *
+ * * ============LICENSE_START=======================================================
+ * * org.onap.dcae
+ * * ================================================================================
+ * * Copyright (c) 2020 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.
+ * * You may obtain a copy of the License at
+ * *
+ * * http://www.apache.org/licenses/LICENSE-2.0
+ * *
+ * * Unless required by applicable law or agreed to in writing, software
+ * * distributed under the License is distributed on an "AS IS" BASIS,
+ * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * * See the License for the specific language governing permissions and
+ * * limitations under the License.
+ * * ============LICENSE_END=========================================================
+ *
+ *
+ */
+
+package org.onap.blueprintgenerator.service.common;
+
+import org.onap.blueprintgenerator.model.common.OnapBlueprint;
+import org.springframework.stereotype.Service;
+
+import java.util.LinkedHashMap;
+
+/**
+ * @author : Ravi Mantena
+ * @date 10/16/2020
+ * Application: ONAP - Blueprint Generator
+ * Common ONAP Service used by ONAP and DMAAP Blueprint to set Quotations of generated Blueprint
+ */
+
+
+@Service
+public class QuotationService {
+
+ // Method to add Quotes for String Types
+ public OnapBlueprint setQuotations(OnapBlueprint bp) {
+ for(String s: bp.getInputs().keySet()) {
+ LinkedHashMap<String, Object> temp = bp.getInputs().get(s);
+ if(temp.get("type") == "string") {
+ String def = (String) temp.get("default");
+ if(def != null){
+ def = def.replaceAll("\"$", "").replaceAll("^\"", "");
+ }
+ def = '"' + def + '"';
+ temp.replace("default", def);
+ bp.getInputs().replace(s, temp);
+ }
+ }
+ return bp;
+ }
+
+}
diff --git a/mod/bpgenerator/onap/src/main/java/org/onap/blueprintgenerator/service/common/ResourceConfigService.java b/mod/bpgenerator/onap/src/main/java/org/onap/blueprintgenerator/service/common/ResourceConfigService.java
new file mode 100644
index 0000000..7b03372
--- /dev/null
+++ b/mod/bpgenerator/onap/src/main/java/org/onap/blueprintgenerator/service/common/ResourceConfigService.java
@@ -0,0 +1,98 @@
+/*
+ *
+ * * ============LICENSE_START=======================================================
+ * * org.onap.dcae
+ * * ================================================================================
+ * * Copyright (c) 2020 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.
+ * * You may obtain a copy of the License at
+ * *
+ * * http://www.apache.org/licenses/LICENSE-2.0
+ * *
+ * * Unless required by applicable law or agreed to in writing, software
+ * * distributed under the License is distributed on an "AS IS" BASIS,
+ * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * * See the License for the specific language governing permissions and
+ * * limitations under the License.
+ * * ============LICENSE_END=========================================================
+ *
+ *
+ */
+
+package org.onap.blueprintgenerator.service.common;
+
+import org.onap.blueprintgenerator.constants.Constants;
+import org.onap.blueprintgenerator.model.common.GetInput;
+import org.onap.blueprintgenerator.model.common.ResourceConfig;
+import org.onap.blueprintgenerator.service.base.BlueprintHelperService;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+
+import java.util.HashMap;
+import java.util.LinkedHashMap;
+import java.util.Map;
+import java.util.TreeMap;
+
+/**
+ * @author : Ravi Mantena
+ * @date 10/16/2020
+ * Application: ONAP - Blueprint Generator
+ * Common ONAP Service used by ONAP and DMAAP Blueprint to add ResourceConfig
+ */
+
+
+@Service("onapResourceConfigService")
+public class ResourceConfigService {
+
+ @Autowired
+ private BlueprintHelperService blueprintHelperService;
+
+ //Method to create Resouce Config for properties
+ public Map<String,Object> createResourceConfig(Map<String, LinkedHashMap<String, Object>> inputs, String name){
+ Map<String,Object> response = new HashMap<>();
+ ResourceConfig resourceConfig = new ResourceConfig();
+
+ LinkedHashMap<String, Object> memoryLimit = blueprintHelperService.createStringInput(Constants.MEMORY_LIMIT_128Mi);
+
+ LinkedHashMap<String, Object> cpuLimit = blueprintHelperService.createStringInput( Constants.CPU_LIMIT_250m);
+
+ name = blueprintHelperService.getNamePrefix(name);
+
+ Map<String, GetInput> lim = new TreeMap<>();
+
+ GetInput cpu = new GetInput();
+ cpu.setBpInputName(name + Constants.CPU_LIMIT);
+ lim.put("cpu", cpu);
+
+ GetInput memL = new GetInput();
+ memL.setBpInputName(name + Constants.MEMORY_LIMIT);
+ lim.put("memory", memL);
+
+ inputs.put(name + Constants.CPU_LIMIT, cpuLimit);
+ inputs.put(name + Constants.MEMORY_LIMIT, memoryLimit);
+
+ resourceConfig.setLimits(lim);
+
+ Map<String, GetInput> req = new TreeMap<>();
+
+ GetInput cpuR = new GetInput();
+ cpuR.setBpInputName(name + Constants.CPU_REQUEST);
+ req.put("cpu", cpuR);
+
+ GetInput memR = new GetInput();
+ memR.setBpInputName(name + Constants.MEMORY_REQUEST);
+ req.put("memory", memR);
+
+ inputs.put(name + Constants.CPU_REQUEST, cpuLimit);
+ inputs.put(name + Constants.MEMORY_REQUEST, memoryLimit);
+
+ resourceConfig.setRequests(req);
+
+ response.put("resourceConfig", resourceConfig);
+ response.put("inputs", inputs);
+ return response;
+ }
+
+}
diff --git a/mod/bpgenerator/onap/src/main/java/org/onap/blueprintgenerator/service/common/StartInputsService.java b/mod/bpgenerator/onap/src/main/java/org/onap/blueprintgenerator/service/common/StartInputsService.java
new file mode 100644
index 0000000..20c3656
--- /dev/null
+++ b/mod/bpgenerator/onap/src/main/java/org/onap/blueprintgenerator/service/common/StartInputsService.java
@@ -0,0 +1,97 @@
+/*
+ *
+ * * ============LICENSE_START=======================================================
+ * * org.onap.dcae
+ * * ================================================================================
+ * * Copyright (c) 2020 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.
+ * * You may obtain a copy of the License at
+ * *
+ * * http://www.apache.org/licenses/LICENSE-2.0
+ * *
+ * * Unless required by applicable law or agreed to in writing, software
+ * * distributed under the License is distributed on an "AS IS" BASIS,
+ * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * * See the License for the specific language governing permissions and
+ * * limitations under the License.
+ * * ============LICENSE_END=========================================================
+ *
+ *
+ */
+
+package org.onap.blueprintgenerator.service.common;
+
+import org.onap.blueprintgenerator.model.common.GetInput;
+import org.onap.blueprintgenerator.model.common.StartInputs;
+import org.onap.blueprintgenerator.model.componentspec.OnapAuxilary;
+import org.onap.blueprintgenerator.model.componentspec.OnapComponentSpec;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+
+import java.util.LinkedHashMap;
+import java.util.Map;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+
+/**
+ * @author : Ravi Mantena
+ * @date 10/16/2020
+ * Application: ONAP - Blueprint Generator
+ * Common ONAP Service used by ONAP and DMAAP Blueprint to add Start Inputs Node under Start
+ */
+
+
+@Service
+public class StartInputsService {
+
+ @Autowired
+ private PgaasNodeService pgaasNodeService;
+
+ //Method to create Start Inputs for Start in Interfaces
+ public Map<String, Object> createStartInputs(Map<String, LinkedHashMap<String, Object>> inputs, OnapComponentSpec onapComponentSpec){
+
+ Map<String,Object> response = new HashMap<>();
+ StartInputs startInputs = new StartInputs();
+
+ int count = 0;
+ List<String> portList = new ArrayList();
+ OnapAuxilary aux = onapComponentSpec.getAuxilary();
+
+ if (aux.getPorts() != null) {
+ for(Object p : aux.getPorts()) {
+ String[] ports = p.toString().split(":");
+ portList.add(String.format("concat: [\"%s:\", {get_input: external_port_%d}]" , ports[0], count));
+
+ LinkedHashMap<String, Object> portType = new LinkedHashMap();
+ portType.put("type", "string");
+ portType.put("default", ports[1]);
+ inputs.put("external_port_" + count, portType);
+ count++;
+ }
+ }
+
+ startInputs.setPorts(portList);
+
+ LinkedHashMap<String, Object> envMap = new LinkedHashMap();
+ if(onapComponentSpec.getAuxilary().getDatabases() != null){
+ Map<String, Object> envVars = pgaasNodeService.getEnvVariables(onapComponentSpec.getAuxilary().getDatabases());
+ startInputs.setEnvs(envVars);
+ envMap.put("default", "&envs {}");
+ }
+ else {
+ GetInput env = new GetInput();
+ env.setBpInputName("envs");
+ startInputs.setEnvs(env);
+ envMap.put("default", "{}");
+ }
+ inputs.put("envs", envMap);
+
+ response.put("startInputs", startInputs);
+ response.put("inputs", inputs);
+ return response;
+ }
+
+}
diff --git a/mod/bpgenerator/onap/src/main/java/org/onap/blueprintgenerator/service/common/StartService.java b/mod/bpgenerator/onap/src/main/java/org/onap/blueprintgenerator/service/common/StartService.java
new file mode 100644
index 0000000..3fbfdb1
--- /dev/null
+++ b/mod/bpgenerator/onap/src/main/java/org/onap/blueprintgenerator/service/common/StartService.java
@@ -0,0 +1,65 @@
+/*
+ *
+ * * ============LICENSE_START=======================================================
+ * * org.onap.dcae
+ * * ================================================================================
+ * * Copyright (c) 2020 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.
+ * * You may obtain a copy of the License at
+ * *
+ * * http://www.apache.org/licenses/LICENSE-2.0
+ * *
+ * * Unless required by applicable law or agreed to in writing, software
+ * * distributed under the License is distributed on an "AS IS" BASIS,
+ * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * * See the License for the specific language governing permissions and
+ * * limitations under the License.
+ * * ============LICENSE_END=========================================================
+ *
+ *
+ */
+
+package org.onap.blueprintgenerator.service.common;
+
+
+import org.onap.blueprintgenerator.model.common.Start;
+import org.onap.blueprintgenerator.model.common.StartInputs;
+import org.onap.blueprintgenerator.model.componentspec.OnapComponentSpec;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+
+import java.util.HashMap;
+import java.util.LinkedHashMap;
+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 Start Node
+ */
+
+
+@Service
+public class StartService {
+
+ @Autowired
+ private StartInputsService startInputsService;
+
+ // Method to create Start for Interfaces
+ public Map<String,Object> createStart(Map<String, LinkedHashMap<String, Object>> inputs, OnapComponentSpec onapComponentSpec) {
+ Map<String,Object> response = new HashMap<>();
+ Start start = new Start();
+
+ Map<String, Object> startInputsResponse = startInputsService.createStartInputs(inputs, onapComponentSpec);
+ inputs = (Map<String, LinkedHashMap<String, Object>>) startInputsResponse.get("inputs");
+ start.setInputs((StartInputs) startInputsResponse.get("startInputs"));
+
+ response.put("start", start);
+ response.put("inputs", inputs);
+ return response;
+ }
+
+}