diff options
Diffstat (limited to 'src')
23 files changed, 1204 insertions, 1078 deletions
diff --git a/src/main/java/org/onap/clamp/clds/ClampServlet.java b/src/main/java/org/onap/clamp/clds/ClampServlet.java index e8fd83e2e..90d0693d1 100644 --- a/src/main/java/org/onap/clamp/clds/ClampServlet.java +++ b/src/main/java/org/onap/clamp/clds/ClampServlet.java @@ -5,6 +5,8 @@ * Copyright (C) 2018 AT&T Intellectual Property. All rights * reserved. * ================================================================================ + * Modifications Copyright (c) 2019 Samsung + * ================================================================================ * 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 @@ -25,16 +27,6 @@ package org.onap.clamp.clds; import com.att.eelf.configuration.EELFLogger; import com.att.eelf.configuration.EELFManager; - -import java.io.IOException; -import java.security.Principal; -import java.util.ArrayList; -import java.util.List; - -import javax.servlet.ServletException; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - import org.apache.camel.component.servlet.CamelHttpTransportServlet; import org.onap.clamp.clds.service.SecureServicePermission; import org.springframework.context.ApplicationContext; @@ -47,6 +39,14 @@ import org.springframework.security.core.context.SecurityContextHolder; import org.springframework.security.core.userdetails.User; import org.springframework.web.context.support.WebApplicationContextUtils; +import javax.servlet.ServletException; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; +import java.io.IOException; +import java.security.Principal; +import java.util.ArrayList; +import java.util.List; + public class ClampServlet extends CamelHttpTransportServlet { /** @@ -54,24 +54,27 @@ public class ClampServlet extends CamelHttpTransportServlet { */ private static final long serialVersionUID = -4198841134910211542L; - protected static final EELFLogger logger = EELFManager.getInstance().getLogger(ClampServlet.class); - public static final String PERM_INSTANCE = "clamp.config.security.permission.instance"; - public static final String PERM_CL = "clamp.config.security.permission.type.cl"; - public static final String PERM_TEMPLATE = "clamp.config.security.permission.type.template"; - public static final String PERM_VF = "clamp.config.security.permission.type.filter.vf"; - public static final String PERM_MANAGE = "clamp.config.security.permission.type.cl.manage"; - public static final String PERM_TOSCA = "clamp.config.security.permission.type.tosca"; - public static final String AUTHENTICATION_CLASS = "clamp.config.security.authentication.class"; + private static final EELFLogger logger = EELFManager.getInstance().getLogger(ClampServlet.class); + private static final String PERM_INSTANCE = "clamp.config.security.permission.instance"; + private static final String PERM_CL = "clamp.config.security.permission.type.cl"; + private static final String PERM_TEMPLATE = "clamp.config.security.permission.type.template"; + private static final String PERM_VF = "clamp.config.security.permission.type.filter.vf"; + private static final String PERM_MANAGE = "clamp.config.security.permission.type.cl.manage"; + private static final String PERM_TOSCA = "clamp.config.security.permission.type.tosca"; + private static final String AUTHENTICATION_CLASS = "clamp.config.security.authentication.class"; + private static final String READ = "read"; + private static final String UPDATE = "update"; + private static List<SecureServicePermission> permissionList; private synchronized Class loadDynamicAuthenticationClass() { try { String authenticationObject = WebApplicationContextUtils.getWebApplicationContext(getServletContext()) - .getEnvironment().getProperty(AUTHENTICATION_CLASS); + .getEnvironment().getProperty(AUTHENTICATION_CLASS); return Class.forName(authenticationObject); } catch (ClassNotFoundException e) { logger.error( - "Exception caught when attempting to create associated class of config:" + AUTHENTICATION_CLASS, e); + "Exception caught when attempting to create associated class of config:" + AUTHENTICATION_CLASS, e); return Object.class; } } @@ -80,24 +83,24 @@ public class ClampServlet extends CamelHttpTransportServlet { if (permissionList == null) { permissionList = new ArrayList<>(); ApplicationContext applicationContext = WebApplicationContextUtils - .getWebApplicationContext(getServletContext()); + .getWebApplicationContext(getServletContext()); String cldsPermissionInstance = applicationContext.getEnvironment().getProperty(PERM_INSTANCE); permissionList.add(SecureServicePermission.create(applicationContext.getEnvironment().getProperty(PERM_CL), - cldsPermissionInstance, "read")); + cldsPermissionInstance, READ)); permissionList.add(SecureServicePermission.create(applicationContext.getEnvironment().getProperty(PERM_CL), - cldsPermissionInstance, "update")); + cldsPermissionInstance, UPDATE)); permissionList.add(SecureServicePermission.create( - applicationContext.getEnvironment().getProperty(PERM_TEMPLATE), cldsPermissionInstance, "read")); + applicationContext.getEnvironment().getProperty(PERM_TEMPLATE), cldsPermissionInstance, READ)); permissionList.add(SecureServicePermission.create( - applicationContext.getEnvironment().getProperty(PERM_TEMPLATE), cldsPermissionInstance, "update")); + applicationContext.getEnvironment().getProperty(PERM_TEMPLATE), cldsPermissionInstance, UPDATE)); permissionList.add(SecureServicePermission.create(applicationContext.getEnvironment().getProperty(PERM_VF), - cldsPermissionInstance, "*")); + cldsPermissionInstance, "*")); permissionList.add(SecureServicePermission - .create(applicationContext.getEnvironment().getProperty(PERM_MANAGE), cldsPermissionInstance, "*")); + .create(applicationContext.getEnvironment().getProperty(PERM_MANAGE), cldsPermissionInstance, "*")); permissionList.add(SecureServicePermission - .create(applicationContext.getEnvironment().getProperty(PERM_TOSCA), cldsPermissionInstance, "read")); + .create(applicationContext.getEnvironment().getProperty(PERM_TOSCA), cldsPermissionInstance, READ)); permissionList.add(SecureServicePermission - .create(applicationContext.getEnvironment().getProperty(PERM_TOSCA), cldsPermissionInstance, "update")); + .create(applicationContext.getEnvironment().getProperty(PERM_TOSCA), cldsPermissionInstance, UPDATE)); } return permissionList; } @@ -107,8 +110,7 @@ public class ClampServlet extends CamelHttpTransportServlet { * to isUserInRole will invoke a http call to AAF server. */ @Override - protected void doService(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { + protected void doService(HttpServletRequest request, HttpServletResponse response) { Principal principal = request.getUserPrincipal(); if (loadDynamicAuthenticationClass().isInstance(principal)) { // When AAF is enabled, there is a need to provision the permissions to Spring @@ -121,7 +123,7 @@ public class ClampServlet extends CamelHttpTransportServlet { } } Authentication auth = new UsernamePasswordAuthenticationToken(new User(principal.getName(), "", grantedAuths), "", - grantedAuths); + grantedAuths); SecurityContextHolder.getContext().setAuthentication(auth); } try { @@ -134,6 +136,5 @@ public class ClampServlet extends CamelHttpTransportServlet { logger.error("Exception caught when executing HTTP sendError in servlet", e); } } - } }
\ No newline at end of file diff --git a/src/main/java/org/onap/clamp/clds/camel/CamelProxy.java b/src/main/java/org/onap/clamp/clds/camel/CamelProxy.java index a74f4c702..f6265982b 100644 --- a/src/main/java/org/onap/clamp/clds/camel/CamelProxy.java +++ b/src/main/java/org/onap/clamp/clds/camel/CamelProxy.java @@ -5,6 +5,8 @@ * Copyright (C) 2018 AT&T Intellectual Property. All rights * reserved. * ================================================================================ + * Modifications Copyright (c) 2019 Samsung + * ================================================================================ * 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 @@ -18,7 +20,7 @@ * limitations under the License. * ============LICENSE_END============================================ * =================================================================== - * + * */ package org.onap.clamp.clds.camel; @@ -29,41 +31,32 @@ import org.apache.camel.ExchangeProperty; * This interface describes the CamelProxy parameters that must be passed to the * Camel flow. */ +@FunctionalInterface public interface CamelProxy { /** * This method is called when invoking a camel flow. - * - * @param actionCommand - * The action coming from the Clamp UI (like SUBMIT, UPDATE, - * DELETE, ...) - * @param modelProperties - * The Model properties created based on the BPMN Json and - * Properties Json - * @param modelBpmnProperties - * The Json with all the properties describing the flow - * @param modelName - * The model name - * @param controlName - * The control loop name - * @param docText - * The Global properties JSON containing YAML (coming from CLamp - * template) - * @param isTest - * Is a test or not (flag coming from the UI) - * @param userId - * The user ID coming from the UI - * @param isInsertTestEvent - * Is a test or not (flag coming from the UI) - * @param eventAction - * The latest event action in database (like CREATE, SUBMIT, ...) + * + * @param actionCommand The action coming from the Clamp UI (like SUBMIT, UPDATE, + * DELETE, ...) + * @param modelProperties The Model properties created based on the BPMN Json and + * Properties Json + * @param modelBpmnProperties The Json with all the properties describing the flow + * @param modelName The model name + * @param controlName The control loop name + * @param docText The Global properties JSON containing YAML (coming from CLamp + * template) + * @param isTest Is a test or not (flag coming from the UI) + * @param userId The user ID coming from the UI + * @param isInsertTestEvent Is a test or not (flag coming from the UI) + * @param eventAction The latest event action in database (like CREATE, SUBMIT, ...) * @return A string containing the result of the Camel flow execution */ String executeAction(@ExchangeProperty("actionCd") String actionCommand, - @ExchangeProperty("modelProp") String modelProperties, - @ExchangeProperty("modelBpmnProp") String modelBpmnProperties, - @ExchangeProperty("modelName") String modelName, @ExchangeProperty("controlName") String controlName, - @ExchangeProperty("docText") String docText, @ExchangeProperty("isTest") boolean isTest, - @ExchangeProperty("userid") String userId, @ExchangeProperty("isInsertTestEvent") boolean isInsertTestEvent, - @ExchangeProperty("eventAction") String eventAction); + @ExchangeProperty("modelProp") String modelProperties, + @ExchangeProperty("modelBpmnProp") String modelBpmnProperties, + @ExchangeProperty("modelName") String modelName, @ExchangeProperty("controlName") String controlName, + @ExchangeProperty("docText") String docText, @ExchangeProperty("isTest") boolean isTest, + @ExchangeProperty("userid") String userId, @ExchangeProperty("isInsertTestEvent") boolean isInsertTestEvent, + @ExchangeProperty("eventAction") String eventAction); } diff --git a/src/main/java/org/onap/clamp/clds/client/DcaeDispatcherServices.java b/src/main/java/org/onap/clamp/clds/client/DcaeDispatcherServices.java index f7aff0eff..83401a3c4 100644 --- a/src/main/java/org/onap/clamp/clds/client/DcaeDispatcherServices.java +++ b/src/main/java/org/onap/clamp/clds/client/DcaeDispatcherServices.java @@ -1,218 +1,216 @@ -/*-
- * ============LICENSE_START=======================================================
- * ONAP CLAMP
- * ================================================================================
- * Copyright (C) 2017-2018 AT&T Intellectual Property. All rights
- * reserved.
- * ================================================================================
- * Modifications Copyright (c) 2019 Samsung
- * ================================================================================
- * 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.client;
-
-import com.att.eelf.configuration.EELFLogger;
-import com.att.eelf.configuration.EELFManager;
-
-import com.google.gson.JsonObject;
-import java.io.IOException;
-import java.util.Date;
-
-import org.json.simple.JSONObject;
-import org.json.simple.parser.JSONParser;
-import org.json.simple.parser.ParseException;
-import org.onap.clamp.clds.config.ClampProperties;
-import org.onap.clamp.clds.exception.dcae.DcaeDeploymentException;
-import org.onap.clamp.clds.util.LoggingUtils;
-import org.onap.clamp.util.HttpConnectionManager;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.stereotype.Component;
-
-/**
- * This class implements the communication with DCAE for the service
- * deployments.
- */
-@Component
-public class DcaeDispatcherServices {
-
- protected static final EELFLogger logger = EELFManager.getInstance().getLogger(DcaeDispatcherServices.class);
- protected static final EELFLogger metricsLogger = EELFManager.getInstance().getMetricsLogger();
- private final ClampProperties refProp;
- private final HttpConnectionManager dcaeHttpConnectionManager;
- private static final String STATUS_URL_LOG = "Status URL extracted: ";
- private static final String DCAE_URL_PREFIX = "/dcae-deployments/";
- private static final String DCAE_URL_PROPERTY_NAME = "dcae.dispatcher.url";
- private static final String DCAE_LINK_FIELD = "links";
- private static final String DCAE_STATUS_FIELD = "status";
-
- @Autowired
- public DcaeDispatcherServices(ClampProperties refProp, HttpConnectionManager dcaeHttpConnectionManager) {
- this.refProp = refProp;
- this.dcaeHttpConnectionManager = dcaeHttpConnectionManager;
- }
-
- /**
- * Get the Operation Status from a specified URL with retry.
- * @param operationStatusUrl
- * The URL of the DCAE
- * @return The status
- * @throws InterruptedException Exception during the retry
- */
- public String getOperationStatusWithRetry(String operationStatusUrl) throws InterruptedException {
- String operationStatus = "";
- for (int i = 0; i < Integer.valueOf(refProp.getStringValue("dcae.dispatcher.retry.limit")); i++) {
- logger.info("Trying to get Operation status on DCAE for url:" + operationStatusUrl);
- operationStatus = getOperationStatus(operationStatusUrl);
- logger.info("Current Status is:" + operationStatus);
- if (!"processing".equalsIgnoreCase(operationStatus)) {
- return operationStatus;
- } else {
- Thread.sleep(Integer.valueOf(refProp.getStringValue("dcae.dispatcher.retry.interval")));
- }
- }
- logger.warn("Number of attempts on DCAE is over, stopping the getOperationStatus method");
- return operationStatus;
- }
-
- /**
- * Get the Operation Status from a specified URL.
- * @param statusUrl
- * The URL provided by a previous DCAE Query
- * @return The status
- */
- public String getOperationStatus(String statusUrl) {
- // Assigning processing status to monitor operation status further
- String opStatus = "processing";
- Date startTime = new Date();
- LoggingUtils.setTargetContext("DCAE", "getOperationStatus");
- try {
- String responseStr = dcaeHttpConnectionManager.doHttpRequest(statusUrl, "GET", null,
- null, "DCAE", null,
- null);
- JSONObject jsonObj = parseResponse(responseStr);
- String operationType = (String) jsonObj.get("operationType");
- String status = (String) jsonObj.get(DCAE_STATUS_FIELD);
- logger.info("Operation Type - " + operationType + ", Status " + status);
- LoggingUtils.setResponseContext("0", "Get operation status success", this.getClass().getName());
- opStatus = status;
- } catch (Exception e) {
- LoggingUtils.setResponseContext("900", "Get operation status failed", this.getClass().getName());
- LoggingUtils.setErrorContext("900", "Get operation status error");
- logger.error("Exception occurred during getOperationStatus Operation with DCAE", e);
- } finally {
- LoggingUtils.setTimeContext(startTime, new Date());
- metricsLogger.info("getOperationStatus complete");
- }
- return opStatus;
- }
-
- /**
- * Returns status URL for createNewDeployment operation.
- * @param deploymentId
- * The deployment ID
- * @param serviceTypeId
- * Service type ID
- * @param blueprintInputJson
- * The value for each blueprint parameters in a flat JSON
- * @return The status URL
- */
- public String createNewDeployment(String deploymentId, String serviceTypeId, JsonObject blueprintInputJson) {
- Date startTime = new Date();
- LoggingUtils.setTargetContext("DCAE", "createNewDeployment");
- try {
- JsonObject rootObject = refProp.getJsonTemplate("dcae.deployment.template").getAsJsonObject();
- rootObject.addProperty("serviceTypeId", serviceTypeId);
- if (blueprintInputJson != null) {
- rootObject.add("inputs", blueprintInputJson);
- }
- String apiBodyString = rootObject.toString();
- logger.info("Dcae api Body String - " + apiBodyString);
- String url = refProp.getStringValue(DCAE_URL_PROPERTY_NAME) + DCAE_URL_PREFIX + deploymentId;
- String statusUrl = getDcaeResponse(url, "PUT", apiBodyString, "application/json", DCAE_LINK_FIELD,
- DCAE_STATUS_FIELD);
- LoggingUtils.setResponseContext("0", "Create new deployment failed", this.getClass().getName());
- return statusUrl;
- } catch (Exception e) {
- LoggingUtils.setResponseContext("900", "Create new deployment failed", this.getClass().getName());
- LoggingUtils.setErrorContext("900", "Create new deployment error");
- logger.error("Exception occurred during createNewDeployment Operation with DCAE", e);
- throw new DcaeDeploymentException("Exception occurred during createNewDeployment Operation with DCAE", e);
- } finally {
- LoggingUtils.setTimeContext(startTime, new Date());
- metricsLogger.info("createNewDeployment complete");
- }
- }
-
- /***
- * Returns status URL for deleteExistingDeployment operation.
- *
- * @param deploymentId
- * The deployment ID
- * @param serviceTypeId
- * The service Type ID
- * @return The status URL
- */
- public String deleteExistingDeployment(String deploymentId, String serviceTypeId) {
- Date startTime = new Date();
- LoggingUtils.setTargetContext("DCAE", "deleteExistingDeployment");
- try {
- String apiBodyString = "{\"serviceTypeId\": \"" + serviceTypeId + "\"}";
- logger.info("Dcae api Body String - " + apiBodyString);
- String url = refProp.getStringValue(DCAE_URL_PROPERTY_NAME) + DCAE_URL_PREFIX + deploymentId;
- String statusUrl = getDcaeResponse(url, "DELETE", apiBodyString, "application/json", DCAE_LINK_FIELD,
- DCAE_STATUS_FIELD);
- LoggingUtils.setResponseContext("0", "Delete existing deployment success", this.getClass().getName());
- return statusUrl;
-
- } catch (Exception e) {
- LoggingUtils.setResponseContext("900", "Delete existing deployment failed", this.getClass().getName());
- LoggingUtils.setErrorContext("900", "Delete existing deployment error");
- logger.error("Exception occurred during deleteExistingDeployment Operation with DCAE", e);
- throw new DcaeDeploymentException("Exception occurred during deleteExistingDeployment Operation with DCAE",
- e);
- } finally {
- LoggingUtils.setTimeContext(startTime, new Date());
- metricsLogger.info("deleteExistingDeployment complete");
- }
- }
-
- private String getDcaeResponse(String url, String requestMethod, String payload, String contentType, String node,
- String nodeAttr) throws IOException, ParseException {
- Date startTime = new Date();
- try {
- String responseStr = dcaeHttpConnectionManager.doHttpRequest(url, requestMethod, payload, contentType, "DCAE", null, null);
- JSONObject jsonObj = parseResponse(responseStr);
- JSONObject linksObj = (JSONObject) jsonObj.get(node);
- String statusUrl = (String) linksObj.get(nodeAttr);
- logger.info(STATUS_URL_LOG + statusUrl);
- return statusUrl;
- } catch (IOException | ParseException e) {
- logger.error("Exception occurred getting response from DCAE", e);
- throw e;
- } finally {
- LoggingUtils.setTimeContext(startTime, new Date());
- metricsLogger.info("getDcaeResponse complete");
- }
- }
-
- private JSONObject parseResponse(String responseStr) throws ParseException {
- JSONParser parser = new JSONParser();
- Object obj0 = parser.parse(responseStr);
- JSONObject jsonObj = (JSONObject) obj0;
- return jsonObj;
- }
+/*- + * ============LICENSE_START======================================================= + * ONAP CLAMP + * ================================================================================ + * Copyright (C) 2017-2018 AT&T Intellectual Property. All rights + * reserved. + * ================================================================================ + * Modifications Copyright (c) 2019 Samsung + * ================================================================================ + * 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.client; + +import com.att.eelf.configuration.EELFLogger; +import com.att.eelf.configuration.EELFManager; + +import com.google.gson.JsonObject; +import java.io.IOException; +import java.util.Date; + +import org.json.simple.JSONObject; +import org.json.simple.parser.JSONParser; +import org.json.simple.parser.ParseException; +import org.onap.clamp.clds.config.ClampProperties; +import org.onap.clamp.clds.exception.dcae.DcaeDeploymentException; +import org.onap.clamp.clds.util.LoggingUtils; +import org.onap.clamp.util.HttpConnectionManager; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Component; + +/** + * This class implements the communication with DCAE for the service + * deployments. + */ +@Component +public class DcaeDispatcherServices { + + protected static final EELFLogger logger = EELFManager.getInstance().getLogger(DcaeDispatcherServices.class); + protected static final EELFLogger metricsLogger = EELFManager.getInstance().getMetricsLogger(); + private final ClampProperties refProp; + private final HttpConnectionManager dcaeHttpConnectionManager; + private static final String STATUS_URL_LOG = "Status URL extracted: "; + private static final String DCAE_URL_PREFIX = "/dcae-deployments/"; + private static final String DCAE_URL_PROPERTY_NAME = "dcae.dispatcher.url"; + private static final String DCAE_LINK_FIELD = "links"; + private static final String DCAE_STATUS_FIELD = "status"; + + @Autowired + public DcaeDispatcherServices(ClampProperties refProp, HttpConnectionManager dcaeHttpConnectionManager) { + this.refProp = refProp; + this.dcaeHttpConnectionManager = dcaeHttpConnectionManager; + } + + /** + * Get the Operation Status from a specified URL with retry. + * @param operationStatusUrl + * The URL of the DCAE + * @return The status + * @throws InterruptedException Exception during the retry + */ + public String getOperationStatusWithRetry(String operationStatusUrl) throws InterruptedException { + String operationStatus = ""; + for (int i = 0; i < Integer.valueOf(refProp.getStringValue("dcae.dispatcher.retry.limit")); i++) { + logger.info("Trying to get Operation status on DCAE for url:" + operationStatusUrl); + operationStatus = getOperationStatus(operationStatusUrl); + logger.info("Current Status is:" + operationStatus); + if (!"processing".equalsIgnoreCase(operationStatus)) { + return operationStatus; + } else { + Thread.sleep(Integer.valueOf(refProp.getStringValue("dcae.dispatcher.retry.interval"))); + } + } + logger.warn("Number of attempts on DCAE is over, stopping the getOperationStatus method"); + return operationStatus; + } + + /** + * Get the Operation Status from a specified URL. + * @param statusUrl + * The URL provided by a previous DCAE Query + * @return The status + */ + public String getOperationStatus(String statusUrl) { + // Assigning processing status to monitor operation status further + String opStatus = "processing"; + Date startTime = new Date(); + LoggingUtils.setTargetContext("DCAE", "getOperationStatus"); + try { + String responseStr = dcaeHttpConnectionManager.doHttpRequest(statusUrl, "GET", null, + null, "DCAE", null, + null); + JSONObject jsonObj = parseResponse(responseStr); + String operationType = (String) jsonObj.get("operationType"); + String status = (String) jsonObj.get(DCAE_STATUS_FIELD); + logger.info("Operation Type - " + operationType + ", Status " + status); + LoggingUtils.setResponseContext("0", "Get operation status success", this.getClass().getName()); + opStatus = status; + } catch (Exception e) { + LoggingUtils.setResponseContext("900", "Get operation status failed", this.getClass().getName()); + LoggingUtils.setErrorContext("900", "Get operation status error"); + logger.error("Exception occurred during getOperationStatus Operation with DCAE", e); + } finally { + LoggingUtils.setTimeContext(startTime, new Date()); + metricsLogger.info("getOperationStatus complete"); + } + return opStatus; + } + + /** + * Returns status URL for createNewDeployment operation. + * @param deploymentId + * The deployment ID + * @param serviceTypeId + * Service type ID + * @param blueprintInputJson + * The value for each blueprint parameters in a flat JSON + * @return The status URL + */ + public String createNewDeployment(String deploymentId, String serviceTypeId, JsonObject blueprintInputJson) { + Date startTime = new Date(); + LoggingUtils.setTargetContext("DCAE", "createNewDeployment"); + try { + JsonObject rootObject = refProp.getJsonTemplate("dcae.deployment.template").getAsJsonObject(); + rootObject.addProperty("serviceTypeId", serviceTypeId); + if (blueprintInputJson != null) { + rootObject.add("inputs", blueprintInputJson); + } + String apiBodyString = rootObject.toString(); + logger.info("Dcae api Body String - " + apiBodyString); + String url = refProp.getStringValue(DCAE_URL_PROPERTY_NAME) + DCAE_URL_PREFIX + deploymentId; + String statusUrl = getDcaeResponse(url, "PUT", apiBodyString, "application/json", DCAE_LINK_FIELD, + DCAE_STATUS_FIELD); + LoggingUtils.setResponseContext("0", "Create new deployment failed", this.getClass().getName()); + return statusUrl; + } catch (Exception e) { + LoggingUtils.setResponseContext("900", "Create new deployment failed", this.getClass().getName()); + LoggingUtils.setErrorContext("900", "Create new deployment error"); + logger.error("Exception occurred during createNewDeployment Operation with DCAE", e); + throw new DcaeDeploymentException("Exception occurred during createNewDeployment Operation with DCAE", e); + } finally { + LoggingUtils.setTimeContext(startTime, new Date()); + metricsLogger.info("createNewDeployment complete"); + } + } + + /*** + * Returns status URL for deleteExistingDeployment operation. + * + * @param deploymentId + * The deployment ID + * @param serviceTypeId + * The service Type ID + * @return The status URL + */ + public String deleteExistingDeployment(String deploymentId, String serviceTypeId) { + Date startTime = new Date(); + LoggingUtils.setTargetContext("DCAE", "deleteExistingDeployment"); + try { + String apiBodyString = "{\"serviceTypeId\": \"" + serviceTypeId + "\"}"; + logger.info("Dcae api Body String - " + apiBodyString); + String url = refProp.getStringValue(DCAE_URL_PROPERTY_NAME) + DCAE_URL_PREFIX + deploymentId; + String statusUrl = getDcaeResponse(url, "DELETE", apiBodyString, "application/json", DCAE_LINK_FIELD, + DCAE_STATUS_FIELD); + LoggingUtils.setResponseContext("0", "Delete existing deployment success", this.getClass().getName()); + return statusUrl; + + } catch (Exception e) { + LoggingUtils.setResponseContext("900", "Delete existing deployment failed", this.getClass().getName()); + LoggingUtils.setErrorContext("900", "Delete existing deployment error"); + logger.error("Exception occurred during deleteExistingDeployment Operation with DCAE", e); + throw new DcaeDeploymentException("Exception occurred during deleteExistingDeployment Operation with DCAE", + e); + } finally { + LoggingUtils.setTimeContext(startTime, new Date()); + metricsLogger.info("deleteExistingDeployment complete"); + } + } + + private String getDcaeResponse(String url, String requestMethod, String payload, String contentType, String node, + String nodeAttr) throws IOException, ParseException { + Date startTime = new Date(); + try { + String responseStr = dcaeHttpConnectionManager.doHttpRequest(url, requestMethod, payload, contentType, "DCAE", null, null); + JSONObject jsonObj = parseResponse(responseStr); + JSONObject linksObj = (JSONObject) jsonObj.get(node); + String statusUrl = (String) linksObj.get(nodeAttr); + logger.info(STATUS_URL_LOG + statusUrl); + return statusUrl; + } catch (IOException | ParseException e) { + logger.error("Exception occurred getting response from DCAE", e); + throw e; + } finally { + LoggingUtils.setTimeContext(startTime, new Date()); + metricsLogger.info("getDcaeResponse complete"); + } + } + + private JSONObject parseResponse(String responseStr) throws ParseException { + JSONParser parser = new JSONParser(); + return (JSONObject) parser.parse(responseStr); + } }
\ No newline at end of file diff --git a/src/main/java/org/onap/clamp/clds/client/req/policy/PolicyClient.java b/src/main/java/org/onap/clamp/clds/client/req/policy/PolicyClient.java index 43209b299..68d8529ce 100644 --- a/src/main/java/org/onap/clamp/clds/client/req/policy/PolicyClient.java +++ b/src/main/java/org/onap/clamp/clds/client/req/policy/PolicyClient.java @@ -65,7 +65,6 @@ import org.onap.policy.api.PolicyType; import org.onap.policy.api.PushPolicyParameters; import org.onap.policy.api.RuleProvider; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.context.ApplicationContext; import org.springframework.context.annotation.Primary; import org.springframework.stereotype.Component; @@ -76,22 +75,23 @@ import org.springframework.stereotype.Component; @Primary public class PolicyClient { - protected PolicyEngine policyEngine; - protected static final String LOG_POLICY_PREFIX = "Response is "; - protected static final EELFLogger logger = EELFManager.getInstance().getLogger(PolicyClient.class); - protected static final EELFLogger metricsLogger = EELFManager.getInstance().getMetricsLogger(); - public static final String POLICY_MSTYPE_PROPERTY_NAME = "policy.ms.type"; - public static final String POLICY_ONAPNAME_PROPERTY_NAME = "policy.onap.name"; - public static final String POLICY_BASENAME_PREFIX_PROPERTY_NAME = "policy.base.policyNamePrefix"; - public static final String POLICY_OP_NAME_PREFIX_PROPERTY_NAME = "policy.op.policyNamePrefix"; + private PolicyEngine policyEngine; + private static final String LOG_POLICY_PREFIX = "Response is "; + private static final EELFLogger logger = EELFManager.getInstance().getLogger(PolicyClient.class); + private static final EELFLogger metricsLogger = EELFManager.getInstance().getMetricsLogger(); + private static final String POLICY_MSTYPE_PROPERTY_NAME = "policy.ms.type"; + private static final String POLICY_ONAPNAME_PROPERTY_NAME = "policy.onap.name"; + private static final String POLICY_BASENAME_PREFIX_PROPERTY_NAME = "policy.base.policyNamePrefix"; + private static final String POLICY_OP_NAME_PREFIX_PROPERTY_NAME = "policy.op.policyNamePrefix"; public static final String POLICY_MS_NAME_PREFIX_PROPERTY_NAME = "policy.ms.policyNamePrefix"; - public static final String POLICY_OP_TYPE_PROPERTY_NAME = "policy.op.type"; - public static final String TOSCA_FILE_TEMP_PATH = "tosca.filePath"; + private static final String POLICY_OP_TYPE_PROPERTY_NAME = "policy.op.type"; + private static final String TOSCA_FILE_TEMP_PATH = "tosca.filePath"; + private static final String POLICY_COMMUNICATION_LOG_MESSAGE = "Exception occurred during policy communication"; + private static final String POLICY_COMMUNICATION_EXC_MESSAGE = "Exception while communicating with Policy"; + private static final String POLICY = "Policy"; @Autowired - protected ApplicationContext appContext; - @Autowired - protected ClampProperties refProp; + private ClampProperties refProp; @Autowired private PolicyConfiguration policyConfiguration; @@ -274,12 +274,12 @@ public class PolicyClient { if ((PolicyClass.Decision.equals(policyParameters.getPolicyClass()) && !checkDecisionPolicyExists(prop)) || (PolicyClass.Config.equals(policyParameters.getPolicyClass()) && !checkPolicyExists(prop, policyPrefix, policyNameWithPrefix))) { - LoggingUtils.setTargetContext("Policy", "createPolicy"); + LoggingUtils.setTargetContext(POLICY, "createPolicy"); logger.info("Attempting to create policy for action=" + prop.getActionCd()); response = getPolicyEngine().createPolicy(policyParameters); responseMessage = response.getResponseMessage(); } else { - LoggingUtils.setTargetContext("Policy", "updatePolicy"); + LoggingUtils.setTargetContext(POLICY, "updatePolicy"); logger.info("Attempting to update policy for action=" + prop.getActionCd()); response = getPolicyEngine().updatePolicy(policyParameters); responseMessage = response.getResponseMessage(); @@ -287,8 +287,8 @@ public class PolicyClient { } catch (Exception e) { LoggingUtils.setResponseContext("900", "Policy send failed", this.getClass().getName()); LoggingUtils.setErrorContext("900", "Policy send error"); - logger.error("Exception occurred during policy communication", e); - throw new PolicyClientException("Exception while communicating with Policy", e); + logger.error(POLICY_COMMUNICATION_LOG_MESSAGE, e); + throw new PolicyClientException(POLICY_COMMUNICATION_EXC_MESSAGE, e); } logger.info(LOG_POLICY_PREFIX + responseMessage); LoggingUtils.setTimeContext(startTime, new Date()); @@ -329,7 +329,7 @@ public class PolicyClient { PolicyChangeResponse response; String responseMessage = ""; try { - LoggingUtils.setTargetContext("Policy", "pushPolicy"); + LoggingUtils.setTargetContext(POLICY, "pushPolicy"); logger.info("Attempting to push policy..."); response = getPolicyEngine().pushPolicy(pushPolicyParameters); if (response != null) { @@ -338,8 +338,8 @@ public class PolicyClient { } catch (Exception e) { LoggingUtils.setResponseContext("900", "Policy push failed", this.getClass().getName()); LoggingUtils.setErrorContext("900", "Policy push error"); - logger.error("Exception occurred during policy communication", e); - throw new PolicyClientException("Exception while communicating with Policy", e); + logger.error(POLICY_COMMUNICATION_LOG_MESSAGE, e); + throw new PolicyClientException(POLICY_COMMUNICATION_EXC_MESSAGE, e); } logger.info(LOG_POLICY_PREFIX + responseMessage); if (response != null && (response.getResponseCode() == 200 || response.getResponseCode() == 204)) { @@ -466,8 +466,8 @@ public class PolicyClient { deletePolicyResponse = deletePolicy(prop, DictionaryType.Decision.toString(), null); } } catch (Exception e) { - logger.error("Exception occurred during policy communication", e); - throw new PolicyClientException("Exception while communicating with Policy", e); + logger.error(POLICY_COMMUNICATION_LOG_MESSAGE, e); + throw new PolicyClientException(POLICY_COMMUNICATION_EXC_MESSAGE, e); } return deletePolicyResponse; } @@ -492,8 +492,8 @@ public class PolicyClient { deletePolicyResponse = deletePolicy(prop, policyType, null); } } catch (Exception e) { - logger.error("Exception occurred during policy communication", e); - throw new PolicyClientException("Exception while communicating with Policy", e); + logger.error(POLICY_COMMUNICATION_LOG_MESSAGE, e); + throw new PolicyClientException(POLICY_COMMUNICATION_EXC_MESSAGE, e); } return deletePolicyResponse; } @@ -650,8 +650,8 @@ public class PolicyClient { } catch (Exception e) { LoggingUtils.setResponseContext("900", "Policy Model import failed", this.getClass().getName()); LoggingUtils.setErrorContext("900", "Policy Model import error"); - logger.error("Exception occurred during policy communication", e); - throw new PolicyClientException("Exception while communicating with Policy", e); + logger.error(POLICY_COMMUNICATION_LOG_MESSAGE, e); + throw new PolicyClientException(POLICY_COMMUNICATION_EXC_MESSAGE, e); } logger.info(LOG_POLICY_PREFIX + responseMessage); if (response != null && (response.getResponseCode() == 200 || response.getResponseCode() == 204)) { diff --git a/src/main/java/org/onap/clamp/clds/sdc/controller/installer/BlueprintParser.java b/src/main/java/org/onap/clamp/clds/sdc/controller/installer/BlueprintParser.java index 5dcffd61c..809904f22 100644 --- a/src/main/java/org/onap/clamp/clds/sdc/controller/installer/BlueprintParser.java +++ b/src/main/java/org/onap/clamp/clds/sdc/controller/installer/BlueprintParser.java @@ -89,7 +89,7 @@ public class BlueprintParser { } String msName = theBiggestMicroServiceKey.toLowerCase().contains(HOLMES_PREFIX) ? HOLMES : TCA; return Collections - .singletonList(new MicroService(msName, "onap.policy.monitoring.cdap.tca.hi.lo.app", "", "", "")); + .singletonList(new MicroService(msName, "onap.policies.monitoring.cdap.tca.hi.lo.app", "", "", "")); } String getName(Entry<String, JsonElement> entry) { 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 f1344723e..595b1805e 100644 --- a/src/main/java/org/onap/clamp/clds/tosca/ToscaSchemaConstants.java +++ b/src/main/java/org/onap/clamp/clds/tosca/ToscaSchemaConstants.java @@ -58,7 +58,7 @@ public class ToscaSchemaConstants { public static final String PATTERN = "pattern"; // Prefix for policy nodes - public static final String POLICY_NODE = "onap.policy."; + public static final String POLICY_NODE = "onap.policies."; // Prefix for data nodes public static final String POLICY_DATA = "onap.datatypes."; diff --git a/src/main/java/org/onap/clamp/flow/log/FlowLogOperation.java b/src/main/java/org/onap/clamp/flow/log/FlowLogOperation.java index ae96f6a8c..3da93b26a 100644 --- a/src/main/java/org/onap/clamp/flow/log/FlowLogOperation.java +++ b/src/main/java/org/onap/clamp/flow/log/FlowLogOperation.java @@ -52,16 +52,15 @@ public class FlowLogOperation { /** * Generate the entry log. * - * @param serviceDesc The service description - * the loop name + * @param serviceDesc + * The service description the loop name */ public void startLog(Exchange exchange, String serviceDesc) { util.entering(request, serviceDesc); - exchange.getIn().setHeader(ONAPLogConstants.Headers.REQUEST_ID, - util.getProperties(ONAPLogConstants.MDCs.REQUEST_ID)); - exchange.getIn().setHeader(ONAPLogConstants.Headers.INVOCATION_ID, + exchange.setProperty(ONAPLogConstants.Headers.REQUEST_ID, util.getProperties(ONAPLogConstants.MDCs.REQUEST_ID)); + exchange.setProperty(ONAPLogConstants.Headers.INVOCATION_ID, util.getProperties(ONAPLogConstants.MDCs.INVOCATION_ID)); - exchange.getIn().setHeader(ONAPLogConstants.Headers.PARTNER_NAME, + exchange.setProperty(ONAPLogConstants.Headers.PARTNER_NAME, util.getProperties(ONAPLogConstants.MDCs.PARTNER_NAME)); } @@ -69,18 +68,17 @@ public class FlowLogOperation { * Generate the exiting log. */ public void endLog() { - util.exiting(HttpStatus.OK.toString(), "Successful", Level.INFO, - ONAPLogConstants.ResponseStatus.COMPLETED); + util.exiting(HttpStatus.OK.toString(), "Successful", Level.INFO, ONAPLogConstants.ResponseStatus.COMPLETED); } /** * Generate the error exiting log. */ public void errorLog() { - util.exiting(HttpStatus.INTERNAL_SERVER_ERROR.toString(), "Failed", - Level.INFO, ONAPLogConstants.ResponseStatus.ERROR); + util.exiting(HttpStatus.INTERNAL_SERVER_ERROR.toString(), "Failed", Level.INFO, + ONAPLogConstants.ResponseStatus.ERROR); } - + /** * Generate the error exiting log. */ diff --git a/src/main/resources/application-noaaf.properties b/src/main/resources/application-noaaf.properties index 89bd8a558..6124f10d8 100644 --- a/src/main/resources/application-noaaf.properties +++ b/src/main/resources/application-noaaf.properties @@ -135,7 +135,7 @@ clamp.config.dcae.deployment.template=classpath:/clds/templates/dcae-deployment- # # # Configuration Settings for Policy Engine Components -clamp.config.policy.url=http://policy.api.simpledemo.onap.org:8081 +clamp.config.policy.url=http4://policy.api.simpledemo.onap.org:8081 clamp.config.policy.userName=test clamp.config.policy.password=test clamp.config.policy.pdpUrl1=http://policy.api.simpledemo.onap.org:8081/pdp/ , testpdp, alpha123 diff --git a/src/main/resources/application.properties b/src/main/resources/application.properties index 38350567b..123443175 100644 --- a/src/main/resources/application.properties +++ b/src/main/resources/application.properties @@ -152,7 +152,7 @@ clamp.config.dcae.deployment.template=classpath:/clds/templates/dcae-deployment- # # # Configuration Settings for Policy Engine Components -clamp.config.policy.url=http://policy.api.simpledemo.onap.org:8081 +clamp.config.policy.url=http4://policy.api.simpledemo.onap.org:8081 clamp.config.policy.userName=test clamp.config.policy.password=test clamp.config.policy.pdpUrl1=http://policy.api.simpledemo.onap.org:8081/pdp/ , testpdp, alpha123 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 6bd1132cc..5c5f122cd 100644 --- a/src/main/resources/clds/camel/rest/clamp-api-v2.xml +++ b/src/main/resources/clds/camel/rest/clamp-api-v2.xml @@ -5,8 +5,9 @@ outType="java.lang.String[]" produces="application/json"> <route> - <doTry> - <to + <removeHeaders pattern="*" /> + <doTry> + <to uri="bean:org.onap.clamp.flow.log.FlowLogOperation?method=startLog(*, 'Get All ClosedLoop')" /> <to uri="bean:org.onap.clamp.authorization.AuthorizationController?method=authorize(*,'cl','','read')" /> @@ -14,14 +15,15 @@ uri="bean:org.onap.clamp.loop.LoopController?method=getLoopNames()" /> <to uri="bean:org.onap.clamp.flow.log.FlowLogOperation?method=endLog()" /> - <doCatch> - <exception>java.lang.Exception</exception> - <handled> - <constant>false</constant> - </handled> - <to uri="bean:org.onap.clamp.flow.log.FlowLogOperation?method=errorLog()" /> - </doCatch> - </doTry> + <doCatch> + <exception>java.lang.Exception</exception> + <handled> + <constant>false</constant> + </handled> + <to + uri="bean:org.onap.clamp.flow.log.FlowLogOperation?method=errorLog()" /> + </doCatch> + </doTry> </route> </get> <get @@ -29,8 +31,11 @@ outType="org.onap.clamp.loop.Loop" produces="application/json"> <route> + <removeHeaders + pattern="*" + excludePattern="loopName" /> <doTry> - <to + <to uri="bean:org.onap.clamp.flow.log.FlowLogOperation?method=startLog(*, 'Get Closed Loop')" /> <to uri="bean:org.onap.clamp.authorization.AuthorizationController?method=authorize(*,'cl','','read')" /> @@ -38,14 +43,15 @@ uri="bean:org.onap.clamp.loop.LoopController?method=getLoop(${header.loopName})" /> <to uri="bean:org.onap.clamp.flow.log.FlowLogOperation?method=endLog()" /> - <doCatch> - <exception>java.lang.Exception</exception> - <handled> - <constant>false</constant> - </handled> - <to uri="bean:org.onap.clamp.flow.log.FlowLogOperation?method=errorLog()" /> - </doCatch> - </doTry> + <doCatch> + <exception>java.lang.Exception</exception> + <handled> + <constant>false</constant> + </handled> + <to + uri="bean:org.onap.clamp.flow.log.FlowLogOperation?method=errorLog()" /> + </doCatch> + </doTry> </route> </get> <get @@ -53,8 +59,11 @@ outType="java.lang.String" produces="application/xml"> <route> + <removeHeaders + pattern="*" + excludePattern="loopName" /> <doTry> - <to + <to uri="bean:org.onap.clamp.flow.log.FlowLogOperation?method=startLog(*, 'Get SVG Representation')" /> <to uri="bean:org.onap.clamp.authorization.AuthorizationController?method=authorize(*,'cl','','read')" /> @@ -62,14 +71,15 @@ uri="bean:org.onap.clamp.loop.LoopController?method=getSVGRepresentation(${header.loopName})" /> <to uri="bean:org.onap.clamp.flow.log.FlowLogOperation?method=endLog()" /> - <doCatch> - <exception>java.lang.Exception</exception> - <handled> - <constant>false</constant> - </handled> - <to uri="bean:org.onap.clamp.flow.log.FlowLogOperation?method=errorLog()" /> - </doCatch> - </doTry> + <doCatch> + <exception>java.lang.Exception</exception> + <handled> + <constant>false</constant> + </handled> + <to + uri="bean:org.onap.clamp.flow.log.FlowLogOperation?method=errorLog()" /> + </doCatch> + </doTry> </route> </get> @@ -80,8 +90,11 @@ outType="org.onap.clamp.loop.Loop" produces="application/json"> <route> + <removeHeaders + pattern="*" + excludePattern="loopName" /> <doTry> - <to + <to uri="bean:org.onap.clamp.flow.log.FlowLogOperation?method=startLog(*, 'Update the global properties')" /> <to uri="bean:org.onap.clamp.authorization.AuthorizationController?method=authorize(*,'cl','','update')" /> @@ -92,17 +105,18 @@ <to uri="bean:org.onap.clamp.loop.LoopController?method=updateGlobalPropertiesJson(${header.loopName},${header.GlobalPropertiesJson})" /> <to - uri="bean:org.onap.clamp.loop.log.LoopLogService?method=addLog('Global Properties UPDATED','INFO',${header.LoopObject})" /> + uri="bean:org.onap.clamp.loop.log.LoopLogService?method=addLog('Global Properties UPDATED','INFO',${exchangeProperty[loopObject]})" /> <to uri="bean:org.onap.clamp.flow.log.FlowLogOperation?method=endLog()" /> - <doCatch> - <exception>java.lang.Exception</exception> - <handled> - <constant>false</constant> - </handled> - <to uri="bean:org.onap.clamp.flow.log.FlowLogOperation?method=errorLog()" /> - </doCatch> - </doTry> + <doCatch> + <exception>java.lang.Exception</exception> + <handled> + <constant>false</constant> + </handled> + <to + uri="bean:org.onap.clamp.flow.log.FlowLogOperation?method=errorLog()" /> + </doCatch> + </doTry> </route> </post> <post @@ -112,8 +126,11 @@ outType="org.onap.clamp.loop.Loop" produces="application/json"> <route> + <removeHeaders + pattern="*" + excludePattern="loopName" /> <doTry> - <to + <to uri="bean:org.onap.clamp.flow.log.FlowLogOperation?method=startLog(*, 'Update operational policies')" /> <to uri="bean:org.onap.clamp.authorization.AuthorizationController?method=authorize(*,'cl','','update')" /> @@ -124,17 +141,18 @@ <to uri="bean:org.onap.clamp.loop.LoopController?method=updateOperationalPolicies(${header.loopName},${header.OperationalPoliciesArray})" /> <to - uri="bean:org.onap.clamp.loop.log.LoopLogService?method=addLog('Operational and Guard policies UPDATED','INFO',${header.LoopObject})" /> + uri="bean:org.onap.clamp.loop.log.LoopLogService?method=addLog('Operational and Guard policies UPDATED','INFO',${exchangeProperty[loopObject]})" /> <to uri="bean:org.onap.clamp.flow.log.FlowLogOperation?method=endLog()" /> - <doCatch> - <exception>java.lang.Exception</exception> - <handled> - <constant>false</constant> - </handled> - <to uri="bean:org.onap.clamp.flow.log.FlowLogOperation?method=errorLog()" /> - </doCatch> - </doTry> + <doCatch> + <exception>java.lang.Exception</exception> + <handled> + <constant>false</constant> + </handled> + <to + uri="bean:org.onap.clamp.flow.log.FlowLogOperation?method=errorLog()" /> + </doCatch> + </doTry> </route> </post> <post @@ -144,30 +162,34 @@ outType="org.onap.clamp.policy.microservice.MicroServicePolicy" produces="application/json"> <route> + <removeHeaders + pattern="*" + excludePattern="loopName" /> <doTry> - <to + <to uri="bean:org.onap.clamp.flow.log.FlowLogOperation?method=startLog(*, 'Update Microservice policies')" /> <to uri="bean:org.onap.clamp.authorization.AuthorizationController?method=authorize(*,'cl','','update')" /> - <setHeader headerName="MicroServicePolicyObject"> + <setProperty propertyName="MicroServicePolicyObject"> <simple>${body}</simple> - </setHeader> + </setProperty> <to uri="direct:load-loop" /> <to - uri="bean:org.onap.clamp.loop.LoopController?method=updateMicroservicePolicy(${header.loopName},${header.MicroServicePolicyObject})" /> + uri="bean:org.onap.clamp.loop.LoopController?method=updateMicroservicePolicy(${header.loopName},${exchangeProperty[MicroServicePolicyObject]})" /> <to - uri="bean:org.onap.clamp.loop.log.LoopLogService?method=addLog('Micro Service policies UPDATED','INFO',${header.LoopObject})" /> + uri="bean:org.onap.clamp.loop.log.LoopLogService?method=addLog('Micro Service policies UPDATED','INFO',${exchangeProperty[loopObject]})" /> <to uri="bean:org.onap.clamp.flow.log.FlowLogOperation?method=endLog()" /> - <doCatch> - <exception>java.lang.Exception</exception> - <handled> - <constant>false</constant> - </handled> - <to uri="bean:org.onap.clamp.flow.log.FlowLogOperation?method=errorLog()" /> - </doCatch> - </doTry> + <doCatch> + <exception>java.lang.Exception</exception> + <handled> + <constant>false</constant> + </handled> + <to + uri="bean:org.onap.clamp.flow.log.FlowLogOperation?method=errorLog()" /> + </doCatch> + </doTry> </route> </post> <put @@ -175,8 +197,11 @@ outType="org.onap.clamp.loop.Loop" produces="application/json"> <route> + <removeHeaders + pattern="*" + excludePattern="loopName" /> <doTry> - <to + <to uri="bean:org.onap.clamp.flow.log.FlowLogOperation?method=startLog(*, 'Deploy the closed loop')" /> <to uri="bean:org.onap.clamp.authorization.AuthorizationController?method=authorize(*,'cl','','update')" /> @@ -184,14 +209,15 @@ uri="bean:org.onap.clamp.operation.LoopOperation?method=deployLoop(*,${header.loopName})" /> <to uri="bean:org.onap.clamp.flow.log.FlowLogOperation?method=endLog()" /> - <doCatch> - <exception>java.lang.Exception</exception> - <handled> - <constant>false</constant> - </handled> - <to uri="bean:org.onap.clamp.flow.log.FlowLogOperation?method=errorLog()" /> - </doCatch> - </doTry> + <doCatch> + <exception>java.lang.Exception</exception> + <handled> + <constant>false</constant> + </handled> + <to + uri="bean:org.onap.clamp.flow.log.FlowLogOperation?method=errorLog()" /> + </doCatch> + </doTry> </route> </put> <put @@ -199,8 +225,11 @@ outType="org.onap.clamp.loop.Loop" produces="application/json"> <route> + <removeHeaders + pattern="*" + excludePattern="loopName" /> <doTry> - <to + <to uri="bean:org.onap.clamp.flow.log.FlowLogOperation?method=startLog(*, 'Undeploy the closed loop')" /> <to uri="bean:org.onap.clamp.authorization.AuthorizationController?method=authorize(*,'cl','','update')" /> @@ -208,14 +237,15 @@ uri="bean:org.onap.clamp.operation.LoopOperation?method=unDeployLoop(${header.loopName})" /> <to uri="bean:org.onap.clamp.flow.log.FlowLogOperation?method=endLog()" /> - <doCatch> - <exception>java.lang.Exception</exception> - <handled> - <constant>false</constant> - </handled> - <to uri="bean:org.onap.clamp.flow.log.FlowLogOperation?method=errorLog()" /> - </doCatch> - </doTry> + <doCatch> + <exception>java.lang.Exception</exception> + <handled> + <constant>false</constant> + </handled> + <to + uri="bean:org.onap.clamp.flow.log.FlowLogOperation?method=errorLog()" /> + </doCatch> + </doTry> </route> </put> <put @@ -223,45 +253,42 @@ outType="org.onap.clamp.loop.Loop" produces="application/json"> <route> + <removeHeaders + pattern="*" + excludePattern="loopName" /> <doTry> <log loggingLevel="INFO" message="Receive STOP request for loop: ${header.loopName}" /> - <to + <to uri="bean:org.onap.clamp.flow.log.FlowLogOperation?method=startLog('Stop the closed loop')" /> <to uri="bean:org.onap.clamp.authorization.AuthorizationController?method=authorize(*,'cl','','update')" /> <to uri="direct:load-loop" /> - - <doTry> - <to uri="direct:remove-all-policy-from-active-pdp-group" /> - <doCatch> - <exception>java.lang.Exception</exception> - <handled> - <constant>false</constant> - </handled> - <to uri="bean:org.onap.clamp.flow.log.FlowLogOperation?method=invokeReturnLog()" /> - </doCatch> - </doTry> - - + <to uri="direct:remove-all-policy-from-active-pdp-group" /> <log loggingLevel="INFO" message="STOP request successfully executed for loop: ${body}" /> <to - uri="bean:org.onap.clamp.loop.log.LoopLogService?method=addLog('STOP request successfully executed','INFO',${header.LoopObject})" /> + uri="bean:org.onap.clamp.loop.log.LoopLogService?method=addLog('STOP request successfully executed','INFO',${exchangeProperty[loopObject]})" /> <to uri="bean:org.onap.clamp.loop.LoopController?method=getLoop(${header.loopName})" /> <to uri="bean:org.onap.clamp.flow.log.FlowLogOperation?method=endLog()" /> - <doCatch> - <exception>java.lang.Exception</exception> - <handled> - <constant>false</constant> - </handled> - <to uri="bean:org.onap.clamp.flow.log.FlowLogOperation?method=errorLog()" /> - </doCatch> - </doTry> + <doCatch> + <exception>java.lang.Exception</exception> + <handled> + <constant>false</constant> + </handled> + <to + uri="bean:org.onap.clamp.flow.log.FlowLogOperation?method=errorLog()" /> + <log + loggingLevel="ERROR" + message="STOP request failed for loop: $${header.loopName}" /> + <to + uri="bean:org.onap.clamp.loop.log.LoopLogService?method=addLog('STOP request failed','ERROR',${exchangeProperty[loopObject]})" /> + </doCatch> + </doTry> </route> </put> <put @@ -269,44 +296,44 @@ outType="org.onap.clamp.loop.Loop" produces="application/json"> <route> + <removeHeaders + pattern="*" + excludePattern="loopName" /> <doTry> <log loggingLevel="INFO" message="Receive START request for loop: ${header.loopName}" /> - <to + <to uri="bean:org.onap.clamp.flow.log.FlowLogOperation?method=startLog('Start the closed loop')" /> <to uri="bean:org.onap.clamp.authorization.AuthorizationController?method=authorize(*,'cl','','update')" /> <to uri="direct:load-loop" /> - - <doTry> - <to uri="direct:add-all-to-active-pdp-group" /> - <doCatch> - <exception>java.lang.Exception</exception> - <handled> - <constant>false</constant> - </handled> - <to uri="bean:org.onap.clamp.flow.log.FlowLogOperation?method=invokeReturnLog()" /> - </doCatch> - </doTry> + + <to uri="direct:add-all-to-active-pdp-group" /> <log loggingLevel="INFO" - message="START request successfully executed for loop: ${body}" /> + message="START request successfully executed for loop: ${header.loopName}" /> <to - uri="bean:org.onap.clamp.loop.log.LoopLogService?method=addLog('START request successfully executed','INFO',${header.LoopObject})" /> + uri="bean:org.onap.clamp.loop.log.LoopLogService?method=addLog('START request successfully executed','INFO',${exchangeProperty[loopObject]})" /> <to uri="bean:org.onap.clamp.loop.LoopController?method=getLoop(${header.loopName})" /> <to uri="bean:org.onap.clamp.flow.log.FlowLogOperation?method=endLog()" /> - <doCatch> - <exception>java.lang.Exception</exception> - <handled> - <constant>false</constant> - </handled> - <to uri="bean:org.onap.clamp.flow.log.FlowLogOperation?method=errorLog()" /> - </doCatch> - </doTry> + <doCatch> + <exception>java.lang.Exception</exception> + <handled> + <constant>false</constant> + </handled> + <to + uri="bean:org.onap.clamp.flow.log.FlowLogOperation?method=errorLog()" /> + <log + loggingLevel="ERROR" + message="START request failed for loop: ${header.loopName}" /> + <to + uri="bean:org.onap.clamp.loop.log.LoopLogService?method=addLog('START request failed','INFO',${exchangeProperty[loopObject]})" /> + </doCatch> + </doTry> </route> </put> <put @@ -314,301 +341,189 @@ outType="org.onap.clamp.loop.Loop" produces="application/json"> <route> + <removeHeaders + pattern="*" + excludePattern="loopName" /> <doTry> <log loggingLevel="INFO" message="Receive SUBMIT request for loop: ${header.loopName}" /> - <to - uri="bean:org.onap.clamp.flow.log.FlowLogOperation?method=startLog(*, 'Submit the closed loop')" /> + <to + uri="bean:org.onap.clamp.flow.log.FlowLogOperation?method=startLog(*, 'Submit the closed loop')" /> <to uri="bean:org.onap.clamp.authorization.AuthorizationController?method=authorize(*,'cl','','update')" /> <to uri="direct:load-loop" /> <to - uri="bean:org.onap.clamp.loop.log.LoopLogService?method=addLog('Receive SUBMIT request','INFO',${header.LoopObject})" /> - <setHeader headerName="RaiseHttpExceptionFlag"> + uri="bean:org.onap.clamp.loop.log.LoopLogService?method=addLog('Receive SUBMIT request','INFO',${exchangeProperty[loopObject]})" /> + <setProperty propertyName="raiseHttpExceptionFlag"> <simple resultType="java.lang.Boolean">false</simple> - </setHeader> - - <doTry> - <to uri="direct:remove-all-policy-from-active-pdp-group" /> - <doCatch> - <exception>java.lang.Exception</exception> - <handled> - <constant>false</constant> - </handled> - <to uri="bean:org.onap.clamp.flow.log.FlowLogOperation?method=invokeReturnLog()" /> - </doCatch> - </doTry> - + </setProperty> + <to uri="direct:remove-all-policy-from-active-pdp-group" /> <log loggingLevel="INFO" - message="Processing all MICRO-SERVICES policies defined in loop ${header.LoopObject.getName()}" /> + message="Processing all MICRO-SERVICES policies defined in loop ${exchangeProperty[loopObject].getName()}" /> <split> - <simple>${header.LoopObject.getMicroServicePolicies()} + <simple>${exchangeProperty[loopObject].getMicroServicePolicies()} </simple> - <setHeader headerName="microServicePolicy"> + <setProperty propertyName="microServicePolicy"> <simple>${body}</simple> - </setHeader> + </setProperty> <log loggingLevel="INFO" - message="Processing Micro Service Policy: ${header.microServicePolicy.getName()}" /> - <setHeader headerName="RaiseHttpExceptionFlag"> + message="Processing Micro Service Policy: ${exchangeProperty[microServicePolicy].getName()}" /> + <setProperty propertyName="raiseHttpExceptionFlag"> <simple resultType="java.lang.Boolean">false</simple> - </setHeader> - - <doTry> - <to uri="direct:delete-micro-service-policy" /> - <doCatch> - <exception>java.lang.Exception</exception> - <handled> - <constant>false</constant> - </handled> - <to uri="bean:org.onap.clamp.flow.log.FlowLogOperation?method=invokeReturnLog()" /> - </doCatch> - </doTry> - - <doTry> - <to uri="direct:create-micro-service-policy" /> - <doCatch> - <exception>java.lang.Exception</exception> - <handled> - <constant>false</constant> - </handled> - <to uri="bean:org.onap.clamp.flow.log.FlowLogOperation?method=invokeReturnLog()" /> - </doCatch> - </doTry> - + </setProperty> + <to uri="direct:delete-micro-service-policy" /> + <to uri="direct:create-micro-service-policy" /> </split> <log loggingLevel="INFO" - message="Processing all OPERATIONAL policies defined in loop ${header.LoopObject.getName()}" /> + message="Processing all OPERATIONAL policies defined in loop ${exchangeProperty[loopObject].getName()}" /> <split> - <simple>${header.LoopObject.getOperationalPolicies()} + <simple>${exchangeProperty[loopObject].getOperationalPolicies()} </simple> - <setHeader headerName="operationalPolicy"> + <setProperty propertyName="operationalPolicy"> <simple>${body}</simple> - </setHeader> + </setProperty> <log loggingLevel="INFO" - message="Processing Operational Policy: ${header.operationalPolicy.getName()}" /> - <setHeader headerName="RaiseHttpExceptionFlag"> + message="Processing Operational Policy: ${exchangeProperty[operationalPolicy].getName()}" /> + <setProperty propertyName="raiseHttpExceptionFlag"> <simple resultType="java.lang.Boolean">false</simple> - </setHeader> + </setProperty> - <doTry> - <to uri="direct:delete-operational-policy" /> - <doCatch> - <exception>java.lang.Exception</exception> - <handled> - <constant>false</constant> - </handled> - <to uri="bean:org.onap.clamp.flow.log.FlowLogOperation?method=invokeReturnLog()" /> - </doCatch> - </doTry> + <to uri="direct:delete-operational-policy" /> + <to uri="direct:create-operational-policy" /> - <doTry> - <to uri="direct:create-operational-policy" /> - <doCatch> - <exception>java.lang.Exception</exception> - <handled> - <constant>false</constant> - </handled> - <to uri="bean:org.onap.clamp.flow.log.FlowLogOperation?method=invokeReturnLog()" /> - </doCatch> - </doTry> - - <log loggingLevel="INFO" - message="Processing all GUARD policies defined in loop ${header.LoopObject.getName()}" /> + message="Processing all GUARD policies defined in loop ${exchangeProperty[loopObject].getName()}" /> <split> - <simple>${header.operationalPolicy.createGuardPolicyPayloads().entrySet()} + <simple>${exchangeProperty[operationalPolicy].createGuardPolicyPayloads().entrySet()} </simple> - <setHeader headerName="guardPolicy"> + <setProperty propertyName="guardPolicy"> <simple>${body}</simple> - </setHeader> + </setProperty> <log loggingLevel="INFO" - message="Processing Guard Policy: ${header.guardPolicy.getKey()}" /> + message="Processing Guard Policy: ${exchangeProperty[guardPolicy].getKey()}" /> - <setHeader headerName="RaiseHttpExceptionFlag"> + <setProperty propertyName="raiseHttpExceptionFlag"> <simple resultType="java.lang.Boolean">false</simple> - </setHeader> - - <doTry> - <to uri="direct:delete-guard-policy" /> - <doCatch> - <exception>java.lang.Exception</exception> - <handled> - <constant>false</constant> - </handled> - <to uri="bean:org.onap.clamp.flow.log.FlowLogOperation?method=invokeReturnLog()" /> - </doCatch> - </doTry> - - <doTry> - <to uri="direct:create-guard-policy" /> - <doCatch> - <exception>java.lang.Exception</exception> - <handled> - <constant>false</constant> - </handled> - <to uri="bean:org.onap.clamp.flow.log.FlowLogOperation?method=invokeReturnLog()" /> - </doCatch> - </doTry> - + </setProperty> + <to uri="direct:delete-guard-policy" /> + <to uri="direct:create-guard-policy" /> </split> </split> - - - <doTry> - <to uri="direct:add-all-to-active-pdp-group" /> - <doCatch> - <exception>java.lang.Exception</exception> - <handled> - <constant>false</constant> - </handled> - <to uri="bean:org.onap.clamp.flow.log.FlowLogOperation?method=invokeReturnLog()" /> - </doCatch> - </doTry> - + <to uri="direct:add-all-to-active-pdp-group" /> <log loggingLevel="INFO" - message="SUBMIT request successfully executed for loop: ${body}" /> + message="SUBMIT request successfully executed for loop: ${header.loopName}" /> <to - uri="bean:org.onap.clamp.loop.log.LoopLogService?method=addLog('SUBMIT request successfully executed','INFO',${header.LoopObject})" /> + uri="bean:org.onap.clamp.loop.log.LoopLogService?method=addLog('SUBMIT request successfully executed','INFO',${exchangeProperty[loopObject]})" /> <to uri="bean:org.onap.clamp.loop.LoopController?method=getLoop(${header.loopName})" /> <to uri="bean:org.onap.clamp.flow.log.FlowLogOperation?method=endLog()" /> - <doCatch> - <exception>java.lang.Exception</exception> - <handled> - <constant>false</constant> - </handled> - <to uri="bean:org.onap.clamp.flow.log.FlowLogOperation?method=errorLog()" /> - </doCatch> - </doTry> + <doCatch> + <exception>java.lang.Exception</exception> + <handled> + <constant>false</constant> + </handled> + <to + uri="bean:org.onap.clamp.flow.log.FlowLogOperation?method=errorLog()" /> + <log + loggingLevel="ERROR" + message="SUBMIT request failed for loop: ${header.loopName}" /> + <to + uri="bean:org.onap.clamp.loop.log.LoopLogService?method=addLog('SUBMIT request failed','ERROR',${exchangeProperty[loopObject]})" /> + </doCatch> + </doTry> </route> </put> <put uri="/v2/loop/delete/{loopName}"> <route> + <removeHeaders + pattern="*" + excludePattern="loopName" /> <doTry> <log loggingLevel="INFO" message="Receive DELETE request for loop: ${header.loopName}" /> - <to + <to uri="bean:org.onap.clamp.flow.log.FlowLogOperation?method=startLog('Delete the closed loop')" /> <to uri="bean:org.onap.clamp.authorization.AuthorizationController?method=authorize(*,'cl','','update')" /> <to uri="direct:load-loop" /> <to - uri="bean:org.onap.clamp.loop.log.LoopLogService?method=addLog('Receive DELETE request','INFO',${header.LoopObject})" /> - - <doTry> - <to uri="direct:remove-all-policy-from-active-pdp-group" /> - <doCatch> - <exception>java.lang.Exception</exception> - <handled> - <constant>false</constant> - </handled> - <to uri="bean:org.onap.clamp.flow.log.FlowLogOperation?method=invokeReturnLog()" /> - </doCatch> - </doTry> - - + uri="bean:org.onap.clamp.loop.log.LoopLogService?method=addLog('Receive DELETE request','INFO',${exchangeProperty[loopObject]})" /> + <to uri="direct:remove-all-policy-from-active-pdp-group" /> <split> - <simple>${header.LoopObject.getMicroServicePolicies()} + <simple>${exchangeProperty[loopObject].getMicroServicePolicies()} </simple> - <setHeader headerName="microServicePolicy"> + <setProperty propertyName="microServicePolicy"> <simple>${body}</simple> - </setHeader> + </setProperty> <log loggingLevel="INFO" - message="Processing Micro Service Policy: ${header.microServicePolicy.getName()}" /> - - <doTry> - <to uri="direct:delete-micro-service-policy" /> - <doCatch> - <exception>java.lang.Exception</exception> - <handled> - <constant>false</constant> - </handled> - <to uri="bean:org.onap.clamp.flow.log.FlowLogOperation?method=invokeReturnLog()" /> - </doCatch> - </doTry> - + message="Processing Micro Service Policy: ${exchangeProperty[microServicePolicy].getName()}" /> + <to uri="direct:delete-micro-service-policy" /> </split> <log loggingLevel="INFO" - message="Processing all OPERATIONAL policies defined in loop ${header.LoopObject.getName()}" /> + message="Processing all OPERATIONAL policies defined in loop ${exchangeProperty[loopObject].getName()}" /> <split> - <simple>${header.LoopObject.getOperationalPolicies()} + <simple>${exchangeProperty[loopObject].getOperationalPolicies()} </simple> - <setHeader headerName="operationalPolicy"> + <setProperty propertyName="operationalPolicy"> <simple>${body}</simple> - </setHeader> + </setProperty> <log loggingLevel="INFO" - message="Processing Operational Policy: ${header.operationalPolicy.getName()}" /> - - <doTry> - <to uri="direct:delete-operational-policy" /> - <doCatch> - <exception>java.lang.Exception</exception> - <handled> - <constant>false</constant> - </handled> - <to uri="bean:org.onap.clamp.flow.log.FlowLogOperation?method=invokeReturnLog()" /> - </doCatch> - </doTry> - + message="Processing Operational Policy: ${exchangeProperty[operationalPolicy].getName()}" /> + <to uri="direct:delete-operational-policy" /> <log loggingLevel="INFO" - message="Processing all GUARD policies defined in loop ${header.LoopObject.getName()}" /> + message="Processing all GUARD policies defined in loop ${exchangeProperty[loopObject].getName()}" /> <split> - <simple>${header.operationalPolicy.createGuardPolicyPayloads().entrySet()} + <simple>${exchangeProperty[operationalPolicy].createGuardPolicyPayloads().entrySet()} </simple> - <setHeader headerName="guardPolicy"> + <setProperty propertyName="guardPolicy"> <simple>${body}</simple> - </setHeader> + </setProperty> <log loggingLevel="INFO" - message="Processing Guard Policy: ${header.guardPolicy.getKey()}" /> - - <doTry> - <to uri="direct:delete-guard-policy" /> - <doCatch> - <exception>java.lang.Exception</exception> - <handled> - <constant>false</constant> - </handled> - <to uri="bean:org.onap.clamp.flow.log.FlowLogOperation?method=invokeReturnLog()" /> - </doCatch> - </doTry> - + message="Processing Guard Policy: ${exchangeProperty[guardPolicy].getKey()}" /> + <to uri="direct:delete-guard-policy" /> </split> </split> <to uri="bean:org.onap.clamp.loop.log.LoopService?method=deleteLoop(${header.loopName})" /> <log loggingLevel="INFO" - message="DELETE request successfully executed for loop: ${body}" /> + 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',${header.LoopObject})" /> + 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> - <handled> - <constant>false</constant> - </handled> - <to uri="bean:org.onap.clamp.flow.log.FlowLogOperation?method=errorLog()" /> - </doCatch> - </doTry> + <doCatch> + <exception>java.lang.Exception</exception> + <handled> + <constant>false</constant> + </handled> + <to + uri="bean:org.onap.clamp.flow.log.FlowLogOperation?method=errorLog()" /> + <log + loggingLevel="ERROR" + message="DELETE request failed for loop: ${header.loopName}" /> + <to + uri="bean:org.onap.clamp.loop.log.LoopLogService?method=addLog('DELETE request failed','ERROR',${exchangeProperty[loopObject]})" /> + </doCatch> + </doTry> </route> </put> </rest> diff --git a/src/main/resources/clds/camel/routes/flexible-flow.xml b/src/main/resources/clds/camel/routes/flexible-flow.xml index 808e1d8a1..9ba030786 100644 --- a/src/main/resources/clds/camel/routes/flexible-flow.xml +++ b/src/main/resources/clds/camel/routes/flexible-flow.xml @@ -81,14 +81,14 @@ <setBody> <simple>${header.loopName}</simple> </setBody> - <setHeader headerName="LoopObject"> + <setProperty propertyName="loopObject"> <method ref="org.onap.clamp.loop.LoopService" method="getLoop" /> - </setHeader> + </setProperty> <when> - <simple>${header.LoopObject} == null</simple> + <simple>${exchangeProperty[loopObject]} == null</simple> <setHeader headerName="CamelHttpResponseCode"> <constant>404</constant> </setHeader> @@ -98,354 +98,409 @@ <stop /> </when> </route> + <route id="create-micro-service-policy"> <from uri="direct:create-micro-service-policy" /> - - <log - loggingLevel="INFO" - message="Creating Micro Service Policy: ${header.microServicePolicy.getName()}" /> - <to - uri="bean:org.onap.clamp.flow.log.FlowLogOperation?method=invokeLog('Policy', 'Create Micro Service Policy')" /> - <setBody> - <simple>${header.microServicePolicy.createPolicyPayload()} - </simple> - </setBody> - <setHeader headerName="CamelHttpMethod"> - <constant>POST</constant> - </setHeader> - <setHeader headerName="Content-Type"> - <constant>application/json</constant> - </setHeader> - <setHeader headerName="CamelHttpUri"> - <simple>{{clamp.config.policy.url}}/policy/api/v1/policyTypes/${header.microServicePolicy.getModelType()}/versions/1.0.0/policies - </simple> - </setHeader> - <setHeader headerName="X-ONAP-RequestID"> - <simple>${header.X-ONAP-REAUESTID} - </simple> - </setHeader> - <setHeader headerName="X-ONAP-InvocationID"> - <simple>${header.X-ONAP-InvocationID} - </simple> - </setHeader> - <setHeader headerName="X-ONAP-PartnerName"> - <simple>${header.X-ONAP-PartnerName} - </simple> - </setHeader> - <log - loggingLevel="INFO" - message="Endpoint to create microservice policy: ${header.CamelHttpMethod} ${header.CamelHttpUri}"></log> - <toD - uri="http4://policyhost:8085?mapHttpMessageHeaders=false&throwExceptionOnFailure=${header.RaiseHttpExceptionFlag}&httpClient.connectTimeout=10000&authUsername={{clamp.config.policy.userName}}&authPassword={{clamp.config.policy.password}}" /> - <to - uri="bean:org.onap.clamp.loop.log.LoopLogService?method=addLog('MicroService policy created successfully','INFO',${header.LoopObject})" /> - <to uri="direct:reset-raise-http-exception-flag" /> - <to uri="bean:org.onap.clamp.flow.log.FlowLogOperation?method=invokeReturnLog()" /> + <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.url}}/policy/api/v1/policytypes/${exchangeProperty[microServicePolicy].getModelType()}/versions/1.0.0/policies"></log> + <toD + uri="{{clamp.config.policy.url}}/policy/api/v1/policytypes/${exchangeProperty[microServicePolicy].getModelType()}/versions/1.0.0/policies?bridgeEndpoint=true&mapHttpMessageHeaders=false&throwExceptionOnFailure=${exchangeProperty[raiseHttpExceptionFlag]}&httpClient.connectTimeout=10000&authUsername={{clamp.config.policy.userName}}&authPassword={{clamp.config.policy.password}}" /> + <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> + <to uri="direct:dump-loop-log-http-response" /> + </doFinally> + </doTry> </route> + <route id="delete-micro-service-policy"> <from uri="direct:delete-micro-service-policy" /> - - <log - loggingLevel="INFO" - message="Deleting Micro Service Policy: ${header.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="CamelHttpUri"> - <simple>{{clamp.config.policy.url}}/policy/api/v1/policyTypes/${header.microServicePolicy.getModelType()}/versions/1.0.0/policies/${header.microServicePolicy.getName()} - </simple> - </setHeader> - <setHeader headerName="X-ONAP-RequestID"> - <simple>${header.X-ONAP-REAUESTID} - </simple> - </setHeader> - <setHeader headerName="X-ONAP-InvocationID"> - <simple>${header.X-ONAP-InvocationID} - </simple> - </setHeader> - <setHeader headerName="X-ONAP-PartnerName"> - <simple>${header.X-ONAP-PartnerName} - </simple> - </setHeader> - <log - loggingLevel="INFO" - message="Endpoint to delete microservice policy: ${header.CamelHttpMethod} ${header.CamelHttpUri}"></log> - <toD - uri="http4://policyhost:8085?mapHttpMessageHeaders=false&throwExceptionOnFailure=${header.RaiseHttpExceptionFlag}&httpClient.connectTimeout=10000&deleteWithBody=false&mapHttpMessageBody=false&mapHttpMessageFormUrlEncodedBody=false&authUsername={{clamp.config.policy.userName}}&authPassword={{clamp.config.policy.password}}" /> - <to - uri="bean:org.onap.clamp.loop.log.LoopLogService?method=addLog('MicroService policy deleted successfully','INFO',${header.LoopObject})" /> - <to uri="direct:reset-raise-http-exception-flag" /> - <to uri="bean:org.onap.clamp.flow.log.FlowLogOperation?method=invokeReturnLog()" /> + <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.url}}/policy/api/v1/policytypes/${exchangeProperty[microServicePolicy].getModelType()}/versions/1.0.0/policies/${exchangeProperty[microServicePolicy].getName()}"></log> + <toD + uri="{{clamp.config.policy.url}}/policy/api/v1/policytypes/${exchangeProperty[microServicePolicy].getModelType()}/versions/1.0.0/policies/${exchangeProperty[microServicePolicy].getName()}?bridgeEndpoint=true&mapHttpMessageHeaders=false&throwExceptionOnFailure=${exchangeProperty[raiseHttpExceptionFlag]}&httpClient.connectTimeout=10000&deleteWithBody=false&mapHttpMessageBody=false&mapHttpMessageFormUrlEncodedBody=false&authUsername={{clamp.config.policy.userName}}&authPassword={{clamp.config.policy.password}}" /> + + <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> + <to uri="direct:dump-loop-log-http-response" /> + </doFinally> + </doTry> </route> <route id="create-operational-policy"> <from uri="direct:create-operational-policy" /> - - <log - loggingLevel="INFO" - message="Creating Operational Policy: ${header.operationalPolicy.getName()}" /> - <to - uri="bean:org.onap.clamp.flow.log.FlowLogOperation?method=invokeLog('Policy', 'Create Operational Policy')" /> - <setBody> - <simple>${header.operationalPolicy.createPolicyPayload()} - </simple> - </setBody> - <setHeader headerName="CamelHttpMethod"> - <constant>POST</constant> - </setHeader> - <setHeader headerName="Content-Type"> - <constant>application/yaml; legacy-version</constant> - </setHeader> - <setHeader headerName="CamelHttpUri"> - <simple>{{clamp.config.policy.url}}/policy/api/v1/policyTypes/onap.policies.controloop.operational/versions/1.0.0/policies - </simple> - </setHeader> - <setHeader headerName="X-ONAP-RequestID"> - <simple>${header.X-ONAP-REAUESTID} - </simple> - </setHeader> - <setHeader headerName="X-ONAP-InvocationID"> - <simple>${header.X-ONAP-InvocationID} - </simple> - </setHeader> - <setHeader headerName="X-ONAP-PartnerName"> - <simple>${header.X-ONAP-PartnerName} - </simple> - </setHeader> - <log - loggingLevel="INFO" - message="Endpoint to create operational policy: ${header.CamelHttpMethod} ${header.CamelHttpUri}"></log> - <toD - uri="http4://policyhost:8085?mapHttpMessageHeaders=false&throwExceptionOnFailure=${header.RaiseHttpExceptionFlag}&httpClient.connectTimeout=10000&authUsername={{clamp.config.policy.userName}}&authPassword={{clamp.config.policy.password}}" /> - <to - uri="bean:org.onap.clamp.loop.log.LoopLogService?method=addLog('Operational policy created successfully','INFO',${header.LoopObject})" /> - <to uri="direct:reset-raise-http-exception-flag" /> - <to uri="bean:org.onap.clamp.flow.log.FlowLogOperation?method=invokeReturnLog()" /> + <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/yaml; vnd.onap.operational</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.url}}/policy/api/v1/policytypes/onap.policy.controlloop.operational/versions/1.0.0/policies"></log> + <toD + uri="{{clamp.config.policy.url}}/policy/api/v1/policytypes/onap.policy.controlloop.operational/versions/1.0.0/policies?bridgeEndpoint=true&mapHttpMessageHeaders=false&throwExceptionOnFailure=${exchangeProperty[raiseHttpExceptionFlag]}&httpClient.connectTimeout=10000&authUsername={{clamp.config.policy.userName}}&authPassword={{clamp.config.policy.password}}" /> + <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> + <to uri="direct:dump-loop-log-http-response" /> + </doFinally> + </doTry> </route> + <route id="delete-operational-policy"> <from uri="direct:delete-operational-policy" /> - - <log - loggingLevel="INFO" - message="Deleting Operational Policy: ${header.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="CamelHttpUri"> - <simple>{{clamp.config.policy.url}}/policy/api/v1/policyTypes/onap.policies.controloop.operational/versions/1.0.0/policies/${header.operationalPolicy.getName()} - </simple> - </setHeader> - <setHeader headerName="X-ONAP-RequestID"> - <simple>${header.X-ONAP-REAUESTID} - </simple> - </setHeader> - <setHeader headerName="X-ONAP-InvocationID"> - <simple>${header.X-ONAP-InvocationID} - </simple> - </setHeader> - <setHeader headerName="X-ONAP-PartnerName"> - <simple>${header.X-ONAP-PartnerName} - </simple> - </setHeader> - <log - loggingLevel="INFO" - message="Endpoint to delete operational policy: ${header.CamelHttpMethod} ${header.CamelHttpUri}"></log> - <toD - uri="http4://policyhost:8085?mapHttpMessageHeaders=false&throwExceptionOnFailure=${header.RaiseHttpExceptionFlag}&httpClient.connectTimeout=10000&deleteWithBody=false&mapHttpMessageBody=false&mapHttpMessageFormUrlEncodedBody=false&authUsername={{clamp.config.policy.userName}}&authPassword={{clamp.config.policy.password}}" /> - <to - uri="bean:org.onap.clamp.loop.log.LoopLogService?method=addLog('Operational policy deleted successfully','INFO',${header.LoopObject})" /> - <to uri="direct:reset-raise-http-exception-flag" /> - <to uri="bean:org.onap.clamp.flow.log.FlowLogOperation?method=invokeReturnLog()" /> + <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.url}}/policy/api/v1/policytypes/onap.policy.controlloop.operational/versions/1.0.0/policies/${exchangeProperty[operationalPolicy].getName()}"></log> + <toD + uri="{{clamp.config.policy.url}}/policy/api/v1/policytypes/onap.policy.controlloop.operational/versions/1.0.0/policies/${exchangeProperty[operationalPolicy].getName()}?bridgeEndpoint=true&mapHttpMessageHeaders=false&throwExceptionOnFailure=${exchangeProperty[raiseHttpExceptionFlag]}&httpClient.connectTimeout=10000&deleteWithBody=false&mapHttpMessageBody=false&mapHttpMessageFormUrlEncodedBody=false&authUsername={{clamp.config.policy.userName}}&authPassword={{clamp.config.policy.password}}" /> + <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> + <to uri="direct:dump-loop-log-http-response" /> + </doFinally> + </doTry> </route> <route id="create-guard-policy"> <from uri="direct:create-guard-policy" /> - - <log - loggingLevel="INFO" - message="Creating Guard Policy: ${header.guardPolicy.getKey()}" /> - <to - uri="bean:org.onap.clamp.flow.log.FlowLogOperation?method=invokeLog('Policy', 'Create Guard Policy')" /> - <setBody> - <simple>${header.guardPolicy.getValue()} - </simple> - </setBody> - <setHeader headerName="CamelHttpMethod"> - <constant>POST</constant> - </setHeader> - <setHeader headerName="Content-Type"> - <constant>application/json</constant> - </setHeader> - <setHeader headerName="CamelHttpUri"> - <simple>{{clamp.config.policy.url}}/policy/api/v1/policyTypes/onap.policies.controlloop.Guard/versions/1.0.0/policies - </simple> - </setHeader> - <setHeader headerName="X-ONAP-RequestID"> - <simple>${header.X-ONAP-REAUESTID} - </simple> - </setHeader> - <setHeader headerName="X-ONAP-InvocationID"> - <simple>${header.X-ONAP-InvocationID} - </simple> - </setHeader> - <setHeader headerName="X-ONAP-PartnerName"> - <simple>${header.X-ONAP-PartnerName} - </simple> - </setHeader> - <log - loggingLevel="INFO" - message="Endpoint to create guard policy: ${header.CamelHttpMethod} ${header.CamelHttpUri}"></log> - <toD - uri="http4://policyhost:8085?mapHttpMessageHeaders=false&throwExceptionOnFailure=${header.RaiseHttpExceptionFlag}&httpClient.connectTimeout=10000&authUsername={{clamp.config.policy.userName}}&authPassword={{clamp.config.policy.password}}" /> - <to - uri="bean:org.onap.clamp.loop.log.LoopLogService?method=addLog('Guard policy created successfully','INFO',${header.LoopObject})" /> - <to uri="direct:reset-raise-http-exception-flag" /> - <to uri="bean:org.onap.clamp.flow.log.FlowLogOperation?method=invokeReturnLog()" /> + <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.url}}/policy/api/v1/policytypes/onap.policy.controlloop.Guard/versions/1.0.0/policies"></log> + <toD + uri="{{clamp.config.policy.url}}/policy/api/v1/policytypes/onap.policy.controlloop.Guard/versions/1.0.0/policies?bridgeEndpoint=true&mapHttpMessageHeaders=false&throwExceptionOnFailure=${exchangeProperty[raiseHttpExceptionFlag]}&httpClient.connectTimeout=10000&authUsername={{clamp.config.policy.userName}}&authPassword={{clamp.config.policy.password}}" /> + <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> + <to uri="direct:dump-loop-log-http-response" /> + </doFinally> + </doTry> </route> + <route id="delete-guard-policy"> <from uri="direct:delete-guard-policy" /> - - <log - loggingLevel="INFO" - message="Deleting Guard Policy: ${header.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="CamelHttpUri"> - <simple>{{clamp.config.policy.url}}/policy/api/v1/policyTypes/onap.policies.controlloop.Guard/versions/1.0.0/policies/${header.guardPolicy.getKey()} - </simple> - </setHeader> - <setHeader headerName="X-ONAP-RequestID"> - <simple>${header.X-ONAP-REAUESTID} - </simple> - </setHeader> - <setHeader headerName="X-ONAP-InvocationID"> - <simple>${header.X-ONAP-InvocationID} - </simple> - </setHeader> - <setHeader headerName="X-ONAP-PartnerName"> - <simple>${header.X-ONAP-PartnerName} - </simple> - </setHeader> - <log - loggingLevel="INFO" - message="Endpoint to delete guard policy: ${header.CamelHttpMethod} ${header.CamelHttpUri}"></log> - <toD - uri="http4://policyhost:8085?throwExceptionOnFailure=${header.RaiseHttpExceptionFlag}&httpClient.connectTimeout=10000&deleteWithBody=false&mapHttpMessageBody=false&mapHttpMessageFormUrlEncodedBody=false&authUsername={{clamp.config.policy.userName}}&authPassword={{clamp.config.policy.password}}" /> - <to - uri="bean:org.onap.clamp.loop.log.LoopLogService?method=addLog('Guard policy deleted successfully','INFO',${header.LoopObject})" /> - <to uri="direct:reset-raise-http-exception-flag" /> - <to uri="bean:org.onap.clamp.flow.log.FlowLogOperation?method=invokeReturnLog()" /> - </route> - <route id="add-all-to-active-pdp-group"> - <from uri="direct:add-all-to-active-pdp-group" /> - - <log - loggingLevel="INFO" - message="Adding loop policies to PDP Group: ${header.LoopObject.getName()}" /> - <to - uri="bean:org.onap.clamp.flow.log.FlowLogOperation?method=invokeLog('Policy', 'Add policies to PDP group')" /> - <setBody> - <simple>${header.LoopObject.createPoliciesPayloadPdpGroup()} - </simple> - </setBody> - <setHeader headerName="CamelHttpMethod"> - <constant>POST</constant> - </setHeader> - <setHeader headerName="Content-Type"> - <constant>application/json</constant> - </setHeader> - <setHeader headerName="CamelHttpUri"> - <simple>{{clamp.config.policy.url}}/policy/pap/v1/pdps - </simple> - </setHeader> - <setHeader headerName="X-ONAP-RequestID"> - <simple>${header.X-ONAP-REAUESTID} - </simple> - </setHeader> - <setHeader headerName="X-ONAP-InvocationID"> - <simple>${header.X-ONAP-InvocationID} - </simple> - </setHeader> - <setHeader headerName="X-ONAP-PartnerName"> - <simple>${header.X-ONAP-PartnerName} - </simple> - </setHeader> - <log - loggingLevel="INFO" - message="Endpoint to add policies to PDP Group: ${header.CamelHttpMethod} ${header.CamelHttpUri}"></log> - <toD - uri="http4://policyhost:8085?mapHttpMessageHeaders=false&throwExceptionOnFailure=${header.RaiseHttpExceptionFlag}&httpClient.connectTimeout=10000&authUsername={{clamp.config.policy.userName}}&authPassword={{clamp.config.policy.password}}" /> - <to - uri="bean:org.onap.clamp.loop.log.LoopLogService?method=addLog('Policies pushed to PDP Group successfully','INFO',${header.LoopObject})" /> - <to uri="direct:reset-raise-http-exception-flag" /> - <to uri="bean:org.onap.clamp.flow.log.FlowLogOperation?method=invokeReturnLog()" /> - </route> - - <route id="remove-all-policy-from-active-pdp-group"> - <from uri="direct:remove-all-policy-from-active-pdp-group" /> - <log - loggingLevel="INFO" - message="Removing policies from active PDP group for loop: ${header.LoopObject.getName()}" /> - <to - uri="bean:org.onap.clamp.flow.log.FlowLogOperation?method=invokeLog('Policy', 'Removing policies PDP group')" /> - <split> - <simple>${header.LoopObject.listPolicyNamesPdpGroup()}</simple> - <setHeader headerName="PolicyName"> - <simple>${body}</simple> - </setHeader> + <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="CamelHttpUri"> - <simple>{{clamp.config.policy.url}}/pdps/policies/${header.PolicyName}/versions/1.0.0 + <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.url}}/policy/api/v1/policytypes/onap.policy.controlloop.Guard/versions/1.0.0/policies/${exchangeProperty[guardPolicy].getKey()}"></log> + <toD + uri="{{clamp.config.policy.url}}/policy/api/v1/policytypes/onap.policy.controlloop.Guard/versions/1.0.0/policies/${exchangeProperty[guardPolicy].getKey()}?bridgeEndpoint=true&throwExceptionOnFailure=${exchangeProperty[raiseHttpExceptionFlag]}&httpClient.connectTimeout=10000&deleteWithBody=false&mapHttpMessageBody=false&mapHttpMessageFormUrlEncodedBody=false&authUsername={{clamp.config.policy.userName}}&authPassword={{clamp.config.policy.password}}" /> + + <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> + <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].createPoliciesPayloadPdpGroup()} </simple> + </setBody> + <setHeader headerName="CamelHttpMethod"> + <constant>POST</constant> + </setHeader> + <setHeader headerName="Content-Type"> + <constant>application/json</constant> </setHeader> <setHeader headerName="X-ONAP-RequestID"> - <simple>${header.X-ONAP-REAUESTID} + <simple>${exchangeProperty[X-ONAP-RequestID]} </simple> </setHeader> <setHeader headerName="X-ONAP-InvocationID"> - <simple>${header.X-ONAP-InvocationID} + <simple>${exchangeProperty[X-ONAP-InvocationID]} </simple> </setHeader> <setHeader headerName="X-ONAP-PartnerName"> - <simple>${header.X-ONAP-PartnerName} + <simple>${exchangeProperty[X-ONAP-PartnerName]} </simple> </setHeader> <log loggingLevel="INFO" - message="Endpoint to delete policy from PDP Group: ${header.CamelHttpMethod} ${header.CamelHttpUri}"></log> + message="Endpoint to add policies to PDP Group: {{clamp.config.policy.url}}/policy/pap/v1/pdps"></log> <toD - uri="http4://policyhost:8085?mapHttpMessageHeaders=false&throwExceptionOnFailure=${header.RaiseHttpExceptionFlag}&httpClient.connectTimeout=10000&authUsername={{clamp.config.policy.userName}}&authPassword={{clamp.config.policy.password}}" /> + uri="{{clamp.config.policy.url}}/policy/pap/v1/pdps?throwExceptionOnFailure=${exchangeProperty[raiseHttpExceptionFlag]}&httpClient.connectTimeout=10000&authMethod=Basic&authUsername=test&authPassword=test" /> + + <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> + <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 policies from active PDP group for loop: ${exchangeProperty[loopObject].getName()}" /> <to - uri="bean:org.onap.clamp.loop.log.LoopLogService?method=addLog(${header.PolicyName}' Policy removed from PDP Group successfully','INFO',${header.LoopObject})" /> - </split> - <to uri="direct:reset-raise-http-exception-flag" /> - <to uri="bean:org.onap.clamp.flow.log.FlowLogOperation?method=invokeReturnLog()" /> + uri="bean:org.onap.clamp.flow.log.FlowLogOperation?method=invokeLog('Policy', 'Removing policies PDP group')" /> + <split> + <simple>${exchangeProperty[loopObject].listPolicyNamesPdpGroup()} + </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.url}}/pdps/policies/${exchangeProperty[policyName]}/versions/1.0.0"></log> + <toD + uri="{{clamp.config.policy.url}}/pdps/policies/${exchangeProperty[policyName]}/versions/1.0.0?bridgeEndpoint=true&mapHttpMessageHeaders=false&throwExceptionOnFailure=${exchangeProperty[raiseHttpExceptionFlag]}&httpClient.connectTimeout=10000&authUsername={{clamp.config.policy.userName}}&authPassword={{clamp.config.policy.password}}" /> + <setProperty propertyName="logMessage"> + <simple>${exchangeProperty[policyName]} PDP Group removal status + </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>${exchangeProperty[policyName]} PDP Group removal status + </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="reset-raise-http-exception-flag"> <from uri="direct:reset-raise-http-exception-flag" /> - <setHeader headerName="RaiseHttpExceptionFlag"> + <setProperty propertyName="raiseHttpExceptionFlag"> <simple resultType="java.lang.Boolean">true</simple> - </setHeader> + </setProperty> + </route> + + <route id="dump-loop-log-http-response"> + <from uri="direct:dump-loop-log-http-response" /> + <to + uri="bean:org.onap.clamp.loop.log.LoopLogService?method=addLog(${exchangeProperty[logMessage]} - ${header.CamelHttpResponseCode} : ${header.CamelHttpResponseText},'INFO',${exchangeProperty[loopObject]})" /> </route> </routes>
\ No newline at end of file diff --git a/src/main/resources/logback-default.xml b/src/main/resources/logback-default.xml index 2eba127e9..bc8ebb909 100644 --- a/src/main/resources/logback-default.xml +++ b/src/main/resources/logback-default.xml @@ -1,66 +1,97 @@ <included> <jmxConfigurator /> <!-- Example evaluator filter applied against console appender --> -<property name="p_tim" value="%d{"yyyy-MM-dd'T'HH:mm:ss.SSSXXX", UTC}"/> - <property name="p_lvl" value="%level"/> - <property name="p_log" value="%logger"/> - <property name="p_mdc" value="%replace(%replace(%mdc){'\t','\\\\t'}){'\n', '\\\\n'}"/> - <property name="p_msg" value="%replace(%replace(%msg){'\t', '\\\\t'}){'\n','\\\\n'}"/> - <property name="p_exc" value="%replace(%replace(%rootException){'\t', '\\\\t'}){'\n','\\\\n'}"/> - <property name="p_mak" value="%replace(%replace(%marker){'\t', '\\\\t'}){'\n','\\\\n'}"/> - <property name="p_thr" value="%thread"/> - <property name="defaultPattern" value="%nopexception${p_tim}\t${p_thr}\t${p_lvl}\t${p_log}\t${p_mdc}\t${p_msg}\t${p_exc}\t${p_mak}\t%n"/> - <property name="debugPattern" value="%nopexception${p_tim}|${p_lvl}|${p_mdc}|${p_exc}|%msg%n"/> + <property + name="p_tim" + value="%d{"yyyy-MM-dd'T'HH:mm:ss.SSSXXX", UTC}" /> + <property + name="p_lvl" + value="%level" /> + <property + name="p_log" + value="%logger" /> + <property + name="p_mdc" + value="%replace(%replace(%mdc){'\t','\\\\t'}){'\n', '\\\\n'}" /> + <property + name="p_msg" + value="%replace(%replace(%msg){'\t', '\\\\t'}){'\n','\\\\n'}" /> + <property + name="p_exc" + value="%replace(%replace(%rootException){'\t', '\\\\t'}){'\n','\\\\n'}" /> + <property + name="p_mak" + value="%replace(%replace(%marker){'\t', '\\\\t'}){'\n','\\\\n'}" /> + <property + name="p_thr" + value="%thread" /> + <property + name="defaultPattern" + value="%nopexception${p_tim}\t${p_thr}\t${p_lvl}\t${p_log}\t${p_mdc}\t${p_msg}\t${p_exc}\t${p_mak}\t%n" /> + <property + name="debugPattern" + value="%nopexception${p_tim}|${p_lvl}|${p_mdc}|${p_exc}|%msg%n" /> - <!-- Example evaluator filter applied against console appender --> - <appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender"> - <filter class="ch.qos.logback.classic.filter.ThresholdFilter"> - <level>INFO</level> - </filter> - <encoder> - <pattern>%d{HH:mm:ss.SSS} [%thread] %-5level %logger{1024} - %msg%n</pattern> - </encoder> - </appender> + <!-- Example evaluator filter applied against console appender --> + <appender + name="STDOUT" + class="ch.qos.logback.core.ConsoleAppender"> + <filter class="ch.qos.logback.classic.filter.ThresholdFilter"> + <level>INFO</level> + </filter> + <encoder> + <pattern>%d{HH:mm:ss.SSS} [%thread] %-5level %logger{1024} - %msg%n + </pattern> + </encoder> + </appender> - <appender name="ERROR" - class="ch.qos.logback.core.rolling.RollingFileAppender"> - <filter class="ch.qos.logback.classic.filter.ThresholdFilter"> - <level>INFO</level> - </filter> - <file>${logDirectory}/error.log</file> - <append>true</append> - <encoder> - <pattern>${defaultPattern}</pattern> - </encoder> - <rollingPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedRollingPolicy"> - <fileNamePattern>${outputDirectory}/clamp/error.%d{yyyy-MM-dd}.%i.log.zip</fileNamePattern> - <maxFileSize>50MB</maxFileSize> - <maxHistory>30</maxHistory> - <totalSizeCap>10GB</totalSizeCap> - </rollingPolicy> - <triggeringPolicy - class="ch.qos.logback.core.rolling.SizeBasedTriggeringPolicy"> - <maxFileSize>10MB</maxFileSize> - </triggeringPolicy> - </appender> + <appender + name="ERROR" + class="ch.qos.logback.core.rolling.RollingFileAppender"> + <filter class="ch.qos.logback.classic.filter.ThresholdFilter"> + <level>INFO</level> + </filter> + <file>${logDirectory}/error.log</file> + <append>true</append> + <encoder> + <pattern>${defaultPattern}</pattern> + </encoder> + <rollingPolicy + class="ch.qos.logback.core.rolling.SizeAndTimeBasedRollingPolicy"> + <fileNamePattern>${outputDirectory}/clamp/error.%d{yyyy-MM-dd}.%i.log.zip + </fileNamePattern> + <maxFileSize>50MB</maxFileSize> + <maxHistory>30</maxHistory> + <totalSizeCap>10GB</totalSizeCap> + </rollingPolicy> + <triggeringPolicy + class="ch.qos.logback.core.rolling.SizeBasedTriggeringPolicy"> + <maxFileSize>10MB</maxFileSize> + </triggeringPolicy> + </appender> - <appender name="DEBUG" - class="ch.qos.logback.core.rolling.RollingFileAppender"> - <file>${logDirectory}/debug.log</file> - <append>true</append> - <encoder> - <pattern>${debugPattern}</pattern> - </encoder> - <rollingPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedRollingPolicy"> - <fileNamePattern>${outputDirectory}/clamp/debug.%d{yyyy-MM-dd}.%i.log.zip</fileNamePattern> - <maxFileSize>50MB</maxFileSize> - <maxHistory>30</maxHistory> - <totalSizeCap>10GB</totalSizeCap> - </rollingPolicy> - </appender> + <appender + name="DEBUG" + class="ch.qos.logback.core.rolling.RollingFileAppender"> + <file>${logDirectory}/debug.log</file> + <append>true</append> + <encoder> + <pattern>%d{HH:mm:ss.SSS} [%thread] %-5level %logger{1024} - %msg%n + </pattern> + </encoder> + <rollingPolicy + class="ch.qos.logback.core.rolling.SizeAndTimeBasedRollingPolicy"> + <fileNamePattern>${outputDirectory}/clamp/debug.%d{yyyy-MM-dd}.%i.log.zip + </fileNamePattern> + <maxFileSize>50MB</maxFileSize> + <maxHistory>30</maxHistory> + <totalSizeCap>10GB</totalSizeCap> + </rollingPolicy> + </appender> - <appender name="AUDIT" + <appender + name="AUDIT" class="ch.qos.logback.core.rolling.RollingFileAppender"> <file>${logDirectory}/audit.log</file> <append>true</append> @@ -79,13 +110,15 @@ <maxFileSize>10MB</maxFileSize> </triggeringPolicy> </appender> - <appender name="asyncEELFAudit" + <appender + name="asyncEELFAudit" class="ch.qos.logback.classic.AsyncAppender"> <queueSize>256</queueSize> <appender-ref ref="AUDIT" /> </appender> - <appender name="METRIC" + <appender + name="METRIC" class="ch.qos.logback.core.rolling.RollingFileAppender"> <file>${logDirectory}/metric.log</file> <append>true</append> @@ -104,14 +137,16 @@ <maxFileSize>10MB</maxFileSize> </triggeringPolicy> </appender> - <appender name="asyncEELFMetrics" + <appender + name="asyncEELFMetrics" class="ch.qos.logback.classic.AsyncAppender"> <queueSize>256</queueSize> <appender-ref ref="METRIC" /> </appender> <!-- SECURITY related loggers --> - <appender name="SECURITY" + <appender + name="SECURITY" class="ch.qos.logback.core.rolling.RollingFileAppender"> <file>${logDirectory}/security.log</file> <append>true</append> @@ -130,55 +165,15 @@ <maxFileSize>10MB</maxFileSize> </triggeringPolicy> </appender> - <appender name="asyncEELFSecurity" + <appender + name="asyncEELFSecurity" class="ch.qos.logback.classic.AsyncAppender"> <queueSize>256</queueSize> <appender-ref ref="SECURITY" /> </appender> - <!-- AAF related loggers --> - <logger name="org.onap.aaf" level="INFO" additivity="true"> - <appender-ref ref="DEBUG" /> - </logger> - <logger name="org.apache.catalina.core" level="INFO" - additivity="true"> - <appender-ref ref="DEBUG" /> - </logger> - <!-- CLDS related loggers --> - <logger name="org.onap.clamp" level="INFO" - additivity="true"> - <appender-ref ref="ERROR" /> - </logger> - - <!-- CLDS related loggers --> - <logger name="com.att.eelf.error" level="OFF" additivity="true"> - <appender-ref ref="ERROR" /> - </logger> - <!-- EELF related loggers --> - <logger name="com.att.eelf.audit" level="INFO" - additivity="false"> - <appender-ref ref="asyncEELFAudit" /> - </logger> - <logger name="com.att.eelf.metrics" level="DEBUG" - additivity="false"> - <appender-ref ref="asyncEELFMetrics" /> - </logger> - <logger name="com.att.eelf.security" level="DEBUG" - additivity="false"> - <appender-ref ref="asyncEELFSecurity" /> - </logger> - - <!-- Spring related loggers --> - <logger name="org.springframework" level="DEBUG" /> - - <!-- Other Loggers that may help troubleshoot --> - <logger name="org.apache" level="DEBUG" /> - - <!-- logback internals logging --> - <logger name="ch.qos.logback.classic" level="INFO" /> - <logger name="ch.qos.logback.core" level="INFO" /> - <!-- logback jms appenders & loggers definition starts here --> - <appender name="auditLogs" + <appender + name="auditLogs" class="ch.qos.logback.core.rolling.RollingFileAppender"> <filter class="ch.qos.logback.classic.filter.ThresholdFilter"> </filter> @@ -198,7 +193,8 @@ <pattern>"%d [%thread] %-5level %logger{1024} - %msg%n"</pattern> </encoder> </appender> - <appender name="perfLogs" + <appender + name="perfLogs" class="ch.qos.logback.core.rolling.RollingFileAppender"> <filter class="ch.qos.logback.classic.filter.ThresholdFilter"> </filter> @@ -218,14 +214,81 @@ <pattern>"%d [%thread] %-5level %logger{1024} - %msg%n"</pattern> </encoder> </appender> - <logger name="AuditRecord" level="INFO" additivity="FALSE"> + + <logger + name="org.onap.aaf" + level="DEBUG"> + <appender-ref ref="DEBUG" /> + </logger> + <logger + name="org.apache" + level="DEBUG"> + <appender-ref ref="DEBUG" /> + </logger> + <!-- Spring related loggers --> + <logger + name="org.springframework" + level="DEBUG"> + <appender-ref ref="DEBUG" /> + </logger> + + <!-- CLDS related loggers --> + <logger + name="org.onap.clamp" + level="DEBUG"> + <appender-ref ref="ERROR" /> + <appender-ref ref="DEBUG" /> + </logger> + + <!-- CLDS related loggers --> + <logger + name="com.att.eelf.error" + level="OFF"> + <appender-ref ref="ERROR" /> + </logger> + <!-- EELF related loggers --> + <logger + name="com.att.eelf.audit" + level="INFO" + additivity="false"> + <appender-ref ref="asyncEELFAudit" /> + </logger> + <logger + name="com.att.eelf.metrics" + level="DEBUG" + additivity="false"> + <appender-ref ref="asyncEELFMetrics" /> + </logger> + <logger + name="com.att.eelf.security" + level="DEBUG" + additivity="false"> + <appender-ref ref="asyncEELFSecurity" /> + </logger> + + <!-- logback internals logging --> + <logger + name="ch.qos.logback.classic" + level="INFO" /> + <logger + name="ch.qos.logback.core" + level="INFO" /> + <logger + name="AuditRecord" + level="INFO" + additivity="false"> <appender-ref ref="auditLogs" /> </logger> - <logger name="AuditRecord_DirectCall" level="INFO" - additivity="FALSE"> + <logger + name="AuditRecord_DirectCall" + level="INFO" + additivity="false"> <appender-ref ref="auditLogs" /> </logger> - <logger name="PerfTrackerRecord" level="INFO" additivity="FALSE"> + <logger + name="PerfTrackerRecord" + level="INFO" + additivity="false"> <appender-ref ref="perfLogs" /> </logger> <!-- logback jms appenders & loggers definition ends here --> diff --git a/src/test/java/org/onap/clamp/clds/client/TcaPolicyDeleteDelegateTest.java b/src/test/java/org/onap/clamp/clds/client/TcaPolicyDeleteDelegateTest.java new file mode 100644 index 000000000..70edabe68 --- /dev/null +++ b/src/test/java/org/onap/clamp/clds/client/TcaPolicyDeleteDelegateTest.java @@ -0,0 +1,103 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP CLAMP + * ================================================================================ + * Copyright (C) 2019 Samsung. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END============================================ + * =================================================================== + * + */ + +package org.onap.clamp.clds.client; + +import org.apache.camel.Exchange; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.mockito.InjectMocks; +import org.mockito.Mock; +import org.mockito.Mockito; +import org.mockito.runners.MockitoJUnitRunner; +import org.onap.clamp.clds.client.req.policy.PolicyClient; +import org.onap.clamp.clds.exception.ModelBpmnException; + +@RunWith(MockitoJUnitRunner.class) +public class TcaPolicyDeleteDelegateTest { + + private static final String TCA_ID_FROM_JSON = "{\"tca\":[{\"id\":\"\",\"from\":\"\"}]}"; + private static final String HOLMES_ID_FROM_JSON = "{\"holmes\":[{\"id\":\"\",\"from\":\"\"}]}"; + private static final String ID_JSON = "{\"id\":\"\"}"; + private static final String NOT_JSON = "not json"; + private static final String MODEL_BPMN_KEY = "modelBpmnProp"; + private static final String MODEL_PROP_KEY = "modelProp"; + private static final String TEST_KEY = "isTest"; + private static final String PROPERTY_NAME = "tcaPolicyDeleteResponseMessage"; + private static final String MESSAGE = "message"; + + @Mock + private Exchange camelExchange; + + @Mock + private PolicyClient policyClient; + + @InjectMocks + private TcaPolicyDeleteDelegate tcaPolicyDeleteDelegate; + + @Test + public void shouldExecuteSuccessfully() { + //given + Mockito.when(camelExchange.getProperty(MODEL_BPMN_KEY)).thenReturn(TCA_ID_FROM_JSON); + Mockito.when(camelExchange.getProperty(MODEL_PROP_KEY)).thenReturn(ID_JSON); + Mockito.when(camelExchange.getProperty(TEST_KEY)).thenReturn(false); + + Mockito.when(policyClient.deleteMicrosService(Mockito.any())).thenReturn(MESSAGE); + + //when + tcaPolicyDeleteDelegate.execute(camelExchange); + + //then + Mockito.verify(camelExchange).setProperty(PROPERTY_NAME, MESSAGE.getBytes()); + } + + @Test + public void shouldExecuteTcaNotFound() { + //given + Mockito.when(camelExchange.getProperty(MODEL_BPMN_KEY)).thenReturn(HOLMES_ID_FROM_JSON); + Mockito.when(camelExchange.getProperty(MODEL_PROP_KEY)).thenReturn(ID_JSON); + Mockito.when(camelExchange.getProperty(TEST_KEY)).thenReturn(false); + + //when + tcaPolicyDeleteDelegate.execute(camelExchange); + + //then + Mockito.verify(policyClient, Mockito.never()).deleteMicrosService(Mockito.any()); + Mockito.verify(camelExchange, Mockito.never()).setProperty(Mockito.any(), Mockito.any()); + } + + @Test(expected = ModelBpmnException.class) + public void shouldThrowModelBpmnException() { + //given + Mockito.when(camelExchange.getProperty(MODEL_BPMN_KEY)).thenReturn(NOT_JSON); + Mockito.when(camelExchange.getProperty(TEST_KEY)).thenReturn(false); + + //when + tcaPolicyDeleteDelegate.execute(camelExchange); + } + + @Test(expected = NullPointerException.class) + public void shouldThrowNullPointerException() { + //when + tcaPolicyDeleteDelegate.execute(camelExchange); + } +} diff --git a/src/test/java/org/onap/clamp/clds/sdc/controller/installer/BlueprintParserTest.java b/src/test/java/org/onap/clamp/clds/sdc/controller/installer/BlueprintParserTest.java index e86fb27d0..211bb3906 100644 --- a/src/test/java/org/onap/clamp/clds/sdc/controller/installer/BlueprintParserTest.java +++ b/src/test/java/org/onap/clamp/clds/sdc/controller/installer/BlueprintParserTest.java @@ -163,8 +163,8 @@ public class BlueprintParserTest { @Test public void fallBackToOneMicroServiceTCATest() { - MicroService tcaMS = new MicroService(BlueprintParser.TCA, "onap.policy.monitoring.cdap.tca.hi.lo.app", "", "", - ""); + MicroService tcaMS = new MicroService(BlueprintParser.TCA, "onap.policies.monitoring.cdap.tca.hi.lo.app", "", + "", ""); List<MicroService> expected = Collections.singletonList(tcaMS); List<MicroService> actual = new BlueprintParser().fallbackToOneMicroService(microServiceBlueprintOldStyleTCA); @@ -174,7 +174,7 @@ public class BlueprintParserTest { @Test public void fallBackToOneMicroServiceHolmesTest() { - MicroService holmesMS = new MicroService(BlueprintParser.HOLMES, "onap.policy.monitoring.cdap.tca.hi.lo.app", + MicroService holmesMS = new MicroService(BlueprintParser.HOLMES, "onap.policies.monitoring.cdap.tca.hi.lo.app", "", "", ""); List<MicroService> expected = Collections.singletonList(holmesMS); diff --git a/src/test/java/org/onap/clamp/policy/microservice/MicroServicePayloadTest.java b/src/test/java/org/onap/clamp/policy/microservice/MicroServicePayloadTest.java index c511f3415..68925a913 100644 --- a/src/test/java/org/onap/clamp/policy/microservice/MicroServicePayloadTest.java +++ b/src/test/java/org/onap/clamp/policy/microservice/MicroServicePayloadTest.java @@ -37,7 +37,7 @@ public class MicroServicePayloadTest { @Test public void testPayloadConstruction() throws IOException { - MicroServicePolicy policy = new MicroServicePolicy("testPolicy", "onap.policy.monitoring.cdap.tca.hi.lo.app", + MicroServicePolicy policy = new MicroServicePolicy("testPolicy", "onap.policies.monitoring.cdap.tca.hi.lo.app", ResourceFileUtil.getResourceAsString("tosca/tosca_example.yaml"), false, new HashSet<>()); policy.setProperties(JsonUtils.GSON.fromJson( ResourceFileUtil.getResourceAsString("tosca/micro-service-policy-properties.json"), JsonObject.class)); diff --git a/src/test/resources/application.properties b/src/test/resources/application.properties index 9f711e3e9..26e0b3b9d 100644 --- a/src/test/resources/application.properties +++ b/src/test/resources/application.properties @@ -141,7 +141,7 @@ clamp.config.dcae.deployment.template=classpath:/clds/templates/dcae-deployment- #
#
# Configuration Settings for Policy Engine Components
-clamp.config.policy.url=http://localhost:${docker.http-cache.port.host}
+clamp.config.policy.url=http4://localhost:${docker.http-cache.port.host}
clamp.config.policy.userName=test
clamp.config.policy.password=test
clamp.config.policy.pdpUrl1=http://localhost:${docker.http-cache.port.host}/pdp/ , testpdp, alpha123
diff --git a/src/test/resources/example/sdc/blueprint-dcae/tca.yaml b/src/test/resources/example/sdc/blueprint-dcae/tca.yaml index b2bf8bb96..edaa0be28 100644 --- a/src/test/resources/example/sdc/blueprint-dcae/tca.yaml +++ b/src/test/resources/example/sdc/blueprint-dcae/tca.yaml @@ -17,7 +17,7 @@ node_templates: properties: policy_id: get_input: policy_id - policy_type_id: onap.policy.monitoring.cdap.tca.hi.lo.app + policy_type_id: onap.policies.monitoring.cdap.tca.hi.lo.app cdap_host_host: type: dcae.nodes.StreamingAnalytics.SelectedCDAPInfrastructure properties: diff --git a/src/test/resources/example/sdc/blueprint-dcae/tca_2.yaml b/src/test/resources/example/sdc/blueprint-dcae/tca_2.yaml index fb042575b..c834b1b93 100644 --- a/src/test/resources/example/sdc/blueprint-dcae/tca_2.yaml +++ b/src/test/resources/example/sdc/blueprint-dcae/tca_2.yaml @@ -166,5 +166,5 @@ node_templates: properties: policy_id: get_input: policy_id - policy_type_id: onap.policy.monitoring.cdap.tca.hi.lo.app + policy_type_id: onap.policies.monitoring.cdap.tca.hi.lo.app diff --git a/src/test/resources/example/sdc/blueprint-dcae/tca_3.yaml b/src/test/resources/example/sdc/blueprint-dcae/tca_3.yaml index b2bf8bb96..edaa0be28 100644 --- a/src/test/resources/example/sdc/blueprint-dcae/tca_3.yaml +++ b/src/test/resources/example/sdc/blueprint-dcae/tca_3.yaml @@ -17,7 +17,7 @@ node_templates: properties: policy_id: get_input: policy_id - policy_type_id: onap.policy.monitoring.cdap.tca.hi.lo.app + policy_type_id: onap.policies.monitoring.cdap.tca.hi.lo.app cdap_host_host: type: dcae.nodes.StreamingAnalytics.SelectedCDAPInfrastructure properties: diff --git a/src/test/resources/example/sdc/expected-result/policy-data.yaml b/src/test/resources/example/sdc/expected-result/policy-data.yaml index 7f2c4847b..2d3153112 100644 --- a/src/test/resources/example/sdc/expected-result/policy-data.yaml +++ b/src/test/resources/example/sdc/expected-result/policy-data.yaml @@ -135,7 +135,7 @@ policy_types: tosca.policies.Monitoring: derived_from: tosca.policies.Root description: A base policy type for all policies that governs monitoring provisioning - onap.policy.monitoring.cdap.tca.hi.lo.app: + onap.policies.monitoring.cdap.tca.hi.lo.app: derived_from: tosca.policies.Monitoring version: 1.0.0 properties: diff --git a/src/test/resources/example/sdc/service-Vloadbalancerms-csar.csar b/src/test/resources/example/sdc/service-Vloadbalancerms-csar.csar Binary files differindex b5fe39d31..727ef16b7 100755 --- a/src/test/resources/example/sdc/service-Vloadbalancerms-csar.csar +++ b/src/test/resources/example/sdc/service-Vloadbalancerms-csar.csar diff --git a/src/test/resources/tosca/micro-service-policy-payload.json b/src/test/resources/tosca/micro-service-policy-payload.json index 01d6d275c..2de06b083 100644 --- a/src/test/resources/tosca/micro-service-policy-payload.json +++ b/src/test/resources/tosca/micro-service-policy-payload.json @@ -4,7 +4,7 @@ "policies": [ { "testPolicy": { - "type": "onap.policy.monitoring.cdap.tca.hi.lo.app", + "type": "onap.policies.monitoring.cdap.tca.hi.lo.app", "version": "1.0.0", "metadata": { "policy-id": "testPolicy" diff --git a/src/test/resources/tosca/tosca_example.yaml b/src/test/resources/tosca/tosca_example.yaml index 699cffd7e..b0119f887 100644 --- a/src/test/resources/tosca/tosca_example.yaml +++ b/src/test/resources/tosca/tosca_example.yaml @@ -3,7 +3,7 @@ policy_types: onap.policies.Monitoring: derived_from: tosca.policies.Root description: a base policy type for all policies that governs monitoring provisioning - onap.policy.monitoring.cdap.tca.hi.lo.app: + onap.policies.monitoring.cdap.tca.hi.lo.app: derived_from: onap.policies.Monitoring version: 1.0.0 properties: |