summaryrefslogtreecommitdiffstats
path: root/gui-editors
diff options
context:
space:
mode:
authorRam Krishna Verma <ram_krishna.verma@bell.ca>2021-06-11 16:01:27 -0400
committerRam Krishna Verma <ram_krishna.verma@bell.ca>2021-06-14 09:52:32 -0400
commitdeec0f708a368eb979cf8d48d6221ee52cc919ad (patch)
tree2eb53886d68b4c3332a28571218f6a5709b5f473 /gui-editors
parent8c6beedc3d58420988c9e80d75aad96198e2962e (diff)
Fix sonar in policy/gui
use "var" for local variables Issue-ID: POLICY-3077 Change-Id: I6e31317bfda3d2b9bdde038cec709a3398f2f655 Signed-off-by: Ram Krishna Verma <ram_krishna.verma@bell.ca>
Diffstat (limited to 'gui-editors')
-rw-r--r--gui-editors/gui-editor-apex/src/main/java/org/onap/policy/gui/editors/apex/rest/handling/ApexEditorRestResource.java3
-rw-r--r--gui-editors/gui-editor-apex/src/main/java/org/onap/policy/gui/editors/apex/rest/handling/ModelHandler.java10
-rw-r--r--gui-editors/gui-editor-apex/src/main/java/org/onap/policy/gui/editors/apex/rest/handling/RestSession.java3
-rw-r--r--gui-editors/gui-editor-apex/src/main/java/org/onap/policy/gui/editors/apex/rest/handling/RestUtils.java5
-rw-r--r--gui-editors/gui-editor-apex/src/main/java/org/onap/policy/gui/editors/apex/rest/handling/plugin/upload/PolicyUploadHandler.java4
5 files changed, 14 insertions, 11 deletions
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 dcf3988..0b777b6 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
@@ -3,6 +3,7 @@
* 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.
+ * Modifications Copyright (C) 2021 Bell Canada. 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.
@@ -823,7 +824,7 @@ public class ApexEditorRestResource implements RestCommandHandler {
protected static int createCorruptSession() {
final var apexEditorRestResource = new ApexEditorRestResource();
final ApexApiResult result = apexEditorRestResource.createSession();
- final int corruptSessionId = Integer.parseInt(result.getMessages().get(0));
+ final var corruptSessionId = Integer.parseInt(result.getMessages().get(0));
SESSION_HANDLER.setCorruptSession(corruptSessionId);
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 6c34cc4..38c7fec 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
@@ -3,6 +3,7 @@
* 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.
+ * Modifications Copyright (C) 2021 Bell Canada. 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.
@@ -22,7 +23,6 @@
package org.onap.policy.gui.editors.apex.rest.handling;
-import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
import com.google.gson.JsonObject;
import java.util.ArrayList;
@@ -317,7 +317,7 @@ public class ModelHandler implements RestCommandHandler {
* @return The list result, containing JSON augmented representations of objects stored in its "messages" array
*/
private ApexApiResult addKeyInfo2Messages(final RestSession session, final ApexApiResult incomingResult) {
- final ApexApiResult result = new ApexApiResult(incomingResult.getResult());
+ final var result = new ApexApiResult(incomingResult.getResult());
result.setMessages(incomingResult.getMessages());
final List<String> messages = incomingResult.getMessages();
@@ -344,7 +344,7 @@ public class ModelHandler implements RestCommandHandler {
* @return the augmented message
*/
private String addKeyInfo2Message(final RestSession session, final String message) {
- final Gson gson = new GsonBuilder().serializeNulls().enableComplexMapKeySerialization().create();
+ final var gson = new GsonBuilder().serializeNulls().enableComplexMapKeySerialization().create();
var jsonObject = gson.fromJson(message, JsonObject.class);
if (jsonObject == null) {
@@ -418,7 +418,7 @@ public class ModelHandler implements RestCommandHandler {
private boolean setUuidAndDescription(final RestSession session, JsonObject jsonObject, String name,
String version) {
// Look up the key information for the name and version
- JsonObject keyInfoJsonObject = lookupKeyInfo(session, name, version);
+ var keyInfoJsonObject = lookupKeyInfo(session, name, version);
if (keyInfoJsonObject == null || keyInfoJsonObject.get(APEX_KEY_INFO) != null) {
return false;
}
@@ -456,7 +456,7 @@ public class ModelHandler implements RestCommandHandler {
return null;
}
- final Gson gson = new GsonBuilder().serializeNulls().enableComplexMapKeySerialization().create();
+ final var gson = new GsonBuilder().serializeNulls().enableComplexMapKeySerialization().create();
final String keyInfoJson = keyInfoMessages.get(0);
return gson.fromJson(keyInfoJson, JsonObject.class);
}
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 c0eb876..662c634 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
@@ -3,6 +3,7 @@
* Copyright (C) 2018 Ericsson. All rights reserved.
* Modifications Copyright (C) 2020 Nordix Foundation.
* Modifications Copyright (C) 2021 AT&T Intellectual Property. All rights reserved.
+ * Modifications Copyright (C) 2021 Bell Canada. 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.
@@ -212,7 +213,7 @@ public class RestSession {
AxArtifactKey policyModelKey = apexModelBeingUploaded.getPolicyModel().getKey();
- String policyModelUUid = apexModelBeingUploaded.getPolicyModel().getKeyInformation().get(policyModelKey)
+ var policyModelUUid = apexModelBeingUploaded.getPolicyModel().getKeyInformation().get(policyModelKey)
.getUuid().toString();
return new PolicyUploadHandler().doUpload(result.getMessage(), policyModelKey, policyModelUUid);
}
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 51b65fc..42ba08e 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
@@ -3,6 +3,7 @@
* 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.
+ * Modifications Copyright (C) 2021 Bell Canada. 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.
@@ -90,7 +91,7 @@ public abstract class RestUtils {
}
if (val.isJsonArray()) {
final var arr = val.getAsJsonArray();
- for (int i = 0; i < arr.size(); i++) {
+ for (var i = 0; i < arr.size(); i++) {
arr.set(i, blank2null(arr.get(i)));
}
}
@@ -156,7 +157,7 @@ public abstract class RestUtils {
public static <C extends AxConcept> C getConceptFromJson(final String jsonString, final Class<C> clz)
throws JAXBException {
Unmarshaller unmarshaller = null;
- final JAXBContext jaxbContext = JAXBContext.newInstance(clz);
+ final var jaxbContext = JAXBContext.newInstance(clz);
unmarshaller = jaxbContext.createUnmarshaller();
if (jsonString.matches(JSON_INPUT_TYPE_REGEXP)) {
unmarshaller.setProperty(MarshallerProperties.MEDIA_TYPE, MediaType.APPLICATION_JSON);
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 8223033..ebbe3db 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
@@ -2,6 +2,7 @@
* ============LICENSE_START=======================================================
* Copyright (C) 2020 Nordix Foundation
* Modifications Copyright (C) 2021 AT&T Intellectual Property. All rights reserved.
+ * Modifications Copyright (C) 2021 Bell Canada. 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.
@@ -25,7 +26,6 @@ import java.util.Base64;
import javax.ws.rs.client.ClientBuilder;
import javax.ws.rs.client.Entity;
import javax.ws.rs.core.MediaType;
-import javax.ws.rs.core.Response;
import org.apache.commons.lang3.StringUtils;
import org.onap.policy.apex.model.basicmodel.concepts.AxArtifactKey;
import org.onap.policy.apex.model.modelapi.ApexApiResult;
@@ -56,7 +56,7 @@ public class PolicyUploadHandler {
LOGGER.entry();
if (StringUtils.isBlank(ApexEditorMain.getParameters().getUploadUrl())) {
- final ApexApiResult apexApiResult = new ApexApiResult(Result.FAILED);
+ final var apexApiResult = new ApexApiResult(Result.FAILED);
apexApiResult.addMessage("Model upload is disabled, parameter upload-url is not set on server");
LOGGER.exit(MODEL_UPLOAD_NOT_OK);
return apexApiResult;