From c03a0455e2956e43e425d6f4121ab5d8d20158f1 Mon Sep 17 00:00:00 2001 From: liamfallon Date: Mon, 21 Oct 2019 19:59:22 +0100 Subject: Use updated APPC model code in apex vcpe example The APPC implementation was changed in a recent review, this review fixes the apex vcpe example to use this new model. Also fixes an an issue in the CLI editor where escape characters are not now required in example JSON. Issue-ID: POLICY-2043 Change-Id: Id251948c9de27f73ba48cec498e68a43f71c4062 Signed-off-by: liamfallon --- .../policy/apex/auth/clieditor/utils/CliUtils.java | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) (limited to 'auth/cli-editor/src/main/java') diff --git a/auth/cli-editor/src/main/java/org/onap/policy/apex/auth/clieditor/utils/CliUtils.java b/auth/cli-editor/src/main/java/org/onap/policy/apex/auth/clieditor/utils/CliUtils.java index 2454f39fa..9459a7ffd 100644 --- a/auth/cli-editor/src/main/java/org/onap/policy/apex/auth/clieditor/utils/CliUtils.java +++ b/auth/cli-editor/src/main/java/org/onap/policy/apex/auth/clieditor/utils/CliUtils.java @@ -47,11 +47,6 @@ import org.slf4j.LoggerFactory; * @author Ajith Sreekumar (ajith.sreekumar@est.tech) */ public class CliUtils { - - private CliUtils() { - // This class cannot be initialized - } - private static final Logger LOGGER = LoggerFactory.getLogger(CliUtils.class); // Recurring string constants @@ -59,13 +54,20 @@ public class CliUtils { private static final int MAX_HELP_LINE_LENGTH = 120; /** - * Method to create apex policy in tosca service template. + * Private constructor to prevent sub-classing. + */ + private CliUtils() { + // This class cannot be initialized + } + + /** + * Method to create apex policy in TOSCA service template. * * @param parameters containing paths to the apex config and tosca template skeleton file * @param policyModelFilePath path of apex policy model */ public static void createToscaServiceTemplate(ApexCliToscaParameters parameters, String policyModelFilePath) - throws IOException, CoderException { + throws IOException, CoderException { final StandardCoder standardCoder = new StandardCoder(); String apexConfig = TextFileUtils.getTextFileAsString(parameters.getApexConfigFileName()); JsonObject apexConfigJson = standardCoder.decode(apexConfig, JsonObject.class); @@ -79,7 +81,7 @@ public class CliUtils { JsonObject toscaPolicyProperties = toscaTemplateJson.get("topology_template").getAsJsonObject(); JsonObject toscaPolicy = toscaPolicyProperties.get("policies").getAsJsonArray().get(0).getAsJsonObject(); JsonObject toscaProperties = toscaPolicy.get(toscaPolicy.keySet().toArray()[0].toString()).getAsJsonObject() - .get("properties").getAsJsonObject(); + .get("properties").getAsJsonObject(); toscaProperties.add("content", apexConfigJson); final String toscaPolicyString = standardCoder.encode(toscaTemplateJson); @@ -192,7 +194,7 @@ public class CliUtils { * @return list of arguments */ public static List generateArgumentsForCliEditor(CommandLineParameters parameters, - Properties optionVariableMap, Class class1) { + Properties optionVariableMap, Class class1) { List cliArgsList = new ArrayList<>(); PropertyDescriptor pd; @@ -209,7 +211,7 @@ public class CliUtils { if (argValue instanceof String && !key.equals("o")) { cliArgsList.add("-" + key); cliArgsList.add(argValue.toString()); - } else if (argValue instanceof Boolean && (Boolean)argValue) { + } else if (argValue instanceof Boolean && (Boolean) argValue) { cliArgsList.add("-" + key); } } catch (Exception e) { -- cgit