summaryrefslogtreecommitdiffstats
path: root/mod/bpgenerator/onap/src/main/java/org/onap/blueprintgenerator/service
diff options
context:
space:
mode:
Diffstat (limited to 'mod/bpgenerator/onap/src/main/java/org/onap/blueprintgenerator/service')
-rw-r--r--mod/bpgenerator/onap/src/main/java/org/onap/blueprintgenerator/service/InfoService.java51
-rw-r--r--mod/bpgenerator/onap/src/main/java/org/onap/blueprintgenerator/service/OnapBlueprintService.java40
-rw-r--r--mod/bpgenerator/onap/src/main/java/org/onap/blueprintgenerator/service/common/AppConfigService.java86
-rw-r--r--mod/bpgenerator/onap/src/main/java/org/onap/blueprintgenerator/service/common/CommonUtils.java150
-rw-r--r--mod/bpgenerator/onap/src/main/java/org/onap/blueprintgenerator/service/common/ComponentSpecService.java10
-rw-r--r--mod/bpgenerator/onap/src/main/java/org/onap/blueprintgenerator/service/common/DmaapService.java73
-rw-r--r--mod/bpgenerator/onap/src/main/java/org/onap/blueprintgenerator/service/common/ExternalCertificateDataFactoryService.java14
-rw-r--r--mod/bpgenerator/onap/src/main/java/org/onap/blueprintgenerator/service/common/ExternalCertificateParametersFactoryService.java44
-rw-r--r--mod/bpgenerator/onap/src/main/java/org/onap/blueprintgenerator/service/common/ExternalTlsInfoFactoryService.java48
-rw-r--r--mod/bpgenerator/onap/src/main/java/org/onap/blueprintgenerator/service/common/ImportsService.java24
-rw-r--r--mod/bpgenerator/onap/src/main/java/org/onap/blueprintgenerator/service/common/InterfacesService.java22
-rw-r--r--mod/bpgenerator/onap/src/main/java/org/onap/blueprintgenerator/service/common/NodeService.java139
-rw-r--r--mod/bpgenerator/onap/src/main/java/org/onap/blueprintgenerator/service/common/PgaasNodeService.java82
-rw-r--r--mod/bpgenerator/onap/src/main/java/org/onap/blueprintgenerator/service/common/PolicyNodeService.java38
-rw-r--r--mod/bpgenerator/onap/src/main/java/org/onap/blueprintgenerator/service/common/PropertiesService.java180
-rw-r--r--mod/bpgenerator/onap/src/main/java/org/onap/blueprintgenerator/service/common/QuotationService.java21
-rw-r--r--mod/bpgenerator/onap/src/main/java/org/onap/blueprintgenerator/service/common/ResourceConfigService.java27
-rw-r--r--mod/bpgenerator/onap/src/main/java/org/onap/blueprintgenerator/service/common/StartInputsService.java37
-rw-r--r--mod/bpgenerator/onap/src/main/java/org/onap/blueprintgenerator/service/common/StartService.java24
-rw-r--r--mod/bpgenerator/onap/src/main/java/org/onap/blueprintgenerator/service/dmaap/DmaapBlueprintService.java197
-rw-r--r--mod/bpgenerator/onap/src/main/java/org/onap/blueprintgenerator/service/dmaap/StreamsService.java34
21 files changed, 852 insertions, 489 deletions
diff --git a/mod/bpgenerator/onap/src/main/java/org/onap/blueprintgenerator/service/InfoService.java b/mod/bpgenerator/onap/src/main/java/org/onap/blueprintgenerator/service/InfoService.java
index fed3707..66f71da 100644
--- a/mod/bpgenerator/onap/src/main/java/org/onap/blueprintgenerator/service/InfoService.java
+++ b/mod/bpgenerator/onap/src/main/java/org/onap/blueprintgenerator/service/InfoService.java
@@ -35,32 +35,37 @@ import java.util.Map;
/**
* @author : Ravi Mantena
- * @date 10/16/2020
- * Application: ONAP - Blueprint Generator
- * Service to create Message Router and Data Router Information
+ * @date 10/16/2020 Application: ONAP - Blueprint Generator Service to create Message Router and
+ * Data Router Information
*/
-
@Service
public class InfoService {
@Autowired
private BlueprintHelperService blueprintHelperService;
- // Method to create info for Message Router
- public Map<String,Object> createMessageRouterInfo(Map<String, LinkedHashMap<String, Object>> inputs, String config, char type) {
-
- Map<String,Object> response = new HashMap<>();
+ /**
+ * Creates info for Message Router
+ *
+ * @param inputs Inputs
+ * @param config Config
+ * @param type BP Type
+ * @return
+ */
+ public Map<String, Object> createMessageRouterInfo(
+ Map<String, LinkedHashMap<String, Object>> inputs, String config, char type) {
+
+ Map<String, Object> response = new HashMap<>();
Info info = new Info();
LinkedHashMap<String, Object> stringType = new LinkedHashMap<>();
stringType.put("type", "string");
config = config.replaceAll("-", "_");
- if(type == 'p') {
+ if (type == 'p') {
config = config + "_publish_url";
- }
- else if(type == 's') {
- config = config+ "_subscribe_url";
+ } else if (type == 's') {
+ config = config + "_subscribe_url";
}
GetInput topic = new GetInput();
@@ -74,10 +79,17 @@ public class InfoService {
return response;
}
- // Method to create info for Data Router
- public Map<String,Object> createDataRouterInfo(Map<String, LinkedHashMap<String, Object>> inputs, String config) {
-
- Map<String,Object> response = new HashMap<>();
+ /**
+ * Creates info for Data Router
+ *
+ * @param inputs Inputs
+ * @param config Config
+ * @return
+ */
+ public Map<String, Object> createDataRouterInfo(
+ Map<String, LinkedHashMap<String, Object>> inputs, String config) {
+
+ Map<String, Object> response = new HashMap<>();
Info info = new Info();
LinkedHashMap<String, Object> stringType = new LinkedHashMap<>();
@@ -98,12 +110,14 @@ public class InfoService {
info.setLocation(location);
inputs.put(userlocationInputName, stringType);
- String userdeliveryUrlInputName = blueprintHelperService.joinUnderscore(config, "delivery_url");
+ String userdeliveryUrlInputName = blueprintHelperService
+ .joinUnderscore(config, "delivery_url");
GetInput deliveryUrl = new GetInput(userdeliveryUrlInputName);
info.setDelivery_url(deliveryUrl);
inputs.put(userdeliveryUrlInputName, stringType);
- String usersubscriberIDInputName = blueprintHelperService.joinUnderscore(config, "subscriber_id");
+ String usersubscriberIDInputName =
+ blueprintHelperService.joinUnderscore(config, "subscriber_id");
GetInput subscriberID = new GetInput(usersubscriberIDInputName);
info.setSubscriber_id(subscriberID);
inputs.put(usersubscriberIDInputName, stringType);
@@ -112,5 +126,4 @@ public class InfoService {
response.put("inputs", inputs);
return response;
}
-
}
diff --git a/mod/bpgenerator/onap/src/main/java/org/onap/blueprintgenerator/service/OnapBlueprintService.java b/mod/bpgenerator/onap/src/main/java/org/onap/blueprintgenerator/service/OnapBlueprintService.java
index f25c18c..748facf 100644
--- a/mod/bpgenerator/onap/src/main/java/org/onap/blueprintgenerator/service/OnapBlueprintService.java
+++ b/mod/bpgenerator/onap/src/main/java/org/onap/blueprintgenerator/service/OnapBlueprintService.java
@@ -23,7 +23,6 @@
package org.onap.blueprintgenerator.service;
-
import org.onap.blueprintgenerator.constants.Constants;
import org.onap.blueprintgenerator.exception.BlueprintException;
import org.onap.blueprintgenerator.model.common.Input;
@@ -46,11 +45,8 @@ import java.util.TreeMap;
/**
* @author : Ravi Mantena
- * @date 10/16/2020
- * Application: ONAP - Blueprint Generator
- * Service to create ONAP Blueprint
+ * @date 10/16/2020 Application: ONAP - Blueprint Generator Service to create ONAP Blueprint
*/
-
@Service
public class OnapBlueprintService extends BlueprintService {
@@ -69,43 +65,51 @@ public class OnapBlueprintService extends BlueprintService {
@Autowired
protected ImportsService importsService;
- // Method to generate Onap Blueprint
+ /**
+ * Creates Onap Blueprint
+ *
+ * @param onapComponentSpec OnapComponentSpec
+ * @param input Inputs
+ * @return
+ */
public OnapBlueprint createBlueprint(OnapComponentSpec onapComponentSpec, Input input) {
try {
OnapBlueprint blueprint = new OnapBlueprint();
blueprint.setTosca_definitions_version(Constants.TOSCA_DEF_VERSION);
- //if (!"".equals(input.getImportPath()))
- if (!StringUtils.isEmpty(input.getImportPath()))
+ // if (!"".equals(input.getImportPath()))
+ if (!StringUtils.isEmpty(input.getImportPath())) {
blueprint.setImports(importsService.createImportsFromFile(input.getImportPath()));
- else
+ } else {
blueprint.setImports(importsService.createImports(input.getBpType()));
+ }
Map<String, Node> nodeTemplate = new TreeMap<>();
String nodeName = onapComponentSpec.getSelf().getName();
Map<String, LinkedHashMap<String, Object>> inputs = new TreeMap<>();
- Map<String, Object> onapNodeResponse = nodeService.createOnapNode(inputs, onapComponentSpec, input.getServiceNameOverride());
+ Map<String, Object> onapNodeResponse =
+ nodeService
+ .createOnapNode(inputs, onapComponentSpec, input.getServiceNameOverride());
inputs = (Map<String, LinkedHashMap<String, Object>>) onapNodeResponse.get("inputs");
nodeTemplate.put(nodeName, (Node) onapNodeResponse.get("onapNode"));
blueprint.setNode_templates(nodeTemplate);
- if (onapComponentSpec.getPolicyInfo() != null)
+ if (onapComponentSpec.getPolicyInfo() != null) {
policyNodeService.addPolicyNodesAndInputs(onapComponentSpec, nodeTemplate, inputs);
+ }
- if (onapComponentSpec.getAuxilary() != null && onapComponentSpec.getAuxilary().getDatabases() != null)
+ if (onapComponentSpec.getAuxilary() != null
+ && onapComponentSpec.getAuxilary().getDatabases() != null) {
pgaasNodeService.addPgaasNodesAndInputs(onapComponentSpec, nodeTemplate, inputs);
+ }
blueprint.setInputs(inputs);
return quotationService.setQuotations(blueprint);
} catch (Exception ex) {
- throw new BlueprintException("Unable to create ONAP Blueprint Object from given input parameters", ex);
+ throw new BlueprintException(
+ "Unable to create ONAP Blueprint Object from given input parameters", ex);
}
}
-
-
}
-
-
-
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
index c6d744c..7c87af7 100644
--- 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
@@ -43,12 +43,9 @@ 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
+ * @date 10/16/2020 Application: ONAP - Blueprint Generator Common ONAP Service used to create App
+ * Config
*/
-
-
@Service("onapAppConfigService")
public class AppConfigService {
@@ -58,31 +55,52 @@ public class AppConfigService {
@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<>();
+ /**
+ * Creates Inputs section under App Config with Publishes, Subscribes, Parameters sections by
+ * checking Datarouter/MessageRouter/override/Dmaap values
+ *
+ * @param inputs Inputs
+ * @param onapComponentSpec Onap Component Specification
+ * @param override Parameter to Service Component Override
+ * @param isDmaap Dmaap Argument
+ * @return
+ */
+ 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() != 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");
+ 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");
+ 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);
@@ -93,22 +111,29 @@ public class AppConfigService {
Map<String, Dmaap> streamSubscribes = new TreeMap<>();
- if(onapComponentSpec.getStreams() != null) {
+ 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");
+ 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");
+ 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);
@@ -121,14 +146,15 @@ public class AppConfigService {
appconfig.setStreams_subscribes(streamSubscribes);
Map<String, Object> parameters = new TreeMap<>();
- for(Parameters p: onapComponentSpec.getParameters()) {
+ for (Parameters p : onapComponentSpec.getParameters()) {
String pName = p.getName();
- if(p.isSourced_at_deployment()) {
+ 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());
+ if (!"".equals(p.getValue())) {
+ LinkedHashMap<String, Object> pInputs =
+ blueprintHelperService.createStringInput(p.getValue());
inputs.put(pName, pInputs);
} else {
LinkedHashMap<String, Object> pInputs = new LinkedHashMap<>();
@@ -136,23 +162,23 @@ public class AppConfigService {
inputs.put(pName, pInputs);
}
} else {
- if("string".equals(p.getType())) {
- String val =(String) p.getValue();
+ if ("string".equals(p.getType())) {
+ String val = (String) p.getValue();
val = '"' + val + '"';
parameters.put(pName, val);
- }
- else {
+ } 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());
+ // parameters.put(pName, pName.equals("collector.schema.file") ?
+ // ((String)p.getValue()).replace("\"", "\\\"") : p.getValue());
}
}
}
- if(override != null) {
+ 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);
+ LinkedHashMap<String, Object> over = blueprintHelperService.createStringInput(override);
inputs.put(Constants.SERVICE_COMPONENT_NAME_OVERRIDE, over);
}
appconfig.setParams(parameters);
@@ -160,7 +186,5 @@ public class AppConfigService {
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
index 97ed47f..2bfa43e 100644
--- 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
@@ -23,8 +23,6 @@
package org.onap.blueprintgenerator.service.common;
-
-
import org.apache.commons.cli.CommandLineParser;
import org.apache.commons.cli.HelpFormatter;
import org.apache.commons.cli.ParseException;
@@ -40,106 +38,163 @@ 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
+ * @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 {
+ /**
+ * Prints input arguments options to run the Blueprint Application
+ */
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");
+ 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");
}
+ /**
+ * Parses Input Arguments and validates is reuired arguments are provided or not
+ *
+ * @param args Input Arguments
+ * @return
+ */
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"))
+ 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"))
+ } else if (args[i].contains("--blueprint-path")) {
modArgs[i] = "-_blueprint_path";
- else if(args[i].contains("--blueprint-name"))
+ } else if (args[i].contains("--blueprint-name")) {
modArgs[i] = "-_blueprint_name";
- else if(args[i].contains("--imports"))
+ } else if (args[i].contains("--imports")) {
modArgs[i] = "-_imports";
- else if(args[i].contains("--service-name-override"))
+ } else if (args[i].contains("--service-name-override")) {
modArgs[i] = "-_service_name_override";
- else if(args[i].contains("--dmaap-plugin"))
+ } else if (args[i].contains("--dmaap-plugin")) {
modArgs[i] = "-_dmaap_plugin";
- else
+ } else {
modArgs[i] = args[i];
+ }
}
- String commands = " ";
- for (String s : modArgs) {
- commands = commands + " " + s;
+ StringBuilder commandsBuf = new StringBuilder("");
+ String sep = "";
+ for (String s : modArgs) {
+ commandsBuf.append(sep).append(s);
+ sep = " ";
}
+ String commands = commandsBuf.toString();
- //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)");
+ // 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(
+ "_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");
+ 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"));
+ 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);
+ 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");
+ 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");
+ 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");
+ 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 (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);
@@ -148,5 +203,4 @@ public class CommonUtils {
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
index 4991bda..7145ac8 100644
--- 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
@@ -23,6 +23,7 @@
package org.onap.blueprintgenerator.service.common;
+import java.io.IOException;
import org.onap.blueprintgenerator.exception.ComponentSpecException;
import org.onap.blueprintgenerator.model.componentspec.OnapComponentSpec;
import com.fasterxml.jackson.databind.ObjectMapper;
@@ -51,7 +52,7 @@ public class ComponentSpecService {
/**
* Creates ComponentSpec from given file path and validates if the input is json file or not
*
- * @param componentSpecPath
+ * @param componentSpecPath Path of Component Spec File Location
* @return
*/
public OnapComponentSpec createComponentSpecFromFile(String componentSpecPath) {
@@ -63,7 +64,9 @@ public class ComponentSpecService {
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);
+ throw new ComponentSpecException(
+ "Unable to create ONAP Component Spec from the input file: " + componentSpecPath,
+ ex);
}
return componentSpec;
}
@@ -71,7 +74,8 @@ public class ComponentSpecService {
/**
* Creates the component spec from string.
* This method is used by RuntimeAPI
- * @param specString the spec string
+ * @param specString the spec string of Component Spec
+ * @return
*/
public OnapComponentSpec createComponentSpecFromString(String specString) {
OnapComponentSpec 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
index d4b2c42..e21b852 100644
--- 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
@@ -35,63 +35,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, 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);
+ 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{
+ } 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, LinkedHashMap<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");
dmaap.setDmaap_info(infoResponse.get("info"));
- }
- else {
+ } else {
String infoType = "<<" + counter + ">>";
dmaap.setDmaap_info(infoType);
}
@@ -99,5 +123,4 @@ public class DmaapService {
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
index ab48ada..f81da68 100644
--- 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
@@ -30,21 +30,19 @@ 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
+ * @date 10/16/2020 Application: ONAP - Blueprint Generator Common ONAP Service to add External
+ * Certificate Data Factory
*/
-
-
@Service
public abstract class ExternalCertificateDataFactoryService {
- // Method to concatenate Constant with field
+ // 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; }
-
+ 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
index 300aa5d..226a319 100644
--- 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
@@ -35,40 +35,52 @@ 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
+ * @date 10/16/2020 Application: ONAP - Blueprint Generator Common ONAP Service used by ONAP and
+ * DMAAP Blueprint to add Common ONAP Service to add External Certificate Parameters Factory
*/
-
-
@Service
-public class ExternalCertificateParametersFactoryService extends ExternalCertificateDataFactoryService {
+public class ExternalCertificateParametersFactoryService
+ extends ExternalCertificateDataFactoryService {
@Autowired
private BlueprintHelperService blueprintHelperService;
- // method to create external certificate parameters
+ /**
+ * Creates external certificate parameters
+ *
+ * @return
+ */
public ExternalCertificateParameters create() {
- ExternalCertificateParameters externalCertificateParameters = new ExternalCertificateParameters();
- externalCertificateParameters.setCommonName(createPrefixedGetInput(Constants.COMMON_NAME_FIELD));
+ 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
+ /**
+ * Creates input list for external certificate parameters factory
+ *
+ * @return
+ */
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);
+ 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);
+ 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
index 10364ab..0694821 100644
--- 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
@@ -36,12 +36,9 @@ 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
+ * @date 10/16/2020 Application: ONAP - Blueprint Generator Common ONAP Service to add External TLS
+ * Info
*/
-
-
@Service
public class ExternalTlsInfoFactoryService extends ExternalCertificateDataFactoryService {
@@ -51,37 +48,58 @@ public class ExternalTlsInfoFactoryService extends ExternalCertificateDataFactor
@Autowired
private BlueprintHelperService blueprintHelperService;
- //Method to create External TLS Info from Component Spec
+ /**
+ * Creates External TLS Info from Component Spec
+ *
+ * @param cs ComponentSpec
+ * @return
+ */
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.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());
+ 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) {
+ /**
+ * Creates Input List for External TLS Info from Component Spec
+ *
+ * @param cs ComponentSpec
+ * @return
+ */
+ 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));
+ 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);
+ 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);
+ 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
index cb9c03c..6fa43da 100644
--- 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
@@ -37,12 +37,9 @@ 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
+ * @date 10/16/2020 Application: DCAE/ONAP - Blueprint Generator Common Module: Used by ONAP
+ * Blueprint Application Service: For Imports
*/
-
@Service
public class ImportsService {
@@ -64,11 +61,16 @@ public class ImportsService {
@Value("${import.Clamp}")
private String importClamp;
-
@Qualifier("yamlObjectMapper")
@Autowired
protected ObjectMapper yamlObjectMapper;
+ /**
+ * Creates Imports for Blueprint based on Blueprint Type
+ *
+ * @param bpType Blueprint Type
+ * @return
+ */
public List<String> createImports(String bpType) {
List<String> imports = new ArrayList<>();
if (bpType.equals("o")) {
@@ -77,8 +79,7 @@ public class ImportsService {
imports.add(importsOnapK8sDcaepolicyplugin);
imports.add(importPostgres);
imports.add(importClamp);
- }
- else {
+ } else {
imports.add(importsOnapTypes);
imports.add(importsOnapK8sPlugintypes);
imports.add(importsDmaapDmaapplugin);
@@ -88,11 +89,16 @@ public class ImportsService {
return imports;
}
+ /**
+ * Creates Imports for Blueprint from the file path provided
+ *
+ * @param path Path of Import File
+ * @return
+ */
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
index bfd14a4..a14204f 100644
--- 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
@@ -35,22 +35,26 @@ 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
+ * @date 10/16/2020 Application: ONAP - Blueprint Generator Common ONAP Service 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){
+ /**
+ * Creates Interface to include Start and Start inputs sections in BP for given Inputs and
+ * ComponentSpec
+ *
+ * @param inputs Inputs
+ * @param onapComponentSpec OnapComponentSpec
+ * @return
+ */
+ public Map<String, Object> createInterface(
+ Map<String, LinkedHashMap<String, Object>> inputs, OnapComponentSpec onapComponentSpec) {
- Map<String,Object> response = new HashMap<>();
+ Map<String, Object> response = new HashMap<>();
Interfaces interfaces = new Interfaces();
Map<String, Object> startResponse = startService.createStart(inputs, onapComponentSpec);
@@ -62,6 +66,4 @@ public class InterfacesService {
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
index b8da0d7..ab1b7f2 100644
--- 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
@@ -42,15 +42,11 @@ 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
+ * @date 10/16/2020 Application: ONAP - Blueprint Generator Common ONAP Service to add
+ * ONAP/DMAAP/Feed/Topic Nodes
*/
-
-
@Service
public class NodeService {
@@ -69,68 +65,97 @@ public class NodeService {
@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<>();
+ /**
+ * Creates Onap Node to include interface
+ *
+ * @param inputs Inputs
+ * @param onapComponentSpec OnapComponentSpec
+ * @param override Service Name Override
+ * @return
+ */
+ 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);
+ 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"));
+ 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);
+ 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);
+ 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);
+ 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"));
+ 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<>();
+ /**
+ * Creates Dmaap Node to include interface
+ *
+ * @param inputs Inputs
+ * @param onapComponentSpec OnapComponentSpec
+ * @param override Service Name Override
+ * @return
+ */
+ 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);
+ 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"));
+ 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()) {
+ if (onapComponentSpec.getStreams().getPublishes() != null) {
+ for (Publishes publishes : onapComponentSpec.getStreams().getPublishes()) {
Map<String, String> pubRelations = new LinkedHashMap();
- if(blueprintHelperService.isMessageRouterType(publishes.getType())){
+ 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())){
+ } else if (blueprintHelperService.isDataRouterType(publishes.getType())) {
pubRelations.put("type", Constants.PUBLISH_FILES);
pubRelations.put("target", publishes.getConfig_key() + Constants._FEED);
}
@@ -138,13 +163,13 @@ public class NodeService {
}
}
- if(onapComponentSpec.getStreams().getSubscribes() != null) {
- for(Subscribes subscribes: onapComponentSpec.getStreams().getSubscribes()) {
- Map<String, String> subRelations = new LinkedHashMap();
- if(blueprintHelperService.isMessageRouterType(subscribes.getType())){
+ 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())){
+ } else if (blueprintHelperService.isDataRouterType(subscribes.getType())) {
subRelations.put("type", Constants.SUBSCRIBE_TO_FILES);
subRelations.put("target", subscribes.getConfig_key() + Constants._FEED);
}
@@ -152,30 +177,42 @@ public class NodeService {
}
}
- if(onapComponentSpec.getPolicyInfo() != null){
- List<Map<String, String>> policyRelationshipsList = policyNodeService.getPolicyRelationships(onapComponentSpec);
+ 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);
+ 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);
+ 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"));
+ 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<>();
+ /**
+ * Creates Feed Node for Streams
+ *
+ * @param inputs Inputs
+ * @param name Name
+ * @return
+ */
+ 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();
@@ -183,7 +220,8 @@ public class NodeService {
feedNode.setType(Constants.FEED);
- org.onap.blueprintgenerator.model.common.Properties props = new org.onap.blueprintgenerator.model.common.Properties();
+ 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);
@@ -196,9 +234,16 @@ public class NodeService {
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<>();
+ /**
+ * Creates Topic Node for Streams
+ *
+ * @param inputs Inpts
+ * @param name Name
+ * @return
+ */
+ 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();
@@ -217,6 +262,4 @@ public class NodeService {
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
index ff45701..d18ca92 100644
--- 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
@@ -26,7 +26,6 @@ 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;
@@ -45,30 +44,43 @@ 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
+ * @date 10/16/2020 Application: ONAP - Blueprint Generator Common ONAP Service 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) {
+ /**
+ * Creates Pgaas Nodes and Inputs for Databases
+ *
+ * @param onapComponentSpec OnapComponentSpec
+ * @param nodeTemplate Node template
+ * @param inputs Inputs
+ * @return
+ */
+ 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);
+ if (databases != null) {
+ 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 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) {
@@ -76,7 +88,7 @@ public class PgaasNodeService {
String dbName = database.getKey();
pgaasNode.setType(Constants.PGAAS_NODE_TYPE);
pgaasNode.setPgaasNodeProperties(buildPgaasNodeProperties(dbName));
- nodeTemplate.put(dbName + Constants.PGAAS_NODE_NAME_POSTFIX , pgaasNode);
+ nodeTemplate.put(dbName + Constants.PGAAS_NODE_NAME_POSTFIX, pgaasNode);
}
private PgaasNodeProperties buildPgaasNodeProperties(String dbName) {
@@ -95,10 +107,17 @@ public class PgaasNodeService {
return pgaasNodeProperties;
}
- // method to create Pgaas Node Relationships for Databases
- public List<Map<String, String>> getPgaasNodeRelationships(OnapComponentSpec onapComponentSpec) {
+ /**
+ * Creates Pgaas Nodes Relationships for Databases
+ *
+ * @param onapComponentSpec OnapComponentSpec
+ * @return
+ */
+ 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()){
+ 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);
@@ -107,10 +126,15 @@ public class PgaasNodeService {
return relationships;
}
- // method to create Env Variables for Databases
+ /**
+ * Creates Env Variables for Databases
+ *
+ * @param databases Database
+ * @return
+ */
public Map<String, Object> getEnvVariables(Map<String, String> databases) {
Map<String, Object> envVariables = new LinkedHashMap<>();
- for(Map.Entry<String, String> database : databases.entrySet()){
+ for (Map.Entry<String, String> database : databases.entrySet()) {
String name = database.getKey().toUpperCase();
envVariables.put("<<", "*envs");
@@ -118,21 +142,25 @@ public class PgaasNodeService {
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 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 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);
+ 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));
+ 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
index 7f6c63d..43d819f 100644
--- 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
@@ -41,31 +41,40 @@ 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
+ * @date 10/16/2020 Application: ONAP - Blueprint Generator Common ONAP Service 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) {
+ /**
+ * Creates Policy Nodes and Inputs
+ *
+ * @param onapComponentSpec OnapComponentSpec
+ * @param nodeTemplate Node Template
+ * @param inputs Inputs
+ * @return
+ */
+ 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){
+ for (TypePolicy policy : policyList) {
addPolicyNodesToNodeTemplate(policy, nodeTemplate);
addPolicyInputs(policy, inputs);
}
}
- private void addPolicyInputs(TypePolicy policy, Map<String, LinkedHashMap<String, Object>> 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));
+ inputs.put(
+ policy.getNode_label() + "_policy_id",
+ blueprintHelperService.createStringInput("policy_id", defaultValue));
}
private void addPolicyNodesToNodeTemplate(TypePolicy policy, Map<String, Node> nodeTemplate) {
@@ -84,11 +93,16 @@ public class PolicyNodeService {
return policyNodeProperties;
}
- // Method to add Policy Relationships
+ /**
+ * Creates Policy Relationships
+ *
+ * @param onapComponentSpec OnapComponentSpec
+ * @return
+ */
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){
+ for (TypePolicy policy : policyList) {
Map<String, String> relationship = new LinkedHashMap<>();
relationship.put("type", Constants.POLICY_RELATIONSHIP_TYPE);
relationship.put("target", policy.getNode_label());
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
index e858d88..3c36cca 100644
--- 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
@@ -47,13 +47,9 @@ 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
+ * @date 10/16/2020 Application: ONAP - Blueprint Generator Common ONAP Service to create Properties
+ * Node
*/
-
-
-
@Service("onapPropertiesService")
public class PropertiesService {
@@ -72,18 +68,30 @@ public class PropertiesService {
@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();
+ /**
+ * Creates ONAP properties
+ *
+ * @param inputs Inputs
+ * @param onapComponentSpec OnapComponentSpec
+ * @param override Override
+ * @return
+ */
+ 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()));
-
+ inputs.put(
+ "image",
+ blueprintHelperService.createStringInput(onapComponentSpec.getArtifacts()[0].getUri()));
GetInput location = new GetInput();
location.setBpInputName("location_id");
@@ -98,14 +106,16 @@ public class PropertiesService {
replica.setBpInputName("replicas");
properties.setReplicas(replica);
- LinkedHashMap<String, Object> replicas = blueprintHelperService.createIntegerInput("number of instances", 1);
+ 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);
+ 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"));
@@ -114,7 +124,9 @@ public class PropertiesService {
properties.setAlways_pull_image(always_pull_image);
- LinkedHashMap<String, Object> inputAlwaysPullImage = blueprintHelperService.createBooleanInput("Set to true if the image should always be pulled",true);
+ 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();
@@ -122,33 +134,49 @@ public class PropertiesService {
properties.setService_component_type(sType);
Map<String, Object> tls_info = onapComponentSpec.getAuxilary().getTls_info();
- if(tls_info != null) {
+ if (tls_info != null) {
addTlsInfo(onapComponentSpec, inputs, properties);
if (tls_info.get(Constants.USE_EXTERNAL_TLS_FIELD) != null) {
- inputs.putAll(addExternalTlsInfo(onapComponentSpec,properties));
+ inputs.putAll(addExternalTlsInfo(onapComponentSpec, properties));
}
}
- Map<String, Object> resourceConfigResponse = resourceConfigService.createResourceConfig(inputs, onapComponentSpec.getSelf().getName());
+ 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"));
+ 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();
+ /**
+ * Creates Dmaap properties
+ *
+ * @param inputs Inputs
+ * @param onapComponentSpec OnapComponentSpec
+ * @param override Override
+ * @return
+ */
+ 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()));
+ inputs.put(
+ "tag_version",
+ blueprintHelperService.createStringInput(onapComponentSpec.getArtifacts()[0].getUri()));
GetInput location = new GetInput();
location.setBpInputName("location_id");
@@ -164,10 +192,10 @@ public class PropertiesService {
properties.setService_component_type(sType);
Map<String, Object> tls_info = onapComponentSpec.getAuxilary().getTls_info();
- if(tls_info != null) {
+ if (tls_info != null) {
addTlsInfo(onapComponentSpec, inputs, properties);
if (tls_info.get(Constants.USE_EXTERNAL_TLS_FIELD) != null) {
- inputs.putAll(addExternalTlsInfo(onapComponentSpec,properties));
+ inputs.putAll(addExternalTlsInfo(onapComponentSpec, properties));
}
}
@@ -175,31 +203,50 @@ public class PropertiesService {
replica.setBpInputName("replicas");
properties.setReplicas(replica);
- LinkedHashMap<String, Object> rep = blueprintHelperService.createIntegerInput( "number of instances", 1);
+ 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);
+ 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() != 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");
+ 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");
+ 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"));
}
}
@@ -207,53 +254,84 @@ public class PropertiesService {
}
ArrayList<Streams> subStreams = new ArrayList();
- if(onapComponentSpec.getStreams() != null) {
+ 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");
+ 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");
+ 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())
+ if (!pubStreams.isEmpty()) {
properties.setStreams_publishes(pubStreams);
+ }
- if(!subStreams.isEmpty())
+ if (!subStreams.isEmpty()) {
properties.setStreams_subscribes(subStreams);
+ }
- Map<String, Object> resourceConfigResponse = resourceConfigService.createResourceConfig(inputs, onapComponentSpec.getSelf().getName());
+ 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"));
+ 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) {
+ 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"));
+ 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"));
+ 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);
- }
-
+ 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
index c79ec56..642a13e 100644
--- 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
@@ -30,22 +30,24 @@ 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
+ * @date 10/16/2020 Application: ONAP - Blueprint Generator Common ONAP Service to set Quotations of
+ * generated Blueprint
*/
-
-
@Service
public class QuotationService {
- // Method to add Quotes for String Types
+ /**
+ * Adds Quotes for String Types for generated Blueprint
+ *
+ * @param bp Blueprint
+ * @return
+ */
public OnapBlueprint setQuotations(OnapBlueprint bp) {
- for(String s: bp.getInputs().keySet()) {
+ for (String s : bp.getInputs().keySet()) {
LinkedHashMap<String, Object> temp = bp.getInputs().get(s);
- if(temp.get("type") == "string") {
+ if (temp.get("type") == "string") {
String def = (String) temp.get("default");
- if(def != null){
+ if (def != null) {
def = def.replaceAll("\"$", "").replaceAll("^\"", "");
}
def = '"' + def + '"';
@@ -55,5 +57,4 @@ public class QuotationService {
}
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
index 7b03372..a3a9c97 100644
--- 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
@@ -37,26 +37,32 @@ 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
+ * @date 10/16/2020 Application: ONAP - Blueprint Generator Common ONAP Service 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<>();
+ /**
+ * Creates Resouce Config for properties
+ *
+ * @param inputs Inputs
+ * @param name Name
+ * @return
+ */
+ 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> memoryLimit =
+ blueprintHelperService.createStringInput(Constants.MEMORY_LIMIT_128Mi);
- LinkedHashMap<String, Object> cpuLimit = blueprintHelperService.createStringInput( Constants.CPU_LIMIT_250m);
+ LinkedHashMap<String, Object> cpuLimit =
+ blueprintHelperService.createStringInput(Constants.CPU_LIMIT_250m);
name = blueprintHelperService.getNamePrefix(name);
@@ -94,5 +100,4 @@ public class ResourceConfigService {
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
index 20c3656..8ec0024 100644
--- 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
@@ -38,22 +38,26 @@ 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
+ * @date 10/16/2020 Application: ONAP - Blueprint Generator Common ONAP Service 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<>();
+ /**
+ * Creates Start Inputs for Start in Interfaces
+ *
+ * @param inputs Inputs
+ * @param onapComponentSpec OnapComponentSpec
+ * @return
+ */
+ 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;
@@ -61,9 +65,11 @@ public class StartInputsService {
OnapAuxilary aux = onapComponentSpec.getAuxilary();
if (aux.getPorts() != null) {
- for(Object p : aux.getPorts()) {
+ for (Object p : aux.getPorts()) {
String[] ports = p.toString().split(":");
- portList.add(String.format("concat: [\"%s:\", {get_input: external_port_%d}]" , ports[0], count));
+ portList.add(
+ String.format("concat: [\"%s:\", {get_input: external_port_%d}]", ports[0],
+ count));
LinkedHashMap<String, Object> portType = new LinkedHashMap();
portType.put("type", "string");
@@ -76,12 +82,12 @@ public class StartInputsService {
startInputs.setPorts(portList);
LinkedHashMap<String, Object> envMap = new LinkedHashMap();
- if(onapComponentSpec.getAuxilary().getDatabases() != null){
- Map<String, Object> envVars = pgaasNodeService.getEnvVariables(onapComponentSpec.getAuxilary().getDatabases());
+ if (onapComponentSpec.getAuxilary().getDatabases() != null) {
+ Map<String, Object> envVars =
+ pgaasNodeService.getEnvVariables(onapComponentSpec.getAuxilary().getDatabases());
startInputs.setEnvs(envVars);
envMap.put("default", "&envs {}");
- }
- else {
+ } else {
GetInput env = new GetInput();
env.setBpInputName("envs");
startInputs.setEnvs(env);
@@ -93,5 +99,4 @@ public class StartInputsService {
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
index 3fbfdb1..6c92c6f 100644
--- 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
@@ -23,7 +23,6 @@
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;
@@ -36,24 +35,28 @@ 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
+ * @date 10/16/2020 Application: ONAP - Blueprint Generator Common ONAP Service 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<>();
+ /**
+ * Creates Start for Interfaces
+ *
+ * @param inputs Inputs
+ * @param onapComponentSpec OnapComponentSpec
+ * @return
+ */
+ 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);
+ Map<String, Object> startInputsResponse =
+ startInputsService.createStartInputs(inputs, onapComponentSpec);
inputs = (Map<String, LinkedHashMap<String, Object>>) startInputsResponse.get("inputs");
start.setInputs((StartInputs) startInputsResponse.get("startInputs"));
@@ -61,5 +64,4 @@ public class StartService {
response.put("inputs", inputs);
return response;
}
-
}
diff --git a/mod/bpgenerator/onap/src/main/java/org/onap/blueprintgenerator/service/dmaap/DmaapBlueprintService.java b/mod/bpgenerator/onap/src/main/java/org/onap/blueprintgenerator/service/dmaap/DmaapBlueprintService.java
index 002bd6c..9da2074 100644
--- a/mod/bpgenerator/onap/src/main/java/org/onap/blueprintgenerator/service/dmaap/DmaapBlueprintService.java
+++ b/mod/bpgenerator/onap/src/main/java/org/onap/blueprintgenerator/service/dmaap/DmaapBlueprintService.java
@@ -48,97 +48,116 @@ import java.util.TreeMap;
/**
* @author : Ravi Mantena
- * @date 10/16/2020
- * Application: ONAP - Blueprint Generator
- * Service to create DMAAP Blueprint
+ * @date 10/16/2020 Application: ONAP - Blueprint Generator Service to create DMAAP Blueprint
*/
-
@Service
public class DmaapBlueprintService extends BlueprintService {
- @Autowired
- protected ImportsService importsService;
-
- @Autowired
- private NodeService nodeService;
-
- @Autowired
- private PolicyNodeService policyNodeService;
-
- @Autowired
- private PgaasNodeService pgaasNodeService;
-
- @Autowired
- private QuotationService quotationService;
-
- @Autowired
- private BlueprintHelperService blueprintHelperService;
-
- // method to generate Dmaap Blueprint
- public OnapBlueprint createBlueprint(OnapComponentSpec onapComponentSpec, Input input) {
- try {
- OnapBlueprint blueprint = new OnapBlueprint();
- blueprint.setTosca_definitions_version(Constants.TOSCA_DEF_VERSION);
- blueprint.setDescription(onapComponentSpec.getSelf().getDescription());
-
- Map<String, LinkedHashMap<String, Object>> inputs = new TreeMap<>();
-
- //if (!"".equals(input.getImportPath()))
- if (!StringUtils.isEmpty(input.getImportPath()) )
- blueprint.setImports(importsService.createImportsFromFile(input.getImportPath()));
- else
- blueprint.setImports(importsService.createImports(input.getBpType()));
-
- Map<String, Node> nodeTemplate = new TreeMap();
-
- Map<String, Object> dmaapNodeResponse = nodeService.createDmaapNode(onapComponentSpec, inputs, input.getServiceNameOverride());
- inputs = (Map<String, LinkedHashMap<String, Object>>) dmaapNodeResponse.get("inputs");
- nodeTemplate.put(onapComponentSpec.getSelf().getName(), (Node) dmaapNodeResponse.get("dmaapNode"));
-
- 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> topicNodeResponse = nodeService.createTopicNode(inputs, topic);
- inputs = (Map<String, LinkedHashMap<String, Object>>) topicNodeResponse.get("inputs");
- nodeTemplate.put(topic, (Node) topicNodeResponse.get("topicNode"));
- } else if (blueprintHelperService.isDataRouterType(publishes.getType())) {
- String feed = publishes.getConfig_key() + Constants._FEED;
- Map<String, Object> feedNodeResponse = nodeService.createFeedNode(inputs, feed);
- inputs = (Map<String, LinkedHashMap<String, Object>>) feedNodeResponse.get("inputs");
- nodeTemplate.put(feed, (Node) feedNodeResponse.get("feedNode"));
- }
- }
- }
- if (onapComponentSpec.getStreams().getSubscribes() != null) {
- for (Subscribes s : onapComponentSpec.getStreams().getSubscribes()) {
- if (blueprintHelperService.isMessageRouterType(s.getType())) {
- String topic = s.getConfig_key() + Constants._TOPIC;
- Map<String, Object> topicNodeResponse = nodeService.createTopicNode(inputs, topic);
- inputs = (Map<String, LinkedHashMap<String, Object>>) topicNodeResponse.get("inputs");
- nodeTemplate.put(topic, (Node) topicNodeResponse.get("topicNode"));
- } else if (blueprintHelperService.isDataRouterType(s.getType())) {
- String feed = s.getConfig_key() + Constants._FEED;
- Map<String, Object> feedNodeResponse = nodeService.createFeedNode(inputs, feed);
- inputs = (Map<String, LinkedHashMap<String, Object>>) feedNodeResponse.get("inputs");
- nodeTemplate.put(feed, (Node) feedNodeResponse.get("feedNode"));
- }
- }
+ @Autowired
+ protected ImportsService importsService;
+
+ @Autowired
+ private NodeService nodeService;
+
+ @Autowired
+ private PolicyNodeService policyNodeService;
+
+ @Autowired
+ private PgaasNodeService pgaasNodeService;
+
+ @Autowired
+ private QuotationService quotationService;
+
+ @Autowired
+ private BlueprintHelperService blueprintHelperService;
+
+ /**
+ * Creates Dmaap Blueprint
+ *
+ * @param onapComponentSpec OnapComponentSpec
+ * @param input Inputs
+ * @return
+ */
+ public OnapBlueprint createBlueprint(OnapComponentSpec onapComponentSpec, Input input) {
+ try {
+ OnapBlueprint blueprint = new OnapBlueprint();
+ blueprint.setTosca_definitions_version(Constants.TOSCA_DEF_VERSION);
+ blueprint.setDescription(onapComponentSpec.getSelf().getDescription());
+
+ Map<String, LinkedHashMap<String, Object>> inputs = new TreeMap<>();
+
+ // if (!"".equals(input.getImportPath()))
+ if (!StringUtils.isEmpty(input.getImportPath())) {
+ blueprint.setImports(importsService.createImportsFromFile(input.getImportPath()));
+ } else {
+ blueprint.setImports(importsService.createImports(input.getBpType()));
+ }
+
+ Map<String, Node> nodeTemplate = new TreeMap();
+
+ Map<String, Object> dmaapNodeResponse =
+ nodeService
+ .createDmaapNode(onapComponentSpec, inputs, input.getServiceNameOverride());
+ inputs = (Map<String, LinkedHashMap<String, Object>>) dmaapNodeResponse.get("inputs");
+ nodeTemplate.put(
+ onapComponentSpec.getSelf().getName(), (Node) dmaapNodeResponse.get("dmaapNode"));
+
+ 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> topicNodeResponse = nodeService
+ .createTopicNode(inputs, topic);
+ inputs = (Map<String, LinkedHashMap<String, Object>>) topicNodeResponse
+ .get("inputs");
+ nodeTemplate.put(topic, (Node) topicNodeResponse.get("topicNode"));
+ } else if (blueprintHelperService.isDataRouterType(publishes.getType())) {
+ String feed = publishes.getConfig_key() + Constants._FEED;
+ Map<String, Object> feedNodeResponse = nodeService
+ .createFeedNode(inputs, feed);
+ inputs = (Map<String, LinkedHashMap<String, Object>>) feedNodeResponse
+ .get("inputs");
+ nodeTemplate.put(feed, (Node) feedNodeResponse.get("feedNode"));
+ }
+ }
+ }
+ if (onapComponentSpec.getStreams().getSubscribes() != null) {
+ for (Subscribes s : onapComponentSpec.getStreams().getSubscribes()) {
+ if (blueprintHelperService.isMessageRouterType(s.getType())) {
+ String topic = s.getConfig_key() + Constants._TOPIC;
+ Map<String, Object> topicNodeResponse = nodeService
+ .createTopicNode(inputs, topic);
+ inputs = (Map<String, LinkedHashMap<String, Object>>) topicNodeResponse
+ .get("inputs");
+ nodeTemplate.put(topic, (Node) topicNodeResponse.get("topicNode"));
+ } else if (blueprintHelperService.isDataRouterType(s.getType())) {
+ String feed = s.getConfig_key() + Constants._FEED;
+ Map<String, Object> feedNodeResponse = nodeService
+ .createFeedNode(inputs, feed);
+ inputs = (Map<String, LinkedHashMap<String, Object>>) feedNodeResponse
+ .get("inputs");
+ nodeTemplate.put(feed, (Node) feedNodeResponse.get("feedNode"));
+ }
+ }
+ }
+ }
+
+ if (onapComponentSpec.getPolicyInfo() != null) {
+ policyNodeService.addPolicyNodesAndInputs(onapComponentSpec, nodeTemplate, inputs);
+ }
+
+ if (onapComponentSpec.getAuxilary() != null
+ && onapComponentSpec.getAuxilary().getDatabases() != null) {
+ pgaasNodeService.addPgaasNodesAndInputs(onapComponentSpec, nodeTemplate, inputs);
+ }
+
+ blueprint.setNode_templates(nodeTemplate);
+ blueprint.setInputs(inputs);
+ return quotationService.setQuotations(blueprint);
+ } catch (Exception ex) {
+ throw new BlueprintException(
+ "Unable to create ONAP DMAAP Blueprint Object from given input parameters", ex);
+ }
}
- }
-
- if (onapComponentSpec.getPolicyInfo() != null)
- policyNodeService.addPolicyNodesAndInputs(onapComponentSpec, nodeTemplate, inputs);
-
- if (onapComponentSpec.getAuxilary() != null && onapComponentSpec.getAuxilary().getDatabases() != null)
- pgaasNodeService.addPgaasNodesAndInputs(onapComponentSpec, nodeTemplate, inputs);
-
- blueprint.setNode_templates(nodeTemplate);
- blueprint.setInputs(inputs);
- return quotationService.setQuotations(blueprint);
- } catch (Exception ex) {
- throw new BlueprintException("Unable to create ONAP DMAAP Blueprint Object from given input parameters", ex);
- }
- }
-} \ No newline at end of file
+}
diff --git a/mod/bpgenerator/onap/src/main/java/org/onap/blueprintgenerator/service/dmaap/StreamsService.java b/mod/bpgenerator/onap/src/main/java/org/onap/blueprintgenerator/service/dmaap/StreamsService.java
index 16687fc..051b060 100644
--- a/mod/bpgenerator/onap/src/main/java/org/onap/blueprintgenerator/service/dmaap/StreamsService.java
+++ b/mod/bpgenerator/onap/src/main/java/org/onap/blueprintgenerator/service/dmaap/StreamsService.java
@@ -35,21 +35,33 @@ import java.util.Map;
/**
* @author : Ravi Mantena
- * @date 10/16/2020
- * Application: ONAP - Blueprint Generator
- * Service to create Streams
+ * @date 10/16/2020 Application: ONAP - Blueprint Generator Service to create Streams
*/
-
-
@Service
public class StreamsService {
@Autowired
private BlueprintHelperService blueprintHelperService;
- //Methos to create streams for Dmaap Blueprint
- public Map<String, Object> createStreams(Map<String, LinkedHashMap<String, Object>> inputs, String name, String type, String key, String route, char o){
- Map<String,Object> response = new HashMap<>();
+ /**
+ * Creates streams for Dmaap Blueprint
+ *
+ * @param inputs Inputs
+ * @param name Name
+ * @param type Type
+ * @param key Key
+ * @param route Route
+ * @param o For Data Router Type s
+ * @return
+ */
+ public Map<String, Object> createStreams(
+ Map<String, LinkedHashMap<String, Object>> inputs,
+ String name,
+ String type,
+ String key,
+ String route,
+ char o) {
+ Map<String, Object> response = new HashMap<>();
Streams streams = new Streams();
LinkedHashMap<String, Object> stringType = new LinkedHashMap();
@@ -63,8 +75,8 @@ public class StreamsService {
inputs.put(key + "_" + name + "_location", stringType);
streams.setLocation(location);
- if(blueprintHelperService.isDataRouterType(type)) {
- if('s' == o) {
+ if (blueprintHelperService.isDataRouterType(type)) {
+ if ('s' == o) {
GetInput username = new GetInput();
username.setBpInputName(key + "_" + name + "_username");
streams.setUsername(username);
@@ -89,7 +101,6 @@ public class StreamsService {
streams.setScheme("https");
}
-
} else {
GetInput client = new GetInput();
client.setBpInputName(key + "_" + name + "_client_role");
@@ -100,5 +111,4 @@ public class StreamsService {
response.put("inputs", inputs);
return response;
}
-
}