aboutsummaryrefslogtreecommitdiffstats
path: root/auth/cli-editor/src/main
diff options
context:
space:
mode:
Diffstat (limited to 'auth/cli-editor/src/main')
-rw-r--r--auth/cli-editor/src/main/java/org/onap/policy/apex/auth/clieditor/ApexCLIEditorMain.java195
-rw-r--r--auth/cli-editor/src/main/java/org/onap/policy/apex/auth/clieditor/ApexModelHandler.java185
-rw-r--r--auth/cli-editor/src/main/java/org/onap/policy/apex/auth/clieditor/ApexModelProperties.java215
-rw-r--r--auth/cli-editor/src/main/java/org/onap/policy/apex/auth/clieditor/CLIArgument.java144
-rw-r--r--auth/cli-editor/src/main/java/org/onap/policy/apex/auth/clieditor/CLIArgumentValue.java91
-rw-r--r--auth/cli-editor/src/main/java/org/onap/policy/apex/auth/clieditor/CLICommand.java240
-rw-r--r--auth/cli-editor/src/main/java/org/onap/policy/apex/auth/clieditor/CLICommands.java42
-rw-r--r--auth/cli-editor/src/main/java/org/onap/policy/apex/auth/clieditor/CLIEditorLoop.java543
-rw-r--r--auth/cli-editor/src/main/java/org/onap/policy/apex/auth/clieditor/CLIException.java49
-rw-r--r--auth/cli-editor/src/main/java/org/onap/policy/apex/auth/clieditor/CLILineParser.java321
-rw-r--r--auth/cli-editor/src/main/java/org/onap/policy/apex/auth/clieditor/CLIParameterParser.java156
-rw-r--r--auth/cli-editor/src/main/java/org/onap/policy/apex/auth/clieditor/CLIParameters.java571
-rw-r--r--auth/cli-editor/src/main/java/org/onap/policy/apex/auth/clieditor/KeywordNode.java188
-rw-r--r--auth/cli-editor/src/main/java/org/onap/policy/apex/auth/clieditor/package-info.java28
-rw-r--r--auth/cli-editor/src/main/resources/etc/editor/ApexModelProperties.json9
-rw-r--r--auth/cli-editor/src/main/resources/etc/editor/Commands.json2427
-rw-r--r--auth/cli-editor/src/main/resources/examples/scripts/ShellPolicyModel.apex23
-rw-r--r--auth/cli-editor/src/main/resources/examples/scripts/ShellPolicyModelAddSchema.apex21
-rw-r--r--auth/cli-editor/src/main/resources/examples/scripts/TestPolicyAvroEventContext.apex569
-rw-r--r--auth/cli-editor/src/main/resources/examples/scripts/TestPolicyJavaEventContext.apex324
20 files changed, 6341 insertions, 0 deletions
diff --git a/auth/cli-editor/src/main/java/org/onap/policy/apex/auth/clieditor/ApexCLIEditorMain.java b/auth/cli-editor/src/main/java/org/onap/policy/apex/auth/clieditor/ApexCLIEditorMain.java
new file mode 100644
index 000000000..4a2635efa
--- /dev/null
+++ b/auth/cli-editor/src/main/java/org/onap/policy/apex/auth/clieditor/ApexCLIEditorMain.java
@@ -0,0 +1,195 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * Copyright (C) 2016-2018 Ericsson. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.policy.apex.auth.clieditor;
+
+import java.io.IOException;
+import java.util.Arrays;
+import java.util.Set;
+import java.util.TreeSet;
+
+import org.onap.policy.apex.model.utilities.json.JSONHandler;
+import org.slf4j.ext.XLogger;
+import org.slf4j.ext.XLoggerFactory;
+
+/**
+ * This class initiates an Apex CLI editor from a java main method.
+ *
+ * @author Liam Fallon (liam.fallon@ericsson.com)
+ */
+public class ApexCLIEditorMain {
+ // Get a reference to the logger
+ private static final XLogger LOGGER = XLoggerFactory.getXLogger(ApexCLIEditorMain.class);
+
+ // The editor parameters
+ private CLIParameters parameters;
+
+ // The CLI commands read in from JSON
+ private CLICommands commands;
+
+ // The Apex model properties read in from JSON
+ private ApexModelProperties apexModelProperties;
+
+ // The number of errors encountered in command processing
+ private int errorCount = 0;
+
+ /**
+ * Instantiates the Apex CLI editor.
+ *
+ * @param args the command line arguments
+ */
+ public ApexCLIEditorMain(final String[] args) {
+ LOGGER.info("Starting Apex CLI editor " + Arrays.toString(args) + " . . .");
+
+ try {
+ final CLIParameterParser parser = new CLIParameterParser();
+ parameters = parser.parse(args);
+
+ if (parameters.isHelpSet()) {
+ parser.help(ApexCLIEditorMain.class.getCanonicalName());
+ return;
+ }
+ parameters.validate();
+ } catch (final Exception e) {
+ LOGGER.error("start of Apex command line editor failed, " + e.getMessage());
+ errorCount++;
+ return;
+ }
+
+ LOGGER.debug("parameters are: " + parameters.toString());
+
+ // Read the command definitions
+ try {
+ commands = new JSONHandler<CLICommands>().read(CLICommands.class, parameters.getMetadataStream());
+ LOGGER.debug("found " + commands.getCommandSet().size() + " commands");
+ } catch (final Exception e) {
+ LOGGER.error("start of Apex command line editor failed, error reading command metadata from "
+ + parameters.getMetadataLocation());
+ LOGGER.error(e.getMessage());
+ errorCount++;
+ return;
+ }
+
+ // The JSON processing returns null if there is an empty file
+ if (null == commands) {
+ LOGGER.error("start of Apex command line editor failed, no commands found in "
+ + parameters.getApexPropertiesLocation());
+ errorCount++;
+ return;
+ }
+
+ // Read the Apex properties
+ try {
+ apexModelProperties = new JSONHandler<ApexModelProperties>().read(ApexModelProperties.class,
+ parameters.getApexPropertiesStream());
+ LOGGER.debug("model properties are: " + apexModelProperties.toString());
+ } catch (final Exception e) {
+ LOGGER.error("start of Apex command line editor failed, error reading Apex model properties from "
+ + parameters.getApexPropertiesLocation());
+ LOGGER.error(e.getMessage());
+ errorCount++;
+ return;
+ }
+
+ // The JSON processing returns null if there is an empty file
+ if (apexModelProperties == null) {
+ LOGGER.error("start of Apex command line editor failed, no Apex model properties found in "
+ + parameters.getApexPropertiesLocation());
+ errorCount++;
+ return;
+ }
+
+ // Find the system commands
+ final Set<KeywordNode> systemCommandNodes = new TreeSet<>();
+ for (final CLICommand command : commands.getCommandSet()) {
+ if (command.isSystemCommand()) {
+ systemCommandNodes.add(new KeywordNode(command.getName(), command));
+ }
+ }
+
+ // Read in the command hierarchy, this builds a tree of commands
+ final KeywordNode rootKeywordNode = new KeywordNode("root");
+ for (final CLICommand command : commands.getCommandSet()) {
+ rootKeywordNode.processKeywords(command.getKeywordlist(), command);
+ }
+ rootKeywordNode.addSystemCommandNodes(systemCommandNodes);
+
+ // Create the model we will work towards
+ ApexModelHandler modelHandler = null;
+ try {
+ modelHandler =
+ new ApexModelHandler(apexModelProperties.getProperties(), parameters.getInputModelFileName());
+ } catch (final Exception e) {
+ LOGGER.error("execution of Apex command line editor failed: " + e.getMessage());
+ errorCount++;
+ return;
+ }
+
+ final CLIEditorLoop cliEditorLoop =
+ new CLIEditorLoop(apexModelProperties.getProperties(), modelHandler, rootKeywordNode);
+ try {
+ errorCount =
+ cliEditorLoop.runLoop(parameters.getCommandInputStream(), parameters.getOutputStream(), parameters);
+
+ if (errorCount == 0) {
+ LOGGER.info("Apex CLI editor completed execution");
+ } else {
+ LOGGER.error("execution of Apex command line editor failed: " + errorCount
+ + " command execution failure(s) occurred");
+ }
+ } catch (final IOException e) {
+ LOGGER.error("execution of Apex command line editor failed: " + e.getMessage());
+ return;
+ }
+ }
+
+ /**
+ * Get the number of errors encountered in command processing
+ *
+ * @return the number of errors
+ */
+ public int getErrorCount() {
+ return errorCount;
+ }
+
+ /**
+ * Sets the number of errors encountered in command processing.
+ *
+ * @param errorCount the number of errors
+ */
+ public void setErrorCount(final int errorCount) {
+ this.errorCount = errorCount;
+ }
+
+
+ /**
+ * The main method, kicks off the editor.
+ *
+ * @param args the arguments
+ */
+ public static void main(final String[] args) {
+ final ApexCLIEditorMain cliEditor = new ApexCLIEditorMain(args);
+
+ // Only call system.exit on errors as it brings the JVM down
+ if (cliEditor.getErrorCount() > 0) {
+ System.exit(cliEditor.getErrorCount());
+ }
+ }
+}
diff --git a/auth/cli-editor/src/main/java/org/onap/policy/apex/auth/clieditor/ApexModelHandler.java b/auth/cli-editor/src/main/java/org/onap/policy/apex/auth/clieditor/ApexModelHandler.java
new file mode 100644
index 000000000..a5e5302f9
--- /dev/null
+++ b/auth/cli-editor/src/main/java/org/onap/policy/apex/auth/clieditor/ApexModelHandler.java
@@ -0,0 +1,185 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * Copyright (C) 2016-2018 Ericsson. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.policy.apex.auth.clieditor;
+
+import java.io.PrintWriter;
+import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Method;
+import java.util.Properties;
+import java.util.TreeMap;
+
+import org.onap.policy.apex.model.modelapi.ApexAPIResult;
+import org.onap.policy.apex.model.modelapi.ApexModel;
+import org.onap.policy.apex.model.modelapi.ApexModelFactory;
+
+/**
+ * This class instantiates and holds the Apex model being manipulated by the editor.
+ *
+ * @author Liam Fallon (liam.fallon@ericsson.com)
+ */
+public class ApexModelHandler {
+ private ApexModel apexModel = null;
+
+ /**
+ * Create the Apex Model with the properties specified.
+ *
+ * @param properties The properties of the Apex model
+ */
+ public ApexModelHandler(final Properties properties) {
+ apexModel = new ApexModelFactory().createApexModel(properties, true);
+ }
+
+ /**
+ * Create the Apex Model with the properties specified and load it from a file.
+ *
+ * @param properties The properties of the Apex model
+ * @param modelFileName The name of the model file to edit
+ */
+ public ApexModelHandler(final Properties properties, final String modelFileName) {
+ this(properties);
+
+ if (modelFileName == null) {
+ return;
+ }
+
+ final ApexAPIResult result = apexModel.loadFromFile(modelFileName);
+ if (result.isNOK()) {
+ throw new CLIException(result.getMessages().get(0));
+ }
+ }
+
+ /**
+ * Execute a command on the Apex model.
+ *
+ * @param command The command to execute
+ * @param argumentValues Arguments of the command
+ * @param writer A writer to which to write output
+ * @return the result of the executed command
+ */
+ public ApexAPIResult executeCommand(final CLICommand command,
+ final TreeMap<String, CLIArgumentValue> argumentValues, final PrintWriter writer) {
+ // Get the method
+ final Method apiMethod = getCommandMethod(command);
+
+ // Get the method arguments
+ final Object[] parameterArray = getParameterArray(command, argumentValues, apiMethod);
+
+ try {
+ final Object returnObject = apiMethod.invoke(apexModel, parameterArray);
+
+ if (returnObject instanceof ApexAPIResult) {
+ final ApexAPIResult result = (ApexAPIResult) returnObject;
+ writer.println(result);
+ return result;
+ } else {
+ throw new CLIException(
+ "invocation of specified method \"" + command.getApiMethod() + "\" failed for command \""
+ + command.getName() + "\" the returned object is not an instance of ApexAPIResult");
+ }
+ } catch (IllegalAccessException | IllegalArgumentException e) {
+ writer.println("invocation of specified method \"" + command.getApiMethod() + "\" failed for command \""
+ + command.getName() + "\"");
+ e.printStackTrace(writer);
+ throw new CLIException("invocation of specified method \"" + command.getApiMethod()
+ + "\" failed for command \"" + command.getName() + "\"", e);
+ } catch (final InvocationTargetException e) {
+ writer.println("invocation of specified method \"" + command.getApiMethod() + "\" failed for command \""
+ + command.getName() + "\"");
+ e.getCause().printStackTrace(writer);
+ throw new CLIException("invocation of specified method \"" + command.getApiMethod()
+ + "\" failed for command \"" + command.getName() + "\"", e);
+ }
+ }
+
+ /**
+ * Find the API method for the command.
+ *
+ * @param command The command
+ * @return the API method
+ */
+ private Method getCommandMethod(final CLICommand command) {
+ final String className = command.getAPIClassName();
+ final String methodName = command.getAPIMethodName();
+
+ try {
+ final Class<? extends Object> apiClass = Class.forName(className);
+ for (final Method apiMethod : apiClass.getMethods()) {
+ if (apiMethod.getName().equals(methodName)) {
+ return apiMethod;
+ }
+ }
+ throw new CLIException("specified method \"" + command.getApiMethod() + "\" not found for command \""
+ + command.getName() + "\"");
+ } catch (final ClassNotFoundException e) {
+ throw new CLIException("specified class \"" + command.getApiMethod() + "\" not found for command \""
+ + command.getName() + "\"");
+ }
+ }
+
+ /**
+ * Get the arguments of the command as an ordered array of objects ready for the method.
+ *
+ * @param command the command that invoked the method
+ * @param argumentValues the argument values for the method
+ * @param apiMethod the method itself
+ * @return the argument list
+ */
+ private Object[] getParameterArray(final CLICommand command, final TreeMap<String, CLIArgumentValue> argumentValues,
+ final Method apiMethod) {
+ final Object[] parameterArray = new Object[argumentValues.size()];
+
+ int i = 0;
+ try {
+ for (final Class<?> parametertype : apiMethod.getParameterTypes()) {
+ final String parameterValue =
+ argumentValues.get(command.getArgumentList().get(i).getArgumentName()).getValue();
+
+ if (parametertype.equals(boolean.class)) {
+ parameterArray[i] = (boolean) Boolean.valueOf(parameterValue);
+ } else {
+ parameterArray[i] = parameterValue;
+ }
+ i++;
+ }
+ } catch (final Exception e) {
+ throw new CLIException("number of argument mismatch on method \"" + command.getApiMethod()
+ + "\" for command \"" + command.getName() + "\"");
+ }
+
+ return parameterArray;
+ }
+
+ /**
+ * Save the model to a string.
+ *
+ * @param messageWriter the writer to write status messages to
+ * @return the string
+ */
+ public String writeModelToString(final PrintWriter messageWriter) {
+ final ApexAPIResult result = apexModel.listModel();
+
+ if (result.isOK()) {
+ return result.getMessage();
+ } else {
+ return null;
+ }
+ }
+}
diff --git a/auth/cli-editor/src/main/java/org/onap/policy/apex/auth/clieditor/ApexModelProperties.java b/auth/cli-editor/src/main/java/org/onap/policy/apex/auth/clieditor/ApexModelProperties.java
new file mode 100644
index 000000000..6ed68288a
--- /dev/null
+++ b/auth/cli-editor/src/main/java/org/onap/policy/apex/auth/clieditor/ApexModelProperties.java
@@ -0,0 +1,215 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * Copyright (C) 2016-2018 Ericsson. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.policy.apex.auth.clieditor;
+
+import java.util.Properties;
+
+/**
+ * This class contains the definitions of Apex model properties.
+ *
+ * @author Liam Fallon (liam.fallon@ericsson.com)
+ */
+public class ApexModelProperties {
+ /** The default version that will be used for concepts. */
+ public static final String DEFAULT_CONCEPT_VERSION = "0.0.1";
+
+ /** The default name space that will be used for concepts. */
+ public static final String DEFAULT_EVENT_NAMESPACE = "org.onap.policy.apex";
+
+ /** The default source that will be used for events. */
+ public static final String DEFAULT_EVENT_SOURCE = "eventSource";
+
+ /** The default target that will be used for events. */
+ public static final String DEFAULT_EVENT_TARGET = "eventTarget";
+
+ /** The default logic block start token. */
+ public static final String DEFAULT_LOGIC_BLOCK_START_TAG = "LB{";
+
+ /** The default logic block end token. */
+ public static final String DEFAULT_LOGIC_BLOCK_END_TAG = "}LB";
+
+ /** The default logic block end token. */
+ public static final String DEFAULT_POLICY_TEMPLATE = "FREEFORM";
+
+ /** The default macro file token. */
+ public static final String DEFAULT_MACRO_FILE_TAG = "#MACROFILE:";
+
+ // @formatter:off
+ private String defaultConceptVersion = DEFAULT_CONCEPT_VERSION;
+ private String defaultEventNamespace = DEFAULT_EVENT_NAMESPACE;
+ private String defaultEventSource = DEFAULT_EVENT_SOURCE;
+ private String defaultEventTarget = DEFAULT_EVENT_TARGET;
+ private String defaultLogicBlockStartTag = DEFAULT_LOGIC_BLOCK_START_TAG;
+ private String defaultLogicBlockEndTag = DEFAULT_LOGIC_BLOCK_END_TAG;
+ private String defaultPolicyTemplate = DEFAULT_POLICY_TEMPLATE;
+ private String defaultMacroFileTag = DEFAULT_MACRO_FILE_TAG;
+ // @formatter:on
+
+ /**
+ * Gets the default property values for the Apex CLI editor.
+ *
+ * @return the default properties
+ */
+ public Properties getProperties() {
+ final Properties properties = new Properties();
+ // @formatter:off
+ properties.setProperty("DEFAULT_CONCEPT_VERSION", defaultConceptVersion);
+ properties.setProperty("DEFAULT_EVENT_NAMESPACE", defaultEventNamespace);
+ properties.setProperty("DEFAULT_EVENT_SOURCE", defaultEventSource);
+ properties.setProperty("DEFAULT_EVENT_TARGET", defaultEventTarget);
+ properties.setProperty("DEFAULT_LOGIC_BLOCK_START_TAG", defaultLogicBlockStartTag);
+ properties.setProperty("DEFAULT_LOGIC_BLOCK_END_TAG", defaultLogicBlockEndTag);
+ properties.setProperty("DEFAULT_MACRO_FILE_TAG", defaultMacroFileTag);
+ // @formatter:on
+ return properties;
+ }
+
+ /**
+ * Gets the default concept version.
+ *
+ * @return the default concept version
+ */
+ public String getDefaultConceptVersion() {
+ return defaultConceptVersion;
+ }
+
+ /**
+ * Sets the default concept version.
+ *
+ * @param defaultConceptVersion the default concept version
+ */
+ public void setDefaultConceptVersion(final String defaultConceptVersion) {
+ this.defaultConceptVersion = defaultConceptVersion;
+ }
+
+ /**
+ * Gets the default event namespace.
+ *
+ * @return the default event namespace
+ */
+ public String getDefaultEventNamespace() {
+ return defaultEventNamespace;
+ }
+
+ /**
+ * Sets the default event namespace.
+ *
+ * @param defaultEventNamespace the default event namespace
+ */
+ public void setDefaultEventNamespace(final String defaultEventNamespace) {
+ this.defaultEventNamespace = defaultEventNamespace;
+ }
+
+ /**
+ * Gets the default event source.
+ *
+ * @return the default event source
+ */
+ public String getDefaultEventSource() {
+ return defaultEventSource;
+ }
+
+ /**
+ * Sets the default event source.
+ *
+ * @param defaultEventSource the default event source
+ */
+ public void setDefaultEventSource(final String defaultEventSource) {
+ this.defaultEventSource = defaultEventSource;
+ }
+
+ /**
+ * Gets the default event target.
+ *
+ * @return the default event target
+ */
+ public String getDefaultEventTarget() {
+ return defaultEventTarget;
+ }
+
+ /**
+ * Sets the default event target.
+ *
+ * @param defaultEventTarget the default event target
+ */
+ public void setDefaultEventTarget(final String defaultEventTarget) {
+ this.defaultEventTarget = defaultEventTarget;
+ }
+
+ /**
+ * Gets the default logic block start tag.
+ *
+ * @return the default logic block start tag
+ */
+ public String getDefaultLogicBlockStartTag() {
+ return defaultLogicBlockStartTag;
+ }
+
+ /**
+ * Gets the default logic block end tag.
+ *
+ * @return the default logic block end tag
+ */
+ public String getDefaultLogicBlockEndTag() {
+ return defaultLogicBlockEndTag;
+ }
+
+ /**
+ * Gets the default policy template type.
+ *
+ * @return the default policy template
+ */
+ public String getDefaultPolicyTemplate() {
+ return defaultPolicyTemplate;
+ }
+
+ /**
+ * Sets the default policy template type.
+ *
+ * @param defaultPolicyTemplate the new default policy template
+ */
+ public void setDefaultPolicyTemplate(final String defaultPolicyTemplate) {
+ this.defaultPolicyTemplate = defaultPolicyTemplate;
+ }
+
+ /**
+ * Gets the default macro file tag.
+ *
+ * @return the default macro file end tag
+ */
+ public String getDefaultMacroFileTag() {
+ return defaultMacroFileTag;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see java.lang.Object#toString()
+ */
+ @Override
+ public String toString() {
+ return "ApexModelProperties [defaultConceptVersion=" + defaultConceptVersion + ", defaultEventNamespace="
+ + defaultEventNamespace + ", defaultEventSource=" + defaultEventSource + ", defaultEventTarget="
+ + defaultEventTarget + ", defaultLogicBlockStartTag=" + defaultLogicBlockStartTag
+ + ", defaultLogicBlockEndTag=" + defaultLogicBlockEndTag + ", defaultPolicyTemplate="
+ + defaultPolicyTemplate + ", defaultMacroFileTag=" + defaultMacroFileTag + "]";
+ }
+}
diff --git a/auth/cli-editor/src/main/java/org/onap/policy/apex/auth/clieditor/CLIArgument.java b/auth/cli-editor/src/main/java/org/onap/policy/apex/auth/clieditor/CLIArgument.java
new file mode 100644
index 000000000..b215f69e4
--- /dev/null
+++ b/auth/cli-editor/src/main/java/org/onap/policy/apex/auth/clieditor/CLIArgument.java
@@ -0,0 +1,144 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * Copyright (C) 2016-2018 Ericsson. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.policy.apex.auth.clieditor;
+
+import org.onap.policy.apex.model.utilities.Assertions;
+
+/**
+ * This class holds the definition of an argument of a CLI command.
+ *
+ * @author Liam Fallon (liam.fallon@ericsson.com)
+ */
+public class CLIArgument implements Comparable<CLIArgument> {
+ private final String argumentName;
+ private final boolean nullable;
+ private final String description;
+
+ /**
+ * This Constructor constructs a non nullable command line argument with a blank name and
+ * description.
+ */
+ public CLIArgument() {
+ this("", false, "");
+ }
+
+ /**
+ * This Constructor constructs a non nullable command line argument with the given name and
+ * description.
+ *
+ * @param incomingArgumentName the argument name
+ */
+ public CLIArgument(final String incomingArgumentName) {
+ this(incomingArgumentName, false, "");
+ }
+
+ /**
+ * This Constructor constructs a command line argument with the given name, nullability, and
+ * description.
+ *
+ * @param argumentName the argument name
+ * @param nullable the nullable
+ * @param description the description
+ */
+ public CLIArgument(final String argumentName, final boolean nullable, final String description) {
+ this.argumentName = argumentName;
+ this.nullable = nullable;
+ this.description = description;
+ }
+
+ /**
+ * Gets the argument name.
+ *
+ * @return the argument name
+ */
+ public String getArgumentName() {
+ return argumentName;
+ }
+
+ /**
+ * Checks if the argument is nullable.
+ *
+ * @return true, if checks if the argument is nullable
+ */
+ public boolean isNullable() {
+ return nullable;
+ }
+
+ /**
+ * Gets the argument description.
+ *
+ * @return the argument description
+ */
+ public String getDescription() {
+ return description;
+ }
+
+ /**
+ * Gets the argument help.
+ *
+ * @return the argument help
+ */
+ public String getHelp() {
+ final StringBuilder builder = new StringBuilder();
+ builder.append(argumentName);
+ builder.append(nullable ? ": (O) " : ": (M) ");
+ builder.append(description);
+ return builder.toString();
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see java.lang.Object#toString()
+ */
+ @Override
+ public String toString() {
+ return "CLIArgument [argumentName=" + argumentName + ", nullable=" + nullable + ", description=" + description
+ + "]";
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see java.lang.Comparable#compareTo(java.lang.Object)
+ */
+ @Override
+ public int compareTo(final CLIArgument otherArgument) {
+ Assertions.argumentNotNull(otherArgument, "comparison object may not be null");
+
+ if (this == otherArgument) {
+ return 0;
+ }
+ if (getClass() != otherArgument.getClass()) {
+ return this.hashCode() - otherArgument.hashCode();
+ }
+
+ final CLIArgument other = otherArgument;
+
+ if (!argumentName.equals(other.argumentName)) {
+ return argumentName.compareTo(other.argumentName);
+ }
+ if (nullable != other.nullable) {
+ return (this.hashCode() - other.hashCode());
+ }
+ return description.compareTo(otherArgument.description);
+ }
+}
diff --git a/auth/cli-editor/src/main/java/org/onap/policy/apex/auth/clieditor/CLIArgumentValue.java b/auth/cli-editor/src/main/java/org/onap/policy/apex/auth/clieditor/CLIArgumentValue.java
new file mode 100644
index 000000000..d87a8dc5b
--- /dev/null
+++ b/auth/cli-editor/src/main/java/org/onap/policy/apex/auth/clieditor/CLIArgumentValue.java
@@ -0,0 +1,91 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * Copyright (C) 2016-2018 Ericsson. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.policy.apex.auth.clieditor;
+
+/**
+ * This class represents an argument used on a command and its value.
+ *
+ * @author Liam Fallon (liam.fallon@ericsson.com)
+ */
+public class CLIArgumentValue {
+ private final CLIArgument cliArgument;
+ private boolean specified;
+ private String value;
+
+ /**
+ * The Constructor creates an argument value for the given argument, has not been set, and has
+ * no value.
+ *
+ * @param cliArgument the argument for which this object is a value
+ */
+ public CLIArgumentValue(final CLIArgument cliArgument) {
+ this.cliArgument = cliArgument;
+ specified = false;
+ value = null;
+ }
+
+ /**
+ * Gets the argument for which this object is a value.
+ *
+ * @return the argument for which this object is a value
+ */
+ public CLIArgument getCliArgument() {
+ return cliArgument;
+ }
+
+ /**
+ * Checks if the argument value is specified.
+ *
+ * @return true, if the argument value is specified
+ */
+ public boolean isSpecified() {
+ return specified;
+ }
+
+ /**
+ * Gets the argument value.
+ *
+ * @return the argument value
+ */
+ public String getValue() {
+ return value;
+ }
+
+ /**
+ * Sets the argument value.
+ *
+ * @param value the argument value
+ */
+ public void setValue(final String value) {
+ this.value = value;
+ specified = true;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see java.lang.Object#toString()
+ */
+ @Override
+ public String toString() {
+ return "CLIArgumentValue [cliArgument=" + cliArgument + ", specified=" + specified + ", value=" + value + "]";
+ }
+}
diff --git a/auth/cli-editor/src/main/java/org/onap/policy/apex/auth/clieditor/CLICommand.java b/auth/cli-editor/src/main/java/org/onap/policy/apex/auth/clieditor/CLICommand.java
new file mode 100644
index 000000000..74f4a6f92
--- /dev/null
+++ b/auth/cli-editor/src/main/java/org/onap/policy/apex/auth/clieditor/CLICommand.java
@@ -0,0 +1,240 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * Copyright (C) 2016-2018 Ericsson. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.policy.apex.auth.clieditor;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.onap.policy.apex.model.utilities.Assertions;
+
+/**
+ * This class represents a single Apex CLI command that is issued to the Apex Editor Java API
+ * {@link com.ericsson.apex.model.modelapi.ApexEditorAPI}.
+ *
+ * @author Liam Fallon (liam.fallon@ericsson.com)
+ */
+public class CLICommand implements Comparable<CLICommand> {
+ private String name = "";
+ private final List<String> keywordlist = new ArrayList<>();
+ private final List<CLIArgument> argumentList = new ArrayList<>();
+ private String apiMethod = "";
+ private boolean systemCommand = false;
+ private String description = "";
+
+ /**
+ * Gets the class name of the class that executes this command in the Java API.
+ *
+ * @return the class name of the class that executes this command in the Java API
+ */
+ public String getAPIClassName() {
+ final int lastDotPos = apiMethod.lastIndexOf('.');
+ if (lastDotPos == -1) {
+ throw new CLIException("invalid API method name specified on command \"" + name
+ + "\", class name not found: " + apiMethod);
+ }
+ return apiMethod.substring(0, lastDotPos);
+ }
+
+ /**
+ * Gets the method name of the method that executes this command in the Java API.
+ *
+ * @return the the method name of the method that executes this command in the Java API
+ */
+ public String getAPIMethodName() {
+ final int lastDotPos = apiMethod.lastIndexOf('.');
+ if (lastDotPos == -1) {
+ throw new CLIException("invalid API method name specified on command \"" + name
+ + "\", class name not found: " + apiMethod);
+ }
+ if (lastDotPos == apiMethod.length() - 1) {
+ throw new CLIException("no API method name specified on command \"" + name + "\": " + apiMethod);
+ }
+ return apiMethod.substring(lastDotPos + 1);
+ }
+
+ /**
+ * Gets the name of the editor command.
+ *
+ * @return the name of the editor command
+ */
+ public String getName() {
+ return name;
+ }
+
+ /**
+ * Sets the name of the editor command.
+ *
+ * @param name the name of the editor command
+ */
+ public void setName(final String name) {
+ this.name = name;
+ }
+
+ /**
+ * Gets the list of keywords for this command.
+ *
+ * @return the list of keywords for this command
+ */
+ public List<String> getKeywordlist() {
+ return keywordlist;
+ }
+
+ /**
+ * Gets the list of arguments for this command.
+ *
+ * @return the list of arguments for this command
+ */
+ public List<CLIArgument> getArgumentList() {
+ return argumentList;
+ }
+
+ /**
+ * Gets the method of the method that executes this command in the Java API.
+ *
+ * @return the method of the method that executes this command in the Java API
+ */
+ public String getApiMethod() {
+ return apiMethod;
+ }
+
+ /**
+ * Sets the method of the method that executes this command in the Java API.
+ *
+ * @param apiMethod the method of the method that executes this command in the Java API
+ */
+ public void setApiMethod(final String apiMethod) {
+ this.apiMethod = apiMethod;
+ }
+
+ /**
+ * Gets the description of the command.
+ *
+ * @return the description of the command
+ */
+ public String getDescription() {
+ return description;
+ }
+
+ /**
+ * Sets the description of the command.
+ *
+ * @param description the description of the command
+ */
+ public void setDescription(final String description) {
+ this.description = description;
+ }
+
+ /**
+ * Checks if this command is a system command.
+ *
+ * @return true, if this command is a system command
+ */
+ public boolean isSystemCommand() {
+ return systemCommand;
+ }
+
+ /**
+ * Sets whether this command is a system command.
+ *
+ * @param systemCommand whether this command is a system command
+ */
+ public void setSystemCommand(final boolean systemCommand) {
+ this.systemCommand = systemCommand;
+ }
+
+ /**
+ * Gets help for this command.
+ *
+ * @return the help for this command
+ */
+ public String getHelp() {
+ final StringBuilder builder = new StringBuilder();
+ for (final String keyword : keywordlist) {
+ builder.append(keyword);
+ builder.append(' ');
+ }
+ builder.append('{');
+ builder.append(name);
+ builder.append("}: ");
+ builder.append(description);
+
+ for (final CLIArgument argument : argumentList) {
+ if (argument == null) {
+ continue;
+ }
+ builder.append("\n\t");
+ builder.append(argument.getHelp());
+ }
+ return builder.toString();
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see java.lang.Object#toString()
+ */
+ @Override
+ public String toString() {
+ return "CLICommand [name=" + name + ",keywordlist=" + keywordlist + ", argumentList=" + argumentList
+ + ", apiMethod=" + apiMethod + ", systemCommand=" + systemCommand + ", description=" + description
+ + "]";
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see java.lang.Comparable#compareTo(java.lang.Object)
+ */
+ @Override
+ public int compareTo(final CLICommand otherCommand) {
+ Assertions.argumentNotNull(otherCommand, "comparison object may not be null");
+
+ if (this == otherCommand) {
+ return 0;
+ }
+ if (getClass() != otherCommand.getClass()) {
+ return this.hashCode() - otherCommand.hashCode();
+ }
+
+ final CLICommand other = otherCommand;
+
+ for (int i = 0, j = 0;; i++, j++) {
+ if (i < keywordlist.size() && j < otherCommand.keywordlist.size()) {
+ if (!keywordlist.get(i).equals(other.keywordlist.get(j))) {
+ return keywordlist.get(i).compareTo(other.keywordlist.get(j));
+ }
+ } else if (i == keywordlist.size() && j == otherCommand.keywordlist.size()) {
+ break;
+ } else if (i == keywordlist.size()) {
+ return -1;
+ } else {
+ return 1;
+ }
+ }
+ if (!argumentList.equals(other.argumentList)) {
+ return (argumentList.hashCode() - other.argumentList.hashCode());
+ }
+ if (systemCommand != other.systemCommand) {
+ return (this.hashCode() - other.hashCode());
+ }
+ return apiMethod.compareTo(other.apiMethod);
+ }
+}
diff --git a/auth/cli-editor/src/main/java/org/onap/policy/apex/auth/clieditor/CLICommands.java b/auth/cli-editor/src/main/java/org/onap/policy/apex/auth/clieditor/CLICommands.java
new file mode 100644
index 000000000..4c9bab045
--- /dev/null
+++ b/auth/cli-editor/src/main/java/org/onap/policy/apex/auth/clieditor/CLICommands.java
@@ -0,0 +1,42 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * Copyright (C) 2016-2018 Ericsson. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.policy.apex.auth.clieditor;
+
+import java.util.Set;
+import java.util.TreeSet;
+
+/**
+ * This class contains the CLI commands read in from a JSON file.
+ *
+ * @author Liam Fallon (liam.fallon@ericsson.com)
+ */
+public class CLICommands {
+ private final Set<CLICommand> commandList = new TreeSet<>();
+
+ /**
+ * Gets the command set.
+ *
+ * @return the command set
+ */
+ public Set<CLICommand> getCommandSet() {
+ return commandList;
+ }
+}
diff --git a/auth/cli-editor/src/main/java/org/onap/policy/apex/auth/clieditor/CLIEditorLoop.java b/auth/cli-editor/src/main/java/org/onap/policy/apex/auth/clieditor/CLIEditorLoop.java
new file mode 100644
index 000000000..560648901
--- /dev/null
+++ b/auth/cli-editor/src/main/java/org/onap/policy/apex/auth/clieditor/CLIEditorLoop.java
@@ -0,0 +1,543 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * Copyright (C) 2016-2018 Ericsson. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.policy.apex.auth.clieditor;
+
+import java.io.BufferedReader;
+import java.io.File;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+import java.io.OutputStream;
+import java.io.OutputStreamWriter;
+import java.io.PrintWriter;
+import java.util.AbstractMap.SimpleEntry;
+import java.util.ArrayDeque;
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map.Entry;
+import java.util.Properties;
+import java.util.TreeMap;
+
+import org.onap.policy.apex.model.modelapi.ApexAPIResult;
+import org.onap.policy.apex.model.modelapi.ApexAPIResult.RESULT;
+import org.onap.policy.apex.model.utilities.TextFileUtils;
+import org.onap.policy.apex.model.utilities.TreeMapUtils;
+
+/**
+ * This class implements the editor loop, the loop of execution that continuously executes commands
+ * until the quit command is issued or EOF is detected on input.
+ *
+ * @author Liam Fallon (liam.fallon@ericsson.com)
+ */
+public class CLIEditorLoop {
+ // The model handler that is handling the API towards the Apex model being editied
+ private final ApexModelHandler modelHandler;
+
+ // Holds the current location in the keyword hierarchy
+ private final ArrayDeque<KeywordNode> keywordNodeDeque = new ArrayDeque<>();
+
+ // Logic block tags
+ private final String logicBlockStartTag;
+ private final String logicBlockEndTag;
+
+ // File Macro tag
+ private final String macroFileTag;
+
+ /**
+ * Initiate the loop with the keyword node tree.
+ *
+ * @param properties The CLI editor properties defined for execution
+ * @param modelHandler the model handler that will handle commands
+ * @param rootKeywordNode The root keyword node tree
+ */
+ public CLIEditorLoop(final Properties properties, final ApexModelHandler modelHandler,
+ final KeywordNode rootKeywordNode) {
+ this.modelHandler = modelHandler;
+ keywordNodeDeque.push(rootKeywordNode);
+
+ logicBlockStartTag = properties.getProperty("DEFAULT_LOGIC_BLOCK_START_TAG");
+ logicBlockEndTag = properties.getProperty("DEFAULT_LOGIC_BLOCK_END_TAG");
+ macroFileTag = properties.getProperty("DEFAULT_MACRO_FILE_TAG");
+ }
+
+ /**
+ * Run a command loop.
+ *
+ * @param inputStream The stream to read commands from
+ * @param outputStream The stream to write command output and messages to
+ * @param parameters The parameters for the CLI editor
+ * @return the exit code from command processing
+ * @throws IOException Thrown on exceptions on IO
+ */
+ public int runLoop(final InputStream inputStream, final OutputStream outputStream, final CLIParameters parameters)
+ throws IOException {
+ // Readers and writers for input and output
+ final BufferedReader reader = new BufferedReader(new InputStreamReader(inputStream));
+ final PrintWriter writer = new PrintWriter(new OutputStreamWriter(outputStream));
+
+ // The parser parses the input lines into commands and arguments
+ final CLILineParser parser = new CLILineParser();
+
+ // The main loop for command handing, it continues until EOF on the input stream or until a
+ // quit command
+ int errorCount = 0;
+ ApexAPIResult result = new ApexAPIResult();
+ while (result.getResult() != RESULT.FINISHED) {
+ if (!parameters.isIgnoreCommandFailures() && errorCount > 0) {
+ break;
+ }
+
+ // Output prompt and get a line of input
+ writer.print(getPrompt());
+ writer.flush();
+ String line = reader.readLine();
+ if (line == null) {
+ break;
+ }
+
+ // Expand any macros in the script
+ try {
+ while (line.contains(macroFileTag)) {
+ line = expandMacroFile(parameters, line);
+ }
+ }
+ // Print any error messages from command parsing and finding
+ catch (final CLIException e) {
+ writer.println(e.getMessage());
+ errorCount++;
+ continue;
+ }
+
+ if (parameters.isEchoSet()) {
+ writer.println(line);
+ }
+
+ String logicBlock = null;
+ if (line.trim().endsWith(logicBlockStartTag)) {
+ line = line.replace(logicBlockStartTag, "").trim();
+
+ logicBlock = "";
+ while (true) {
+ String logicLine = reader.readLine();
+ if (logicLine == null) {
+ logicBlock = null;
+ break;
+ }
+
+ try {
+ while (logicLine.contains(macroFileTag)) {
+ logicLine = expandMacroFile(parameters, logicLine);
+ }
+ }
+ // Print any error messages from command parsing and finding
+ catch (final CLIException e) {
+ writer.println(e.getMessage());
+ errorCount++;
+ continue;
+ }
+
+ if (parameters.isEchoSet()) {
+ writer.println(logicLine);
+ }
+
+ if (logicLine.trim().endsWith(logicBlockEndTag)) {
+ logicBlock += logicLine.replace(logicBlockEndTag, "").trim() + "\n";
+ break;
+ } else {
+ logicBlock += logicLine + "\n";
+ }
+ }
+ }
+
+ try {
+ // Parse the line into a list of commands and arguments
+ final ArrayList<String> commandWords = parser.parse(line, logicBlock);
+
+ // Find the command, if the command is null, then we are simply changing position in
+ // the hierarchy
+ final CLICommand command = findCommand(commandWords);
+ if (command != null) {
+ // Check the arguments of the command
+ final TreeMap<String, CLIArgumentValue> argumentValues = getArgumentValues(command, commandWords);
+
+ // Execute the command, a FINISHED result means a command causes the loop to
+ // leave execution
+ result = executeCommand(command, argumentValues, writer);
+ if (result.isNOK()) {
+ errorCount++;
+ }
+ }
+ }
+ // Print any error messages from command parsing and finding
+ catch (final CLIException e) {
+ writer.println(e.getMessage());
+ errorCount++;
+ } catch (final Exception e) {
+ e.printStackTrace(writer);
+ }
+ }
+
+ // Get the output model
+ if (!parameters.isSuppressModelOutputSet()) {
+ final String modelString = modelHandler.writeModelToString(writer);
+
+ if (parameters.checkSetOutputModelFileName()) {
+ TextFileUtils.putStringAsTextFile(modelString, parameters.getOutputModelFileName());
+ } else {
+ System.out.println(modelString);
+ }
+ }
+
+ reader.close();
+ writer.close();
+
+ return errorCount;
+ }
+
+ /**
+ * Output a prompt that indicates where in the keyword hierarchy we are.
+ *
+ * @return A string with the prompt
+ */
+ private String getPrompt() {
+ final StringBuilder builder = new StringBuilder();
+ final Iterator<KeywordNode> keynodeDequeIter = keywordNodeDeque.descendingIterator();
+
+ while (keynodeDequeIter.hasNext()) {
+ builder.append('/');
+ builder.append(keynodeDequeIter.next().getKeyword());
+ }
+ builder.append("> ");
+
+ return builder.toString();
+ }
+
+ /**
+ * Finds a command for the given input command words. Command words need only ne specified
+ * enough to uniquely identify them. Therefore, "p s o c" will find the command "policy state
+ * output create"
+ *
+ * @param commandWords The commands and arguments parsed from the command line by the parser
+ * @return The found command
+ */
+
+ private CLICommand findCommand(final ArrayList<String> commandWords) {
+ CLICommand command = null;
+
+ final KeywordNode startKeywordNode = keywordNodeDeque.peek();
+
+ // Go down through the keywords searching for the command
+ for (int i = 0; i < commandWords.size(); i++) {
+ final KeywordNode searchKeywordNode = keywordNodeDeque.peek();
+
+ // We have got to the arguments, time to stop looking
+ if (commandWords.get(i).indexOf('=') > 0) {
+ unwindStack(startKeywordNode);
+ throw new CLIException("command not found: " + stringAL2String(commandWords));
+ }
+
+ // If the node entries found is not equal to one, then we have either no command or more
+ // than one command matching
+ final List<Entry<String, KeywordNode>> foundNodeEntries =
+ TreeMapUtils.findMatchingEntries(searchKeywordNode.getChildren(), commandWords.get(i));
+ if (foundNodeEntries.size() == 0) {
+ unwindStack(startKeywordNode);
+ throw new CLIException("command not found: " + stringAL2String(commandWords));
+ } else if (foundNodeEntries.size() > 1) {
+ unwindStack(startKeywordNode);
+ throw new CLIException("multiple commands matched: " + stringAL2String(commandWords) + " ["
+ + nodeAL2String(foundNodeEntries) + ']');
+ }
+
+ // Record the fully expanded command word
+ commandWords.set(i, foundNodeEntries.get(0).getKey());
+
+ // Check if there is a command
+ final KeywordNode childKeywordNode = foundNodeEntries.get(0).getValue();
+ command = childKeywordNode.getCommand();
+
+ // If the command is null, we go into a sub mode, otherwise we unwind the stack of
+ // commands and return the found command
+ if (command == null) {
+ keywordNodeDeque.push(childKeywordNode);
+ } else {
+ unwindStack(startKeywordNode);
+ return command;
+ }
+ }
+
+ return null;
+ }
+
+ /**
+ * Unwind the stack of keyword node entries we have placed on the queue in a command search.
+ *
+ * @param startKeywordNode The point on the queue we want to unwind to
+ */
+ private void unwindStack(final KeywordNode startKeywordNode) {
+ // Unwind the stack
+ while (true) {
+ if (keywordNodeDeque.peek().equals(startKeywordNode)) {
+ return;
+ }
+ keywordNodeDeque.pop();
+ }
+ }
+
+ /**
+ * Check the arguments of the command.
+ *
+ * @param command The command to check
+ * @param commandWords The command words entered
+ * @return the argument values
+ */
+ private TreeMap<String, CLIArgumentValue> getArgumentValues(final CLICommand command,
+ final ArrayList<String> commandWords) {
+ final TreeMap<String, CLIArgumentValue> argumentValues = new TreeMap<>();
+ for (final CLIArgument argument : command.getArgumentList()) {
+ if (argument != null) {
+ argumentValues.put(argument.getArgumentName(), new CLIArgumentValue(argument));
+ }
+ }
+
+ // Set the value of the arguments
+ for (final Entry<String, String> argument : getCommandArguments(commandWords)) {
+ final List<Entry<String, CLIArgumentValue>> foundArguments =
+ TreeMapUtils.findMatchingEntries(argumentValues, argument.getKey());
+ if (foundArguments.size() == 0) {
+ throw new CLIException("command " + stringAL2String(commandWords) + ": " + " argument \""
+ + argument.getKey() + "\" not allowed on command");
+ } else if (foundArguments.size() > 1) {
+ throw new CLIException("command " + stringAL2String(commandWords) + ": " + " argument " + argument
+ + " matches multiple arguments [" + argumentAL2String(foundArguments) + ']');
+ }
+
+ // Set the value of the argument, stripping off any quotes
+ final String argumentValue = argument.getValue().replaceAll("^\"", "").replaceAll("\"$", "");
+ foundArguments.get(0).getValue().setValue(argumentValue);
+ }
+
+ // Now check all mandatory arguments are set
+ for (final CLIArgumentValue argumentValue : argumentValues.values()) {
+ if (!argumentValue.isSpecified()) {
+ // Argument values are null by default so if this argument is not nullable it is
+ // mandatory
+ if (!argumentValue.getCliArgument().isNullable()) {
+ throw new CLIException("command " + stringAL2String(commandWords) + ": " + " mandatory argument \""
+ + argumentValue.getCliArgument().getArgumentName() + "\" not specified");
+ }
+ }
+ }
+
+ return argumentValues;
+ }
+
+ /**
+ * Get the arguments of the command, the command words have already been conditioned into an
+ * array starting with the command words and ending with the arguments as name=value tuples.
+ *
+ * @param commandWords The command words entered by the user
+ * @return the arguments as an entry array list
+ */
+ private ArrayList<Entry<String, String>> getCommandArguments(final ArrayList<String> commandWords) {
+ final ArrayList<Entry<String, String>> arguments = new ArrayList<>();
+
+ // Iterate over the command words, arguments are of the format name=value
+ for (final String word : commandWords) {
+ final int equalsPos = word.indexOf('=');
+ if (equalsPos > 0) {
+ arguments.add(
+ new SimpleEntry<>(word.substring(0, equalsPos), word.substring(equalsPos + 1, word.length())));
+ }
+ }
+
+ return arguments;
+ }
+
+ /**
+ * Execute system and editor commands.
+ *
+ * @param command The command to execute
+ * @param argumentValues The arguments input on the command line to invoke the command
+ * @param writer The writer to use for any output from the command
+ * @return the result of execution of the command
+ */
+ private ApexAPIResult executeCommand(final CLICommand command,
+ final TreeMap<String, CLIArgumentValue> argumentValues, final PrintWriter writer) {
+ if (command.isSystemCommand()) {
+ return exceuteSystemCommand(command, writer);
+ } else {
+ return modelHandler.executeCommand(command, argumentValues, writer);
+ }
+ }
+
+ /**
+ * Execute system commands.
+ *
+ * @param command The command to execute
+ * @param writer The writer to use for any output from the command
+ * @return the result of execution of the command
+ */
+ private ApexAPIResult exceuteSystemCommand(final CLICommand command, final PrintWriter writer) {
+ if (command.getName().equals("back")) {
+ return executeBackCommand();
+ } else if (command.getName().equals("help")) {
+ return executeHelpCommand(writer);
+ } else if (command.getName().equals("quit")) {
+ return executeQuitCommand();
+ } else {
+ return new ApexAPIResult(RESULT.SUCCESS);
+ }
+ }
+
+ /**
+ * Execute the "back" command.
+ *
+ * @return the result of execution of the command
+ */
+ private ApexAPIResult executeBackCommand() {
+ if (keywordNodeDeque.size() > 1) {
+ keywordNodeDeque.pop();
+ }
+ return new ApexAPIResult(RESULT.SUCCESS);
+ }
+
+ /**
+ * Execute the "quit" command.
+ *
+ * @return the result of execution of the command
+ */
+ private ApexAPIResult executeQuitCommand() {
+ return new ApexAPIResult(RESULT.FINISHED);
+ }
+
+ /**
+ * Execute the "help" command.
+ *
+ * @param writer The writer to use for output from the command
+ * @return the result of execution of the command
+ */
+ private ApexAPIResult executeHelpCommand(final PrintWriter writer) {
+ for (final CLICommand command : keywordNodeDeque.peek().getCommands()) {
+ writer.println(command.getHelp());
+ }
+ return new ApexAPIResult(RESULT.SUCCESS);
+ }
+
+ /**
+ * Helper method to output an array list of keyword node entries to a string.
+ *
+ * @param nodeEntryArrayList the array list of keyword node entries
+ * @return the string
+ */
+ private String nodeAL2String(final List<Entry<String, KeywordNode>> nodeEntryArrayList) {
+ final ArrayList<String> stringArrayList = new ArrayList<>();
+ for (final Entry<String, KeywordNode> node : nodeEntryArrayList) {
+ stringArrayList.add(node.getValue().getKeyword());
+ }
+
+ return stringAL2String(stringArrayList);
+ }
+
+ /**
+ * Helper method to output an array list of argument entries to a string.
+ *
+ * @param argumentArrayList the argument array list
+ * @return the string
+ */
+ private String argumentAL2String(final List<Entry<String, CLIArgumentValue>> argumentArrayList) {
+ final ArrayList<String> stringArrayList = new ArrayList<>();
+ for (final Entry<String, CLIArgumentValue> argument : argumentArrayList) {
+ stringArrayList.add(argument.getValue().getCliArgument().getArgumentName());
+ }
+
+ return stringAL2String(stringArrayList);
+ }
+
+ /**
+ * Helper method to output an array list of strings to a string.
+ *
+ * @param stringArrayList the array list of strings
+ * @return the string
+ */
+ private String stringAL2String(final List<String> stringArrayList) {
+ final StringBuilder builder = new StringBuilder();
+ boolean first = true;
+ for (final String word : stringArrayList) {
+ if (first) {
+ first = false;
+ } else {
+ builder.append(',');
+ }
+ builder.append(word);
+ }
+
+ return builder.toString();
+ }
+
+ /**
+ * This method reads in the file from a file macro statement, expands the macro, and replaces
+ * the Macro tag in the line with the file contents.
+ *
+ * @param parameters The parameters for the CLI editor
+ * @param line The line with the macro keyword in it
+ * @return the expanded line
+ */
+ private String expandMacroFile(final CLIParameters parameters, final String line) {
+ final int macroTagPos = line.indexOf(macroFileTag);
+
+ // Get the line before and after the macro tag
+ final String lineBeforeMacroTag = line.substring(0, macroTagPos);
+ final String lineAfterMacroTag = line.substring(macroTagPos + macroFileTag.length()).replaceAll("^\\s*", "");
+
+ // Get the file name that is the argument of the Macro tag
+ final String[] lineWords = lineAfterMacroTag.split("\\s+");
+
+ if (lineWords.length == 0) {
+ throw new CLIException("no file name specified for Macro File Tag");
+ }
+
+ // Get the macro file name and the remainder of the line after the file name
+ String macroFileName = lineWords[0];
+ final String lineAfterMacroFileName = lineAfterMacroTag.replaceFirst(macroFileName, "");
+
+ if (macroFileName.length() > 2 && macroFileName.startsWith("\"") && macroFileName.endsWith("\"")) {
+ macroFileName = macroFileName.substring(1, macroFileName.length() - 1);
+ } else {
+ throw new CLIException(
+ "macro file name \"" + macroFileName + "\" must exist and be quoted with double quotes \"\"");
+ }
+
+ // Append the working directory to the macro file name
+ macroFileName = parameters.getWorkingDirectory() + File.separatorChar + macroFileName;
+
+ // Now, get the text file for the argument of the macro
+ String macroFileContents = null;
+ try {
+ macroFileContents = TextFileUtils.getTextFileAsString(macroFileName);
+ } catch (final IOException e) {
+ throw new CLIException("file \"" + macroFileName + "\" specified in Macro File Tag not found", e);
+ }
+
+ return lineBeforeMacroTag + macroFileContents + lineAfterMacroFileName;
+ }
+}
diff --git a/auth/cli-editor/src/main/java/org/onap/policy/apex/auth/clieditor/CLIException.java b/auth/cli-editor/src/main/java/org/onap/policy/apex/auth/clieditor/CLIException.java
new file mode 100644
index 000000000..8e1104c3b
--- /dev/null
+++ b/auth/cli-editor/src/main/java/org/onap/policy/apex/auth/clieditor/CLIException.java
@@ -0,0 +1,49 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * Copyright (C) 2016-2018 Ericsson. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.policy.apex.auth.clieditor;
+
+/**
+ * A run time exception used to report parsing and command input errors.
+ *
+ * @author Liam Fallon (liam.fallon@ericsson.com)
+ */
+public class CLIException extends IllegalArgumentException {
+ private static final long serialVersionUID = 6520231162404452427L;
+
+ /**
+ * Create a CLIException with a message.
+ *
+ * @param message the message
+ */
+ public CLIException(final String message) {
+ super(message);
+ }
+
+ /**
+ * Create a CLIException with a message and an exception.
+ *
+ * @param message the message
+ * @param t the t
+ */
+ public CLIException(final String message, final Throwable t) {
+ super(message, t);
+ }
+}
diff --git a/auth/cli-editor/src/main/java/org/onap/policy/apex/auth/clieditor/CLILineParser.java b/auth/cli-editor/src/main/java/org/onap/policy/apex/auth/clieditor/CLILineParser.java
new file mode 100644
index 000000000..fd4541f28
--- /dev/null
+++ b/auth/cli-editor/src/main/java/org/onap/policy/apex/auth/clieditor/CLILineParser.java
@@ -0,0 +1,321 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * Copyright (C) 2016-2018 Ericsson. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.policy.apex.auth.clieditor;
+
+import java.util.ArrayList;
+
+/**
+ * This class chops a command line up into commands, parameters and arguments.
+ *
+ * @author Liam Fallon (liam.fallon@ericsson.com)
+ */
+public class CLILineParser {
+
+ /**
+ * This method breaks a line of input up into commands, parameters, and arguments. Commands are
+ * standalone words at the beginning of the line, of which there may be multiple Parameters are
+ * single words followed by an '=' character Arguments are single words or a block of quoted
+ * text following an '=' character.
+ *
+ * Format: command [command....] parameter=argument [parameter = argument]
+ *
+ * Examples entity create name=hello description="description of hello" help entity list
+ *
+ * @param line The line to parse
+ * @param logicBlock A block of logic code to be taken literally
+ * @return the string array list
+ */
+ public ArrayList<String> parse(final String line, final String logicBlock) {
+ return checkFormat(
+ mergeArguments(mergeEquals(
+ splitOnEquals(stripAndSplitWords(mergeQuotes(splitOnChar(stripComments(line), '\"')))))),
+ logicBlock);
+ }
+
+ /**
+ * Strip comments from lines, comments start with a # character.
+ *
+ * @param line the line
+ * @return the line without comments
+ */
+ private String stripComments(final String line) {
+ final int commentPos = line.indexOf('#');
+ if (commentPos == -1) {
+ return line;
+ } else {
+ return line.substring(0, commentPos);
+ }
+ }
+
+ /**
+ * This method merges an array with separate quotes into an array with quotes delimiting the
+ * start and end of quoted words Example [Humpty ],["],[Dumpty sat on the wall],["],[, Humpty
+ * Dumpty had ],["],["],a ["],[great],["],[ fall] becomes [Humpty ],["Dumpty sat on the
+ * wall"],[, Humpty Dumpty had ],[""],[a],["great"],[ fall].
+ *
+ * @param wordsSplitOnQuotes the words split on quotes
+ * @return the merged array list
+ */
+ private ArrayList<String> mergeQuotes(final ArrayList<String> wordsSplitOnQuotes) {
+ final ArrayList<String> wordsWithQuotesMerged = new ArrayList<>();
+
+ for (int i = 0; i < wordsSplitOnQuotes.size();) {
+ if (wordsSplitOnQuotes.get(i).equals("\"")) {
+ String quotedWord = wordsSplitOnQuotes.get(i++);
+
+ for (; i < wordsSplitOnQuotes.size(); i++) {
+ quotedWord += wordsSplitOnQuotes.get(i);
+ if (wordsSplitOnQuotes.get(i).equals("\"")) {
+ i++;
+ break;
+ }
+ }
+ if (quotedWord.matches("^\".*\"$")) {
+ wordsWithQuotesMerged.add(quotedWord);
+ } else {
+ throw new CLIException("trailing quote found in input " + wordsSplitOnQuotes);
+ }
+ } else {
+ wordsWithQuotesMerged.add(wordsSplitOnQuotes.get(i++));
+ }
+ }
+
+ return wordsWithQuotesMerged;
+ }
+
+ /**
+ * This method splits the words on an array list into an array list where each portion of the
+ * line is split into words by '=', quoted words are ignored Example: aaa = bbb = ccc=ddd=eee =
+ * becomes [aaa ],[=],[bbb ],[=],[ccc],[=],[ddd],[=],[eee ],[=].
+ *
+ * @param words the words
+ * @return the merged array list
+ */
+ private ArrayList<String> splitOnEquals(final ArrayList<String> words) {
+ final ArrayList<String> wordsSplitOnEquals = new ArrayList<>();
+
+ for (final String word : words) {
+ // Is this a quoted word ?
+ if (word.startsWith("\"")) {
+ wordsSplitOnEquals.add(word);
+ continue;
+ }
+
+ // Split on equals character
+ final ArrayList<String> splitWords = splitOnChar(word, '=');
+ for (final String splitWord : splitWords) {
+ wordsSplitOnEquals.add(splitWord);
+ }
+ }
+
+ return wordsSplitOnEquals;
+ }
+
+ /**
+ * This method merges an array with separate equals into an array with equals delimiting the
+ * start of words Example: [aaa ],[=],[bbb ],[=],[ccc],[=],[ddd],[=],[eee ],[=] becomes [aaa
+ * ],[= bbb ],[= ccc],[=ddd],[=eee ],[=].
+ *
+ * @param wordsSplitOnEquals the words split on equals
+ * @return the merged array list
+ */
+ private ArrayList<String> mergeEquals(final ArrayList<String> wordsSplitOnEquals) {
+ final ArrayList<String> wordsWithEqualsMerged = new ArrayList<>();
+
+ for (int i = 0; i < wordsSplitOnEquals.size();) {
+ // Is this a quoted word ?
+ if (wordsSplitOnEquals.get(i).startsWith("\"")) {
+ wordsWithEqualsMerged.add(wordsSplitOnEquals.get(i));
+ continue;
+ }
+
+ if (wordsSplitOnEquals.get(i).equals("=")) {
+ if (i < wordsSplitOnEquals.size() - 1 && !wordsSplitOnEquals.get(i + 1).startsWith("=")) {
+ wordsWithEqualsMerged.add(wordsSplitOnEquals.get(i) + wordsSplitOnEquals.get(i + 1));
+ i += 2;
+ } else {
+ wordsWithEqualsMerged.add(wordsSplitOnEquals.get(i++));
+ }
+ } else {
+ wordsWithEqualsMerged.add(wordsSplitOnEquals.get(i++));
+ }
+ }
+
+ return wordsWithEqualsMerged;
+ }
+
+ /**
+ * This method merges words that start with an '=' character with the previous word if that word
+ * does not start with an '='.
+ *
+ * @param words the words
+ * @return the merged array list
+ */
+ private ArrayList<String> mergeArguments(final ArrayList<String> words) {
+ final ArrayList<String> mergedArguments = new ArrayList<>();
+
+ for (int i = 0; i < words.size(); i++) {
+ // Is this a quoted word ?
+ if (words.get(i).startsWith("\"")) {
+ mergedArguments.add(words.get(i));
+ continue;
+ }
+
+ if (words.get(i).startsWith("=")) {
+ if (i > 0 && !words.get(i - 1).startsWith("=")) {
+ mergedArguments.remove(mergedArguments.size() - 1);
+ mergedArguments.add(words.get(i - 1) + words.get(i));
+ } else {
+ mergedArguments.add(words.get(i));
+ }
+ } else {
+ mergedArguments.add(words.get(i));
+ }
+ }
+
+ return mergedArguments;
+ }
+
+ /**
+ * This method strips all non quoted white space down to single spaces and splits non-quoted
+ * words into separate words.
+ *
+ * @param words the words
+ * @return the array list with white space stripped and words split
+ */
+ private ArrayList<String> stripAndSplitWords(final ArrayList<String> words) {
+ final ArrayList<String> strippedAndSplitWords = new ArrayList<>();
+
+ for (String word : words) {
+ // Is this a quoted word
+ if (word.startsWith("\"")) {
+ strippedAndSplitWords.add(word);
+ continue;
+ }
+
+ // Strip white space by replacing all white space with blanks and then removing leading
+ // and trailing blanks
+ word = word.replaceAll("\\s+", " ").trim();
+
+ if (word.length() == 0) {
+ continue;
+ }
+
+ // Split on space characters
+ final String[] splitWords = word.split(" ");
+ for (final String splitWord : splitWords) {
+ strippedAndSplitWords.add(splitWord);
+ }
+ }
+
+ return strippedAndSplitWords;
+ }
+
+ /**
+ * This method splits a line of text into an array list where each portion of the line is split
+ * into words by a character, with the characters themselves as separate words Example: Humpty
+ * "Dumpty sat on the wall", Humpty Dumpty had ""a "great" fall becomes [Humpty ],["],[Dumpty
+ * sat on the wall],["],[, Humpty Dumpty had ],["],["],a ["],[great],["],[ fall].
+ *
+ * @param line the input line
+ * @param splitChar the split char
+ * @return the split array list
+ */
+ private ArrayList<String> splitOnChar(final String line, final char splitChar) {
+ final ArrayList<String> wordsSplitOnQuotes = new ArrayList<>();
+
+ int currentPos = 0;
+ while (currentPos != -1) {
+ final int quotePos = line.indexOf(splitChar, currentPos);
+ if (quotePos != -1) {
+ if (currentPos < quotePos) {
+ wordsSplitOnQuotes.add(line.substring(currentPos, quotePos));
+ }
+ wordsSplitOnQuotes.add("" + splitChar);
+ currentPos = quotePos + 1;
+
+ if (currentPos == line.length()) {
+ currentPos = -1;
+ }
+ } else {
+ wordsSplitOnQuotes.add(line.substring(currentPos));
+ currentPos = quotePos;
+ }
+ }
+
+ return wordsSplitOnQuotes;
+ }
+
+ /**
+ * This method checks that an array list containing a command is in the correct format.
+ *
+ * @param commandWords the command words
+ * @param logicBlock A block of logic code to be taken literally
+ * @return the checked array list
+ */
+ private ArrayList<String> checkFormat(final ArrayList<String> commandWords, final String logicBlock) {
+ // There should be at least one word
+ if (commandWords.size() == 0) {
+ return commandWords;
+ }
+
+ // The first word must be alphanumeric, that is a command
+ if (!commandWords.get(0).matches("^[a-zA-Z0-9]*$")) {
+ throw new CLIException(
+ "first command word is not alphanumeric or is not a command: " + commandWords.get(0));
+ }
+
+ // Now check that we have a sequence of commands at the beginning
+ int currentWordPos = 0;
+ while (currentWordPos < commandWords.size()) {
+ if (commandWords.get(currentWordPos).matches("^[a-zA-Z0-9]*$")) {
+ currentWordPos++;
+ } else {
+ break;
+ }
+ }
+
+ while (currentWordPos < commandWords.size()) {
+ // From now on we should have a sequence of parameters with arguments delimited by a
+ // single '=' character
+ if (currentWordPos < commandWords.size() - 1 || logicBlock == null) {
+ // No logic block
+ if (commandWords.get(currentWordPos).matches("^[a-zA-Z0-9]+=[a-zA-Z0-9/\"].*$")) {
+ currentWordPos++;
+ } else {
+ throw new CLIException(
+ "command argument is not properly formed: " + commandWords.get(currentWordPos));
+ }
+ } else {
+ // Logic block
+ if (commandWords.get(currentWordPos).matches("^[a-zA-Z0-9]+=")) {
+ commandWords.set(currentWordPos, commandWords.get(currentWordPos) + logicBlock);
+ currentWordPos++;
+ } else {
+ throw new CLIException(
+ "command argument is not properly formed: " + commandWords.get(currentWordPos));
+ }
+ }
+ }
+
+ return commandWords;
+ }
+}
diff --git a/auth/cli-editor/src/main/java/org/onap/policy/apex/auth/clieditor/CLIParameterParser.java b/auth/cli-editor/src/main/java/org/onap/policy/apex/auth/clieditor/CLIParameterParser.java
new file mode 100644
index 000000000..382f23fb0
--- /dev/null
+++ b/auth/cli-editor/src/main/java/org/onap/policy/apex/auth/clieditor/CLIParameterParser.java
@@ -0,0 +1,156 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * Copyright (C) 2016-2018 Ericsson. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.policy.apex.auth.clieditor;
+
+import java.nio.file.Paths;
+import java.util.Arrays;
+
+import org.apache.commons.cli.CommandLine;
+import org.apache.commons.cli.DefaultParser;
+import org.apache.commons.cli.HelpFormatter;
+import org.apache.commons.cli.Option;
+import org.apache.commons.cli.Options;
+import org.apache.commons.cli.ParseException;
+
+/**
+ * This class reads and handles command line parameters to the Apex CLI editor.
+ *
+ * @author Liam Fallon (liam.fallon@ericsson.com)
+ */
+public class CLIParameterParser {
+ private static final int MAX_HELP_LINE_LENGTH = 120;
+
+ // Apache Commons CLI options
+ private final Options options;
+
+ /**
+ * Construct the options for the CLI editor.
+ */
+ public CLIParameterParser() {
+ options = new Options();
+ options.addOption(Option.builder("h").longOpt("help").desc("outputs the usage of this command").required(false)
+ .type(Boolean.class).build());
+ options.addOption(Option.builder("m").longOpt("metadata-file").desc("name of the command metadata file to use")
+ .hasArg().argName("CMD_METADATA_FILE").required(false).type(String.class).build());
+ options.addOption(
+ Option.builder("a").longOpt("model-props-file").desc("name of the apex model properties file to use")
+ .hasArg().argName("MODEL_PROPS_FILE").required(false).type(String.class).build());
+ options.addOption(Option.builder("c").longOpt("command-file")
+ .desc("name of a file containing editor commands to run into the editor").hasArg()
+ .argName("COMMAND_FILE").required(false).type(String.class).build());
+ options.addOption(Option.builder("l").longOpt("log-file")
+ .desc("name of a file that will contain command logs from the editor, will log to standard output if not specified or suppressed with \"-nl\" flag")
+ .hasArg().argName("LOG_FILE").required(false).type(String.class).build());
+ options.addOption(Option.builder("nl").longOpt("no-log")
+ .desc("if specified, no logging or output of commands to standard output or log file is carried out")
+ .required(false).type(Boolean.class).build());
+ options.addOption(Option.builder("nm").longOpt("no-model-output")
+ .desc("if specified, no output of a model to standard output or model output file is carried out, "
+ + "the user can use the \"save\" command in a script to save a model")
+ .required(false).type(Boolean.class).build());
+ options.addOption(Option.builder("i").longOpt("input-model-file")
+ .desc("name of a file that contains an input model for the editor").hasArg().argName("INPUT_MODEL_FILE")
+ .required(false).type(String.class).build());
+ options.addOption(Option.builder("o").longOpt("output-model-file")
+ .desc("name of a file that will contain the output model for the editor, "
+ + "will output model to standard output if not specified or suppressed with \"-nm\" flag")
+ .hasArg().argName("OUTPUT_MODEL_FILE").required(false).type(String.class).build());
+ options.addOption(Option.builder("if").longOpt("ignore-failures")
+ .desc("true or false, ignore failures of commands in command files and continue executing the command file")
+ .hasArg().argName("IGNORE_FAILURES_FLAG").required(false).type(Boolean.class).build());
+ options.addOption(Option.builder("wd").longOpt("working-directory")
+ .desc("the working directory that is the root for the CLI editor and is the root from which to look for included macro files")
+ .hasArg().argName("WORKING_DIRECTORY").required(false).type(String.class).build());
+ }
+
+ /**
+ * Parse the command line options.
+ *
+ * @param args The arguments
+ * @return the CLI parameters
+ */
+ public CLIParameters parse(final String[] args) {
+ CommandLine commandLine = null;
+ try {
+ commandLine = new DefaultParser().parse(options, args);
+ } catch (final ParseException e) {
+ throw new CLIException("invalid command line arguments specified : " + e.getMessage());
+ }
+
+ final CLIParameters parameters = new CLIParameters();
+ final String[] remainingArgs = commandLine.getArgs();
+
+ if (remainingArgs.length > 0) {
+ throw new CLIException("too many command line arguments specified : " + Arrays.toString(remainingArgs));
+ }
+
+ if (commandLine.hasOption('h')) {
+ parameters.setHelp(true);
+ }
+ if (commandLine.hasOption('m')) {
+ parameters.setMetadataFileName(commandLine.getOptionValue('m'));
+ }
+ if (commandLine.hasOption('a')) {
+ parameters.setApexPorpertiesFileName(commandLine.getOptionValue('a'));
+ }
+ if (commandLine.hasOption('c')) {
+ parameters.setCommandFileName(commandLine.getOptionValue('c'));
+ }
+ if (commandLine.hasOption('l')) {
+ parameters.setLogFileName(commandLine.getOptionValue('l'));
+ }
+ if (commandLine.hasOption("nl")) {
+ parameters.setSuppressLog(true);
+ }
+ if (commandLine.hasOption("nm")) {
+ parameters.setSuppressModelOutput(true);
+ }
+ if (commandLine.hasOption('i')) {
+ parameters.setInputModelFileName(commandLine.getOptionValue('i'));
+ }
+ if (commandLine.hasOption('o')) {
+ parameters.setOutputModelFileName(commandLine.getOptionValue('o'));
+ }
+ if (commandLine.hasOption("if")) {
+ parameters.setIgnoreCommandFailuresSet(true);
+ parameters.setIgnoreCommandFailures(Boolean.valueOf(commandLine.getOptionValue("if")));
+ } else {
+ parameters.setIgnoreCommandFailuresSet(false);
+ }
+ if (commandLine.hasOption("wd")) {
+ parameters.setWorkingDirectory(commandLine.getOptionValue("wd"));
+ } else {
+ parameters.setWorkingDirectory(Paths.get("").toAbsolutePath().toString());
+ }
+
+ return parameters;
+ }
+
+ /**
+ * Print help information.
+ *
+ * @param mainClassName the main class name
+ */
+ public void help(final String mainClassName) {
+ final HelpFormatter helpFormatter = new HelpFormatter();
+ helpFormatter.printHelp(MAX_HELP_LINE_LENGTH, mainClassName + " [options...]", "options", options, "");
+ }
+}
diff --git a/auth/cli-editor/src/main/java/org/onap/policy/apex/auth/clieditor/CLIParameters.java b/auth/cli-editor/src/main/java/org/onap/policy/apex/auth/clieditor/CLIParameters.java
new file mode 100644
index 000000000..476d17e3f
--- /dev/null
+++ b/auth/cli-editor/src/main/java/org/onap/policy/apex/auth/clieditor/CLIParameters.java
@@ -0,0 +1,571 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * Copyright (C) 2016-2018 Ericsson. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.policy.apex.auth.clieditor;
+
+import java.io.ByteArrayOutputStream;
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
+
+import org.onap.policy.apex.model.utilities.ResourceUtils;
+
+/**
+ * This class reads and handles command line parameters to the Apex CLI editor.
+ *
+ * @author Liam Fallon (liam.fallon@ericsson.com)
+ */
+public class CLIParameters {
+ // Default location of the command definition meta data in JSON
+ private static final String JSON_COMMAND_METADATA_RESOURCE = "etc/editor/Commands.json";
+ private static final String APEX_MODEL_PROPERTIES_RESOURCE = "etc/editor/ApexModelProperties.json";
+
+ // The editor parameters
+ private boolean helpSet = false;
+ private String metadataFileName = null;
+ private String apexPropertiesFileName = null;
+ private String commandFileName = null;
+ private String inputModelFileName = null;
+ private String outputModelFileName = null;
+ private String workingDirectory = null;
+ private String logFileName = null;
+ private boolean echo = false;
+ private boolean suppressLog = false;
+ private boolean suppressModelOutput = false;
+ private boolean ignoreCommandFailuresSet = false;
+ private boolean ignoreCommandFailures = false;
+
+ /**
+ * Validates the command line parameters.
+ */
+ public void validate() {
+ validateReadableFile("Metadata File", metadataFileName);
+ validateReadableFile("Properties File", apexPropertiesFileName);
+ validateReadableFile("Command File", commandFileName);
+ validateReadableFile("Input Model File", inputModelFileName);
+ validateWritableFile("Output Model File", outputModelFileName);
+ validateWritableFile("Log File", logFileName);
+ validateWritableDirectory("Working Directory", workingDirectory);
+
+ if (isSuppressLogSet()) {
+ setEcho(false);
+ } else {
+ if (checkSetCommandFileName()) {
+ setEcho(true);
+ if (!checkSetIgnoreCommandFailures()) {
+ setIgnoreCommandFailures(false);
+ }
+ } else {
+ setEcho(false);
+ if (!checkSetIgnoreCommandFailures()) {
+ setIgnoreCommandFailures(true);
+ }
+ }
+ }
+ }
+
+ /**
+ * Gets the command metadata for the editor commands as a stream.
+ *
+ * @return the command metadata for the editor commands as a stream.
+ * @throws IOException the IO exception
+ */
+ public InputStream getMetadataStream() throws IOException {
+ if (metadataFileName == null) {
+ return ResourceUtils.getResourceAsStream(JSON_COMMAND_METADATA_RESOURCE);
+ } else {
+ return new FileInputStream(new File(metadataFileName));
+ }
+ }
+
+ /**
+ * Gets the location of command metadata for the editor commands.
+ *
+ * @return the location of command metadata for the editor commands
+ */
+ public String getMetadataLocation() {
+ if (metadataFileName == null) {
+ return "resource: \"" + JSON_COMMAND_METADATA_RESOURCE + "\"";
+ } else {
+ return "file: \"" + metadataFileName + "\"";
+ }
+ }
+
+ /**
+ * Gets the properties that are used for command default values as a stream.
+ *
+ * @return the properties that are used for command default values as a stream
+ * @throws IOException the IO exception
+ */
+ public InputStream getApexPropertiesStream() throws IOException {
+ if (apexPropertiesFileName == null) {
+ return ResourceUtils.getResourceAsStream(APEX_MODEL_PROPERTIES_RESOURCE);
+ } else {
+ return new FileInputStream(new File(apexPropertiesFileName));
+ }
+ }
+
+ /**
+ * Gets the location of the properties that are used for command default values.
+ *
+ * @return the location of the properties that are used for command default values
+ */
+ public String getApexPropertiesLocation() {
+ if (metadataFileName == null) {
+ return "resource: \"" + APEX_MODEL_PROPERTIES_RESOURCE + "\"";
+ } else {
+ return "file: \"" + apexPropertiesFileName + "\"";
+ }
+ }
+
+ /**
+ * Gets the input stream on which commands are being received.
+ *
+ * @return the input stream on which commands are being received
+ * @throws IOException the IO exception
+ */
+ public InputStream getCommandInputStream() throws IOException {
+ if (commandFileName == null) {
+ return System.in;
+ } else {
+ return new FileInputStream(new File(commandFileName));
+ }
+ }
+
+ /**
+ * Gets the output stream on which command result messages are being output.
+ *
+ * @return the output stream on which command result messages are being output
+ * @throws IOException the IO exception
+ */
+ public OutputStream getOutputStream() throws IOException {
+ // Check if log suppression is active, if so, consume all output on a byte array output
+ // stream
+ if (isSuppressLogSet()) {
+ return new ByteArrayOutputStream();
+
+ }
+ if (logFileName == null) {
+ return System.out;
+ } else {
+ return new FileOutputStream(new File(logFileName), true);
+ }
+ }
+
+ /**
+ * Validate that a file is readable.
+ *
+ * @param fileTag the file tag, a tag used for information and error messages
+ * @param fileName the file name to check
+ */
+ private void validateReadableFile(final String fileTag, final String fileName) {
+ if (fileName == null) {
+ return;
+ }
+ final File theFile = new File(fileName);
+ if (!theFile.exists()) {
+ throw new CLIException("file " + fileName + " of type " + fileTag + " does not exist");
+ }
+ if (!theFile.isFile()) {
+ throw new CLIException("file " + fileName + " of type " + fileTag + " is not a normal file");
+ }
+ if (!theFile.canRead()) {
+ throw new CLIException("file " + fileName + " of type " + fileTag + " is ureadable");
+ }
+ }
+
+ /**
+ * Validate that a file is writable.
+ *
+ * @param fileTag the file tag, a tag used for information and error messages
+ * @param fileName the file name to check
+ */
+ private void validateWritableFile(final String fileTag, final String fileName) {
+ if (fileName == null) {
+ return;
+ }
+ final File theFile = new File(fileName);
+ if (theFile.exists()) {
+ if (!theFile.isFile()) {
+ throw new CLIException("file " + fileName + " of type " + fileTag + " is not a normal file");
+ }
+ if (!theFile.canWrite()) {
+ throw new CLIException("file " + fileName + " of type " + fileTag + " cannot be written");
+ }
+ } else {
+ try {
+ theFile.createNewFile();
+ } catch (final IOException e) {
+ throw new CLIException("file " + fileName + " cannot be created: " + e.getMessage());
+ }
+ }
+ }
+
+ /**
+ * Validate that a directory exists and is writable.
+ *
+ * @param directoryTag the directory tag, a tag used for information and error messages
+ * @param directoryName the directory name to check
+ */
+ private void validateWritableDirectory(final String directoryTag, final String directoryName) {
+ if (directoryName == null) {
+ return;
+ }
+ final File theDirectory = new File(directoryName);
+ if (theDirectory.exists()) {
+ if (!theDirectory.isDirectory()) {
+ throw new CLIException(
+ "directory " + directoryName + " of type " + directoryTag + " is not a directory");
+ }
+ if (!theDirectory.canWrite()) {
+ throw new CLIException(
+ "directory " + directoryName + " of type " + directoryTag + " cannot be written");
+ }
+ }
+ }
+
+ /**
+ * Checks if help is set.
+ *
+ * @return true, if help is set
+ */
+ public boolean isHelpSet() {
+ return helpSet;
+ }
+
+ /**
+ * Sets whether the help flag is set or not.
+ *
+ * @param isHelpSet the value of the help flag
+ */
+ public void setHelp(final boolean isHelpSet) {
+ this.helpSet = isHelpSet;
+ }
+
+ /**
+ * Gets the file name of the command metadata file for the editor commands.
+ *
+ * @return the file name of the command metadata file for the editor commands
+ */
+ public String getMetadataFileName() {
+ return metadataFileName;
+ }
+
+ /**
+ * Sets the file name of the command metadata file for the editor commands.
+ *
+ * @param metadataFileName the file name of the command metadata file for the editor commands
+ */
+ public void setMetadataFileName(final String metadataFileName) {
+ this.metadataFileName = metadataFileName.trim();
+ }
+
+ /**
+ * Check if the file name of the command metadata file for the editor commands is set.
+ *
+ * @return true, if the file name of the command metadata file for the editor commands is set
+ */
+ public boolean checkSetMetadataFileName() {
+ return metadataFileName != null && metadataFileName.length() > 0;
+ }
+
+ /**
+ * Gets the file name of the file containing properties that are used for command default
+ * values.
+ *
+ * @return the file name of the file containing properties that are used for command default
+ * values
+ */
+ public String getApexPorpertiesFileName() {
+ return apexPropertiesFileName;
+ }
+
+ /**
+ * Sets the file name of the file containing properties that are used for command default
+ * values.
+ *
+ * @param apexPorpertiesFileName the file name of the file containing properties that are used
+ * for command default values
+ */
+ public void setApexPorpertiesFileName(final String apexPorpertiesFileName) {
+ apexPropertiesFileName = apexPorpertiesFileName.trim();
+ }
+
+ /**
+ * Check if the file name of the file containing properties that are used for command default
+ * values is set.
+ *
+ * @return true, if the file name of the file containing properties that are used for command
+ * default values is set
+ */
+ public boolean checkSetApexPropertiesFileName() {
+ return apexPropertiesFileName != null && apexPropertiesFileName.length() > 0;
+ }
+
+ /**
+ * Gets the name of the file containing commands to be streamed into the CLI editor.
+ *
+ * @return the name of the file containing commands to be streamed into the CLI editor
+ */
+ public String getCommandFileName() {
+ return commandFileName;
+ }
+
+ /**
+ * Sets the name of the file containing commands to be streamed into the CLI editor.
+ *
+ * @param commandFileName the name of the file containing commands to be streamed into the CLI
+ * editor
+ */
+ public void setCommandFileName(final String commandFileName) {
+ this.commandFileName = commandFileName.trim();
+ }
+
+ /**
+ * Check if the name of the file containing commands to be streamed into the CLI editor is set.
+ *
+ * @return true, if the name of the file containing commands to be streamed into the CLI editor
+ * is set
+ */
+ public boolean checkSetCommandFileName() {
+ return commandFileName != null && commandFileName.length() > 0;
+ }
+
+ /**
+ * Gets the name of the file containing the Apex model that will be used to initialize the Apex
+ * model in the CLI editor.
+ *
+ * @return the name of the file containing the Apex model that will be used to initialize the
+ * Apex model in the CLI editor
+ */
+ public String getInputModelFileName() {
+ return inputModelFileName;
+ }
+
+ /**
+ * Sets the name of the file containing the Apex model that will be used to initialize the Apex
+ * model in the CLI editor.
+ *
+ * @param inputModelFileName the name of the file containing the Apex model that will be used to
+ * initialize the Apex model in the CLI editor
+ */
+ public void setInputModelFileName(final String inputModelFileName) {
+ this.inputModelFileName = inputModelFileName.trim();
+ }
+
+ /**
+ * Check if the name of the file containing the Apex model that will be used to initialize the
+ * Apex model in the CLI editor is set.
+ *
+ * @return true, if the name of the file containing the Apex model that will be used to
+ * initialize the Apex model in the CLI editor is set
+ */
+ public boolean checkSetInputModelFileName() {
+ return inputModelFileName != null && inputModelFileName.length() > 0;
+ }
+
+ /**
+ * Gets the name of the file that the Apex CLI editor will save the Apex model to when it exits.
+ *
+ * @return the name of the file that the Apex CLI editor will save the Apex model to when it
+ * exits
+ */
+ public String getOutputModelFileName() {
+ return outputModelFileName;
+ }
+
+ /**
+ * Sets the name of the file that the Apex CLI editor will save the Apex model to when it exits.
+ *
+ * @param outputModelFileName the name of the file that the Apex CLI editor will save the Apex
+ * model to when it exits
+ */
+ public void setOutputModelFileName(final String outputModelFileName) {
+ this.outputModelFileName = outputModelFileName.trim();
+ }
+
+ /**
+ * Check if the name of the file that the Apex CLI editor will save the Apex model to when it
+ * exits is set.
+ *
+ * @return true, if the name of the file that the Apex CLI editor will save the Apex model to
+ * when it exits is set
+ */
+ public boolean checkSetOutputModelFileName() {
+ return outputModelFileName != null && outputModelFileName.length() > 0;
+ }
+
+ /**
+ * Gets the working directory that is the root for CLI editor macro includes.
+ *
+ * @return the CLI editor working directory
+ */
+ public String getWorkingDirectory() {
+ return workingDirectory;
+ }
+
+ /**
+ * Sets the working directory that is the root for CLI editor macro includes.
+ *
+ * @param workingDirectory the CLI editor working directory
+ */
+ public void setWorkingDirectory(final String workingDirectory) {
+ this.workingDirectory = workingDirectory.trim();
+ }
+
+ /**
+ * Gets the name of the file to which the Apex CLI editor will log commands and responses.
+ *
+ * @return the name of the file to which the Apex CLI editor will log commands and responses
+ */
+ public String getLogFileName() {
+ return logFileName;
+ }
+
+ /**
+ * Sets the name of the file to which the Apex CLI editor will log commands and responses.
+ *
+ * @param logFileName the name of the file to which the Apex CLI editor will log commands and
+ * responses
+ */
+ public void setLogFileName(final String logFileName) {
+ this.logFileName = logFileName.trim();
+ }
+
+ /**
+ * Check if the name of the file to which the Apex CLI editor will log commands and responses is
+ * set.
+ *
+ * @return true, if the name of the file to which the Apex CLI editor will log commands and
+ * responses is set
+ */
+ public boolean checkSetLogFileName() {
+ return logFileName != null;
+ }
+
+ /**
+ * Checks if the Apex CLI editor is set to echo commands that have been entered.
+ *
+ * @return true, if the Apex CLI editor is set to echo commands that have been entered
+ */
+ public boolean isEchoSet() {
+ return echo;
+ }
+
+ /**
+ * Sets whether the Apex CLI editor should echo commands that have been entered.
+ *
+ * @param echo true, if the Apex CLI editor should echo commands that have been entered
+ */
+ public void setEcho(final boolean echo) {
+ this.echo = echo;
+ }
+
+ /**
+ * Checks whether the Apex CLI editor is set to suppress logging of command output.
+ *
+ * @return true, if the Apex CLI editor is set to suppress logging of command output.
+ */
+ public boolean isSuppressLogSet() {
+ return suppressLog;
+ }
+
+ /**
+ * Sets whether the Apex CLI editor should suppress logging of command output.
+ *
+ * @param suppressLog true, if the Apex CLI editor should suppress logging of command output
+ */
+ public void setSuppressLog(final boolean suppressLog) {
+ this.suppressLog = suppressLog;
+ }
+
+ /**
+ * Checks whether the Apex CLI editor is set to suppress output of its Apex model on exit.
+ *
+ * @return true, if checks if the Apex CLI editor is set to suppress output of its Apex model on
+ * exit
+ */
+ public boolean isSuppressModelOutputSet() {
+ return suppressModelOutput;
+ }
+
+ /**
+ * Sets whether the Apex CLI editor should suppress output of its Apex model on exit.
+ *
+ * @param suppressModelOutput true, if the Apex CLI editor should suppress output of its Apex
+ * model on exit
+ */
+ public void setSuppressModelOutput(final boolean suppressModelOutput) {
+ this.suppressModelOutput = suppressModelOutput;
+ }
+
+ /**
+ * Check if the command failures flag is set
+ *
+ * @return true if the command failures flag has been set
+ */
+ public boolean checkSetIgnoreCommandFailures() {
+ return ignoreCommandFailuresSet;
+ }
+
+ /**
+ * Checks if the command failures flag is set.
+ *
+ * @param ignoreCommandFailuresSet true if the command failures flag has been set
+ */
+ public void setIgnoreCommandFailuresSet(final boolean ignoreCommandFailuresSet) {
+ this.ignoreCommandFailuresSet = ignoreCommandFailuresSet;
+ }
+
+ /**
+ * Checks if command failures should be ignored and command execution continue.
+ *
+ * @return true if command failures should be ignored
+ */
+ public boolean isIgnoreCommandFailures() {
+ return ignoreCommandFailures;
+ }
+
+ /**
+ * Sets if command errors should be ignored and command execution continue.
+ *
+ * @param ignoreCommandFailures true if command errors should be ignored
+ */
+ public void setIgnoreCommandFailures(final boolean ignoreCommandFailures) {
+ this.ignoreCommandFailures = ignoreCommandFailures;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see java.lang.Object#toString()
+ */
+ @Override
+ public String toString() {
+ return "CLIParameters [helpSet=" + helpSet + ", metadataFileName=" + metadataFileName
+ + ", apexPropertiesFileName=" + apexPropertiesFileName + ", commandFileName=" + commandFileName
+ + ", inputModelFileName=" + inputModelFileName + ", outputModelFileName=" + outputModelFileName
+ + ", logFileName=" + logFileName + ", echo=" + echo + ", suppressLog=" + suppressLog
+ + ", suppressModelOutput=" + suppressModelOutput + "]";
+ }
+}
diff --git a/auth/cli-editor/src/main/java/org/onap/policy/apex/auth/clieditor/KeywordNode.java b/auth/cli-editor/src/main/java/org/onap/policy/apex/auth/clieditor/KeywordNode.java
new file mode 100644
index 000000000..06579e073
--- /dev/null
+++ b/auth/cli-editor/src/main/java/org/onap/policy/apex/auth/clieditor/KeywordNode.java
@@ -0,0 +1,188 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * Copyright (C) 2016-2018 Ericsson. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.policy.apex.auth.clieditor;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Set;
+import java.util.TreeMap;
+import java.util.TreeSet;
+
+import org.onap.policy.apex.model.utilities.Assertions;
+
+/**
+ * The Class KeywordNode holds the structure of a command keyword for the Apex CLI editor. The
+ * keyword itself and all its children are held as a recursive tree. This class is used to manage
+ * interactive sub-modes in the Apex CLI editor.
+ */
+public class KeywordNode implements Comparable<KeywordNode> {
+ private final String keyword;
+ private final TreeMap<String, KeywordNode> children;
+ private CLICommand command;
+
+ /**
+ * This Constructor creates a keyword node with the given keyword and no command.
+ *
+ * @param keyword the keyword of the node
+ */
+ public KeywordNode(final String keyword) {
+ this(keyword, null);
+ }
+
+ /**
+ * This Constructor creates a keyword node with the given keyword and command.
+ *
+ * @param keyword the keyword of the keyword node
+ * @param command the command associated with this keyword
+ */
+ public KeywordNode(final String keyword, final CLICommand command) {
+ Assertions.argumentNotNull(keyword, "commands may not be null");
+
+ this.keyword = keyword;
+ children = new TreeMap<>();
+ this.command = command;
+ }
+
+ /**
+ * Process a list of keywords on this keyword node, recursing the keyword node tree, creating
+ * new branches for the keyword list if required. When the end of a branch has been reached,
+ * store the command in that keyword node..
+ *
+ * @param keywordList the list of keywords to process on this keyword node
+ * @param incomingCommand the command
+ */
+ public void processKeywords(final List<String> keywordList, final CLICommand incomingCommand) {
+ if (keywordList.size() <= 0) {
+ this.command = incomingCommand;
+ return;
+ }
+
+ if (!children.containsKey(keywordList.get(0))) {
+ children.put(keywordList.get(0), new KeywordNode(keywordList.get(0)));
+ }
+
+ final ArrayList<String> nextLevelKeywordList = new ArrayList<>(keywordList);
+ nextLevelKeywordList.remove(0);
+ children.get(keywordList.get(0)).processKeywords(nextLevelKeywordList, incomingCommand);
+ }
+
+ /**
+ * Adds the system commands to the keyword node.
+ *
+ * @param systemCommandNodes the system command nodes to add to the keyword node
+ */
+ public void addSystemCommandNodes(final Set<KeywordNode> systemCommandNodes) {
+ if (children.isEmpty()) {
+ return;
+ }
+
+ for (final KeywordNode node : children.values()) {
+ node.addSystemCommandNodes(systemCommandNodes);
+ }
+
+ for (final KeywordNode systemCommandNode : systemCommandNodes) {
+ children.put(systemCommandNode.getKeyword(), systemCommandNode);
+ }
+
+ }
+
+ /**
+ * Gets the keyword of this keyword node.
+ *
+ * @return the keyword of this keyword node
+ */
+ public String getKeyword() {
+ return keyword;
+ }
+
+ /**
+ * Gets the children of this keyword node.
+ *
+ * @return the children of this keyword node
+ */
+ public TreeMap<String, KeywordNode> getChildren() {
+ return children;
+ }
+
+ /**
+ * Gets the command of this keyword node.
+ *
+ * @return the command of this keyword node
+ */
+ public CLICommand getCommand() {
+ return command;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see java.lang.Object#toString()
+ */
+ @Override
+ public String toString() {
+ return "CommandKeywordNode [keyword=" + keyword + ", children=" + children + ", command=" + command + "]";
+ }
+
+ /**
+ * Gets the commands.
+ *
+ * @return the commands
+ */
+ public Set<CLICommand> getCommands() {
+ final Set<CLICommand> commandSet = new TreeSet<>();
+
+ for (final KeywordNode child : children.values()) {
+ if (child.getCommand() != null) {
+ commandSet.add(child.getCommand());
+ }
+ commandSet.addAll(child.getCommands());
+ }
+
+ return commandSet;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see java.lang.Comparable#compareTo(java.lang.Object)
+ */
+ @Override
+ public int compareTo(final KeywordNode otherKeywordNode) {
+ Assertions.argumentNotNull(otherKeywordNode, "comparison object may not be null");
+
+ if (this == otherKeywordNode) {
+ return 0;
+ }
+ if (getClass() != otherKeywordNode.getClass()) {
+ return this.hashCode() - otherKeywordNode.hashCode();
+ }
+
+ final KeywordNode other = otherKeywordNode;
+
+ if (!keyword.equals(other.keyword)) {
+ return keyword.compareTo(other.keyword);
+ }
+ if (!children.equals(other.children)) {
+ return (children.hashCode() - other.children.hashCode());
+ }
+ return command.compareTo(otherKeywordNode.command);
+ }
+}
diff --git a/auth/cli-editor/src/main/java/org/onap/policy/apex/auth/clieditor/package-info.java b/auth/cli-editor/src/main/java/org/onap/policy/apex/auth/clieditor/package-info.java
new file mode 100644
index 000000000..e0e7f746e
--- /dev/null
+++ b/auth/cli-editor/src/main/java/org/onap/policy/apex/auth/clieditor/package-info.java
@@ -0,0 +1,28 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * Copyright (C) 2016-2018 Ericsson. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ * ============LICENSE_END=========================================================
+ */
+
+/**
+ * Provides a command line editor for APEX. The command line editor can be used to interactively
+ * from the command line to edit policy models or it can be executed using scripts containing CLI
+ * commands.
+ *
+ * @author Liam Fallon (liam.fallon@ericsson.com)
+ */
+package org.onap.policy.apex.auth.clieditor;
diff --git a/auth/cli-editor/src/main/resources/etc/editor/ApexModelProperties.json b/auth/cli-editor/src/main/resources/etc/editor/ApexModelProperties.json
new file mode 100644
index 000000000..bd33d69da
--- /dev/null
+++ b/auth/cli-editor/src/main/resources/etc/editor/ApexModelProperties.json
@@ -0,0 +1,9 @@
+{
+ "defaultConceptVersion" : "0.0.1",
+ "defaultEventNamespace" : "org.onap.policy.apex.auth.clieditor",
+ "defaultEventSource" : "CLIEditorSource",
+ "defaultEventTarget" : "CLIEditorTarget",
+ "defaultLogicBlockStartTag" : "LS",
+ "defaultLogicBlockEndTag" : "LE",
+ "defaultMacroFileTag" : "#MACROFILE:"
+}
diff --git a/auth/cli-editor/src/main/resources/etc/editor/Commands.json b/auth/cli-editor/src/main/resources/etc/editor/Commands.json
new file mode 100644
index 000000000..54ad92a2b
--- /dev/null
+++ b/auth/cli-editor/src/main/resources/etc/editor/Commands.json
@@ -0,0 +1,2427 @@
+{
+ "commandList": [
+ {
+ "name": "quit",
+ "keywordlist": [
+ "quit"
+ ],
+ "argumentList": [],
+ "systemCommand": "true",
+ "description": "quit execution of command handling, this command quits immediately without saving the model"
+ },
+ {
+ "name": "back",
+ "keywordlist": [
+ "back"
+ ],
+ "argumentList": [],
+ "systemCommand": "true",
+ "description": "go back one level in editor context hierarchy"
+ },
+ {
+ "name": "help",
+ "keywordlist": [
+ "help"
+ ],
+ "argumentList": [],
+ "systemCommand": "true",
+ "description": "output help information appropriate to this point in the editor context hierarchy"
+ },
+ {
+ "name": "load",
+ "keywordlist": [
+ "load"
+ ],
+ "argumentList": [
+ {
+ "argumentName": "fileName",
+ "nullable": false,
+ "description": "Name of a file containing an Apex model in JSON or XML format"
+ }
+ ],
+ "apiMethod": "org.onap.policy.apex.model.modelapi.ApexModel.loadFromFile",
+ "description": "Load an Apex model from a file"
+ },
+ {
+ "name": "save",
+ "keywordlist": [
+ "save"
+ ],
+ "argumentList": [
+ {
+ "argumentName": "fileName",
+ "nullable": true,
+ "description": "Name of the file to save the model to"
+ },
+ {
+ "argumentName": "xmlFlag",
+ "nullable": true,
+ "description": "Flag indicating that the model should be saved in XML format, model saved in JSON format if flag is false or is not specified"
+ }
+ ],
+ "apiMethod": "org.onap.policy.apex.model.modelapi.ApexModel.saveToFile",
+ "description": "Save an Apex model to a file"
+ },
+ {
+ "name": "analyse",
+ "keywordlist": [
+ "analyse"
+ ],
+ "argumentList": [],
+ "apiMethod": "org.onap.policy.apex.model.modelapi.ApexModel.analyse",
+ "description": "Analyse an Apex model to show concept usage"
+ },
+ {
+ "name": "validate",
+ "keywordlist": [
+ "validate"
+ ],
+ "argumentList": [],
+ "apiMethod": "org.onap.policy.apex.model.modelapi.ApexModel.validate",
+ "description": "Validate the entire Apex model to ensure it is consistent"
+ },
+ {
+ "name": "compare",
+ "keywordlist": [
+ "compare"
+ ],
+ "argumentList": [
+ {
+ "argumentName": "otherModelFileName",
+ "nullable": false,
+ "description": "The file name of the other model"
+ },
+ {
+ "argumentName": "diffsOnly",
+ "nullable": true,
+ "description": "Flag indicating that only differences between the model are returned when set"
+ },
+ {
+ "argumentName": "keysOnly",
+ "nullable": true,
+ "description": "Flag indicating that only keys are printed when set, more terse output"
+ }
+ ],
+ "apiMethod": "org.onap.policy.apex.model.modelapi.ApexModel.compare",
+ "description": "Compare an Apex model with another Apex model"
+ },
+ {
+ "name": "split",
+ "keywordlist": [
+ "split"
+ ],
+ "argumentList": [
+ {
+ "argumentName": "targetModelName",
+ "nullable": false,
+ "description": "the file name of the target model in which to store the model split out from the original model"
+ },
+ {
+ "argumentName": "splitOutPolicies",
+ "nullable": "false",
+ "description": "the policies form the original model to include in the split out model, specified as a comma delimited list of policy names"
+ }
+ ],
+ "apiMethod": "org.onap.policy.apex.model.modelapi.ApexModel.split",
+ "description": "Split an Apex model into a separate Apex model with only the specified policies"
+ },
+ {
+ "name": "merge",
+ "keywordlist": [
+ "merge"
+ ],
+ "argumentList": [
+ {
+ "argumentName": "mergeInModelName",
+ "nullable": false,
+ "description": "the file name of the model to merge into the current model"
+ },
+ {
+ "argumentName": "keepOriginal",
+ "nullable": "true",
+ "description": "if true, if a concept exists in both models, the original model copy of that concept is kept, if false, the mreged model overwrites"
+ }
+ ],
+ "apiMethod": "org.onap.policy.apex.model.modelapi.ApexModel.merge",
+ "description": "Merge another Apex model into this model"
+ },
+ {
+ "name": "createModel",
+ "keywordlist": [
+ "model",
+ "create"
+ ],
+ "argumentList": [
+ {
+ "argumentName": "name",
+ "nullable": false,
+ "description": "name of the model"
+ },
+ {
+ "argumentName": "version",
+ "nullable": true,
+ "description": "version of the model, omit to use the default version"
+ },
+ {
+ "argumentName": "uuid",
+ "nullable": true,
+ "description": "model UUID, omit to generate a UUID"
+ },
+ {
+ "argumentName": "description",
+ "nullable": true,
+ "description": "model description, omit to generate a description"
+ }
+ ],
+ "apiMethod": "org.onap.policy.apex.model.modelapi.ApexEditorAPI.createModel",
+ "description": "Create an Apex model."
+ },
+ {
+ "name": "listModel",
+ "keywordlist": [
+ "model",
+ "list"
+ ],
+ "argumentList": [],
+ "apiMethod": "org.onap.policy.apex.model.modelapi.ApexEditorAPI.listModel",
+ "description": "List an Apex model, list all the concepts in the model"
+ },
+ {
+ "name": "deleteModel",
+ "keywordlist": [
+ "model",
+ "delete"
+ ],
+ "argumentList": [],
+ "apiMethod": "org.onap.policy.apex.model.modelapi.ApexEditorAPI.deleteModel",
+ "description": "Delete an Apex model, clear all the concepts in the model"
+ },
+ {
+ "name": "createKeyInformation",
+ "keywordlist": [
+ "keyinfo",
+ "create"
+ ],
+ "argumentList": [
+ {
+ "argumentName": "name",
+ "nullable": false,
+ "description": "name of the concept for the key information"
+ },
+ {
+ "argumentName": "version",
+ "nullable": true,
+ "description": "version of the concept for the key information, omit to use the default version"
+ },
+ {
+ "argumentName": "uuid",
+ "nullable": true,
+ "description": "key information UUID, set to null to generate a UUID"
+ },
+ {
+ "argumentName": "description",
+ "nullable": true,
+ "description": "concept description, omit to generate a description"
+ }
+ ],
+ "apiMethod": "org.onap.policy.apex.model.modelapi.ApexEditorAPI.createKeyInformation",
+ "description": "Create key information"
+ },
+ {
+ "name": "updateKeyInformation",
+ "keywordlist": [
+ "keyinfo",
+ "update"
+ ],
+ "argumentList": [
+ {
+ "argumentName": "name",
+ "nullable": false,
+ "description": "name of the concept for the key information"
+ },
+ {
+ "argumentName": "version",
+ "nullable": true,
+ "description": "version of the concept for the key information, omit to update the latest version"
+ },
+ {
+ "argumentName": "uuid",
+ "nullable": true,
+ "description": "key information UUID, omit to not update"
+ },
+ {
+ "argumentName": "description",
+ "nullable": true,
+ "description": "concept description, omit to not update"
+ }
+ ],
+ "apiMethod": "org.onap.policy.apex.model.modelapi.ApexEditorAPI.updateKeyInformation",
+ "description": "Update key information"
+ },
+ {
+ "name": "listKeyInformation",
+ "keywordlist": [
+ "keyinfo",
+ "list"
+ ],
+ "argumentList": [
+ {
+ "argumentName": "name",
+ "nullable": true,
+ "description": "name of the concept for the key information, omit to list all"
+ },
+ {
+ "argumentName": "version",
+ "nullable": true,
+ "description": "starting version of the concept for the key information, omit to list all versions"
+ }
+ ],
+ "apiMethod": "org.onap.policy.apex.model.modelapi.ApexEditorAPI.ListKeyInformation",
+ "description": "List key information"
+ },
+ {
+ "name": "deleteKeyInformation",
+ "keywordlist": [
+ "keyinfo",
+ "delete"
+ ],
+ "argumentList": [
+ {
+ "argumentName": "name",
+ "nullable": true,
+ "description": "name of the concept for the key information"
+ },
+ {
+ "argumentName": "version",
+ "nullable": true,
+ "description": "version of the concept for the key information, omit to delete all versions"
+ }
+ ],
+ "apiMethod": "org.onap.policy.apex.model.modelapi.ApexEditorAPI.deleteKeyInformation",
+ "description": "Delete key information"
+ },
+ {
+ "name": "validateKeyInformation",
+ "keywordlist": [
+ "keyinfo",
+ "validate"
+ ],
+ "argumentList": [
+ {
+ "argumentName": "name",
+ "nullable": true,
+ "description": "name of the concept for the key information"
+ },
+ {
+ "argumentName": "version",
+ "nullable": true,
+ "description": "version of the concept for the key information, omit to validate all versions"
+ }
+ ],
+ "apiMethod": "org.onap.policy.apex.model.modelapi.ApexEditorAPI.validateKeyInformation",
+ "description": "Validate key information"
+ },
+ {
+ "name": "createSchema",
+ "keywordlist": [
+ "schema",
+ "create"
+ ],
+ "argumentList": [
+ {
+ "argumentName": "name",
+ "nullable": false,
+ "description": "name of the schema"
+ },
+ {
+ "argumentName": "version",
+ "nullable": true,
+ "description": "version of the schema, omit to use the default version"
+ },
+ {
+ "argumentName": "flavour",
+ "nullable": true,
+ "description": "the flavour of the technology for this schema, defaults to \"Java\""
+ },
+ {
+ "argumentName": "schema",
+ "nullable": false,
+ "description": "the schema text that describes the item represented by the schema"
+ },
+ {
+ "argumentName": "uuid",
+ "nullable": true,
+ "description": "schema UUID, omit to generate a UUID"
+ },
+ {
+ "argumentName": "description",
+ "nullable": true,
+ "description": "schema description, omit to generate a description"
+ }
+ ],
+ "apiMethod": "org.onap.policy.apex.model.modelapi.ApexEditorAPI.createContextSchema",
+ "description": "Create a schema."
+ },
+ {
+ "name": "updateSchema",
+ "keywordlist": [
+ "schema",
+ "update"
+ ],
+ "argumentList": [
+ {
+ "argumentName": "name",
+ "nullable": false,
+ "description": "name of the schema"
+ },
+ {
+ "argumentName": "version",
+ "nullable": true,
+ "description": "version of the schema, omit to use the default version"
+ },
+ {
+ "argumentName": "flavour",
+ "nullable": true,
+ "description": "the flavour of the technology for this schema, defaults to \"Java\""
+ },
+ {
+ "argumentName": "schema",
+ "nullable": false,
+ "description": "the schema text that describes the item represented by the schema"
+ },
+ {
+ "argumentName": "uuid",
+ "nullable": true,
+ "description": "schema UUID, omit to generate a UUID"
+ },
+ {
+ "argumentName": "description",
+ "nullable": true,
+ "description": "schema description, omit to generate a description"
+ }
+ ],
+ "apiMethod": "org.onap.policy.apex.model.modelapi.ApexEditorAPI.updateContextSchema",
+ "description": "Update a schema."
+ },
+ {
+ "name": "listSchemas",
+ "keywordlist": [
+ "schema",
+ "list"
+ ],
+ "argumentList": [
+ {
+ "argumentName": "name",
+ "nullable": true,
+ "description": "name of the schema, omit to list all"
+ },
+ {
+ "argumentName": "version",
+ "nullable": true,
+ "description": "starting version of the schema, omit to list all versions"
+ }
+ ],
+ "apiMethod": "org.onap.policy.apex.model.modelapi.ApexEditorAPI.listContextSchemas",
+ "description": "List schemas."
+ },
+ {
+ "name": "deleteSchema",
+ "keywordlist": [
+ "schema",
+ "delete"
+ ],
+ "argumentList": [
+ {
+ "argumentName": "name",
+ "nullable": true,
+ "description": "name of the schema"
+ },
+ {
+ "argumentName": "version",
+ "nullable": true,
+ "description": "version of the schema, omit to delete all versions"
+ }
+ ],
+ "apiMethod": "org.onap.policy.apex.model.modelapi.ApexEditorAPI.deleteContextSchema",
+ "description": "Delete a schema."
+ },
+ {
+ "name": "validateSchemas",
+ "keywordlist": [
+ "schema",
+ "validate"
+ ],
+ "argumentList": [
+ {
+ "argumentName": "name",
+ "nullable": true,
+ "description": "name of the schema, omit to list all"
+ },
+ {
+ "argumentName": "version",
+ "nullable": true,
+ "description": "starting version of the schema, omit to list all versions"
+ }
+ ],
+ "apiMethod": "org.onap.policy.apex.model.modelapi.ApexEditorAPI.validateContextSchemas",
+ "description": "Validate context schemas."
+ },
+ {
+ "name": "createEvent",
+ "keywordlist": [
+ "event",
+ "create"
+ ],
+ "argumentList": [
+ {
+ "argumentName": "name",
+ "nullable": false,
+ "description": "name of the event"
+ },
+ {
+ "argumentName": "version",
+ "nullable": true,
+ "description": "version of the event, omit to use the default version"
+ },
+ {
+ "argumentName": "nameSpace",
+ "nullable": true,
+ "description": "of the event, omit to use the default value"
+ },
+ {
+ "argumentName": "source",
+ "nullable": true,
+ "description": "of the event, omit to use the default value"
+ },
+ {
+ "argumentName": "target",
+ "nullable": true,
+ "description": "of the event, omit to use the default value"
+ },
+ {
+ "argumentName": "uuid",
+ "nullable": true,
+ "description": "event UUID, omit to generate a UUID"
+ },
+ {
+ "argumentName": "description",
+ "nullable": true,
+ "description": "event description, omit to generate a description"
+ }
+ ],
+ "apiMethod": "org.onap.policy.apex.model.modelapi.ApexEditorAPI.createEvent",
+ "description": "Create an event."
+ },
+ {
+ "name": "updateEvent",
+ "keywordlist": [
+ "event",
+ "update"
+ ],
+ "argumentList": [
+ {
+ "argumentName": "name",
+ "nullable": false,
+ "description": "name of the event"
+ },
+ {
+ "argumentName": "version",
+ "nullable": true,
+ "description": "version of the event, omit to use the latest version"
+ },
+ {
+ "argumentName": "nameSpace",
+ "nullable": true,
+ "description": "of the event, omit to not update"
+ },
+ {
+ "argumentName": "source",
+ "nullable": true,
+ "description": "of the event, omit to not update"
+ },
+ {
+ "argumentName": "target",
+ "nullable": true,
+ "description": "of the event, omit to not update"
+ },
+ {
+ "argumentName": "uuid",
+ "nullable": true,
+ "description": "event UUID, omit to not update"
+ },
+ {
+ "argumentName": "description",
+ "nullable": true,
+ "description": "event description, omit to not update"
+ }
+ ],
+ "apiMethod": "org.onap.policy.apex.model.modelapi.ApexEditorAPI.updateEvent",
+ "description": "Update an event."
+ },
+ {
+ "name": "listEvent",
+ "keywordlist": [
+ "event",
+ "list"
+ ],
+ "argumentList": [
+ {
+ "argumentName": "name",
+ "nullable": true,
+ "description": "name of the event, omit to list all"
+ },
+ {
+ "argumentName": "version",
+ "nullable": true,
+ "description": "starting version of the event, omit to list all versions"
+ }
+ ],
+ "apiMethod": "org.onap.policy.apex.model.modelapi.ApexEditorAPI.listEvent",
+ "description": "List events."
+ },
+ {
+ "name": "deleteEvent",
+ "keywordlist": [
+ "event",
+ "delete"
+ ],
+ "argumentList": [
+ {
+ "argumentName": "name",
+ "nullable": false,
+ "description": "name of the event"
+ },
+ {
+ "argumentName": "version",
+ "nullable": true,
+ "description": "version of the event, omit to delete all versions"
+ }
+ ],
+ "apiMethod": "org.onap.policy.apex.model.modelapi.ApexEditorAPI.deleteEvent",
+ "description": "Delete an event."
+ },
+ {
+ "name": "validateEvent",
+ "keywordlist": [
+ "event",
+ "validate"
+ ],
+ "argumentList": [
+ {
+ "argumentName": "name",
+ "nullable": true,
+ "description": "name of the event, omit to list all"
+ },
+ {
+ "argumentName": "version",
+ "nullable": true,
+ "description": "starting version of the event, omit to list all versions"
+ }
+ ],
+ "apiMethod": "org.onap.policy.apex.model.modelapi.ApexEditorAPI.validateEvent",
+ "description": "Validate events."
+ },
+ {
+ "name": "createEventPar",
+ "keywordlist": [
+ "event",
+ "parameter",
+ "create"
+ ],
+ "argumentList": [
+ {
+ "argumentName": "name",
+ "nullable": false,
+ "description": "name of the event"
+ },
+ {
+ "argumentName": "version",
+ "nullable": true,
+ "description": "version of the event, omit to use the latest version"
+ },
+ {
+ "argumentName": "parName",
+ "nullable": false,
+ "description": "of the parameter"
+ },
+ {
+ "argumentName": "schemaName",
+ "nullable": false,
+ "description": "name of the parameter schema"
+ },
+ {
+ "argumentName": "schemaVersion",
+ "nullable": true,
+ "description": "version of the parameter schema, omit to use the latest version"
+ },
+ {
+ "argumentName": "optional",
+ "nullable": true,
+ "description": "indicates if the parameter is optional, if omitted, the parameter is mandatory"
+ }
+ ],
+ "apiMethod": "org.onap.policy.apex.model.modelapi.ApexEditorAPI.createEventPar",
+ "description": "Create an event parameter."
+ },
+ {
+ "name": "listEventPar",
+ "keywordlist": [
+ "event",
+ "parameter",
+ "list"
+ ],
+ "argumentList": [
+ {
+ "argumentName": "name",
+ "nullable": false,
+ "description": "name of the event"
+ },
+ {
+ "argumentName": "version",
+ "nullable": true,
+ "description": "version of the event, omit to list latest version"
+ },
+ {
+ "argumentName": "parName",
+ "nullable": true,
+ "description": "name of the parameter, omit to list all parameters of the event"
+ }
+ ],
+ "apiMethod": "org.onap.policy.apex.model.modelapi.ApexEditorAPI.listEventPar",
+ "description": "List event parameters."
+ },
+ {
+ "name": "deleteEventPar",
+ "keywordlist": [
+ "event",
+ "parameter",
+ "delete"
+ ],
+ "argumentList": [
+ {
+ "argumentName": "name",
+ "nullable": false,
+ "description": "name of the event"
+ },
+ {
+ "argumentName": "version",
+ "nullable": true,
+ "description": "version of the event, omit to use the latest version"
+ },
+ {
+ "argumentName": "parName",
+ "nullable": true,
+ "description": "of the parameter, omit to delete all parameters"
+ }
+ ],
+ "apiMethod": "org.onap.policy.apex.model.modelapi.ApexEditorAPI.deleteEventPar",
+ "description": "Delete an event parameter."
+ },
+ {
+ "name": "createAlbum",
+ "keywordlist": [
+ "album",
+ "create"
+ ],
+ "argumentList": [
+ {
+ "argumentName": "name",
+ "nullable": false,
+ "description": "name of the context album"
+ },
+ {
+ "argumentName": "version",
+ "nullable": true,
+ "description": "version of the context album, omit to use the default version"
+ },
+ {
+ "argumentName": "scope",
+ "nullable": false,
+ "description": "scope of application of the context album"
+ },
+ {
+ "argumentName": "writable",
+ "nullable": false,
+ "description": "true if the album is writable, false otherwise, album defaults to writable if omitted"
+ },
+ {
+ "argumentName": "schemaName",
+ "nullable": false,
+ "description": "name of the album schema"
+ },
+ {
+ "argumentName": "schemaVersion",
+ "nullable": true,
+ "description": "version of the album schema, omit to use the latest version"
+ },
+ {
+ "argumentName": "uuid",
+ "nullable": true,
+ "description": "context album UUID, omit to generate a UUID"
+ },
+ {
+ "argumentName": "description",
+ "nullable": true,
+ "description": "album description, omit to generate a description"
+ }
+ ],
+ "apiMethod": "org.onap.policy.apex.model.modelapi.ApexEditorAPI.createContextAlbum",
+ "description": "Create a context album."
+ },
+ {
+ "name": "updateAlbum",
+ "keywordlist": [
+ "album",
+ "update"
+ ],
+ "argumentList": [
+ {
+ "argumentName": "name",
+ "nullable": false,
+ "description": "name of the context album"
+ },
+ {
+ "argumentName": "version",
+ "nullable": true,
+ "description": "version of the context album, omit to use the latest version"
+ },
+ {
+ "argumentName": "scope",
+ "nullable": false,
+ "description": "scope of application of the context album"
+ },
+ {
+ "argumentName": "writable",
+ "nullable": false,
+ "description": "true if the album is writable, false otherwise, album defaults to writable if omitted"
+ },
+ {
+ "argumentName": "schemaName",
+ "nullable": false,
+ "description": "name of the album schema"
+ },
+ {
+ "argumentName": "schemaVersion",
+ "nullable": true,
+ "description": "version of the album schema, omit to use the latest version"
+ },
+ {
+ "argumentName": "uuid",
+ "nullable": true,
+ "description": "context album UUID, omit to not update"
+ },
+ {
+ "argumentName": "description",
+ "nullable": true,
+ "description": "album description, omit to not update"
+ }
+ ],
+ "apiMethod": "org.onap.policy.apex.model.modelapi.ApexEditorAPI.updateContextAlbum",
+ "description": "Update a context album."
+ },
+ {
+ "name": "listAlbum",
+ "keywordlist": [
+ "album",
+ "list"
+ ],
+ "argumentList": [
+ {
+ "argumentName": "name",
+ "nullable": true,
+ "description": "name of the context album, omit to list all"
+ },
+ {
+ "argumentName": "version",
+ "nullable": true,
+ "description": "starting version of the context album, omit to list all versions"
+ }
+ ],
+ "apiMethod": "org.onap.policy.apex.model.modelapi.ApexEditorAPI.listContextAlbum",
+ "description": "List context albums."
+ },
+ {
+ "name": "deleteAlbum",
+ "keywordlist": [
+ "album",
+ "delete"
+ ],
+ "argumentList": [
+ {
+ "argumentName": "name",
+ "nullable": false,
+ "description": "name of the context album"
+ },
+ {
+ "argumentName": "version",
+ "nullable": true,
+ "description": "version of the context album, omit to delete versions"
+ }
+ ],
+ "apiMethod": "org.onap.policy.apex.model.modelapi.ApexEditorAPI.deleteContextAlbum",
+ "description": "Delete a context album."
+ },
+ {
+ "name": "validateAlbum",
+ "keywordlist": [
+ "album",
+ "validate"
+ ],
+ "argumentList": [
+ {
+ "argumentName": "name",
+ "nullable": true,
+ "description": "name of the context album, omit to list all"
+ },
+ {
+ "argumentName": "version",
+ "nullable": true,
+ "description": "starting version of the context album, omit to list all versions"
+ }
+ ],
+ "apiMethod": "org.onap.policy.apex.model.modelapi.ApexEditorAPI.validateContextAlbum",
+ "description": "Validate context albums."
+ },
+ {
+ "name": "createTask",
+ "keywordlist": [
+ "task",
+ "create"
+ ],
+ "argumentList": [
+ {
+ "argumentName": "name",
+ "nullable": false,
+ "description": "name of the task"
+ },
+ {
+ "argumentName": "version",
+ "nullable": true,
+ "description": "version of the task, omit to use the default version"
+ },
+ {
+ "argumentName": "uuid",
+ "nullable": true,
+ "description": "task UUID, omit to generate a UUID"
+ },
+ {
+ "argumentName": "description",
+ "nullable": true,
+ "description": "task description, omit to generate a description"
+ }
+ ],
+ "apiMethod": "org.onap.policy.apex.model.modelapi.ApexEditorAPI.createTask",
+ "description": "Create a task."
+ },
+ {
+ "name": "updateTask",
+ "keywordlist": [
+ "task",
+ "update"
+ ],
+ "argumentList": [
+ {
+ "argumentName": "name",
+ "nullable": false,
+ "description": "name of the task"
+ },
+ {
+ "argumentName": "version",
+ "nullable": true,
+ "description": "version of the task, omit to use the latest version"
+ },
+ {
+ "argumentName": "uuid",
+ "nullable": true,
+ "description": "task UUID, omit to not update"
+ },
+ {
+ "argumentName": "description",
+ "nullable": true,
+ "description": "task description, omit to not update"
+ }
+ ],
+ "apiMethod": "org.onap.policy.apex.model.modelapi.ApexEditorAPI.updateTask",
+ "description": "Update a task."
+ },
+ {
+ "name": "listTask",
+ "keywordlist": [
+ "task",
+ "list"
+ ],
+ "argumentList": [
+ {
+ "argumentName": "name",
+ "nullable": true,
+ "description": "name of the task, omit to list all"
+ },
+ {
+ "argumentName": "version",
+ "nullable": true,
+ "description": "starting version of the task, omit to list all versions"
+ }
+ ],
+ "apiMethod": "org.onap.policy.apex.model.modelapi.ApexEditorAPI.listTask",
+ "description": "List tasks."
+ },
+ {
+ "name": "deleteTask",
+ "keywordlist": [
+ "task",
+ "delete"
+ ],
+ "argumentList": [
+ {
+ "argumentName": "name",
+ "nullable": false,
+ "description": "name of the task"
+ },
+ {
+ "argumentName": "version",
+ "nullable": true,
+ "description": "version of the task, omit to use the latest version"
+ }
+ ],
+ "apiMethod": "org.onap.policy.apex.model.modelapi.ApexEditorAPI.deleteTask",
+ "description": "Delete a task."
+ },
+ {
+ "name": "validateTask",
+ "keywordlist": [
+ "task",
+ "validate"
+ ],
+ "argumentList": [
+ {
+ "argumentName": "name",
+ "nullable": true,
+ "description": "name of the task, omit to list all"
+ },
+ {
+ "argumentName": "version",
+ "nullable": true,
+ "description": "starting version of the task, omit to list all versions"
+ }
+ ],
+ "apiMethod": "org.onap.policy.apex.model.modelapi.ApexEditorAPI.validateTask",
+ "description": "Validate tasks."
+ },
+ {
+ "name": "createTaskLogic",
+ "keywordlist": [
+ "task",
+ "logic",
+ "create"
+ ],
+ "argumentList": [
+ {
+ "argumentName": "name",
+ "nullable": false,
+ "description": "name of the task"
+ },
+ {
+ "argumentName": "version",
+ "nullable": true,
+ "description": "version of the task, omit to use the latest version"
+ },
+ {
+ "argumentName": "logicFlavour",
+ "nullable": true,
+ "description": "the task logic flavour for the task, omit to use the default task logic flavour"
+ },
+ {
+ "argumentName": "logic",
+ "nullable": false,
+ "description": "the source code for the logic of the task"
+ }
+ ],
+ "apiMethod": "org.onap.policy.apex.model.modelapi.ApexEditorAPI.createTaskLogic",
+ "description": "Create logic for a task."
+ },
+ {
+ "name": "updateTaskLogic",
+ "keywordlist": [
+ "task",
+ "logic",
+ "update"
+ ],
+ "argumentList": [
+ {
+ "argumentName": "name",
+ "nullable": false,
+ "description": "name of the task"
+ },
+ {
+ "argumentName": "version",
+ "nullable": true,
+ "description": "version of the task, omit to use the latest version"
+ },
+ {
+ "argumentName": "logicFlavour",
+ "nullable": true,
+ "description": "the task logic flavour for the task, omit to not update"
+ },
+ {
+ "argumentName": "logic",
+ "nullable": true,
+ "description": "the source code for the logic of the task, omit to not update"
+ }
+ ],
+ "apiMethod": "org.onap.policy.apex.model.modelapi.ApexEditorAPI.updateTaskLogic",
+ "description": "Update logic for a task."
+ },
+ {
+ "name": "listTaskLogic",
+ "keywordlist": [
+ "task",
+ "logic",
+ "list"
+ ],
+ "argumentList": [
+ {
+ "argumentName": "name",
+ "nullable": false,
+ "description": "name of the task"
+ },
+ {
+ "argumentName": "version",
+ "nullable": true,
+ "description": "version of the task, omit to list the latest version"
+ }
+ ],
+ "apiMethod": "org.onap.policy.apex.model.modelapi.ApexEditorAPI.listTaskLogic",
+ "description": "List task logic."
+ },
+ {
+ "name": "deleteTaskLogic",
+ "keywordlist": [
+ "task",
+ "logic",
+ "delete"
+ ],
+ "argumentList": [
+ {
+ "argumentName": "name",
+ "nullable": false,
+ "description": "name of the task"
+ },
+ {
+ "argumentName": "version",
+ "nullable": true,
+ "description": "version of the task, omit to use the latest version"
+ }
+ ],
+ "apiMethod": "org.onap.policy.apex.model.modelapi.ApexEditorAPI.deleteTaskLogic",
+ "description": "Delete logic for a task."
+ },
+ {
+ "name": "createTaskInputField",
+ "keywordlist": [
+ "task",
+ "inputfield",
+ "create"
+ ],
+ "argumentList": [
+ {
+ "argumentName": "name",
+ "nullable": false,
+ "description": "name of the task"
+ },
+ {
+ "argumentName": "version",
+ "nullable": true,
+ "description": "version of the task, omit to use the latest version"
+ },
+ {
+ "argumentName": "fieldName",
+ "nullable": false,
+ "description": "of the input field"
+ },
+ {
+ "argumentName": "schemaName",
+ "nullable": false,
+ "description": "name of the input field schema"
+ },
+ {
+ "argumentName": "schemaVersion",
+ "nullable": true,
+ "description": "version of the input field schema, omit to use the latest version"
+ },
+ {
+ "argumentName": "optional",
+ "nullable": true,
+ "description": "indicates if the field is optional, if omitted, the field is mandatory"
+ }
+ ],
+ "apiMethod": "org.onap.policy.apex.model.modelapi.ApexEditorAPI.createTaskInputField",
+ "description": "Create a task input field."
+ },
+ {
+ "name": "listTaskInputField",
+ "keywordlist": [
+ "task",
+ "inputfield",
+ "list"
+ ],
+ "argumentList": [
+ {
+ "argumentName": "name",
+ "nullable": false,
+ "description": "name of the task"
+ },
+ {
+ "argumentName": "version",
+ "nullable": true,
+ "description": "version of the task, omit to use the latest version"
+ },
+ {
+ "argumentName": "fieldName",
+ "nullable": true,
+ "description": "field name of the input field, omit to list all input fields of the task"
+ }
+ ],
+ "apiMethod": "org.onap.policy.apex.model.modelapi.ApexEditorAPI.listTaskInputField",
+ "description": "List task input fields."
+ },
+ {
+ "name": "deleteTaskInputField",
+ "keywordlist": [
+ "task",
+ "inputfield",
+ "delete"
+ ],
+ "argumentList": [
+ {
+ "argumentName": "name",
+ "nullable": false,
+ "description": "name of the task"
+ },
+ {
+ "argumentName": "version",
+ "nullable": true,
+ "description": "version of the task, omit to use the latest version"
+ },
+ {
+ "argumentName": "fieldName",
+ "nullable": true,
+ "description": "of the input field, omit to delete all input fields"
+ }
+ ],
+ "apiMethod": "org.onap.policy.apex.model.modelapi.ApexEditorAPI.deleteTaskInputField",
+ "description": "Delete a task input field."
+ },
+ {
+ "name": "createTaskOutputField",
+ "keywordlist": [
+ "task",
+ "outputfield",
+ "create"
+ ],
+ "argumentList": [
+ {
+ "argumentName": "name",
+ "nullable": false,
+ "description": "name of the task"
+ },
+ {
+ "argumentName": "version",
+ "nullable": true,
+ "description": "version of the task, omit to use the latest version"
+ },
+ {
+ "argumentName": "fieldName",
+ "nullable": false,
+ "description": "of the output field"
+ },
+ {
+ "argumentName": "schemaName",
+ "nullable": false,
+ "description": "name of the output field schema"
+ },
+ {
+ "argumentName": "schemaVersion",
+ "nullable": true,
+ "description": "version of the output field schema, omit to use the latest version"
+ },
+ {
+ "argumentName": "optional",
+ "nullable": true,
+ "description": "indicates if the field is optional, if omitted, the field is mandatory"
+ }
+ ],
+ "apiMethod": "org.onap.policy.apex.model.modelapi.ApexEditorAPI.createTaskOutputField",
+ "description": "Create a task output field."
+ },
+ {
+ "name": "listTaskOutputField",
+ "keywordlist": [
+ "task",
+ "outputfield",
+ "list"
+ ],
+ "argumentList": [
+ {
+ "argumentName": "name",
+ "nullable": false,
+ "description": "name of the task"
+ },
+ {
+ "argumentName": "version",
+ "nullable": true,
+ "description": "version of the task, omit to use the latest version"
+ },
+ {
+ "argumentName": "fieldName",
+ "nullable": true,
+ "description": "field name of the output field, omit to list all output fields of the task"
+ }
+ ],
+ "apiMethod": "org.onap.policy.apex.model.modelapi.ApexEditorAPI.listTaskOutputField",
+ "description": "List task output fields."
+ },
+ {
+ "name": "deleteTaskOutputField",
+ "keywordlist": [
+ "task",
+ "outputfield",
+ "delete"
+ ],
+ "argumentList": [
+ {
+ "argumentName": "name",
+ "nullable": false,
+ "description": "name of the task"
+ },
+ {
+ "argumentName": "version",
+ "nullable": true,
+ "description": "version of the task, omit to use the latest version"
+ },
+ {
+ "argumentName": "fieldName",
+ "nullable": true,
+ "description": "of the output field, omit to delete all output fields"
+ }
+ ],
+ "apiMethod": "org.onap.policy.apex.model.modelapi.ApexEditorAPI.deleteTaskOutputField",
+ "description": "Delete a task output field."
+ },
+ {
+ "name": "createTaskParameter",
+ "keywordlist": [
+ "task",
+ "parameter",
+ "create"
+ ],
+ "argumentList": [
+ {
+ "argumentName": "name",
+ "nullable": false,
+ "description": "name of the task"
+ },
+ {
+ "argumentName": "version",
+ "nullable": true,
+ "description": "version of the task, omit to use the latest version"
+ },
+ {
+ "argumentName": "parName",
+ "nullable": false,
+ "description": "of the parameter"
+ },
+ {
+ "argumentName": "defaultValue",
+ "nullable": false,
+ "description": "of the parameter"
+ }
+ ],
+ "apiMethod": "org.onap.policy.apex.model.modelapi.ApexEditorAPI.createTaskParameter",
+ "description": "Create a task parameter."
+ },
+ {
+ "name": "listTaskParameter",
+ "keywordlist": [
+ "task",
+ "parameter",
+ "list"
+ ],
+ "argumentList": [
+ {
+ "argumentName": "name",
+ "nullable": false,
+ "description": "name of the task"
+ },
+ {
+ "argumentName": "version",
+ "nullable": true,
+ "description": "version of the task, omit to use the latest version"
+ },
+ {
+ "argumentName": "parName",
+ "nullable": true,
+ "description": "name of the parameter, omit to list all parameters of the task"
+ }
+ ],
+ "apiMethod": "org.onap.policy.apex.model.modelapi.ApexEditorAPI.listTaskParameter",
+ "description": "List task parameters."
+ },
+ {
+ "name": "deleteTaskParameter",
+ "keywordlist": [
+ "task",
+ "parameter",
+ "delete"
+ ],
+ "argumentList": [
+ {
+ "argumentName": "name",
+ "nullable": false,
+ "description": "name of the task"
+ },
+ {
+ "argumentName": "version",
+ "nullable": true,
+ "description": "version of the task, omit to use the latest version"
+ },
+ {
+ "argumentName": "parName",
+ "nullable": true,
+ "description": "of the parameter, omit to delete all task parameters"
+ }
+ ],
+ "apiMethod": "org.onap.policy.apex.model.modelapi.ApexEditorAPI.deleteTaskParameter",
+ "description": "Delete a task parameter."
+ },
+ {
+ "name": "createTaskContextRef",
+ "keywordlist": [
+ "task",
+ "contextref",
+ "create"
+ ],
+ "argumentList": [
+ {
+ "argumentName": "name",
+ "nullable": false,
+ "description": "name of the task"
+ },
+ {
+ "argumentName": "version",
+ "nullable": true,
+ "description": "version of the task, omit to use the latest version"
+ },
+ {
+ "argumentName": "albumName",
+ "nullable": false,
+ "description": "name of the context album for the context reference"
+ },
+ {
+ "argumentName": "albumVersion",
+ "nullable": true,
+ "description": "version of the context album for the context reference, omit to use the latest version"
+ }
+ ],
+ "apiMethod": "org.onap.policy.apex.model.modelapi.ApexEditorAPI.createTaskContextRef",
+ "description": "Create a task context reference."
+ },
+ {
+ "name": "listTaskContextRef",
+ "keywordlist": [
+ "task",
+ "contextref",
+ "list"
+ ],
+ "argumentList": [
+ {
+ "argumentName": "name",
+ "nullable": false,
+ "description": "name of the task"
+ },
+ {
+ "argumentName": "version",
+ "nullable": true,
+ "description": "version of the task, omit to use the latest version"
+ },
+ {
+ "argumentName": "albumName",
+ "nullable": true,
+ "description": "name of the context album for the context reference, omit to list all task context references"
+ },
+ {
+ "argumentName": "albumVersion",
+ "nullable": true,
+ "description": "version of the context album for the context reference, omit to use the latest version"
+ }
+ ],
+ "apiMethod": "org.onap.policy.apex.model.modelapi.ApexEditorAPI.listTaskContextRef",
+ "description": "List task context references."
+ },
+ {
+ "name": "deleteTaskContextRef",
+ "keywordlist": [
+ "task",
+ "contextref",
+ "delete"
+ ],
+ "argumentList": [
+ {
+ "argumentName": "name",
+ "nullable": false,
+ "description": "name of the task"
+ },
+ {
+ "argumentName": "version",
+ "nullable": true,
+ "description": "version of the task, omit to use the latest version"
+ },
+ {
+ "argumentName": "albumName",
+ "nullable": true,
+ "description": "name of the context album for the context reference, omit to delete all task context references"
+ },
+ {
+ "argumentName": "albumVersion",
+ "nullable": true,
+ "description": "version of the context album for the context reference, omit to use the latest version"
+ }
+ ],
+ "apiMethod": "org.onap.policy.apex.model.modelapi.ApexEditorAPI.deleteTaskContextRef",
+ "description": "Delete a task context reference."
+ },
+ {
+ "name": "createPolicy",
+ "keywordlist": [
+ "policy",
+ "create"
+ ],
+ "argumentList": [
+ {
+ "argumentName": "name",
+ "nullable": false,
+ "description": "name of the policy"
+ },
+ {
+ "argumentName": "version",
+ "nullable": true,
+ "description": "version of the policy, omit to use the default version"
+ },
+ {
+ "argumentName": "template",
+ "nullable": true,
+ "description": "template used to create the policy, omit to use the default template"
+ },
+ {
+ "argumentName": "firstState",
+ "nullable": false,
+ "description": "the first state of the policy"
+ },
+ {
+ "argumentName": "uuid",
+ "nullable": true,
+ "description": "policy UUID, omit to generate a UUID"
+ },
+ {
+ "argumentName": "description",
+ "nullable": true,
+ "description": "policy description, omit to generate a description"
+ }
+ ],
+ "apiMethod": "org.onap.policy.apex.model.modelapi.ApexEditorAPI.createPolicy",
+ "description": "Create a policy."
+ },
+ {
+ "name": "updatePolicy",
+ "keywordlist": [
+ "policy",
+ "update"
+ ],
+ "argumentList": [
+ {
+ "argumentName": "name",
+ "nullable": false,
+ "description": "name of the policy"
+ },
+ {
+ "argumentName": "version",
+ "nullable": true,
+ "description": "version of the policy, omit to use the latest version"
+ },
+ {
+ "argumentName": "template",
+ "nullable": true,
+ "description": "template used to create the policy, omit to not update"
+ },
+ {
+ "argumentName": "firstState",
+ "nullable": false,
+ "description": "the first state of the policy"
+ },
+ {
+ "argumentName": "uuid",
+ "nullable": true,
+ "description": "policy UUID, omit to not update"
+ },
+ {
+ "argumentName": "description",
+ "nullable": true,
+ "description": "policy description, omit to not update"
+ }
+ ],
+ "apiMethod": "org.onap.policy.apex.model.modelapi.ApexEditorAPI.updatePolicy",
+ "description": "Update a policy."
+ },
+ {
+ "name": "listPolicy",
+ "keywordlist": [
+ "policy",
+ "list"
+ ],
+ "argumentList": [
+ {
+ "argumentName": "name",
+ "nullable": true,
+ "description": "name of the policy, omit to list all"
+ },
+ {
+ "argumentName": "version",
+ "nullable": true,
+ "description": "starting version of the policy, omit to list all versions"
+ }
+ ],
+ "apiMethod": "org.onap.policy.apex.model.modelapi.ApexEditorAPI.listPolicy",
+ "description": "List policies."
+ },
+ {
+ "name": "deletePolicy",
+ "keywordlist": [
+ "policy",
+ "delete"
+ ],
+ "argumentList": [
+ {
+ "argumentName": "name",
+ "nullable": false,
+ "description": "name of the policy"
+ },
+ {
+ "argumentName": "version",
+ "nullable": true,
+ "description": "version of the policy, omit to use the latest version"
+ }
+ ],
+ "apiMethod": "org.onap.policy.apex.model.modelapi.ApexEditorAPI.deletePolicy",
+ "description": "Delete a policy."
+ },
+ {
+ "name": "validatePolicy",
+ "keywordlist": [
+ "policy",
+ "validate"
+ ],
+ "argumentList": [
+ {
+ "argumentName": "name",
+ "nullable": true,
+ "description": "name of the policy, omit to list all"
+ },
+ {
+ "argumentName": "version",
+ "nullable": true,
+ "description": "starting version of the policy, omit to list all versions"
+ }
+ ],
+ "apiMethod": "org.onap.policy.apex.model.modelapi.ApexEditorAPI.validatePolicy",
+ "description": "Validate policies."
+ },
+ {
+ "name": "createPolicyState",
+ "keywordlist": [
+ "policy",
+ "state",
+ "create"
+ ],
+ "argumentList": [
+ {
+ "argumentName": "name",
+ "nullable": false,
+ "description": "name of the policy"
+ },
+ {
+ "argumentName": "version",
+ "nullable": true,
+ "description": "version of the policy, omit to use the latest version"
+ },
+ {
+ "argumentName": "stateName",
+ "nullable": false,
+ "description": "of the state"
+ },
+ {
+ "argumentName": "triggerName",
+ "nullable": false,
+ "description": "name of the trigger event for this state"
+ },
+ {
+ "argumentName": "triggerVersion",
+ "nullable": true,
+ "description": "version of the trigger event for this state, omit to use the latest version"
+ },
+ {
+ "argumentName": "defaultTaskName",
+ "nullable": false,
+ "description": "the default task name"
+ },
+ {
+ "argumentName": "defaultTaskVersion",
+ "nullable": true,
+ "description": "the default task version, omit to use the latest version"
+ }
+ ],
+ "apiMethod": "org.onap.policy.apex.model.modelapi.ApexEditorAPI.createPolicyState",
+ "description": "Create a policy state."
+ },
+ {
+ "name": "updatePolicyState",
+ "keywordlist": [
+ "policy",
+ "state",
+ "update"
+ ],
+ "argumentList": [
+ {
+ "argumentName": "name",
+ "nullable": false,
+ "description": "name of the policy"
+ },
+ {
+ "argumentName": "version",
+ "nullable": true,
+ "description": "version of the policy, omit to use the latest version"
+ },
+ {
+ "argumentName": "stateName",
+ "nullable": false,
+ "description": "of the state"
+ },
+ {
+ "argumentName": "triggerName",
+ "nullable": true,
+ "description": "name of the trigger event for this state, omit to not update"
+ },
+ {
+ "argumentName": "triggerVersion",
+ "nullable": false,
+ "description": "version of the trigger event for this state, set to use latest version of trigger event"
+ },
+ {
+ "argumentName": "defaultTaskName",
+ "nullable": true,
+ "description": "the default task name, omit to not update"
+ },
+ {
+ "argumentName": "defaultTaskVersion",
+ "nullable": false,
+ "description": "the default task version, set to use latest version of default task"
+ }
+ ],
+ "apiMethod": "org.onap.policy.apex.model.modelapi.ApexEditorAPI.updatePolicyState",
+ "description": "Update a policy state."
+ },
+ {
+ "name": "listPolicyState",
+ "keywordlist": [
+ "policy",
+ "state",
+ "list"
+ ],
+ "argumentList": [
+ {
+ "argumentName": "name",
+ "nullable": false,
+ "description": "name of the policy"
+ },
+ {
+ "argumentName": "version",
+ "nullable": true,
+ "description": "version of the policy, omit to use the latest version"
+ },
+ {
+ "argumentName": "stateName",
+ "nullable": true,
+ "description": "of the state, omit to list all states of the policy"
+ }
+ ],
+ "apiMethod": "org.onap.policy.apex.model.modelapi.ApexEditorAPI.listPolicyState",
+ "description": "List policy states."
+ },
+ {
+ "name": "deletePolicyState",
+ "keywordlist": [
+ "policy",
+ "state",
+ "delete"
+ ],
+ "argumentList": [
+ {
+ "argumentName": "name",
+ "nullable": false,
+ "description": "name of the policy"
+ },
+ {
+ "argumentName": "version",
+ "nullable": true,
+ "description": "version of the policy, omit to use the latest version"
+ },
+ {
+ "argumentName": "stateName",
+ "nullable": true,
+ "description": "of the state, omit to delete all states"
+ }
+ ],
+ "apiMethod": "org.onap.policy.apex.model.modelapi.ApexEditorAPI.deletePolicyState",
+ "description": "Delete a policy state."
+ },
+ {
+ "name": "createPolicyStateTaskSelectionLogic",
+ "keywordlist": [
+ "policy",
+ "state",
+ "selecttasklogic",
+ "create"
+ ],
+ "argumentList": [
+ {
+ "argumentName": "name",
+ "nullable": false,
+ "description": "name of the policy"
+ },
+ {
+ "argumentName": "version",
+ "nullable": true,
+ "description": "version of the policy, omit to use the latest version"
+ },
+ {
+ "argumentName": "stateName",
+ "nullable": false,
+ "description": "of the state"
+ },
+ {
+ "argumentName": "logicFlavour",
+ "nullable": true,
+ "description": "the task selection logic flavour for the state, omit to use the default task logic flavour"
+ },
+ {
+ "argumentName": "logic",
+ "nullable": false,
+ "description": "the source code for the logic of the state"
+ }
+ ],
+ "apiMethod": "org.onap.policy.apex.model.modelapi.ApexEditorAPI.createPolicyStateTaskSelectionLogic",
+ "description": "Create task selection logic for a state."
+ },
+ {
+ "name": "updatePolicyStateTaskSelectionLogic",
+ "keywordlist": [
+ "policy",
+ "state",
+ "selecttasklogic",
+ "update"
+ ],
+ "argumentList": [
+ {
+ "argumentName": "name",
+ "nullable": false,
+ "description": "name of the policy"
+ },
+ {
+ "argumentName": "version",
+ "nullable": true,
+ "description": "version of the policy, omit to use the latest version"
+ },
+ {
+ "argumentName": "stateName",
+ "nullable": false,
+ "description": "of the state"
+ },
+ {
+ "argumentName": "logicFlavour",
+ "nullable": true,
+ "description": "the task selection logic flavour for the state, omit to not update"
+ },
+ {
+ "argumentName": "logic",
+ "nullable": true,
+ "description": "the source code for the logic of the state, omit to not update"
+ }
+ ],
+ "apiMethod": "org.onap.policy.apex.model.modelapi.ApexEditorAPI.updatePolicyStateTaskSelectionLogic",
+ "description": "Update task selection logic for a state."
+ },
+ {
+ "name": "listPolicyStateTaskSelectionLogic",
+ "keywordlist": [
+ "policy",
+ "state",
+ "selecttasklogic",
+ "list"
+ ],
+ "argumentList": [
+ {
+ "argumentName": "name",
+ "nullable": false,
+ "description": "name of the policy"
+ },
+ {
+ "argumentName": "version",
+ "nullable": true,
+ "description": "version of the policy, omit to use the latest version"
+ },
+ {
+ "argumentName": "stateName",
+ "nullable": false,
+ "description": "of the state"
+ }
+ ],
+ "apiMethod": "org.onap.policy.apex.model.modelapi.ApexEditorAPI.listPolicyStateTaskSelectionLogic",
+ "description": "List task selection logic for a state."
+ },
+ {
+ "name": "deletePolicyStateTaskSelectionLogic",
+ "keywordlist": [
+ "policy",
+ "state",
+ "selecttasklogic",
+ "delete"
+ ],
+ "argumentList": [
+ {
+ "argumentName": "name",
+ "nullable": false,
+ "description": "name of the policy"
+ },
+ {
+ "argumentName": "version",
+ "nullable": true,
+ "description": "version of the policy, omit to use the latest version"
+ },
+ {
+ "argumentName": "stateName",
+ "nullable": false,
+ "description": "of the state"
+ }
+ ],
+ "apiMethod": "org.onap.policy.apex.model.modelapi.ApexEditorAPI.deletePolicyStateTaskSelectionLogic",
+ "description": "Delete task selection logic for a state."
+ },
+ {
+ "name": "createPolicyStateOutput",
+ "keywordlist": [
+ "policy",
+ "state",
+ "output",
+ "create"
+ ],
+ "argumentList": [
+ {
+ "argumentName": "name",
+ "nullable": false,
+ "description": "name of the policy"
+ },
+ {
+ "argumentName": "version",
+ "nullable": true,
+ "description": "version of the policy, omit to use the latest version"
+ },
+ {
+ "argumentName": "stateName",
+ "nullable": false,
+ "description": "of the state"
+ },
+ {
+ "argumentName": "outputName",
+ "nullable": false,
+ "description": "of the state output"
+ },
+ {
+ "argumentName": "eventName",
+ "nullable": false,
+ "description": "name of the output event for this state output"
+ },
+ {
+ "argumentName": "eventVersion",
+ "nullable": true,
+ "description": "version of the output event for this state output, omit to use the latest version"
+ },
+ {
+ "argumentName": "nextState",
+ "nullable": true,
+ "description": "for this state to transition to, omit if this is the last state that the policy transitions to on this branch"
+ }
+ ],
+ "apiMethod": "org.onap.policy.apex.model.modelapi.ApexEditorAPI.createPolicyStateOutput",
+ "description": "Create a policy state output."
+ },
+ {
+ "name": "listPolicyStateOutput",
+ "keywordlist": [
+ "policy",
+ "state",
+ "output",
+ "list"
+ ],
+ "argumentList": [
+ {
+ "argumentName": "name",
+ "nullable": false,
+ "description": "name of the policy"
+ },
+ {
+ "argumentName": "version",
+ "nullable": true,
+ "description": "version of the policy, omit to use the latest version"
+ },
+ {
+ "argumentName": "stateName",
+ "nullable": false,
+ "description": "of the state"
+ },
+ {
+ "argumentName": "outputName",
+ "nullable": true,
+ "description": "of the state output, omit to list all outputs of the state"
+ }
+ ],
+ "apiMethod": "org.onap.policy.apex.model.modelapi.ApexEditorAPI.listPolicyStateOutput",
+ "description": "List policy state outputs."
+ },
+ {
+ "name": "deletePolicyStateOutput",
+ "keywordlist": [
+ "policy",
+ "state",
+ "output",
+ "delete"
+ ],
+ "argumentList": [
+ {
+ "argumentName": "name",
+ "nullable": false,
+ "description": "name of the policy"
+ },
+ {
+ "argumentName": "version",
+ "nullable": true,
+ "description": "version of the policy, omit to use the latest version"
+ },
+ {
+ "argumentName": "stateName",
+ "nullable": false,
+ "description": "of the state"
+ },
+ {
+ "argumentName": "outputName",
+ "nullable": true,
+ "description": "of the state output, omit to delete all state outputs"
+ }
+ ],
+ "apiMethod": "org.onap.policy.apex.model.modelapi.ApexEditorAPI.deletePolicyStateOutput",
+ "description": "Delete a policy state output."
+ },
+ {
+ "name": "createPolicyStateFinalizerLogic",
+ "keywordlist": [
+ "policy",
+ "state",
+ "finalizerlogic",
+ "create"
+ ],
+ "argumentList": [
+ {
+ "argumentName": "name",
+ "nullable": false,
+ "description": "name of the policy"
+ },
+ {
+ "argumentName": "version",
+ "nullable": true,
+ "description": "version of the policy, omit to use the latest version"
+ },
+ {
+ "argumentName": "stateName",
+ "nullable": false,
+ "description": "of the state"
+ },
+ {
+ "argumentName": "finalizerLogicName",
+ "nullable": false,
+ "description": "name of the state finalizer logic"
+ },
+ {
+ "argumentName": "logicFlavour",
+ "nullable": true,
+ "description": "the policy finalizer logic flavour for the state, omit to use the default task logic flavour"
+ },
+ {
+ "argumentName": "logic",
+ "nullable": false,
+ "description": "the source code for the logic of the state"
+ }
+ ],
+ "apiMethod": "org.onap.policy.apex.model.modelapi.ApexEditorAPI.createPolicyStateFinalizerLogic",
+ "description": "Create policy finalizer logic for a state."
+ },
+ {
+ "name": "updatePolicyStateFinalizerLogic",
+ "keywordlist": [
+ "policy",
+ "state",
+ "finalizerlogic",
+ "update"
+ ],
+ "argumentList": [
+ {
+ "argumentName": "name",
+ "nullable": false,
+ "description": "name of the policy"
+ },
+ {
+ "argumentName": "version",
+ "nullable": true,
+ "description": "version of the policy, omit to use the latest version"
+ },
+ {
+ "argumentName": "stateName",
+ "nullable": false,
+ "description": "of the state"
+ },
+ {
+ "argumentName": "finalizerLogicName",
+ "nullable": false,
+ "description": "name of the state finalizer logic"
+ },
+ {
+ "argumentName": "logicFlavour",
+ "nullable": true,
+ "description": "the policy finalizer logic flavour for the state, omit to not update"
+ },
+ {
+ "argumentName": "logic",
+ "nullable": true,
+ "description": "the source code for the logic of the state, omit to not update"
+ }
+ ],
+ "apiMethod": "org.onap.policy.apex.model.modelapi.ApexEditorAPI.updatePolicyStateFinalizerLogic",
+ "description": "Update policy finalizer logic for a state."
+ },
+ {
+ "name": "listPolicyStateFinalizerLogic",
+ "keywordlist": [
+ "policy",
+ "state",
+ "finalizerlogic",
+ "list"
+ ],
+ "argumentList": [
+ {
+ "argumentName": "name",
+ "nullable": false,
+ "description": "name of the policy"
+ },
+ {
+ "argumentName": "version",
+ "nullable": true,
+ "description": "version of the policy, omit to use the latest version"
+ },
+ {
+ "argumentName": "stateName",
+ "nullable": false,
+ "description": "of the state"
+ },
+ {
+ "argumentName": "finalizerLogicName",
+ "nullable": false,
+ "description": "name of the state finalizer logic"
+ }
+ ],
+ "apiMethod": "org.onap.policy.apex.model.modelapi.ApexEditorAPI.listPolicyStateFinalizerLogic",
+ "description": "List policy finalizer logic for a state."
+ },
+ {
+ "name": "deletePolicyStateFinalizerLogic",
+ "keywordlist": [
+ "policy",
+ "state",
+ "finalizerlogic",
+ "delete"
+ ],
+ "argumentList": [
+ {
+ "argumentName": "name",
+ "nullable": false,
+ "description": "name of the policy"
+ },
+ {
+ "argumentName": "version",
+ "nullable": true,
+ "description": "version of the policy, omit to use the latest version"
+ },
+ {
+ "argumentName": "stateName",
+ "nullable": false,
+ "description": "of the state"
+ },
+ {
+ "argumentName": "finalizerLogicName",
+ "nullable": false,
+ "description": "name of the state finalizer logic"
+ }
+ ],
+ "apiMethod": "org.onap.policy.apex.model.modelapi.ApexEditorAPI.deletePolicyStateFinalizerLogic",
+ "description": "Delete policy finalizer logic for a state."
+ },
+ {
+ "name": "createPolicyStateTaskRef",
+ "keywordlist": [
+ "policy",
+ "state",
+ "taskref",
+ "create"
+ ],
+ "argumentList": [
+ {
+ "argumentName": "name",
+ "nullable": false,
+ "description": "name of the policy"
+ },
+ {
+ "argumentName": "version",
+ "nullable": true,
+ "description": "version of the policy, omit to use the latest version"
+ },
+ {
+ "argumentName": "stateName",
+ "nullable": false,
+ "description": "of the state"
+ },
+ {
+ "argumentName": "taskLocalName",
+ "nullable": true,
+ "description": "local name of the task in the state, omit to use the task name"
+ },
+ {
+ "argumentName": "taskName",
+ "nullable": false,
+ "description": "name of the task"
+ },
+ {
+ "argumentName": "taskVersion",
+ "nullable": true,
+ "description": "version of the task, omit to use the latest version"
+ },
+ {
+ "argumentName": "outputType",
+ "nullable": false,
+ "description": "Type of output for the task, must be DIRECT for direct output to a state output or LOGIC for output to state finalizer logic"
+ },
+ {
+ "argumentName": "outputName",
+ "nullable": false,
+ "description": "the name of the state output or state state finalizer logic to handle the task output"
+ }
+ ],
+ "apiMethod": "org.onap.policy.apex.model.modelapi.ApexEditorAPI.createPolicyStateTaskRef",
+ "description": "Create a policy state task reference."
+ },
+ {
+ "name": "listPolicyStateTaskRef",
+ "keywordlist": [
+ "policy",
+ "state",
+ "taskref",
+ "list"
+ ],
+ "argumentList": [
+ {
+ "argumentName": "name",
+ "nullable": false,
+ "description": "name of the policy"
+ },
+ {
+ "argumentName": "version",
+ "nullable": true,
+ "description": "version of the policy, omit to use the latest version"
+ },
+ {
+ "argumentName": "stateName",
+ "nullable": false,
+ "description": "of the state"
+ },
+ {
+ "argumentName": "taskName",
+ "nullable": true,
+ "description": "name of the task, omit to list all task references"
+ },
+ {
+ "argumentName": "taskVersion",
+ "nullable": true,
+ "description": "version of the task, omit to use the latest version"
+ }
+ ],
+ "apiMethod": "org.onap.policy.apex.model.modelapi.ApexEditorAPI.listPolicyStateTaskRef",
+ "description": "List policy state task references."
+ },
+ {
+ "name": "deletePolicyStateTaskRef",
+ "keywordlist": [
+ "policy",
+ "state",
+ "taskref",
+ "delete"
+ ],
+ "argumentList": [
+ {
+ "argumentName": "name",
+ "nullable": false,
+ "description": "name of the policy"
+ },
+ {
+ "argumentName": "version",
+ "nullable": true,
+ "description": "version of the policy, omit to use the latest version"
+ },
+ {
+ "argumentName": "stateName",
+ "nullable": false,
+ "description": "of the state"
+ },
+ {
+ "argumentName": "taskName",
+ "nullable": true,
+ "description": "name of the task, omit to delete all task references"
+ },
+ {
+ "argumentName": "taskVersion",
+ "nullable": true,
+ "description": "version of the task, omit to use the latest version"
+ }
+ ],
+ "apiMethod": "org.onap.policy.apex.model.modelapi.ApexEditorAPI.deletePolicyStateTaskRef",
+ "description": "Delete a policy state task reference."
+ },
+ {
+ "name": "createPolicyStateContextRef",
+ "keywordlist": [
+ "policy",
+ "state",
+ "contextref",
+ "create"
+ ],
+ "argumentList": [
+ {
+ "argumentName": "name",
+ "nullable": false,
+ "description": "name of the policy"
+ },
+ {
+ "argumentName": "version",
+ "nullable": true,
+ "description": "version of the policy, omit to use the latest version"
+ },
+ {
+ "argumentName": "stateName",
+ "nullable": false,
+ "description": "of the state"
+ },
+ {
+ "argumentName": "albumName",
+ "nullable": false,
+ "description": "name of the context album for the context reference"
+ },
+ {
+ "argumentName": "albumVersion",
+ "nullable": true,
+ "description": "version of the context album for the context reference, omit to use the latest version"
+ }
+ ],
+ "apiMethod": "org.onap.policy.apex.model.modelapi.ApexEditorAPI.createPolicyStateContextRef",
+ "description": "Create a policy state context reference."
+ },
+ {
+ "name": "listPolicyStateContextRef",
+ "keywordlist": [
+ "policy",
+ "state",
+ "contextref",
+ "list"
+ ],
+ "argumentList": [
+ {
+ "argumentName": "name",
+ "nullable": false,
+ "description": "name of the policy"
+ },
+ {
+ "argumentName": "version",
+ "nullable": true,
+ "description": "version of the policy, omit to use the latest version"
+ },
+ {
+ "argumentName": "stateName",
+ "nullable": false,
+ "description": "of the state"
+ },
+ {
+ "argumentName": "albumName",
+ "nullable": true,
+ "description": "name of the context album for the context reference, omit to list all task context references"
+ },
+ {
+ "argumentName": "albumVersion",
+ "nullable": true,
+ "description": "version of the context album for the context reference, omit to use the latest version"
+ }
+ ],
+ "apiMethod": "org.onap.policy.apex.model.modelapi.ApexEditorAPI.listPolicyStateContextRef",
+ "description": "List policy state context references."
+ },
+ {
+ "name": "deletePolicyStateContextRef",
+ "keywordlist": [
+ "policy",
+ "state",
+ "contextref",
+ "delete"
+ ],
+ "argumentList": [
+ {
+ "argumentName": "name",
+ "nullable": false,
+ "description": "name of the policy"
+ },
+ {
+ "argumentName": "version",
+ "nullable": true,
+ "description": "version of the policy, omit to use the default version"
+ },
+ {
+ "argumentName": "stateName",
+ "nullable": false,
+ "description": "of the state"
+ },
+ {
+ "argumentName": "albumName",
+ "nullable": true,
+ "description": "name of the context album for the context reference, omit to delete all task context references"
+ },
+ {
+ "argumentName": "albumVersion",
+ "nullable": true,
+ "description": "version of the context album for the context reference, omit to use the latest version"
+ }
+ ],
+ "apiMethod": "org.onap.policy.apex.model.modelapi.ApexEditorAPI.deletePolicyStateContextRef",
+ "description": "Delete a policy state context reference."
+ }
+ ]
+}
diff --git a/auth/cli-editor/src/main/resources/examples/scripts/ShellPolicyModel.apex b/auth/cli-editor/src/main/resources/examples/scripts/ShellPolicyModel.apex
new file mode 100644
index 000000000..1b4507fc7
--- /dev/null
+++ b/auth/cli-editor/src/main/resources/examples/scripts/ShellPolicyModel.apex
@@ -0,0 +1,23 @@
+#-------------------------------------------------------------------------------
+# ============LICENSE_START=======================================================
+# Copyright (C) 2016-2018 Ericsson. All rights reserved.
+# ================================================================================
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+# SPDX-License-Identifier: Apache-2.0
+# ============LICENSE_END=========================================================
+#-------------------------------------------------------------------------------
+
+model create name=ShellPolicyModel
+
+schema create name=Test_type flavour=Java schema=java.lang.String \ No newline at end of file
diff --git a/auth/cli-editor/src/main/resources/examples/scripts/ShellPolicyModelAddSchema.apex b/auth/cli-editor/src/main/resources/examples/scripts/ShellPolicyModelAddSchema.apex
new file mode 100644
index 000000000..ed1b4e437
--- /dev/null
+++ b/auth/cli-editor/src/main/resources/examples/scripts/ShellPolicyModelAddSchema.apex
@@ -0,0 +1,21 @@
+#-------------------------------------------------------------------------------
+# ============LICENSE_START=======================================================
+# Copyright (C) 2016-2018 Ericsson. All rights reserved.
+# ================================================================================
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+# SPDX-License-Identifier: Apache-2.0
+# ============LICENSE_END=========================================================
+#-------------------------------------------------------------------------------
+
+schema create name=Another_Test_type flavour=Java schema=java.lang.String \ No newline at end of file
diff --git a/auth/cli-editor/src/main/resources/examples/scripts/TestPolicyAvroEventContext.apex b/auth/cli-editor/src/main/resources/examples/scripts/TestPolicyAvroEventContext.apex
new file mode 100644
index 000000000..f333a3e9a
--- /dev/null
+++ b/auth/cli-editor/src/main/resources/examples/scripts/TestPolicyAvroEventContext.apex
@@ -0,0 +1,569 @@
+#-------------------------------------------------------------------------------
+# ============LICENSE_START=======================================================
+# Copyright (C) 2016-2018 Ericsson. All rights reserved.
+# ================================================================================
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+# SPDX-License-Identifier: Apache-2.0
+# ============LICENSE_END=========================================================
+#-------------------------------------------------------------------------------
+
+model create name=Test_PolicyModel
+
+schema create name=AvroBoolean_type flavour=Avro schema=LS
+{
+ "type" : "boolean"
+}
+LE
+
+schema create name=AvroByte_type flavour=Avro schema=LS
+{
+ "type" : "int"
+}
+LE
+
+schema create name=AvroShort_type flavour=Avro schema=LS
+{
+ "type" : "int"
+}
+LE
+
+schema create name=AvroInteger_type flavour=Avro schema=LS
+{
+ "type" : "int"
+}
+LE
+
+schema create name=AvroLong_type flavour=Avro schema=LS
+{
+ "type" : "long"
+}
+LE
+
+schema create name=AvroFloat_type flavour=Avro schema=LS
+{
+ "type" : "float"
+}
+LE
+
+schema create name=AvroDouble_type flavour=Avro schema=LS
+{
+ "type" : "double"
+}
+LE
+
+schema create name=AvroString_type flavour=Avro schema=LS
+{
+ "type" : "string"}
+LE
+
+schema create name=AvroMap_type flavour=Avro schema=LS
+{
+ "type": "map", "values": "string"
+}
+LE
+
+schema create name=AvroArray_type flavour=Avro schema=LS
+{
+ "type": "array", "items": "string"
+}
+LE
+
+schema create name=CustomBoolean_type flavour=Avro schema=LS
+{
+ "type" : "record",
+ "name" : "TestContextItem000",
+ "namespace" : "com.ericsson.apex.context.test.avro.concepts",
+ "fields" : [
+ {"name": "flag", "type": "boolean"}
+ ]
+}
+LE
+
+schema create name=CustomByte_type flavour=Avro schema=LS
+{
+ "type" : "record",
+ "name" : "TestContextItem001",
+ "namespace" : "com.ericsson.apex.context.test.avro.concepts",
+ "fields" : [
+ {"name": "byteValue", "type": "int"}
+ ]
+}
+LE
+
+schema create name=CustomInteger_type flavour=Avro schema=LS
+{
+ "type" : "record",
+ "name" : "TestContextItem002",
+ "namespace" : "com.ericsson.apex.context.test.avro.concepts",
+ "fields" : [
+ {"name": "intValue", "type": "int"}
+ ]
+}
+LE
+
+schema create name=CustomLong_type flavour=Avro schema=LS
+{
+ "type" : "record",
+ "name" : "TestContextItem003",
+ "namespace" : "com.ericsson.apex.context.test.avro.concepts",
+ "fields" : [
+ {"name": "longValue", "type": "long"}
+ ]
+}
+LE
+
+schema create name=CustomFloat_type flavour=Avro schema=LS
+{
+ "type" : "record",
+ "name" : "TestContextItem004",
+ "namespace" : "com.ericsson.apex.context.test.avro.concepts",
+ "fields" : [
+ {"name": "floatValue", "type": "float"}
+ ]
+}
+LE
+
+schema create name=CustomDouble_type flavour=Avro schema=LS
+{
+ "type" : "record",
+ "name" : "TestContextItem005",
+ "namespace" : "com.ericsson.apex.context.test.avro.concepts",
+ "fields" : [
+ {"name": "doubleValue", "type": "double"}
+ ]
+}
+LE
+
+schema create name=CustomString_type flavour=Avro schema=LS
+{
+ "type" : "record",
+ "name" : "TestContextItem006",
+ "namespace" : "com.ericsson.apex.context.test.avro.concepts",
+ "fields" : [
+ {"name": "stringValue", "type": "string"}
+ ]
+}
+LE
+
+schema create name=CustomALong_type flavour=Avro schema=LS
+{
+ "type" : "record",
+ "name" : "TestContextItem007",
+ "namespace" : "com.ericsson.apex.context.test.avro.concepts",
+ "fields" : [
+ {"name": "longValue", "type": "long"}
+ ]
+}
+LE
+
+schema create name=CustomDate0_type flavour=Avro schema=LS
+{
+ "type" : "record",
+ "name" : "TestContextItem008",
+ "namespace" : "com.ericsson.apex.context.test.avro.concepts",
+ "fields" : [
+ {"name": "time" , "type": "long"},
+ {"name": "year" , "type": "int"},
+ {"name": "month" , "type": "int"},
+ {"name": "day" , "type": "int"},
+ {"name": "hour" , "type": "int"},
+ {"name": "minute" , "type": "int"},
+ {"name": "second" , "type": "int"},
+ {"name": "milliSecond", "type": "int"}
+ ]
+}
+LE
+
+schema create name=CustomDate1_type flavour=Avro schema=LS
+{
+ "type" : "record",
+ "name" : "TestContextItem009",
+ "namespace" : "com.ericsson.apex.context.test.avro.concepts",
+ "fields" : [
+ {"name": "dateValue" , "type": {
+ "type" : "record",
+ "name" : "TestContextItem008",
+ "namespace" : "com.ericsson.apex.context.test.avro.concepts",
+ "fields" : [
+ {"name": "time" , "type": "long"},
+ {"name": "year" , "type": "int"},
+ {"name": "month" , "type": "int"},
+ {"name": "day" , "type": "int"},
+ {"name": "hour" , "type": "int"},
+ {"name": "minute" , "type": "int"},
+ {"name": "second" , "type": "int"},
+ {"name": "milliSecond", "type": "int"}
+ ]
+ }
+ },
+ {"name": "dst" , "type": "boolean"},
+ {"name": "timeZoneString", "type": "string"}
+ ]
+}
+LE
+
+schema create name=CustomDate2_type flavour=Avro schema=LS
+{
+ "type" : "record",
+ "name" : "TestContextItem00A",
+ "namespace" : "com.ericsson.apex.context.test.avro.concepts",
+ "fields" : [
+ {"name": "dateValue" , "type": {
+ "type" : "record",
+ "name" : "TestContextItem008",
+ "namespace" : "com.ericsson.apex.context.test.avro.concepts",
+ "fields" : [
+ {"name": "time" , "type": "long"},
+ {"name": "year" , "type": "int"},
+ {"name": "month" , "type": "int"},
+ {"name": "day" , "type": "int"},
+ {"name": "hour" , "type": "int"},
+ {"name": "minute" , "type": "int"},
+ {"name": "second" , "type": "int"},
+ {"name": "milliSecond", "type": "int"}
+ ]
+ }
+ },
+ {"name": "dst" , "type": "boolean"},
+ {"name": "timeZoneString", "type": "string"},
+ {"name": "utcOffset" , "type": "int"},
+ {"name": "localeLanguage", "type": "string"},
+ {"name": "localeCountry" , "type": "string"}
+ ]
+}
+LE
+
+schema create name=CustomSet_type flavour=Avro schema=LS
+{
+ "type" : "record",
+ "name" : "TestContextItem00B",
+ "namespace" : "com.ericsson.apex.context.test.avro.concepts",
+ "fields" : [
+ {"name": "setValue", "type": {
+ "type": "array", "items": "string"
+ }
+ }
+ ]
+}
+LE
+
+schema create name=CustomMap_type flavour=Avro schema=LS
+{
+ "type" : "record",
+ "name" : "TestContextItem00C",
+ "namespace" : "com.ericsson.apex.context.test.avro.concepts",
+ "fields" : [
+ {"name": "mapValue", "type": {
+ "type": "map", "values": "string"
+ }
+ }
+ ]
+}
+LE
+
+event create name=Test_InputEvent nameSpace=com.ericsson.apex.test source=External target=Apex
+
+event parameter create name=Test_InputEvent parName=AvroBoolean schemaName=AvroBoolean_type optional=false
+event parameter create name=Test_InputEvent parName=AvroByte schemaName=AvroByte_type optional=false
+event parameter create name=Test_InputEvent parName=AvroShort schemaName=AvroShort_type
+event parameter create name=Test_InputEvent parName=AvroInteger schemaName=AvroInteger_type optional=false
+event parameter create name=Test_InputEvent parName=AvroLong schemaName=AvroLong_type
+event parameter create name=Test_InputEvent parName=AvroFloat schemaName=AvroFloat_type
+event parameter create name=Test_InputEvent parName=AvroDouble schemaName=AvroDouble_type optional=false
+event parameter create name=Test_InputEvent parName=AvroString schemaName=AvroString_type
+event parameter create name=Test_InputEvent parName=AvroMap schemaName=AvroMap_type
+event parameter create name=Test_InputEvent parName=AvroArray schemaName=AvroArray_type
+event parameter create name=Test_InputEvent parName=CustomBoolean schemaName=CustomBoolean_type
+event parameter create name=Test_InputEvent parName=CustomByte schemaName=CustomByte_type
+event parameter create name=Test_InputEvent parName=CustomInteger schemaName=CustomInteger_type
+event parameter create name=Test_InputEvent parName=CustomLong schemaName=CustomLong_type
+event parameter create name=Test_InputEvent parName=CustomFloat schemaName=CustomFloat_type
+event parameter create name=Test_InputEvent parName=CustomDouble schemaName=CustomDouble_type
+event parameter create name=Test_InputEvent parName=CustomString schemaName=CustomString_type
+event parameter create name=Test_InputEvent parName=CustomALong schemaName=CustomALong_type
+event parameter create name=Test_InputEvent parName=CustomDate0 schemaName=CustomDate0_type
+event parameter create name=Test_InputEvent parName=CustomDate1 schemaName=CustomDate1_type
+event parameter create name=Test_InputEvent parName=CustomDate2 schemaName=CustomDate2_type
+event parameter create name=Test_InputEvent parName=CustomSet schemaName=CustomSet_type
+event parameter create name=Test_InputEvent parName=CustomMap schemaName=CustomMap_type
+
+event create name=Test_OutputEvent nameSpace=com.ericsson.apex.test source=External target=Apex
+
+event parameter create name=Test_OutputEvent parName=AvroBoolean schemaName=AvroBoolean_type
+event parameter create name=Test_OutputEvent parName=AvroByte schemaName=AvroByte_type
+event parameter create name=Test_OutputEvent parName=AvroShort schemaName=AvroShort_type
+event parameter create name=Test_OutputEvent parName=AvroInteger schemaName=AvroInteger_type
+event parameter create name=Test_OutputEvent parName=AvroLong schemaName=AvroLong_type
+event parameter create name=Test_OutputEvent parName=AvroFloat schemaName=AvroFloat_type
+event parameter create name=Test_OutputEvent parName=AvroDouble schemaName=AvroDouble_type
+event parameter create name=Test_OutputEvent parName=AvroString schemaName=AvroString_type
+event parameter create name=Test_OutputEvent parName=AvroMap schemaName=AvroMap_type
+event parameter create name=Test_OutputEvent parName=AvroArray schemaName=AvroArray_type
+event parameter create name=Test_OutputEvent parName=CustomBoolean schemaName=CustomBoolean_type
+event parameter create name=Test_OutputEvent parName=CustomByte schemaName=CustomByte_type
+event parameter create name=Test_OutputEvent parName=CustomInteger schemaName=CustomInteger_type
+event parameter create name=Test_OutputEvent parName=CustomLong schemaName=CustomLong_type
+event parameter create name=Test_OutputEvent parName=CustomFloat schemaName=CustomFloat_type
+event parameter create name=Test_OutputEvent parName=CustomDouble schemaName=CustomDouble_type
+event parameter create name=Test_OutputEvent parName=CustomString schemaName=CustomString_type
+event parameter create name=Test_OutputEvent parName=CustomALong schemaName=CustomALong_type
+event parameter create name=Test_OutputEvent parName=CustomDate0 schemaName=CustomDate0_type
+event parameter create name=Test_OutputEvent parName=CustomDate1 schemaName=CustomDate1_type
+event parameter create name=Test_OutputEvent parName=CustomDate2 schemaName=CustomDate2_type
+event parameter create name=Test_OutputEvent parName=CustomSet schemaName=CustomSet_type
+event parameter create name=Test_OutputEvent parName=CustomMap schemaName=CustomMap_type
+
+album create name=AvroBooleanAlbum scope=policy writable=true schemaName=AvroBoolean_type
+album create name=AvroByteAlbum scope=policy writable=true schemaName=AvroByte_type
+album create name=AvroShortAlbum scope=policy writable=true schemaName=AvroShort_type
+album create name=AvroIntegerAlbum scope=policy writable=true schemaName=AvroInteger_type
+album create name=AvroLongAlbum scope=policy writable=true schemaName=AvroLong_type
+album create name=AvroFloatAlbum scope=policy writable=true schemaName=AvroFloat_type
+album create name=AvroDoubleAlbum scope=policy writable=true schemaName=AvroDouble_type
+album create name=AvroStringAlbum scope=policy writable=true schemaName=AvroString_type
+album create name=AvroMapAlbum scope=policy writable=true schemaName=AvroMap_type
+album create name=AvroArrayAlbum scope=policy writable=true schemaName=AvroArray_type
+album create name=CustomBooleanAlbum scope=policy writable=true schemaName=CustomBoolean_type
+album create name=CustomByteAlbum scope=policy writable=true schemaName=CustomByte_type
+album create name=CustomIntegerAlbum scope=policy writable=true schemaName=CustomInteger_type
+album create name=CustomLongAlbum scope=policy writable=true schemaName=CustomLong_type
+album create name=CustomFloatAlbum scope=policy writable=true schemaName=CustomFloat_type
+album create name=CustomDoubleAlbum scope=policy writable=true schemaName=CustomDouble_type
+album create name=CustomStringAlbum scope=policy writable=true schemaName=CustomString_type
+album create name=CustomALongAlbum scope=policy writable=true schemaName=CustomALong_type
+album create name=CustomDate0Album scope=policy writable=true schemaName=CustomDate0_type
+album create name=CustomDate1Album scope=policy writable=true schemaName=CustomDate1_type
+album create name=CustomDate2Album scope=policy writable=true schemaName=CustomDate2_type
+album create name=CustomSetAlbum scope=policy writable=true schemaName=CustomSet_type
+album create name=CustomMapAlbum scope=policy writable=true schemaName=CustomMap_type
+
+task create name=Test_Task
+
+task inputfield create name=Test_Task fieldName=AvroBoolean schemaName=AvroBoolean_type
+task inputfield create name=Test_Task fieldName=AvroByte schemaName=AvroByte_type
+task inputfield create name=Test_Task fieldName=AvroShort schemaName=AvroShort_type
+task inputfield create name=Test_Task fieldName=AvroInteger schemaName=AvroInteger_type
+task inputfield create name=Test_Task fieldName=AvroLong schemaName=AvroLong_type
+task inputfield create name=Test_Task fieldName=AvroFloat schemaName=AvroFloat_type
+task inputfield create name=Test_Task fieldName=AvroDouble schemaName=AvroDouble_type
+task inputfield create name=Test_Task fieldName=AvroString schemaName=AvroString_type
+task inputfield create name=Test_Task fieldName=AvroMap schemaName=AvroMap_type
+task inputfield create name=Test_Task fieldName=AvroArray schemaName=AvroArray_type
+task inputfield create name=Test_Task fieldName=CustomBoolean schemaName=CustomBoolean_type
+task inputfield create name=Test_Task fieldName=CustomByte schemaName=CustomByte_type
+task inputfield create name=Test_Task fieldName=CustomInteger schemaName=CustomInteger_type
+task inputfield create name=Test_Task fieldName=CustomLong schemaName=CustomLong_type
+task inputfield create name=Test_Task fieldName=CustomFloat schemaName=CustomFloat_type
+task inputfield create name=Test_Task fieldName=CustomDouble schemaName=CustomDouble_type
+task inputfield create name=Test_Task fieldName=CustomString schemaName=CustomString_type
+task inputfield create name=Test_Task fieldName=CustomALong schemaName=CustomALong_type
+task inputfield create name=Test_Task fieldName=CustomDate0 schemaName=CustomDate0_type
+task inputfield create name=Test_Task fieldName=CustomDate1 schemaName=CustomDate1_type
+task inputfield create name=Test_Task fieldName=CustomDate2 schemaName=CustomDate2_type
+task inputfield create name=Test_Task fieldName=CustomSet schemaName=CustomSet_type
+task inputfield create name=Test_Task fieldName=CustomMap schemaName=CustomMap_type
+
+task outputfield create name=Test_Task fieldName=AvroBoolean schemaName=AvroBoolean_type
+task outputfield create name=Test_Task fieldName=AvroByte schemaName=AvroByte_type
+task outputfield create name=Test_Task fieldName=AvroShort schemaName=AvroShort_type
+task outputfield create name=Test_Task fieldName=AvroInteger schemaName=AvroInteger_type
+task outputfield create name=Test_Task fieldName=AvroLong schemaName=AvroLong_type
+task outputfield create name=Test_Task fieldName=AvroFloat schemaName=AvroFloat_type
+task outputfield create name=Test_Task fieldName=AvroDouble schemaName=AvroDouble_type
+task outputfield create name=Test_Task fieldName=AvroString schemaName=AvroString_type
+task outputfield create name=Test_Task fieldName=AvroMap schemaName=AvroMap_type
+task outputfield create name=Test_Task fieldName=AvroArray schemaName=AvroArray_type
+task outputfield create name=Test_Task fieldName=CustomBoolean schemaName=CustomBoolean_type
+task outputfield create name=Test_Task fieldName=CustomByte schemaName=CustomByte_type
+task outputfield create name=Test_Task fieldName=CustomInteger schemaName=CustomInteger_type
+task outputfield create name=Test_Task fieldName=CustomLong schemaName=CustomLong_type
+task outputfield create name=Test_Task fieldName=CustomFloat schemaName=CustomFloat_type
+task outputfield create name=Test_Task fieldName=CustomDouble schemaName=CustomDouble_type
+task outputfield create name=Test_Task fieldName=CustomString schemaName=CustomString_type
+task outputfield create name=Test_Task fieldName=CustomALong schemaName=CustomALong_type
+task outputfield create name=Test_Task fieldName=CustomDate0 schemaName=CustomDate0_type
+task outputfield create name=Test_Task fieldName=CustomDate1 schemaName=CustomDate1_type
+task outputfield create name=Test_Task fieldName=CustomDate2 schemaName=CustomDate2_type
+task outputfield create name=Test_Task fieldName=CustomSet schemaName=CustomSet_type
+task outputfield create name=Test_Task fieldName=CustomMap schemaName=CustomMap_type
+
+task contextref create name=Test_Task albumName=AvroBooleanAlbum
+task contextref create name=Test_Task albumName=AvroByteAlbum
+task contextref create name=Test_Task albumName=AvroShortAlbum
+task contextref create name=Test_Task albumName=AvroIntegerAlbum
+task contextref create name=Test_Task albumName=AvroLongAlbum
+task contextref create name=Test_Task albumName=AvroFloatAlbum
+task contextref create name=Test_Task albumName=AvroDoubleAlbum
+task contextref create name=Test_Task albumName=AvroStringAlbum
+task contextref create name=Test_Task albumName=AvroMapAlbum
+task contextref create name=Test_Task albumName=AvroArrayAlbum
+task contextref create name=Test_Task albumName=CustomBooleanAlbum
+task contextref create name=Test_Task albumName=CustomByteAlbum
+task contextref create name=Test_Task albumName=CustomIntegerAlbum
+task contextref create name=Test_Task albumName=CustomLongAlbum
+task contextref create name=Test_Task albumName=CustomFloatAlbum
+task contextref create name=Test_Task albumName=CustomDoubleAlbum
+task contextref create name=Test_Task albumName=CustomStringAlbum
+task contextref create name=Test_Task albumName=CustomALongAlbum
+task contextref create name=Test_Task albumName=CustomDate0Album
+task contextref create name=Test_Task albumName=CustomDate1Album
+task contextref create name=Test_Task albumName=CustomDate2Album
+task contextref create name=Test_Task albumName=CustomSetAlbum
+task contextref create name=Test_Task albumName=CustomMapAlbum
+
+task logic create name=Test_Task logicFlavour=JAVASCRIPT logic=LS
+executor.logger.debug(executor.subject.id);
+
+executor.logger.debug(executor.inFields);
+
+executor.getContextAlbum("AvroBooleanAlbum" ).put("AvroBoolean" , executor.inFields.get("AvroBoolean"));
+executor.getContextAlbum("AvroByteAlbum" ).put("AvroByte" , executor.inFields.get("AvroByte" ));
+executor.getContextAlbum("AvroShortAlbum" ).put("AvroShort" , executor.inFields.get("AvroShort" ));
+executor.getContextAlbum("AvroIntegerAlbum" ).put("AvroInteger" , executor.inFields.get("AvroInteger"));
+executor.getContextAlbum("AvroLongAlbum" ).put("AvroLong" , executor.inFields.get("AvroLong" ));
+executor.getContextAlbum("AvroFloatAlbum" ).put("AvroFloat" , executor.inFields.get("AvroFloat" ));
+executor.getContextAlbum("AvroDoubleAlbum" ).put("AvroDouble" , executor.inFields.get("AvroDouble" ));
+executor.getContextAlbum("AvroStringAlbum" ).put("AvroString" , executor.inFields.get("AvroString" ));
+executor.getContextAlbum("AvroMapAlbum" ).put("AvroMap" , executor.inFields.get("AvroMap" ));
+executor.getContextAlbum("AvroArrayAlbum" ).put("AvroArray" , executor.inFields.get("AvroArray" ));
+executor.getContextAlbum("CustomBooleanAlbum").put("CustomBoolean", executor.inFields.get("CustomBoolean"));
+executor.getContextAlbum("CustomByteAlbum" ).put("CustomByte" , executor.inFields.get("CustomByte" ));
+executor.getContextAlbum("CustomIntegerAlbum").put("CustomInteger", executor.inFields.get("CustomInteger"));
+executor.getContextAlbum("CustomLongAlbum" ).put("CustomLong" , executor.inFields.get("CustomLong" ));
+executor.getContextAlbum("CustomFloatAlbum" ).put("CustomFloat" , executor.inFields.get("CustomFloat" ));
+executor.getContextAlbum("CustomDoubleAlbum" ).put("CustomDouble" , executor.inFields.get("CustomDouble" ));
+executor.getContextAlbum("CustomStringAlbum" ).put("CustomString" , executor.inFields.get("CustomString" ));
+executor.getContextAlbum("CustomALongAlbum" ).put("CustomALong" , executor.inFields.get("CustomALong" ));
+executor.getContextAlbum("CustomDate0Album" ).put("CustomDate0" , executor.inFields.get("CustomDate0" ));
+executor.getContextAlbum("CustomDate1Album" ).put("CustomDate1" , executor.inFields.get("CustomDate1" ));
+executor.getContextAlbum("CustomDate2Album" ).put("CustomDate2" , executor.inFields.get("CustomDate2" ));
+executor.getContextAlbum("CustomSetAlbum" ).put("CustomSet" , executor.inFields.get("CustomSet" ));
+executor.getContextAlbum("CustomMapAlbum" ).put("CustomMap" , executor.inFields.get("CustomMap" ));
+
+var avroBoolean = executor.getContextAlbum("AvroBooleanAlbum" ).get("AvroBoolean" );
+var avroByte = executor.getContextAlbum("AvroByteAlbum" ).get("AvroByte" );
+var avroShort = executor.getContextAlbum("AvroShortAlbum" ).get("AvroShort" );
+var avroInteger = executor.getContextAlbum("AvroIntegerAlbum" ).get("AvroInteger" );
+var avroLong = executor.getContextAlbum("AvroLongAlbum" ).get("AvroLong" );
+var avroFloat = executor.getContextAlbum("AvroFloatAlbum" ).get("AvroFloat" );
+var avroDouble = executor.getContextAlbum("AvroDoubleAlbum" ).get("AvroDouble" );
+var avroString = executor.getContextAlbum("AvroStringAlbum" ).get("AvroString" );
+var customBoolean = executor.getContextAlbum("CustomBooleanAlbum").get("CustomBoolean");
+var customByte = executor.getContextAlbum("CustomByteAlbum" ).get("CustomByte" );
+var customInteger = executor.getContextAlbum("CustomIntegerAlbum").get("CustomInteger");
+var customLong = executor.getContextAlbum("CustomLongAlbum" ).get("CustomLong" );
+var customFloat = executor.getContextAlbum("CustomFloatAlbum" ).get("CustomFloat" );
+var customDouble = executor.getContextAlbum("CustomDoubleAlbum" ).get("CustomDouble" );
+var customString = executor.getContextAlbum("CustomStringAlbum" ).get("CustomString" );
+var customALong = executor.getContextAlbum("CustomALongAlbum" ).get("CustomALong" );
+var customDate0 = executor.getContextAlbum("CustomDate0Album" ).get("CustomDate0" );
+var customDate1 = executor.getContextAlbum("CustomDate1Album" ).get("CustomDate1" );
+var customDate2 = executor.getContextAlbum("CustomDate2Album" ).get("CustomDate2" );
+var customSet = executor.getContextAlbum("CustomSetAlbum" ).get("CustomSet" );
+var customMap = executor.getContextAlbum("CustomMapAlbum" ).get("CustomMap" );
+
+javaIntegerType = Java.type("java.lang.Integer");
+javaLongType = Java.type("java.lang.Long");
+javaFloatType = Java.type("java.lang.Float");
+
+avroBoolean = !avroBoolean;
+avroByte = new javaIntegerType(avroByte + 1);
+avroShort = new javaIntegerType(avroShort + 1);
+avroInteger = new javaIntegerType(avroInteger + 1);
+avroLong = new javaLongType (avroLong + 1);
+avroFloat = new javaFloatType (avroFloat + 0.99);
+avroDouble += 0.99;
+avroString = avroString + " added to end of string";
+customBoolean.put("flag", !customBoolean.get("flag"));
+customByte .put("byteValue" , customByte .get("byteValue" ) + 1);
+customInteger.put("intValue" , customInteger.get("intValue" ) + 1);
+customLong .put("longValue" , new javaLongType (customLong .get("longValue" ) + 1));
+customFloat .put("floatValue" , new javaFloatType(customFloat.get("floatValue") + 1.0));
+customDouble .put("doubleValue", customDouble .get("doubleValue") + 1.0);
+customString .put("stringValue", customString .get("stringValue") + " added to end of string");
+customALong .put("longValue" , new javaLongType (customALong.get("longValue" ) + 1));
+
+customDate0.put("year", 1922);
+customDate0.put("month", 12);
+customDate0.put("day", 6);
+
+customDate1.put("dateValue", customDate0);
+customDate2.put("dateValue", customDate0);
+
+customSet.get("setValue").add("with");
+customSet.get("setValue").add("a");
+customSet.get("setValue").add("beard");
+
+customMap.get("mapValue").put("love", "hate");
+customMap.get("mapValue").put("summer", "winter");
+customMap.get("mapValue").put("good", "bad");
+
+executor.getContextAlbum("AvroBooleanAlbum" ).put("AvroBoolean" , avroBoolean);
+executor.getContextAlbum("AvroByteAlbum" ).put("AvroByte" , avroByte);
+executor.getContextAlbum("AvroShortAlbum" ).put("AvroShort" , avroShort);
+executor.getContextAlbum("AvroIntegerAlbum" ).put("AvroInteger" , avroInteger);
+executor.getContextAlbum("AvroLongAlbum" ).put("AvroLong" , avroLong);
+executor.getContextAlbum("AvroFloatAlbum" ).put("AvroFloat" , avroFloat);
+executor.getContextAlbum("AvroDoubleAlbum" ).put("AvroDouble" , avroDouble);
+executor.getContextAlbum("AvroStringAlbum" ).put("AvroString" , avroString);
+executor.getContextAlbum("CustomBooleanAlbum").put("CustomBoolean", customBoolean);
+executor.getContextAlbum("CustomByteAlbum" ).put("CustomByte" , customByte);
+executor.getContextAlbum("CustomIntegerAlbum").put("CustomInteger", customInteger);
+executor.getContextAlbum("CustomLongAlbum" ).put("CustomLong" , customLong);
+executor.getContextAlbum("CustomFloatAlbum" ).put("CustomFloat" , customFloat);
+executor.getContextAlbum("CustomDoubleAlbum" ).put("CustomDouble" , customDouble);
+executor.getContextAlbum("CustomStringAlbum" ).put("CustomString" , customString);
+executor.getContextAlbum("CustomALongAlbum" ).put("CustomALong" , customALong);
+executor.getContextAlbum("CustomDate0Album" ).put("CustomDate0" , customDate0);
+executor.getContextAlbum("CustomDate1Album" ).put("CustomDate1" , customDate1);
+executor.getContextAlbum("CustomDate2Album" ).put("CustomDate2" , customDate2);
+executor.getContextAlbum("CustomSetAlbum" ).put("CustomSet" , customSet);
+executor.getContextAlbum("CustomMapAlbum" ).put("CustomMap" , customMap);
+
+executor.outFields.put("AvroBoolean" , executor.getContextAlbum("AvroBooleanAlbum" ).get("AvroBoolean" ));
+executor.outFields.put("AvroByte" , executor.getContextAlbum("AvroByteAlbum" ).get("AvroByte" ));
+executor.outFields.put("AvroShort" , executor.getContextAlbum("AvroShortAlbum" ).get("AvroShort" ));
+executor.outFields.put("AvroInteger" , executor.getContextAlbum("AvroIntegerAlbum" ).get("AvroInteger" ));
+executor.outFields.put("AvroLong" , executor.getContextAlbum("AvroLongAlbum" ).get("AvroLong" ));
+executor.outFields.put("AvroFloat" , executor.getContextAlbum("AvroFloatAlbum" ).get("AvroFloat" ));
+executor.outFields.put("AvroDouble" , executor.getContextAlbum("AvroDoubleAlbum" ).get("AvroDouble" ));
+executor.outFields.put("AvroString" , executor.getContextAlbum("AvroStringAlbum" ).get("AvroString" ));
+executor.outFields.put("AvroMap" , executor.getContextAlbum("AvroMapAlbum" ).get("AvroMap" ));
+executor.outFields.put("AvroArray" , executor.getContextAlbum("AvroArrayAlbum" ).get("AvroArray" ));
+executor.outFields.put("CustomBoolean", executor.getContextAlbum("CustomBooleanAlbum").get("CustomBoolean"));
+executor.outFields.put("CustomByte" , executor.getContextAlbum("CustomByteAlbum" ).get("CustomByte" ));
+executor.outFields.put("CustomInteger", executor.getContextAlbum("CustomIntegerAlbum").get("CustomInteger"));
+executor.outFields.put("CustomLong" , executor.getContextAlbum("CustomLongAlbum" ).get("CustomLong" ));
+executor.outFields.put("CustomFloat" , executor.getContextAlbum("CustomFloatAlbum" ).get("CustomFloat" ));
+executor.outFields.put("CustomDouble" , executor.getContextAlbum("CustomDoubleAlbum" ).get("CustomDouble" ));
+executor.outFields.put("CustomString" , executor.getContextAlbum("CustomStringAlbum" ).get("CustomString" ));
+executor.outFields.put("CustomALong" , executor.getContextAlbum("CustomALongAlbum" ).get("CustomALong" ));
+executor.outFields.put("CustomDate0" , executor.getContextAlbum("CustomDate0Album" ).get("CustomDate0" ));
+executor.outFields.put("CustomDate1" , executor.getContextAlbum("CustomDate1Album" ).get("CustomDate1" ));
+executor.outFields.put("CustomDate2" , executor.getContextAlbum("CustomDate2Album" ).get("CustomDate2" ));
+executor.outFields.put("CustomSet" , executor.getContextAlbum("CustomSetAlbum" ).get("CustomSet" ));
+executor.outFields.put("CustomMap" , executor.getContextAlbum("CustomMapAlbum" ).get("CustomMap" ));
+
+executor.logger.debug(executor.outFields);
+
+var returnValueType = Java.type("java.lang.Boolean");
+var returnValue = new returnValueType(true);
+
+LE
+
+policy create name=Test_Policy template=FREEFORM firstState=OnlyState
+
+policy state create name=Test_Policy stateName=OnlyState triggerName=Test_InputEvent defaultTaskName=Test_Task
+policy state output create name=Test_Policy stateName=OnlyState outputName=OnlyState2Out eventName=Test_OutputEvent
+policy state taskref create name=Test_Policy stateName=OnlyState taskName=Test_Task outputType=DIRECT outputName=OnlyState2Out
diff --git a/auth/cli-editor/src/main/resources/examples/scripts/TestPolicyJavaEventContext.apex b/auth/cli-editor/src/main/resources/examples/scripts/TestPolicyJavaEventContext.apex
new file mode 100644
index 000000000..8d1711638
--- /dev/null
+++ b/auth/cli-editor/src/main/resources/examples/scripts/TestPolicyJavaEventContext.apex
@@ -0,0 +1,324 @@
+#-------------------------------------------------------------------------------
+# ============LICENSE_START=======================================================
+# Copyright (C) 2016-2018 Ericsson. All rights reserved.
+# ================================================================================
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+# SPDX-License-Identifier: Apache-2.0
+# ============LICENSE_END=========================================================
+#-------------------------------------------------------------------------------
+
+model create name=Test_PolicyModel
+
+schema create name=JavaBoolean_type flavour=Java schema=java.lang.Boolean
+schema create name=JavaByte_type flavour=Java schema=java.lang.Byte
+schema create name=JavaShort_type flavour=Java schema=java.lang.Short
+schema create name=JavaInteger_type flavour=Java schema=java.lang.Integer
+schema create name=JavaLong_type flavour=Java schema=java.lang.Long
+schema create name=JavaFloat_type flavour=Java schema=java.lang.Float
+schema create name=JavaDouble_type flavour=Java schema=java.lang.Double
+schema create name=JavaString_type flavour=Java schema=java.lang.String
+schema create name=CustomBoolean_type flavour=Java schema=org.onap.policy.apex.context.test.concepts.TestContextItem000
+schema create name=CustomByte_type flavour=Java schema=org.onap.policy.apex.context.test.concepts.TestContextItem001
+schema create name=CustomInteger_type flavour=Java schema=org.onap.policy.apex.context.test.concepts.TestContextItem002
+schema create name=CustomLong_type flavour=Java schema=org.onap.policy.apex.context.test.concepts.TestContextItem003
+schema create name=CustomFloat_type flavour=Java schema=org.onap.policy.apex.context.test.concepts.TestContextItem004
+schema create name=CustomDouble_type flavour=Java schema=org.onap.policy.apex.context.test.concepts.TestContextItem005
+schema create name=CustomString_type flavour=Java schema=org.onap.policy.apex.context.test.concepts.TestContextItem006
+schema create name=CustomJLong_type flavour=Java schema=org.onap.policy.apex.context.test.concepts.TestContextItem007
+schema create name=CustomDate0_type flavour=Java schema=org.onap.policy.apex.context.test.concepts.TestContextItem008
+schema create name=CustomDate1_type flavour=Java schema=org.onap.policy.apex.context.test.concepts.TestContextItem009
+schema create name=CustomDate2_type flavour=Java schema=org.onap.policy.apex.context.test.concepts.TestContextItem00A
+schema create name=CustomSet_type flavour=Java schema=org.onap.policy.apex.context.test.concepts.TestContextItem00B
+schema create name=CustomMap_type flavour=Java schema=org.onap.policy.apex.context.test.concepts.TestContextItem00C
+
+event create name=Test_InputEvent nameSpace=org.onap.policy.apex.test source=External target=Apex
+
+event parameter create name=Test_InputEvent parName=JavaBoolean schemaName=JavaBoolean_type
+event parameter create name=Test_InputEvent parName=JavaByte schemaName=JavaByte_type
+event parameter create name=Test_InputEvent parName=JavaShort schemaName=JavaShort_type
+event parameter create name=Test_InputEvent parName=JavaInteger schemaName=JavaInteger_type
+event parameter create name=Test_InputEvent parName=JavaLong schemaName=JavaLong_type
+event parameter create name=Test_InputEvent parName=JavaFloat schemaName=JavaFloat_type
+event parameter create name=Test_InputEvent parName=JavaDouble schemaName=JavaDouble_type
+event parameter create name=Test_InputEvent parName=JavaString schemaName=JavaString_type
+event parameter create name=Test_InputEvent parName=CustomBoolean schemaName=CustomBoolean_type
+event parameter create name=Test_InputEvent parName=CustomByte schemaName=CustomByte_type
+event parameter create name=Test_InputEvent parName=CustomInteger schemaName=CustomInteger_type
+event parameter create name=Test_InputEvent parName=CustomLong schemaName=CustomLong_type
+event parameter create name=Test_InputEvent parName=CustomFloat schemaName=CustomFloat_type
+event parameter create name=Test_InputEvent parName=CustomDouble schemaName=CustomDouble_type
+event parameter create name=Test_InputEvent parName=CustomString schemaName=CustomString_type
+event parameter create name=Test_InputEvent parName=CustomJLong schemaName=CustomJLong_type
+event parameter create name=Test_InputEvent parName=CustomDate0 schemaName=CustomDate0_type
+event parameter create name=Test_InputEvent parName=CustomDate1 schemaName=CustomDate1_type
+event parameter create name=Test_InputEvent parName=CustomDate2 schemaName=CustomDate2_type
+event parameter create name=Test_InputEvent parName=CustomSet schemaName=CustomSet_type
+event parameter create name=Test_InputEvent parName=CustomMap schemaName=CustomMap_type
+
+event create name=Test_OutputEvent nameSpace=org.onap.policy.apex.test source=External target=Apex
+
+event parameter create name=Test_OutputEvent parName=JavaBoolean schemaName=JavaBoolean_type
+event parameter create name=Test_OutputEvent parName=JavaByte schemaName=JavaByte_type
+event parameter create name=Test_OutputEvent parName=JavaShort schemaName=JavaShort_type
+event parameter create name=Test_OutputEvent parName=JavaInteger schemaName=JavaInteger_type
+event parameter create name=Test_OutputEvent parName=JavaLong schemaName=JavaLong_type
+event parameter create name=Test_OutputEvent parName=JavaFloat schemaName=JavaFloat_type
+event parameter create name=Test_OutputEvent parName=JavaDouble schemaName=JavaDouble_type
+event parameter create name=Test_OutputEvent parName=JavaString schemaName=JavaString_type
+event parameter create name=Test_OutputEvent parName=CustomBoolean schemaName=CustomBoolean_type
+event parameter create name=Test_OutputEvent parName=CustomByte schemaName=CustomByte_type
+event parameter create name=Test_OutputEvent parName=CustomInteger schemaName=CustomInteger_type
+event parameter create name=Test_OutputEvent parName=CustomLong schemaName=CustomLong_type
+event parameter create name=Test_OutputEvent parName=CustomFloat schemaName=CustomFloat_type
+event parameter create name=Test_OutputEvent parName=CustomDouble schemaName=CustomDouble_type
+event parameter create name=Test_OutputEvent parName=CustomString schemaName=CustomString_type
+event parameter create name=Test_OutputEvent parName=CustomJLong schemaName=CustomJLong_type
+event parameter create name=Test_OutputEvent parName=CustomDate0 schemaName=CustomDate0_type
+event parameter create name=Test_OutputEvent parName=CustomDate1 schemaName=CustomDate1_type
+event parameter create name=Test_OutputEvent parName=CustomDate2 schemaName=CustomDate2_type
+event parameter create name=Test_OutputEvent parName=CustomSet schemaName=CustomSet_type
+event parameter create name=Test_OutputEvent parName=CustomMap schemaName=CustomMap_type
+
+album create name=JavaBooleanAlbum scope=policy writable=true schemaName=JavaBoolean_type
+album create name=JavaByteAlbum scope=policy writable=true schemaName=JavaByte_type
+album create name=JavaShortAlbum scope=policy writable=true schemaName=JavaShort_type
+album create name=JavaIntegerAlbum scope=policy writable=true schemaName=JavaInteger_type
+album create name=JavaLongAlbum scope=policy writable=true schemaName=JavaLong_type
+album create name=JavaFloatAlbum scope=policy writable=true schemaName=JavaFloat_type
+album create name=JavaDoubleAlbum scope=policy writable=true schemaName=JavaDouble_type
+album create name=JavaStringAlbum scope=policy writable=true schemaName=JavaString_type
+album create name=CustomBooleanAlbum scope=policy writable=true schemaName=CustomBoolean_type
+album create name=CustomByteAlbum scope=policy writable=true schemaName=CustomByte_type
+album create name=CustomIntegerAlbum scope=policy writable=true schemaName=CustomInteger_type
+album create name=CustomLongAlbum scope=policy writable=true schemaName=CustomLong_type
+album create name=CustomFloatAlbum scope=policy writable=true schemaName=CustomFloat_type
+album create name=CustomDoubleAlbum scope=policy writable=true schemaName=CustomDouble_type
+album create name=CustomStringAlbum scope=policy writable=true schemaName=CustomString_type
+album create name=CustomJLongAlbum scope=policy writable=true schemaName=CustomJLong_type
+album create name=CustomDate0Album scope=policy writable=true schemaName=CustomDate0_type
+album create name=CustomDate1Album scope=policy writable=true schemaName=CustomDate1_type
+album create name=CustomDate2Album scope=policy writable=true schemaName=CustomDate2_type
+album create name=CustomSetAlbum scope=policy writable=true schemaName=CustomSet_type
+album create name=CustomMapAlbum scope=policy writable=true schemaName=CustomMap_type
+
+task create name=Test_Task
+
+task inputfield create name=Test_Task fieldName=JavaBoolean schemaName=JavaBoolean_type
+task inputfield create name=Test_Task fieldName=JavaByte schemaName=JavaByte_type
+task inputfield create name=Test_Task fieldName=JavaShort schemaName=JavaShort_type
+task inputfield create name=Test_Task fieldName=JavaInteger schemaName=JavaInteger_type
+task inputfield create name=Test_Task fieldName=JavaLong schemaName=JavaLong_type
+task inputfield create name=Test_Task fieldName=JavaFloat schemaName=JavaFloat_type
+task inputfield create name=Test_Task fieldName=JavaDouble schemaName=JavaDouble_type
+task inputfield create name=Test_Task fieldName=JavaString schemaName=JavaString_type
+task inputfield create name=Test_Task fieldName=CustomBoolean schemaName=CustomBoolean_type
+task inputfield create name=Test_Task fieldName=CustomByte schemaName=CustomByte_type
+task inputfield create name=Test_Task fieldName=CustomInteger schemaName=CustomInteger_type
+task inputfield create name=Test_Task fieldName=CustomLong schemaName=CustomLong_type
+task inputfield create name=Test_Task fieldName=CustomFloat schemaName=CustomFloat_type
+task inputfield create name=Test_Task fieldName=CustomDouble schemaName=CustomDouble_type
+task inputfield create name=Test_Task fieldName=CustomString schemaName=CustomString_type
+task inputfield create name=Test_Task fieldName=CustomJLong schemaName=CustomJLong_type
+task inputfield create name=Test_Task fieldName=CustomDate0 schemaName=CustomDate0_type
+task inputfield create name=Test_Task fieldName=CustomDate1 schemaName=CustomDate1_type
+task inputfield create name=Test_Task fieldName=CustomDate2 schemaName=CustomDate2_type
+task inputfield create name=Test_Task fieldName=CustomSet schemaName=CustomSet_type
+task inputfield create name=Test_Task fieldName=CustomMap schemaName=CustomMap_type
+
+task outputfield create name=Test_Task fieldName=JavaBoolean schemaName=JavaBoolean_type
+task outputfield create name=Test_Task fieldName=JavaByte schemaName=JavaByte_type
+task outputfield create name=Test_Task fieldName=JavaShort schemaName=JavaShort_type
+task outputfield create name=Test_Task fieldName=JavaInteger schemaName=JavaInteger_type
+task outputfield create name=Test_Task fieldName=JavaLong schemaName=JavaLong_type
+task outputfield create name=Test_Task fieldName=JavaFloat schemaName=JavaFloat_type
+task outputfield create name=Test_Task fieldName=JavaDouble schemaName=JavaDouble_type
+task outputfield create name=Test_Task fieldName=JavaString schemaName=JavaString_type
+task outputfield create name=Test_Task fieldName=CustomBoolean schemaName=CustomBoolean_type
+task outputfield create name=Test_Task fieldName=CustomByte schemaName=CustomByte_type
+task outputfield create name=Test_Task fieldName=CustomInteger schemaName=CustomInteger_type
+task outputfield create name=Test_Task fieldName=CustomLong schemaName=CustomLong_type
+task outputfield create name=Test_Task fieldName=CustomFloat schemaName=CustomFloat_type
+task outputfield create name=Test_Task fieldName=CustomDouble schemaName=CustomDouble_type
+task outputfield create name=Test_Task fieldName=CustomString schemaName=CustomString_type
+task outputfield create name=Test_Task fieldName=CustomJLong schemaName=CustomJLong_type
+task outputfield create name=Test_Task fieldName=CustomDate0 schemaName=CustomDate0_type
+task outputfield create name=Test_Task fieldName=CustomDate1 schemaName=CustomDate1_type
+task outputfield create name=Test_Task fieldName=CustomDate2 schemaName=CustomDate2_type
+task outputfield create name=Test_Task fieldName=CustomSet schemaName=CustomSet_type
+task outputfield create name=Test_Task fieldName=CustomMap schemaName=CustomMap_type
+
+task contextref create name=Test_Task albumName=JavaBooleanAlbum
+task contextref create name=Test_Task albumName=JavaByteAlbum
+task contextref create name=Test_Task albumName=JavaShortAlbum
+task contextref create name=Test_Task albumName=JavaIntegerAlbum
+task contextref create name=Test_Task albumName=JavaLongAlbum
+task contextref create name=Test_Task albumName=JavaFloatAlbum
+task contextref create name=Test_Task albumName=JavaDoubleAlbum
+task contextref create name=Test_Task albumName=JavaStringAlbum
+task contextref create name=Test_Task albumName=CustomBooleanAlbum
+task contextref create name=Test_Task albumName=CustomByteAlbum
+task contextref create name=Test_Task albumName=CustomIntegerAlbum
+task contextref create name=Test_Task albumName=CustomLongAlbum
+task contextref create name=Test_Task albumName=CustomFloatAlbum
+task contextref create name=Test_Task albumName=CustomDoubleAlbum
+task contextref create name=Test_Task albumName=CustomStringAlbum
+task contextref create name=Test_Task albumName=CustomJLongAlbum
+task contextref create name=Test_Task albumName=CustomDate0Album
+task contextref create name=Test_Task albumName=CustomDate1Album
+task contextref create name=Test_Task albumName=CustomDate2Album
+task contextref create name=Test_Task albumName=CustomSetAlbum
+task contextref create name=Test_Task albumName=CustomMapAlbum
+
+task logic create name=Test_Task logicFlavour=JAVASCRIPT logic=LS
+executor.logger.debug(executor.subject.id);
+
+executor.logger.debug(executor.inFields);
+
+executor.getContextAlbum("JavaBooleanAlbum" ).put("JavaBoolean" , executor.inFields.get("JavaBoolean" ));
+executor.getContextAlbum("JavaByteAlbum" ).put("JavaByte" , executor.inFields.get("JavaByte" ));
+executor.getContextAlbum("JavaShortAlbum" ).put("JavaShort" , executor.inFields.get("JavaShort" ));
+executor.getContextAlbum("JavaIntegerAlbum" ).put("JavaInteger" , executor.inFields.get("JavaInteger" ));
+executor.getContextAlbum("JavaLongAlbum" ).put("JavaLong" , executor.inFields.get("JavaLong" ));
+executor.getContextAlbum("JavaFloatAlbum" ).put("JavaFloat" , executor.inFields.get("JavaFloat" ));
+executor.getContextAlbum("JavaDoubleAlbum" ).put("JavaDouble" , executor.inFields.get("JavaDouble" ));
+executor.getContextAlbum("JavaStringAlbum" ).put("JavaString" , executor.inFields.get("JavaString" ));
+executor.getContextAlbum("CustomBooleanAlbum").put("CustomBoolean", executor.inFields.get("CustomBoolean"));
+executor.getContextAlbum("CustomByteAlbum" ).put("CustomByte" , executor.inFields.get("CustomByte" ));
+executor.getContextAlbum("CustomIntegerAlbum").put("CustomInteger", executor.inFields.get("CustomInteger"));
+executor.getContextAlbum("CustomLongAlbum" ).put("CustomLong" , executor.inFields.get("CustomLong" ));
+executor.getContextAlbum("CustomFloatAlbum" ).put("CustomFloat" , executor.inFields.get("CustomFloat" ));
+executor.getContextAlbum("CustomDoubleAlbum" ).put("CustomDouble" , executor.inFields.get("CustomDouble" ));
+executor.getContextAlbum("CustomStringAlbum" ).put("CustomString" , executor.inFields.get("CustomString" ));
+executor.getContextAlbum("CustomJLongAlbum" ).put("CustomJLong" , executor.inFields.get("CustomJLong" ));
+executor.getContextAlbum("CustomDate0Album" ).put("CustomDate0" , executor.inFields.get("CustomDate0" ));
+executor.getContextAlbum("CustomDate1Album" ).put("CustomDate1" , executor.inFields.get("CustomDate1" ));
+executor.getContextAlbum("CustomDate2Album" ).put("CustomDate2" , executor.inFields.get("CustomDate2" ));
+executor.getContextAlbum("CustomSetAlbum" ).put("CustomSet" , executor.inFields.get("CustomSet" ));
+executor.getContextAlbum("CustomMapAlbum" ).put("CustomMap" , executor.inFields.get("CustomMap" ));
+
+var javaBoolean = executor.getContextAlbum("JavaBooleanAlbum" ).get("JavaBoolean" );
+var javaByte = executor.getContextAlbum("JavaByteAlbum" ).get("JavaByte" );
+var javaShort = executor.getContextAlbum("JavaShortAlbum" ).get("JavaShort" );
+var javaInteger = executor.getContextAlbum("JavaIntegerAlbum" ).get("JavaInteger" );
+var javaLong = executor.getContextAlbum("JavaLongAlbum" ).get("JavaLong" );
+var javaFloat = executor.getContextAlbum("JavaFloatAlbum" ).get("JavaFloat" );
+var javaDouble = executor.getContextAlbum("JavaDoubleAlbum" ).get("JavaDouble" );
+var javaString = executor.getContextAlbum("JavaStringAlbum" ).get("JavaString" );
+var customBoolean = executor.getContextAlbum("CustomBooleanAlbum").get("CustomBoolean");
+var customByte = executor.getContextAlbum("CustomByteAlbum" ).get("CustomByte" );
+var customInteger = executor.getContextAlbum("CustomIntegerAlbum").get("CustomInteger");
+var customLong = executor.getContextAlbum("CustomLongAlbum" ).get("CustomLong" );
+var customFloat = executor.getContextAlbum("CustomFloatAlbum" ).get("CustomFloat" );
+var customDouble = executor.getContextAlbum("CustomDoubleAlbum" ).get("CustomDouble" );
+var customString = executor.getContextAlbum("CustomStringAlbum" ).get("CustomString" );
+var customJLong = executor.getContextAlbum("CustomJLongAlbum" ).get("CustomJLong" );
+var customDate0 = executor.getContextAlbum("CustomDate0Album" ).get("CustomDate0" );
+var customDate1 = executor.getContextAlbum("CustomDate1Album" ).get("CustomDate1" );
+var customDate2 = executor.getContextAlbum("CustomDate2Album" ).get("CustomDate2" );
+var customSet = executor.getContextAlbum("CustomSetAlbum" ).get("CustomSet" );
+var customMap = executor.getContextAlbum("CustomMapAlbum" ).get("CustomMap" );
+
+javaBoolean = !javaBoolean;
+javaByte += 1;
+javaShortType = Java.type("java.lang.Short");
+javaShort = new javaShortType(javaShort + 1);
+javaInteger += 1;
+javaLong += 1;
+javaFloat += 0.99;
+javaDouble += 0.99;
+javaString = javaString + " added to end of string";
+customBoolean.setFlag(!customBoolean);
+customByte .setByteValue (customByte .getByteValue() + 1);
+customInteger.setIntValue (customInteger.getIntValue() + 1);
+customLong .setLongValue (customLong .getLongValue() + 1);
+customFloat .setFloatValue (customFloat .getFloatValue() + 1);
+customDouble .setDoubleValue(customDouble .getDoubleValue() + 1);
+customString .setStringValue(customString .getStringValue() + " added to end of string");
+customJLong .setLongValue (customJLong .getLongValue() + 1);
+
+customDate0Type = Java.type("org.onap.policy.apex.context.test.concepts.TestContextItem008");
+customDate0 = new customDate0Type(1499868391);
+
+customDate1Type = Java.type("org.onap.policy.apex.context.test.concepts.TestContextItem009");
+customDate1 = new customDate1Type();
+customDate1.setDateValue(customDate0);
+
+customDate2Type = Java.type("org.onap.policy.apex.context.test.concepts.TestContextItem00A");
+customDate2 = new customDate2Type();
+customDate2.setDateValue(customDate0);
+
+customSet.getSetValue().add("with");
+customSet.getSetValue().add("a");
+customSet.getSetValue().add("beard");
+
+customMap.getMapValue().put("love", "hate");
+customMap.getMapValue().put("summer", "winter");
+customMap.getMapValue().put("good", "bad");
+
+executor.getContextAlbum("JavaBooleanAlbum" ).put("JavaBoolean" , javaBoolean);
+executor.getContextAlbum("JavaByteAlbum" ).put("JavaByte" , javaByte);
+executor.getContextAlbum("JavaShortAlbum" ).put("JavaShort" , javaShort);
+executor.getContextAlbum("JavaIntegerAlbum" ).put("JavaInteger" , javaInteger);
+executor.getContextAlbum("JavaLongAlbum" ).put("JavaLong" , javaLong);
+executor.getContextAlbum("JavaFloatAlbum" ).put("JavaFloat" , javaFloat);
+executor.getContextAlbum("JavaDoubleAlbum" ).put("JavaDouble" , javaDouble);
+executor.getContextAlbum("JavaStringAlbum" ).put("JavaString" , javaString);
+executor.getContextAlbum("CustomBooleanAlbum").put("CustomBoolean", customBoolean);
+executor.getContextAlbum("CustomByteAlbum" ).put("CustomByte" , customByte);
+executor.getContextAlbum("CustomIntegerAlbum").put("CustomInteger", customInteger);
+executor.getContextAlbum("CustomLongAlbum" ).put("CustomLong" , customLong);
+executor.getContextAlbum("CustomFloatAlbum" ).put("CustomFloat" , customFloat);
+executor.getContextAlbum("CustomDoubleAlbum" ).put("CustomDouble" , customDouble);
+executor.getContextAlbum("CustomStringAlbum" ).put("CustomString" , customString);
+executor.getContextAlbum("CustomJLongAlbum" ).put("CustomJLong" , customJLong);
+executor.getContextAlbum("CustomDate0Album" ).put("CustomDate0" , customDate0);
+executor.getContextAlbum("CustomDate1Album" ).put("CustomDate1" , customDate1);
+executor.getContextAlbum("CustomDate2Album" ).put("CustomDate2" , customDate2);
+executor.getContextAlbum("CustomSetAlbum" ).put("CustomSet" , customSet);
+executor.getContextAlbum("CustomMapAlbum" ).put("CustomMap" , customMap);
+
+executor.outFields.put("JavaBoolean" , executor.getContextAlbum("JavaBooleanAlbum" ).get("JavaBoolean" ));
+executor.outFields.put("JavaByte" , executor.getContextAlbum("JavaByteAlbum" ).get("JavaByte" ));
+executor.outFields.put("JavaShort" , executor.getContextAlbum("JavaShortAlbum" ).get("JavaShort" ));
+executor.outFields.put("JavaInteger" , executor.getContextAlbum("JavaIntegerAlbum" ).get("JavaInteger" ));
+executor.outFields.put("JavaLong" , executor.getContextAlbum("JavaLongAlbum" ).get("JavaLong" ));
+executor.outFields.put("JavaFloat" , executor.getContextAlbum("JavaFloatAlbum" ).get("JavaFloat" ));
+executor.outFields.put("JavaDouble" , executor.getContextAlbum("JavaDoubleAlbum" ).get("JavaDouble" ));
+executor.outFields.put("JavaString" , executor.getContextAlbum("JavaStringAlbum" ).get("JavaString" ));
+executor.outFields.put("CustomBoolean", executor.getContextAlbum("CustomBooleanAlbum").get("CustomBoolean"));
+executor.outFields.put("CustomByte" , executor.getContextAlbum("CustomByteAlbum" ).get("CustomByte" ));
+executor.outFields.put("CustomInteger", executor.getContextAlbum("CustomIntegerAlbum").get("CustomInteger"));
+executor.outFields.put("CustomLong" , executor.getContextAlbum("CustomLongAlbum" ).get("CustomLong" ));
+executor.outFields.put("CustomFloat" , executor.getContextAlbum("CustomFloatAlbum" ).get("CustomFloat" ));
+executor.outFields.put("CustomDouble" , executor.getContextAlbum("CustomDoubleAlbum" ).get("CustomDouble" ));
+executor.outFields.put("CustomString" , executor.getContextAlbum("CustomStringAlbum" ).get("CustomString" ));
+executor.outFields.put("CustomJLong" , executor.getContextAlbum("CustomJLongAlbum" ).get("CustomJLong" ));
+executor.outFields.put("CustomDate0" , executor.getContextAlbum("CustomDate0Album" ).get("CustomDate0" ));
+executor.outFields.put("CustomDate1" , executor.getContextAlbum("CustomDate1Album" ).get("CustomDate1" ));
+executor.outFields.put("CustomDate2" , executor.getContextAlbum("CustomDate2Album" ).get("CustomDate2" ));
+executor.outFields.put("CustomSet" , executor.getContextAlbum("CustomSetAlbum" ).get("CustomSet" ));
+executor.outFields.put("CustomMap" , executor.getContextAlbum("CustomMapAlbum" ).get("CustomMap" ));
+
+executor.logger.debug(executor.outFields);
+
+var returnValueType = Java.type("java.lang.Boolean");
+var returnValue = new returnValueType(true);
+
+LE
+
+policy create name=Test_Policy template=FREEFORM firstState=OnlyState
+
+policy state create name=Test_Policy stateName=OnlyState triggerName=Test_InputEvent defaultTaskName=Test_Task
+policy state output create name=Test_Policy stateName=OnlyState outputName=OnlyState2Out eventName=Test_OutputEvent
+policy state taskref create name=Test_Policy stateName=OnlyState taskName=Test_Task outputType=DIRECT outputName=OnlyState2Out