summaryrefslogtreecommitdiffstats
path: root/gui-editors/gui-editor-apex
diff options
context:
space:
mode:
authorJim Hahn <jrh3@att.com>2021-05-10 12:52:21 -0400
committerJim Hahn <jrh3@att.com>2021-05-10 12:53:22 -0400
commitcc035870af8fa909fc19774f0b9382cf00e051a8 (patch)
treea382cf847fe38a7e0c8e049b702eee22b6a54f80 /gui-editors/gui-editor-apex
parentbb9489515b7a4bcbfc3e28407ec5f4f1fc4df6bb (diff)
Fix sonars in policy-gui
Fixed: - use "var" Only fixed the ones I saw visually, as SonarLint wouldn't run - something about missing node.js. Issue-ID: POLICY-3094 Change-Id: I594d424b42ce446d86724d75b1dd9ec868c14f2b Signed-off-by: Jim Hahn <jrh3@att.com>
Diffstat (limited to 'gui-editors/gui-editor-apex')
-rw-r--r--gui-editors/gui-editor-apex/src/main/java/org/onap/policy/gui/editors/apex/rest/ApexEditorMain.java4
-rw-r--r--gui-editors/gui-editor-apex/src/main/java/org/onap/policy/gui/editors/apex/rest/ApexEditorParameterParser.java9
-rw-r--r--gui-editors/gui-editor-apex/src/main/java/org/onap/policy/gui/editors/apex/rest/ApexEditorParameters.java10
-rw-r--r--gui-editors/gui-editor-apex/src/main/java/org/onap/policy/gui/editors/apex/rest/handling/ApexEditorRestResource.java11
-rw-r--r--gui-editors/gui-editor-apex/src/main/java/org/onap/policy/gui/editors/apex/rest/handling/ContextAlbumHandler.java4
-rw-r--r--gui-editors/gui-editor-apex/src/main/java/org/onap/policy/gui/editors/apex/rest/handling/ContextSchemaHandler.java4
-rw-r--r--gui-editors/gui-editor-apex/src/main/java/org/onap/policy/gui/editors/apex/rest/handling/EventHandler.java6
-rw-r--r--gui-editors/gui-editor-apex/src/main/java/org/onap/policy/gui/editors/apex/rest/handling/ModelHandler.java9
-rw-r--r--gui-editors/gui-editor-apex/src/main/java/org/onap/policy/gui/editors/apex/rest/handling/PolicyHandler.java14
-rw-r--r--gui-editors/gui-editor-apex/src/main/java/org/onap/policy/gui/editors/apex/rest/handling/RestSession.java8
-rw-r--r--gui-editors/gui-editor-apex/src/main/java/org/onap/policy/gui/editors/apex/rest/handling/RestUtils.java19
-rw-r--r--gui-editors/gui-editor-apex/src/main/java/org/onap/policy/gui/editors/apex/rest/handling/TaskHandler.java14
-rw-r--r--gui-editors/gui-editor-apex/src/main/java/org/onap/policy/gui/editors/apex/rest/handling/bean/BeanBase.java4
-rw-r--r--gui-editors/gui-editor-apex/src/main/java/org/onap/policy/gui/editors/apex/rest/handling/plugin/upload/PolicyUploadHandler.java11
-rw-r--r--gui-editors/gui-editor-apex/src/test/java/org/onap/policy/gui/editors/apex/rest/ApexEditorStartupTest.java9
-rw-r--r--gui-editors/gui-editor-apex/src/test/java/org/onap/policy/gui/editors/apex/rest/RestInterfaceTest.java5
16 files changed, 70 insertions, 71 deletions
diff --git a/gui-editors/gui-editor-apex/src/main/java/org/onap/policy/gui/editors/apex/rest/ApexEditorMain.java b/gui-editors/gui-editor-apex/src/main/java/org/onap/policy/gui/editors/apex/rest/ApexEditorMain.java
index dd9710f..3a10759 100644
--- a/gui-editors/gui-editor-apex/src/main/java/org/onap/policy/gui/editors/apex/rest/ApexEditorMain.java
+++ b/gui-editors/gui-editor-apex/src/main/java/org/onap/policy/gui/editors/apex/rest/ApexEditorMain.java
@@ -84,7 +84,7 @@ public class ApexEditorMain {
this.outStream = outStream;
// Editor parameter parsing
- final ApexEditorParameterParser parser = new ApexEditorParameterParser();
+ final var parser = new ApexEditorParameterParser();
try {
// Get and check the parameters
@@ -216,7 +216,7 @@ public class ApexEditorMain {
*/
public static void main(final String[] args) {
try {
- final ApexEditorMain editorMain = new ApexEditorMain(args, System.out);
+ final var editorMain = new ApexEditorMain(args, System.out);
editorMain.init();
} catch (final Exception e) {
LOGGER.error("start failed", e);
diff --git a/gui-editors/gui-editor-apex/src/main/java/org/onap/policy/gui/editors/apex/rest/ApexEditorParameterParser.java b/gui-editors/gui-editor-apex/src/main/java/org/onap/policy/gui/editors/apex/rest/ApexEditorParameterParser.java
index 4337efc..7487fa0 100644
--- a/gui-editors/gui-editor-apex/src/main/java/org/onap/policy/gui/editors/apex/rest/ApexEditorParameterParser.java
+++ b/gui-editors/gui-editor-apex/src/main/java/org/onap/policy/gui/editors/apex/rest/ApexEditorParameterParser.java
@@ -2,6 +2,7 @@
* ============LICENSE_START=======================================================
* Copyright (C) 2016-2018 Ericsson. All rights reserved.
* Modifications Copyright (C) 2020 Nordix Foundation.
+ * Modifications Copyright (C) 2021 AT&T Intellectual Property. All rights reserved.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -123,7 +124,7 @@ public class ApexEditorParameterParser {
throw new ApexEditorParameterException("invalid command line arguments specified : " + e.getMessage());
}
- final ApexEditorParameters parameters = new ApexEditorParameters();
+ final var parameters = new ApexEditorParameters();
final String[] remainingArgs = commandLine.getArgs();
if (commandLine.getArgs().length > 0) {
@@ -180,10 +181,10 @@ public class ApexEditorParameterParser {
* @return the help
*/
public String getHelp(final String mainClassName) {
- final StringWriter stringWriter = new StringWriter();
- final PrintWriter stringPrintWriter = new PrintWriter(stringWriter);
+ final var stringWriter = new StringWriter();
+ final var stringPrintWriter = new PrintWriter(stringWriter);
- final HelpFormatter helpFormatter = new HelpFormatter();
+ final var helpFormatter = new HelpFormatter();
helpFormatter.printHelp(stringPrintWriter, COMMAND_HELP_MAX_LINE_WIDTH, mainClassName + " [options...] ", null,
options, 0, 1, "");
diff --git a/gui-editors/gui-editor-apex/src/main/java/org/onap/policy/gui/editors/apex/rest/ApexEditorParameters.java b/gui-editors/gui-editor-apex/src/main/java/org/onap/policy/gui/editors/apex/rest/ApexEditorParameters.java
index 7eb0195..3f988b5 100644
--- a/gui-editors/gui-editor-apex/src/main/java/org/onap/policy/gui/editors/apex/rest/ApexEditorParameters.java
+++ b/gui-editors/gui-editor-apex/src/main/java/org/onap/policy/gui/editors/apex/rest/ApexEditorParameters.java
@@ -2,6 +2,7 @@
* ============LICENSE_START=======================================================
* Copyright (C) 2016-2018 Ericsson. All rights reserved.
* Modifications Copyright (C) 2020-2021 Nordix Foundation.
+ * Modifications Copyright (C) 2021 AT&T Intellectual Property. All rights reserved.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -74,14 +75,7 @@ public class ApexEditorParameters {
* @return the string
*/
public String validate() {
- String validationMessage = "";
- validationMessage += validatePort();
- validationMessage += validateTimeToLive();
- validationMessage += validateUrl();
- validationMessage += validateUploadUrl();
- validationMessage += validateUploadUserid();
-
- return validationMessage;
+ return validatePort() + validateTimeToLive() + validateUrl() + validateUploadUrl() + validateUploadUserid();
}
/**
diff --git a/gui-editors/gui-editor-apex/src/main/java/org/onap/policy/gui/editors/apex/rest/handling/ApexEditorRestResource.java b/gui-editors/gui-editor-apex/src/main/java/org/onap/policy/gui/editors/apex/rest/handling/ApexEditorRestResource.java
index dc27d49..dcf3988 100644
--- a/gui-editors/gui-editor-apex/src/main/java/org/onap/policy/gui/editors/apex/rest/handling/ApexEditorRestResource.java
+++ b/gui-editors/gui-editor-apex/src/main/java/org/onap/policy/gui/editors/apex/rest/handling/ApexEditorRestResource.java
@@ -2,6 +2,7 @@
* ============LICENSE_START=======================================================
* Copyright (C) 2016-2018 Ericsson. All rights reserved.
* Modifications Copyright (C) 2020 Nordix Foundation.
+ * Modifications Copyright (C) 2021 AT&T Intellectual Property. All rights reserved.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -114,7 +115,7 @@ public class ApexEditorRestResource implements RestCommandHandler {
return new ApexApiResult(Result.FAILED, "Session ID must be set to -1 to create sessions: " + sessionId);
}
- ApexApiResult result = new ApexApiResult();
+ var result = new ApexApiResult();
SESSION_HANDLER.createSession(result);
return result;
}
@@ -632,7 +633,7 @@ public class ApexEditorRestResource implements RestCommandHandler {
private ApexApiResult processRestCommand(final RestCommandType commandType, final RestCommand command) {
LOGGER.entry(commandType);
try {
- ApexApiResult result = new ApexApiResult();
+ var result = new ApexApiResult();
RestSession session = SESSION_HANDLER.getSession(sessionId, result);
if (session == null) {
return result;
@@ -659,7 +660,7 @@ public class ApexEditorRestResource implements RestCommandHandler {
final String jsonString) {
LOGGER.entry(commandType, jsonString);
try {
- ApexApiResult result = new ApexApiResult();
+ var result = new ApexApiResult();
RestSession session = SESSION_HANDLER.getSession(sessionId, result);
if (session == null) {
return result;
@@ -687,7 +688,7 @@ public class ApexEditorRestResource implements RestCommandHandler {
final String name, final String version) {
LOGGER.entry(commandType, name, version);
try {
- ApexApiResult result = new ApexApiResult();
+ var result = new ApexApiResult();
RestSession session = SESSION_HANDLER.getSession(sessionId, result);
if (session == null) {
return result;
@@ -820,7 +821,7 @@ public class ApexEditorRestResource implements RestCommandHandler {
* handling.
*/
protected static int createCorruptSession() {
- final ApexEditorRestResource apexEditorRestResource = new ApexEditorRestResource();
+ final var apexEditorRestResource = new ApexEditorRestResource();
final ApexApiResult result = apexEditorRestResource.createSession();
final int corruptSessionId = Integer.parseInt(result.getMessages().get(0));
diff --git a/gui-editors/gui-editor-apex/src/main/java/org/onap/policy/gui/editors/apex/rest/handling/ContextAlbumHandler.java b/gui-editors/gui-editor-apex/src/main/java/org/onap/policy/gui/editors/apex/rest/handling/ContextAlbumHandler.java
index 2b29367..ffe445c 100644
--- a/gui-editors/gui-editor-apex/src/main/java/org/onap/policy/gui/editors/apex/rest/handling/ContextAlbumHandler.java
+++ b/gui-editors/gui-editor-apex/src/main/java/org/onap/policy/gui/editors/apex/rest/handling/ContextAlbumHandler.java
@@ -106,7 +106,7 @@ public class ContextAlbumHandler implements RestCommandHandler {
session.editModel();
- final BeanContextAlbum jsonbean = RestUtils.getJsonParameters(jsonString, BeanContextAlbum.class);
+ final var jsonbean = RestUtils.getJsonParameters(jsonString, BeanContextAlbum.class);
ApexApiResult result = session.getApexModelEdited().createContextAlbum(jsonbean.getName(),
jsonbean.getVersion(), jsonbean.getScope(), Boolean.toString(jsonbean.getWriteable()),
@@ -134,7 +134,7 @@ public class ContextAlbumHandler implements RestCommandHandler {
session.editModel();
- final BeanContextAlbum jsonbean = RestUtils.getJsonParameters(jsonString, BeanContextAlbum.class);
+ final var jsonbean = RestUtils.getJsonParameters(jsonString, BeanContextAlbum.class);
ApexApiResult result = session.getApexModelEdited().updateContextAlbum(jsonbean.getName(),
jsonbean.getVersion(), jsonbean.getScope(), Boolean.toString(jsonbean.getWriteable()),
diff --git a/gui-editors/gui-editor-apex/src/main/java/org/onap/policy/gui/editors/apex/rest/handling/ContextSchemaHandler.java b/gui-editors/gui-editor-apex/src/main/java/org/onap/policy/gui/editors/apex/rest/handling/ContextSchemaHandler.java
index a9b856d..030bdeb 100644
--- a/gui-editors/gui-editor-apex/src/main/java/org/onap/policy/gui/editors/apex/rest/handling/ContextSchemaHandler.java
+++ b/gui-editors/gui-editor-apex/src/main/java/org/onap/policy/gui/editors/apex/rest/handling/ContextSchemaHandler.java
@@ -101,7 +101,7 @@ public class ContextSchemaHandler implements RestCommandHandler {
session.editModel();
- final BeanContextSchema jsonbean = RestUtils.getJsonParameters(jsonString, BeanContextSchema.class);
+ final var jsonbean = RestUtils.getJsonParameters(jsonString, BeanContextSchema.class);
ApexApiResult result = session.getApexModelEdited().createContextSchema(jsonbean.getName(),
jsonbean.getVersion(), jsonbean.getSchemaFlavour(), jsonbean.getSchemaDefinition(), jsonbean.getUuid(),
jsonbean.getDescription());
@@ -124,7 +124,7 @@ public class ContextSchemaHandler implements RestCommandHandler {
session.editModel();
- final BeanContextSchema jsonbean = RestUtils.getJsonParameters(jsonString, BeanContextSchema.class);
+ final var jsonbean = RestUtils.getJsonParameters(jsonString, BeanContextSchema.class);
ApexApiResult result = session.getApexModelEdited().updateContextSchema(jsonbean.getName(),
jsonbean.getVersion(), jsonbean.getSchemaFlavour(), jsonbean.getSchemaDefinition(), jsonbean.getUuid(),
diff --git a/gui-editors/gui-editor-apex/src/main/java/org/onap/policy/gui/editors/apex/rest/handling/EventHandler.java b/gui-editors/gui-editor-apex/src/main/java/org/onap/policy/gui/editors/apex/rest/handling/EventHandler.java
index debf99a..0adfffa 100644
--- a/gui-editors/gui-editor-apex/src/main/java/org/onap/policy/gui/editors/apex/rest/handling/EventHandler.java
+++ b/gui-editors/gui-editor-apex/src/main/java/org/onap/policy/gui/editors/apex/rest/handling/EventHandler.java
@@ -106,7 +106,7 @@ public class EventHandler implements RestCommandHandler {
private ApexApiResult createEvent(final RestSession session, final String jsonString) {
LOGGER.entry(jsonString);
- final BeanEvent jsonbean = RestUtils.getJsonParameters(jsonString, BeanEvent.class);
+ final var jsonbean = RestUtils.getJsonParameters(jsonString, BeanEvent.class);
session.editModel();
@@ -132,7 +132,7 @@ public class EventHandler implements RestCommandHandler {
* @return result the result of the parameter creation operation
*/
private ApexApiResult createEventParameters(final RestSession session, final BeanEvent jsonbean) {
- ApexApiResult result = new ApexApiResult();
+ var result = new ApexApiResult();
if (jsonbean.getParameters() == null || jsonbean.getParameters().isEmpty()) {
return result;
@@ -175,7 +175,7 @@ public class EventHandler implements RestCommandHandler {
private ApexApiResult updateEvent(final RestSession session, final String jsonString) {
LOGGER.entry(jsonString);
- final BeanEvent jsonbean = RestUtils.getJsonParameters(jsonString, BeanEvent.class);
+ final var jsonbean = RestUtils.getJsonParameters(jsonString, BeanEvent.class);
if (blank2Null(jsonbean.getName()) == null || blank2Null(jsonbean.getVersion()) == null) {
LOGGER.exit("Event/Update" + NOT_OK);
diff --git a/gui-editors/gui-editor-apex/src/main/java/org/onap/policy/gui/editors/apex/rest/handling/ModelHandler.java b/gui-editors/gui-editor-apex/src/main/java/org/onap/policy/gui/editors/apex/rest/handling/ModelHandler.java
index 9770710..6c34cc4 100644
--- a/gui-editors/gui-editor-apex/src/main/java/org/onap/policy/gui/editors/apex/rest/handling/ModelHandler.java
+++ b/gui-editors/gui-editor-apex/src/main/java/org/onap/policy/gui/editors/apex/rest/handling/ModelHandler.java
@@ -2,6 +2,7 @@
* ============LICENSE_START=======================================================
* Copyright (C) 2018 Ericsson. All rights reserved.
* Modifications Copyright (C) 2019-2020 Nordix Foundation.
+ * Modifications Copyright (C) 2021 AT&T Intellectual Property. All rights reserved.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -182,7 +183,7 @@ public class ModelHandler implements RestCommandHandler {
private ApexApiResult createModel(final RestSession session, final String jsonString) {
LOGGER.entry(jsonString);
- final BeanModel jsonbean = RestUtils.getJsonParameters(jsonString, BeanModel.class);
+ final var jsonbean = RestUtils.getJsonParameters(jsonString, BeanModel.class);
session.editModel();
@@ -206,7 +207,7 @@ public class ModelHandler implements RestCommandHandler {
private ApexApiResult updateModel(final RestSession session, final String jsonString) {
LOGGER.entry(jsonString);
- final BeanModel jsonbean = RestUtils.getJsonParameters(jsonString, BeanModel.class);
+ final var jsonbean = RestUtils.getJsonParameters(jsonString, BeanModel.class);
session.editModel();
@@ -345,7 +346,7 @@ public class ModelHandler implements RestCommandHandler {
private String addKeyInfo2Message(final RestSession session, final String message) {
final Gson gson = new GsonBuilder().serializeNulls().enableComplexMapKeySerialization().create();
- JsonObject jsonObject = gson.fromJson(message, JsonObject.class);
+ var jsonObject = gson.fromJson(message, JsonObject.class);
if (jsonObject == null) {
return message;
}
@@ -354,7 +355,7 @@ public class ModelHandler implements RestCommandHandler {
String version = readFieldFromJsonObject(jsonObject, VERSION, null);
if (name == null && version == null) {
- JsonObject newJsonObject = getSubJsonObject(jsonObject);
+ var newJsonObject = getSubJsonObject(jsonObject);
if (newJsonObject != null) {
jsonObject = newJsonObject;
diff --git a/gui-editors/gui-editor-apex/src/main/java/org/onap/policy/gui/editors/apex/rest/handling/PolicyHandler.java b/gui-editors/gui-editor-apex/src/main/java/org/onap/policy/gui/editors/apex/rest/handling/PolicyHandler.java
index 0ceee17..a968695 100644
--- a/gui-editors/gui-editor-apex/src/main/java/org/onap/policy/gui/editors/apex/rest/handling/PolicyHandler.java
+++ b/gui-editors/gui-editor-apex/src/main/java/org/onap/policy/gui/editors/apex/rest/handling/PolicyHandler.java
@@ -118,7 +118,7 @@ public class PolicyHandler implements RestCommandHandler {
public ApexApiResult createPolicy(final RestSession session, final String jsonString) {
LOGGER.entry(jsonString);
- final BeanPolicy jsonbean = RestUtils.getJsonParameters(jsonString, BeanPolicy.class);
+ final var jsonbean = RestUtils.getJsonParameters(jsonString, BeanPolicy.class);
session.editModel();
@@ -145,7 +145,7 @@ public class PolicyHandler implements RestCommandHandler {
* can be retrieved using {@link ApexApiResult#getMessages()}
*/
private ApexApiResult createPolicyContent(RestSession session, BeanPolicy jsonbean) {
- ApexApiResult result = new ApexApiResult();
+ var result = new ApexApiResult();
if (jsonbean.getStates() == null || jsonbean.getStates().isEmpty()) {
result.setResult(Result.FAILED);
@@ -306,7 +306,7 @@ public class PolicyHandler implements RestCommandHandler {
private ApexApiResult createStateContextReferences(final RestSession session, final String policyName,
final String policyVersion, final String stateName, final BeanState stateBean) {
- ApexApiResult result = new ApexApiResult();
+ var result = new ApexApiResult();
final BeanKeyRef[] contextReferences = stateBean.getContexts();
if (contextReferences == null || contextReferences.length == 0) {
@@ -353,7 +353,7 @@ public class PolicyHandler implements RestCommandHandler {
private ApexApiResult createStateFinalizers(final RestSession session, final String policyName,
final String policyVersion, final String stateName, final BeanState stateBean) {
- ApexApiResult result = new ApexApiResult();
+ var result = new ApexApiResult();
final Map<String, BeanLogic> finalizers = stateBean.getFinalizers();
if (finalizers == null || finalizers.isEmpty()) {
@@ -400,7 +400,7 @@ public class PolicyHandler implements RestCommandHandler {
private ApexApiResult createStateOutputs(final RestSession session, final String policyName,
final String policyVersion, final String stateName, final BeanState stateBean) {
- ApexApiResult result = new ApexApiResult();
+ var result = new ApexApiResult();
final Map<String, BeanStateOutput> stateOutputs = stateBean.getStateOutputs();
if (stateOutputs == null || stateOutputs.isEmpty()) {
@@ -453,7 +453,7 @@ public class PolicyHandler implements RestCommandHandler {
private ApexApiResult createStateTaskReferences(final RestSession session, final String policyName,
final String policyVersion, final String stateName, final BeanState stateBean) {
- ApexApiResult result = new ApexApiResult();
+ var result = new ApexApiResult();
final Map<String, BeanStateTaskRef> taskMap = stateBean.getTasks();
if (taskMap == null || taskMap.isEmpty()) {
@@ -506,7 +506,7 @@ public class PolicyHandler implements RestCommandHandler {
LOGGER.entry(jsonString);
- final BeanPolicy jsonbean = RestUtils.getJsonParameters(jsonString, BeanPolicy.class);
+ final var jsonbean = RestUtils.getJsonParameters(jsonString, BeanPolicy.class);
if (blank2Null(jsonbean.getName()) == null || blank2Null(jsonbean.getVersion()) == null) {
LOGGER.exit("Task/Update" + NOT_OK);
diff --git a/gui-editors/gui-editor-apex/src/main/java/org/onap/policy/gui/editors/apex/rest/handling/RestSession.java b/gui-editors/gui-editor-apex/src/main/java/org/onap/policy/gui/editors/apex/rest/handling/RestSession.java
index c0c53cd..c0eb876 100644
--- a/gui-editors/gui-editor-apex/src/main/java/org/onap/policy/gui/editors/apex/rest/handling/RestSession.java
+++ b/gui-editors/gui-editor-apex/src/main/java/org/onap/policy/gui/editors/apex/rest/handling/RestSession.java
@@ -2,6 +2,7 @@
* ============LICENSE_START=======================================================
* Copyright (C) 2018 Ericsson. All rights reserved.
* Modifications Copyright (C) 2020 Nordix Foundation.
+ * Modifications Copyright (C) 2021 AT&T Intellectual Property. All rights reserved.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -106,7 +107,7 @@ public class RestSession {
}
@SuppressWarnings("unchecked")
- Map<String, Object> apexEngineServiceParameterMap = (Map<String, Object>) toscaServiceTemplate
+ var apexEngineServiceParameterMap = (Map<String, Object>) toscaServiceTemplate
.getToscaTopologyTemplate().getPoliciesAsMap().values().iterator().next().getProperties()
.get(ENGINE_SERVICE_PARAMETERS);
@@ -174,8 +175,7 @@ public class RestSession {
ToscaPolicy ap = toscaServiceTemplate.getToscaTopologyTemplate().getPoliciesAsMap().values().iterator().next();
@SuppressWarnings("unchecked")
- Map<String, Object> apexEngineServiceParameterMap = (Map<String, Object>) ap.getProperties()
- .get(ENGINE_SERVICE_PARAMETERS);
+ var apexEngineServiceParameterMap = (Map<String, Object>) ap.getProperties().get(ENGINE_SERVICE_PARAMETERS);
Object decoded = null;
try {
@@ -186,7 +186,7 @@ public class RestSession {
apexEngineServiceParameterMap.put(POLICY_TYPE_IMPL, decoded);
- ApexApiResult result = new ApexApiResult();
+ var result = new ApexApiResult();
try {
result.addMessage(new StandardYamlCoder().encode(toscaServiceTemplate));
} catch (CoderException e) {
diff --git a/gui-editors/gui-editor-apex/src/main/java/org/onap/policy/gui/editors/apex/rest/handling/RestUtils.java b/gui-editors/gui-editor-apex/src/main/java/org/onap/policy/gui/editors/apex/rest/handling/RestUtils.java
index 0151aa5..51b65fc 100644
--- a/gui-editors/gui-editor-apex/src/main/java/org/onap/policy/gui/editors/apex/rest/handling/RestUtils.java
+++ b/gui-editors/gui-editor-apex/src/main/java/org/onap/policy/gui/editors/apex/rest/handling/RestUtils.java
@@ -23,7 +23,6 @@
package org.onap.policy.gui.editors.apex.rest.handling;
import com.google.gson.GsonBuilder;
-import com.google.gson.JsonArray;
import com.google.gson.JsonElement;
import com.google.gson.JsonNull;
import com.google.gson.JsonObject;
@@ -84,19 +83,19 @@ public abstract class RestUtils {
return JsonNull.INSTANCE;
}
if (val.isJsonPrimitive() && ((JsonPrimitive) val).isString()) {
- final String v = ((JsonPrimitive) val).getAsString();
+ final var v = ((JsonPrimitive) val).getAsString();
if (v == null || "".equals(v)) {
return JsonNull.INSTANCE;
}
}
if (val.isJsonArray()) {
- final JsonArray arr = val.getAsJsonArray();
+ final var arr = val.getAsJsonArray();
for (int i = 0; i < arr.size(); i++) {
arr.set(i, blank2null(arr.get(i)));
}
}
if (val.isJsonObject()) {
- final JsonObject o = val.getAsJsonObject();
+ final var o = val.getAsJsonObject();
for (final Entry<String, JsonElement> e : o.entrySet()) {
e.setValue(blank2null(e.getValue()));
}
@@ -112,9 +111,9 @@ public abstract class RestUtils {
* @return a map of the JSON strings
*/
public static Map<String, String> getJsonParameters(final String jsonString) {
- final GsonBuilder gb = new GsonBuilder();
+ final var gb = new GsonBuilder();
gb.serializeNulls().enableComplexMapKeySerialization();
- final JsonObject jsonObject = gb.create().fromJson(jsonString, JsonObject.class);
+ final var jsonObject = gb.create().fromJson(jsonString, JsonObject.class);
final Map<String, String> jsonMap = new TreeMap<>();
for (final Entry<String, JsonElement> jsonEntry : jsonObject.entrySet()) {
@@ -134,9 +133,9 @@ public abstract class RestUtils {
* @return a map of the JSON strings
*/
public static <C extends BeanBase> C getJsonParameters(final String jsonString, final Class<C> clz) {
- final GsonBuilder gb = new GsonBuilder();
+ final var gb = new GsonBuilder();
gb.serializeNulls().enableComplexMapKeySerialization();
- final JsonObject jsonObject = gb.create().fromJson(jsonString, JsonObject.class);
+ final var jsonObject = gb.create().fromJson(jsonString, JsonObject.class);
for (final Entry<String, JsonElement> jsonEntry : jsonObject.entrySet()) {
final JsonElement val = jsonEntry.getValue();
@@ -167,7 +166,7 @@ public abstract class RestUtils {
} else {
return null;
}
- final StreamSource source = new StreamSource(new StringReader(jsonString));
+ final var source = new StreamSource(new StringReader(jsonString));
final JAXBElement<C> rootElement = unmarshaller.unmarshal(source, clz);
return rootElement.getValue();
}
@@ -179,7 +178,7 @@ public abstract class RestUtils {
* @return the JSO nfrom concept
*/
public static String getJsonfromConcept(final Object object) {
- final GsonBuilder gb = new GsonBuilder();
+ final var gb = new GsonBuilder();
gb.serializeNulls().enableComplexMapKeySerialization();
return gb.create().toJson(object);
}
diff --git a/gui-editors/gui-editor-apex/src/main/java/org/onap/policy/gui/editors/apex/rest/handling/TaskHandler.java b/gui-editors/gui-editor-apex/src/main/java/org/onap/policy/gui/editors/apex/rest/handling/TaskHandler.java
index a5dd4cd..c9f4142 100644
--- a/gui-editors/gui-editor-apex/src/main/java/org/onap/policy/gui/editors/apex/rest/handling/TaskHandler.java
+++ b/gui-editors/gui-editor-apex/src/main/java/org/onap/policy/gui/editors/apex/rest/handling/TaskHandler.java
@@ -111,7 +111,7 @@ public class TaskHandler implements RestCommandHandler {
private ApexApiResult createTask(final RestSession session, final String jsonString) {
LOGGER.entry(jsonString);
- final BeanTask jsonbean = RestUtils.getJsonParameters(jsonString, BeanTask.class);
+ final var jsonbean = RestUtils.getJsonParameters(jsonString, BeanTask.class);
session.editModel();
@@ -166,7 +166,7 @@ public class TaskHandler implements RestCommandHandler {
* @return the result of the operation
*/
private ApexApiResult createInputFields(final RestSession session, final BeanTask jsonbean) {
- ApexApiResult result = new ApexApiResult();
+ var result = new ApexApiResult();
if (jsonbean.getInputFields() == null || jsonbean.getInputFields().isEmpty()) {
return result;
@@ -214,7 +214,7 @@ public class TaskHandler implements RestCommandHandler {
* @return the result of the operation
*/
private ApexApiResult createOutputFields(final RestSession session, final BeanTask jsonbean) {
- ApexApiResult result = new ApexApiResult();
+ var result = new ApexApiResult();
if (jsonbean.getOutputFields() == null || jsonbean.getOutputFields().isEmpty()) {
return result;
@@ -262,7 +262,7 @@ public class TaskHandler implements RestCommandHandler {
* @return the result of the operation
*/
private ApexApiResult createTaskLogic(final RestSession session, final BeanTask jsonbean) {
- ApexApiResult result = new ApexApiResult();
+ var result = new ApexApiResult();
if (jsonbean.getTaskLogic() == null) {
return result;
@@ -288,7 +288,7 @@ public class TaskHandler implements RestCommandHandler {
* @return the result of the operation
*/
private ApexApiResult createTaskParameters(final RestSession session, final BeanTask jsonbean) {
- ApexApiResult result = new ApexApiResult();
+ var result = new ApexApiResult();
if (jsonbean.getParameters() == null || jsonbean.getParameters().isEmpty()) {
return result;
@@ -326,7 +326,7 @@ public class TaskHandler implements RestCommandHandler {
* @return the result of the operation
*/
private ApexApiResult createContextReferences(final RestSession session, final BeanTask jsonbean) {
- ApexApiResult result = new ApexApiResult();
+ var result = new ApexApiResult();
if (jsonbean.getContexts() == null || jsonbean.getContexts().length == 0) {
return result;
@@ -365,7 +365,7 @@ public class TaskHandler implements RestCommandHandler {
private ApexApiResult updateTask(final RestSession session, final String jsonString) {
LOGGER.entry(jsonString);
- final BeanTask jsonbean = RestUtils.getJsonParameters(jsonString, BeanTask.class);
+ final var jsonbean = RestUtils.getJsonParameters(jsonString, BeanTask.class);
if (blank2Null(jsonbean.getName()) == null || blank2Null(jsonbean.getVersion()) == null) {
LOGGER.exit("Task/Update" + NOT_OK);
diff --git a/gui-editors/gui-editor-apex/src/main/java/org/onap/policy/gui/editors/apex/rest/handling/bean/BeanBase.java b/gui-editors/gui-editor-apex/src/main/java/org/onap/policy/gui/editors/apex/rest/handling/bean/BeanBase.java
index dbc5ae2..aa5692a 100644
--- a/gui-editors/gui-editor-apex/src/main/java/org/onap/policy/gui/editors/apex/rest/handling/bean/BeanBase.java
+++ b/gui-editors/gui-editor-apex/src/main/java/org/onap/policy/gui/editors/apex/rest/handling/bean/BeanBase.java
@@ -2,6 +2,7 @@
* ============LICENSE_START=======================================================
* Copyright (C) 2016-2018 Ericsson. All rights reserved.
* Modifications Copyright (C) 2020-2021 Nordix Foundation.
+ * Modifications Copyright (C) 2021 AT&T Intellectual Property. All rights reserved.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -21,7 +22,6 @@
package org.onap.policy.gui.editors.apex.rest.handling.bean;
-import java.lang.reflect.Field;
import java.lang.reflect.Method;
/**
@@ -53,7 +53,7 @@ public abstract class BeanBase {
// Use field approach
if (field != null) {
try {
- final Field f = this.getClass().getDeclaredField(field);
+ final var f = this.getClass().getDeclaredField(field);
f.trySetAccessible();
return (String) (f.get(this));
} catch (final Exception e) {
diff --git a/gui-editors/gui-editor-apex/src/main/java/org/onap/policy/gui/editors/apex/rest/handling/plugin/upload/PolicyUploadHandler.java b/gui-editors/gui-editor-apex/src/main/java/org/onap/policy/gui/editors/apex/rest/handling/plugin/upload/PolicyUploadHandler.java
index 6d8b803..8223033 100644
--- a/gui-editors/gui-editor-apex/src/main/java/org/onap/policy/gui/editors/apex/rest/handling/plugin/upload/PolicyUploadHandler.java
+++ b/gui-editors/gui-editor-apex/src/main/java/org/onap/policy/gui/editors/apex/rest/handling/plugin/upload/PolicyUploadHandler.java
@@ -1,6 +1,7 @@
/*
* ============LICENSE_START=======================================================
* Copyright (C) 2020 Nordix Foundation
+ * Modifications Copyright (C) 2021 AT&T Intellectual Property. All rights reserved.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -62,7 +63,7 @@ public class PolicyUploadHandler {
}
- final UploadPolicyRequestDto uploadPolicyRequestDto = new UploadPolicyRequestDto();
+ final var uploadPolicyRequestDto = new UploadPolicyRequestDto();
uploadPolicyRequestDto.setUserId(ApexEditorMain.getParameters().getUploadUserid());
uploadPolicyRequestDto
.setFileData(Base64.getEncoder().encodeToString(toscaServiceTemplate.getBytes(StandardCharsets.UTF_8)));
@@ -70,19 +71,19 @@ public class PolicyUploadHandler {
String.format("%s.%s.%s", policyModelUuid, policyModelKey.getName(), policyModelKey.getVersion()));
try {
- final Response response = ClientBuilder.newClient().target(ApexEditorMain.getParameters().getUploadUrl())
+ final var response = ClientBuilder.newClient().target(ApexEditorMain.getParameters().getUploadUrl())
.request(MediaType.APPLICATION_JSON)
.post(Entity.entity(uploadPolicyRequestDto, MediaType.APPLICATION_JSON));
if (response.getStatus() == 201) {
- final ApexApiResult apexApiResult = new ApexApiResult(Result.SUCCESS);
+ final var apexApiResult = new ApexApiResult(Result.SUCCESS);
String.format("uploading Policy '%s' to URL '%s' with userId '%s' was successful",
policyModelKey.getId(), ApexEditorMain.getParameters().getUploadUrl(),
ApexEditorMain.getParameters().getUploadUserid());
LOGGER.exit("Model/Upload: OK");
return apexApiResult;
} else {
- final ApexApiResult apexApiResult = new ApexApiResult(Result.FAILED);
+ final var apexApiResult = new ApexApiResult(Result.FAILED);
apexApiResult.addMessage(
String.format("uploading Policy '%s' to URL '%s' with userId '%s' failed with status %s",
policyModelKey.getId(), ApexEditorMain.getParameters().getUploadUrl(),
@@ -91,7 +92,7 @@ public class PolicyUploadHandler {
return apexApiResult;
}
} catch (Exception e) {
- final ApexApiResult apexApiResult = new ApexApiResult(Result.FAILED);
+ final var apexApiResult = new ApexApiResult(Result.FAILED);
apexApiResult
.addMessage(String.format("uploading Policy '%s' to URL '%s' with userId '%s' failed with error %s",
policyModelKey.getId(), ApexEditorMain.getParameters().getUploadUrl(),
diff --git a/gui-editors/gui-editor-apex/src/test/java/org/onap/policy/gui/editors/apex/rest/ApexEditorStartupTest.java b/gui-editors/gui-editor-apex/src/test/java/org/onap/policy/gui/editors/apex/rest/ApexEditorStartupTest.java
index d78eba3..717da11 100644
--- a/gui-editors/gui-editor-apex/src/test/java/org/onap/policy/gui/editors/apex/rest/ApexEditorStartupTest.java
+++ b/gui-editors/gui-editor-apex/src/test/java/org/onap/policy/gui/editors/apex/rest/ApexEditorStartupTest.java
@@ -2,6 +2,7 @@
* ============LICENSE_START=======================================================
* Copyright (C) 2016-2018 Ericsson. All rights reserved.
* Modifications Copyright (C) 2020 Nordix Foundation.
+ * Modifications Copyright (C) 2021 AT&T Intellectual Property. All rights reserved.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -334,15 +335,15 @@ public class ApexEditorStartupTest {
*/
private String runEditor(final String[] args) throws InterruptedException {
ParameterService.clear();
- final ByteArrayOutputStream outBaStream = new ByteArrayOutputStream();
- final PrintStream outStream = new PrintStream(outBaStream);
+ final var outBaStream = new ByteArrayOutputStream();
+ final var outStream = new PrintStream(outBaStream);
- final ApexEditorMain editorMain = new ApexEditorMain(args, outStream);
+ final var editorMain = new ApexEditorMain(args, outStream);
// This test must be started in a thread because we want to intercept the output
// in cases where the editor is
// started infinitely
- final Runnable testThread = new Runnable() {
+ final var testThread = new Runnable() {
@Override
public void run() {
editorMain.init();
diff --git a/gui-editors/gui-editor-apex/src/test/java/org/onap/policy/gui/editors/apex/rest/RestInterfaceTest.java b/gui-editors/gui-editor-apex/src/test/java/org/onap/policy/gui/editors/apex/rest/RestInterfaceTest.java
index cf1c4fa..3506dab 100644
--- a/gui-editors/gui-editor-apex/src/test/java/org/onap/policy/gui/editors/apex/rest/RestInterfaceTest.java
+++ b/gui-editors/gui-editor-apex/src/test/java/org/onap/policy/gui/editors/apex/rest/RestInterfaceTest.java
@@ -2,6 +2,7 @@
* ============LICENSE_START=======================================================
* Copyright (C) 2016-2018 Ericsson. All rights reserved.
* Modifications Copyright (C) 2020 Nordix Foundation.
+ * Modifications Copyright (C) 2021 AT&T Intellectual Property. All rights reserved.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -76,10 +77,10 @@ public class RestInterfaceTest {
// Start the editor
editorMain = new ApexEditorMain(EDITOR_MAIN_ARGS, System.out);
// prevent a stray stdin value from killing the editor
- final ByteArrayInputStream input = new ByteArrayInputStream("".getBytes());
+ final var input = new ByteArrayInputStream("".getBytes());
System.setIn(input);
// Init the editor in a separate thread
- final Runnable testThread = new Runnable() {
+ final var testThread = new Runnable() {
@Override
public void run() {
editorMain.init();