Standardize loop controller 21/102521/1
authorsebdet <sebastien.determe@intl.att.com>
Thu, 27 Feb 2020 19:43:51 +0000 (11:43 -0800)
committersebdet <sebastien.determe@intl.att.com>
Thu, 27 Feb 2020 19:43:51 +0000 (11:43 -0800)
Make all calls from camel to loop controller instead of the service to make things consistent.

Issue-ID: CLAMP-647

Change-Id: I68524bd3d5bfbf5dd7a4acf6c59823df06fd4cd9
Signed-off-by: sebdet <sebastien.determe@intl.att.com>
src/main/java/org/onap/clamp/loop/LoopController.java
src/main/java/org/onap/clamp/loop/LoopService.java
src/main/resources/clds/camel/rest/clamp-api-v2.xml

index 7b037da..2ad47a3 100644 (file)
@@ -26,10 +26,8 @@ package org.onap.clamp.loop;
 import com.google.gson.JsonArray;
 import com.google.gson.JsonObject;
 import com.google.gson.reflect.TypeToken;
-
 import java.lang.reflect.Type;
 import java.util.List;
-
 import org.onap.clamp.clds.util.JsonUtils;
 import org.onap.clamp.policy.microservice.MicroServicePolicy;
 import org.onap.clamp.policy.operational.OperationalPolicy;
@@ -102,6 +100,27 @@ public class LoopController {
         return loopService.updateAndSaveGlobalPropertiesJson(loopName, globalProperties);
     }
 
+    /**
+     * This method add an operational policy to a loop instance.
+     *
+     * @param loopName The loop name
+     * @param policyType The policy model type
+     * @param policyVersion The policy model  version
+     * @return The loop modified
+     */
+    public Loop addOperationalPolicy(String loopName, String policyType, String policyVersion) {
+        return loopService.addOperationalPolicy(loopName,policyType,policyVersion);
+    }
+
+    /**
+     * This method deletes the loop.
+     *
+     * @param loopName The loop Name
+     */
+    public void deleteLoop(String loopName) {
+        loopService.deleteLoop(loopName);
+    }
+
     /**
      * Update one MicroService policy properties.
      *
index 34be203..0be3132 100644 (file)
@@ -102,8 +102,16 @@ public class LoopService {
         loopsRepository.save(loop);
     }
 
+    /**
+     * This method add an operational policy to a loop instance.
+     *
+     * @param loopName The loop name
+     * @param policyType The policy model type
+     * @param policyVersion The policy model  version
+     * @return The loop modified
+     */
     Loop addOperationalPolicy(String loopName, String policyType, String policyVersion) {
-        Loop loop = findClosedLoopByName(loopName);
+        Loop loop = getLoop(loopName);
         PolicyModel policyModel = policyModelsService.getPolicyModel(policyType, policyVersion);
         if (policyModel == null) {
             return null;
index 280b808..3bcfc06 100644 (file)
                                                </split>
                                        </split>
                                        <to
-                                               uri="bean:org.onap.clamp.loop.log.LoopService?method=deleteLoop(${header.loopName})" />
+                                               uri="bean:org.onap.clamp.loop.log.LoopController?method=deleteLoop(${header.loopName})" />
                                        <log loggingLevel="INFO"
                                                message="DELETE request successfully executed for loop: ${header.loopName}" />
                                        <to
                                                        uri="bean:org.onap.clamp.loop.log.LoopLogService?method=addLog('ADD OperationalPolicy request','INFO',${exchangeProperty[loopObject]})" />
                                        <doTry>
                                                <to
-                                                               uri="bean:org.onap.clamp.loop.LoopService?method=addOperationalPolicy(${loopName},${policyType},${policyVersion})" />
+                                                               uri="bean:org.onap.clamp.loop.LoopController?method=addOperationalPolicy(${loopName},${policyType},${policyVersion})" />
 
                                                <to
                                                                uri="bean:org.onap.clamp.loop.log.LoopLogService?method=addLog('ADD OperationalPolicy request successfully executed','INFO',${exchangeProperty[loopObject]})" />