aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJim Hahn <jrh3@att.com>2021-02-22 22:40:05 +0000
committerGerrit Code Review <gerrit@onap.org>2021-02-22 22:40:05 +0000
commit09ace211a47e77a922911126ca2ba144500c4cfe (patch)
tree8effa28a880d16242cae1322edb5ba0963e190df
parent4d79c44047e9c4601ba551f6c167336d7fc8372b (diff)
parent3793824dd42862a0d46e5db1d44b346ed14f0eca (diff)
Merge "Fix the Tosca Converter to Json Schema" into tosca-poc
-rw-r--r--src/main/java/org/onap/policy/clamp/clds/tosca/update/execution/cds/ToscaMetadataCdsProcess.java12
-rw-r--r--src/main/java/org/onap/policy/clamp/clds/tosca/update/execution/target/ToscaMetadataTargetProcess.java12
-rw-r--r--src/main/java/org/onap/policy/clamp/clds/tosca/update/parser/ToscaConverterToJsonSchema.java4
-rw-r--r--src/test/resources/http-cache/example/policy/api/v1/policytypes/onap.policies.Naming/versions/1.0.0/.file2
4 files changed, 25 insertions, 5 deletions
diff --git a/src/main/java/org/onap/policy/clamp/clds/tosca/update/execution/cds/ToscaMetadataCdsProcess.java b/src/main/java/org/onap/policy/clamp/clds/tosca/update/execution/cds/ToscaMetadataCdsProcess.java
index bd3a1cb13..4ad47422c 100644
--- a/src/main/java/org/onap/policy/clamp/clds/tosca/update/execution/cds/ToscaMetadataCdsProcess.java
+++ b/src/main/java/org/onap/policy/clamp/clds/tosca/update/execution/cds/ToscaMetadataCdsProcess.java
@@ -2,7 +2,7 @@
* ============LICENSE_START=======================================================
* ONAP CLAMP
* ================================================================================
- * Copyright (C) 2020 AT&T Intellectual Property. All rights
+ * Copyright (C) 2020-2021 AT&T Intellectual Property. All rights
* reserved.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
@@ -23,6 +23,8 @@
package org.onap.policy.clamp.clds.tosca.update.execution.cds;
+import com.att.eelf.configuration.EELFLogger;
+import com.att.eelf.configuration.EELFManager;
import com.google.gson.JsonArray;
import com.google.gson.JsonElement;
import com.google.gson.JsonObject;
@@ -31,6 +33,7 @@ import java.util.Set;
import org.onap.policy.clamp.clds.tosca.ToscaSchemaConstants;
import org.onap.policy.clamp.clds.tosca.ToscaSchemaConstants;
import org.onap.policy.clamp.clds.tosca.update.execution.ToscaMetadataProcess;
+import org.onap.policy.clamp.clds.tosca.update.execution.target.ToscaMetadataTargetProcess;
import org.onap.policy.clamp.loop.service.Service;
@@ -39,8 +42,15 @@ import org.onap.policy.clamp.loop.service.Service;
*/
public class ToscaMetadataCdsProcess extends ToscaMetadataProcess {
+ private static final EELFLogger logger =
+ EELFManager.getInstance().getLogger(ToscaMetadataCdsProcess.class);
+
@Override
public void executeProcess(String parameters, JsonObject childObject, Service serviceModel) {
+ if (serviceModel == null) {
+ logger.info("serviceModel is null, therefore the ToscaMetadataCdsProcess is skipped");
+ return;
+ }
switch (parameters) {
case "actor":
JsonArray jsonArray = new JsonArray();
diff --git a/src/main/java/org/onap/policy/clamp/clds/tosca/update/execution/target/ToscaMetadataTargetProcess.java b/src/main/java/org/onap/policy/clamp/clds/tosca/update/execution/target/ToscaMetadataTargetProcess.java
index f4ca9909b..dcfd0594f 100644
--- a/src/main/java/org/onap/policy/clamp/clds/tosca/update/execution/target/ToscaMetadataTargetProcess.java
+++ b/src/main/java/org/onap/policy/clamp/clds/tosca/update/execution/target/ToscaMetadataTargetProcess.java
@@ -2,7 +2,7 @@
* ============LICENSE_START=======================================================
* ONAP CLAMP
* ================================================================================
- * Copyright (C) 2020 AT&T Intellectual Property. All rights
+ * Copyright (C) 2020-2021 AT&T Intellectual Property. All rights
* reserved.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
@@ -23,7 +23,10 @@
package org.onap.policy.clamp.clds.tosca.update.execution.target;
+import com.att.eelf.configuration.EELFLogger;
+import com.att.eelf.configuration.EELFManager;
import com.google.gson.JsonObject;
+import org.onap.policy.clamp.clds.tosca.update.execution.ToscaMetadataExecutor;
import org.onap.policy.clamp.clds.tosca.update.execution.ToscaMetadataProcess;
import org.onap.policy.clamp.loop.service.Service;
import org.onap.policy.clamp.policy.operational.OperationalPolicyRepresentationBuilder;
@@ -33,8 +36,15 @@ import org.onap.policy.clamp.policy.operational.OperationalPolicyRepresentationB
*/
public class ToscaMetadataTargetProcess extends ToscaMetadataProcess {
+ private static final EELFLogger logger =
+ EELFManager.getInstance().getLogger(ToscaMetadataTargetProcess.class);
+
@Override
public void executeProcess(String parameters, JsonObject childObject, Service serviceModel) {
+ if (serviceModel == null) {
+ logger.info("serviceModel is null, therefore the ToscaMetadataTargetProcess is skipped");
+ return;
+ }
childObject.add("anyOf", OperationalPolicyRepresentationBuilder.createAnyOfArray(serviceModel, false));
}
}
diff --git a/src/main/java/org/onap/policy/clamp/clds/tosca/update/parser/ToscaConverterToJsonSchema.java b/src/main/java/org/onap/policy/clamp/clds/tosca/update/parser/ToscaConverterToJsonSchema.java
index 5a9720a00..74fd8e5fd 100644
--- a/src/main/java/org/onap/policy/clamp/clds/tosca/update/parser/ToscaConverterToJsonSchema.java
+++ b/src/main/java/org/onap/policy/clamp/clds/tosca/update/parser/ToscaConverterToJsonSchema.java
@@ -118,8 +118,8 @@ public class ToscaConverterToJsonSchema {
JsonArray requirements = new JsonArray();
ToscaElement toParse = components.get(nameComponent);
//Check for a father component, and launch the same process
- if (!toParse.getDerivedFrom().equals("tosca.datatypes.Root")
- && !toParse.getDerivedFrom().equals("tosca.policies.Root")) {
+ if (!"tosca.datatypes.Root".equals(toParse.getDerivedFrom())
+ && !"tosca.policies.Root".equals(toParse.getDerivedFrom())) {
requirements.addAll(getRequirements(toParse.getDerivedFrom()));
}
//Each property is checked, and add to the requirement array if it's required
diff --git a/src/test/resources/http-cache/example/policy/api/v1/policytypes/onap.policies.Naming/versions/1.0.0/.file b/src/test/resources/http-cache/example/policy/api/v1/policytypes/onap.policies.Naming/versions/1.0.0/.file
index a44435111..a00692971 100644
--- a/src/test/resources/http-cache/example/policy/api/v1/policytypes/onap.policies.Naming/versions/1.0.0/.file
+++ b/src/test/resources/http-cache/example/policy/api/v1/policytypes/onap.policies.Naming/versions/1.0.0/.file
@@ -61,7 +61,7 @@ data_types:
type: policy.data.increment-sequence
required: false
policy.data.increment-sequence:
- derived_from: tosca.nodes.Root
+ derived_from: tosca.datatypes.Root
properties:
scope:
type: list