aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorxg353y <xg353y@intl.att.com>2019-02-20 12:45:04 +0100
committerxg353y <xg353y@intl.att.com>2019-02-20 13:47:13 +0100
commit1885741f27d74104a34cadf1f4d9c73f82c4fcff (patch)
tree957923b5bc4ee8b6dfdfb12995b6ef244def0491 /src
parent9eb3c7a2fa4f6cace52d49a84123f370babaf57f (diff)
Fix the bugs
Fix the bugs in tosca model related code, due to the json removal activity. Issue-ID: CLAMP-292 Change-Id: I6306930052b876b1ba8b0e1ce71689d4499e165c Change-Id: I6306930052b876b1ba8b0e1ce71689d4499e165c Signed-off-by: xg353y <xg353y@intl.att.com>
Diffstat (limited to 'src')
-rw-r--r--src/main/java/org/onap/clamp/clds/model/CldsToscaModel.java24
-rw-r--r--src/main/java/org/onap/clamp/clds/service/CldsToscaService.java14
-rw-r--r--src/main/resources/META-INF/resources/designer/scripts/ToscaModelCtrl.js2
-rw-r--r--src/main/resources/clds/camel/rest/clds-services.xml1
-rw-r--r--src/test/java/org/onap/clamp/clds/it/CldsToscaServiceItCase.java6
5 files changed, 16 insertions, 31 deletions
diff --git a/src/main/java/org/onap/clamp/clds/model/CldsToscaModel.java b/src/main/java/org/onap/clamp/clds/model/CldsToscaModel.java
index 25b8d401..6184b394 100644
--- a/src/main/java/org/onap/clamp/clds/model/CldsToscaModel.java
+++ b/src/main/java/org/onap/clamp/clds/model/CldsToscaModel.java
@@ -36,7 +36,12 @@ public class CldsToscaModel extends CldsToscaModelRevision {
private String id;
private String policyType;
private String toscaModelName;
- private String toscaModelYaml;
+
+ /**
+ * Construct
+ */
+ public CldsToscaModel () {
+ }
/**
* Creates or updates Tosca Model to DB
@@ -123,21 +128,4 @@ public class CldsToscaModel extends CldsToscaModelRevision {
this.toscaModelName = toscaModelName;
}
- /**
- * @return the toscaModelYaml
- */
- @Override
- public String getToscaModelYaml() {
- return toscaModelYaml;
- }
-
- /**
- * @param toscaModelYaml
- * the toscaModelYaml to set
- */
- @Override
- public void setToscaModelYaml(String toscaModelYaml) {
- this.toscaModelYaml = toscaModelYaml;
- }
-
}
diff --git a/src/main/java/org/onap/clamp/clds/service/CldsToscaService.java b/src/main/java/org/onap/clamp/clds/service/CldsToscaService.java
index 04205b70..adebd785 100644
--- a/src/main/java/org/onap/clamp/clds/service/CldsToscaService.java
+++ b/src/main/java/org/onap/clamp/clds/service/CldsToscaService.java
@@ -101,7 +101,7 @@ public class CldsToscaService extends SecureServiceBase {
*
* @return clds tosca models - list of CLDS tosca models
*/
- public ResponseEntity<List<CldsToscaModel>> getAllToscaModels() {
+ public List<CldsToscaModel> getAllToscaModels() {
Date startTime = new Date();
LoggingUtils.setRequestContext("CldsToscaService: Get All tosca models", getPrincipalName());
@@ -111,7 +111,7 @@ public class CldsToscaService extends SecureServiceBase {
LoggingUtils.setTimeContext(startTime, new Date());
LoggingUtils.setResponseContext("0", "Get All tosca models success", this.getClass().getName());
auditLogger.info("Get All tosca models");
- return new ResponseEntity<>(cldsToscaModels, HttpStatus.OK);
+ return cldsToscaModels;
}
/**
@@ -123,7 +123,7 @@ public class CldsToscaService extends SecureServiceBase {
*
* @return clds tosca model - CLDS tosca model for a given tosca model name
*/
- public ResponseEntity<CldsToscaModel> getToscaModel(String toscaModelName) {
+ public CldsToscaModel getToscaModel(String toscaModelName) {
Date startTime = new Date();
LoggingUtils.setRequestContext("CldsToscaService: Get tosca models by model name", getPrincipalName());
// TODO revisit based on new permissions
@@ -132,8 +132,7 @@ public class CldsToscaService extends SecureServiceBase {
LoggingUtils.setTimeContext(startTime, new Date());
LoggingUtils.setResponseContext("0", "Get tosca models by model name success", this.getClass().getName());
auditLogger.info("GET tosca models by model name completed");
- return new ResponseEntity<>(Optional.ofNullable(cldsToscaModels).get().stream().findFirst().get(),
- HttpStatus.OK);
+ return cldsToscaModels.get(0);
}
/**
@@ -143,7 +142,7 @@ public class CldsToscaService extends SecureServiceBase {
* @param policyType
* @return clds tosca model - CLDS tosca model for a given policy type
*/
- public ResponseEntity<CldsToscaModel> getToscaModelsByPolicyType(String policyType) {
+ public CldsToscaModel getToscaModelsByPolicyType(String policyType) {
Date startTime = new Date();
LoggingUtils.setRequestContext("CldsToscaService: Get tosca models by policyType", getPrincipalName());
// TODO revisit based on new permissions
@@ -152,8 +151,7 @@ public class CldsToscaService extends SecureServiceBase {
LoggingUtils.setTimeContext(startTime, new Date());
LoggingUtils.setResponseContext("0", "Get tosca models by policyType success", this.getClass().getName());
auditLogger.info("GET tosca models by policyType completed");
- return new ResponseEntity<>(Optional.ofNullable(cldsToscaModels).get().stream().findFirst().get(),
- HttpStatus.OK);
+ return cldsToscaModels.get(0);
}
public ResponseEntity<?> deleteToscaModelById(String toscaModeId) {
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 dc71fcd2..f78ad1e6 100644
--- a/src/main/resources/META-INF/resources/designer/scripts/ToscaModelCtrl.js
+++ b/src/main/resources/META-INF/resources/designer/scripts/ToscaModelCtrl.js
@@ -29,7 +29,7 @@ app.controller('ToscaModelCtrl',
toscaModelService.getHpModelJsonByPolicyType(selectedPolicy).then(function(response) {
$('#editor').empty();
- var toscaModel = JSON.parse(response.body.toscaModelJson);
+ var toscaModel = JSON.parse(response.toscaModelJson);
if($scope.policyList && toscaModel.schema.properties && toscaModel.schema.properties.policyList){
toscaModel.schema.properties.policyList.enum = $scope.policyList;
}
diff --git a/src/main/resources/clds/camel/rest/clds-services.xml b/src/main/resources/clds/camel/rest/clds-services.xml
index e4c4f4cb..7abffd35 100644
--- a/src/main/resources/clds/camel/rest/clds-services.xml
+++ b/src/main/resources/clds/camel/rest/clds-services.xml
@@ -115,6 +115,7 @@
uri="bean:org.onap.clamp.clds.service.CldsToscaService?method=parseToscaModelAndSave(${header.toscaModelName},${body})" />
</put>
<get uri="/tosca/models/policyType/{policyType}"
+ outType="org.onap.clamp.clds.model.CldsToscaModel"
produces="application/json">
<to
uri="bean:org.onap.clamp.clds.service.CldsToscaService?method=getToscaModelsByPolicyType(${header.policyType})" />
diff --git a/src/test/java/org/onap/clamp/clds/it/CldsToscaServiceItCase.java b/src/test/java/org/onap/clamp/clds/it/CldsToscaServiceItCase.java
index d4c7e5c2..7d48086c 100644
--- a/src/test/java/org/onap/clamp/clds/it/CldsToscaServiceItCase.java
+++ b/src/test/java/org/onap/clamp/clds/it/CldsToscaServiceItCase.java
@@ -120,16 +120,14 @@ public class CldsToscaServiceItCase {
@Test
public void testGetToscaModel() throws Exception {
- ResponseEntity<CldsToscaModel> responseEntity = cldsToscaService.getToscaModel("tca-policy-test");
- CldsToscaModel savedModel = responseEntity.getBody();
+ CldsToscaModel savedModel = cldsToscaService.getToscaModel("tca-policy-test");
assertNotNull(savedModel);
assertEquals("tca-policy-test", savedModel.getToscaModelName());
}
@Test
public void testGetToscaModelsByPolicyType() throws Exception {
- ResponseEntity<CldsToscaModel> responseEntity = cldsToscaService.getToscaModelsByPolicyType("tca");
- CldsToscaModel savedModel = responseEntity.getBody();
+ CldsToscaModel savedModel = cldsToscaService.getToscaModelsByPolicyType("tca");
assertNotNull(savedModel);
assertEquals("tca-policy-test", savedModel.getToscaModelName());
assertEquals("tca", savedModel.getPolicyType());