aboutsummaryrefslogtreecommitdiffstats
path: root/src/main
diff options
context:
space:
mode:
Diffstat (limited to 'src/main')
-rw-r--r--src/main/java/org/onap/clamp/clds/client/CdsServices.java26
-rw-r--r--src/main/java/org/onap/clamp/clds/exception/cds/CdsParametersException.java53
-rw-r--r--src/main/java/org/onap/clamp/clds/tosca/JsonEditorSchemaConstants.java15
-rw-r--r--src/main/java/org/onap/clamp/clds/tosca/ToscaSchemaConstants.java5
-rw-r--r--src/main/java/org/onap/clamp/clds/tosca/ToscaYamlToJsonConvertor.java106
-rw-r--r--src/main/java/org/onap/clamp/clds/tosca/update/execution/cds/ToscaMetadataCdsProcess.java121
-rw-r--r--src/main/java/org/onap/clamp/loop/Loop.java30
-rw-r--r--src/main/java/org/onap/clamp/loop/LoopController.java4
-rw-r--r--src/main/java/org/onap/clamp/loop/LoopService.java10
-rw-r--r--src/main/java/org/onap/clamp/loop/components/external/PolicyComponent.java46
-rw-r--r--src/main/java/org/onap/clamp/policy/Policy.java2
-rw-r--r--src/main/java/org/onap/clamp/policy/microservice/MicroServicePolicy.java5
-rw-r--r--src/main/java/org/onap/clamp/policy/microservice/MicroServicePolicyService.java2
-rw-r--r--src/main/java/org/onap/clamp/policy/operational/LegacyOperationalPolicy.java21
-rw-r--r--src/main/java/org/onap/clamp/policy/operational/OperationalPolicyRepresentationBuilder.java44
-rw-r--r--src/main/resources/clds/camel/rest/clamp-api-v2.xml99
-rw-r--r--src/main/resources/clds/camel/routes/dcae-flows.xml11
-rw-r--r--src/main/resources/clds/camel/routes/loop-flows.xml23
-rw-r--r--src/main/resources/clds/camel/routes/policy-flows.xml1290
-rw-r--r--src/main/resources/clds/json-schema/operational_policies/operational_policy.json30
20 files changed, 1081 insertions, 862 deletions
diff --git a/src/main/java/org/onap/clamp/clds/client/CdsServices.java b/src/main/java/org/onap/clamp/clds/client/CdsServices.java
index fe1937ab1..b8eb41946 100644
--- a/src/main/java/org/onap/clamp/clds/client/CdsServices.java
+++ b/src/main/java/org/onap/clamp/clds/client/CdsServices.java
@@ -34,6 +34,7 @@ import java.util.Map;
import org.apache.camel.CamelContext;
import org.apache.camel.Exchange;
import org.apache.camel.builder.ExchangeBuilder;
+import org.onap.clamp.clds.exception.cds.CdsParametersException;
import org.onap.clamp.clds.model.cds.CdsBpWorkFlowListResponse;
import org.onap.clamp.clds.util.JsonUtils;
import org.onap.clamp.clds.util.LoggingUtils;
@@ -117,7 +118,7 @@ public class CdsServices {
return null;
}
- private JsonObject parseCdsResponse(String response) {
+ protected JsonObject parseCdsResponse(String response) {
JsonObject root = JsonParser.parseString(response).getAsJsonObject();
JsonObject inputs = root.getAsJsonObject("workFlowData").getAsJsonObject("inputs");
JsonObject dataTypes = root.getAsJsonObject("dataTypes");
@@ -135,13 +136,34 @@ public class CdsServices {
String type = inputProperty.get("type").getAsString();
if (isComplexType(type, dataTypes)) {
inputObject.add(key, handleComplexType(type, dataTypes));
+ } else if (type.equalsIgnoreCase("list")) {
+ inputObject.add(key, handleListType(key, inputProperty,
+ dataTypes));
} else {
- inputObject.addProperty(key, "");
+ inputObject.add(key, entry.getValue());
}
}
return inputObject;
}
+ private JsonObject handleListType(String propertyName,
+ JsonObject inputProperty,
+ JsonObject dataTypes) {
+ if (inputProperty.get("entry_schema") != null) {
+ String type = inputProperty.get("entry_schema").getAsJsonObject().get(
+ "type").getAsString();
+ if (dataTypes.get(type) != null) {
+ JsonObject jsonObject = new JsonObject();
+ jsonObject.addProperty("type", "list");
+ jsonObject.add("properties", handleComplexType(type, dataTypes));
+ return jsonObject;
+ } else {
+ return inputProperty;
+ }
+ }
+ throw new CdsParametersException("Entry schema is null for " + propertyName);
+ }
+
private JsonObject handleComplexType(String key, JsonObject dataTypes) {
JsonObject properties = dataTypes.get(key).getAsJsonObject().get("properties").getAsJsonObject();
return getInputProperties(properties, dataTypes);
diff --git a/src/main/java/org/onap/clamp/clds/exception/cds/CdsParametersException.java b/src/main/java/org/onap/clamp/clds/exception/cds/CdsParametersException.java
new file mode 100644
index 000000000..73ce31f89
--- /dev/null
+++ b/src/main/java/org/onap/clamp/clds/exception/cds/CdsParametersException.java
@@ -0,0 +1,53 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP CLAMP
+ * ================================================================================
+ * Copyright (C) 2020 Huawei Technologies Co., Ltd.
+ * ================================================================================
+ * 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=========================================================
+ * ================================================================================
+ *
+ */
+
+package org.onap.clamp.clds.exception.cds;
+
+/**
+ * Exception while parsing CDS response.
+ */
+public class CdsParametersException extends RuntimeException {
+
+ /**
+ * serialization id.
+ */
+ private static final long serialVersionUID = 8425657297510362736L;
+
+ /**
+ * This constructor can be used to create a new CdsParametersException.
+ *
+ * @param message The message to dump
+ */
+ public CdsParametersException(final String message) {
+ super(message);
+ }
+
+ /**
+ * This constructor can be used to create a new CdsParametersException.
+ *
+ * @param message The message to dump
+ * @param cause The Throwable cause object
+ */
+ public CdsParametersException(final String message, final Throwable cause) {
+ super(message, cause);
+ }
+}
diff --git a/src/main/java/org/onap/clamp/clds/tosca/JsonEditorSchemaConstants.java b/src/main/java/org/onap/clamp/clds/tosca/JsonEditorSchemaConstants.java
index fdc94231f..e3c661698 100644
--- a/src/main/java/org/onap/clamp/clds/tosca/JsonEditorSchemaConstants.java
+++ b/src/main/java/org/onap/clamp/clds/tosca/JsonEditorSchemaConstants.java
@@ -28,8 +28,10 @@ public class JsonEditorSchemaConstants {
//Data types in JSON Schema
public static final String TYPE_OBJECT = "object";
public static final String TYPE_ARRAY = "array";
+ public static final String TYPE_MAP = "map";
public static final String TYPE_STRING = "string";
public static final String TYPE_INTEGER = "integer";
+ public static final String TYPE_DATE_TIME = "datetime";
//Key elements in JSON Schema
public static final String TYPE = "type";
@@ -43,6 +45,9 @@ public class JsonEditorSchemaConstants {
public static final String ITEMS = "items";
public static final String PROPERTIES = "properties";
public static final String PROPERTY_ORDER = "propertyOrder";
+ public static final String VALUES = "values";
+ public static final String HEADER_TEMPLATE = "headerTemplate";
+ public static final String HEADER_TEMPLATE_VALUE = "{{self.name}}";
public static final String MINIMUM = "minimum";
public static final String MAXIMUM = "maximum";
@@ -50,9 +55,13 @@ public class JsonEditorSchemaConstants {
public static final String MAX_LENGTH = "maxLength";
public static final String EXCLUSIVE_MINIMUM = "exclusiveMinimum";
public static final String EXCLUSIVE_MAXIMUM = "exclusiveMaximum";
+ public static final String MINITEMS = "minItems";
+ public static final String MAXITEMS = "maxItems";
public static final String CUSTOM_KEY_FORMAT = "format";
public static final String CUSTOM_KEY_FORMAT_TABS_TOP = "tabs-top";
+ public static final String CUSTOM_KEY_FORMAT_TABS = "tabs";
+ public static final String CUSTOM_KEY_FORMAT_INPUT = "input";
public static final String FORMAT_SELECT = "select";
public static final String UNIQUE_ITEMS = "uniqueItems";
public static final String TRUE = "true";
@@ -67,5 +76,11 @@ public class JsonEditorSchemaConstants {
public static final String SCHEMA = "schema";
public static final String CURRENT_VALUES = "currentValues";
+ public static final String PLUGIN = "plugin";
+ public static final String DATE_TIME_PICKER = "datetimepicker";
+ public static final String VALIDATION = "validation";
+ public static final String DATE_TIME_FORMAT = "YYYY/MM/DD HH:mm:ss";
+ public static final String INPUT_EVENT = "input_event";
+ public static final String DP_CHANGE = "dp.change";
}
diff --git a/src/main/java/org/onap/clamp/clds/tosca/ToscaSchemaConstants.java b/src/main/java/org/onap/clamp/clds/tosca/ToscaSchemaConstants.java
index 9601649c9..d00c431c8 100644
--- a/src/main/java/org/onap/clamp/clds/tosca/ToscaSchemaConstants.java
+++ b/src/main/java/org/onap/clamp/clds/tosca/ToscaSchemaConstants.java
@@ -30,8 +30,11 @@ public class ToscaSchemaConstants {
public static final String TYPE_MAP = "map";
public static final String TYPE_STRING = "string";
public static final String TYPE_INTEGER = "integer";
+ public static final String TYPE_NUMBER = "number";
+ public static final String TYPE_DATE_TIME = "datetime";
public static final String TYPE_FLOAT = "float";
public static final String TYPE_BOOLEAN = "boolean";
+ public static final String TYPE_USER_DEFINED = "userDefined";
// Key elements in Tosca
public static final String NODE_TYPES = "policy_types";
@@ -46,6 +49,8 @@ public class ToscaSchemaConstants {
public static final String METADATA = "metadata";
public static final String METADATA_POLICY_MODEL_TYPE = "policy_model_type";
public static final String METADATA_ACRONYM = "acronym";
+ public static final String METADATA_ELEMENT_NAME = "element_name";
+ public static final String METADATA_HEADER_TEMPLATE = "header_template";
public static final String METADATA_CLAMP_POSSIBLE_VALUES = "clamp_possible_values";
// Constraints
diff --git a/src/main/java/org/onap/clamp/clds/tosca/ToscaYamlToJsonConvertor.java b/src/main/java/org/onap/clamp/clds/tosca/ToscaYamlToJsonConvertor.java
index 666ca6702..45bb87ed8 100644
--- a/src/main/java/org/onap/clamp/clds/tosca/ToscaYamlToJsonConvertor.java
+++ b/src/main/java/org/onap/clamp/clds/tosca/ToscaYamlToJsonConvertor.java
@@ -38,6 +38,7 @@ import java.util.stream.Collectors;
import org.json.JSONArray;
import org.json.JSONObject;
import org.onap.clamp.clds.config.ClampProperties;
+import org.onap.clamp.tosca.Dictionary;
import org.onap.clamp.tosca.DictionaryElement;
import org.onap.clamp.tosca.DictionaryService;
import org.springframework.beans.factory.annotation.Autowired;
@@ -142,6 +143,13 @@ public class ToscaYamlToJsonConvertor {
parseNodeAndDataType(loadedYaml, nodeTypes, dataNodes);
populateJsonEditorObject(loadedYaml, nodeTypes, dataNodes, jsonParentObject, jsonTempObject,
modelTypeToUse);
+
+ String headerTemplate = getValueFromMetadata(validateAndConvertToJson(yamlString),
+ ToscaSchemaConstants.METADATA_HEADER_TEMPLATE);
+ if (headerTemplate != null) {
+ jsonParentObject.put(JsonEditorSchemaConstants.HEADER_TEMPLATE,
+ JsonEditorSchemaConstants.HEADER_TEMPLATE_VALUE);
+ }
if (jsonTempObject.length() > 0) {
jsonParentObject = jsonTempObject;
}
@@ -234,7 +242,7 @@ public class ToscaYamlToJsonConvertor {
jsonTempObject.put(JsonEditorSchemaConstants.ITEMS,
jsonParentObject);
jsonTempObject.put(JsonEditorSchemaConstants.FORMAT,
- JsonEditorSchemaConstants.CUSTOM_KEY_FORMAT_TABS_TOP);
+ JsonEditorSchemaConstants.CUSTOM_KEY_FORMAT_TABS);
jsonTempObject.put(JsonEditorSchemaConstants.UNIQUE_ITEMS,
JsonEditorSchemaConstants.TRUE);
}
@@ -652,12 +660,43 @@ public class ToscaYamlToJsonConvertor {
Optional.ofNullable(cldsDictionaryElements).get().stream().forEach(c -> {
JSONObject jsonObject = new JSONObject();
+ if (c.getSubDictionary() != null) {
+ Dictionary subDictionary =
+ dictionaryService.getDictionary(c.getSubDictionary());
+ if (subDictionary != null
+ && !subDictionary.getDictionaryElements().isEmpty()) {
+
+ jsonObject.put(JsonEditorSchemaConstants.CUSTOM_KEY_FORMAT_INPUT,
+ JsonEditorSchemaConstants.FORMAT_SELECT);
+
+ List<String> shortNames = new ArrayList<>();
+ subDictionary.getDictionaryElements().stream().forEach(c1 -> {
+ shortNames.add(c1.getShortName());
+ });
+ jsonObject.put(JsonEditorSchemaConstants.VALUES, shortNames);
+ }
+ }
jsonObject.put(JsonEditorSchemaConstants.TYPE, getJsonType(c.getType()));
+
if (c.getType() != null
- && c.getType().equalsIgnoreCase(ToscaSchemaConstants.TYPE_STRING)) {
+ && (c.getType().equalsIgnoreCase(ToscaSchemaConstants.TYPE_STRING)
+ || c.getType().equalsIgnoreCase(ToscaSchemaConstants.TYPE_DATE_TIME)
+ || c.getType().equalsIgnoreCase(ToscaSchemaConstants.TYPE_MAP))) {
jsonObject.put(JsonEditorSchemaConstants.MIN_LENGTH, 1);
+ if (c.getType().equalsIgnoreCase(ToscaSchemaConstants.TYPE_DATE_TIME)) {
+ jsonObject.put(JsonEditorSchemaConstants.PLUGIN,
+ JsonEditorSchemaConstants.DATE_TIME_PICKER);
+ jsonObject.put(JsonEditorSchemaConstants.INPUT_EVENT,
+ JsonEditorSchemaConstants.DP_CHANGE);
+ JSONObject formatJsonObject = new JSONObject();
+ formatJsonObject.put(JsonEditorSchemaConstants.FORMAT,
+ JsonEditorSchemaConstants.DATE_TIME_FORMAT);
+ jsonObject.put(JsonEditorSchemaConstants.VALIDATION,
+ formatJsonObject);
+ }
}
+
jsonObject.put(JsonEditorSchemaConstants.ID, c.getName());
jsonObject.put(JsonEditorSchemaConstants.LABEL, c.getShortName());
jsonObject.put(JsonEditorSchemaConstants.OPERATORS, subCldsDictionaryNames);
@@ -678,32 +717,44 @@ public class ToscaYamlToJsonConvertor {
String dictionaryKey = dictionaryReference.substring(
dictionaryReference.indexOf(ToscaSchemaConstants.DICTIONARY) + 11,
dictionaryReference.length());
+
if (dictionaryKey != null) {
- List<DictionaryElement> cldsDictionaryElements =
- dictionaryService.getDictionary(dictionaryKey).getDictionaryElements().stream()
- .collect(Collectors.toList());
- if (cldsDictionaryElements != null) {
- List<String> cldsDictionaryNames = new ArrayList<>();
- List<String> cldsDictionaryFullNames = new ArrayList<>();
- cldsDictionaryElements.stream().forEach(c -> {
- // Json type will be translated before Policy creation
- if (c.getType() != null && !c.getType().equalsIgnoreCase("json")) {
- cldsDictionaryFullNames.add(c.getName());
+ if (dictionaryKey.contains(ToscaSchemaConstants.TYPE_USER_DEFINED)) {
+ childObject.put(JsonEditorSchemaConstants.ENUM, new ArrayList<>());
+ // Add Enum titles for generated translated values during
+ // JSON instance generation
+ JSONObject enumTitles = new JSONObject();
+ enumTitles.put(JsonEditorSchemaConstants.ENUM_TITLES, new ArrayList<>());
+ childObject.put(JsonEditorSchemaConstants.OPTIONS, enumTitles);
+ } else {
+ List<DictionaryElement> cldsDictionaryElements =
+ dictionaryService.getDictionary(dictionaryKey).getDictionaryElements()
+ .stream().collect(Collectors.toList());
+ if (cldsDictionaryElements != null) {
+ List<String> cldsDictionaryNames = new ArrayList<>();
+ List<String> cldsDictionaryFullNames = new ArrayList<>();
+ cldsDictionaryElements.stream().forEach(c -> {
+ // Json type will be translated before Policy creation
+ if (c.getType() != null && !c.getType().equalsIgnoreCase("json")) {
+ cldsDictionaryFullNames.add(c.getName());
+ }
+ cldsDictionaryNames.add(c.getShortName());
+ });
+
+ if (!cldsDictionaryFullNames.isEmpty()) {
+ childObject.put(JsonEditorSchemaConstants.ENUM,
+ cldsDictionaryFullNames);
+ // Add Enum titles for generated translated values during JSON instance
+ // generation
+ JSONObject enumTitles = new JSONObject();
+ enumTitles.put(JsonEditorSchemaConstants.ENUM_TITLES,
+ cldsDictionaryNames);
+ childObject.put(JsonEditorSchemaConstants.OPTIONS, enumTitles);
+ } else {
+ childObject.put(JsonEditorSchemaConstants.ENUM, cldsDictionaryNames);
}
- cldsDictionaryNames.add(c.getShortName());
- });
- if (!cldsDictionaryFullNames.isEmpty()) {
- childObject.put(JsonEditorSchemaConstants.ENUM, cldsDictionaryFullNames);
- // Add Enum titles for generated translated values during JSON instance
- // generation
- JSONObject enumTitles = new JSONObject();
- enumTitles.put(JsonEditorSchemaConstants.ENUM_TITLES, cldsDictionaryNames);
- childObject.put(JsonEditorSchemaConstants.OPTIONS, enumTitles);
- } else {
- childObject.put(JsonEditorSchemaConstants.ENUM, cldsDictionaryNames);
}
-
}
}
}
@@ -711,10 +762,15 @@ public class ToscaYamlToJsonConvertor {
private String getJsonType(String toscaType) {
String jsonType = null;
- if (toscaType.equalsIgnoreCase(ToscaSchemaConstants.TYPE_INTEGER)) {
+ if (toscaType.equalsIgnoreCase(ToscaSchemaConstants.TYPE_INTEGER)
+ || toscaType.equalsIgnoreCase(ToscaSchemaConstants.TYPE_NUMBER)) {
jsonType = JsonEditorSchemaConstants.TYPE_INTEGER;
+ } else if (toscaType.equalsIgnoreCase(ToscaSchemaConstants.TYPE_DATE_TIME)) {
+ jsonType = JsonEditorSchemaConstants.TYPE_DATE_TIME;
} else if (toscaType.equalsIgnoreCase(ToscaSchemaConstants.TYPE_LIST)) {
jsonType = JsonEditorSchemaConstants.TYPE_ARRAY;
+ } else if (toscaType.equalsIgnoreCase(ToscaSchemaConstants.TYPE_MAP)) {
+ jsonType = JsonEditorSchemaConstants.TYPE_MAP;
} else {
jsonType = JsonEditorSchemaConstants.TYPE_STRING;
}
diff --git a/src/main/java/org/onap/clamp/clds/tosca/update/execution/cds/ToscaMetadataCdsProcess.java b/src/main/java/org/onap/clamp/clds/tosca/update/execution/cds/ToscaMetadataCdsProcess.java
index 81e30cf43..c15641413 100644
--- a/src/main/java/org/onap/clamp/clds/tosca/update/execution/cds/ToscaMetadataCdsProcess.java
+++ b/src/main/java/org/onap/clamp/clds/tosca/update/execution/cds/ToscaMetadataCdsProcess.java
@@ -23,10 +23,17 @@
package org.onap.clamp.clds.tosca.update.execution.cds;
+import static org.onap.clamp.clds.tosca.ToscaSchemaConstants.PROPERTIES;
+import static org.onap.clamp.clds.tosca.ToscaSchemaConstants.TYPE;
+import static org.onap.clamp.clds.tosca.ToscaSchemaConstants.TYPE_LIST;
+
import com.google.gson.JsonArray;
import com.google.gson.JsonElement;
import com.google.gson.JsonObject;
+
import java.util.Map;
+import java.util.Set;
+
import org.onap.clamp.clds.tosca.update.execution.ToscaMetadataProcess;
import org.onap.clamp.loop.service.Service;
import org.onap.clamp.tosca.DictionaryService;
@@ -58,9 +65,11 @@ public class ToscaMetadataCdsProcess extends ToscaMetadataProcess {
}
private static void generatePayload(JsonObject childObject, Service serviceModel) {
- generatePayloadPerResource(childObject, "VF", serviceModel);
- generatePayloadPerResource(childObject, "PNF", serviceModel);
- addToJsonArray(childObject, "anyOf", createBlankEntry());
+ JsonArray schemaAnyOf = new JsonArray();
+ schemaAnyOf.addAll(createBlankEntry());
+ schemaAnyOf.addAll(generatePayloadPerResource("VF", serviceModel));
+ schemaAnyOf.addAll(generatePayloadPerResource("PNF", serviceModel));
+ addToJsonArray(childObject, "anyOf", schemaAnyOf);
}
private static void generateOperation(JsonObject childObject, Service serviceModel) {
@@ -92,8 +101,8 @@ public class ToscaMetadataCdsProcess extends ToscaMetadataProcess {
}
- private static void generatePayloadPerResource(JsonObject childObject, String resourceName,
- Service serviceModel) {
+ private static JsonArray generatePayloadPerResource(String resourceName,
+ Service serviceModel) {
JsonArray schemaAnyOf = new JsonArray();
for (Map.Entry<String, JsonElement> entry : serviceModel.getResourceDetails().getAsJsonObject(resourceName)
@@ -105,13 +114,14 @@ public class ToscaMetadataCdsProcess extends ToscaMetadataProcess {
.entrySet()) {
JsonObject obj = new JsonObject();
obj.addProperty("title", workflowsEntry.getKey());
- obj.add("properties", createPayloadProperty(workflowsEntry.getValue().getAsJsonObject(),
- controllerProperties));
+ obj.add("properties",
+ createInputPropertiesForPayload(workflowsEntry.getValue().getAsJsonObject(),
+ controllerProperties));
schemaAnyOf.add(obj);
}
}
}
- addToJsonArray(childObject, "anyOf", schemaAnyOf);
+ return schemaAnyOf;
}
private static JsonArray createBlankEntry() {
@@ -123,20 +133,6 @@ public class ToscaMetadataCdsProcess extends ToscaMetadataProcess {
return result;
}
- private static JsonObject createPayloadProperty(JsonObject workFlow, JsonObject controllerProperties) {
- JsonObject payloadResult = new JsonObject();
-
- payloadResult.add("artifact_name",
- createAnyOfJsonProperty("artifact_name", controllerProperties.get("sdnc_model_name").getAsString()));
- payloadResult.add("artifact_version",
- createAnyOfJsonProperty("artifact_version",
- controllerProperties.get("sdnc_model_version").getAsString()));
- payloadResult.add("mode", createAnyOfJsonProperty("mode", "async"));
-
- payloadResult.add("data", createAnyOfJsonObject("data", workFlow.getAsJsonObject("inputs")));
- return payloadResult;
- }
-
private static JsonObject createAnyOfJsonProperty(String name, String defaultValue) {
JsonObject result = new JsonObject();
result.addProperty("title", name);
@@ -157,9 +153,86 @@ public class ToscaMetadataCdsProcess extends ToscaMetadataProcess {
private static void addToJsonArray(JsonObject childObject, String section, JsonArray value) {
if (childObject.getAsJsonArray(section) != null) {
childObject.getAsJsonArray(section).addAll(value);
- }
- else {
+ } else {
childObject.add(section, value);
}
}
+
+ /**
+ * Returns the properties of payload based on the cds work flows.
+ *
+ * @param workFlow cds work flows to update payload
+ * @param controllerProperties cds properties to get blueprint name and
+ * version
+ * @return returns the properties of payload
+ */
+ public static JsonObject createInputPropertiesForPayload(JsonObject workFlow,
+ JsonObject controllerProperties) {
+ String artifactName = controllerProperties.get("sdnc_model_name").getAsString();
+ String artifactVersion = controllerProperties.get("sdnc_model_version").getAsString();
+ JsonObject inputs = workFlow.getAsJsonObject("inputs");
+ JsonObject jsonObject = new JsonObject();
+ jsonObject.add("artifact_name", createAnyOfJsonProperty(
+ "artifact name", artifactName));
+ jsonObject.add("artifact_version", createAnyOfJsonProperty(
+ "artifact version", artifactVersion));
+ jsonObject.add("mode", createCdsInputProperty(
+ "mode", "string", "async", null));
+ jsonObject.add("data", createDataProperty(inputs));
+
+ return jsonObject;
+ }
+
+ private static JsonObject createDataProperty(JsonObject inputs) {
+ JsonObject data = new JsonObject();
+ data.addProperty("title", "data");
+ data.add(PROPERTIES, addDataFields(inputs));
+ return data;
+ }
+
+ private static JsonObject addDataFields(JsonObject inputs) {
+ JsonObject jsonObject = new JsonObject();
+ Set<Map.Entry<String, JsonElement>> entrySet = inputs.entrySet();
+ for (Map.Entry<String, JsonElement> entry : entrySet) {
+ String key = entry.getKey();
+ JsonObject inputProperty = inputs.getAsJsonObject(key);
+ if (inputProperty.get(TYPE) == null) {
+ jsonObject.add(entry.getKey(),
+ createAnyOfJsonObject(key,
+ addDataFields(entry.getValue().getAsJsonObject())));
+ } else {
+ jsonObject.add(entry.getKey(),
+ createCdsInputProperty(key,
+ inputProperty.get("type").getAsString(),
+ null,
+ entry.getValue().getAsJsonObject()));
+ }
+ }
+ return jsonObject;
+ }
+
+ private static JsonObject createCdsInputProperty(String title,
+ String type,
+ String defaultValue,
+ JsonObject cdsProperty) {
+ JsonObject property = new JsonObject();
+ property.addProperty("title", title);
+
+ if (TYPE_LIST.equalsIgnoreCase(type)) {
+ property.addProperty(TYPE, "array");
+ if (cdsProperty.get(PROPERTIES) != null) {
+ JsonObject listProperties = new JsonObject();
+ listProperties.add(PROPERTIES,
+ addDataFields(cdsProperty.get(PROPERTIES).getAsJsonObject()));
+ property.add("items", listProperties);
+ }
+ } else {
+ property.addProperty(TYPE, type);
+ }
+
+ if (defaultValue != null) {
+ property.addProperty("default", defaultValue);
+ }
+ return property;
+ }
}
diff --git a/src/main/java/org/onap/clamp/loop/Loop.java b/src/main/java/org/onap/clamp/loop/Loop.java
index 19a17dbb0..081331337 100644
--- a/src/main/java/org/onap/clamp/loop/Loop.java
+++ b/src/main/java/org/onap/clamp/loop/Loop.java
@@ -331,6 +331,36 @@ public class Loop extends AuditEntity implements Serializable {
}
/**
+ * Return the operationalPolicy object with the opPolicyName.
+ *
+ * @param opPolicyName The operationalPolicy name
+ * @return The OperationalPolicy object found in loop object
+ */
+ public OperationalPolicy getOperationalPolicy(String opPolicyName) {
+ for (OperationalPolicy operationalPolicy : this.getOperationalPolicies()) {
+ if (operationalPolicy.getName().equals(opPolicyName)) {
+ return operationalPolicy;
+ }
+ }
+ return null;
+ }
+
+ /**
+ * Return the microServicePolicy object with the msPolicyName.
+ *
+ * @param msPolicyName The microServicePolicy name
+ * @return The MicroServicePolicy object found in loop object
+ */
+ public MicroServicePolicy getMicroServicePolicy(String msPolicyName) {
+ for (MicroServicePolicy microServicePolicy : this.getMicroServicePolicies()) {
+ if (microServicePolicy.getName().equals(msPolicyName)) {
+ return microServicePolicy;
+ }
+ }
+ return null;
+ }
+
+ /**
* Generate the loop name.
*
* @param serviceName The service name
diff --git a/src/main/java/org/onap/clamp/loop/LoopController.java b/src/main/java/org/onap/clamp/loop/LoopController.java
index a2a44631b..fad93bc7d 100644
--- a/src/main/java/org/onap/clamp/loop/LoopController.java
+++ b/src/main/java/org/onap/clamp/loop/LoopController.java
@@ -137,11 +137,11 @@ public class LoopController {
}
/**
- * This method remove an operational policy to a loop instance.
+ * This method removes an operational policy from a loop instance.
*
* @param loopName The loop name
* @param policyType The policy model type
- * @param policyVersion The policy model version
+ * @param policyVersion The policy model version
* @return The loop modified
*/
public Loop removeOperationalPolicy(String loopName, String policyType, String policyVersion) {
diff --git a/src/main/java/org/onap/clamp/loop/LoopService.java b/src/main/java/org/onap/clamp/loop/LoopService.java
index af1f58ba7..3f568a331 100644
--- a/src/main/java/org/onap/clamp/loop/LoopService.java
+++ b/src/main/java/org/onap/clamp/loop/LoopService.java
@@ -98,7 +98,7 @@ public class LoopService {
public void updateDcaeDeploymentFields(Loop loop, String deploymentId, String deploymentUrl) {
loop.setDcaeDeploymentId(deploymentId);
loop.setDcaeDeploymentStatusUrl(deploymentUrl);
- loopsRepository.save(loop);
+ loopsRepository.saveAndFlush(loop);
}
public void updateLoopState(Loop loop, String newState) {
@@ -118,6 +118,12 @@ public class LoopService {
Loop addOperationalPolicy(String loopName, String policyType, String policyVersion) throws IOException {
Loop loop = getLoop(loopName);
PolicyModel policyModel = policyModelsService.getPolicyModel(policyType, policyVersion);
+ Set<OperationalPolicy> opPolicySet = loop.getOperationalPolicies();
+ for (OperationalPolicy opPolicy : opPolicySet) {
+ if (opPolicy.getPolicyModel().equals(policyModel)) {
+ throw new IllegalArgumentException("This type of Operational Policy is already added to the loop. Please choose another one.");
+ }
+ }
if (policyModel == null) {
return null;
}
@@ -131,7 +137,7 @@ public class LoopService {
*
* @param loopName The loop name
* @param policyType The policy model type
- * @param policyVersion The policy model version
+ * @param policyVersion The policy model version
* @return The loop modified
*/
Loop removeOperationalPolicy(String loopName, String policyType, String policyVersion) {
diff --git a/src/main/java/org/onap/clamp/loop/components/external/PolicyComponent.java b/src/main/java/org/onap/clamp/loop/components/external/PolicyComponent.java
index 8270a96e3..227f40a72 100644
--- a/src/main/java/org/onap/clamp/loop/components/external/PolicyComponent.java
+++ b/src/main/java/org/onap/clamp/loop/components/external/PolicyComponent.java
@@ -28,7 +28,6 @@ import com.att.eelf.configuration.EELFManager;
import com.google.gson.GsonBuilder;
import com.google.gson.JsonArray;
import com.google.gson.JsonObject;
-import java.util.ArrayList;
import java.util.HashMap;
import java.util.LinkedList;
import java.util.List;
@@ -76,25 +75,33 @@ public class PolicyComponent extends ExternalComponent {
/**
* Generates the Json that must be sent to policy to add all policies to Active
* PDP group.
- *
+ * @param loop the loop object
+ * @param action POST (to add policy to group) or DELETE (to delete policy from group)
* @return The json, payload to send
*/
- public static String createPoliciesPayloadPdpGroup(Loop loop) {
+ public static String createPoliciesPayloadPdpGroup(Loop loop, String action) {
Map<String, Map<String, List<JsonObject>>> pdpGroupMap = new HashMap<>();
for (OperationalPolicy opPolicy : loop.getOperationalPolicies()) {
updatePdpGroupMap(opPolicy.getPdpGroup(), opPolicy.getPdpSubgroup(),
opPolicy.getName(),
- opPolicy.getPolicyModel().getVersion(), pdpGroupMap);
+ "1.0.0", pdpGroupMap);
+ if (opPolicy.isLegacy()) {
+ for (String guardName:opPolicy.createGuardPolicyPayloads().keySet()) {
+ updatePdpGroupMap(opPolicy.getPdpGroup(), opPolicy.getPdpSubgroup(),
+ guardName,
+ "1.0.0", pdpGroupMap);
+ }
+ }
}
for (MicroServicePolicy msPolicy : loop.getMicroServicePolicies()) {
updatePdpGroupMap(msPolicy.getPdpGroup(), msPolicy.getPdpSubgroup(),
msPolicy.getName(),
- msPolicy.getPolicyModel().getVersion(), pdpGroupMap);
+ "1.0.0", pdpGroupMap);
}
String payload = new GsonBuilder().setPrettyPrinting().create()
- .toJson(generateActivatePdpGroupPayload(pdpGroupMap));
+ .toJson(generateActivatePdpGroupPayload(pdpGroupMap, action));
logger.info("PdpGroup policy payload: " + payload);
return payload;
}
@@ -102,12 +109,12 @@ public class PolicyComponent extends ExternalComponent {
private static void updatePdpGroupMap(String pdpGroup,
String pdpSubGroup,
String policyName,
- String policyModelVersion,
+ String policyVersion,
Map<String, Map<String,
List<JsonObject>>> pdpGroupMap) {
JsonObject policyJson = new JsonObject();
policyJson.addProperty("name", policyName);
- policyJson.addProperty("version", policyModelVersion);
+ policyJson.addProperty("version", policyVersion);
Map<String, List<JsonObject>> pdpSubGroupMap;
List<JsonObject> policyList;
if (pdpGroupMap.get(pdpGroup) == null) {
@@ -129,7 +136,7 @@ public class PolicyComponent extends ExternalComponent {
}
private static JsonObject generateActivatePdpGroupPayload(
- Map<String, Map<String, List<JsonObject>>> pdpGroupMap) {
+ Map<String, Map<String, List<JsonObject>>> pdpGroupMap, String action) {
JsonArray payloadArray = new JsonArray();
for (Entry<String, Map<String, List<JsonObject>>> pdpGroupInfo : pdpGroupMap.entrySet()) {
JsonObject pdpGroupNode = new JsonObject();
@@ -141,7 +148,7 @@ public class PolicyComponent extends ExternalComponent {
JsonObject pdpSubGroupNode = new JsonObject();
subPdpArray.add(pdpSubGroupNode);
pdpSubGroupNode.addProperty("pdpType", pdpSubGroupInfo.getKey());
- pdpSubGroupNode.addProperty("action", "POST");
+ pdpSubGroupNode.addProperty("action", action);
JsonArray policyArray = new JsonArray();
pdpSubGroupNode.add("policies", policyArray);
@@ -157,25 +164,6 @@ public class PolicyComponent extends ExternalComponent {
return jsonObject;
}
- /**
- * Generates the list of policy names that must be send/remove to/from active
- * PDP group.
- *
- * @return A list of policy names
- */
- public static List<String> listPolicyNamesPdpGroup(Loop loop) {
- List<String> policyNamesList = new ArrayList<>();
- for (OperationalPolicy opPolicy : loop.getOperationalPolicies()) {
- policyNamesList.add(opPolicy.getName());
- policyNamesList.addAll(opPolicy.createGuardPolicyPayloads().keySet());
- }
- for (MicroServicePolicy microServicePolicy : loop.getMicroServicePolicies()) {
- policyNamesList.add(microServicePolicy.getName());
- }
- logger.info("Policies that will be removed from PDP: " + policyNamesList);
- return policyNamesList;
- }
-
private static ExternalComponentState findNewState(boolean found, boolean deployed) {
ExternalComponentState newState = NOT_SENT;
diff --git a/src/main/java/org/onap/clamp/policy/Policy.java b/src/main/java/org/onap/clamp/policy/Policy.java
index d84f2c8a0..65e88d182 100644
--- a/src/main/java/org/onap/clamp/policy/Policy.java
+++ b/src/main/java/org/onap/clamp/policy/Policy.java
@@ -284,4 +284,6 @@ public abstract class Policy extends AuditEntity {
.append(blueprintFilename.replaceAll(".yaml", ""));
return buffer.toString().replace('.', '_').replaceAll(" ", "");
}
+
+ public abstract Boolean isLegacy();
}
diff --git a/src/main/java/org/onap/clamp/policy/microservice/MicroServicePolicy.java b/src/main/java/org/onap/clamp/policy/microservice/MicroServicePolicy.java
index 77627a31a..127f495cc 100644
--- a/src/main/java/org/onap/clamp/policy/microservice/MicroServicePolicy.java
+++ b/src/main/java/org/onap/clamp/policy/microservice/MicroServicePolicy.java
@@ -157,6 +157,11 @@ public class MicroServicePolicy extends Policy implements Serializable {
this.getPolicyModel().getPolicyModelType(), serviceModel));
}
+ @Override
+ public Boolean isLegacy() {
+ return false;
+ }
+
public Boolean getShared() {
return shared;
}
diff --git a/src/main/java/org/onap/clamp/policy/microservice/MicroServicePolicyService.java b/src/main/java/org/onap/clamp/policy/microservice/MicroServicePolicyService.java
index 37533c1f6..060e79a63 100644
--- a/src/main/java/org/onap/clamp/policy/microservice/MicroServicePolicyService.java
+++ b/src/main/java/org/onap/clamp/policy/microservice/MicroServicePolicyService.java
@@ -91,7 +91,7 @@ public class MicroServicePolicyService implements PolicyService<MicroServicePoli
String deploymentUrl) {
microServicePolicy.setDcaeDeploymentId(deploymentId);
microServicePolicy.setDcaeDeploymentStatusUrl(deploymentUrl);
- microServiceRepository.save(microServicePolicy);
+ microServiceRepository.saveAndFlush(microServicePolicy);
}
diff --git a/src/main/java/org/onap/clamp/policy/operational/LegacyOperationalPolicy.java b/src/main/java/org/onap/clamp/policy/operational/LegacyOperationalPolicy.java
index 033f2cebb..3765277d8 100644
--- a/src/main/java/org/onap/clamp/policy/operational/LegacyOperationalPolicy.java
+++ b/src/main/java/org/onap/clamp/policy/operational/LegacyOperationalPolicy.java
@@ -201,11 +201,13 @@ public class LegacyOperationalPolicy {
policy.getAsJsonObject().remove(ACTOR);
String actorStr = actor.getAsJsonObject().get(ACTOR).getAsString();
policy.getAsJsonObject().addProperty(ACTOR, actorStr);
- policy.getAsJsonObject().addProperty(RECIPE, getRecipe(actor));
if ("CDS".equalsIgnoreCase(actorStr)) {
- addPayloadAttributes(actor.getAsJsonObject(ACTOR).getAsJsonObject(RECIPE), policy);
+ policy.getAsJsonObject().addProperty(RECIPE, getRecipe(actor));
+ addCdsPayloadAttributes(actor.getAsJsonObject(RECIPE), policy);
} else {
+ policy.getAsJsonObject().addProperty(RECIPE,
+ actor.getAsJsonObject().get(RECIPE).getAsString());
addPayloadAttributes(actor, policy);
}
}
@@ -226,7 +228,20 @@ public class LegacyOperationalPolicy {
}
}
+ private static void addCdsPayloadAttributes(JsonObject jsonObject,
+ JsonElement policy) {
+ JsonElement payloadElem = jsonObject.getAsJsonObject().get(PAYLOAD);
+ JsonObject payloadObject = payloadElem != null ?
+ payloadElem.getAsJsonObject() : null;
+ if (payloadObject != null) {
+ policy.getAsJsonObject().add(PAYLOAD,
+ payloadObject);
+ } else {
+ policy.getAsJsonObject().addProperty(PAYLOAD, "");
+ }
+ }
+
private static String getRecipe(JsonObject actor) {
- return actor.getAsJsonObject().get("type").getAsString();
+ return actor.getAsJsonObject().get("recipe").getAsJsonObject().get("recipe").getAsString();
}
}
diff --git a/src/main/java/org/onap/clamp/policy/operational/OperationalPolicyRepresentationBuilder.java b/src/main/java/org/onap/clamp/policy/operational/OperationalPolicyRepresentationBuilder.java
index 44ee11970..4e362d841 100644
--- a/src/main/java/org/onap/clamp/policy/operational/OperationalPolicyRepresentationBuilder.java
+++ b/src/main/java/org/onap/clamp/policy/operational/OperationalPolicyRepresentationBuilder.java
@@ -24,13 +24,17 @@
package org.onap.clamp.policy.operational;
+import static org.onap.clamp.clds.tosca.update.execution.cds.ToscaMetadataCdsProcess.createInputPropertiesForPayload;
+
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;
+
import java.io.IOException;
import java.util.Map.Entry;
+
import org.onap.clamp.clds.util.JsonUtils;
import org.onap.clamp.clds.util.ResourceFileUtil;
import org.onap.clamp.loop.service.Service;
@@ -70,7 +74,7 @@ public class OperationalPolicyRepresentationBuilder {
for (JsonElement actor : actors) {
if ("CDS".equalsIgnoreCase(actor.getAsJsonObject().get("title").getAsString())) {
- actor.getAsJsonObject().get("properties").getAsJsonObject().get("type").getAsJsonObject()
+ actor.getAsJsonObject().get("properties").getAsJsonObject().get("recipe").getAsJsonObject()
.get("anyOf").getAsJsonArray()
.addAll(createAnyOfArrayForCdsRecipe(modelJson));
}
@@ -195,8 +199,9 @@ public class OperationalPolicyRepresentationBuilder {
for (Entry<String, JsonElement> workflowsEntry : workflows.entrySet()) {
JsonObject obj = new JsonObject();
obj.addProperty("title", workflowsEntry.getKey());
+ obj.addProperty("type", "object");
obj.add("properties", createPayloadProperty(workflowsEntry.getValue().getAsJsonObject(),
- controllerProperties));
+ controllerProperties, workflowsEntry.getKey()));
schemaArray.add(obj);
}
@@ -205,26 +210,27 @@ public class OperationalPolicyRepresentationBuilder {
return schemaArray;
}
- private static JsonObject createPayloadProperty(JsonObject workFlow, JsonObject controllerProperties) {
- JsonObject type = new JsonObject();
- type.addProperty("title", "Payload (YAML)");
- type.addProperty("type", "string");
- type.addProperty("default", createDefaultStringForPayload(workFlow, controllerProperties));
- type.addProperty("format", "textarea");
+ private static JsonObject createPayloadProperty(JsonObject workFlow,
+ JsonObject controllerProperties, String workFlowName) {
+ JsonObject payload = new JsonObject();
+ payload.addProperty("title", "Payload (YAML)");
+ payload.addProperty("type", "object");
+ payload.add("properties", createInputPropertiesForPayload(workFlow,
+ controllerProperties));
JsonObject properties = new JsonObject();
- properties.add("type", type);
+ properties.add("recipe", createRecipeForCdsWorkflow(workFlowName));
+ properties.add("payload", payload);
return properties;
}
- private static String createDefaultStringForPayload(JsonObject workFlow, JsonObject controllerProperties) {
- String artifactName = controllerProperties.get("sdnc_model_name").toString();
- String artifactVersion = controllerProperties.get("sdnc_model_version").toString();
- String data = workFlow.getAsJsonObject("inputs").toString();
- StringBuilder builder = new StringBuilder("'").append("artifact_name : ").append(artifactName).append("\n")
- .append("artifact_version : ").append(artifactVersion).append("\n")
- .append("mode : async").append("\n")
- .append("data : ").append("'").append("\\").append("'").append(data).append("\\").append("'")
- .append("'");
- return builder.toString();
+ private static JsonObject createRecipeForCdsWorkflow(String workflow) {
+ JsonObject recipe = new JsonObject();
+ recipe.addProperty("title", "recipe");
+ recipe.addProperty("type", "string");
+ recipe.addProperty("default", workflow);
+ JsonObject options = new JsonObject();
+ options.addProperty("hidden", true);
+ recipe.add("options", options);
+ return recipe;
}
}
diff --git a/src/main/resources/clds/camel/rest/clamp-api-v2.xml b/src/main/resources/clds/camel/rest/clamp-api-v2.xml
index e6741d6f8..879c9b707 100644
--- a/src/main/resources/clds/camel/rest/clamp-api-v2.xml
+++ b/src/main/resources/clds/camel/rest/clamp-api-v2.xml
@@ -605,48 +605,62 @@
uri="bean:org.onap.clamp.loop.log.LoopLogService?method=addLog('DELETE request','INFO',${exchangeProperty[loopObject]})" />
<to uri="direct:undeploy-loop" />
<to uri="direct:remove-all-policy-from-active-pdp-group" />
+ <log loggingLevel="INFO"
+ message="Deleting all MICRO-SERVICES policies defined in loop ${exchangeProperty[loopObject].getName()}" />
<split>
<simple>${exchangeProperty[loopObject].getMicroServicePolicies()}
</simple>
- <setProperty propertyName="microServicePolicy">
+ <setProperty propertyName="policy">
<simple>${body}</simple>
</setProperty>
<log loggingLevel="INFO"
- message="Processing Micro Service Policy: ${exchangeProperty[microServicePolicy].getName()}" />
- <to uri="direct:delete-micro-service-policy" />
+ message="Deleting Micro Service Policy: ${exchangeProperty[policy].getName()}" />
+ <setProperty propertyName="raiseHttpExceptionFlag">
+ <simple resultType="java.lang.Boolean">false</simple>
+ </setProperty>
+ <to uri="direct:delete-policy" />
</split>
-
<log loggingLevel="INFO"
- message="Processing all OPERATIONAL policies defined in loop ${exchangeProperty[loopObject].getName()}" />
+ message="Deleting all OPERATIONAL policies defined in loop ${exchangeProperty[loopObject].getName()}" />
<split>
<simple>${exchangeProperty[loopObject].getOperationalPolicies()}
</simple>
- <setProperty propertyName="operationalPolicy">
+ <setProperty propertyName="policy">
<simple>${body}</simple>
</setProperty>
<log loggingLevel="INFO"
- message="Processing Operational Policy: ${exchangeProperty[operationalPolicy].getName()}" />
- <to uri="direct:delete-operational-policy" />
- <log loggingLevel="INFO"
- message="Processing all GUARD policies defined in loop ${exchangeProperty[loopObject].getName()}" />
- <split>
- <simple>${exchangeProperty[operationalPolicy].createGuardPolicyPayloads().entrySet()}
- </simple>
- <setProperty propertyName="guardPolicy">
- <simple>${body}</simple>
- </setProperty>
- <log loggingLevel="INFO"
- message="Processing Guard Policy: ${exchangeProperty[guardPolicy].getKey()}" />
- <to uri="direct:delete-guard-policy" />
- </split>
+ message="Deleting Operational Policy: ${exchangeProperty[policy].getName()}" />
+ <setProperty propertyName="raiseHttpExceptionFlag">
+ <simple resultType="java.lang.Boolean">false</simple>
+ </setProperty>
+ <to uri="direct:delete-policy" />
+ <choice>
+ <when>
+ <simple>${exchangeProperty['policy'].isLegacy()} == true
+ </simple>
+ <log loggingLevel="INFO"
+ message="Deleting all GUARD policies (LEGACY) defined in loop ${exchangeProperty[loopObject].getName()}" />
+ <split>
+ <simple>${exchangeProperty[operationalPolicy].createGuardPolicyPayloads().entrySet()}
+ </simple>
+ <setProperty propertyName="guardPolicy">
+ <simple>${body}</simple>
+ </setProperty>
+ <log loggingLevel="INFO"
+ message="Deleting Guard Policy: ${exchangeProperty[guardPolicy].getKey()}" />
+ <setProperty propertyName="raiseHttpExceptionFlag">
+ <simple resultType="java.lang.Boolean">false</simple>
+ </setProperty>
+ <to uri="direct:delete-guard-policy" />
+ </split>
+ </when>
+ </choice>
</split>
<to
- uri="bean:org.onap.clamp.loop.log.LoopController?method=deleteLoop(${header.loopName})" />
+ uri="bean:org.onap.clamp.loop.LoopController?method=deleteLoop(${header.loopName})" />
<log loggingLevel="INFO"
message="DELETE request successfully executed for loop: ${header.loopName}" />
<to
- uri="bean:org.onap.clamp.loop.log.LoopLogService?method=addLog('DELETE request successfully executed','INFO',${exchangeProperty[loopObject]})" />
- <to
uri="bean:org.onap.clamp.flow.log.FlowLogOperation?method=endLog()" />
<doCatch>
<exception>java.lang.Exception</exception>
@@ -683,16 +697,14 @@
<to uri="direct:load-loop" />
<to
uri="bean:org.onap.clamp.loop.log.LoopLogService?method=addLog('GET STATUS request','INFO',${exchangeProperty[loopObject]})" />
- <doTry>
- <to uri="direct:update-policy-status-for-loop" />
- <to uri="direct:update-dcae-status-for-loop" />
- <to uri="direct:update-loop-state" />
+ <to uri="direct:update-policy-status-for-loop" />
+ <to uri="direct:update-dcae-status-for-loop" />
+ <to uri="direct:update-loop-state" />
- <to
+ <to
uri="bean:org.onap.clamp.loop.log.LoopLogService?method=addLog('GET STATUS request successfully executed','INFO',${exchangeProperty[loopObject]})" />
- <to
+ <to
uri="bean:org.onap.clamp.flow.log.FlowLogOperation?method=endLog()" />
- </doTry>
<doCatch>
<exception>java.lang.Exception</exception>
<handled>
@@ -704,17 +716,14 @@
message="GET STATUS request FAILED for loop: ${header.loopName}, ${exception.stacktrace}" />
<to
uri="bean:org.onap.clamp.loop.log.LoopLogService?method=addLog('GET STATUS request failed, Error reported: ${exception} - Body: ${exception.responseBody}','ERROR',${exchangeProperty[loopObject]})" />
- <setHeader headerName="CamelHttpResponseCode">
- <constant>500</constant>
- </setHeader>
- <setBody>
- <simple>GET STATUS request FAILED</simple>
- </setBody>
</doCatch>
<doFinally>
<setBody>
<simple>${exchangeProperty[loopObject]}</simple>
</setBody>
+ <setHeader headerName="CamelHttpResponseCode">
+ <constant>200</constant>
+ </setHeader>
</doFinally>
</doTry>
</route>
@@ -756,15 +765,29 @@
</doTry>
</route>
</put>
- <put uri="/v2/loop/removeOperationaPolicy/{loopName}/policyModel/{policyType}/{policyVersion}" outType="org.onap.clamp.loop.Loop" produces="application/json">
+ <put uri="/v2/loop/removeOperationaPolicy/{loopName}/policyModel/{policyType}/{policyVersion}/{policyName}" outType="org.onap.clamp.loop.Loop" produces="application/json">
<route>
- <removeHeaders pattern="*" excludePattern="loopName|policyType|policyVersion" />
+ <removeHeaders pattern="*" excludePattern="loopName|policyType|policyVersion|policyName" />
<doTry>
<to
uri="bean:org.onap.clamp.flow.log.FlowLogOperation?method=startLog(*, 'REMOVE operational Policy')" />
<to
uri="bean:org.onap.clamp.authorization.AuthorizationController?method=authorize(*,'cl','','update')" />
<to uri="direct:load-loop" />
+ <setProperty propertyName="policyName">
+ <simple>${header.policyName}</simple>
+ </setProperty>
+ <setProperty propertyName="policy">
+ <simple>${exchangeProperty[loopObject].getOperationalPolicy(header.policyName)}</simple>
+ </setProperty>
+ <setProperty propertyName="raiseHttpExceptionFlag">
+ <simple resultType="java.lang.Boolean">false</simple>
+ </setProperty>
+ <to uri="direct:remove-one-policy-from-active-pdp-group" />
+ <setProperty propertyName="raiseHttpExceptionFlag">
+ <simple resultType="java.lang.Boolean">false</simple>
+ </setProperty>
+ <to uri="direct:delete-policy" />
<to
uri="bean:org.onap.clamp.loop.LoopController?method=removeOperationalPolicy(${header.loopName},${header.policyType},${header.policyVersion})" />
<to
diff --git a/src/main/resources/clds/camel/routes/dcae-flows.xml b/src/main/resources/clds/camel/routes/dcae-flows.xml
index f40207cc7..e36f28abf 100644
--- a/src/main/resources/clds/camel/routes/dcae-flows.xml
+++ b/src/main/resources/clds/camel/routes/dcae-flows.xml
@@ -371,6 +371,17 @@
message="Endpoint to query Closed Loop status: ${exchangeProperty[getStatusUrl]}"></log>
<toD
uri="${exchangeProperty[getStatusUrl]}?bridgeEndpoint=true&amp;useSystemProperties=true&amp;throwExceptionOnFailure=${exchangeProperty[raiseHttpExceptionFlag]}&amp;authMethod=Basic&amp;authUsername={{clamp.config.dcae.deployment.userName}}&amp;authPassword={{clamp.config.dcae.deployment.password}}&amp;connectionTimeToLive=5000&amp;httpClient.connectTimeout=10000&amp;httpClient.socketTimeout=30000&amp;authenticationPreemptive=true&amp;connectionClose=true" />
+ <doCatch>
+ <exception>java.lang.Exception</exception>
+ <handled>
+ <constant>true</constant>
+ </handled>
+
+ <log loggingLevel="ERROR"
+ message="GET policy request FAILED for loop: ${header.loopName}, ${exception.stacktrace}" />
+ <to
+ uri="bean:org.onap.clamp.loop.log.LoopLogService?method=addLog('GET policy request failed, Error reported: ${exception.message}','ERROR',${exchangeProperty[loopObject]})" />
+ </doCatch>
<doFinally>
<to uri="direct:reset-raise-http-exception-flag" />
<to
diff --git a/src/main/resources/clds/camel/routes/loop-flows.xml b/src/main/resources/clds/camel/routes/loop-flows.xml
index 8c22743a3..2f4d9c8cf 100644
--- a/src/main/resources/clds/camel/routes/loop-flows.xml
+++ b/src/main/resources/clds/camel/routes/loop-flows.xml
@@ -40,6 +40,9 @@
<setProperty propertyName="policyType">
<simple>${body.getPolicyModel().getPolicyModelType()}</simple>
</setProperty>
+ <setProperty propertyName="policyTypeVersion">
+ <simple>${body.getPolicyModel().getVersion()}</simple>
+ </setProperty>
<setProperty propertyName="policyVersion">
<simple>1.0.0</simple>
</setProperty>
@@ -61,9 +64,22 @@
<setProperty propertyName="policyType">
<simple>${body.getPolicyModel().getPolicyModelType()}</simple>
</setProperty>
- <setProperty propertyName="policyVersion">
- <simple>1.0.0</simple>
+ <setProperty propertyName="policyTypeVersion">
+ <simple>${body.getPolicyModel().getVersion()}</simple>
</setProperty>
+ <choice>
+ <when>
+ <simple>${body.isLegacy()} == true</simple>
+ <setProperty propertyName="policyVersion">
+ <simple>1</simple>
+ </setProperty>
+ </when>
+ <otherwise>
+ <setProperty propertyName="policyVersion">
+ <simple>1.0.0</simple>
+ </setProperty>
+ </otherwise>
+ </choice>
<setProperty propertyName="operationalPolicy">
<simple>${body}</simple>
</setProperty>
@@ -84,6 +100,9 @@
<setProperty propertyName="policyType">
<simple>onap.policies.controlloop.Guard</simple>
</setProperty>
+ <setProperty propertyName="policyTypeVersion">
+ <simple>1.0.0</simple>
+ </setProperty>
<setProperty propertyName="policyVersion">
<simple>1</simple>
</setProperty>
diff --git a/src/main/resources/clds/camel/routes/policy-flows.xml b/src/main/resources/clds/camel/routes/policy-flows.xml
index a2c7a4ca3..1731308ee 100644
--- a/src/main/resources/clds/camel/routes/policy-flows.xml
+++ b/src/main/resources/clds/camel/routes/policy-flows.xml
@@ -1,717 +1,601 @@
-
<routes xmlns="http://camel.apache.org/schema/spring">
- <route id="verify-one-policy">
- <from uri="direct:verify-one-policy"/>
- <setProperty propertyName="raiseHttpExceptionFlag">
- <simple resultType="java.lang.Boolean">false</simple>
- </setProperty>
- <to uri="direct:get-policy"/>
- <when>
- <simple> ${header.CamelHttpResponseCode} != 200 </simple>
- <setProperty propertyName="policyFound">
- <simple resultType="java.lang.Boolean">false</simple>
- </setProperty>
- <log loggingLevel="WARN"
- message="At least one policy has not been found on policy engine: ${exchangeProperty[policyName]}"/>
- </when>
- <setProperty propertyName="raiseHttpExceptionFlag">
- <simple resultType="java.lang.Boolean">false</simple>
- </setProperty>
- <to uri="direct:get-deployment-policy"/>
- <when>
- <simple> ${header.CamelHttpResponseCode} != 200 </simple>
- <setProperty propertyName="policyDeployed">
- <simple resultType="java.lang.Boolean">false</simple>
- </setProperty>
- <log loggingLevel="WARN"
- message="At least one policy has not been deployed on policy engine: ${exchangeProperty[policyName]}"/>
- </when>
- <setProperty propertyName="newPolicyState">
- <simple>${exchangeProperty[policyComponent].computeState(*)}</simple>
- </setProperty>
- </route>
-
- <route id="get-policy">
- <from uri="direct:get-policy"/>
- <doTry>
- <log loggingLevel="INFO"
- message="Getting Policy: ${exchangeProperty[policyName]}"/>
- <to
- uri="bean:org.onap.clamp.flow.log.FlowLogOperation?method=invokeLog('Policy', 'Get Policy')"/>
- <setHeader headerName="CamelHttpMethod">
- <constant>GET</constant>
- </setHeader>
- <setHeader headerName="X-ONAP-RequestID">
- <simple>${exchangeProperty[X-ONAP-RequestID]}
- </simple>
- </setHeader>
- <setHeader headerName="X-ONAP-InvocationID">
- <simple>${exchangeProperty[X-ONAP-InvocationID]}
- </simple>
- </setHeader>
- <setHeader headerName="X-ONAP-PartnerName">
- <simple>${exchangeProperty[X-ONAP-PartnerName]}
- </simple>
- </setHeader>
- <log loggingLevel="INFO"
- message="Endpoint to get policy: {{clamp.config.policy.api.url}}/policy/api/v1/policytypes/${exchangeProperty[policyType]}/versions/1.0.0/policies/${exchangeProperty[policyName]}/versions/${exchangeProperty[policyVersion]}"></log>
- <toD
- uri="{{clamp.config.policy.api.url}}/policy/api/v1/policytypes/${exchangeProperty[policyType]}/versions/1.0.0/policies/${exchangeProperty[policyName]}/versions/${exchangeProperty[policyVersion]}?bridgeEndpoint=true&amp;useSystemProperties=true&amp;throwExceptionOnFailure=${exchangeProperty[raiseHttpExceptionFlag]}&amp;authMethod=Basic&amp;authUsername={{clamp.config.policy.api.userName}}&amp;authPassword={{clamp.config.policy.api.password}}&amp;connectionTimeToLive=5000&amp;httpClient.connectTimeout=10000&amp;httpClient.socketTimeout=20000&amp;authenticationPreemptive=true&amp;connectionClose=true"/>
- <doFinally>
- <to uri="direct:reset-raise-http-exception-flag"/>
- <to
- uri="bean:org.onap.clamp.flow.log.FlowLogOperation?method=invokeReturnLog()"/>
- <setProperty propertyName="logMessage">
- <simple>${exchangeProperty[policyName]} GET
- Policy status
- </simple>
- </setProperty>
- <setProperty propertyName="logComponent">
- <simple>POLICY</simple>
- </setProperty>
- <to uri="direct:dump-loop-log-http-response"/>
- </doFinally>
- </doTry>
- </route>
-
- <route id="get-deployment-policy">
- <from uri="direct:get-deployment-policy"/>
- <doTry>
- <log loggingLevel="INFO"
- message="Getting the policy deployment in PDP: ${exchangeProperty[policyName]}"/>
- <to
- uri="bean:org.onap.clamp.flow.log.FlowLogOperation?method=invokeLog('Policy', 'Getting the policy deployment in PDP')"/>
- <setHeader headerName="CamelHttpMethod">
- <constant>GET</constant>
- </setHeader>
- <setHeader headerName="X-ONAP-RequestID">
- <simple>${exchangeProperty[X-ONAP-RequestID]}
- </simple>
- </setHeader>
- <setHeader headerName="X-ONAP-InvocationID">
- <simple>${exchangeProperty[X-ONAP-InvocationID]}
- </simple>
- </setHeader>
- <setHeader headerName="X-ONAP-PartnerName">
- <simple>${exchangeProperty[X-ONAP-PartnerName]}
- </simple>
- </setHeader>
- <log loggingLevel="INFO"
- message="Endpoint to get policy deployment status: {{clamp.config.policy.pap.url}}/policy/pap/v1/policies/deployed/${exchangeProperty[policyName]}/1.0.0"></log>
- <toD
- uri="{{clamp.config.policy.pap.url}}/policy/pap/v1/policies/deployed/${exchangeProperty[policyName]}/1.0.0?bridgeEndpoint=true&amp;useSystemProperties=true&amp;throwExceptionOnFailure=${exchangeProperty[raiseHttpExceptionFlag]}&amp;authMethod=Basic&amp;authUsername={{clamp.config.policy.api.userName}}&amp;authPassword={{clamp.config.policy.api.password}}&amp;connectionTimeToLive=5000&amp;httpClient.connectTimeout=10000&amp;httpClient.socketTimeout=20000&amp;authenticationPreemptive=true&amp;connectionClose=true"/>
- <doFinally>
- <to uri="direct:reset-raise-http-exception-flag"/>
- <to
- uri="bean:org.onap.clamp.flow.log.FlowLogOperation?method=invokeReturnLog()"/>
- <setProperty propertyName="logMessage">
- <simple>${exchangeProperty[policyName]} GET Policy deployment
- status
- </simple>
- </setProperty>
- <setProperty propertyName="logComponent">
- <simple>POLICY</simple>
- </setProperty>
- <to uri="direct:dump-loop-log-http-response"/>
- </doFinally>
- </doTry>
- </route>
- <route id="get-all-policy-models">
- <from uri="direct:get-all-policy-models"/>
- <doTry>
- <log loggingLevel="INFO" message="Getting all the policy models"/>
- <to
- uri="bean:org.onap.clamp.flow.log.FlowLogOperation?method=invokeLog('Policy', 'Getting all the policy models')"/>
- <setHeader headerName="CamelHttpMethod">
- <constant>GET</constant>
- </setHeader>
- <setHeader headerName="X-ONAP-RequestID">
- <simple>${exchangeProperty[X-ONAP-RequestID]}
- </simple>
- </setHeader>
- <setHeader headerName="X-ONAP-InvocationID">
- <simple>${exchangeProperty[X-ONAP-InvocationID]}
- </simple>
- </setHeader>
- <setHeader headerName="X-ONAP-PartnerName">
- <simple>${exchangeProperty[X-ONAP-PartnerName]}
- </simple>
- </setHeader>
- <log loggingLevel="INFO"
- message="Endpoint to get all policy models: {{clamp.config.policy.api.url}}/policy/api/v1/policytypes"></log>
- <toD
- uri="{{clamp.config.policy.api.url}}/policy/api/v1/policytypes?bridgeEndpoint=true&amp;useSystemProperties=true&amp;throwExceptionOnFailure=${exchangeProperty[raiseHttpExceptionFlag]}&amp;authMethod=Basic&amp;authUsername={{clamp.config.policy.api.userName}}&amp;authPassword={{clamp.config.policy.api.password}}&amp;connectionTimeToLive=5000&amp;httpClient.connectTimeout=10000&amp;httpClient.socketTimeout=20000&amp;authenticationPreemptive=true&amp;connectionClose=true"/>
- <convertBodyTo type="java.lang.String"/>
- <doFinally>
- <to uri="direct:reset-raise-http-exception-flag"/>
- <to
- uri="bean:org.onap.clamp.flow.log.FlowLogOperation?method=invokeReturnLog()"/>
- </doFinally>
- </doTry>
- </route>
- <route id="get-policy-model">
- <from uri="direct:get-policy-model"/>
- <doTry>
- <log loggingLevel="INFO"
- message="Getting the policy model: ${exchangeProperty[policyModelName]}/${exchangeProperty[policyModelVersion]}"/>
- <to
- uri="bean:org.onap.clamp.flow.log.FlowLogOperation?method=invokeLog('Policy', 'Getting the policy model')"/>
- <setHeader headerName="CamelHttpMethod">
- <constant>GET</constant>
- </setHeader>
- <setHeader headerName="X-ONAP-RequestID">
- <simple>${exchangeProperty[X-ONAP-RequestID]}
- </simple>
- </setHeader>
- <setHeader headerName="X-ONAP-InvocationID">
- <simple>${exchangeProperty[X-ONAP-InvocationID]}
- </simple>
- </setHeader>
- <setHeader headerName="X-ONAP-PartnerName">
- <simple>${exchangeProperty[X-ONAP-PartnerName]}
- </simple>
- </setHeader>
- <log loggingLevel="INFO"
- message="Endpoint to get policy model: {{clamp.config.policy.api.url}}/policy/api/v1/policytypes/${exchangeProperty[policyModelName]}/versions/${exchangeProperty[policyModelVersion]}"></log>
- <toD
- uri="{{clamp.config.policy.api.url}}/policy/api/v1/policytypes/${exchangeProperty[policyModelName]}/versions/${exchangeProperty[policyModelVersion]}?bridgeEndpoint=true&amp;useSystemProperties=true&amp;throwExceptionOnFailure=${exchangeProperty[raiseHttpExceptionFlag]}&amp;authMethod=Basic&amp;authUsername={{clamp.config.policy.api.userName}}&amp;authPassword={{clamp.config.policy.api.password}}&amp;connectionTimeToLive=5000&amp;httpClient.connectTimeout=10000&amp;httpClient.socketTimeout=20000&amp;authenticationPreemptive=true&amp;connectionClose=true"/>
- <convertBodyTo type="java.lang.String"/>
- <doFinally>
- <to uri="direct:reset-raise-http-exception-flag"/>
- <to
- uri="bean:org.onap.clamp.flow.log.FlowLogOperation?method=invokeReturnLog()"/>
- </doFinally>
- </doTry>
- </route>
- <route id="create-policy">
- <from uri="direct:create-policy"/>
- <doTry>
- <log loggingLevel="INFO"
- message="Creating Policy: ${exchangeProperty[policy].getName()}"/>
- <to
- uri="bean:org.onap.clamp.flow.log.FlowLogOperation?method=invokeLog('Policy', 'Create Policy')"/>
- <setBody>
- <simple>${exchangeProperty[policy].createPolicyPayload()}
- </simple>
- </setBody>
- <setHeader headerName="CamelHttpMethod">
- <constant>POST</constant>
- </setHeader>
- <setHeader headerName="Content-Type">
- <constant>application/json</constant>
- </setHeader>
- <setHeader headerName="X-ONAP-RequestID">
- <simple>${exchangeProperty[X-ONAP-RequestID]}
- </simple>
- </setHeader>
- <setHeader headerName="X-ONAP-InvocationID">
- <simple>${exchangeProperty[X-ONAP-InvocationID]}
- </simple>
- </setHeader>
- <setHeader headerName="X-ONAP-PartnerName">
- <simple>${exchangeProperty[X-ONAP-PartnerName]}
- </simple>
- </setHeader>
- <log loggingLevel="INFO"
- message="Endpoint to create policy: {{clamp.config.policy.api.url}}/policy/api/v1/policytypes/${exchangeProperty[policy].getPolicyModel().getPolicyModelType()}/versions/${exchangeProperty[policy].getPolicyModel().getVersion()}/policies"></log>
- <toD
- uri="{{clamp.config.policy.api.url}}/policy/api/v1/policytypes/${exchangeProperty[policy].getPolicyModel().getPolicyModelType()}/versions/${exchangeProperty[policy].getPolicyModel().getVersion()}/policies?bridgeEndpoint=true&amp;useSystemProperties=true&amp;mapHttpMessageHeaders=false&amp;throwExceptionOnFailure=${exchangeProperty[raiseHttpExceptionFlag]}&amp;authUsername={{clamp.config.policy.api.userName}}&amp;authPassword={{clamp.config.policy.api.password}}&amp;connectionTimeToLive=5000&amp;httpClient.connectTimeout=10000&amp;httpClient.socketTimeout=20000&amp;authenticationPreemptive=true&amp;connectionClose=true"/>
- <doFinally>
- <to uri="direct:reset-raise-http-exception-flag"/>
- <to
- uri="bean:org.onap.clamp.flow.log.FlowLogOperation?method=invokeReturnLog()"/>
- <setProperty propertyName="logMessage">
- <simple>${exchangeProperty[policy].getName()} creation
- status
- </simple>
- </setProperty>
- <setProperty propertyName="logComponent">
- <simple>POLICY</simple>
- </setProperty>
- <to uri="direct:dump-loop-log-http-response"/>
- </doFinally>
- </doTry>
- </route>
+ <route id="verify-one-policy">
+ <from uri="direct:verify-one-policy"/>
+ <setProperty propertyName="raiseHttpExceptionFlag">
+ <simple resultType="java.lang.Boolean">false</simple>
+ </setProperty>
+ <to uri="direct:get-policy"/>
+ <when>
+ <simple>${header.CamelHttpResponseCode} != 200</simple>
+ <setProperty propertyName="policyFound">
+ <simple resultType="java.lang.Boolean">false</simple>
+ </setProperty>
+ <log loggingLevel="WARN"
+ message="At least one policy has not been found on policy engine: ${exchangeProperty[policyName]}"/>
+ </when>
+ <setProperty propertyName="raiseHttpExceptionFlag">
+ <simple resultType="java.lang.Boolean">false</simple>
+ </setProperty>
+ <to uri="direct:get-deployment-policy"/>
+ <when>
+ <simple>${header.CamelHttpResponseCode} != 200</simple>
+ <setProperty propertyName="policyDeployed">
+ <simple resultType="java.lang.Boolean">false</simple>
+ </setProperty>
+ <log loggingLevel="WARN"
+ message="At least one policy has not been deployed on policy engine: ${exchangeProperty[policyName]}"/>
+ </when>
+ <setProperty propertyName="newPolicyState">
+ <simple>${exchangeProperty[policyComponent].computeState(*)}</simple>
+ </setProperty>
+ </route>
- <route id="delete-policy">
- <from uri="direct:delete-policy"/>
- <doTry>
- <log loggingLevel="INFO"
- message="Deleting Policy: ${exchangeProperty[policy].getName()}"/>
- <to
- uri="bean:org.onap.clamp.flow.log.FlowLogOperation?method=invokeLog('Policy', 'Delete Policy')"/>
- <setBody>
- <constant>null</constant>
- </setBody>
- <setHeader headerName="CamelHttpMethod">
- <constant>DELETE</constant>
- </setHeader>
- <setHeader headerName="X-ONAP-RequestID">
- <simple>${exchangeProperty[X-ONAP-RequestID]}
- </simple>
- </setHeader>
- <setHeader headerName="X-ONAP-InvocationID">
- <simple>${exchangeProperty[X-ONAP-InvocationID]}
- </simple>
- </setHeader>
- <setHeader headerName="X-ONAP-PartnerName">
- <simple>${exchangeProperty[X-ONAP-PartnerName]}
- </simple>
- </setHeader>
- <log loggingLevel="INFO"
- message="Endpoint to delete microservice policy: {{clamp.config.policy.api.url}}/policy/api/v1/policytypes/${exchangeProperty[policy].getPolicyModel().getPolicyModelType()}/versions/${exchangeProperty[policy].getPolicyModel().getVersion()}/policies/${exchangeProperty[policy].getName()}/versions/1.0.0"></log>
- <toD
- uri="{{clamp.config.policy.api.url}}/policy/api/v1/policytypes/${exchangeProperty[policy].getPolicyModel().getPolicyModelType()}/versions/${exchangeProperty[policy].getPolicyModel().getVersion()}/policies/${exchangeProperty[policy].getName()}/versions/1.0.0?bridgeEndpoint=true&amp;useSystemProperties=true&amp;mapHttpMessageHeaders=false&amp;throwExceptionOnFailure=${exchangeProperty[raiseHttpExceptionFlag]}&amp;deleteWithBody=false&amp;mapHttpMessageBody=false&amp;mapHttpMessageFormUrlEncodedBody=false&amp;authUsername={{clamp.config.policy.api.userName}}&amp;authPassword={{clamp.config.policy.api.password}}&amp;connectionTimeToLive=5000&amp;httpClient.connectTimeout=10000&amp;httpClient.socketTimeout=20000&amp;authenticationPreemptive=true&amp;connectionClose=true"/>
+ <route id="get-policy">
+ <from uri="direct:get-policy"/>
+ <doTry>
+ <log loggingLevel="INFO"
+ message="Getting Policy: ${exchangeProperty[policyName]}"/>
+ <to
+ uri="bean:org.onap.clamp.flow.log.FlowLogOperation?method=invokeLog('Policy', 'Get Policy')"/>
+ <setHeader headerName="CamelHttpMethod">
+ <constant>GET</constant>
+ </setHeader>
+ <setHeader headerName="X-ONAP-RequestID">
+ <simple>${exchangeProperty[X-ONAP-RequestID]}
+ </simple>
+ </setHeader>
+ <setHeader headerName="X-ONAP-InvocationID">
+ <simple>${exchangeProperty[X-ONAP-InvocationID]}
+ </simple>
+ </setHeader>
+ <setHeader headerName="X-ONAP-PartnerName">
+ <simple>${exchangeProperty[X-ONAP-PartnerName]}
+ </simple>
+ </setHeader>
+ <log loggingLevel="INFO"
+ message="Endpoint to get policy: {{clamp.config.policy.api.url}}/policy/api/v1/policytypes/${exchangeProperty[policyType]}/versions/${exchangeProperty[policyTypeVersion]}/policies/${exchangeProperty[policyName]}/versions/${exchangeProperty[policyVersion]}"></log>
+ <toD
+ uri="{{clamp.config.policy.api.url}}/policy/api/v1/policytypes/${exchangeProperty[policyType]}/versions/${exchangeProperty[policyTypeVersion]}/policies/${exchangeProperty[policyName]}/versions/${exchangeProperty[policyVersion]}?bridgeEndpoint=true&amp;useSystemProperties=true&amp;throwExceptionOnFailure=${exchangeProperty[raiseHttpExceptionFlag]}&amp;authMethod=Basic&amp;authUsername={{clamp.config.policy.api.userName}}&amp;authPassword={{clamp.config.policy.api.password}}&amp;connectionTimeToLive=5000&amp;httpClient.connectTimeout=10000&amp;httpClient.socketTimeout=20000&amp;authenticationPreemptive=true&amp;connectionClose=true"/>
+ <doCatch>
+ <exception>java.lang.Exception</exception>
+ <handled>
+ <constant>true</constant>
+ </handled>
- <doFinally>
- <to uri="direct:reset-raise-http-exception-flag"/>
- <to
- uri="bean:org.onap.clamp.flow.log.FlowLogOperation?method=invokeReturnLog()"/>
- <setProperty propertyName="logMessage">
- <simple>${exchangeProperty[policy].getName()} removal
- status
- </simple>
- </setProperty>
- <setProperty propertyName="logComponent">
- <simple>POLICY</simple>
- </setProperty>
- <to uri="direct:dump-loop-log-http-response"/>
- </doFinally>
- </doTry>
- </route>
- <route id="create-micro-service-policy">
- <from uri="direct:create-micro-service-policy"/>
- <doTry>
- <log loggingLevel="INFO"
- message="Creating Micro Service Policy: ${exchangeProperty[microServicePolicy].getName()}"/>
- <to
- uri="bean:org.onap.clamp.flow.log.FlowLogOperation?method=invokeLog('Policy', 'Create Micro Service Policy')"/>
- <setBody>
- <simple>${exchangeProperty[microServicePolicy].createPolicyPayload()}
- </simple>
- </setBody>
- <setHeader headerName="CamelHttpMethod">
- <constant>POST</constant>
- </setHeader>
- <setHeader headerName="Content-Type">
- <constant>application/json</constant>
- </setHeader>
- <setHeader headerName="X-ONAP-RequestID">
- <simple>${exchangeProperty[X-ONAP-RequestID]}
- </simple>
- </setHeader>
- <setHeader headerName="X-ONAP-InvocationID">
- <simple>${exchangeProperty[X-ONAP-InvocationID]}
- </simple>
- </setHeader>
- <setHeader headerName="X-ONAP-PartnerName">
- <simple>${exchangeProperty[X-ONAP-PartnerName]}
- </simple>
- </setHeader>
- <log loggingLevel="INFO"
- message="Endpoint to create microservice policy: {{clamp.config.policy.api.url}}/policy/api/v1/policytypes/${exchangeProperty[microServicePolicy].getPolicyModel().getPolicyModelType()}/versions/1.0.0/policies"></log>
- <toD
- uri="{{clamp.config.policy.api.url}}/policy/api/v1/policytypes/${exchangeProperty[microServicePolicy].getPolicyModel().getPolicyModelType()}/versions/1.0.0/policies?bridgeEndpoint=true&amp;useSystemProperties=true&amp;mapHttpMessageHeaders=false&amp;throwExceptionOnFailure=${exchangeProperty[raiseHttpExceptionFlag]}&amp;authUsername={{clamp.config.policy.api.userName}}&amp;authPassword={{clamp.config.policy.api.password}}&amp;connectionTimeToLive=5000&amp;httpClient.connectTimeout=10000&amp;httpClient.socketTimeout=20000&amp;authenticationPreemptive=true&amp;connectionClose=true"/>
- <doFinally>
- <to uri="direct:reset-raise-http-exception-flag"/>
- <to
- uri="bean:org.onap.clamp.flow.log.FlowLogOperation?method=invokeReturnLog()"/>
- <setProperty propertyName="logMessage">
- <simple>${exchangeProperty[microServicePolicy].getName()} creation
- status
- </simple>
- </setProperty>
- <setProperty propertyName="logComponent">
- <simple>POLICY</simple>
- </setProperty>
- <to uri="direct:dump-loop-log-http-response"/>
- </doFinally>
- </doTry>
- </route>
+ <log loggingLevel="ERROR"
+ message="GET policy request FAILED for loop: ${header.loopName}, ${exception.stacktrace}" />
+ <to
+ uri="bean:org.onap.clamp.loop.log.LoopLogService?method=addLog('GET policy request failed, Error reported: ${exception.message}','ERROR',${exchangeProperty[loopObject]})" />
+ </doCatch>
+ <doFinally>
+ <to uri="direct:reset-raise-http-exception-flag"/>
+ <to
+ uri="bean:org.onap.clamp.flow.log.FlowLogOperation?method=invokeReturnLog()"/>
+ <setProperty propertyName="logMessage">
+ <simple>${exchangeProperty[policyName]} GET
+ Policy status
+ </simple>
+ </setProperty>
+ <setProperty propertyName="logComponent">
+ <simple>POLICY</simple>
+ </setProperty>
+ <to uri="direct:dump-loop-log-http-response"/>
+ </doFinally>
+ </doTry>
+ </route>
- <route id="delete-micro-service-policy">
- <from uri="direct:delete-micro-service-policy"/>
- <doTry>
- <log loggingLevel="INFO"
- message="Deleting Micro Service Policy: ${exchangeProperty[microServicePolicy].getName()}"/>
- <to
- uri="bean:org.onap.clamp.flow.log.FlowLogOperation?method=invokeLog('Policy', 'Delete Micro Service Policy')"/>
- <setBody>
- <constant>null</constant>
- </setBody>
- <setHeader headerName="CamelHttpMethod">
- <constant>DELETE</constant>
- </setHeader>
- <setHeader headerName="X-ONAP-RequestID">
- <simple>${exchangeProperty[X-ONAP-RequestID]}
- </simple>
- </setHeader>
- <setHeader headerName="X-ONAP-InvocationID">
- <simple>${exchangeProperty[X-ONAP-InvocationID]}
- </simple>
- </setHeader>
- <setHeader headerName="X-ONAP-PartnerName">
- <simple>${exchangeProperty[X-ONAP-PartnerName]}
- </simple>
- </setHeader>
- <log loggingLevel="INFO"
- message="Endpoint to delete microservice policy: {{clamp.config.policy.api.url}}/policy/api/v1/policytypes/${exchangeProperty[microServicePolicy].getPolicyModel().getPolicyModelType()}/versions/1.0.0/policies/${exchangeProperty[microServicePolicy].getName()}/versions/1.0.0"></log>
- <toD
- uri="{{clamp.config.policy.api.url}}/policy/api/v1/policytypes/${exchangeProperty[microServicePolicy].getPolicyModel().getPolicyModelType()}/versions/1.0.0/policies/${exchangeProperty[microServicePolicy].getName()}/versions/1.0.0?bridgeEndpoint=true&amp;useSystemProperties=true&amp;mapHttpMessageHeaders=false&amp;throwExceptionOnFailure=${exchangeProperty[raiseHttpExceptionFlag]}&amp;deleteWithBody=false&amp;mapHttpMessageBody=false&amp;mapHttpMessageFormUrlEncodedBody=false&amp;authUsername={{clamp.config.policy.api.userName}}&amp;authPassword={{clamp.config.policy.api.password}}&amp;connectionTimeToLive=5000&amp;httpClient.connectTimeout=10000&amp;httpClient.socketTimeout=20000&amp;authenticationPreemptive=true&amp;connectionClose=true"/>
+ <route id="get-deployment-policy">
+ <from uri="direct:get-deployment-policy"/>
+ <doTry>
+ <log loggingLevel="INFO"
+ message="Getting the policy deployment in PDP: ${exchangeProperty[policyName]}"/>
+ <to
+ uri="bean:org.onap.clamp.flow.log.FlowLogOperation?method=invokeLog('Policy', 'Getting the policy deployment in PDP')"/>
+ <setHeader headerName="CamelHttpMethod">
+ <constant>GET</constant>
+ </setHeader>
+ <setHeader headerName="X-ONAP-RequestID">
+ <simple>${exchangeProperty[X-ONAP-RequestID]}
+ </simple>
+ </setHeader>
+ <setHeader headerName="X-ONAP-InvocationID">
+ <simple>${exchangeProperty[X-ONAP-InvocationID]}
+ </simple>
+ </setHeader>
+ <setHeader headerName="X-ONAP-PartnerName">
+ <simple>${exchangeProperty[X-ONAP-PartnerName]}
+ </simple>
+ </setHeader>
+ <log loggingLevel="INFO"
+ message="Endpoint to get policy deployment status: {{clamp.config.policy.pap.url}}/policy/pap/v1/policies/deployed/${exchangeProperty[policyName]}/1.0.0"></log>
+ <toD
+ uri="{{clamp.config.policy.pap.url}}/policy/pap/v1/policies/deployed/${exchangeProperty[policyName]}/1.0.0?bridgeEndpoint=true&amp;useSystemProperties=true&amp;throwExceptionOnFailure=${exchangeProperty[raiseHttpExceptionFlag]}&amp;authMethod=Basic&amp;authUsername={{clamp.config.policy.api.userName}}&amp;authPassword={{clamp.config.policy.api.password}}&amp;connectionTimeToLive=5000&amp;httpClient.connectTimeout=10000&amp;httpClient.socketTimeout=20000&amp;authenticationPreemptive=true&amp;connectionClose=true"/>
+ <doCatch>
+ <exception>java.lang.Exception</exception>
+ <handled>
+ <constant>true</constant>
+ </handled>
- <doFinally>
- <to uri="direct:reset-raise-http-exception-flag"/>
- <to
- uri="bean:org.onap.clamp.flow.log.FlowLogOperation?method=invokeReturnLog()"/>
- <setProperty propertyName="logMessage">
- <simple>${exchangeProperty[microServicePolicy].getName()} removal
- status
- </simple>
- </setProperty>
- <setProperty propertyName="logComponent">
- <simple>POLICY</simple>
- </setProperty>
- <to uri="direct:dump-loop-log-http-response"/>
- </doFinally>
- </doTry>
- </route>
+ <log loggingLevel="ERROR"
+ message="GET policy request FAILED for loop: ${header.loopName}, ${exception.stacktrace}" />
+ <to
+ uri="bean:org.onap.clamp.loop.log.LoopLogService?method=addLog('GET policy request failed, Error reported: ${exception.message}','ERROR',${exchangeProperty[loopObject]})" />
+ </doCatch>
+ <doFinally>
+ <to uri="direct:reset-raise-http-exception-flag"/>
+ <to
+ uri="bean:org.onap.clamp.flow.log.FlowLogOperation?method=invokeReturnLog()"/>
+ <setProperty propertyName="logMessage">
+ <simple>${exchangeProperty[policyName]} GET Policy deployment
+ status
+ </simple>
+ </setProperty>
+ <setProperty propertyName="logComponent">
+ <simple>POLICY</simple>
+ </setProperty>
+ <to uri="direct:dump-loop-log-http-response"/>
+ </doFinally>
+ </doTry>
+ </route>
+ <route id="get-all-policy-models">
+ <from uri="direct:get-all-policy-models"/>
+ <doTry>
+ <log loggingLevel="INFO" message="Getting all the policy models"/>
+ <to
+ uri="bean:org.onap.clamp.flow.log.FlowLogOperation?method=invokeLog('Policy', 'Getting all the policy models')"/>
+ <setHeader headerName="CamelHttpMethod">
+ <constant>GET</constant>
+ </setHeader>
+ <setHeader headerName="X-ONAP-RequestID">
+ <simple>${exchangeProperty[X-ONAP-RequestID]}
+ </simple>
+ </setHeader>
+ <setHeader headerName="X-ONAP-InvocationID">
+ <simple>${exchangeProperty[X-ONAP-InvocationID]}
+ </simple>
+ </setHeader>
+ <setHeader headerName="X-ONAP-PartnerName">
+ <simple>${exchangeProperty[X-ONAP-PartnerName]}
+ </simple>
+ </setHeader>
+ <log loggingLevel="INFO"
+ message="Endpoint to get all policy models: {{clamp.config.policy.api.url}}/policy/api/v1/policytypes"></log>
+ <toD
+ uri="{{clamp.config.policy.api.url}}/policy/api/v1/policytypes?bridgeEndpoint=true&amp;useSystemProperties=true&amp;throwExceptionOnFailure=${exchangeProperty[raiseHttpExceptionFlag]}&amp;authMethod=Basic&amp;authUsername={{clamp.config.policy.api.userName}}&amp;authPassword={{clamp.config.policy.api.password}}&amp;connectionTimeToLive=5000&amp;httpClient.connectTimeout=10000&amp;httpClient.socketTimeout=20000&amp;authenticationPreemptive=true&amp;connectionClose=true"/>
+ <convertBodyTo type="java.lang.String"/>
+ <doFinally>
+ <to uri="direct:reset-raise-http-exception-flag"/>
+ <to
+ uri="bean:org.onap.clamp.flow.log.FlowLogOperation?method=invokeReturnLog()"/>
+ </doFinally>
+ </doTry>
+ </route>
+ <route id="get-policy-model">
+ <from uri="direct:get-policy-model"/>
+ <doTry>
+ <log loggingLevel="INFO"
+ message="Getting the policy model: ${exchangeProperty[policyModelName]}/${exchangeProperty[policyModelVersion]}"/>
+ <to
+ uri="bean:org.onap.clamp.flow.log.FlowLogOperation?method=invokeLog('Policy', 'Getting the policy model')"/>
+ <setHeader headerName="CamelHttpMethod">
+ <constant>GET</constant>
+ </setHeader>
+ <setHeader headerName="X-ONAP-RequestID">
+ <simple>${exchangeProperty[X-ONAP-RequestID]}
+ </simple>
+ </setHeader>
+ <setHeader headerName="X-ONAP-InvocationID">
+ <simple>${exchangeProperty[X-ONAP-InvocationID]}
+ </simple>
+ </setHeader>
+ <setHeader headerName="X-ONAP-PartnerName">
+ <simple>${exchangeProperty[X-ONAP-PartnerName]}
+ </simple>
+ </setHeader>
+ <log loggingLevel="INFO"
+ message="Endpoint to get policy model: {{clamp.config.policy.api.url}}/policy/api/v1/policytypes/${exchangeProperty[policyModelName]}/versions/${exchangeProperty[policyModelVersion]}"></log>
+ <toD
+ uri="{{clamp.config.policy.api.url}}/policy/api/v1/policytypes/${exchangeProperty[policyModelName]}/versions/${exchangeProperty[policyModelVersion]}?bridgeEndpoint=true&amp;useSystemProperties=true&amp;throwExceptionOnFailure=${exchangeProperty[raiseHttpExceptionFlag]}&amp;authMethod=Basic&amp;authUsername={{clamp.config.policy.api.userName}}&amp;authPassword={{clamp.config.policy.api.password}}&amp;connectionTimeToLive=5000&amp;httpClient.connectTimeout=10000&amp;httpClient.socketTimeout=20000&amp;authenticationPreemptive=true&amp;connectionClose=true"/>
+ <convertBodyTo type="java.lang.String"/>
+ <doFinally>
+ <to uri="direct:reset-raise-http-exception-flag"/>
+ <to
+ uri="bean:org.onap.clamp.flow.log.FlowLogOperation?method=invokeReturnLog()"/>
+ </doFinally>
+ </doTry>
+ </route>
+ <route id="create-policy">
+ <from uri="direct:create-policy"/>
+ <doTry>
+ <log loggingLevel="INFO"
+ message="Creating Policy: ${exchangeProperty[policy].getName()}"/>
+ <to
+ uri="bean:org.onap.clamp.flow.log.FlowLogOperation?method=invokeLog('Policy', 'Create Policy')"/>
+ <setBody>
+ <simple>${exchangeProperty[policy].createPolicyPayload()}
+ </simple>
+ </setBody>
+ <setHeader headerName="CamelHttpMethod">
+ <constant>POST</constant>
+ </setHeader>
+ <setHeader headerName="Content-Type">
+ <constant>application/json</constant>
+ </setHeader>
+ <setHeader headerName="X-ONAP-RequestID">
+ <simple>${exchangeProperty[X-ONAP-RequestID]}
+ </simple>
+ </setHeader>
+ <setHeader headerName="X-ONAP-InvocationID">
+ <simple>${exchangeProperty[X-ONAP-InvocationID]}
+ </simple>
+ </setHeader>
+ <setHeader headerName="X-ONAP-PartnerName">
+ <simple>${exchangeProperty[X-ONAP-PartnerName]}
+ </simple>
+ </setHeader>
+ <log loggingLevel="INFO"
+ message="Endpoint to create policy: {{clamp.config.policy.api.url}}/policy/api/v1/policytypes/${exchangeProperty[policy].getPolicyModel().getPolicyModelType()}/versions/${exchangeProperty[policy].getPolicyModel().getVersion()}/policies"></log>
+ <toD
+ uri="{{clamp.config.policy.api.url}}/policy/api/v1/policytypes/${exchangeProperty[policy].getPolicyModel().getPolicyModelType()}/versions/${exchangeProperty[policy].getPolicyModel().getVersion()}/policies?bridgeEndpoint=true&amp;useSystemProperties=true&amp;mapHttpMessageHeaders=false&amp;throwExceptionOnFailure=${exchangeProperty[raiseHttpExceptionFlag]}&amp;authUsername={{clamp.config.policy.api.userName}}&amp;authPassword={{clamp.config.policy.api.password}}&amp;connectionTimeToLive=5000&amp;httpClient.connectTimeout=10000&amp;httpClient.socketTimeout=20000&amp;authenticationPreemptive=true&amp;connectionClose=true"/>
+ <doFinally>
+ <to uri="direct:reset-raise-http-exception-flag"/>
+ <to
+ uri="bean:org.onap.clamp.flow.log.FlowLogOperation?method=invokeReturnLog()"/>
+ <setProperty propertyName="logMessage">
+ <simple>${exchangeProperty[policy].getName()} creation
+ status
+ </simple>
+ </setProperty>
+ <setProperty propertyName="logComponent">
+ <simple>POLICY</simple>
+ </setProperty>
+ <to uri="direct:dump-loop-log-http-response"/>
+ </doFinally>
+ </doTry>
+ </route>
- <route id="create-operational-policy">
- <from uri="direct:create-operational-policy"/>
- <doTry>
- <log loggingLevel="INFO"
- message="Creating Operational Policy: ${exchangeProperty[operationalPolicy].getName()}"/>
- <to
- uri="bean:org.onap.clamp.flow.log.FlowLogOperation?method=invokeLog('Policy', 'Create Operational Policy')"/>
- <setBody>
- <simple>${exchangeProperty[operationalPolicy].createPolicyPayload()}
- </simple>
- </setBody>
- <setHeader headerName="CamelHttpMethod">
- <constant>POST</constant>
- </setHeader>
- <setHeader headerName="Content-Type">
- <constant>application/json</constant>
- </setHeader>
- <setHeader headerName="X-ONAP-RequestID">
- <simple>${exchangeProperty[X-ONAP-RequestID]}
- </simple>
- </setHeader>
- <setHeader headerName="X-ONAP-InvocationID">
- <simple>${exchangeProperty[X-ONAP-InvocationID]}
- </simple>
- </setHeader>
- <setHeader headerName="X-ONAP-PartnerName">
- <simple>${exchangeProperty[X-ONAP-PartnerName]}
- </simple>
- </setHeader>
- <log loggingLevel="INFO"
- message="Endpoint to create operational policy: {{clamp.config.policy.api.url}}/policy/api/v1/policytypes/onap.policies.controlloop.Operational/versions/1.0.0/policies"></log>
- <toD
- uri="{{clamp.config.policy.api.url}}/policy/api/v1/policytypes/onap.policies.controlloop.Operational/versions/1.0.0/policies?bridgeEndpoint=true&amp;useSystemProperties=true&amp;mapHttpMessageHeaders=false&amp;throwExceptionOnFailure=${exchangeProperty[raiseHttpExceptionFlag]}&amp;authUsername={{clamp.config.policy.api.userName}}&amp;authPassword={{clamp.config.policy.api.password}}&amp;connectionTimeToLive=5000&amp;httpClient.connectTimeout=10000&amp;httpClient.socketTimeout=20000&amp;authenticationPreemptive=true&amp;connectionClose=true"/>
- <doFinally>
- <to uri="direct:reset-raise-http-exception-flag"/>
- <to
- uri="bean:org.onap.clamp.flow.log.FlowLogOperation?method=invokeReturnLog()"/>
- <setProperty propertyName="logMessage">
- <simple>${exchangeProperty[operationalPolicy].getName()} creation
- status
- </simple>
- </setProperty>
- <setProperty propertyName="logComponent">
- <simple>POLICY</simple>
- </setProperty>
- <to uri="direct:dump-loop-log-http-response"/>
- </doFinally>
- </doTry>
- </route>
+ <route id="delete-policy">
+ <from uri="direct:delete-policy"/>
+ <doTry>
+ <log loggingLevel="INFO"
+ message="Deleting Policy: ${exchangeProperty[policy].getName()}"/>
+ <to
+ uri="bean:org.onap.clamp.flow.log.FlowLogOperation?method=invokeLog('Policy', 'Delete Policy')"/>
+ <setBody>
+ <constant>null</constant>
+ </setBody>
+ <setHeader headerName="CamelHttpMethod">
+ <constant>DELETE</constant>
+ </setHeader>
+ <setHeader headerName="X-ONAP-RequestID">
+ <simple>${exchangeProperty[X-ONAP-RequestID]}
+ </simple>
+ </setHeader>
+ <setHeader headerName="X-ONAP-InvocationID">
+ <simple>${exchangeProperty[X-ONAP-InvocationID]}
+ </simple>
+ </setHeader>
+ <setHeader headerName="X-ONAP-PartnerName">
+ <simple>${exchangeProperty[X-ONAP-PartnerName]}
+ </simple>
+ </setHeader>
+ <choice>
+ <when>
+ <simple>${exchangeProperty[policy].isLegacy()} == true</simple>
+ <setProperty propertyName="policyVersion">
+ <simple>1</simple>
+ </setProperty>
+ </when>
+ <otherwise>
+ <setProperty propertyName="policyVersion">
+ <simple>1.0.0</simple>
+ </setProperty>
+ </otherwise>
+ </choice>
+ <log loggingLevel="INFO"
+ message="Endpoint to delete policy: {{clamp.config.policy.api.url}}/policy/api/v1/policytypes/${exchangeProperty[policy].getPolicyModel().getPolicyModelType()}/versions/${exchangeProperty[policy].getPolicyModel().getVersion()}/policies/${exchangeProperty[policy].getName()}/versions/${exchangeProperty[policyVersion]}"></log>
+ <toD
+ uri="{{clamp.config.policy.api.url}}/policy/api/v1/policytypes/${exchangeProperty[policy].getPolicyModel().getPolicyModelType()}/versions/${exchangeProperty[policy].getPolicyModel().getVersion()}/policies/${exchangeProperty[policy].getName()}/versions/${exchangeProperty[policyVersion]}?bridgeEndpoint=true&amp;useSystemProperties=true&amp;mapHttpMessageHeaders=false&amp;throwExceptionOnFailure=${exchangeProperty[raiseHttpExceptionFlag]}&amp;deleteWithBody=false&amp;mapHttpMessageBody=false&amp;mapHttpMessageFormUrlEncodedBody=false&amp;authUsername={{clamp.config.policy.api.userName}}&amp;authPassword={{clamp.config.policy.api.password}}&amp;connectionTimeToLive=5000&amp;httpClient.connectTimeout=10000&amp;httpClient.socketTimeout=20000&amp;authenticationPreemptive=true&amp;connectionClose=true"/>
- <route id="delete-operational-policy">
- <from uri="direct:delete-operational-policy"/>
- <doTry>
- <log loggingLevel="INFO"
- message="Deleting Operational Policy: ${exchangeProperty[operationalPolicy].getName()}"/>
- <to
- uri="bean:org.onap.clamp.flow.log.FlowLogOperation?method=invokeLog('Policy', 'Delete Operational Policy')"/>
- <setBody>
- <constant>null</constant>
- </setBody>
- <setHeader headerName="CamelHttpMethod">
- <constant>DELETE</constant>
- </setHeader>
- <setHeader headerName="X-ONAP-RequestID">
- <simple>${exchangeProperty[X-ONAP-RequestID]}
- </simple>
- </setHeader>
- <setHeader headerName="X-ONAP-InvocationID">
- <simple>${exchangeProperty[X-ONAP-InvocationID]}
- </simple>
- </setHeader>
- <setHeader headerName="X-ONAP-PartnerName">
- <simple>${exchangeProperty[X-ONAP-PartnerName]}
- </simple>
- </setHeader>
- <log loggingLevel="INFO"
- message="Endpoint to delete operational policy: {{clamp.config.policy.api.url}}/policy/api/v1/policytypes/onap.policies.controlloop.Operational/versions/1.0.0/policies/${exchangeProperty[operationalPolicy].getName()}/versions/1"></log>
- <toD
- uri="{{clamp.config.policy.api.url}}/policy/api/v1/policytypes/onap.policies.controlloop.Operational/versions/1.0.0/policies/${exchangeProperty[operationalPolicy].getName()}/versions/1?bridgeEndpoint=true&amp;useSystemProperties=true&amp;mapHttpMessageHeaders=false&amp;throwExceptionOnFailure=${exchangeProperty[raiseHttpExceptionFlag]}&amp;deleteWithBody=false&amp;mapHttpMessageBody=false&amp;mapHttpMessageFormUrlEncodedBody=false&amp;authUsername={{clamp.config.policy.api.userName}}&amp;authPassword={{clamp.config.policy.api.password}}&amp;connectionTimeToLive=5000&amp;httpClient.connectTimeout=10000&amp;httpClient.socketTimeout=20000&amp;authenticationPreemptive=true&amp;connectionClose=true"/>
- <doFinally>
- <to uri="direct:reset-raise-http-exception-flag"/>
- <to
- uri="bean:org.onap.clamp.flow.log.FlowLogOperation?method=invokeReturnLog()"/>
- <setProperty propertyName="logMessage">
- <simple>${exchangeProperty[operationalPolicy].getName()} removal
- status
- </simple>
- </setProperty>
- <setProperty propertyName="logComponent">
- <simple>POLICY</simple>
- </setProperty>
- <to uri="direct:dump-loop-log-http-response"/>
- </doFinally>
- </doTry>
- </route>
+ <doFinally>
+ <to uri="direct:reset-raise-http-exception-flag"/>
+ <to
+ uri="bean:org.onap.clamp.flow.log.FlowLogOperation?method=invokeReturnLog()"/>
+ <setProperty propertyName="logMessage">
+ <simple>${exchangeProperty[policy].getName()} removal
+ status
+ </simple>
+ </setProperty>
+ <setProperty propertyName="logComponent">
+ <simple>POLICY</simple>
+ </setProperty>
+ <to uri="direct:dump-loop-log-http-response"/>
+ </doFinally>
+ </doTry>
+ </route>
+ <route id="create-guard-policy">
+ <from uri="direct:create-guard-policy"/>
+ <doTry>
+ <log loggingLevel="INFO"
+ message="Creating Guard Policy: ${exchangeProperty[guardPolicy].getKey()}"/>
+ <to
+ uri="bean:org.onap.clamp.flow.log.FlowLogOperation?method=invokeLog('Policy', 'Create Guard Policy')"/>
+ <setBody>
+ <simple>${exchangeProperty[guardPolicy].getValue()}
+ </simple>
+ </setBody>
+ <setHeader headerName="CamelHttpMethod">
+ <constant>POST</constant>
+ </setHeader>
+ <setHeader headerName="Content-Type">
+ <constant>application/json</constant>
+ </setHeader>
+ <setHeader headerName="X-ONAP-RequestID">
+ <simple>${exchangeProperty[X-ONAP-RequestID]}
+ </simple>
+ </setHeader>
+ <setHeader headerName="X-ONAP-InvocationID">
+ <simple>${exchangeProperty[X-ONAP-InvocationID]}
+ </simple>
+ </setHeader>
+ <setHeader headerName="X-ONAP-PartnerName">
+ <simple>${exchangeProperty[X-ONAP-PartnerName]}
+ </simple>
+ </setHeader>
+ <log loggingLevel="INFO"
+ message="Endpoint to create guard policy: {{clamp.config.policy.api.url}}/policy/api/v1/policytypes/onap.policies.controlloop.Guard/versions/1.0.0/policies"></log>
+ <toD
+ uri="{{clamp.config.policy.api.url}}/policy/api/v1/policytypes/onap.policies.controlloop.Guard/versions/1.0.0/policies?bridgeEndpoint=true&amp;useSystemProperties=true&amp;mapHttpMessageHeaders=false&amp;throwExceptionOnFailure=${exchangeProperty[raiseHttpExceptionFlag]}&amp;authUsername={{clamp.config.policy.api.userName}}&amp;authPassword={{clamp.config.policy.api.password}}&amp;connectionTimeToLive=5000&amp;httpClient.connectTimeout=10000&amp;httpClient.socketTimeout=20000&amp;authenticationPreemptive=true&amp;connectionClose=true"/>
+ <doFinally>
+ <to uri="direct:reset-raise-http-exception-flag"/>
+ <to
+ uri="bean:org.onap.clamp.flow.log.FlowLogOperation?method=invokeReturnLog()"/>
+ <setProperty propertyName="logMessage">
+ <simple>${exchangeProperty[guardPolicy].getKey()} creation status
+ </simple>
+ </setProperty>
+ <setProperty propertyName="logComponent">
+ <simple>POLICY</simple>
+ </setProperty>
+ <to uri="direct:dump-loop-log-http-response"/>
+ </doFinally>
+ </doTry>
+ </route>
- <route id="create-guard-policy">
- <from uri="direct:create-guard-policy"/>
- <doTry>
- <log loggingLevel="INFO"
- message="Creating Guard Policy: ${exchangeProperty[guardPolicy].getKey()}"/>
- <to
- uri="bean:org.onap.clamp.flow.log.FlowLogOperation?method=invokeLog('Policy', 'Create Guard Policy')"/>
- <setBody>
- <simple>${exchangeProperty[guardPolicy].getValue()}
- </simple>
- </setBody>
- <setHeader headerName="CamelHttpMethod">
- <constant>POST</constant>
- </setHeader>
- <setHeader headerName="Content-Type">
- <constant>application/json</constant>
- </setHeader>
- <setHeader headerName="X-ONAP-RequestID">
- <simple>${exchangeProperty[X-ONAP-RequestID]}
- </simple>
- </setHeader>
- <setHeader headerName="X-ONAP-InvocationID">
- <simple>${exchangeProperty[X-ONAP-InvocationID]}
- </simple>
- </setHeader>
- <setHeader headerName="X-ONAP-PartnerName">
- <simple>${exchangeProperty[X-ONAP-PartnerName]}
- </simple>
- </setHeader>
- <log loggingLevel="INFO"
- message="Endpoint to create guard policy: {{clamp.config.policy.api.url}}/policy/api/v1/policytypes/onap.policies.controlloop.Guard/versions/1.0.0/policies"></log>
- <toD
- uri="{{clamp.config.policy.api.url}}/policy/api/v1/policytypes/onap.policies.controlloop.Guard/versions/1.0.0/policies?bridgeEndpoint=true&amp;useSystemProperties=true&amp;mapHttpMessageHeaders=false&amp;throwExceptionOnFailure=${exchangeProperty[raiseHttpExceptionFlag]}&amp;authUsername={{clamp.config.policy.api.userName}}&amp;authPassword={{clamp.config.policy.api.password}}&amp;connectionTimeToLive=5000&amp;httpClient.connectTimeout=10000&amp;httpClient.socketTimeout=20000&amp;authenticationPreemptive=true&amp;connectionClose=true"/>
- <doFinally>
- <to uri="direct:reset-raise-http-exception-flag"/>
- <to
- uri="bean:org.onap.clamp.flow.log.FlowLogOperation?method=invokeReturnLog()"/>
- <setProperty propertyName="logMessage">
- <simple>${exchangeProperty[guardPolicy].getKey()} creation status
- </simple>
- </setProperty>
- <setProperty propertyName="logComponent">
- <simple>POLICY</simple>
- </setProperty>
- <to uri="direct:dump-loop-log-http-response"/>
- </doFinally>
- </doTry>
- </route>
+ <route id="delete-guard-policy">
+ <from uri="direct:delete-guard-policy"/>
+ <doTry>
+ <log loggingLevel="INFO"
+ message="Deleting Guard Policy: ${exchangeProperty[guardPolicy].getKey()}"/>
+ <to
+ uri="bean:org.onap.clamp.flow.log.FlowLogOperation?method=invokeLog('Policy', 'Delete Guard Policy')"/>
+ <setBody>
+ <constant>null</constant>
+ </setBody>
+ <setHeader headerName="CamelHttpMethod">
+ <constant>DELETE</constant>
+ </setHeader>
+ <setHeader headerName="X-ONAP-RequestID">
+ <simple>${exchangeProperty[X-ONAP-RequestID]}
+ </simple>
+ </setHeader>
+ <setHeader headerName="X-ONAP-InvocationID">
+ <simple>${exchangeProperty[X-ONAP-InvocationID]}
+ </simple>
+ </setHeader>
+ <setHeader headerName="X-ONAP-PartnerName">
+ <simple>${exchangeProperty[X-ONAP-PartnerName]}
+ </simple>
+ </setHeader>
+ <log loggingLevel="INFO"
+ message="Endpoint to delete guard policy: {{clamp.config.policy.api.url}}/policy/api/v1/policytypes/onap.policies.controlloop.Guard/versions/1.0.0/policies/${exchangeProperty[guardPolicy].getKey()}/versions/1"></log>
+ <toD
+ uri="{{clamp.config.policy.api.url}}/policy/api/v1/policytypes/onap.policies.controlloop.Guard/versions/1.0.0/policies/${exchangeProperty[guardPolicy].getKey()}/versions/1?bridgeEndpoint=true&amp;useSystemProperties=true&amp;throwExceptionOnFailure=${exchangeProperty[raiseHttpExceptionFlag]}&amp;deleteWithBody=false&amp;mapHttpMessageBody=false&amp;mapHttpMessageFormUrlEncodedBody=false&amp;authUsername={{clamp.config.policy.api.userName}}&amp;authPassword={{clamp.config.policy.api.password}}&amp;connectionTimeToLive=5000&amp;httpClient.connectTimeout=10000&amp;httpClient.socketTimeout=20000&amp;authenticationPreemptive=true&amp;connectionClose=true"/>
- <route id="delete-guard-policy">
- <from uri="direct:delete-guard-policy"/>
- <doTry>
- <log loggingLevel="INFO"
- message="Deleting Guard Policy: ${exchangeProperty[guardPolicy].getKey()}"/>
- <to
- uri="bean:org.onap.clamp.flow.log.FlowLogOperation?method=invokeLog('Policy', 'Delete Guard Policy')"/>
- <setBody>
- <constant>null</constant>
- </setBody>
- <setHeader headerName="CamelHttpMethod">
- <constant>DELETE</constant>
- </setHeader>
- <setHeader headerName="X-ONAP-RequestID">
- <simple>${exchangeProperty[X-ONAP-RequestID]}
- </simple>
- </setHeader>
- <setHeader headerName="X-ONAP-InvocationID">
- <simple>${exchangeProperty[X-ONAP-InvocationID]}
- </simple>
- </setHeader>
- <setHeader headerName="X-ONAP-PartnerName">
- <simple>${exchangeProperty[X-ONAP-PartnerName]}
- </simple>
- </setHeader>
- <log loggingLevel="INFO"
- message="Endpoint to delete guard policy: {{clamp.config.policy.api.url}}/policy/api/v1/policytypes/onap.policies.controlloop.Guard/versions/1.0.0/policies/${exchangeProperty[guardPolicy].getKey()}/versions/1"></log>
- <toD
- uri="{{clamp.config.policy.api.url}}/policy/api/v1/policytypes/onap.policies.controlloop.Guard/versions/1.0.0/policies/${exchangeProperty[guardPolicy].getKey()}/versions/1?bridgeEndpoint=true&amp;useSystemProperties=true&amp;throwExceptionOnFailure=${exchangeProperty[raiseHttpExceptionFlag]}&amp;deleteWithBody=false&amp;mapHttpMessageBody=false&amp;mapHttpMessageFormUrlEncodedBody=false&amp;authUsername={{clamp.config.policy.api.userName}}&amp;authPassword={{clamp.config.policy.api.password}}&amp;connectionTimeToLive=5000&amp;httpClient.connectTimeout=10000&amp;httpClient.socketTimeout=20000&amp;authenticationPreemptive=true&amp;connectionClose=true"/>
+ <doFinally>
+ <to uri="direct:reset-raise-http-exception-flag"/>
+ <to
+ uri="bean:org.onap.clamp.flow.log.FlowLogOperation?method=invokeReturnLog()"/>
+ <setProperty propertyName="logMessage">
+ <simple>${exchangeProperty[guardPolicy].getKey()} removal status
+ </simple>
+ </setProperty>
+ <setProperty propertyName="logComponent">
+ <simple>POLICY</simple>
+ </setProperty>
+ <to uri="direct:dump-loop-log-http-response"/>
+ </doFinally>
+ </doTry>
+ </route>
- <doFinally>
- <to uri="direct:reset-raise-http-exception-flag"/>
- <to
- uri="bean:org.onap.clamp.flow.log.FlowLogOperation?method=invokeReturnLog()"/>
- <setProperty propertyName="logMessage">
- <simple>${exchangeProperty[guardPolicy].getKey()} removal status
- </simple>
- </setProperty>
- <setProperty propertyName="logComponent">
- <simple>POLICY</simple>
- </setProperty>
- <to uri="direct:dump-loop-log-http-response"/>
- </doFinally>
- </doTry>
- </route>
+ <route id="add-all-to-active-pdp-group">
+ <from uri="direct:add-all-to-active-pdp-group"/>
+ <doTry>
+ <log loggingLevel="INFO"
+ message="Adding loop policies to PDP Group: ${exchangeProperty[loopObject].getName()}"/>
+ <to
+ uri="bean:org.onap.clamp.flow.log.FlowLogOperation?method=invokeLog('Policy', 'Add policies to PDP group')"/>
+ <setBody>
+ <simple>
+ ${exchangeProperty[loopObject].getComponent("POLICY").createPoliciesPayloadPdpGroup(exchangeProperty[loopObject],"POST")}
+ </simple>
+ </setBody>
+ <setHeader headerName="CamelHttpMethod">
+ <constant>POST</constant>
+ </setHeader>
+ <setHeader headerName="Content-Type">
+ <constant>application/json</constant>
+ </setHeader>
+ <setHeader headerName="X-ONAP-RequestID">
+ <simple>${exchangeProperty[X-ONAP-RequestID]}
+ </simple>
+ </setHeader>
+ <setHeader headerName="X-ONAP-InvocationID">
+ <simple>${exchangeProperty[X-ONAP-InvocationID]}
+ </simple>
+ </setHeader>
+ <setHeader headerName="X-ONAP-PartnerName">
+ <simple>${exchangeProperty[X-ONAP-PartnerName]}
+ </simple>
+ </setHeader>
+ <log loggingLevel="INFO"
+ message="Endpoint to add policies to PDP Group: {{clamp.config.policy.pap.url}}/policy/pap/v1/pdps/deployments/batch"></log>
+ <toD
+ uri="{{clamp.config.policy.pap.url}}/policy/pap/v1/pdps/deployments/batch?bridgeEndpoint=true&amp;throwExceptionOnFailure=${exchangeProperty[raiseHttpExceptionFlag]}&amp;useSystemProperties=true&amp;authUsername={{clamp.config.policy.pap.userName}}&amp;authPassword={{clamp.config.policy.pap.password}}&amp;connectionTimeToLive=5000&amp;httpClient.connectTimeout=10000&amp;httpClient.socketTimeout=20000&amp;authenticationPreemptive=true&amp;connectionClose=true"/>
- <route id="add-all-to-active-pdp-group">
- <from uri="direct:add-all-to-active-pdp-group"/>
- <doTry>
- <log loggingLevel="INFO"
- message="Adding loop policies to PDP Group: ${exchangeProperty[loopObject].getName()}"/>
- <to
- uri="bean:org.onap.clamp.flow.log.FlowLogOperation?method=invokeLog('Policy', 'Add policies to PDP group')"/>
- <setBody>
- <simple>${exchangeProperty[loopObject].getComponent("POLICY").createPoliciesPayloadPdpGroup(exchangeProperty[loopObject])}
- </simple>
- </setBody>
- <setHeader headerName="CamelHttpMethod">
- <constant>POST</constant>
- </setHeader>
- <setHeader headerName="Content-Type">
- <constant>application/json</constant>
- </setHeader>
- <setHeader headerName="X-ONAP-RequestID">
- <simple>${exchangeProperty[X-ONAP-RequestID]}
- </simple>
- </setHeader>
- <setHeader headerName="X-ONAP-InvocationID">
- <simple>${exchangeProperty[X-ONAP-InvocationID]}
- </simple>
- </setHeader>
- <setHeader headerName="X-ONAP-PartnerName">
- <simple>${exchangeProperty[X-ONAP-PartnerName]}
- </simple>
- </setHeader>
- <log loggingLevel="INFO"
- message="Endpoint to add policies to PDP Group: {{clamp.config.policy.pap.url}}/policy/pap/v1/pdps/deployments/batch"></log>
- <toD
- uri="{{clamp.config.policy.pap.url}}/policy/pap/v1/pdps/deployments/batch?bridgeEndpoint=true&amp;throwExceptionOnFailure=${exchangeProperty[raiseHttpExceptionFlag]}&amp;useSystemProperties=true&amp;authUsername={{clamp.config.policy.pap.userName}}&amp;authPassword={{clamp.config.policy.pap.password}}&amp;connectionTimeToLive=5000&amp;httpClient.connectTimeout=10000&amp;httpClient.socketTimeout=20000&amp;authenticationPreemptive=true&amp;connectionClose=true"/>
+ <doFinally>
+ <to uri="direct:reset-raise-http-exception-flag"/>
+ <to
+ uri="bean:org.onap.clamp.flow.log.FlowLogOperation?method=invokeReturnLog()"/>
+ <setProperty propertyName="logMessage">
+ <simple>PDP Group push ALL status</simple>
+ </setProperty>
+ <setProperty propertyName="logComponent">
+ <simple>POLICY</simple>
+ </setProperty>
+ <to uri="direct:dump-loop-log-http-response"/>
+ </doFinally>
+ </doTry>
+ </route>
- <doFinally>
- <to uri="direct:reset-raise-http-exception-flag"/>
- <to
- uri="bean:org.onap.clamp.flow.log.FlowLogOperation?method=invokeReturnLog()"/>
- <setProperty propertyName="logMessage">
- <simple>PDP Group push ALL status</simple>
- </setProperty>
- <setProperty propertyName="logComponent">
- <simple>POLICY</simple>
- </setProperty>
- <to uri="direct:dump-loop-log-http-response"/>
- </doFinally>
- </doTry>
- </route>
+ <route id="remove-all-policy-from-active-pdp-group">
+ <from uri="direct:remove-all-policy-from-active-pdp-group"/>
+ <doTry>
+ <log loggingLevel="INFO"
+ message="Removing loop policies from PDP Group: ${exchangeProperty[loopObject].getName()}"/>
+ <to
+ uri="bean:org.onap.clamp.flow.log.FlowLogOperation?method=invokeLog('Policy', 'Remove policies from PDP group')"/>
+ <setBody>
+ <simple>
+ ${exchangeProperty[loopObject].getComponent("POLICY").createPoliciesPayloadPdpGroup(exchangeProperty[loopObject],"DELETE")}
+ </simple>
+ </setBody>
+ <setHeader headerName="CamelHttpMethod">
+ <constant>POST</constant>
+ </setHeader>
+ <setHeader headerName="Content-Type">
+ <constant>application/json</constant>
+ </setHeader>
+ <setHeader headerName="X-ONAP-RequestID">
+ <simple>${exchangeProperty[X-ONAP-RequestID]}
+ </simple>
+ </setHeader>
+ <setHeader headerName="X-ONAP-InvocationID">
+ <simple>${exchangeProperty[X-ONAP-InvocationID]}
+ </simple>
+ </setHeader>
+ <setHeader headerName="X-ONAP-PartnerName">
+ <simple>${exchangeProperty[X-ONAP-PartnerName]}
+ </simple>
+ </setHeader>
+ <log loggingLevel="INFO"
+ message="Endpoint to remove policies from PDP Group: {{clamp.config.policy.pap.url}}/policy/pap/v1/pdps/deployments/batch"></log>
+ <toD
+ uri="{{clamp.config.policy.pap.url}}/policy/pap/v1/pdps/deployments/batch?bridgeEndpoint=true&amp;throwExceptionOnFailure=${exchangeProperty[raiseHttpExceptionFlag]}&amp;useSystemProperties=true&amp;authUsername={{clamp.config.policy.pap.userName}}&amp;authPassword={{clamp.config.policy.pap.password}}&amp;connectionTimeToLive=5000&amp;httpClient.connectTimeout=10000&amp;httpClient.socketTimeout=20000&amp;authenticationPreemptive=true&amp;connectionClose=true"/>
- <route id="remove-all-policy-from-active-pdp-group">
- <from uri="direct:remove-all-policy-from-active-pdp-group"/>
- <doTry>
- <log loggingLevel="INFO"
- message="Removing policies from active PDP group for loop: ${exchangeProperty[loopObject].getName()}"/>
- <to
- uri="bean:org.onap.clamp.flow.log.FlowLogOperation?method=invokeLog('Policy', 'Removing policies PDP group')"/>
- <split>
- <simple>${exchangeProperty[loopObject].getComponent("POLICY").listPolicyNamesPdpGroup(exchangeProperty[loopObject])}
- </simple>
- <setProperty propertyName="policyName">
- <simple>${body}</simple>
- </setProperty>
- <setBody>
- <constant>null</constant>
- </setBody>
- <setHeader headerName="CamelHttpMethod">
- <constant>DELETE</constant>
- </setHeader>
- <setHeader headerName="X-ONAP-RequestID">
- <simple>${exchangeProperty[X-ONAP-RequestID]}
- </simple>
- </setHeader>
- <setHeader headerName="X-ONAP-InvocationID">
- <simple>${exchangeProperty[X-ONAP-InvocationID]}
- </simple>
- </setHeader>
- <setHeader headerName="X-ONAP-PartnerName">
- <simple>${exchangeProperty[X-ONAP-PartnerName]}
- </simple>
- </setHeader>
- <log loggingLevel="INFO"
- message="Endpoint to delete policy from PDP Group: {{clamp.config.policy.pap.url}}/pdps/deployments/batch/${exchangeProperty[policyName]}/versions/1.0.0"></log>
- <toD
- uri="{{clamp.config.policy.pap.url}}/policy/pap/v1/pdps/deployments/batch/${exchangeProperty[policyName]}/versions/1.0.0?bridgeEndpoint=true&amp;useSystemProperties=true&amp;mapHttpMessageHeaders=false&amp;throwExceptionOnFailure=${exchangeProperty[raiseHttpExceptionFlag]}&amp;authUsername={{clamp.config.policy.pap.userName}}&amp;authPassword={{clamp.config.policy.pap.password}}&amp;connectionTimeToLive=5000&amp;httpClient.connectTimeout=10000&amp;httpClient.socketTimeout=20000&amp;authenticationPreemptive=true&amp;connectionClose=true"/>
- <setProperty propertyName="logMessage">
- <simple>${exchangeProperty[policyName]} PDP Group removal status
- </simple>
- </setProperty>
- <setProperty propertyName="logComponent">
- <simple>POLICY</simple>
- </setProperty>
- <to uri="direct:dump-loop-log-http-response"/>
- </split>
- <doCatch>
- <exception>java.lang.Exception</exception>
- <handled>
- <constant>false</constant>
- </handled>
- <setProperty propertyName="logMessage">
- <simple>PDP Group removal, Error reported: ${exception}</simple>
- </setProperty>
- <setProperty propertyName="logComponent">
- <simple>POLICY</simple>
- </setProperty>
- <to uri="direct:dump-loop-log-http-response"/>
- </doCatch>
- <doFinally>
- <to uri="direct:reset-raise-http-exception-flag"/>
- <to
- uri="bean:org.onap.clamp.flow.log.FlowLogOperation?method=invokeReturnLog()"/>
- </doFinally>
- </doTry>
- </route>
- <route id="get-all-pdp-groups">
- <from uri="direct:get-all-pdp-groups"/>
- <doTry>
- <log loggingLevel="INFO"
- message="Getting the list of PDP Groups"/>
- <to
- uri="bean:org.onap.clamp.flow.log.FlowLogOperation?method=invokeLog('Policy', 'Getting the PDP Group list')"/>
- <setHeader headerName="CamelHttpMethod">
- <constant>GET</constant>
- </setHeader>
- <setHeader headerName="X-ONAP-RequestID">
- <simple>${exchangeProperty[X-ONAP-RequestID]}
- </simple>
- </setHeader>
- <setHeader headerName="X-ONAP-InvocationID">
- <simple>${exchangeProperty[X-ONAP-InvocationID]}
- </simple>
- </setHeader>
- <setHeader headerName="X-ONAP-PartnerName">
- <simple>${exchangeProperty[X-ONAP-PartnerName]}
- </simple>
- </setHeader>
- <log loggingLevel="INFO"
- message="Endpoint to get policy model: {{clamp.config.policy.pap.url}}/policy/pap/v1/pdps"></log>
- <toD
- uri="{{clamp.config.policy.pap.url}}/policy/pap/v1/pdps?bridgeEndpoint=true&amp;useSystemProperties=true&amp;throwExceptionOnFailure=${exchangeProperty[raiseHttpExceptionFlag]}&amp;authMethod=Basic&amp;authUsername={{clamp.config.policy.api.userName}}&amp;authPassword={{clamp.config.policy.api.password}}&amp;connectionTimeToLive=5000&amp;httpClient.connectTimeout=10000&amp;httpClient.socketTimeout=20000&amp;authenticationPreemptive=true&amp;connectionClose=true"/>
- <convertBodyTo type="java.lang.String" />
- <doFinally>
- <to uri="direct:reset-raise-http-exception-flag"/>
- <to
- uri="bean:org.onap.clamp.flow.log.FlowLogOperation?method=invokeReturnLog()"/>
- </doFinally>
- </doTry>
- </route>
+ <doFinally>
+ <to uri="direct:reset-raise-http-exception-flag"/>
+ <to
+ uri="bean:org.onap.clamp.flow.log.FlowLogOperation?method=invokeReturnLog()"/>
+ <setProperty propertyName="logMessage">
+ <simple>PDP Group remove ALL status</simple>
+ </setProperty>
+ <setProperty propertyName="logComponent">
+ <simple>POLICY</simple>
+ </setProperty>
+ <to uri="direct:dump-loop-log-http-response"/>
+ </doFinally>
+ </doTry>
+ </route>
+ <route id="get-all-pdp-groups">
+ <from uri="direct:get-all-pdp-groups"/>
+ <doTry>
+ <log loggingLevel="INFO"
+ message="Getting the list of PDP Groups"/>
+ <to
+ uri="bean:org.onap.clamp.flow.log.FlowLogOperation?method=invokeLog('Policy', 'Getting the PDP Group list')"/>
+ <setHeader headerName="CamelHttpMethod">
+ <constant>GET</constant>
+ </setHeader>
+ <setHeader headerName="X-ONAP-RequestID">
+ <simple>${exchangeProperty[X-ONAP-RequestID]}
+ </simple>
+ </setHeader>
+ <setHeader headerName="X-ONAP-InvocationID">
+ <simple>${exchangeProperty[X-ONAP-InvocationID]}
+ </simple>
+ </setHeader>
+ <setHeader headerName="X-ONAP-PartnerName">
+ <simple>${exchangeProperty[X-ONAP-PartnerName]}
+ </simple>
+ </setHeader>
+ <log loggingLevel="INFO"
+ message="Endpoint to get policy model: {{clamp.config.policy.pap.url}}/policy/pap/v1/pdps"></log>
+ <toD
+ uri="{{clamp.config.policy.pap.url}}/policy/pap/v1/pdps?bridgeEndpoint=true&amp;useSystemProperties=true&amp;throwExceptionOnFailure=${exchangeProperty[raiseHttpExceptionFlag]}&amp;authMethod=Basic&amp;authUsername={{clamp.config.policy.api.userName}}&amp;authPassword={{clamp.config.policy.api.password}}&amp;connectionTimeToLive=5000&amp;httpClient.connectTimeout=10000&amp;httpClient.socketTimeout=20000&amp;authenticationPreemptive=true&amp;connectionClose=true"/>
+ <convertBodyTo type="java.lang.String"/>
+ <doFinally>
+ <to uri="direct:reset-raise-http-exception-flag"/>
+ <to
+ uri="bean:org.onap.clamp.flow.log.FlowLogOperation?method=invokeReturnLog()"/>
+ </doFinally>
+ </doTry>
+ </route>
+ <route id="remove-one-policy-from-active-pdp-group">
+ <from uri="direct:remove-one-policy-from-active-pdp-group"/>
+ <doTry>
+ <log loggingLevel="INFO"
+ message="Removing policy from active PDP group for loop: ${exchangeProperty[loopObject].getName()}"/>
+ <to
+ uri="bean:org.onap.clamp.flow.log.FlowLogOperation?method=invokeLog('Policy', 'Removing one policy PDP group')"/>
+ <setBody>
+ <constant>null</constant>
+ </setBody>
+ <setHeader headerName="CamelHttpMethod">
+ <constant>DELETE</constant>
+ </setHeader>
+ <setHeader headerName="X-ONAP-RequestID">
+ <simple>${exchangeProperty[X-ONAP-RequestID]}
+ </simple>
+ </setHeader>
+ <setHeader headerName="X-ONAP-InvocationID">
+ <simple>${exchangeProperty[X-ONAP-InvocationID]}
+ </simple>
+ </setHeader>
+ <setHeader headerName="X-ONAP-PartnerName">
+ <simple>${exchangeProperty[X-ONAP-PartnerName]}
+ </simple>
+ </setHeader>
+ <log loggingLevel="INFO"
+ message="Endpoint to delete policy from PDP Group: {{clamp.config.policy.pap.url}}/pdps/policies/${exchangeProperty[policyName]}/versions/1.0.0"></log>
+ <toD
+ uri="{{clamp.config.policy.pap.url}}/policy/pap/v1/pdps/policies/${exchangeProperty[policyName]}/versions/1.0.0?bridgeEndpoint=true&amp;useSystemProperties=true&amp;mapHttpMessageHeaders=false&amp;throwExceptionOnFailure=${exchangeProperty[raiseHttpExceptionFlag]}&amp;authUsername={{clamp.config.policy.pap.userName}}&amp;authPassword={{clamp.config.policy.pap.password}}&amp;connectionTimeToLive=5000&amp;httpClient.connectTimeout=10000&amp;httpClient.socketTimeout=20000&amp;authenticationPreemptive=true&amp;connectionClose=true"/>
+ <setProperty propertyName="logMessage">
+ <simple>${exchangeProperty[policyName]} PDP Group removal status
+ </simple>
+ </setProperty>
+ <setProperty propertyName="logComponent">
+ <simple>POLICY</simple>
+ </setProperty>
+ <to uri="direct:dump-loop-log-http-response"/>
+ <doCatch>
+ <exception>java.lang.Exception</exception>
+ <handled>
+ <constant>false</constant>
+ </handled>
+ <setProperty propertyName="logMessage">
+ <simple>PDP Group removal, Error reported: ${exception}</simple>
+ </setProperty>
+ <setProperty propertyName="logComponent">
+ <simple>POLICY</simple>
+ </setProperty>
+ <to uri="direct:dump-loop-log-http-response"/>
+ </doCatch>
+ <doFinally>
+ <to uri="direct:reset-raise-http-exception-flag"/>
+ <to
+ uri="bean:org.onap.clamp.flow.log.FlowLogOperation?method=invokeReturnLog()"/>
+ </doFinally>
+ </doTry>
+ </route>
</routes> \ No newline at end of file
diff --git a/src/main/resources/clds/json-schema/operational_policies/operational_policy.json b/src/main/resources/clds/json-schema/operational_policies/operational_policy.json
index 49d7878a8..7214b022c 100644
--- a/src/main/resources/clds/json-schema/operational_policies/operational_policy.json
+++ b/src/main/resources/clds/json-schema/operational_policies/operational_policy.json
@@ -99,6 +99,7 @@
"anyOf": [
{
"title": "APPC",
+ "type": "object",
"properties": {
"actor": {
"title": "actor",
@@ -108,7 +109,7 @@
"hidden": true
}
},
- "type": {
+ "recipe": {
"title": "recipe",
"type": "string",
"default": "",
@@ -129,6 +130,7 @@
},
{
"title": "SO",
+ "type": "object",
"properties": {
"actor": {
"title": "actor",
@@ -138,7 +140,7 @@
"hidden": true
}
},
- "type": {
+ "recipe": {
"title": "recipe",
"type": "string",
"default": "",
@@ -156,6 +158,7 @@
},
{
"title": "SDNC",
+ "type": "object",
"properties": {
"actor": {
"title": "actor",
@@ -165,7 +168,7 @@
"hidden": true
}
},
- "type": {
+ "recipe": {
"title": "recipe",
"type": "string",
"default": "",
@@ -183,6 +186,7 @@
},
{
"title": "VFC",
+ "type": "object",
"properties": {
"actor": {
"title": "actor",
@@ -192,12 +196,9 @@
"hidden": true
}
},
- "type": {
+ "recipe": {
"title": "recipe",
"type": "string",
- "required": [
- "payload"
- ],
"default": "",
"enum": [
"ModifyConfig"
@@ -212,6 +213,7 @@
},
{
"title": "CDS",
+ "type": "object",
"properties": {
"actor": {
"title": "actor",
@@ -221,17 +223,21 @@
"hidden": true
}
},
- "type": {
+ "recipe": {
"title": "recipe",
"type": "object",
- "required": [
- "payload"
- ],
"anyOf": [
{
"title": "user-defined",
+ "type": "object",
"properties": {
- "type": {
+ "recipe": {
+ "title": "recipe",
+ "type": "string",
+ "default": "user-defined",
+ "format": "textarea"
+ },
+ "payload": {
"title": "Payload (YAML)",
"type": "string",
"default": "",