aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/main/java/org/onap/clamp/clds/client/DcaeHttpConnectionManager.java145
-rw-r--r--src/main/java/org/onap/clamp/clds/client/DcaeInventoryServices.java9
-rw-r--r--src/main/resources/META-INF/resources/designer/partials/portfolios/deploy_parameters.html2
-rw-r--r--src/main/resources/META-INF/resources/designer/scripts/CldsModelService.js136
-rw-r--r--src/main/resources/META-INF/resources/designer/scripts/DeploymentCtrl.js83
-rw-r--r--src/main/resources/META-INF/resources/designer/scripts/OperationalPolicyCtrl.js2
-rw-r--r--src/main/resources/META-INF/resources/designer/scripts/ToscaModelCtrl.js2
-rw-r--r--src/main/resources/META-INF/resources/designer/scripts/app.js37
-rw-r--r--src/main/resources/META-INF/resources/designer/scripts/propertyController.js34
-rw-r--r--src/test/java/org/onap/clamp/clds/client/DcaeDispatcherServicesTest.java27
-rw-r--r--src/test/java/org/onap/clamp/clds/it/HttpConnectionManagerItCase.java (renamed from src/test/java/org/onap/clamp/clds/it/DcaeHttpConnectionManagerItCase.java)26
-rw-r--r--src/test/javascript/propertyController.test.js4
12 files changed, 146 insertions, 361 deletions
diff --git a/src/main/java/org/onap/clamp/clds/client/DcaeHttpConnectionManager.java b/src/main/java/org/onap/clamp/clds/client/DcaeHttpConnectionManager.java
deleted file mode 100644
index 30afddcd0..000000000
--- a/src/main/java/org/onap/clamp/clds/client/DcaeHttpConnectionManager.java
+++ /dev/null
@@ -1,145 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * ONAP CLAMP
- * ================================================================================
- * Copyright (C) 2017 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.
- * 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.
- * ============LICENSE_END============================================
- * Modifications copyright (c) 2018 Nokia
- * ===================================================================
- *
- */
-
-package org.onap.clamp.clds.client;
-
-import com.att.eelf.configuration.EELFLogger;
-import com.att.eelf.configuration.EELFManager;
-
-import java.io.BufferedReader;
-import java.io.DataOutputStream;
-import java.io.IOException;
-import java.io.InputStreamReader;
-import java.net.HttpURLConnection;
-import java.net.URL;
-
-import javax.net.ssl.HttpsURLConnection;
-import javax.ws.rs.BadRequestException;
-
-import org.apache.commons.io.IOUtils;
-import org.onap.clamp.clds.util.LoggingUtils;
-import org.springframework.stereotype.Component;
-
-/**
- * This class manages the HTTP and HTTPS connections to DCAE.
- */
-@Component
-public class DcaeHttpConnectionManager {
- protected static final EELFLogger logger = EELFManager.getInstance().getLogger(DcaeHttpConnectionManager.class);
- protected static final EELFLogger metricsLogger = EELFManager.getInstance().getMetricsLogger();
- private static final String DCAE_REQUEST_FAILED_LOG = "Request Failed - response payload=";
-
- private String doHttpsQuery(URL url, String requestMethod, String payload, String contentType) throws IOException {
- logger.info("Using HTTPS URL to contact DCAE:" + url.toString());
- HttpsURLConnection secureConnection = (HttpsURLConnection) url.openConnection();
- secureConnection.setRequestMethod(requestMethod);
- secureConnection.setRequestProperty("X-ECOMP-RequestID", LoggingUtils.getRequestId());
- if (payload != null && contentType != null) {
- secureConnection.setRequestProperty("Content-Type", contentType);
- secureConnection.setDoOutput(true);
- try (DataOutputStream wr = new DataOutputStream(secureConnection.getOutputStream())) {
- wr.writeBytes(payload);
- wr.flush();
- }
- }
- int responseCode = secureConnection.getResponseCode();
- logger.info("Response Code: " + responseCode);
- if (responseCode < 400) {
- try (BufferedReader reader = new BufferedReader(new InputStreamReader(secureConnection.getInputStream()))) {
- String responseStr = IOUtils.toString(reader);
- logger.info("Response Content: " + responseStr);
- return responseStr;
- }
- } else {
- // In case of connection failure just check whether there is a
- // content or not
- try (BufferedReader reader = new BufferedReader(new InputStreamReader(secureConnection.getErrorStream()))) {
- String responseStr = IOUtils.toString(reader);
- logger.error(DCAE_REQUEST_FAILED_LOG + responseStr);
- throw new BadRequestException(responseStr);
- }
- }
- }
-
- private String doHttpQuery(URL url, String requestMethod, String payload, String contentType) throws IOException {
- LoggingUtils utils = new LoggingUtils(logger);
- logger.info("Using HTTP URL to contact DCAE:" + url);
- HttpURLConnection connection = (HttpURLConnection) url.openConnection();
- connection = utils.invoke(connection, "DCAE", requestMethod);
- connection.setRequestMethod(requestMethod);
- connection.setRequestProperty("X-ECOMP-RequestID", LoggingUtils.getRequestId());
- if (payload != null && contentType != null) {
- connection.setRequestProperty("Content-Type", contentType);
- connection.setDoOutput(true);
- try (DataOutputStream wr = new DataOutputStream(connection.getOutputStream())) {
- wr.writeBytes(payload);
- wr.flush();
- }
- }
- int responseCode = connection.getResponseCode();
- logger.info("Response Code: " + responseCode);
- if (responseCode < 400) {
- try (BufferedReader reader = new BufferedReader(new InputStreamReader(connection.getInputStream()))) {
- String responseStr = IOUtils.toString(reader);
- logger.info("Response Content: " + responseStr);
- utils.invokeReturn();
- return responseStr;
- }
- } else {
- // In case of connection failure just check whether there is a
- // content or not
- try (BufferedReader reader = new BufferedReader(new InputStreamReader(connection.getErrorStream()))) {
- String responseStr = IOUtils.toString(reader);
- logger.error(DCAE_REQUEST_FAILED_LOG + responseStr);
- utils.invokeReturn();
- throw new BadRequestException(responseStr);
- }
- }
- }
-
- /**
- * This method does a HTTP/HTTPS query to DCAE with parameters specified.
- *
- * @param url
- * The string HTTP or HTTPS that mustr be used to connect
- * @param requestMethod
- * The Request Method (PUT, POST, GET, DELETE, etc ...)
- * @param payload
- * The payload if any, in that case an ouputstream is opened
- * @param contentType
- * The "application/json or application/xml, or whatever"
- * @return The payload of the answer
- * @throws IOException
- * In case of issue with the streams
- */
- public String doDcaeHttpQuery(String url, String requestMethod, String payload, String contentType)
- throws IOException {
- URL urlObj = new URL(url);
- if (url.contains("https://")) { // Support for HTTPS
- return doHttpsQuery(urlObj, requestMethod, payload, contentType);
- } else { // Support for HTTP
- return doHttpQuery(urlObj, requestMethod, payload, contentType);
- }
- }
-}
diff --git a/src/main/java/org/onap/clamp/clds/client/DcaeInventoryServices.java b/src/main/java/org/onap/clamp/clds/client/DcaeInventoryServices.java
index ffd19d82e..63fdc6187 100644
--- a/src/main/java/org/onap/clamp/clds/client/DcaeInventoryServices.java
+++ b/src/main/java/org/onap/clamp/clds/client/DcaeInventoryServices.java
@@ -45,6 +45,7 @@ import org.onap.clamp.clds.model.properties.Global;
import org.onap.clamp.clds.model.properties.ModelProperties;
import org.onap.clamp.clds.util.JsonUtils;
import org.onap.clamp.clds.util.LoggingUtils;
+import org.onap.clamp.util.HttpConnectionManager;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
@@ -62,17 +63,17 @@ public class DcaeInventoryServices {
public static final String DCAE_INVENTORY_RETRY_LIMIT = "dcae.intentory.retry.limit";
private final ClampProperties refProp;
private final CldsDao cldsDao;
- private final DcaeHttpConnectionManager dcaeHttpConnectionManager;
+ private final HttpConnectionManager httpConnectionManager;
/**
* Constructor.
*/
@Autowired
public DcaeInventoryServices(ClampProperties refProp, CldsDao cldsDao,
- DcaeHttpConnectionManager dcaeHttpConnectionManager) {
+ HttpConnectionManager httpConnectionManager) {
this.refProp = refProp;
this.cldsDao = cldsDao;
- this.dcaeHttpConnectionManager = dcaeHttpConnectionManager;
+ this.httpConnectionManager = httpConnectionManager;
}
/**
@@ -206,7 +207,7 @@ public class DcaeInventoryServices {
}
for (int i = 0; i < retryLimit; i++) {
metricsLogger.info("Attempt n°" + i + " to contact DCAE inventory");
- String response = dcaeHttpConnectionManager.doDcaeHttpQuery(fullUrl, "GET", null, null);
+ String response = httpConnectionManager.doGeneralHttpQuery(fullUrl, "GET", null, null, "DCAE");
int totalCount = getTotalCountFromDcaeInventoryResponse(response);
metricsLogger.info("getDcaeInformation complete: totalCount returned=" + totalCount);
if (totalCount > 0) {
diff --git a/src/main/resources/META-INF/resources/designer/partials/portfolios/deploy_parameters.html b/src/main/resources/META-INF/resources/designer/partials/portfolios/deploy_parameters.html
index 3fc1b0301..7b1b6c23b 100644
--- a/src/main/resources/META-INF/resources/designer/partials/portfolios/deploy_parameters.html
+++ b/src/main/resources/META-INF/resources/designer/partials/portfolios/deploy_parameters.html
@@ -29,6 +29,8 @@
<div class="modal-body" style="display:block">
<div style="height: 100%;clear: both;" id="deployPropertiesDiv" name="deployPropertiesDiv" ng-init="load_deploy_parameters()" >
Deployment parameters.
+ <form id="deployForm" class="form-horizontal">
+ </form>
</div>
</div>
diff --git a/src/main/resources/META-INF/resources/designer/scripts/CldsModelService.js b/src/main/resources/META-INF/resources/designer/scripts/CldsModelService.js
index 972676b61..3dc4d003e 100644
--- a/src/main/resources/META-INF/resources/designer/scripts/CldsModelService.js
+++ b/src/main/resources/META-INF/resources/designer/scripts/CldsModelService.js
@@ -24,84 +24,47 @@ app
.service(
'cldsModelService',
[
- 'alertService',
- '$http',
- '$q',
- '$rootScope',
- function(alertService, $http, $q, $rootScope) {
-
- function checkIfElementType(name) {
-
- //This will open the methods located in the app.js
- if (undefined == name) {
- return;
- }else if (name.toLowerCase().indexOf("policy") >= 0){
- PolicyWindow();
- } else {
- $rootScope.selectedBoxName = name;
- ToscaModelWindow();
- }
- }
- function handleQueryToBackend(def, svcAction, svcUrl, svcPayload) {
-
- $http.put(svcUrl, svcPayload).success(
- function(data) {
-
- def.resolve(data);
- if (typeof data.statusCodeValue === 'undefined'
- || data.statusCodeValue === 200) {
- alertService.alertMessage(
- "Action Successful: " + svcAction, 1)
- } else {
- if (typeof data.body !== 'undefined') {
- alertService.alertMessage("Action Failure: "
- + svcAction + ", " + data.body.errorMessageForUi, 2);
- } else {
- alertService.alertMessage("Action Failure: "
- + svcAction, 2);
- }
- def.reject(svcAction + " not successful");
- }
- }).error(
- function(data) {
-
- def.resolve(data);
- if (typeof data.body !== 'undefined') {
- alertService.alertMessage("Action Failure: " + svcAction
- + ", " + data.body.errorMessageForUi, 2);
- } else {
- alertService
- .alertMessage("Action Failure: " + svcAction, 2);
- }
- def.reject(svcAction + " not successful");
- });
- }
- this.toggleDeploy = function(uiAction, modelName, controlNamePrefixIn,
- bpmnTextIn, propTextIn, svgXmlIn,
- templateName, typeID, controlNameUuid,
- modelEventService, deploymentId) {
-
- var def = $q.defer();
- var sets = [];
- var action = uiAction.toLowerCase();
- var deployUrl = "/restservices/clds/v1/clds/" + action + "/"
- + modelName;
- var requestData = {
- name : modelName,
- controlNamePrefix : controlNamePrefixIn,
- bpmnText : bpmnTextIn,
- propText : propTextIn,
- imageText : svgXmlIn,
- templateName : templateName,
- typeId : typeID,
- controlNameUuid : controlNameUuid,
- event : modelEventService,
- deploymentId : deploymentId
- };
- handleQueryToBackend(def, action, deployUrl, requestData);
- return def.promise;
- };
- this.getModel = function(modelName) {
+ 'alertService',
+ '$http',
+ '$q',
+ '$rootScope',
+ function(alertService, $http, $q, $rootScope) {
+
+ function checkIfElementType(name) {
+ //This will open the methods located in the app.js
+ if (undefined == name) {
+ return;
+ }else if (name.toLowerCase().indexOf("policy") >= 0){
+ PolicyWindow();
+ } else {
+ $rootScope.selectedBoxName = name;
+ ToscaModelWindow();
+ }
+ }
+ this.toggleDeploy = function(uiAction, modelName) {
+ var svcAction = uiAction.toLowerCase();
+ var deployUrl = "/restservices/clds/v2/loop/" + svcAction + "Loop/" + modelName;
+ var def = $q.defer();
+ var sets = [];
+ $http.put(deployUrl).success(
+ function(data) {
+ def.resolve(data);
+ alertService.alertMessage("Action Successful: " + svcAction, 1)
+ // update deploymentID, lastUpdatedStatus
+ setLastUpdatedStatus(data.lastUpdatedStatus);
+ setDeploymentStatusURL(data.dcaeDeploymentStatusUrl);
+ setDeploymentID(data.dcaeDeploymentId);
+ setStatus();
+ enableDisableMenuOptions();
+ }).error(
+ function(data) {
+ def.resolve(data);
+ alertService.alertMessage("Action Failure: " + svcAction, 2);
+ def.reject(svcAction + " not successful");
+ });
+ return def.promise;
+ }
+ this.getModel = function(modelName) {
var def = $q.defer();
var sets = [];
var svcUrl = "/restservices/clds/v2/loop/" + modelName;
@@ -112,7 +75,6 @@ app
cl_props = data;
def.resolve(data);
}).error(function(data) {
-
def.reject("Open Model not successful");
});
return def.promise;
@@ -145,7 +107,6 @@ app
propText : propTextIn
};
$http.put(svcUrl, svcRequest).success(function(data) {
-
def.resolve(data);
}).error(function(data) {
@@ -205,27 +166,18 @@ app
return def.promise;
};
this.processActionResponse = function(modelName) {
-
- // populate control name (prefix and uuid here)
+ // populate control name (prefix and uuid here)
var headerText = "Closed Loop Modeler - " + modelName;
setStatus();
manageCLImage(modelName);
enableDisableMenuOptions();
};
- this.processRefresh = function(pars) {
-
- var newPars = pars;
- if (typeof pars.body !== 'undefined') {
- newPars = pars.body;
- }
- typeID = newPars.typeId;
- deploymentId = newPars.deploymentId;
+ this.processRefresh = function() {
setStatus();
enableDisableMenuOptions();
}
function setStatus() {
-
- var status = getStatus();
+ var status = getLastUpdatedStatus();
// apply color to status
var statusColor = 'white';
if (status.trim() === "DESIGN") {
diff --git a/src/main/resources/META-INF/resources/designer/scripts/DeploymentCtrl.js b/src/main/resources/META-INF/resources/designer/scripts/DeploymentCtrl.js
index 3faf9f631..138d80202 100644
--- a/src/main/resources/META-INF/resources/designer/scripts/DeploymentCtrl.js
+++ b/src/main/resources/META-INF/resources/designer/scripts/DeploymentCtrl.js
@@ -27,62 +27,40 @@ app
'$scope',
'$rootScope',
'$uibModalInstance',
+'$http',
+'$q',
'data',
'dialogs',
'cldsModelService',
-function($scope, $rootScope, $uibModalInstance, data, dialogs, cldsModelService) {
+function($scope, $rootScope, $uibModalInstance, $http, $q, data, dialogs, cldsModelService) {
function validate_and_set_deploy_parameters() {
- var inputList = document.getElementsByClassName("deployFormId");
- var jsonParameters = "{";
- $.each(inputList, function(key) {
- if (jsonParameters !== "{") {
- jsonParameters = jsonParameters + ",";
+ var form = $("#deployForm")[0];
+ var obj = {};
+ for( var i = 0; i < form.length; ++i ) {
+ var name = form[i].name;
+ var value = form[i].value;
+ if( name ) {
+ obj[ name ] = value;
+ }
}
- jsonParameters = jsonParameters + '"' + inputList[key].id + '":'
- + '"' + inputList[key].value + '"'
- });
- jsonParameters = jsonParameters + "}";
- try {
- // Try to validate the json
- set_deploy_parameters(JSON.parse(jsonParameters));
- } catch (e) {
- console.error("Couldn't parse deploy parameters json");
- }
- }
- function set_deploy_parameters(parameters) {
- if (!'global' in elementMap) {
- elementMap["global"] = [];
- }
- var index = elementMap["global"].findIndex(function(e) {
- return (typeof e == "object" && !(e instanceof Array))
- && "deployParameters" == e["name"];
- });
- if (index == -1) {
- elementMap["global"].push({
- "name" : "deployParameters",
- "value" : parameters
+
+ var el = getGlobalProperty();
+ el["dcaeDeployParameters"] = obj;
+ $scope.saveGlobalProperties(JSON.stringify(el)).then(function(pars) {
+ updateGlobalProperties(el);
+ }, function(data) {
});
- } else {
- elementMap["global"][index]["value"] = parameters;
- }
}
+
$scope.load_deploy_parameters = function() {
- var index = elementMap["global"].findIndex(function(e) {
- return (typeof e == "object" && !(e instanceof Array))
- && "deployParameters" == e["name"];
- });
- if (index != -1) {
- $('#deployPropertiesDiv').append($('<br/>'));
- $.each(elementMap["global"][index].value, function(key) {
- var propertyValue = elementMap["global"][index].value[key];
- $('#deployPropertiesDiv').append(
- $('<label class="control-label">' + key + ' </label>'));
- $('#deployPropertiesDiv').append(
- $(
- '<input style="width: 100%; clear: both;" class="deployFormId" id="'
+ var el = getDeploymentProperties();
+ for (var key in el) {
+ var propertyValue = el[key];
+ $('#deployForm').append(
+ $('<label for="' + key + '" class="control-label">' + key + ' </label>'));
+ $('#deployForm').append(
+ $('<input style="width: 100%; clear: both;" class="form-control" name="'
+ key + '"></input>').val(propertyValue).html(propertyValue));
- $('#deployPropertiesDiv').append($('<br/>'));
- });
}
}
$scope.deploy = function() {
@@ -92,4 +70,15 @@ function($scope, $rootScope, $uibModalInstance, data, dialogs, cldsModelService)
$scope.close = function() {
$uibModalInstance.dismiss();
};
+ $scope.saveGlobalProperties = function(form) {
+ var modelName = getLoopName();
+ var def = $q.defer();
+ var svcUrl = "/restservices/clds/v2/loop/updateGlobalProperties/" + modelName;
+ $http.post(svcUrl, form).success(function(data) {
+ def.resolve(data);
+ }).error(function(data) {
+ def.reject("Save Global properties not successful");
+ });
+ return def.promise;
+ };
} ]);
diff --git a/src/main/resources/META-INF/resources/designer/scripts/OperationalPolicyCtrl.js b/src/main/resources/META-INF/resources/designer/scripts/OperationalPolicyCtrl.js
index 655775461..8e0319c1f 100644
--- a/src/main/resources/META-INF/resources/designer/scripts/OperationalPolicyCtrl.js
+++ b/src/main/resources/META-INF/resources/designer/scripts/OperationalPolicyCtrl.js
@@ -54,7 +54,7 @@ function($scope, $rootScope, $uibModalInstance, data, operationalPolicyService,
};
$scope.submitForm = function(obj) {
- var operationalPolicies = JSON.parse(JSON.stringify(getOperationalPolicies()));
+ var operationalPolicies = getOperationalPolicies();
if (obj !== null) {
operationalPolicies[0]["configurationsJson"] = obj;
}
diff --git a/src/main/resources/META-INF/resources/designer/scripts/ToscaModelCtrl.js b/src/main/resources/META-INF/resources/designer/scripts/ToscaModelCtrl.js
index 1901d95e6..2ef866c8b 100644
--- a/src/main/resources/META-INF/resources/designer/scripts/ToscaModelCtrl.js
+++ b/src/main/resources/META-INF/resources/designer/scripts/ToscaModelCtrl.js
@@ -89,7 +89,7 @@ app.controller('ToscaModelCtrl',
var policyType = $rootScope.selectedBoxName;
var data = $scope.getEditorData();
if(data !== null) {
- var msJson = JSON.parse(JSON.stringify(getMsJson(policyType)));
+ var msJson = getMsJson(policyType);
msJson["properties"] = data[0];
toscaModelService.saveMsProperties(msJson).then(function(pars) {
updateMsProperties(policyType, msJson);
diff --git a/src/main/resources/META-INF/resources/designer/scripts/app.js b/src/main/resources/META-INF/resources/designer/scripts/app.js
index b0b34533a..1b77bf82d 100644
--- a/src/main/resources/META-INF/resources/designer/scripts/app.js
+++ b/src/main/resources/META-INF/resources/designer/scripts/app.js
@@ -580,9 +580,8 @@ function($scope, $rootScope, $timeout, dialogs) {
var svgXml = $("#svgContainer").html();
console.log("refreStatus modelName=" + modelName);
cldsModelService.getModel(modelName).then(function(pars) {
-
console.log("refreStatus: pars=" + pars);
- cldsModelService.processRefresh(pars);
+ cldsModelService.processRefresh();
}, function(data) {
});
@@ -629,40 +628,10 @@ function($scope, $rootScope, $timeout, dialogs) {
});
};
function cldsToggleDeploy(uiAction) {
-
- var modelName = selected_model;
- var controlNamePrefix = "ClosedLoop-";
- var bpmnText = modelXML;
- // serialize model properties
- var propText = JSON.stringify(elementMap);
- var templateName = selected_template;
- var svgXml = $("#svgContainer").html();
console.log("cldsPerformAction: " + uiAction + " modelName="
- + modelName);
- console.log("cldsPerformAction: " + uiAction
- + " controlNamePrefix=" + controlNamePrefix);
- console.log("cldsPerformAction: " + uiAction + " bpmnText="
- + bpmnText);
- console.log("cldsPerformAction: " + uiAction + " propText="
- + propText);
- console.log("cldsPerformAction: " + uiAction
- + " modelEventService=" + modelEventService);
- console.log("cldsPerformAction: " + uiAction + " typeID=" + typeID);
- console.log("cldsPerformAction: " + uiAction + " deploymentId="
- + deploymentId);
- cldsModelService.toggleDeploy(uiAction, modelName,
- controlNamePrefix, bpmnText, propText, svgXml, templateName,
- typeID, controlNameUuid, modelEventService, deploymentId).then(
+ + selected_model);
+ cldsModelService.toggleDeploy(uiAction, selected_model).then(
function(pars) {
-
- var cldsObject = pars.body;
- typeID = cldsObject.typeId;
- controlNameUuid = cldsObject.controlNameUuid;
- selected_template = cldsObject.templateName;
- modelEventService = cldsObject.event;
- actionStateCd = cldsObject.event.actionStateCd;
- deploymentId = cldsObject.deploymentId;
- cldsModelService.processActionResponse(modelName, cldsObject);
}, function(data) {
});
diff --git a/src/main/resources/META-INF/resources/designer/scripts/propertyController.js b/src/main/resources/META-INF/resources/designer/scripts/propertyController.js
index f1ab1e195..2b32f4d26 100644
--- a/src/main/resources/META-INF/resources/designer/scripts/propertyController.js
+++ b/src/main/resources/META-INF/resources/designer/scripts/propertyController.js
@@ -22,7 +22,7 @@
*/
function updateMsProperties(type, newMsProperties) {
- var newMsProperties = cl_props["microServicePolicies"];
+ var newMsProperties = JSON.parse(JSON.stringify(cl_props["microServicePolicies"]));
for (p in newMsProperties) {
if (newMsProperties[p]["name"] == type) {
cl_props["microServicePolicies"][p] = newMsProperties;
@@ -43,22 +43,26 @@ function getLoopName() {
}
function getOperationalPolicyProperty() {
- return cl_props["operationalPolicies"]["0"]["configurationsJson"];
+ return JSON.parse(JSON.stringify(cl_props["operationalPolicies"]["0"]["configurationsJson"]));
}
function getOperationalPolicies() {
- return cl_props["operationalPolicies"];
+ return JSON.parse(JSON.stringify(cl_props["operationalPolicies"]));
}
function getGlobalProperty() {
- return cl_props["globalPropertiesJson"];
+ return JSON.parse(JSON.stringify(cl_props["globalPropertiesJson"]));
+}
+
+function getDeploymentProperties() {
+ return JSON.parse(JSON.stringify(cl_props["globalPropertiesJson"]["dcaeDeployParameters"]));
}
function getMsJson(type) {
var msProperties = cl_props["microServicePolicies"];
for (p in msProperties) {
if (msProperties[p]["name"] == type) {
- return msProperties[p];
+ return JSON.parse(JSON.stringify(msProperties[p]));
}
}
return null;
@@ -68,7 +72,7 @@ function getMsProperty(type) {
var msProperties = cl_props["microServicePolicies"];
for (p in msProperties) {
if (msProperties[p]["name"] == type) {
- return msProperties[p]["properties"];
+ return JSON.parse(JSON.stringify(msProperties[p]["properties"]));
}
}
return null;
@@ -78,21 +82,33 @@ function getMsUI(type) {
var msProperties = cl_props["microServicePolicies"];
for (p in msProperties) {
if (msProperties[p]["name"] == type) {
- return msProperties[p]["jsonRepresentation"];
+ return JSON.parse(JSON.stringify(msProperties[p]["jsonRepresentation"]));
}
}
return null;
}
-function getStatus() {
+function getLastUpdatedStatus() {
return cl_props["lastComputedState"];
}
+function setLastUpdatedStatus(status) {
+ cl_props["lastComputedState"] = status;
+}
+
function getDeploymentID() {
return cl_props["dcaeDeploymentId"];
}
+function setDeploymentID(deploymentId) {
+ cl_props["dcaeDeploymentId"] = deploymentId;
+}
+
function getDeploymentStatusURL() {
return cl_props["dcaeDeploymentStatusUrl"];
}
-module.exports = { getOperationalPolicyProperty,getGlobalProperty,getMsProperty,getMsUI,getStatus,getDeploymentID,getDeploymentStatusURL }; \ No newline at end of file
+
+function setDeploymentStatusURL(deploymentStatusURL) {
+ cl_props["dcaeDeploymentStatusUrl"] = deploymentStatusURL;
+}
+module.exports = { getOperationalPolicyProperty,getGlobalProperty,getMsProperty,getMsUI,getLastUpdatedStatus,getDeploymentID,getDeploymentStatusURL }; \ No newline at end of file
diff --git a/src/test/java/org/onap/clamp/clds/client/DcaeDispatcherServicesTest.java b/src/test/java/org/onap/clamp/clds/client/DcaeDispatcherServicesTest.java
index 1b01f544b..caab61f18 100644
--- a/src/test/java/org/onap/clamp/clds/client/DcaeDispatcherServicesTest.java
+++ b/src/test/java/org/onap/clamp/clds/client/DcaeDispatcherServicesTest.java
@@ -36,6 +36,7 @@ import org.mockito.Mock;
import org.mockito.Mockito;
import org.mockito.runners.MockitoJUnitRunner;
import org.onap.clamp.clds.config.ClampProperties;
+import org.onap.clamp.util.HttpConnectionManager;
@@ -55,7 +56,7 @@ public class DcaeDispatcherServicesTest {
private ClampProperties clampProperties;
@Mock
- DcaeHttpConnectionManager dcaeHttpConnectionManager;
+ HttpConnectionManager httpConnectionManager;
@InjectMocks
DcaeDispatcherServices dcaeDispatcherServices;
@@ -84,7 +85,7 @@ public class DcaeDispatcherServicesTest {
@Test
public void shouldReturnDcaeOperationSataus() throws IOException {
//given
- Mockito.when(dcaeHttpConnectionManager.doDcaeHttpQuery(DEPLOYMENT_STATUS_URL, "GET", null, null))
+ Mockito.when(httpConnectionManager.doGeneralHttpQuery(DEPLOYMENT_STATUS_URL, "GET", null, null, "DCAE"))
.thenReturn(STATUS_RESPONSE_PROCESSING);
//when
String operationStatus = dcaeDispatcherServices.getOperationStatus(DEPLOYMENT_STATUS_URL);
@@ -96,24 +97,24 @@ public class DcaeDispatcherServicesTest {
@Test
public void shouldTryMultipleTimesWhenProcessing() throws IOException, InterruptedException {
//given
- Mockito.when(dcaeHttpConnectionManager.doDcaeHttpQuery(DEPLOYMENT_STATUS_URL, "GET",
- null, null))
+ Mockito.when(httpConnectionManager.doGeneralHttpQuery(DEPLOYMENT_STATUS_URL, "GET",
+ null, null, "DCAE"))
.thenReturn(STATUS_RESPONSE_PROCESSING, STATUS_RESPONSE_PROCESSING, STATUS_RESPONSE_ACTIVE);
//when
String operationStatus = dcaeDispatcherServices.getOperationStatusWithRetry(DEPLOYMENT_STATUS_URL);
//then
Assertions.assertThat(operationStatus).isEqualTo("succeeded");
- Mockito.verify(dcaeHttpConnectionManager, Mockito.times(3))
- .doDcaeHttpQuery(DEPLOYMENT_STATUS_URL, "GET", null, null);
+ Mockito.verify(httpConnectionManager, Mockito.times(3))
+ .doGeneralHttpQuery(DEPLOYMENT_STATUS_URL, "GET", null, null, "DCAE");
}
@Test
public void shouldTryOnlyAsManyTimesAsConfigured() throws IOException, InterruptedException {
//given
- Mockito.when(dcaeHttpConnectionManager
- .doDcaeHttpQuery(DEPLOYMENT_STATUS_URL, "GET", null, null))
+ Mockito.when(httpConnectionManager
+ .doGeneralHttpQuery(DEPLOYMENT_STATUS_URL, "GET", null, null, "DCAE"))
.thenReturn(STATUS_RESPONSE_PROCESSING, STATUS_RESPONSE_PROCESSING, STATUS_RESPONSE_PROCESSING,
STATUS_RESPONSE_PROCESSING, STATUS_RESPONSE_PROCESSING);
//when
@@ -121,8 +122,8 @@ public class DcaeDispatcherServicesTest {
//then
Assertions.assertThat(operationStatus).isEqualTo("processing");
- Mockito.verify(dcaeHttpConnectionManager, Mockito.times(3))
- .doDcaeHttpQuery(DEPLOYMENT_STATUS_URL, "GET", null, null);
+ Mockito.verify(httpConnectionManager, Mockito.times(3))
+ .doGeneralHttpQuery(DEPLOYMENT_STATUS_URL, "GET", null, null, "DCAE");
}
@@ -134,12 +135,12 @@ public class DcaeDispatcherServicesTest {
Mockito.when(clampProperties.getJsonTemplate("dcae.deployment.template"))
.thenReturn(new JsonObject());
- Mockito.when(dcaeHttpConnectionManager
- .doDcaeHttpQuery(DCAE_URL
+ Mockito.when(httpConnectionManager
+ .doGeneralHttpQuery(DCAE_URL
+ "/dcae-deployments/closedLoop_152367c8-b172-47b3-9e58-c53add75d869_deploymentId",
"PUT",
"{\"serviceTypeId\":\"e2ba40f7-bf42-41e7-acd7-48fd07586d90\",\"inputs\":{}}",
- "application/json"))
+ "application/json", "DCAE"))
.thenReturn(DEPLOY_RESPONSE_STRING);
JsonObject blueprintInputJson = new JsonObject();
diff --git a/src/test/java/org/onap/clamp/clds/it/DcaeHttpConnectionManagerItCase.java b/src/test/java/org/onap/clamp/clds/it/HttpConnectionManagerItCase.java
index 8e03153a2..42e9c7f63 100644
--- a/src/test/java/org/onap/clamp/clds/it/DcaeHttpConnectionManagerItCase.java
+++ b/src/test/java/org/onap/clamp/clds/it/HttpConnectionManagerItCase.java
@@ -45,7 +45,7 @@ import javax.ws.rs.BadRequestException;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
-import org.onap.clamp.clds.client.DcaeHttpConnectionManager;
+import org.onap.clamp.util.HttpConnectionManager;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.test.context.SpringBootTest;
@@ -59,7 +59,7 @@ import org.springframework.test.context.junit4.SpringRunner;
@RunWith(SpringRunner.class)
@SpringBootTest(webEnvironment = WebEnvironment.DEFINED_PORT)
@TestPropertySource(locations = "classpath:https/https-test.properties")
-public class DcaeHttpConnectionManagerItCase {
+public class HttpConnectionManagerItCase {
@Value("${server.port}")
private String httpsPort;
@@ -67,7 +67,7 @@ public class DcaeHttpConnectionManagerItCase {
private String httpPort;
@Autowired
- DcaeHttpConnectionManager dcaeHttpConnectionManager;
+ HttpConnectionManager httpConnectionManager;
private static TrustManager[] trustAllCerts = new TrustManager[]{
new X509TrustManager() {
@@ -109,8 +109,8 @@ public class DcaeHttpConnectionManagerItCase {
@Test
public void testHttpGet() throws Exception {
- String response = dcaeHttpConnectionManager
- .doDcaeHttpQuery("http://localhost:" + this.httpPort + "/designer/index.html", "GET", null, null);
+ String response = httpConnectionManager
+ .doGeneralHttpQuery("http://localhost:" + this.httpPort + "/designer/index.html", "GET", null, null, "DCAE");
assertNotNull(response);
// Should be a redirection so 302, so empty
assertTrue(response.isEmpty());
@@ -118,8 +118,8 @@ public class DcaeHttpConnectionManagerItCase {
@Test
public void testHttpsGet() throws Exception {
- String response = dcaeHttpConnectionManager
- .doDcaeHttpQuery("https://localhost:" + this.httpsPort + "/designer/index.html", "GET", null, null);
+ String response = httpConnectionManager
+ .doGeneralHttpQuery("https://localhost:" + this.httpsPort + "/designer/index.html", "GET", null, null, "DCAE");
assertNotNull(response);
// Should contain something
assertTrue(!response.isEmpty());
@@ -127,22 +127,22 @@ public class DcaeHttpConnectionManagerItCase {
@Test(expected = BadRequestException.class)
public void testHttpsGet404() throws IOException {
- dcaeHttpConnectionManager.doDcaeHttpQuery("https://localhost:" + this.httpsPort + "/designer/index1.html",
- "GET", null, null);
+ httpConnectionManager.doGeneralHttpQuery("https://localhost:" + this.httpsPort + "/designer/index1.html",
+ "GET", null, null, "DCAE");
fail("Should have raised an BadRequestException");
}
@Test(expected = BadRequestException.class)
public void testHttpsPost404() throws IOException {
- dcaeHttpConnectionManager.doDcaeHttpQuery("https://localhost:" + this.httpsPort + "/designer/index1.html",
- "POST", "", "application/json");
+ httpConnectionManager.doGeneralHttpQuery("https://localhost:" + this.httpsPort + "/designer/index1.html",
+ "POST", "", "application/json", "DCAE");
fail("Should have raised an BadRequestException");
}
@Test(expected = BadRequestException.class)
public void testHttpException() throws IOException {
- dcaeHttpConnectionManager.doDcaeHttpQuery("http://localhost:" + this.httpsPort + "/designer/index.html", "GET",
- null, null);
+ httpConnectionManager.doGeneralHttpQuery("http://localhost:" + this.httpsPort + "/designer/index.html", "GET",
+ null, null, "DCAE");
fail("Should have raised an BadRequestException");
}
}
diff --git a/src/test/javascript/propertyController.test.js b/src/test/javascript/propertyController.test.js
index 6cb779145..fbbc6beca 100644
--- a/src/test/javascript/propertyController.test.js
+++ b/src/test/javascript/propertyController.test.js
@@ -31,8 +31,8 @@ describe('Property controller tests', function() {
expect(propertyController.getMsUI("test")).toEqual(null);
});
- test('getStatus', () => {
- expect(propertyController.getStatus()).toEqual('DESIGN');
+ test('getLastUpdatedStatus', () => {
+ expect(propertyController.getLastUpdatedStatus()).toEqual('DESIGN');
});
test('getDeploymentID', () => {