summaryrefslogtreecommitdiffstats
path: root/auth
diff options
context:
space:
mode:
authorwaqas.ikram <waqas.ikram@ericsson.com>2018-06-11 12:04:33 +0100
committerwaqas.ikram <waqas.ikram@ericsson.com>2018-06-11 13:10:42 +0100
commit275a9d6e8c8caa883a119339926fba475969b8d5 (patch)
tree644b7fc816f41862e4912eea96862ece7b5c134f /auth
parentd0746b062ca6b85eae756db6eb6c4dead037a35a (diff)
Fixing sonar bugs
Change-Id: I05a81755ce132810c9535babb7bae5b9b9e0bd60 Issue-ID: POLICY-859 Signed-off-by: waqas.ikram <waqas.ikram@ericsson.com>
Diffstat (limited to 'auth')
-rw-r--r--auth/cli-codegen/src/main/java/org/onap/policy/apex/auth/clicodegen/CGCliEditor.java293
-rw-r--r--auth/cli-codegen/src/main/java/org/onap/policy/apex/auth/clicodegen/CliEditorContants.java132
-rw-r--r--auth/cli-editor/src/main/java/org/onap/policy/apex/auth/clieditor/ApexCLIEditorMain.java7
-rw-r--r--auth/cli-editor/src/main/java/org/onap/policy/apex/auth/clieditor/CLIEditorLoop.java32
-rw-r--r--auth/cli-editor/src/main/java/org/onap/policy/apex/auth/clieditor/CLILineParser.java9
-rw-r--r--auth/cli-editor/src/main/java/org/onap/policy/apex/auth/clieditor/CLIParameters.java2
-rw-r--r--auth/cli-editor/src/main/java/org/onap/policy/apex/auth/clieditor/KeywordNode.java5
7 files changed, 334 insertions, 146 deletions
diff --git a/auth/cli-codegen/src/main/java/org/onap/policy/apex/auth/clicodegen/CGCliEditor.java b/auth/cli-codegen/src/main/java/org/onap/policy/apex/auth/clicodegen/CGCliEditor.java
index ca41e5f5f..30e883aae 100644
--- a/auth/cli-codegen/src/main/java/org/onap/policy/apex/auth/clicodegen/CGCliEditor.java
+++ b/auth/cli-codegen/src/main/java/org/onap/policy/apex/auth/clicodegen/CGCliEditor.java
@@ -20,6 +20,60 @@
package org.onap.policy.apex.auth.clicodegen;
+import static org.onap.policy.apex.auth.clicodegen.CliEditorContants.ALBUM_NAME;
+import static org.onap.policy.apex.auth.clicodegen.CliEditorContants.ALBUM_VERSION;
+import static org.onap.policy.apex.auth.clicodegen.CliEditorContants.CONTEXT_REFS;
+import static org.onap.policy.apex.auth.clicodegen.CliEditorContants.CTX_REFS;
+import static org.onap.policy.apex.auth.clicodegen.CliEditorContants.DECLARATION;
+import static org.onap.policy.apex.auth.clicodegen.CliEditorContants.DEFAULT_TASK;
+import static org.onap.policy.apex.auth.clicodegen.CliEditorContants.DEFAULT_TASK_VERSION;
+import static org.onap.policy.apex.auth.clicodegen.CliEditorContants.DEFAULT_VALUE;
+import static org.onap.policy.apex.auth.clicodegen.CliEditorContants.DEFINITIONS;
+import static org.onap.policy.apex.auth.clicodegen.CliEditorContants.DESCRIPTION;
+import static org.onap.policy.apex.auth.clicodegen.CliEditorContants.EVENT_NAME;
+import static org.onap.policy.apex.auth.clicodegen.CliEditorContants.EVENT_VERSION;
+import static org.onap.policy.apex.auth.clicodegen.CliEditorContants.FIELDS;
+import static org.onap.policy.apex.auth.clicodegen.CliEditorContants.FIELD_NAME;
+import static org.onap.policy.apex.auth.clicodegen.CliEditorContants.FIELD_SCHEMA;
+import static org.onap.policy.apex.auth.clicodegen.CliEditorContants.FIELD_SCHEMA_VERSION;
+import static org.onap.policy.apex.auth.clicodegen.CliEditorContants.FINALIZER_LOGICS;
+import static org.onap.policy.apex.auth.clicodegen.CliEditorContants.FINALIZER_LOGIC_NAME;
+import static org.onap.policy.apex.auth.clicodegen.CliEditorContants.FIRST_STATE;
+import static org.onap.policy.apex.auth.clicodegen.CliEditorContants.FLAVOUR;
+import static org.onap.policy.apex.auth.clicodegen.CliEditorContants.INFIELDS;
+import static org.onap.policy.apex.auth.clicodegen.CliEditorContants.LOGIC;
+import static org.onap.policy.apex.auth.clicodegen.CliEditorContants.LOGIC_FLAVOUR;
+import static org.onap.policy.apex.auth.clicodegen.CliEditorContants.NAME;
+import static org.onap.policy.apex.auth.clicodegen.CliEditorContants.NAME_SPACE;
+import static org.onap.policy.apex.auth.clicodegen.CliEditorContants.NEXT_STATE;
+import static org.onap.policy.apex.auth.clicodegen.CliEditorContants.OPTIONAL;
+import static org.onap.policy.apex.auth.clicodegen.CliEditorContants.OUTFIELDS;
+import static org.onap.policy.apex.auth.clicodegen.CliEditorContants.OUTPUTS;
+import static org.onap.policy.apex.auth.clicodegen.CliEditorContants.OUTPUT_NAME;
+import static org.onap.policy.apex.auth.clicodegen.CliEditorContants.OUTPUT_TYPE;
+import static org.onap.policy.apex.auth.clicodegen.CliEditorContants.PARAMS;
+import static org.onap.policy.apex.auth.clicodegen.CliEditorContants.PAR_NAME;
+import static org.onap.policy.apex.auth.clicodegen.CliEditorContants.POLICY_NAME;
+import static org.onap.policy.apex.auth.clicodegen.CliEditorContants.SCHEMA;
+import static org.onap.policy.apex.auth.clicodegen.CliEditorContants.SCHEMA_NAME;
+import static org.onap.policy.apex.auth.clicodegen.CliEditorContants.SCHEMA_VERSION;
+import static org.onap.policy.apex.auth.clicodegen.CliEditorContants.SCOPE;
+import static org.onap.policy.apex.auth.clicodegen.CliEditorContants.SOURCE;
+import static org.onap.policy.apex.auth.clicodegen.CliEditorContants.STATES;
+import static org.onap.policy.apex.auth.clicodegen.CliEditorContants.STATE_NAME;
+import static org.onap.policy.apex.auth.clicodegen.CliEditorContants.TARGET;
+import static org.onap.policy.apex.auth.clicodegen.CliEditorContants.TASKS;
+import static org.onap.policy.apex.auth.clicodegen.CliEditorContants.TASK_LOCAL_NAME;
+import static org.onap.policy.apex.auth.clicodegen.CliEditorContants.TASK_NAME;
+import static org.onap.policy.apex.auth.clicodegen.CliEditorContants.TASK_VERSION;
+import static org.onap.policy.apex.auth.clicodegen.CliEditorContants.TEMPLATE;
+import static org.onap.policy.apex.auth.clicodegen.CliEditorContants.TRIGGER_NAME;
+import static org.onap.policy.apex.auth.clicodegen.CliEditorContants.TRIGGER_VERSION;
+import static org.onap.policy.apex.auth.clicodegen.CliEditorContants.TS_LOGIC;
+import static org.onap.policy.apex.auth.clicodegen.CliEditorContants.UUID;
+import static org.onap.policy.apex.auth.clicodegen.CliEditorContants.VERSION;
+import static org.onap.policy.apex.auth.clicodegen.CliEditorContants.WRITABLE;
+
import java.util.List;
import org.stringtemplate.v4.ST;
@@ -31,6 +85,7 @@ import org.stringtemplate.v4.STGroupFile;
* @author Sven van der Meer (sven.van.der.meer@ericsson.com)
*/
public class CGCliEditor {
+
// CHECKSTYLE:OFF: ParameterNumber
/** The name of the STG file for the code generator. */
@@ -70,10 +125,10 @@ public class CGCliEditor {
throw new IllegalArgumentException("model description should not be blank");
}
- model.add("name", name);
- model.add("version", version);
- model.add("uuid", uuid);
- model.add("description", description);
+ model.add(NAME, name);
+ model.add(VERSION, version);
+ model.add(UUID, uuid);
+ model.add(DESCRIPTION, description);
}
/**
@@ -109,13 +164,13 @@ public class CGCliEditor {
public void addSchemaDeclaration(final String name, final String version, final String uuid,
final String description, final String flavour, final String schema) {
final ST st = stg.getInstanceOf("schemaDecl");
- st.add("name", name);
- st.add("version", version);
- st.add("uuid", uuid);
- st.add("description", description);
- st.add("flavour", flavour);
- st.add("schema", schema);
- model.add("declarations", st);
+ st.add(NAME, name);
+ st.add(VERSION, version);
+ st.add(UUID, uuid);
+ st.add(DESCRIPTION, description);
+ st.add(FLAVOUR, flavour);
+ st.add(SCHEMA, schema);
+ model.add(DECLARATION, st);
}
/**
@@ -134,15 +189,15 @@ public class CGCliEditor {
final String description, final String scope, final boolean writable, final String schemaName,
final String schemaVersion) {
final ST st = stg.getInstanceOf("ctxAlbumDecl");
- st.add("name", name);
- st.add("version", version);
- st.add("uuid", uuid);
- st.add("description", description);
- st.add("scope", scope);
- st.add("writable", writable);
- st.add("schemaName", schemaName);
- st.add("schemaVersion", schemaVersion);
- model.add("declarations", st);
+ st.add(NAME, name);
+ st.add(VERSION, version);
+ st.add(UUID, uuid);
+ st.add(DESCRIPTION, description);
+ st.add(SCOPE, scope);
+ st.add(WRITABLE, writable);
+ st.add(SCHEMA_NAME, schemaName);
+ st.add(SCHEMA_VERSION, schemaVersion);
+ model.add(DECLARATION, st);
}
/**
@@ -159,12 +214,12 @@ public class CGCliEditor {
public ST createEventFieldDefinition(final String eventName, final String version, final String fieldName,
final String fieldSchema, final String fieldSchemaVersion, final boolean optional) {
final ST st = stg.getInstanceOf("eventDefField");
- st.add("eventName", eventName);
- st.add("version", version);
- st.add("fieldName", fieldName);
- st.add("fieldSchema", fieldSchema);
- st.add("fieldSchemaVersion", fieldSchemaVersion);
- st.add("optional", optional);
+ st.add(EVENT_NAME, eventName);
+ st.add(VERSION, version);
+ st.add(FIELD_NAME, fieldName);
+ st.add(FIELD_SCHEMA, fieldSchema);
+ st.add(FIELD_SCHEMA_VERSION, fieldSchemaVersion);
+ st.add(OPTIONAL, optional);
return st;
}
@@ -181,10 +236,10 @@ public class CGCliEditor {
public ST createTaskDefLogic(final String taskName, final String version, final String flavour,
final String logic) {
final ST st = stg.getInstanceOf("taskDefLogic");
- st.add("taskName", taskName);
- st.add("version", version);
- st.add("flavour", flavour);
- st.add("logic", logic);
+ st.add(TASK_NAME, taskName);
+ st.add(VERSION, version);
+ st.add(FLAVOUR, flavour);
+ st.add(LOGIC, logic);
return st;
}
@@ -204,21 +259,21 @@ public class CGCliEditor {
final String description, final String nameSpace, final String source, final String target,
final List<ST> fields) {
final ST st = stg.getInstanceOf("eventDecl");
- st.add("name", name);
- st.add("version", version);
- st.add("uuid", uuid);
- st.add("description", description);
- st.add("source", source);
- st.add("target", target);
- st.add("fields", fields);
+ st.add(NAME, name);
+ st.add(VERSION, version);
+ st.add(UUID, uuid);
+ st.add(DESCRIPTION, description);
+ st.add(SOURCE, source);
+ st.add(TARGET, target);
+ st.add(FIELDS, fields);
if (nameSpace != null) {
- st.add("nameSpace", nameSpace);
+ st.add(NAME_SPACE, nameSpace);
} else if (defaultNamespace != null) {
- st.add("nameSpace", defaultNamespace);
+ st.add(NAME_SPACE, defaultNamespace);
}
- model.add("declarations", st);
+ model.add(DECLARATION, st);
}
/**
@@ -238,16 +293,16 @@ public class CGCliEditor {
final List<ST> infields, final List<ST> outfields, final ST logic, final List<ST> parameters,
final List<ST> contextRefs) {
final ST st = stg.getInstanceOf("taskDecl");
- st.add("name", name);
- st.add("version", version);
- st.add("uuid", uuid);
- st.add("description", description);
- st.add("infields", infields);
- st.add("outfields", outfields);
- st.add("logic", logic);
- st.add("parameters", parameters);
- st.add("contextRefs", contextRefs);
- model.add("declarations", st);
+ st.add(NAME, name);
+ st.add(VERSION, version);
+ st.add(UUID, uuid);
+ st.add(DESCRIPTION, description);
+ st.add(INFIELDS, infields);
+ st.add(OUTFIELDS, outfields);
+ st.add(LOGIC, logic);
+ st.add(PARAMS, parameters);
+ st.add(CONTEXT_REFS, contextRefs);
+ model.add(DECLARATION, st);
}
/**
@@ -264,14 +319,14 @@ public class CGCliEditor {
public void addPolicyDefinition(final String name, final String version, final String uuid,
final String description, final String template, final String firstState, final List<ST> states) {
final ST st = stg.getInstanceOf("policyDef");
- st.add("name", name);
- st.add("version", version);
- st.add("uuid", uuid);
- st.add("description", description);
- st.add("template", template);
- st.add("firstState", firstState);
- st.add("states", states);
- model.add("definitions", st);
+ st.add(NAME, name);
+ st.add(VERSION, version);
+ st.add(UUID, uuid);
+ st.add(DESCRIPTION, description);
+ st.add(TEMPLATE, template);
+ st.add(FIRST_STATE, firstState);
+ st.add(STATES, states);
+ model.add(DEFINITIONS, st);
}
/**
@@ -287,11 +342,11 @@ public class CGCliEditor {
public ST createTaskDefinitionInfields(final String taskName, final String version, final String fieldName,
final String fieldSchema, final String fieldSchemaVersion) {
final ST st = stg.getInstanceOf("taskDefInputFields");
- st.add("taskName", taskName);
- st.add("version", version);
- st.add("fieldName", fieldName);
- st.add("fieldSchema", fieldSchema);
- st.add("fieldSchemaVersion", fieldSchemaVersion);
+ st.add(TASK_NAME, taskName);
+ st.add(VERSION, version);
+ st.add(FIELD_NAME, fieldName);
+ st.add(FIELD_SCHEMA, fieldSchema);
+ st.add(FIELD_SCHEMA_VERSION, fieldSchemaVersion);
return st;
}
@@ -308,11 +363,11 @@ public class CGCliEditor {
public ST createTaskDefinitionOutfields(final String taskName, final String version, final String fieldName,
final String fieldSchema, final String fieldSchemaVersion) {
final ST st = stg.getInstanceOf("taskDefOutputFields");
- st.add("taskName", taskName);
- st.add("version", version);
- st.add("fieldName", fieldName);
- st.add("fieldSchema", fieldSchema);
- st.add("fieldSchemaVersion", fieldSchemaVersion);
+ st.add(TASK_NAME, taskName);
+ st.add(VERSION, version);
+ st.add(FIELD_NAME, fieldName);
+ st.add(FIELD_SCHEMA, fieldSchema);
+ st.add(FIELD_SCHEMA_VERSION, fieldSchemaVersion);
return st;
}
@@ -328,10 +383,10 @@ public class CGCliEditor {
public ST createTaskDefinitionParameters(final String name, final String version, final String parName,
final String defaultValue) {
final ST st = stg.getInstanceOf("taskDefParameter");
- st.add("name", name);
- st.add("version", version);
- st.add("parName", parName);
- st.add("defaultValue", defaultValue);
+ st.add(NAME, name);
+ st.add(VERSION, version);
+ st.add(PAR_NAME, parName);
+ st.add(DEFAULT_VALUE, defaultValue);
return st;
}
@@ -347,10 +402,10 @@ public class CGCliEditor {
public ST createTaskDefinitionContextRef(final String name, final String version, final String albumName,
final String albumVersion) {
final ST st = stg.getInstanceOf("taskDefCtxRef");
- st.add("name", name);
- st.add("version", version);
- st.add("albumName", albumName);
- st.add("albumVersion", albumVersion);
+ st.add(NAME, name);
+ st.add(VERSION, version);
+ st.add(ALBUM_NAME, albumName);
+ st.add(ALBUM_VERSION, albumVersion);
return st;
}
@@ -372,14 +427,14 @@ public class CGCliEditor {
final String taskLocalName, final String taskName, final String taskVersion, final String outputType,
final String outputName) {
final ST st = stg.getInstanceOf("policyStateTask");
- st.add("policyName", policyName);
- st.add("version", version);
- st.add("stateName", stateName);
- st.add("taskLocalName", taskLocalName);
- st.add("taskName", taskName);
- st.add("taskVersion", taskVersion);
- st.add("outputType", outputType);
- st.add("outputName", outputName);
+ st.add(POLICY_NAME, policyName);
+ st.add(VERSION, version);
+ st.add(STATE_NAME, stateName);
+ st.add(TASK_LOCAL_NAME, taskLocalName);
+ st.add(TASK_NAME, taskName);
+ st.add(TASK_VERSION, taskVersion);
+ st.add(OUTPUT_TYPE, outputType);
+ st.add(OUTPUT_NAME, outputName);
return st;
}
@@ -398,13 +453,13 @@ public class CGCliEditor {
public ST createPolicyStateOutput(final String policyName, final String version, final String stateName,
final String outputName, final String eventName, final String eventVersion, final String nextState) {
final ST st = stg.getInstanceOf("policyStateOutput");
- st.add("policyName", policyName);
- st.add("version", version);
- st.add("stateName", stateName);
- st.add("outputName", outputName);
- st.add("eventName", eventName);
- st.add("eventVersion", eventVersion);
- st.add("nextState", nextState);
+ st.add(POLICY_NAME, policyName);
+ st.add(VERSION, version);
+ st.add(STATE_NAME, stateName);
+ st.add(OUTPUT_NAME, outputName);
+ st.add(EVENT_NAME, eventName);
+ st.add(EVENT_VERSION, eventVersion);
+ st.add(NEXT_STATE, nextState);
return st;
}
@@ -430,18 +485,18 @@ public class CGCliEditor {
final String defaultTaskVersion, final List<ST> outputs, final List<ST> tasks, final List<ST> tsLogic,
final List<ST> finalizerLogics, final List<ST> ctxRefs) {
final ST st = stg.getInstanceOf("policyStateDef");
- st.add("policyName", policyName);
- st.add("version", version);
- st.add("stateName", stateName);
- st.add("triggerName", triggerName);
- st.add("triggerVersion", triggerVersion);
- st.add("defaultTask", defaultTask);
- st.add("defaultTaskVersion", defaultTaskVersion);
- st.add("outputs", outputs);
- st.add("tasks", tasks);
- st.add("tsLogic", tsLogic);
- st.add("finalizerLogics", finalizerLogics);
- st.add("ctxRefs", ctxRefs);
+ st.add(POLICY_NAME, policyName);
+ st.add(VERSION, version);
+ st.add(STATE_NAME, stateName);
+ st.add(TRIGGER_NAME, triggerName);
+ st.add(TRIGGER_VERSION, triggerVersion);
+ st.add(DEFAULT_TASK, defaultTask);
+ st.add(DEFAULT_TASK_VERSION, defaultTaskVersion);
+ st.add(OUTPUTS, outputs);
+ st.add(TASKS, tasks);
+ st.add(TS_LOGIC, tsLogic);
+ st.add(FINALIZER_LOGICS, finalizerLogics);
+ st.add(CTX_REFS, ctxRefs);
return st;
}
@@ -459,11 +514,11 @@ public class CGCliEditor {
public ST createPolicyStateDefTaskSelLogic(final String name, final String version, final String stateName,
final String logicFlavour, final String logic) {
final ST st = stg.getInstanceOf("policyStateTaskSelectionLogic");
- st.add("name", name);
- st.add("version", version);
- st.add("stateName", stateName);
- st.add("logicFlavour", logicFlavour);
- st.add("logic", logic);
+ st.add(NAME, name);
+ st.add(VERSION, version);
+ st.add(STATE_NAME, stateName);
+ st.add(LOGIC_FLAVOUR, logicFlavour);
+ st.add(LOGIC, logic);
return st;
}
@@ -482,12 +537,12 @@ public class CGCliEditor {
public ST createPolicyStateDefFinalizerLogic(final String name, final String version, final String stateName,
final String finalizerLogicName, final String logicFlavour, final String logic) {
final ST st = stg.getInstanceOf("policyStateFinalizerLogic");
- st.add("name", name);
- st.add("version", version);
- st.add("stateName", stateName);
- st.add("finalizerLogicName", finalizerLogicName);
- st.add("logicFlavour", logicFlavour);
- st.add("logic", logic);
+ st.add(NAME, name);
+ st.add(VERSION, version);
+ st.add(STATE_NAME, stateName);
+ st.add(FINALIZER_LOGIC_NAME, finalizerLogicName);
+ st.add(LOGIC_FLAVOUR, logicFlavour);
+ st.add(LOGIC, logic);
return st;
}
@@ -504,11 +559,11 @@ public class CGCliEditor {
public ST createPolicyStateDefContextRef(final String name, final String version, final String stateName,
final String albumName, final String albumVersion) {
final ST st = stg.getInstanceOf("policyStateContextRef");
- st.add("name", name);
- st.add("version", version);
- st.add("stateName", stateName);
- st.add("albumName", albumName);
- st.add("albumVersion", albumVersion);
+ st.add(NAME, name);
+ st.add(VERSION, version);
+ st.add(STATE_NAME, stateName);
+ st.add(ALBUM_NAME, albumName);
+ st.add(ALBUM_VERSION, albumVersion);
return st;
}
diff --git a/auth/cli-codegen/src/main/java/org/onap/policy/apex/auth/clicodegen/CliEditorContants.java b/auth/cli-codegen/src/main/java/org/onap/policy/apex/auth/clicodegen/CliEditorContants.java
new file mode 100644
index 000000000..3a82af796
--- /dev/null
+++ b/auth/cli-codegen/src/main/java/org/onap/policy/apex/auth/clicodegen/CliEditorContants.java
@@ -0,0 +1,132 @@
+/*-
+ * ============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.clicodegen;
+
+public class CliEditorContants {
+
+ public static final String FINALIZER_LOGIC_NAME = "finalizerLogicName";
+
+ public static final String LOGIC_FLAVOUR = "logicFlavour";
+
+ public static final String CTX_REFS = "ctxRefs";
+
+ public static final String FINALIZER_LOGICS = "finalizerLogics";
+
+ public static final String TS_LOGIC = "tsLogic";
+
+ public static final String TASKS = "tasks";
+
+ public static final String OUTPUTS = "outputs";
+
+ public static final String DEFAULT_TASK_VERSION = "defaultTaskVersion";
+
+ public static final String DEFAULT_TASK = "defaultTask";
+
+ public static final String TRIGGER_VERSION = "triggerVersion";
+
+ public static final String TRIGGER_NAME = "triggerName";
+
+ public static final String NEXT_STATE = "nextState";
+
+ public static final String EVENT_VERSION = "eventVersion";
+
+ public static final String OUTPUT_NAME = "outputName";
+
+ public static final String OUTPUT_TYPE = "outputType";
+
+ public static final String TASK_VERSION = "taskVersion";
+
+ public static final String TASK_LOCAL_NAME = "taskLocalName";
+
+ public static final String STATE_NAME = "stateName";
+
+ public static final String POLICY_NAME = "policyName";
+
+ public static final String ALBUM_VERSION = "albumVersion";
+
+ public static final String ALBUM_NAME = "albumName";
+
+ public static final String DEFAULT_VALUE = "defaultValue";
+
+ public static final String PAR_NAME = "parName";
+
+ public static final String CONTEXT_REFS = "contextRefs";
+
+ public static final String PARAMS = "parameters";
+
+ public static final String OUTFIELDS = "outfields";
+
+ public static final String INFIELDS = "infields";
+
+ public static final String NAME_SPACE = "nameSpace";
+
+ public static final String FIELDS = "fields";
+
+ public static final String TARGET = "target";
+
+ public static final String SOURCE = "source";
+
+ public static final String LOGIC = "logic";
+
+ public static final String TASK_NAME = "taskName";
+
+ public static final String OPTIONAL = "optional";
+
+ public static final String FIELD_SCHEMA_VERSION = "fieldSchemaVersion";
+
+ public static final String FIELD_SCHEMA = "fieldSchema";
+
+ public static final String FIELD_NAME = "fieldName";
+
+ public static final String EVENT_NAME = "eventName";
+
+ public static final String DECLARATION = "declarations";
+
+ public static final String SCHEMA = "schema";
+
+ public static final String FLAVOUR = "flavour";
+
+ public static final String DESCRIPTION = "description";
+
+ public static final String UUID = "uuid";
+
+ public static final String VERSION = "version";
+
+ public static final String NAME = "name";
+
+ public static final String SCHEMA_VERSION = "schemaVersion";
+
+ public static final String SCHEMA_NAME = "schemaName";
+
+ public static final String WRITABLE = "writable";
+
+ public static final String STATES = "states";
+
+ public static final String FIRST_STATE = "firstState";
+
+ public static final String TEMPLATE = "template";
+
+ public static final String SCOPE = "scope";
+
+ public static final String DEFINITIONS = "definitions";
+
+ private CliEditorContants() {}
+}
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
index cb1a92eaf..0d36d2daa 100644
--- 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
@@ -68,7 +68,7 @@ public class ApexCLIEditorMain {
}
parameters.validate();
} catch (final Exception e) {
- LOGGER.error("start of Apex command line editor failed, " + e.getMessage());
+ LOGGER.error("start of Apex command line editor failed, ", e);
errorCount++;
return;
}
@@ -80,8 +80,7 @@ public class ApexCLIEditorMain {
commands = new JSONHandler<CLICommands>().read(CLICommands.class, parameters.getMetadataStream());
} catch (final Exception e) {
LOGGER.error("start of Apex command line editor failed, error reading command metadata from "
- + parameters.getMetadataLocation());
- LOGGER.error(e.getMessage());
+ + parameters.getMetadataLocation(), e);
errorCount++;
return;
}
@@ -139,7 +138,7 @@ public class ApexCLIEditorMain {
modelHandler =
new ApexModelHandler(apexModelProperties.getProperties(), parameters.getInputModelFileName());
} catch (final Exception e) {
- LOGGER.error("execution of Apex command line editor failed: " + e.getMessage());
+ LOGGER.error("execution of Apex command line editor failed: ", e);
errorCount++;
return;
}
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
index 560648901..4eacde04b 100644
--- 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
@@ -20,6 +20,8 @@
package org.onap.policy.apex.auth.clieditor;
+import static org.onap.policy.apex.model.utilities.TreeMapUtils.findMatchingEntries;
+
import java.io.BufferedReader;
import java.io.File;
import java.io.IOException;
@@ -170,7 +172,7 @@ public class CLIEditorLoop {
try {
// Parse the line into a list of commands and arguments
- final ArrayList<String> commandWords = parser.parse(line, logicBlock);
+ final List<String> commandWords = parser.parse(line, logicBlock);
// Find the command, if the command is null, then we are simply changing position in
// the hierarchy
@@ -240,7 +242,7 @@ public class CLIEditorLoop {
* @return The found command
*/
- private CLICommand findCommand(final ArrayList<String> commandWords) {
+ private CLICommand findCommand(final List<String> commandWords) {
CLICommand command = null;
final KeywordNode startKeywordNode = keywordNodeDeque.peek();
@@ -258,8 +260,8 @@ public class CLIEditorLoop {
// 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) {
+ findMatchingEntries(searchKeywordNode.getChildren(), commandWords.get(i));
+ if (foundNodeEntries.isEmpty()) {
unwindStack(startKeywordNode);
throw new CLIException("command not found: " + stringAL2String(commandWords));
} else if (foundNodeEntries.size() > 1) {
@@ -311,7 +313,7 @@ public class CLIEditorLoop {
* @return the argument values
*/
private TreeMap<String, CLIArgumentValue> getArgumentValues(final CLICommand command,
- final ArrayList<String> commandWords) {
+ final List<String> commandWords) {
final TreeMap<String, CLIArgumentValue> argumentValues = new TreeMap<>();
for (final CLIArgument argument : command.getArgumentList()) {
if (argument != null) {
@@ -338,13 +340,11 @@ public class CLIEditorLoop {
// 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");
- }
+ // Argument values are null by default so if this argument is not nullable it is
+ // mandatory
+ if (!argumentValue.isSpecified() && !argumentValue.getCliArgument().isNullable()) {
+ throw new CLIException("command " + stringAL2String(commandWords) + ": " + " mandatory argument \""
+ + argumentValue.getCliArgument().getArgumentName() + "\" not specified");
}
}
@@ -358,7 +358,7 @@ public class CLIEditorLoop {
* @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) {
+ private ArrayList<Entry<String, String>> getCommandArguments(final List<String> commandWords) {
final ArrayList<Entry<String, String>> arguments = new ArrayList<>();
// Iterate over the command words, arguments are of the format name=value
@@ -398,11 +398,11 @@ public class CLIEditorLoop {
* @return the result of execution of the command
*/
private ApexAPIResult exceuteSystemCommand(final CLICommand command, final PrintWriter writer) {
- if (command.getName().equals("back")) {
+ if ("back".equals(command.getName())) {
return executeBackCommand();
- } else if (command.getName().equals("help")) {
+ } else if ("help".equals(command.getName())) {
return executeHelpCommand(writer);
- } else if (command.getName().equals("quit")) {
+ } else if ("quit".equals(command.getName())) {
return executeQuitCommand();
} else {
return new ApexAPIResult(RESULT.SUCCESS);
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
index fd4541f28..502eb48c5 100644
--- 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
@@ -21,6 +21,7 @@
package org.onap.policy.apex.auth.clieditor;
import java.util.ArrayList;
+import java.util.List;
/**
* This class chops a command line up into commands, parameters and arguments.
@@ -43,7 +44,7 @@ public class CLILineParser {
* @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) {
+ public List<String> parse(final String line, final String logicBlock) {
return checkFormat(
mergeArguments(mergeEquals(
splitOnEquals(stripAndSplitWords(mergeQuotes(splitOnChar(stripComments(line), '\"')))))),
@@ -78,12 +79,12 @@ public class CLILineParser {
final ArrayList<String> wordsWithQuotesMerged = new ArrayList<>();
for (int i = 0; i < wordsSplitOnQuotes.size();) {
- if (wordsSplitOnQuotes.get(i).equals("\"")) {
+ if ("\"".equals(wordsSplitOnQuotes.get(i))) {
String quotedWord = wordsSplitOnQuotes.get(i++);
for (; i < wordsSplitOnQuotes.size(); i++) {
quotedWord += wordsSplitOnQuotes.get(i);
- if (wordsSplitOnQuotes.get(i).equals("\"")) {
+ if ("\"".equals(wordsSplitOnQuotes.get(i))) {
i++;
break;
}
@@ -147,7 +148,7 @@ public class CLILineParser {
continue;
}
- if (wordsSplitOnEquals.get(i).equals("=")) {
+ if ("=".equals(wordsSplitOnEquals.get(i))) {
if (i < wordsSplitOnEquals.size() - 1 && !wordsSplitOnEquals.get(i + 1).startsWith("=")) {
wordsWithEqualsMerged.add(wordsSplitOnEquals.get(i) + wordsSplitOnEquals.get(i + 1));
i += 2;
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
index 476d17e3f..5f363cfa7 100644
--- 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
@@ -216,7 +216,7 @@ public class CLIParameters {
try {
theFile.createNewFile();
} catch (final IOException e) {
- throw new CLIException("file " + fileName + " cannot be created: " + e.getMessage());
+ throw new CLIException("file " + fileName + " cannot be created: ", e);
}
}
}
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
index 06579e073..6be5c6846 100644
--- 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
@@ -22,6 +22,7 @@ package org.onap.policy.apex.auth.clieditor;
import java.util.ArrayList;
import java.util.List;
+import java.util.NavigableMap;
import java.util.Set;
import java.util.TreeMap;
import java.util.TreeSet;
@@ -70,7 +71,7 @@ public class KeywordNode implements Comparable<KeywordNode> {
* @param incomingCommand the command
*/
public void processKeywords(final List<String> keywordList, final CLICommand incomingCommand) {
- if (keywordList.size() <= 0) {
+ if (keywordList.isEmpty()) {
this.command = incomingCommand;
return;
}
@@ -118,7 +119,7 @@ public class KeywordNode implements Comparable<KeywordNode> {
*
* @return the children of this keyword node
*/
- public TreeMap<String, KeywordNode> getChildren() {
+ public NavigableMap<String, KeywordNode> getChildren() {
return children;
}