diff options
author | mkidd <michael.kidd@est.tech> | 2021-03-01 11:13:06 +0000 |
---|---|---|
committer | mkidd <michael.kidd@est.tech> | 2021-03-03 20:00:01 +0000 |
commit | e5b070acb072d62d7f86e50e51b6b1586b85e307 (patch) | |
tree | 9501022bcb1d1f725ac5cadfc577fe44641f16a7 | |
parent | 4f6e6490aa469135379fd2814326e44652caf52f (diff) |
fix code smells and vulnerabilities
used await method inside an if statement that now runs the same code as the accompanying finally block.
removed unused variables from ApexContextAlbumEditForm.js
refactored vars that were redelared - this was not needed as there were variables of this name within scope
added ! operator
Issue-ID: POLICY-3095
Signed-off-by: mkidd <michael.kidd@est.tech>
Change-Id: Idadf4dd6938be5410fef62140de8b265bbaca138
-rw-r--r-- | gui-editors/gui-editor-apex/src/main/resources/webapp/js/ApexContextAlbumEditForm.js | 20 | ||||
-rw-r--r-- | gui-pdp-monitoring/src/main/java/org/onap/policy/gui/pdp/monitoring/PdpMonitoringMain.java | 6 |
2 files changed, 11 insertions, 15 deletions
diff --git a/gui-editors/gui-editor-apex/src/main/resources/webapp/js/ApexContextAlbumEditForm.js b/gui-editors/gui-editor-apex/src/main/resources/webapp/js/ApexContextAlbumEditForm.js index c09e625..79c9da1 100644 --- a/gui-editors/gui-editor-apex/src/main/resources/webapp/js/ApexContextAlbumEditForm.js +++ b/gui-editors/gui-editor-apex/src/main/resources/webapp/js/ApexContextAlbumEditForm.js @@ -1,7 +1,7 @@ /* * ============LICENSE_START======================================================= * Copyright (C) 2016-2018 Ericsson. All rights reserved. - * Modifications Copyright (C) 2020 Nordix Foundation. + * Modifications Copyright (C) 2020-2021 Nordix Foundation. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -59,7 +59,7 @@ function editContextAlbumForm_viewContextAlbum(parent, name, version) { var requestURL = window.restRootURL + "/ContextAlbum/Get?name=" + name + "&version=" + version; ajax_getWithKeyInfo(requestURL, "apexContextAlbum", function(contextAlbum) { // Get all contextSchemas too for album item schema - var requestURL = window.restRootURL + "/ContextSchema/Get?name=&version="; + requestURL = window.restRootURL + "/ContextSchema/Get?name=&version="; var contextSchemas = new Array(); ajax_get(requestURL, function(data2) { for (var i = 0; i < data2.messages.message.length; i++) { @@ -80,7 +80,7 @@ function editContextAlbumForm_editContextAlbum(formParent, name, version) { var requestURL = window.restRootURL + "/ContextAlbum/Get?name=" + name + "&version=" + version; ajax_getWithKeyInfo(requestURL, "apexContextAlbum", function(contextAlbum) { // Get all contextSchemas too for album item schema - var requestURL = window.restRootURL + "/ContextSchema/Get?name=&version="; + requestURL = window.restRootURL + "/ContextSchema/Get?name=&version="; var contextSchemas = new Array(); ajax_get(requestURL, function(data2) { for (var i = 0; i < data2.messages.message.length; i++) { @@ -107,7 +107,6 @@ function editContextAlbumForm_activate(parent, operation, contextAlbum, contextS } apexUtils_emptyElement(parent); - var isedit = false; var createEditOrView = ""; if (!operation) { @@ -116,12 +115,7 @@ function editContextAlbumForm_activate(parent, operation, contextAlbum, contextS createEditOrView = operation.toUpperCase(); } - if (createEditOrView == "CREATE") { - isedit = true; - } else if (createEditOrView == "EDIT" || createEditOrView == "VIEW") { - if (createEditOrView == "EDIT") { - isedit = true; - } + if (createEditOrView == "EDIT" || createEditOrView == "VIEW") { if (!contextAlbum) { console.warn("Invalid value (\"" + contextAlbum @@ -441,7 +435,7 @@ function editContextAlbumForm_submitPressed() { } var readonly = $('#editContextAlbumFormAlbumReadOnlyCheckbox').prop('checked'); if (readonly && scope != "EXTERNAL") { - var message = "Are you sure you want to set the scope ContextAlbum to \"" + message = "Are you sure you want to set the scope ContextAlbum to \"" + scope + "\" while it is set as Read Only. It only makes sense to use readonly for \"EXTERNAL\" Context Albums. If this Album is readonly it cannot be set!"; if (!apexUtils_areYouSure(message)) { @@ -449,7 +443,7 @@ function editContextAlbumForm_submitPressed() { } } if (!readonly && scope == "EXTERNAL") { - var message = "Are you sure you want to set the scope ContextAlbum to \"" + message = "Are you sure you want to set the scope ContextAlbum to \"" + scope + "\" while it is not set as Read Only. It only makes sense to use readonly for \"EXTERNAL\" Context Albums since EXTERNAL context cannot be set in policies."; if (!apexUtils_areYouSure(message)) { @@ -475,7 +469,7 @@ function editContextAlbumForm_submitPressed() { keyInformationTab_reset() }); } else if (createEditOrView == "EDIT") { - var requestURL = window.restRootURL + "/ContextAlbum/Update"; + requestURL = window.restRootURL + "/ContextAlbum/Update"; ajax_put(requestURL, jsonString, function(resultData) { apexUtils_removeElement("editContextAlbumFormDiv"); contextAlbumTab_reset(); diff --git a/gui-pdp-monitoring/src/main/java/org/onap/policy/gui/pdp/monitoring/PdpMonitoringMain.java b/gui-pdp-monitoring/src/main/java/org/onap/policy/gui/pdp/monitoring/PdpMonitoringMain.java index 2a2355e..4324124 100644 --- a/gui-pdp-monitoring/src/main/java/org/onap/policy/gui/pdp/monitoring/PdpMonitoringMain.java +++ b/gui-pdp-monitoring/src/main/java/org/onap/policy/gui/pdp/monitoring/PdpMonitoringMain.java @@ -1,6 +1,6 @@ /*- * ============LICENSE_START======================================================= - * Copyright (C) 2020 Nordix Foundation. + * 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"); @@ -121,7 +121,9 @@ public class PdpMonitoringMain { // Find out how long is left to wait long timeRemaining = parameters.getTimeToLive(); if (timeRemaining >= 0) { - shutdownLatch.await(timeRemaining, TimeUnit.SECONDS); + if (!shutdownLatch.await(timeRemaining, TimeUnit.SECONDS)) { + shutdown(); + } } else { shutdownLatch.await(); } |