Merge changes I8c744a32,Id357ac37,I7df87e14,I2abd173c,Ie53b1dfd

* changes:
  Add timeout + Creds
  Remove SQL Dump
  Add delete support
  Rework Gson in Camel
  PDP Group support
diff --git a/src/main/java/org/onap/clamp/clds/config/CamelConfiguration.java b/src/main/java/org/onap/clamp/clds/config/CamelConfiguration.java
index c3b24bc..f178ce0 100644
--- a/src/main/java/org/onap/clamp/clds/config/CamelConfiguration.java
+++ b/src/main/java/org/onap/clamp/clds/config/CamelConfiguration.java
@@ -36,7 +36,7 @@
 
     @Override
     public void configure() {
-        restConfiguration().component("servlet").bindingMode(RestBindingMode.json).jsonDataFormat("json-gson")
+        restConfiguration().component("servlet").bindingMode(RestBindingMode.json).jsonDataFormat("clamp-gson")
             .dataFormatProperty("prettyPrint", "true")// .enableCORS(true)
             // turn on swagger api-doc
             .apiContextPath("api-doc").apiVendorExtension(true).apiProperty("api.title", "Clamp Rest API")
diff --git a/src/main/java/org/onap/clamp/configuration/CamelGsonConfiguration.java b/src/main/java/org/onap/clamp/configuration/CamelGsonConfiguration.java
deleted file mode 100644
index f71d2f0..0000000
--- a/src/main/java/org/onap/clamp/configuration/CamelGsonConfiguration.java
+++ /dev/null
@@ -1,63 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * ONAP CLAMP
- * ================================================================================
- * Copyright (C) 2019 Nokia Intellectual Property. All rights
- *                             reserved.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END============================================
- * ===================================================================
- *
- */
-
-package org.onap.clamp.configuration;
-
-import com.google.gson.ExclusionStrategy;
-import com.google.gson.FieldAttributes;
-import com.google.gson.annotations.Expose;
-import java.util.Collections;
-import java.util.List;
-import java.util.Optional;
-import org.apache.camel.component.gson.GsonDataFormat;
-import org.apache.camel.spi.DataFormatCustomizer;
-import org.springframework.context.annotation.Bean;
-import org.springframework.context.annotation.Configuration;
-
-@Configuration
-public class CamelGsonConfiguration {
-
-    @Bean
-    public List<DataFormatCustomizer<GsonDataFormat>> provideGsonCustomizers() {
-        DataFormatCustomizer<GsonDataFormat> dataFormatCustomizer = dataformat ->
-            dataformat.setExclusionStrategies(
-                Collections.singletonList(new ExcludeFieldsWithoutExposedAnnotation())
-            );
-        return Collections.singletonList(dataFormatCustomizer);
-    }
-
-    private static class ExcludeFieldsWithoutExposedAnnotation implements ExclusionStrategy {
-
-        @Override
-        public boolean shouldSkipField(FieldAttributes f) {
-            return Optional.ofNullable(f.getAnnotation(Expose.class))
-                .map(expose -> !expose.serialize())
-                .orElse(true);
-        }
-
-        @Override
-        public boolean shouldSkipClass(Class<?> clazz) {
-            return false;
-        }
-    }
-}
diff --git a/src/main/java/org/onap/clamp/configuration/ClampGsonDataFormat.java b/src/main/java/org/onap/clamp/configuration/ClampGsonDataFormat.java
new file mode 100644
index 0000000..aad1ab4
--- /dev/null
+++ b/src/main/java/org/onap/clamp/configuration/ClampGsonDataFormat.java
@@ -0,0 +1,177 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP CLAMP
+ * ================================================================================
+ * Copyright (C) 2019 AT&T Intellectual Property. All rights
+ *                             reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END============================================
+ * ===================================================================
+ */
+package org.onap.clamp.configuration;
+
+import com.google.gson.Gson;
+
+import java.io.BufferedReader;
+import java.io.BufferedWriter;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+import java.io.OutputStream;
+import java.io.OutputStreamWriter;
+import java.lang.reflect.Type;
+import java.nio.charset.StandardCharsets;
+
+import org.apache.camel.Exchange;
+import org.apache.camel.spi.DataFormat;
+import org.apache.camel.spi.DataFormatName;
+import org.apache.camel.support.ServiceSupport;
+import org.apache.camel.util.IOHelper;
+import org.onap.clamp.clds.util.JsonUtils;
+
+public class ClampGsonDataFormat extends ServiceSupport implements DataFormat, DataFormatName {
+    private Gson gson;
+    private Class<?> unmarshalType;
+    private Type unmarshalGenericType;
+    private boolean contentTypeHeader = true;
+
+    public ClampGsonDataFormat() {
+        this(Object.class);
+    }
+
+    /**
+     * Use the default Gson {@link Gson} and with a custom unmarshal type
+     *
+     * @param unmarshalType
+     *        the custom unmarshal type
+     */
+    public ClampGsonDataFormat(Class<?> unmarshalType) {
+        this(null, unmarshalType);
+    }
+
+    /**
+     * Use a custom Gson mapper and and unmarshal type
+     *
+     * @param gson
+     *        the custom mapper
+     * @param unmarshalType
+     *        the custom unmarshal type
+     */
+    public ClampGsonDataFormat(Gson gson, Class<?> unmarshalType) {
+        this.gson = gson;
+        this.unmarshalType = unmarshalType;
+    }
+
+    /**
+     * Use the default Gson {@link Gson} and with a custom unmarshal generic type
+     *
+     * @param unmarshalGenericType
+     *        the custom unmarshal generic type
+     */
+    public ClampGsonDataFormat(Type unmarshalGenericType) {
+        this(null, unmarshalGenericType);
+    }
+
+    /**
+     * Use a custom Gson mapper and and unmarshal token type
+     *
+     * @param gson
+     *        the custom mapper
+     * @param unmarshalGenericType
+     *        the custom unmarshal generic type
+     */
+    public ClampGsonDataFormat(Gson gson, Type unmarshalGenericType) {
+        this.gson = gson;
+        this.unmarshalGenericType = unmarshalGenericType;
+    }
+
+    @Override
+    public String getDataFormatName() {
+        return "clamp-gson";
+    }
+
+    @Override
+    public void marshal(final Exchange exchange, final Object graph, final OutputStream stream) throws Exception {
+        try (final OutputStreamWriter osw = new OutputStreamWriter(stream, StandardCharsets.UTF_8);
+            final BufferedWriter writer = IOHelper.buffered(osw)) {
+            gson.toJson(graph, writer);
+        }
+
+        if (contentTypeHeader) {
+            if (exchange.hasOut()) {
+                exchange.getOut().setHeader(Exchange.CONTENT_TYPE, "application/json");
+            } else {
+                exchange.getIn().setHeader(Exchange.CONTENT_TYPE, "application/json");
+            }
+        }
+    }
+
+    @Override
+    public Object unmarshal(final Exchange exchange, final InputStream stream) throws Exception {
+        try (final InputStreamReader isr = new InputStreamReader(stream, StandardCharsets.UTF_8);
+            final BufferedReader reader = IOHelper.buffered(isr)) {
+            if (unmarshalGenericType == null) {
+                return gson.fromJson(reader, unmarshalType);
+            } else {
+                return gson.fromJson(reader, unmarshalGenericType);
+            }
+        }
+    }
+
+    @Override
+    protected void doStart() throws Exception {
+        if (gson == null) {
+            gson = JsonUtils.GSON_JPA_MODEL;
+        }
+    }
+
+    @Override
+    protected void doStop() throws Exception {
+        // noop
+    }
+
+    // Properties
+    // -------------------------------------------------------------------------
+
+    public Class<?> getUnmarshalType() {
+        return this.unmarshalType;
+    }
+
+    public void setUnmarshalType(Class<?> unmarshalType) {
+        this.unmarshalType = unmarshalType;
+    }
+
+    public Type getUnmarshalGenericType() {
+        return this.unmarshalType;
+    }
+
+    public void setUnmarshalGenericType(Type unmarshalGenericType) {
+        this.unmarshalGenericType = unmarshalGenericType;
+    }
+
+    public boolean isContentTypeHeader() {
+        return contentTypeHeader;
+    }
+
+    /**
+     * If enabled then Gson will set the Content-Type header to
+     * <tt>application/json</tt> when marshalling.
+     */
+    public void setContentTypeHeader(boolean contentTypeHeader) {
+        this.contentTypeHeader = contentTypeHeader;
+    }
+
+    public Gson getGson() {
+        return this.gson;
+    }
+}
diff --git a/src/main/java/org/onap/clamp/loop/Loop.java b/src/main/java/org/onap/clamp/loop/Loop.java
index a24d344..83f938d 100644
--- a/src/main/java/org/onap/clamp/loop/Loop.java
+++ b/src/main/java/org/onap/clamp/loop/Loop.java
@@ -23,6 +23,8 @@
 
 package org.onap.clamp.loop;
 
+import com.google.gson.GsonBuilder;
+import com.google.gson.JsonArray;
 import com.google.gson.JsonObject;
 import com.google.gson.annotations.Expose;
 
@@ -257,6 +259,30 @@
         return buffer.toString().replace('.', '_').replaceAll(" ", "");
     }
 
+    public String createPoliciesPayloadPdpGroup() {
+        JsonObject jsonObject = new JsonObject();
+        JsonArray jsonArray = new JsonArray();
+        jsonObject.add("policies", jsonArray);
+
+        for (OperationalPolicy opPolicy : this.getOperationalPolicies()) {
+            JsonObject policyNode = new JsonObject();
+            jsonArray.add(policyNode);
+            policyNode.addProperty("policy-id", opPolicy.getName());
+
+            for (String guardName : opPolicy.createGuardPolicyPayloads().keySet()) {
+                JsonObject guardPolicyNode = new JsonObject();
+                jsonArray.add(guardPolicyNode);
+                guardPolicyNode.addProperty("policy-id", guardName);
+            }
+        }
+        for (MicroServicePolicy microServicePolicy : this.getMicroServicePolicies()) {
+            JsonObject policyNode = new JsonObject();
+            jsonArray.add(policyNode);
+            policyNode.addProperty("policy-id", microServicePolicy.getName());
+        }
+        return new GsonBuilder().setPrettyPrinting().create().toJson(jsonObject);
+    }
+
     @Override
     public int hashCode() {
         final int prime = 31;
diff --git a/src/main/java/org/onap/clamp/loop/LoopOperation.java b/src/main/java/org/onap/clamp/loop/LoopOperation.java
index 5b55ab0..d9ea248 100644
--- a/src/main/java/org/onap/clamp/loop/LoopOperation.java
+++ b/src/main/java/org/onap/clamp/loop/LoopOperation.java
@@ -31,7 +31,6 @@
 import com.google.gson.JsonObject;
 import com.google.gson.JsonPrimitive;
 
-import java.io.IOException;
 import java.lang.reflect.Array;
 import java.util.Collection;
 import java.util.Date;
@@ -213,163 +212,4 @@
         return new JsonPrimitive(String.valueOf(o));
     }
 
-    /**
-     * Submit the Ms policies.
-     *
-     * @param loopName
-     *        the loop name
-     * @return the updated loop
-     * @throws IOException
-     *         IO exception
-     * @throws Exceptions
-     *         during the operation
-     */
-    public Loop submitMsPolicies(String loopName) throws OperationException, IOException {
-        util.entering(request, "LoopOperation: delete microservice policies");
-        Date startTime = new Date();
-        Loop loop = loopService.getLoop(loopName);
-
-        if (loop == null) {
-            String msg = "Submit MS policies exception: Not able to find closed loop:" + loopName;
-            util.exiting(HttpStatus.INTERNAL_SERVER_ERROR.toString(), msg, Level.INFO,
-                ONAPLogConstants.ResponseStatus.ERROR);
-            throw new OperationException(msg);
-        }
-
-        // verify the current closed loop state
-        if (loop.getLastComputedState() != LoopState.SUBMITTED && loop.getLastComputedState() != LoopState.DESIGN) {
-            String msg = "Submit MS policies exception: This closed loop is in state:" + loop.getLastComputedState()
-                + ". It could be deleted only when it is in SUBMITTED state.";
-            util.exiting(HttpStatus.CONFLICT.toString(), msg, Level.INFO, ONAPLogConstants.ResponseStatus.ERROR);
-            throw new OperationException(msg);
-        }
-
-        // Establish the api call to Policy to create the ms services
-        // policyOp.createMsPolicy(loop.getMicroServicePolicies());
-
-        // audit log
-        LoggingUtils.setTimeContext(startTime, new Date());
-        auditLogger.info("Deletion of MS policies completed");
-        util.exiting(HttpStatus.OK.toString(), "Successful", Level.INFO, ONAPLogConstants.ResponseStatus.COMPLETED);
-        return loop;
-    }
-
-    /**
-     * Delete the Ms policies.
-     *
-     * @param loopName
-     *        the loop name
-     * @return the updated loop
-     * @throws IOException
-     *         IO exception
-     * @throws Exceptions
-     *         during the operation
-     */
-    public Loop deleteMsPolicies(Exchange camelExchange, String loopName) throws OperationException, IOException {
-        util.entering(request, "LoopOperation: delete microservice policies");
-        Date startTime = new Date();
-        Loop loop = loopService.getLoop(loopName);
-
-        if (loop == null) {
-            String msg = "Delete MS policies exception: Not able to find closed loop:" + loopName;
-            util.exiting(HttpStatus.INTERNAL_SERVER_ERROR.toString(), msg, Level.INFO,
-                ONAPLogConstants.ResponseStatus.ERROR);
-            throw new OperationException(msg);
-        }
-
-        // verify the current closed loop state
-        if (loop.getLastComputedState() != LoopState.SUBMITTED) {
-            String msg = "Delete MS policies exception: This closed loop is in state:" + loop.getLastComputedState()
-                + ". It could be deleted only when it is in SUBMITTED state.";
-            util.exiting(HttpStatus.CONFLICT.toString(), msg, Level.INFO, ONAPLogConstants.ResponseStatus.ERROR);
-            throw new OperationException(msg);
-        }
-
-        // Establish the api call to Policy to create the ms services
-        // policyOp.deleteMsPolicy(loop.getMicroServicePolicies());
-
-        // audit log
-        LoggingUtils.setTimeContext(startTime, new Date());
-        auditLogger.info("Deletion of MS policies completed");
-        util.exiting(HttpStatus.OK.toString(), "Successful", Level.INFO, ONAPLogConstants.ResponseStatus.COMPLETED);
-        return loop;
-    }
-
-    /**
-     * Delete the operational policy.
-     *
-     * @param loopName
-     *        the loop name
-     * @return the updated loop
-     * @throws Exceptions
-     *         during the operation
-     */
-    public Loop deleteOpPolicy(Exchange camelExchange, String loopName) throws OperationException {
-        util.entering(request, "LoopOperation: delete guard policy");
-        Date startTime = new Date();
-        Loop loop = loopService.getLoop(loopName);
-
-        if (loop == null) {
-            String msg = "Delete guard policy exception: Not able to find closed loop:" + loopName;
-            util.exiting(HttpStatus.INTERNAL_SERVER_ERROR.toString(), msg, Level.INFO,
-                ONAPLogConstants.ResponseStatus.ERROR);
-            throw new OperationException(msg);
-        }
-
-        // verify the current closed loop state
-        if (loop.getLastComputedState() != LoopState.SUBMITTED) {
-            String msg = "Delete MS policies exception: This closed loop is in state:" + loop.getLastComputedState()
-                + ". It could be deleted only when it is in SUBMITTED state.";
-            util.exiting(HttpStatus.CONFLICT.toString(), msg, Level.INFO, ONAPLogConstants.ResponseStatus.ERROR);
-            throw new OperationException(msg);
-        }
-
-        // Establish the api call to Policy to delete operational policy
-        // client.deleteOpPolicy();
-
-        // audit log
-        LoggingUtils.setTimeContext(startTime, new Date());
-        auditLogger.info("Deletion of Guard policy completed");
-        util.exiting(HttpStatus.OK.toString(), "Successful", Level.INFO, ONAPLogConstants.ResponseStatus.COMPLETED);
-        return loop;
-    }
-
-    /**
-     * Delete the Guard policy.
-     *
-     * @param loopName
-     *        the loop name
-     * @return the updated loop
-     * @throws Exceptions
-     *         during the operation
-     */
-    public Loop deleteGuardPolicy(Exchange camelExchange, String loopName) throws OperationException {
-        util.entering(request, "LoopOperation: delete operational policy");
-        Date startTime = new Date();
-        Loop loop = loopService.getLoop(loopName);
-
-        if (loop == null) {
-            String msg = "Delete operational policy exception: Not able to find closed loop:" + loopName;
-            util.exiting(HttpStatus.INTERNAL_SERVER_ERROR.toString(), msg, Level.INFO,
-                ONAPLogConstants.ResponseStatus.ERROR);
-            throw new OperationException(msg);
-        }
-
-        // verify the current closed loop state
-        if (loop.getLastComputedState() != LoopState.SUBMITTED) {
-            String msg = "Delete MS policies exception: This closed loop is in state:" + loop.getLastComputedState()
-                + ". It could be deleted only when it is in SUBMITTED state.";
-            util.exiting(HttpStatus.CONFLICT.toString(), msg, Level.INFO, ONAPLogConstants.ResponseStatus.ERROR);
-            throw new OperationException(msg);
-        }
-
-        // Establish the api call to Policy to delete Guard policy
-        // client.deleteOpPolicy();
-
-        // audit log
-        LoggingUtils.setTimeContext(startTime, new Date());
-        auditLogger.info("Deletion of operational policy completed");
-        util.exiting(HttpStatus.OK.toString(), "Successful", Level.INFO, ONAPLogConstants.ResponseStatus.COMPLETED);
-        return loop;
-    }
 }
diff --git a/src/main/java/org/onap/clamp/loop/LoopService.java b/src/main/java/org/onap/clamp/loop/LoopService.java
index 8d61b87..4c13922 100644
--- a/src/main/java/org/onap/clamp/loop/LoopService.java
+++ b/src/main/java/org/onap/clamp/loop/LoopService.java
@@ -67,6 +67,10 @@
         return loopsRepository.findById(loopName).orElse(null);
     }
 
+    public void deleteLoop(String loopName) {
+        loopsRepository.deleteById(loopName);
+    }
+
     Loop updateAndSaveOperationalPolicies(String loopName, List<OperationalPolicy> newOperationalPolicies) {
         Loop loop = findClosedLoopByName(loopName);
         Set<OperationalPolicy> newPolicies = operationalPolicyService.updatePolicies(loop, newOperationalPolicies);
diff --git a/src/main/java/org/onap/clamp/loop/log/LoopLogService.java b/src/main/java/org/onap/clamp/loop/log/LoopLogService.java
index b593b41..b02bc11 100644
--- a/src/main/java/org/onap/clamp/loop/log/LoopLogService.java
+++ b/src/main/java/org/onap/clamp/loop/log/LoopLogService.java
@@ -40,4 +40,8 @@
     public void addLog(String message, String logType, Loop loop) {
         repository.save(new LoopLog(message, LogType.valueOf(logType), loop));
     }
+
+    public boolean isExisting(Long logId) {
+        return repository.existsById(logId);
+    }
 }
diff --git a/src/main/resources/META-INF/services/org/apache/camel/dataformat/clamp-gson b/src/main/resources/META-INF/services/org/apache/camel/dataformat/clamp-gson
new file mode 100644
index 0000000..3fa78e0
--- /dev/null
+++ b/src/main/resources/META-INF/services/org/apache/camel/dataformat/clamp-gson
@@ -0,0 +1,23 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP CLAMP
+ * ================================================================================
+ * Copyright (C) 2019 AT&T Intellectual Property. All rights
+ *                             reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END============================================
+ * ===================================================================
+ */
+ 
+class=org.onap.clamp.configuration.ClampGsonDataFormat
\ No newline at end of file
diff --git a/src/main/resources/application-noaaf.properties b/src/main/resources/application-noaaf.properties
index 84e97ea..56ad7e8 100644
--- a/src/main/resources/application-noaaf.properties
+++ b/src/main/resources/application-noaaf.properties
@@ -110,7 +110,7 @@
 spring.jpa.properties.hibernate.use-new-id-generator-mappings=true
 
 # Whether to enable logging of SQL statements.
-spring.jpa.show-sql=true
+#spring.jpa.show-sql=true
 
 #Async Executor default Parameters
 async.core.pool.size=10
@@ -135,7 +135,7 @@
 #
 #
 # Configuration Settings for Policy Engine Components
-clamp.config.policy.url=http://policy.api.simpledemo.onap.org:8081/policy/api/v1
+clamp.config.policy.url=http://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 b1077d3..6401202 100644
--- a/src/main/resources/application.properties
+++ b/src/main/resources/application.properties
@@ -125,7 +125,7 @@
 spring.jpa.properties.hibernate.use-new-id-generator-mappings=true
 
 # Whether to enable logging of SQL statements.
-spring.jpa.show-sql=true
+#spring.jpa.show-sql=true
 
 #Async Executor default Parameters
 async.core.pool.size=10
@@ -150,7 +150,7 @@
 #
 #
 # Configuration Settings for Policy Engine Components
-clamp.config.policy.url=http://policy.api.simpledemo.onap.org:8081/policy/api/v1
+clamp.config.policy.url=http://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 810c9d2..ffa4719 100644
--- a/src/main/resources/clds/camel/rest/clamp-api-v2.xml
+++ b/src/main/resources/clds/camel/rest/clamp-api-v2.xml
@@ -97,14 +97,14 @@
 		</put>
 		<put uri="/v2/loop/submit/{loopName}">
 			<route>
+				<log
+					loggingLevel="INFO"
+					message="Receive SUBMIT request for loop: ${header.loopName}" />
+				<to
+					uri="bean:org.onap.clamp.authorization.AuthorizationController?method=authorize(*,'cl','','update')" />
 				<setBody>
 					<simple>${header.loopName}</simple>
 				</setBody>
-				<log
-					loggingLevel="INFO"
-					message="Receive SUBMIT request for loop: ${body}" />
-				<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})" />
@@ -120,12 +120,12 @@
 					<log
 						loggingLevel="INFO"
 						message="Processing Micro Service Policy: ${header.microServicePolicy.getName()}" />
-					<setHeader headerName="HttpQueryExceptionFlag">
+					<setHeader headerName="RaiseHttpExceptionFlag">
 						<simple resultType="java.lang.Boolean">false</simple>
 					</setHeader>
 					<to uri="direct:delete-micro-service-policy" />
 
-					<setHeader headerName="HttpQueryExceptionFlag">
+					<setHeader headerName="RaiseHttpExceptionFlag">
 						<simple resultType="java.lang.Boolean">true</simple>
 					</setHeader>
 					<to uri="direct:create-micro-service-policy" />
@@ -143,12 +143,12 @@
 					<log
 						loggingLevel="INFO"
 						message="Processing Operational Policy: ${header.operationalPolicy.getName()}" />
-					<setHeader headerName="HttpQueryExceptionFlag">
+					<setHeader headerName="RaiseHttpExceptionFlag">
 						<simple resultType="java.lang.Boolean">false</simple>
 					</setHeader>
 					<to uri="direct:delete-operational-policy" />
 
-					<setHeader headerName="HttpQueryExceptionFlag">
+					<setHeader headerName="RaiseHttpExceptionFlag">
 						<simple resultType="java.lang.Boolean">true</simple>
 					</setHeader>
 					<to uri="direct:create-operational-policy" />
@@ -165,30 +165,98 @@
 							loggingLevel="INFO"
 							message="Processing Guard Policy: ${header.guardPolicy.getKey()}" />
 
-						<setHeader headerName="HttpQueryExceptionFlag">
+						<setHeader headerName="RaiseHttpExceptionFlag">
 							<simple resultType="java.lang.Boolean">false</simple>
 						</setHeader>
 						<to uri="direct:delete-guard-policy" />
 
-						<setHeader headerName="HttpQueryExceptionFlag">
+						<setHeader headerName="RaiseHttpExceptionFlag">
 							<simple resultType="java.lang.Boolean">true</simple>
 						</setHeader>
 						<to uri="direct:create-guard-policy" />
 					</split>
-
 				</split>
+				<setHeader headerName="RaiseHttpExceptionFlag">
+					<simple resultType="java.lang.Boolean">true</simple>
+				</setHeader>
+				<to uri="direct:create-pdp-group-policy" />
+				
+				<log
+					loggingLevel="INFO"
+					message="SUBMIT request successfully executed for loop: ${body}" />
+				<to
+					uri="bean:org.onap.clamp.loop.log.LoopLogService?method=addLog('SUBMIT request successfully executed','INFO',${header.LoopObject})" />
 			</route>
 		</put>
 		<put uri="/v2/loop/delete/{loopName}">
 			<route>
+				<log
+					loggingLevel="INFO"
+					message="Receive DELETE request for loop: ${header.loopName}" />
 				<to
 					uri="bean:org.onap.clamp.authorization.AuthorizationController?method=authorize(*,'cl','','update')" />
+				<setBody>
+					<simple>${header.loopName}</simple>
+				</setBody>
+				<to uri="direct:load-loop" />
 				<to
-					uri="bean:org.onap.clamp.operation.LoopOperation?method=deleteMsPolicies(${header.loopName})" />
+					uri="bean:org.onap.clamp.loop.log.LoopLogService?method=addLog('Receive DELETE request','INFO',${header.LoopObject})" />
+				<split>
+					<simple>${header.LoopObject.getMicroServicePolicies()}
+					</simple>
+					<setHeader headerName="microServicePolicy">
+						<simple>${body}</simple>
+					</setHeader>
+					<log
+						loggingLevel="INFO"
+						message="Processing Micro Service Policy: ${header.microServicePolicy.getName()}" />
+					<setHeader headerName="RaiseHttpExceptionFlag">
+						<simple resultType="java.lang.Boolean">true</simple>
+					</setHeader>
+					<to uri="direct:delete-micro-service-policy" />
+				</split>
+
+				<log
+					loggingLevel="INFO"
+					message="Processing all OPERATIONAL policies defined in loop ${header.LoopObject.getName()}" />
+				<split>
+					<simple>${header.LoopObject.getOperationalPolicies()}
+					</simple>
+					<setHeader headerName="operationalPolicy">
+						<simple>${body}</simple>
+					</setHeader>
+					<log
+						loggingLevel="INFO"
+						message="Processing Operational Policy: ${header.operationalPolicy.getName()}" />
+					<setHeader headerName="RaiseHttpExceptionFlag">
+						<simple resultType="java.lang.Boolean">true</simple>
+					</setHeader>
+					<to uri="direct:delete-operational-policy" />
+					<log
+						loggingLevel="INFO"
+						message="Processing all GUARD policies defined in loop ${header.LoopObject.getName()}" />
+					<split>
+						<simple>${header.operationalPolicy.createGuardPolicyPayloads().entrySet()}
+						</simple>
+						<setHeader headerName="guardPolicy">
+							<simple>${body}</simple>
+						</setHeader>
+						<log
+							loggingLevel="INFO"
+							message="Processing Guard Policy: ${header.guardPolicy.getKey()}" />
+
+						<setHeader headerName="RaiseHttpExceptionFlag">
+							<simple resultType="java.lang.Boolean">true</simple>
+						</setHeader>
+						<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}" />
 				<to
-					uri="bean:org.onap.clamp.operation.LoopOperation?method=deleteOpPolicy(${header.loopName})" />
-				<to
-					uri="bean:org.onap.clamp.operation.LoopOperation?method=deleteGuardPolicy(${header.loopName})" />
+					uri="bean:org.onap.clamp.loop.log.LoopLogService?method=addLog('DELETE request successfully executed','INFO',${header.LoopObject})" />
 			</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 33419c2..1f3e01e 100644
--- a/src/main/resources/clds/camel/routes/flexible-flow.xml
+++ b/src/main/resources/clds/camel/routes/flexible-flow.xml
@@ -113,14 +113,14 @@
 			<constant>application/json</constant>
 		</setHeader>
 		<setHeader headerName="CamelHttpUri">
-			<simple>{{clamp.config.policy.url}}/policyTypes/${header.microServicePolicy.getModelType()}/versions/1.0.0/policies
+			<simple>{{clamp.config.policy.url}}/policy/api/v1/policyTypes/${header.microServicePolicy.getModelType()}/versions/1.0.0/policies
 			</simple>
 		</setHeader>
 		<log
 			loggingLevel="INFO"
 			message="Endpoint to create microservice policy: ${header.CamelHttpMethod} ${header.CamelHttpUri}"></log>
 		<toD
-			uri="http4://policyhost:8085?throwExceptionOnFailure=${header.HttpQueryExceptionFlag}" />
+			uri="http4://policyhost:8085?throwExceptionOnFailure=${header.RaiseHttpExceptionFlag}&amp;httpClient.connectTimeout=10000&amp;authUsername={{clamp.config.policy.userName}}&amp;authPassword={{clamp.config.policy.password}}" />
 		<to
 			uri="bean:org.onap.clamp.loop.log.LoopLogService?method=addLog('MicroService policy created successfully','INFO',${header.LoopObject})" />
 	</route>
@@ -136,14 +136,14 @@
 			<constant>DELETE</constant>
 		</setHeader>
 		<setHeader headerName="CamelHttpUri">
-			<simple>{{clamp.config.policy.url}}/policyTypes/${header.microServicePolicy.getModelType()}/versions/1.0.0/policies/${header.microServicePolicy.getName()}
+			<simple>{{clamp.config.policy.url}}/policy/api/v1/policyTypes/${header.microServicePolicy.getModelType()}/versions/1.0.0/policies/${header.microServicePolicy.getName()}
 			</simple>
 		</setHeader>
 		<log
 			loggingLevel="INFO"
 			message="Endpoint to delete microservice policy: ${header.CamelHttpMethod} ${header.CamelHttpUri}"></log>
 		<toD
-			uri="http4://policyhost:8085?throwExceptionOnFailure=${header.HttpQueryExceptionFlag}&amp;deleteWithBody=false&amp;mapHttpMessageBody=false&amp;mapHttpMessageFormUrlEncodedBody=false" />
+			uri="http4://policyhost:8085?throwExceptionOnFailure=${header.RaiseHttpExceptionFlag}&amp;httpClient.connectTimeout=10000&amp;deleteWithBody=false&amp;mapHttpMessageBody=false&amp;mapHttpMessageFormUrlEncodedBody=false&amp;authUsername={{clamp.config.policy.userName}}&amp;authPassword={{clamp.config.policy.password}}" />
 		<to
 			uri="bean:org.onap.clamp.loop.log.LoopLogService?method=addLog('MicroService policy deleted successfully','INFO',${header.LoopObject})" />
 	</route>
@@ -161,17 +161,17 @@
 			<constant>POST</constant>
 		</setHeader>
 		<setHeader headerName="Content-Type">
-			<constant>application/json</constant>
+			<constant>application/yaml; legacy-version</constant>
 		</setHeader>
 		<setHeader headerName="CamelHttpUri">
-			<simple>{{clamp.config.policy.url}}/policyTypes/onap.policies.controloop.operational/versions/1.0.0/policies
+			<simple>{{clamp.config.policy.url}}/policy/api/v1/policyTypes/onap.policies.controloop.operational/versions/1.0.0/policies
 			</simple>
 		</setHeader>
 		<log
 			loggingLevel="INFO"
 			message="Endpoint to create operational policy: ${header.CamelHttpMethod} ${header.CamelHttpUri}"></log>
 		<toD
-			uri="http4://policyhost:8085?throwExceptionOnFailure=${header.HttpQueryExceptionFlag}" />
+			uri="http4://policyhost:8085?throwExceptionOnFailure=${header.RaiseHttpExceptionFlag}&amp;httpClient.connectTimeout=10000&amp;authUsername={{clamp.config.policy.userName}}&amp;authPassword={{clamp.config.policy.password}}" />
 		<to
 			uri="bean:org.onap.clamp.loop.log.LoopLogService?method=addLog('Operational policy created successfully','INFO',${header.LoopObject})" />
 	</route>
@@ -187,14 +187,14 @@
 			<constant>DELETE</constant>
 		</setHeader>
 		<setHeader headerName="CamelHttpUri">
-			<simple>{{clamp.config.policy.url}}/policyTypes/onap.policies.controloop.operational/versions/1.0.0/policies/${header.operationalPolicy.getName()}
+			<simple>{{clamp.config.policy.url}}/policy/api/v1/policyTypes/onap.policies.controloop.operational/versions/1.0.0/policies/${header.operationalPolicy.getName()}
 			</simple>
 		</setHeader>
 		<log
 			loggingLevel="INFO"
 			message="Endpoint to delete operational policy: ${header.CamelHttpMethod} ${header.CamelHttpUri}"></log>
 		<toD
-			uri="http4://policyhost:8085?throwExceptionOnFailure=${header.HttpQueryExceptionFlag}&amp;deleteWithBody=false&amp;mapHttpMessageBody=false&amp;mapHttpMessageFormUrlEncodedBody=false" />
+			uri="http4://policyhost:8085?throwExceptionOnFailure=${header.RaiseHttpExceptionFlag}&amp;httpClient.connectTimeout=10000&amp;deleteWithBody=false&amp;mapHttpMessageBody=false&amp;mapHttpMessageFormUrlEncodedBody=false&amp;authUsername={{clamp.config.policy.userName}}&amp;authPassword={{clamp.config.policy.password}}" />
 		<to
 			uri="bean:org.onap.clamp.loop.log.LoopLogService?method=addLog('Operational policy deleted successfully','INFO',${header.LoopObject})" />
 	</route>
@@ -215,14 +215,14 @@
 			<constant>application/json</constant>
 		</setHeader>
 		<setHeader headerName="CamelHttpUri">
-			<simple>{{clamp.config.policy.url}}/policyTypes/onap.policies.controlloop.Guard/versions/1.0.0/policies
+			<simple>{{clamp.config.policy.url}}/policy/api/v1/policyTypes/onap.policies.controlloop.Guard/versions/1.0.0/policies
 			</simple>
 		</setHeader>
 		<log
 			loggingLevel="INFO"
 			message="Endpoint to create guard policy: ${header.CamelHttpMethod} ${header.CamelHttpUri}"></log>
 		<toD
-			uri="http4://policyhost:8085?throwExceptionOnFailure=${header.HttpQueryExceptionFlag}" />
+			uri="http4://policyhost:8085?throwExceptionOnFailure=${header.RaiseHttpExceptionFlag}&amp;httpClient.connectTimeout=10000&amp;authUsername={{clamp.config.policy.userName}}&amp;authPassword={{clamp.config.policy.password}}" />
 		<to
 			uri="bean:org.onap.clamp.loop.log.LoopLogService?method=addLog('Guard policy created successfully','INFO',${header.LoopObject})" />
 	</route>
@@ -238,16 +238,43 @@
 			<constant>DELETE</constant>
 		</setHeader>
 		<setHeader headerName="CamelHttpUri">
-			<simple>{{clamp.config.policy.url}}/policyTypes/onap.policies.controlloop.Guard/versions/1.0.0/policies/${header.guardPolicy.getKey()}
+			<simple>{{clamp.config.policy.url}}/policy/api/v1/policyTypes/onap.policies.controlloop.Guard/versions/1.0.0/policies/${header.guardPolicy.getKey()}
 			</simple>
 		</setHeader>
 		<log
 			loggingLevel="INFO"
 			message="Endpoint to delete guard policy: ${header.CamelHttpMethod} ${header.CamelHttpUri}"></log>
 		<toD
-			uri="http4://policyhost:8085?throwExceptionOnFailure=${header.HttpQueryExceptionFlag}&amp;deleteWithBody=false&amp;mapHttpMessageBody=false&amp;mapHttpMessageFormUrlEncodedBody=false" />
+			uri="http4://policyhost:8085?throwExceptionOnFailure=${header.RaiseHttpExceptionFlag}&amp;httpClient.connectTimeout=10000&amp;deleteWithBody=false&amp;mapHttpMessageBody=false&amp;mapHttpMessageFormUrlEncodedBody=false&amp;authUsername={{clamp.config.policy.userName}}&amp;authPassword={{clamp.config.policy.password}}" />
 		<to
 			uri="bean:org.onap.clamp.loop.log.LoopLogService?method=addLog('Guard policy deleted successfully','INFO',${header.LoopObject})" />
 	</route>
-
+	
+	<route id="create-pdp-group-policy">
+		<from uri="direct:create-pdp-group-policy" />
+		<log
+			loggingLevel="INFO"
+			message="Creating PDP Group Policy: ${header.guardPolicy.getKey()}" />
+		<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>
+		<log
+			loggingLevel="INFO"
+			message="Endpoint to create PDP Group policy: ${header.CamelHttpMethod} ${header.CamelHttpUri}"></log>
+		<toD
+			uri="http4://policyhost:8085?throwExceptionOnFailure=${header.RaiseHttpExceptionFlag}&amp;httpClient.connectTimeout=10000&amp;authUsername={{clamp.config.policy.userName}}&amp;authPassword={{clamp.config.policy.password}}" />
+		<to
+			uri="bean:org.onap.clamp.loop.log.LoopLogService?method=addLog('Pdp Group created successfully','INFO',${header.LoopObject})" />
+	</route>
 </routes>
\ No newline at end of file
diff --git a/src/test/java/org/onap/clamp/loop/LoopServiceTestItCase.java b/src/test/java/org/onap/clamp/loop/LoopServiceTestItCase.java
index 2372338..c4254ec 100644
--- a/src/test/java/org/onap/clamp/loop/LoopServiceTestItCase.java
+++ b/src/test/java/org/onap/clamp/loop/LoopServiceTestItCase.java
@@ -38,8 +38,13 @@
 import org.junit.runner.RunWith;
 import org.onap.clamp.clds.Application;
 import org.onap.clamp.clds.util.JsonUtils;
+import org.onap.clamp.loop.log.LogType;
+import org.onap.clamp.loop.log.LoopLog;
+import org.onap.clamp.loop.log.LoopLogService;
 import org.onap.clamp.policy.microservice.MicroServicePolicy;
+import org.onap.clamp.policy.microservice.MicroservicePolicyService;
 import org.onap.clamp.policy.operational.OperationalPolicy;
+import org.onap.clamp.policy.operational.OperationalPolicyService;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.boot.test.context.SpringBootTest;
 import org.springframework.test.context.junit4.SpringRunner;
@@ -57,6 +62,15 @@
     @Autowired
     LoopsRepository loopsRepository;
 
+    @Autowired
+    MicroservicePolicyService microServicePolicyService;
+
+    @Autowired
+    OperationalPolicyService operationalPolicyService;
+
+    @Autowired
+    LoopLogService loopLogService;
+
     @After
     public void tearDown() {
         loopsRepository.deleteAll();
@@ -276,6 +290,35 @@
         assertThat(returnedGlobalProperties.getAsJsonObject()).isEqualTo(updatedGlobalProperites);
     }
 
+    @Test
+    @Transactional
+    public void deleteAttempt() {
+        saveTestLoopToDb();
+        // Add log
+        Loop loop = loopsRepository.findById(EXAMPLE_LOOP_NAME).orElse(null);
+        loop.addLog(new LoopLog("test", LogType.INFO, loop));
+        loop = loopService.saveOrUpdateLoop(loop);
+        // Add op policy
+        OperationalPolicy operationalPolicy = new OperationalPolicy("opPolicy", null,
+            JsonUtils.GSON.fromJson(EXAMPLE_JSON, JsonObject.class));
+        loopService.updateAndSaveOperationalPolicies(EXAMPLE_LOOP_NAME, Lists.newArrayList(operationalPolicy));
+
+        // Add Micro service policy
+        MicroServicePolicy microServicePolicy = new MicroServicePolicy("microPolicy", "",
+            "tosca_definitions_version: tosca_simple_yaml_1_0_0", false,
+            JsonUtils.GSON.fromJson(EXAMPLE_JSON, JsonObject.class), null);
+        loopService.updateAndSaveMicroservicePolicies(EXAMPLE_LOOP_NAME, Lists.newArrayList(microServicePolicy));
+
+        // Verify it's there
+        assertThat(loopsRepository.findById(EXAMPLE_LOOP_NAME).orElse(null)).isNotNull();
+        loopService.deleteLoop(EXAMPLE_LOOP_NAME);
+        // Verify it's well deleted and has been cascaded
+        assertThat(loopsRepository.findById(EXAMPLE_LOOP_NAME).orElse(null)).isNull();
+        assertThat(microServicePolicyService.isExisting("microPolicy")).isFalse();
+        assertThat(operationalPolicyService.isExisting("opPolicy")).isFalse();
+        assertThat(loopLogService.isExisting(((LoopLog) loop.getLoopLogs().toArray()[0]).getId())).isFalse();
+    }
+
     private Loop createTestLoop(String loopName, String loopBlueprint, String loopSvg) {
         return new Loop(loopName, loopBlueprint, loopSvg);
     }
diff --git a/src/test/java/org/onap/clamp/loop/LoopToJsonTest.java b/src/test/java/org/onap/clamp/loop/LoopToJsonTest.java
index 0e03e1b..dcad1a5 100644
--- a/src/test/java/org/onap/clamp/loop/LoopToJsonTest.java
+++ b/src/test/java/org/onap/clamp/loop/LoopToJsonTest.java
@@ -29,15 +29,18 @@
 import com.google.gson.Gson;
 import com.google.gson.JsonObject;
 
+import java.io.IOException;
 import java.util.HashSet;
 import java.util.Random;
 
 import org.junit.Test;
 import org.onap.clamp.clds.util.JsonUtils;
+import org.onap.clamp.clds.util.ResourceFileUtil;
 import org.onap.clamp.loop.log.LogType;
 import org.onap.clamp.loop.log.LoopLog;
 import org.onap.clamp.policy.microservice.MicroServicePolicy;
 import org.onap.clamp.policy.operational.OperationalPolicy;
+import org.skyscreamer.jsonassert.JSONAssert;
 
 public class LoopToJsonTest {
 
@@ -74,10 +77,11 @@
     }
 
     @Test
-    public void LoopGsonTest() {
+    public void LoopGsonTest() throws IOException {
         Loop loopTest = getLoop("ControlLoopTest", "<xml></xml>", "yamlcontent", "{\"testname\":\"testvalue\"}",
             "123456789", "https://dcaetest.org", "UUID-blueprint");
-        OperationalPolicy opPolicy = this.getOperationalPolicy("{\"type\":\"GUARD\"}", "GuardOpPolicyTest");
+        OperationalPolicy opPolicy = this.getOperationalPolicy(
+            ResourceFileUtil.getResourceAsString("tosca/operational-policy-properties.json"), "GuardOpPolicyTest");
         loopTest.addOperationalPolicy(opPolicy);
         MicroServicePolicy microServicePolicy = getMicroServicePolicy("configPolicyTest", "",
             "{\"configtype\":\"json\"}", "tosca_definitions_version: tosca_simple_yaml_1_0_0",
@@ -103,4 +107,20 @@
         assertThat((LoopLog) loopTestDeserialized.getLoopLogs().toArray()[0]).isEqualToIgnoringGivenFields(loopLog,
             "loop");
     }
+
+    @Test
+    public void createPoliciesPayloadPdpGroupTest() throws IOException {
+        Loop loopTest = getLoop("ControlLoopTest", "<xml></xml>", "yamlcontent", "{\"testname\":\"testvalue\"}",
+            "123456789", "https://dcaetest.org", "UUID-blueprint");
+        OperationalPolicy opPolicy = this.getOperationalPolicy(
+            ResourceFileUtil.getResourceAsString("tosca/operational-policy-properties.json"), "GuardOpPolicyTest");
+        loopTest.addOperationalPolicy(opPolicy);
+        MicroServicePolicy microServicePolicy = getMicroServicePolicy("configPolicyTest", "",
+            "{\"configtype\":\"json\"}", "tosca_definitions_version: tosca_simple_yaml_1_0_0",
+            "{\"param1\":\"value1\"}", true);
+        loopTest.addMicroServicePolicy(microServicePolicy);
+
+        JSONAssert.assertEquals(ResourceFileUtil.getResourceAsString("tosca/pdp-group-policy-payload.json"),
+            loopTest.createPoliciesPayloadPdpGroup(), false);
+    }
 }
diff --git a/src/test/resources/tosca/pdp-group-policy-payload.json b/src/test/resources/tosca/pdp-group-policy-payload.json
new file mode 100644
index 0000000..bf941e5
--- /dev/null
+++ b/src/test/resources/tosca/pdp-group-policy-payload.json
@@ -0,0 +1,16 @@
+{
+  "policies": [
+    {
+      "policy-id": "GuardOpPolicyTest"
+    },
+    {
+      "policy-id": "guard2"
+    },
+    {
+      "policy-id": "guard1"
+    },
+    {
+      "policy-id": "configPolicyTest"
+    }
+  ]
+}
\ No newline at end of file