Refactor the java packages 55/23855/1
authorDeterme, Sebastien (sd378r) <sd378r@intl.att.com>
Thu, 16 Nov 2017 12:40:22 +0000 (13:40 +0100)
committerDeterme, Sebastien (sd378r) <sd378r@intl.att.com>
Thu, 16 Nov 2017 13:00:03 +0000 (14:00 +0100)
Refactor the java packages, moving classes to others packages

Change-Id: I5cd2a6477876ce187502afff37a862029a081ab3
Issue-ID: CLAMP-74
Signed-off-by: Determe, Sebastien (sd378r) <sd378r@intl.att.com>
32 files changed:
src/main/java/org/onap/clamp/clds/Application.java
src/main/java/org/onap/clamp/clds/client/DcaeInventoryServices.java
src/main/java/org/onap/clamp/clds/client/HolmesPolicyDelegate.java
src/main/java/org/onap/clamp/clds/client/HolmesPolicyDeleteDelegate.java
src/main/java/org/onap/clamp/clds/client/OperationalPolicyDelegate.java
src/main/java/org/onap/clamp/clds/client/OperationalPolicyDeleteDelegate.java
src/main/java/org/onap/clamp/clds/client/SdcSendReqDelegate.java
src/main/java/org/onap/clamp/clds/client/TcaPolicyDelegate.java
src/main/java/org/onap/clamp/clds/client/TcaPolicyDeleteDelegate.java
src/main/java/org/onap/clamp/clds/client/req/policy/OperationalPolicyReq.java [moved from src/main/java/org/onap/clamp/clds/client/req/OperationalPolicyReq.java with 99% similarity]
src/main/java/org/onap/clamp/clds/client/req/policy/PolicyClient.java [moved from src/main/java/org/onap/clamp/clds/client/PolicyClient.java with 93% similarity]
src/main/java/org/onap/clamp/clds/client/req/sdc/SdcCatalogServices.java [moved from src/main/java/org/onap/clamp/clds/client/SdcCatalogServices.java with 86% similarity]
src/main/java/org/onap/clamp/clds/client/req/sdc/SdcReq.java [moved from src/main/java/org/onap/clamp/clds/client/req/SdcReq.java with 77% similarity]
src/main/java/org/onap/clamp/clds/client/req/tca/TcaRequestFormatter.java [moved from src/main/java/org/onap/clamp/clds/client/req/TcaRequestFormatter.java with 71% similarity]
src/main/java/org/onap/clamp/clds/config/CldsConfiguration.java
src/main/java/org/onap/clamp/clds/dao/CldsDao.java
src/main/java/org/onap/clamp/clds/dao/CldsServiceDataMapper.java [new file with mode: 0644]
src/main/java/org/onap/clamp/clds/dao/ValueItemMapper.java [new file with mode: 0644]
src/main/java/org/onap/clamp/clds/exception/ModelPropertiesException.java [new file with mode: 0644]
src/main/java/org/onap/clamp/clds/model/prop/ModelBpmn.java
src/main/java/org/onap/clamp/clds/service/CldsService.java
src/main/java/org/onap/clamp/clds/service/CldsTemplateService.java
src/test/java/org/onap/clamp/clds/AbstractItCase.java
src/test/java/org/onap/clamp/clds/client/req/OperationalPolicyReqTest.java
src/test/java/org/onap/clamp/clds/it/CldsDaoItCase.java
src/test/java/org/onap/clamp/clds/it/CldsServiceItCase.java
src/test/java/org/onap/clamp/clds/it/OperationPolicyReqItCase.java
src/test/java/org/onap/clamp/clds/it/PolicyClientItCase.java
src/test/java/org/onap/clamp/clds/it/RefPropItCase.java
src/test/java/org/onap/clamp/clds/it/SdcCatalogServicesItCase.java
src/test/java/org/onap/clamp/clds/it/SdcReqItCase.java
src/test/java/org/onap/clamp/clds/it/TcaRequestFormatterItCase.java

index 0304a68..e2bfbd7 100644 (file)
@@ -65,28 +65,22 @@ import org.springframework.scheduling.annotation.EnableAsync;
         ManagementWebSecurityAutoConfiguration.class })
 @EnableAsync
 public class Application extends SpringBootServletInitializer {
-
-    protected static final EELFLogger eelfLogger         = EELFManager.getInstance().getLogger(Application.class);
-
+    protected static final EELFLogger EELF_LOGGER        = EELFManager.getInstance().getLogger(Application.class);
     @Autowired
-    protected ApplicationContext      appContext;
-
+    private ApplicationContext        appContext;
     private static final String       CAMEL_SERVLET_NAME = "CamelServlet";
     private static final String       CAMEL_URL_MAPPING  = "/restservices/clds/v1/*";
-
     // This settings is an additional one to Spring config,
     // only if we want to have an additional port automatically redirected to
     // HTTPS
     @Value("${server.http-to-https-redirection.port:none}")
     private String                    httpRedirectedPort;
-
     /**
      * This 8080 is the default port used by spring if this parameter is not
      * specified in application.properties.
      */
     @Value("${server.port:8080}")
     private String                    springServerPort;
-
     @Value("${server.ssl.key-store:none}")
     private String                    sslKeystoreFile;
 
@@ -139,15 +133,13 @@ public class Application extends SpringBootServletInitializer {
             if (newConnector != null) {
                 tomcat.addAdditionalTomcatConnectors(newConnector);
             }
-
         }
         return tomcat;
-
     }
 
     private Connector createRedirectConnector(int redirectSecuredPort) {
         if (redirectSecuredPort <= 0) {
-            eelfLogger.warn(
+            EELF_LOGGER.warn(
                     "HTTP port redirection to HTTPS is disabled because the HTTPS port is 0 (random port) or -1 (Connector disabled)");
             return null;
         }
@@ -158,5 +150,4 @@ public class Application extends SpringBootServletInitializer {
         connector.setRedirectPort(redirectSecuredPort);
         return connector;
     }
-
 }
index 7662a9f..53d17aa 100644 (file)
@@ -32,6 +32,7 @@ import java.security.GeneralSecurityException;
 import java.util.Date;\r
 import java.util.List;\r
 \r
+import org.apache.commons.codec.DecoderException;\r
 import org.json.simple.JSONArray;\r
 import org.json.simple.JSONObject;\r
 import org.json.simple.parser.JSONParser;\r
@@ -74,8 +75,11 @@ public class DcaeInventoryServices {
      *             In case of issue when decryting the DCAE password\r
      * @throws ParseException\r
      *             In case of DCAE Json parse exception\r
+     * @throws DecoderException\r
+     *             In case of issues with HexString decoding\r
      */\r
-    public void setEventInventory(CldsModel cldsModel, String userId) throws GeneralSecurityException, ParseException {\r
+    public void setEventInventory(CldsModel cldsModel, String userId)\r
+            throws GeneralSecurityException, ParseException, DecoderException {\r
         String artifactName = cldsModel.getControlName();\r
         DcaeEvent dcaeEvent = new DcaeEvent();\r
         String isDcaeInfoAvailable = null;\r
@@ -152,7 +156,9 @@ public class DcaeInventoryServices {
      *            The resource UUID\r
      * @return The DCAE inventory for the artifact\r
      * @throws IOException\r
+     *             In case of issues with the stream\r
      * @throws ParseException\r
+     *             In case of issues with the Json parsing\r
      * \r
      */\r
     public String getDcaeInformation(String artifactName, String serviceUuid, String resourceUuid)\r
index 5e0d470..aaa4a2c 100644 (file)
@@ -30,6 +30,7 @@ import java.util.UUID;
 
 import org.camunda.bpm.engine.delegate.DelegateExecution;
 import org.camunda.bpm.engine.delegate.JavaDelegate;
+import org.onap.clamp.clds.client.req.policy.PolicyClient;
 import org.onap.clamp.clds.model.prop.Holmes;
 import org.onap.clamp.clds.model.prop.ModelProperties;
 import org.onap.clamp.clds.model.refprop.RefProp;
@@ -41,10 +42,8 @@ import org.springframework.beans.factory.annotation.Autowired;
 public class HolmesPolicyDelegate implements JavaDelegate {
     protected static final EELFLogger logger        = EELFManager.getInstance().getLogger(HolmesPolicyDelegate.class);
     protected static final EELFLogger metricsLogger = EELFManager.getInstance().getMetricsLogger();
-
     @Autowired
     private PolicyClient              policyClient;
-
     @Autowired
     private RefProp                   refProp;
 
@@ -54,22 +53,30 @@ public class HolmesPolicyDelegate implements JavaDelegate {
      * @param execution
      */
     @Override
-    public void execute(DelegateExecution execution) throws Exception {
+    public void execute(DelegateExecution execution) {
         String holmesPolicyRequestUuid = UUID.randomUUID().toString();
         execution.setVariable("holmesPolicyRequestUuid", holmesPolicyRequestUuid);
-
         ModelProperties prop = ModelProperties.create(execution);
         Holmes holmes = prop.getType(Holmes.class);
         if (holmes.isFound()) {
-            String responseMessage = policyClient.sendBasePolicyInOther(formatHolmesConfigBody(prop, holmes), holmes.getConfigPolicyName(), prop,
-                    holmesPolicyRequestUuid);
+            String responseMessage = policyClient.sendBasePolicyInOther(formatHolmesConfigBody(prop, holmes),
+                    holmes.getConfigPolicyName(), prop, holmesPolicyRequestUuid);
             if (responseMessage != null) {
                 execution.setVariable("holmesPolicyResponseMessage", responseMessage.getBytes());
             }
         }
     }
 
-    public static String formatHolmesConfigBody (ModelProperties prop, Holmes holmes) {
+    /**
+     * This method is used to create the Payload that must be sent to Holmes.
+     * 
+     * @param prop
+     *            The ModelProperties containing all the closed loop props
+     * @param holmes
+     *            The holmes object extracted from the closed loop
+     * @return The String that must be sent to policy for holmes
+     */
+    public static String formatHolmesConfigBody(ModelProperties prop, Holmes holmes) {
         return prop.getControlName() + "$$$" + holmes.getCorrelationLogic();
     }
 }
index c3c91fa..72db328 100644 (file)
@@ -26,8 +26,11 @@ package org.onap.clamp.clds.client;
 import com.att.eelf.configuration.EELFLogger;
 import com.att.eelf.configuration.EELFManager;
 
+import java.io.IOException;
+
 import org.camunda.bpm.engine.delegate.DelegateExecution;
 import org.camunda.bpm.engine.delegate.JavaDelegate;
+import org.onap.clamp.clds.client.req.policy.PolicyClient;
 import org.onap.clamp.clds.model.prop.Holmes;
 import org.onap.clamp.clds.model.prop.ModelProperties;
 import org.springframework.beans.factory.annotation.Autowired;
@@ -39,7 +42,6 @@ public class HolmesPolicyDeleteDelegate implements JavaDelegate {
     protected static final EELFLogger logger        = EELFManager.getInstance()
             .getLogger(HolmesPolicyDeleteDelegate.class);
     protected static final EELFLogger metricsLogger = EELFManager.getInstance().getMetricsLogger();
-
     @Autowired
     private PolicyClient              policyClient;
 
@@ -47,16 +49,15 @@ public class HolmesPolicyDeleteDelegate implements JavaDelegate {
      * Perform activity. Delete Holmes Policy via policy api.
      *
      * @param execution
+     * @throws IOException
      */
     @Override
-    public void execute(DelegateExecution execution) throws Exception {
+    public void execute(DelegateExecution execution) {
         ModelProperties prop = ModelProperties.create(execution);
         Holmes holmes = prop.getType(Holmes.class);
         if (holmes.isFound()) {
             prop.setCurrentModelElementId(holmes.getId());
-
             policyClient.deleteBasePolicy(prop);
         }
     }
-
 }
index 493b3b3..e6af433 100644 (file)
@@ -26,12 +26,13 @@ package org.onap.clamp.clds.client;
 import com.att.eelf.configuration.EELFLogger;
 import com.att.eelf.configuration.EELFManager;
 
-import java.io.IOException;
+import java.io.UnsupportedEncodingException;
 import java.util.Map;
 
 import org.camunda.bpm.engine.delegate.DelegateExecution;
 import org.camunda.bpm.engine.delegate.JavaDelegate;
-import org.onap.clamp.clds.client.req.OperationalPolicyReq;
+import org.onap.clamp.clds.client.req.policy.OperationalPolicyReq;
+import org.onap.clamp.clds.client.req.policy.PolicyClient;
 import org.onap.clamp.clds.model.prop.ModelProperties;
 import org.onap.clamp.clds.model.prop.Policy;
 import org.onap.clamp.clds.model.prop.PolicyChain;
@@ -51,13 +52,11 @@ public class OperationalPolicyDelegate implements JavaDelegate {
     protected static final EELFLogger logger        = EELFManager.getInstance()
             .getLogger(OperationalPolicyDelegate.class);
     protected static final EELFLogger metricsLogger = EELFManager.getInstance().getMetricsLogger();
-
     /**
      * Automatically injected by Spring, define in CldsConfiguration as a bean.
      */
     @Autowired
     private PolicyClient              policyClient;
-
     /**
      * Automatically injected by Spring, define in CldsConfiguration as a bean.
      */
@@ -71,13 +70,13 @@ public class OperationalPolicyDelegate implements JavaDelegate {
      *            The DelegateExecution
      * @throws BuilderException
      *             In case of issues with OperationalPolicyReq
-     * @throws IOException
-     *             In case of issues with the stream
      * @throws PolicyEngineException
      *             In case of issues with the PolicyEngine creation
+     * @throws UnsupportedEncodingException
      */
     @Override
-    public void execute(DelegateExecution execution) throws IOException, BuilderException, PolicyEngineException {
+    public void execute(DelegateExecution execution)
+            throws BuilderException, PolicyEngineException, UnsupportedEncodingException {
         String responseMessage = null;
         String operationalPolicyRequestUuid = null;
         ModelProperties prop = ModelProperties.create(execution);
@@ -94,5 +93,4 @@ public class OperationalPolicyDelegate implements JavaDelegate {
             }
         }
     }
-
 }
index 2c60941..2bca639 100644 (file)
 
 package org.onap.clamp.clds.client;
 
+import com.att.eelf.configuration.EELFLogger;
+import com.att.eelf.configuration.EELFManager;
+
+import java.io.IOException;
+
 import org.camunda.bpm.engine.delegate.DelegateExecution;
 import org.camunda.bpm.engine.delegate.JavaDelegate;
+import org.onap.clamp.clds.client.req.policy.PolicyClient;
 import org.onap.clamp.clds.model.prop.ModelProperties;
 import org.onap.clamp.clds.model.prop.Policy;
 import org.onap.clamp.clds.model.prop.PolicyChain;
 import org.springframework.beans.factory.annotation.Autowired;
 
-import com.att.eelf.configuration.EELFLogger;
-import com.att.eelf.configuration.EELFManager;
-
 /**
  * Delete Operational Policy via policy api.
  */
@@ -40,31 +43,29 @@ public class OperationalPolicyDeleteDelegate implements JavaDelegate {
     protected static final EELFLogger logger        = EELFManager.getInstance()
             .getLogger(OperationalPolicyDeleteDelegate.class);
     protected static final EELFLogger metricsLogger = EELFManager.getInstance().getMetricsLogger();
-
     @Autowired
-    private PolicyClient            policyClient;
+    private PolicyClient              policyClient;
 
     /**
      * Perform activity. Delete Operational Policy via policy api.
      *
      * @param execution
+     * @throws IOException
      */
     @Override
-    public void execute(DelegateExecution execution) throws Exception {
+    public void execute(DelegateExecution execution) {
         ModelProperties prop = ModelProperties.create(execution);
         Policy policy = prop.getType(Policy.class);
         prop.setCurrentModelElementId(policy.getId());
-
         String responseMessage = "";
-               if(policy.isFound()){
-               for (PolicyChain policyChain : policy.getPolicyChains()) {
-                   prop.setPolicyUniqueId(policyChain.getPolicyId());
-                   responseMessage = policyClient.deleteBrms(prop);
-               }
-               if (responseMessage != null) {
-                   execution.setVariable("operationalPolicyDeleteResponseMessage", responseMessage.getBytes());
-               }
-           }
+        if (policy.isFound()) {
+            for (PolicyChain policyChain : policy.getPolicyChains()) {
+                prop.setPolicyUniqueId(policyChain.getPolicyId());
+                responseMessage = policyClient.deleteBrms(prop);
+            }
+            if (responseMessage != null) {
+                execution.setVariable("operationalPolicyDeleteResponseMessage", responseMessage.getBytes());
+            }
+        }
     }
-
 }
index 90bdcb3..b582349 100644 (file)
@@ -30,7 +30,8 @@ import java.util.List;
 
 import org.camunda.bpm.engine.delegate.DelegateExecution;
 import org.camunda.bpm.engine.delegate.JavaDelegate;
-import org.onap.clamp.clds.client.req.SdcReq;
+import org.onap.clamp.clds.client.req.sdc.SdcCatalogServices;
+import org.onap.clamp.clds.client.req.sdc.SdcReq;
 import org.onap.clamp.clds.model.DcaeEvent;
 import org.onap.clamp.clds.model.prop.ModelProperties;
 import org.onap.clamp.clds.model.refprop.RefProp;
index 7de1268..2d7df84 100644 (file)
@@ -30,7 +30,8 @@ import java.util.UUID;
 
 import org.camunda.bpm.engine.delegate.DelegateExecution;
 import org.camunda.bpm.engine.delegate.JavaDelegate;
-import org.onap.clamp.clds.client.req.TcaRequestFormatter;
+import org.onap.clamp.clds.client.req.policy.PolicyClient;
+import org.onap.clamp.clds.client.req.tca.TcaRequestFormatter;
 import org.onap.clamp.clds.model.prop.ModelProperties;
 import org.onap.clamp.clds.model.prop.Tca;
 import org.onap.clamp.clds.model.refprop.RefProp;
@@ -44,10 +45,8 @@ import org.springframework.beans.factory.annotation.Autowired;
 public class TcaPolicyDelegate implements JavaDelegate {
     protected static final EELFLogger logger        = EELFManager.getInstance().getLogger(TcaPolicyDelegate.class);
     protected static final EELFLogger metricsLogger = EELFManager.getInstance().getMetricsLogger();
-
     @Autowired
     private RefProp                   refProp;
-
     @Autowired
     PolicyClient                      policyClient;
 
@@ -60,16 +59,14 @@ public class TcaPolicyDelegate implements JavaDelegate {
     public void execute(DelegateExecution execution) throws Exception {
         String tcaPolicyRequestUuid = UUID.randomUUID().toString();
         execution.setVariable("tcaPolicyRequestUuid", tcaPolicyRequestUuid);
-
         ModelProperties prop = ModelProperties.create(execution);
         Tca tca = prop.getType(Tca.class);
         if (tca.isFound()) {
             String policyJson = TcaRequestFormatter.createPolicyJson(refProp, prop);
-            String responseMessage = policyClient.sendMicroServiceInOther(policyJson, prop, tcaPolicyRequestUuid);
+            String responseMessage = policyClient.sendMicroServiceInOther(policyJson, prop);
             if (responseMessage != null) {
                 execution.setVariable("tcaPolicyResponseMessage", responseMessage.getBytes());
             }
         }
     }
-
 }
index d3fb3f7..e88b720 100644 (file)
@@ -25,6 +25,7 @@ package org.onap.clamp.clds.client;
 
 import org.camunda.bpm.engine.delegate.DelegateExecution;
 import org.camunda.bpm.engine.delegate.JavaDelegate;
+import org.onap.clamp.clds.client.req.policy.PolicyClient;
 import org.onap.clamp.clds.model.prop.ModelProperties;
 import org.onap.clamp.clds.model.prop.Tca;
 import org.springframework.beans.factory.annotation.Autowired;
@@ -21,7 +21,7 @@
  * ECOMP is a trademark and service mark of AT&T Intellectual Property.
  */
 
-package org.onap.clamp.clds.client.req;
+package org.onap.clamp.clds.client.req.policy;
 
 import com.att.eelf.configuration.EELFLogger;
 import com.att.eelf.configuration.EELFLogger.Level;
@@ -67,7 +67,6 @@ public class OperationalPolicyReq {
     protected static final EELFLogger metricsLogger = EELFManager.getInstance().getMetricsLogger();
 
     private OperationalPolicyReq() {
-
     }
 
     /**
@@ -84,7 +83,6 @@ public class OperationalPolicyReq {
         Global global = prop.getGlobal();
         prop.setCurrentModelElementId(modelElementId);
         prop.setPolicyUniqueId(policyChain.getPolicyId());
-
         String templateName = "";
         String operationTopic = "";
         String notificationTopic = "";
@@ -110,24 +108,19 @@ public class OperationalPolicyReq {
             controller = refProp.getStringValue("op.controller", global.getService());
         }
         String recipeTopic = refProp.getStringValue("op.recipeTopic", global.getService());
-
         // ruleAttributes
         Map<String, String> ruleAttributes = new HashMap<>();
-
         if (operationTopic == null || operationTopic.isEmpty()) {
             logger.info("templateName=" + templateName);
             logger.info("recipeTopic=" + recipeTopic);
             logger.info("notificationTopic=" + notificationTopic);
-
             // if no operationTopic, then don't format yaml - use first policy
             // from list
             PolicyItem policyItem = policyChain.getPolicyItems().get(0);
-
             ruleAttributes.put("templateName", templateName);
             ruleAttributes.put("ClosedLoopControlName", prop.getControlNameAndPolicyUniqueId());
             ruleAttributes.put("RecipeTopic", recipeTopic);
             ruleAttributes.put("NotificationTopic", notificationTopic);
-
             String recipe = policyItem.getRecipe();
             String maxRetries = String.valueOf(policyItem.getMaxRetries());
             String retryTimeLimit = String.valueOf(policyItem.getRetryTimeLimit());
@@ -140,32 +133,25 @@ public class OperationalPolicyReq {
             ruleAttributes.put("MaxRetries", maxRetries);
             ruleAttributes.put("RetryTimeLimit", retryTimeLimit);
             ruleAttributes.put("ResourceId", targetResourceId);
-
         } else {
             logger.info("templateName=" + templateName);
             logger.info("operationTopic=" + operationTopic);
             logger.info("notificationTopic=" + notificationTopic);
-
             // format yaml
             String yaml = (tca != null && tca.isFound()) ? formateNodeBYaml(refProp, prop, modelElementId, policyChain)
                     : formatYaml(refProp, prop, modelElementId, policyChain);
-
             ruleAttributes.put("templateName", templateName);
             ruleAttributes.put("ClosedLoopControlName", prop.getControlNameAndPolicyUniqueId());
             ruleAttributes.put("OperationTopic", operationTopic);
             ruleAttributes.put("NotificationTopic", notificationTopic);
-
             ruleAttributes.put("ControlLoopYaml", yaml);
         }
-
         // matchingAttributes
         Map<String, String> matchingAttributes = new HashMap<>();
         matchingAttributes.put("controller", controller);
-
         Map<AttributeType, Map<String, String>> attributes = new HashMap<>();
         attributes.put(AttributeType.RULE, ruleAttributes);
         attributes.put(AttributeType.MATCHING, matchingAttributes);
-
         return attributes;
     }
 
@@ -180,22 +166,18 @@ public class OperationalPolicyReq {
      */
     public static String formatYaml(RefProp refProp, ModelProperties prop, String modelElementId,
             PolicyChain policyChain) throws BuilderException, UnsupportedEncodingException {
-
         // get property objects
         Global global = prop.getGlobal();
         prop.setCurrentModelElementId(modelElementId);
         prop.setPolicyUniqueId(policyChain.getPolicyId());
-
         // convert values to SDC objects
         Service service = new Service(global.getService());
         Resource[] vfResources = convertToResource(global.getResourceVf(), ResourceType.VF);
         Resource[] vfcResources = convertToResource(global.getResourceVfc(), ResourceType.VFC);
-
         // create builder
         ControlLoopPolicyBuilder builder = ControlLoopPolicyBuilder.Factory.buildControlLoop(prop.getControlName(),
                 policyChain.getTimeout(), service, vfResources);
         builder.addResource(vfcResources);
-
         // process each policy
         Map<String, Policy> policyObjMap = new HashMap<>();
         List<PolicyItem> policyItemList = orderParentFirst(policyChain.getPolicyItems());
@@ -219,12 +201,10 @@ public class OperationalPolicyReq {
                         refProp.getStringValue("op.policy.appc"), target, policyItem.getRecipe(), null,
                         policyItem.getMaxRetries(), policyItem.getRetryTimeLimit(), parentPolicyObj.getId(),
                         convertToPolicyResult(policyItem.getParentPolicyConditions()));
-
                 logger.info("policyObj.id=" + policyObj.getId() + "; parentPolicyObj.id=" + parentPolicyObj.getId());
             }
             policyObjMap.put(policyItem.getId(), policyObj);
         }
-
         //
         // Build the specification
         //
@@ -255,27 +235,22 @@ public class OperationalPolicyReq {
      */
     public static String formateNodeBYaml(RefProp refProp, ModelProperties prop, String modelElementId,
             PolicyChain policyChain) throws BuilderException, UnsupportedEncodingException {
-
         // get property objects
         Global global = prop.getGlobal();
         prop.setCurrentModelElementId(modelElementId);
         prop.setPolicyUniqueId(policyChain.getPolicyId());
-
         // convert values to SDC objects
         Service service = new Service(global.getService());
         Resource[] vfResources = convertToResource(global.getResourceVf(), ResourceType.VF);
         Resource[] vfcResources = convertToResource(global.getResourceVfc(), ResourceType.VFC);
-
         // create builder
         ControlLoopPolicyBuilder builder = ControlLoopPolicyBuilder.Factory.buildControlLoop(prop.getControlName(),
                 policyChain.getTimeout(), service, vfResources);
         builder.addResource(vfcResources);
-
         // process each policy
         Map<String, Policy> policyObjMap = new HashMap<>();
         List<PolicyItem> policyItemList = addAOTSActorRecipe(refProp, global.getService(),
                 policyChain.getPolicyItems());
-
         Policy lastPolicyObj = new Policy();
         for (PolicyItem policyItem : policyItemList) {
             Target target = new Target();
@@ -309,7 +284,6 @@ public class OperationalPolicyReq {
         operationsAccumulateParams.setLimit(Integer.valueOf(refProp.getStringValue("op.eNodeB.limit")));
         operationsAccumulateParams.setPeriod(refProp.getStringValue("op.eNodeB.period"));
         builder.addOperationsAccumulateParams(lastPolicyObj.getId(), operationsAccumulateParams);
-
         //
         // Build the specification
         //
@@ -447,5 +421,4 @@ public class OperationalPolicyReq {
         }
         return prList.stream().map(stringElem -> PolicyResult.toResult(stringElem)).toArray(PolicyResult[]::new);
     }
-
 }
\ No newline at end of file
@@ -21,7 +21,7 @@
  * ECOMP is a trademark and service mark of AT&T Intellectual Property.
  */
 
-package org.onap.clamp.clds.client;
+package org.onap.clamp.clds.client.req.policy;
 
 import com.att.eelf.configuration.EELFLogger;
 import com.att.eelf.configuration.EELFManager;
@@ -62,22 +62,19 @@ import org.springframework.context.ApplicationContext;
  * Policy utility methods - specifically, send the policy.
  */
 public class PolicyClient {
-    protected static final String     POLICY_PREFIX_BASE         = "Config_";
-    protected static final String     POLICY_PREFIX_BRMS_PARAM   = "Config_BRMS_Param_";
-    protected static final String     POLICY_PREFIX_MICROSERVICE = "Config_MS_";
-
-    protected static final String     LOG_POLICY_PREFIX          = "Response is ";
-
-    protected static final EELFLogger logger                     = EELFManager.getInstance()
+    protected static final String     POLICY_PREFIX_BASE            = "Config_";
+    protected static final String     POLICY_PREFIX_BRMS_PARAM      = "Config_BRMS_Param_";
+    protected static final String     POLICY_PREFIX_MICROSERVICE    = "Config_MS_";
+    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();
-
+    protected static final EELFLogger metricsLogger                 = EELFManager.getInstance().getMetricsLogger();
+    protected static final String     POLICY_MSTYPE_PROPERTY_NAME   = "policy.ms.type";
+    protected static final String     POLICY_ONAPNAME_PROPERTY_NAME = "policy.onap.name";
     @Value("${org.onap.clamp.config.files.cldsPolicyConfig:'classpath:/clds/clds-policy-config.properties'}")
     protected String                  cldsPolicyConfigFile;
-
     @Autowired
     protected ApplicationContext      appContext;
-
     @Autowired
     protected RefProp                 refProp;
 
@@ -95,15 +92,11 @@ public class PolicyClient {
      */
     public String sendBrmsPolicy(Map<AttributeType, Map<String, String>> attributes, ModelProperties prop,
             String policyRequestUuid) {
-
         PolicyParameters policyParameters = new PolicyParameters();
-
         // Set Policy Type(Mandatory)
         policyParameters.setPolicyConfigType(PolicyConfigType.BRMS_PARAM);
-
         // Set Policy Name(Mandatory)
         policyParameters.setPolicyName(prop.getPolicyScopeAndNameWithUniqueId());
-
         // documentation says this is options, but when tested, got the
         // following failure: java.lang.Exception: Policy send failed: PE300 -
         // Data Issue: No policyDescription given.
@@ -113,10 +106,8 @@ public class PolicyClient {
         policyParameters.setRequestID(UUID.fromString(policyRequestUuid));
         String policyNamePrefix = refProp.getStringValue("policy.op.policyNamePrefix");
         String rtnMsg = send(policyParameters, prop, policyNamePrefix);
-
         String policyType = refProp.getStringValue("policy.op.type");
         push(policyType, prop);
-
         return rtnMsg;
     }
 
@@ -132,28 +123,21 @@ public class PolicyClient {
      * @return The response message of policy
      */
     public String sendMicroServiceInJson(String policyJson, ModelProperties prop, String policyRequestUuid) {
-
         PolicyParameters policyParameters = new PolicyParameters();
-
         // Set Policy Type
         policyParameters.setPolicyConfigType(PolicyConfigType.MicroService);
-        policyParameters.setEcompName(refProp.getStringValue("policy.onap.name"));
+        policyParameters.setEcompName(refProp.getStringValue(POLICY_ONAPNAME_PROPERTY_NAME));
         policyParameters.setPolicyName(prop.getCurrentPolicyScopeAndPolicyName());
-
         policyParameters.setConfigBody(policyJson);
         policyParameters.setConfigBodyType(PolicyType.JSON);
-
         policyParameters.setRequestID(UUID.fromString(policyRequestUuid));
         String policyNamePrefix = refProp.getStringValue("policy.ms.policyNamePrefix");
-
         // Adding this line to clear the policy id from policy name while
         // pushing to policy engine
         prop.setPolicyUniqueId("");
-
         String rtnMsg = send(policyParameters, prop, policyNamePrefix);
-        String policyType = refProp.getStringValue("policy.ms.type");
+        String policyType = refProp.getStringValue(POLICY_MSTYPE_PROPERTY_NAME);
         push(policyType, prop);
-
         return rtnMsg;
     }
 
@@ -174,26 +158,20 @@ public class PolicyClient {
     public String sendBasePolicyInOther(String configBody, String configPolicyName, ModelProperties prop,
             String policyRequestUuid) {
         PolicyParameters policyParameters = new PolicyParameters();
-
         // Set Policy Type
         policyParameters.setPolicyConfigType(PolicyConfigType.Base);
-        policyParameters.setEcompName(refProp.getStringValue("policy.onap.name"));
+        policyParameters.setEcompName(refProp.getStringValue(POLICY_ONAPNAME_PROPERTY_NAME));
         policyParameters.setPolicyName(prop.getCurrentPolicyScopeAndPolicyName());
-
         policyParameters.setConfigBody(configBody);
         policyParameters.setConfigBodyType(PolicyType.OTHER);
         policyParameters.setConfigName("HolmesPolicy");
         policyParameters.setPolicyName(configPolicyName);
-
         policyParameters.setRequestID(UUID.fromString(policyRequestUuid));
-
         // Adding this line to clear the policy id from policy name while
         // pushing to policy engine
         prop.setPolicyUniqueId("");
-
         String rtnMsg = send(policyParameters, prop, POLICY_PREFIX_BASE);
         push(PolicyConfigType.Base.toString(), prop);
-
         return rtnMsg;
     }
 
@@ -204,29 +182,23 @@ public class PolicyClient {
      *            The config policy string body
      * @param prop
      *            The ModelProperties
-     * @param policyRequestUuid
-     *            The policy request UUID
      * @return The answer from policy call
      */
-    public String sendMicroServiceInOther(String configBody, ModelProperties prop, String policyRequestUuid) {
-
+    public String sendMicroServiceInOther(String configBody, ModelProperties prop) {
         PolicyParameters policyParameters = new PolicyParameters();
-        // Set Policy Type 
+        // Set Policy Type
         policyParameters.setPolicyConfigType(PolicyConfigType.MicroService);
-        policyParameters.setOnapName("DCAE");
-        policyParameters.setEcompName(refProp.getStringValue("policy.onap.name"));
+        // policyParameters.setOnapName(refProp.getStringValue(POLICY_ONAPNAME_PROPERTY_NAME));
+        policyParameters.setEcompName(refProp.getStringValue(POLICY_ONAPNAME_PROPERTY_NAME));
         policyParameters.setPolicyName(prop.getCurrentPolicyScopeAndPolicyName());
         policyParameters.setConfigBody(configBody);
         String policyNamePrefix = refProp.getStringValue("policy.ms.policyNamePrefix");
-
         // Adding this line to clear the policy id from policy name while
         // pushing to policy engine
         prop.setPolicyUniqueId("");
-
         String rtnMsg = send(policyParameters, prop, policyNamePrefix);
-        String policyType = refProp.getStringValue("policy.ms.type");
+        String policyType = refProp.getStringValue(POLICY_MSTYPE_PROPERTY_NAME);
         push(policyType, prop);
-
         return rtnMsg;
     }
 
@@ -241,10 +213,9 @@ public class PolicyClient {
      */
     protected String send(PolicyParameters policyParameters, ModelProperties prop, String policyNamePrefix) {
         // Verify whether it is triggered by Validation Test button from UI
-        if (prop.isTest()) {
+        if (prop.isTestOnly()) {
             return "send not executed for test action";
         }
-
         // API method to create or update Policy.
         PolicyChangeResponse response = null;
         String responseMessage = "";
@@ -267,9 +238,7 @@ public class PolicyClient {
             throw new PolicyClientException("Exception while communicating with Policy", e);
         }
         logger.info(LOG_POLICY_PREFIX + responseMessage);
-
         LoggingUtils.setTimeContext(startTime, new Date());
-
         if (response.getResponseCode() == 200) {
             logger.info("Policy send successful");
             metricsLogger.info("Policy send success");
@@ -278,7 +247,6 @@ public class PolicyClient {
             metricsLogger.info("Policy send failure");
             throw new BadRequestException("Policy send failed: " + responseMessage);
         }
-
         return responseMessage;
     }
 
@@ -293,12 +261,10 @@ public class PolicyClient {
      */
     protected String push(String policyType, ModelProperties prop) {
         // Verify whether it is triggered by Validation Test button from UI
-        if (prop.isTest()) {
+        if (prop.isTestOnly()) {
             return "push not executed for test action";
         }
-
         PushPolicyParameters pushPolicyParameters = new PushPolicyParameters();
-
         // Parameter arguments
         if (prop.getPolicyUniqueId() != null && !prop.getPolicyUniqueId().isEmpty()) {
             pushPolicyParameters.setPolicyName(prop.getPolicyScopeAndNameWithUniqueId());
@@ -306,31 +272,29 @@ public class PolicyClient {
             pushPolicyParameters.setPolicyName(prop.getCurrentPolicyScopeAndPolicyName());
         }
         logger.info("Policy Name in Push policy method - " + pushPolicyParameters.getPolicyName());
-
         pushPolicyParameters.setPolicyType(policyType);
         pushPolicyParameters.setPdpGroup(refProp.getStringValue("policy.pdp.group"));
         pushPolicyParameters.setRequestID(null);
-
         // API method to create or update Policy.
-        PolicyChangeResponse response = null;
+        PolicyChangeResponse response;
         String responseMessage = "";
         try {
             logger.info("Attempting to push policy...");
             response = getPolicyEngine().pushPolicy(pushPolicyParameters);
-            responseMessage = response.getResponseMessage();
+            if (response != null) {
+                responseMessage = response.getResponseMessage();
+            }
         } catch (Exception e) {
             logger.error("Exception occurred during policy communication", e);
             throw new PolicyClientException("Exception while communicating with Policy", e);
         }
         logger.info(LOG_POLICY_PREFIX + responseMessage);
-
         if (response != null && (response.getResponseCode() == 200 || response.getResponseCode() == 204)) {
             logger.info("Policy push successful");
         } else {
             logger.warn("Policy push failed: " + responseMessage);
             throw new BadRequestException("Policy push failed: " + responseMessage);
         }
-
         return responseMessage;
     }
 
@@ -347,17 +311,14 @@ public class PolicyClient {
      *             In case of issues with policy engine
      */
     protected List<Integer> getVersions(String policyNamePrefix, ModelProperties prop) throws PolicyConfigException {
-
         ArrayList<Integer> versions = new ArrayList<>();
         ConfigRequestParameters configRequestParameters = new ConfigRequestParameters();
         String policyName = "";
-
         if (prop.getPolicyUniqueId() != null && !prop.getPolicyUniqueId().isEmpty()) {
             policyName = prop.getCurrentPolicyScopeAndFullPolicyName(policyNamePrefix) + "_" + prop.getPolicyUniqueId();
         } else {
             policyName = prop.getCurrentPolicyScopeAndFullPolicyName(policyNamePrefix);
         }
-
         logger.info("policyName=" + policyName);
         configRequestParameters.setPolicyName(policyName);
         try {
@@ -373,7 +334,6 @@ public class PolicyClient {
             logger.warn("warning: policy not found...policy name - " + policyName, e.getMessage());
         }
         return versions;
-
     }
 
     /**
@@ -401,7 +361,7 @@ public class PolicyClient {
      * @return The response message from Policy
      */
     public String deleteMicrosService(ModelProperties prop) {
-        String policyType = refProp.getStringValue("policy.ms.type");
+        String policyType = refProp.getStringValue(POLICY_MSTYPE_PROPERTY_NAME);
         return deletePolicy(prop, policyType);
     }
 
@@ -438,7 +398,6 @@ public class PolicyClient {
      */
     protected String deletePolicy(ModelProperties prop, String policyType) {
         DeletePolicyParameters deletePolicyParameters = new DeletePolicyParameters();
-
         if (prop.getPolicyUniqueId() != null && !prop.getPolicyUniqueId().isEmpty()) {
             deletePolicyParameters.setPolicyName(prop.getPolicyScopeAndNameWithUniqueId());
         } else {
@@ -451,14 +410,11 @@ public class PolicyClient {
         deletePolicyParameters.setPolicyType(policyType);
         // send delete request
         StringBuilder responseMessage = new StringBuilder(sendDeletePolicy(deletePolicyParameters, prop));
-
         logger.info("Deleting policy from PAP...");
         deletePolicyParameters.setPolicyComponent("PAP");
         deletePolicyParameters.setDeleteCondition(DeletePolicyCondition.ALL);
-
         // send delete request
         responseMessage.append(sendDeletePolicy(deletePolicyParameters, prop));
-
         return responseMessage.toString();
     }
 
@@ -473,10 +429,9 @@ public class PolicyClient {
      */
     protected String sendDeletePolicy(DeletePolicyParameters deletePolicyParameters, ModelProperties prop) {
         // Verify whether it is triggered by Validation Test button from UI
-        if (prop.isTest()) {
+        if (prop.isTestOnly()) {
             return "delete not executed for test action";
         }
-
         // API method to create or update Policy.
         PolicyChangeResponse response = null;
         String responseMessage = "";
@@ -488,14 +443,12 @@ public class PolicyClient {
             logger.error("Exception occurred during policy communnication", e);
         }
         logger.info(LOG_POLICY_PREFIX + responseMessage);
-
         if (response != null && response.getResponseCode() == 200) {
             logger.info("Policy delete successful");
         } else {
             logger.warn("Policy delete failed: " + responseMessage);
             throw new BadRequestException("Policy delete failed: " + responseMessage);
         }
-
         return responseMessage;
     }
 }
\ No newline at end of file
@@ -21,7 +21,7 @@
  * ECOMP is a trademark and service mark of AT&T Intellectual Property.\r
  */\r
 \r
-package org.onap.clamp.clds.client;\r
+package org.onap.clamp.clds.client.req.sdc;\r
 \r
 import com.att.eelf.configuration.EELFLogger;\r
 import com.att.eelf.configuration.EELFManager;\r
@@ -40,8 +40,10 @@ import java.io.Reader;
 import java.io.StringReader;\r
 import java.net.HttpURLConnection;\r
 import java.net.URL;\r
+import java.nio.charset.StandardCharsets;\r
 import java.security.GeneralSecurityException;\r
 import java.util.ArrayList;\r
+import java.util.Base64;\r
 import java.util.Collections;\r
 import java.util.Date;\r
 import java.util.Iterator;\r
@@ -49,10 +51,13 @@ import java.util.List;
 \r
 import javax.ws.rs.BadRequestException;\r
 \r
+import org.apache.commons.codec.DecoderException;\r
+import org.apache.commons.codec.digest.DigestUtils;\r
 import org.apache.commons.csv.CSVFormat;\r
 import org.apache.commons.csv.CSVRecord;\r
+import org.apache.commons.io.IOUtils;\r
 import org.apache.commons.lang3.StringUtils;\r
-import org.onap.clamp.clds.client.req.SdcReq;\r
+import org.apache.http.HttpHeaders;\r
 import org.onap.clamp.clds.exception.SdcCommunicationException;\r
 import org.onap.clamp.clds.model.CldsAlarmCondition;\r
 import org.onap.clamp.clds.model.CldsDBServiceCache;\r
@@ -68,20 +73,45 @@ import org.onap.clamp.clds.model.CldsVfcData;
 import org.onap.clamp.clds.model.prop.Global;\r
 import org.onap.clamp.clds.model.prop.ModelProperties;\r
 import org.onap.clamp.clds.model.refprop.RefProp;\r
+import org.onap.clamp.clds.util.CryptoUtils;\r
 import org.onap.clamp.clds.util.LoggingUtils;\r
 import org.springframework.beans.factory.annotation.Autowired;\r
 \r
 public class SdcCatalogServices {\r
-    protected static final EELFLogger logger             = EELFManager.getInstance()\r
+    protected static final EELFLogger logger                        = EELFManager.getInstance()\r
             .getLogger(SdcCatalogServices.class);\r
-    protected static final EELFLogger metricsLogger      = EELFManager.getInstance().getMetricsLogger();\r
-    private static final String       RESOURCE_VF_TYPE   = "VF";\r
-    private static final String       RESOURCE_VFC_TYPE  = "VFC";\r
-    private static final String       RESOURCE_CVFC_TYPE = "CVFC";\r
+    protected static final EELFLogger metricsLogger                 = EELFManager.getInstance().getMetricsLogger();\r
+    private static final String       RESOURCE_VF_TYPE              = "VF";\r
+    private static final String       RESOURCE_VFC_TYPE             = "VFC";\r
+    private static final String       RESOURCE_CVFC_TYPE            = "CVFC";\r
+    public static final String        SDC_REQUESTID_PROPERTY_NAME   = "sdc.header.requestId";\r
+    private static final String       SDC_METADATA_URL_PREFIX       = "/metadata";\r
+    private static final String       SDC_INSTANCE_ID_PROPERTY_NAME = "sdc.InstanceID";\r
+    private static final String       SDC_CATALOG_URL_PROPERTY_NAME = "sdc.catalog.url";\r
+    private static final String       SDC_SERVICE_URL_PROPERTY_NAME = "sdc.serviceUrl";\r
+    private static final String       SDC_INSTANCE_ID_CLAMP         = "CLAMP-Tool";\r
+    private static final String       RESOURCE_URL_PREFIX           = "resources";\r
     @Autowired\r
     private RefProp                   refProp;\r
-    @Autowired\r
-    private SdcReq                    sdcReq;\r
+    protected CryptoUtils             cryptoUtils                   = new CryptoUtils();\r
+\r
+    /**\r
+     * Return SDC id and pw as a HTTP Basic Auth string (for example: Basic\r
+     * dGVzdDoxMjM0NTY=).\r
+     *\r
+     * @return The String with Basic Auth and password\r
+     * @throws GeneralSecurityException\r
+     *             In case of issue when decryting the SDC password\r
+     * @throws DecoderException\r
+     *             In case of issues with the decoding of the HexString message\r
+     */\r
+    private String getSdcBasicAuth() throws GeneralSecurityException, DecoderException {\r
+        String sdcId = refProp.getStringValue("sdc.serviceUsername");\r
+        String sdcPw = refProp.getStringValue("sdc.servicePassword");\r
+        String password = cryptoUtils.decrypt(sdcPw);\r
+        String idPw = Base64.getEncoder().encodeToString((sdcId + ":" + password).getBytes(StandardCharsets.UTF_8));\r
+        return "Basic " + idPw;\r
+    }\r
 \r
     /**\r
      * This method get the SDC services Information with the corresponding\r
@@ -92,31 +122,31 @@ public class SdcCatalogServices {
      * @return A Json String with all the service list\r
      * @throws GeneralSecurityException\r
      *             In case of issue when decryting the SDC password\r
+     * @throws DecoderException\r
+     *             In case of issues with the decoding of the Hex String\r
      */\r
-    public String getSdcServicesInformation(String uuid) throws GeneralSecurityException {\r
+    public String getSdcServicesInformation(String uuid) throws GeneralSecurityException, DecoderException {\r
         Date startTime = new Date();\r
-        String baseUrl = refProp.getStringValue("sdc.serviceUrl");\r
-        String basicAuth = sdcReq.getSdcBasicAuth();\r
+        String baseUrl = refProp.getStringValue(SDC_SERVICE_URL_PROPERTY_NAME);\r
+        String basicAuth = getSdcBasicAuth();\r
         LoggingUtils.setTargetContext("SDC", "getSdcServicesInformation");\r
         try {\r
             String url = baseUrl;\r
             if (uuid != null) {\r
-                url = baseUrl + "/" + uuid + "/metadata";\r
+                url = baseUrl + "/" + uuid + SDC_METADATA_URL_PREFIX;\r
             }\r
             URL urlObj = new URL(url);\r
             HttpURLConnection conn = (HttpURLConnection) urlObj.openConnection();\r
-            conn.setRequestProperty(refProp.getStringValue("sdc.InstanceID"), "CLAMP-Tool");\r
-            conn.setRequestProperty("Authorization", basicAuth);\r
-            conn.setRequestProperty("Content-Type", "application/json;charset=UTF-8");\r
-            conn.setRequestProperty("X-ECOMP-RequestID", LoggingUtils.getRequestId());\r
+            conn.setRequestProperty(refProp.getStringValue(SDC_INSTANCE_ID_PROPERTY_NAME), SDC_INSTANCE_ID_CLAMP);\r
+            conn.setRequestProperty(HttpHeaders.AUTHORIZATION, basicAuth);\r
+            conn.setRequestProperty(HttpHeaders.CONTENT_TYPE, "application/json;charset=UTF-8");\r
+            conn.setRequestProperty(refProp.getStringValue(SDC_REQUESTID_PROPERTY_NAME), LoggingUtils.getRequestId());\r
             conn.setRequestMethod("GET");\r
             String resp = getResponse(conn);\r
-            if (resp != null) {\r
-                logger.info(resp);\r
-                // metrics log\r
-                LoggingUtils.setResponseContext("0", "Get sdc services success", this.getClass().getName());\r
-                return resp;\r
-            }\r
+            logger.info(resp);\r
+            // metrics log\r
+            LoggingUtils.setResponseContext("0", "Get sdc services success", this.getClass().getName());\r
+            return resp;\r
         } catch (IOException e) {\r
             LoggingUtils.setResponseContext("900", "Get sdc services failed", this.getClass().getName());\r
             LoggingUtils.setErrorContext("900", "Get sdc services error");\r
@@ -223,8 +253,11 @@ public class SdcCatalogServices {
      * @return The service UUID\r
      * @throws GeneralSecurityException\r
      *             In case of issue when decryting the SDC password\r
+     * @throws DecoderException\r
+     *             In case of issues with the decoding of the Hex String\r
      */\r
-    public String getServiceUuidFromServiceInvariantId(String invariantId) throws GeneralSecurityException {\r
+    public String getServiceUuidFromServiceInvariantId(String invariantId)\r
+            throws GeneralSecurityException, DecoderException {\r
         String serviceUuid = "";\r
         String responseStr = getSdcServicesInformation(null);\r
         List<CldsSdcServiceInfo> rawCldsSdcServicesList = getCldsSdcServicesListFromJson(responseStr);\r
@@ -326,15 +359,14 @@ public class SdcCatalogServices {
     public String uploadArtifactToSdc(ModelProperties prop, String userid, String url, String formattedSdcReq)\r
             throws GeneralSecurityException {\r
         // Verify whether it is triggered by Validation Test button from UI\r
-        if (prop.isTest()) {\r
+        if (prop.isTestOnly()) {\r
             return "sdc artifact upload not executed for test action";\r
         }\r
         try {\r
             logger.info("userid=" + userid);\r
-            String md5Text = sdcReq.calculateMD5ByString(formattedSdcReq);\r
-            byte[] postData = sdcReq.stringToByteArray(formattedSdcReq);\r
+            byte[] postData = formattedSdcReq.getBytes(StandardCharsets.UTF_8);\r
             int postDataLength = postData.length;\r
-            HttpURLConnection conn = getSdcHttpUrlConnection(userid, postDataLength, url, md5Text);\r
+            HttpURLConnection conn = getSdcHttpUrlConnection(userid, postDataLength, url, formattedSdcReq);\r
             try (DataOutputStream wr = new DataOutputStream(conn.getOutputStream())) {\r
                 wr.write(postData);\r
             }\r
@@ -356,45 +388,43 @@ public class SdcCatalogServices {
         }\r
     }\r
 \r
-    private HttpURLConnection getSdcHttpUrlConnection(String userid, int postDataLength, String url, String md5Text)\r
+    private HttpURLConnection getSdcHttpUrlConnection(String userid, int postDataLength, String url, String content)\r
             throws GeneralSecurityException {\r
         try {\r
             logger.info("userid=" + userid);\r
-            String basicAuth = sdcReq.getSdcBasicAuth();\r
+            String basicAuth = getSdcBasicAuth();\r
             String sdcXonapInstanceId = refProp.getStringValue("sdc.sdcX-InstanceID");\r
             URL urlObj = new URL(url);\r
             HttpURLConnection conn = (HttpURLConnection) urlObj.openConnection();\r
             conn.setDoOutput(true);\r
-            conn.setRequestProperty(refProp.getStringValue("sdc.InstanceID"), sdcXonapInstanceId);\r
-            conn.setRequestProperty("Authorization", basicAuth);\r
-            conn.setRequestProperty("Content-Type", "application/json");\r
-            conn.setRequestProperty("Content-MD5", md5Text);\r
+            conn.setRequestProperty(refProp.getStringValue(SDC_INSTANCE_ID_PROPERTY_NAME), sdcXonapInstanceId);\r
+            conn.setRequestProperty(HttpHeaders.AUTHORIZATION, basicAuth);\r
+            conn.setRequestProperty(HttpHeaders.CONTENT_TYPE, "application/json");\r
+            conn.setRequestProperty(HttpHeaders.CONTENT_MD5,\r
+                    Base64.getEncoder().encodeToString(DigestUtils.md5Hex(content).getBytes("UTF-8")));\r
             conn.setRequestProperty("USER_ID", userid);\r
             conn.setRequestMethod("POST");\r
             conn.setRequestProperty("charset", "utf-8");\r
-            conn.setRequestProperty("Content-Length", Integer.toString(postDataLength));\r
+            conn.setRequestProperty(HttpHeaders.CONTENT_LENGTH, Integer.toString(postDataLength));\r
             conn.setUseCaches(false);\r
-            conn.setRequestProperty("X-ECOMP-RequestID", LoggingUtils.getRequestId());\r
+            conn.setRequestProperty(refProp.getStringValue(SDC_REQUESTID_PROPERTY_NAME), LoggingUtils.getRequestId());\r
             return conn;\r
         } catch (IOException e) {\r
             logger.error("Exception when attempting to open connection with SDC", e);\r
             throw new SdcCommunicationException("Exception when attempting to open connection with SDC", e);\r
+        } catch (DecoderException e) {\r
+            logger.error("Exception when attempting to decode the Hex string", e);\r
+            throw new SdcCommunicationException("Exception when attempting to decode the Hex string", e);\r
+        } catch (GeneralSecurityException e) {\r
+            logger.error("Exception when attempting to decrypt the encrypted password", e);\r
+            throw new SdcCommunicationException("Exception when attempting to decrypt the encrypted password", e);\r
         }\r
     }\r
 \r
     private String getResponse(HttpURLConnection conn) {\r
         try (InputStream is = getInputStream(conn)) {\r
-            if (is != null) {\r
-                try (BufferedReader in = new BufferedReader(new InputStreamReader(is))) {\r
-                    StringBuilder response = new StringBuilder();\r
-                    String inputLine;\r
-                    while ((inputLine = in.readLine()) != null) {\r
-                        response.append(inputLine);\r
-                    }\r
-                    return response.toString();\r
-                }\r
-            } else {\r
-                return null;\r
+            try (BufferedReader in = new BufferedReader(new InputStreamReader(is))) {\r
+                return IOUtils.toString(in);\r
             }\r
         } catch (IOException e) {\r
             logger.error("Exception when attempting to open SDC response", e);\r
@@ -434,8 +464,12 @@ public class SdcCatalogServices {
      * @param cldsServiceData\r
      * @return\r
      * @throws GeneralSecurityException\r
+     *             In case of issues with the decryting the encrypted password\r
+     * @throws DecoderException\r
+     *             In case of issues with the decoding of the Hex String\r
      */\r
-    public boolean isCldsSdcCacheDataExpired(CldsServiceData cldsServiceData) throws GeneralSecurityException {\r
+    public boolean isCldsSdcCacheDataExpired(CldsServiceData cldsServiceData)\r
+            throws GeneralSecurityException, DecoderException {\r
         boolean expired = false;\r
         if (cldsServiceData != null && cldsServiceData.getServiceUUID() != null) {\r
             String cachedServiceUuid = cldsServiceData.getServiceUUID();\r
@@ -458,13 +492,16 @@ public class SdcCatalogServices {
      * @param invariantServiceUuid\r
      * @return\r
      * @throws GeneralSecurityException\r
+     *             In case of issues with the decryting the encrypted password\r
+     * @throws DecoderException\r
+     *             In case of issues with the decoding of the Hex String\r
      */\r
     public CldsServiceData getCldsServiceDataWithAlarmConditions(String invariantServiceUuid)\r
-            throws GeneralSecurityException {\r
-        String url = refProp.getStringValue("sdc.serviceUrl");\r
-        String catalogUrl = refProp.getStringValue("sdc.catalog.url");\r
+            throws GeneralSecurityException, DecoderException {\r
+        String url = refProp.getStringValue(SDC_SERVICE_URL_PROPERTY_NAME);\r
+        String catalogUrl = refProp.getStringValue(SDC_CATALOG_URL_PROPERTY_NAME);\r
         String serviceUuid = getServiceUuidFromServiceInvariantId(invariantServiceUuid);\r
-        String serviceDetailUrl = url + "/" + serviceUuid + "/metadata";\r
+        String serviceDetailUrl = url + "/" + serviceUuid + SDC_METADATA_URL_PREFIX;\r
         String responseStr = getCldsServicesOrResourcesBasedOnURL(serviceDetailUrl, false);\r
         ObjectMapper objectMapper = new ObjectMapper();\r
         CldsServiceData cldsServiceData = new CldsServiceData();\r
@@ -476,11 +513,11 @@ public class SdcCatalogServices {
                 logger.error("Exception when decoding the CldsServiceData JSON from SDC", e);\r
                 throw new SdcCommunicationException("Exception when decoding the CldsServiceData JSON from SDC", e);\r
             }\r
-            cldsServiceData.setServiceUUID(cldsSdcServiceDetail.getUuid());\r
-            cldsServiceData.setServiceInvariantUUID(cldsSdcServiceDetail.getInvariantUUID());\r
             // To remove duplicate resources from serviceDetail and add valid\r
             // vfs to service\r
             if (cldsSdcServiceDetail != null && cldsSdcServiceDetail.getResources() != null) {\r
+                cldsServiceData.setServiceUUID(cldsSdcServiceDetail.getUuid());\r
+                cldsServiceData.setServiceInvariantUUID(cldsSdcServiceDetail.getInvariantUUID());\r
                 List<CldsSdcResource> cldsSdcResourceList = removeDuplicateSdcResourceInstances(\r
                         cldsSdcServiceDetail.getResources());\r
                 if (cldsSdcResourceList != null && !cldsSdcResourceList.isEmpty()) {\r
@@ -519,7 +556,8 @@ public class SdcCatalogServices {
                     String resourceUuid = getResourceUuidFromResourceInvariantUuid(\r
                             currCldsVfData.getVfInvariantResourceUUID(), allVfResources);\r
                     if (resourceUuid != null) {\r
-                        String vfResourceUuidUrl = catalogUrl + "resources" + "/" + resourceUuid + "/metadata";\r
+                        String vfResourceUuidUrl = catalogUrl + RESOURCE_URL_PREFIX + "/" + resourceUuid\r
+                                + SDC_METADATA_URL_PREFIX;\r
                         String vfResponse = getCldsServicesOrResourcesBasedOnURL(vfResourceUuidUrl, false);\r
                         if (vfResponse != null) {\r
                             // Below 2 line are to get the KPI(field path) data\r
@@ -538,8 +576,8 @@ public class SdcCatalogServices {
                                             String resourceVfcUuid = getResourceUuidFromResourceInvariantUuid(\r
                                                     currCldsVfcData.getVfcInvariantResourceUUID(), allVfcResources);\r
                                             if (resourceVfcUuid != null) {\r
-                                                String vfcResourceUuidUrl = catalogUrl + "resources" + "/"\r
-                                                        + resourceVfcUuid + "/metadata";\r
+                                                String vfcResourceUuidUrl = catalogUrl + RESOURCE_URL_PREFIX + "/"\r
+                                                        + resourceVfcUuid + SDC_METADATA_URL_PREFIX;\r
                                                 String vfcResponse = getCldsServicesOrResourcesBasedOnURL(\r
                                                         vfcResourceUuidUrl, false);\r
                                                 if (vfcResponse != null) {\r
@@ -601,10 +639,10 @@ public class SdcCatalogServices {
     }\r
 \r
     private List<CldsVfcData> getVFCfromCVFC(String resourceUUID) throws GeneralSecurityException {\r
-        String catalogUrl = refProp.getStringValue("sdc.catalog.url");\r
+        String catalogUrl = refProp.getStringValue(SDC_CATALOG_URL_PROPERTY_NAME);\r
         List<CldsVfcData> cldsVfcDataList = new ArrayList<>();\r
         if (resourceUUID != null) {\r
-            String vfcResourceUUIDUrl = catalogUrl + "resources" + "/" + resourceUUID + "/metadata";\r
+            String vfcResourceUUIDUrl = catalogUrl + RESOURCE_URL_PREFIX + "/" + resourceUUID + SDC_METADATA_URL_PREFIX;\r
             try {\r
                 String vfcResponse = getCldsServicesOrResourcesBasedOnURL(vfcResourceUUIDUrl, false);\r
                 ObjectMapper mapper = new ObjectMapper();\r
@@ -809,34 +847,30 @@ public class SdcCatalogServices {
             String urlReworked = removeUnwantedBracesFromString(url);\r
             URL urlObj = new URL(urlReworked);\r
             HttpURLConnection conn = (HttpURLConnection) urlObj.openConnection();\r
-            String basicAuth = sdcReq.getSdcBasicAuth();\r
-            conn.setRequestProperty(refProp.getStringValue("sdc.InstanceID"), "CLAMP-Tool");\r
-            conn.setRequestProperty("Authorization", basicAuth);\r
-            conn.setRequestProperty("Content-Type", "application/json;charset=UTF-8");\r
-            conn.setRequestProperty("X-ECOMP-RequestID", LoggingUtils.getRequestId());\r
+            String basicAuth = getSdcBasicAuth();\r
+            conn.setRequestProperty(refProp.getStringValue(SDC_INSTANCE_ID_PROPERTY_NAME), SDC_INSTANCE_ID_CLAMP);\r
+            conn.setRequestProperty(HttpHeaders.AUTHORIZATION, basicAuth);\r
+            conn.setRequestProperty(HttpHeaders.CONTENT_TYPE, "application/json;charset=UTF-8");\r
+            conn.setRequestProperty(refProp.getStringValue(SDC_REQUESTID_PROPERTY_NAME), LoggingUtils.getRequestId());\r
             conn.setRequestMethod("GET");\r
             int responseCode = conn.getResponseCode();\r
             logger.info("Sdc resource url - " + urlReworked + " , responseCode=" + responseCode);\r
-            StringBuilder response;\r
             try (BufferedReader in = new BufferedReader(new InputStreamReader(conn.getInputStream()))) {\r
-                response = new StringBuilder();\r
-                String inputLine;\r
-                while ((inputLine = in.readLine()) != null) {\r
-                    if (!inputLine.isEmpty()) {\r
-                        response.append(inputLine);\r
-                    }\r
-                    if (alarmConditions) {\r
-                        response.append("\n");\r
-                    }\r
-                }\r
+                String response = IOUtils.toString(in);\r
+                LoggingUtils.setResponseContext("0", "Get sdc resources success", this.getClass().getName());\r
+                return response;\r
             }\r
-            LoggingUtils.setResponseContext("0", "Get sdc resources success", this.getClass().getName());\r
-            return response.toString();\r
         } catch (IOException e) {\r
             LoggingUtils.setResponseContext("900", "Get sdc resources failed", this.getClass().getName());\r
             LoggingUtils.setErrorContext("900", "Get sdc resources error");\r
             logger.error("Exception occurred during query to SDC", e);\r
             return "";\r
+        } catch (DecoderException e) {\r
+            logger.error("Exception when attempting to decode the Hex string", e);\r
+            throw new SdcCommunicationException("Exception when attempting to decode the Hex string", e);\r
+        } catch (GeneralSecurityException e) {\r
+            logger.error("Exception when attempting to decrypt the encrypted password", e);\r
+            throw new SdcCommunicationException("Exception when attempting to decrypt the encrypted password", e);\r
         } finally {\r
             LoggingUtils.setTimeContext(startTime, new Date());\r
             metricsLogger.info("getCldsServicesOrResourcesBasedOnURL completed");\r
@@ -1161,41 +1195,6 @@ public class SdcCatalogServices {
         return artifactUuid;\r
     }\r
 \r
-    public String updateControlLoopStatusToDcae(String dcaeUrl, String invariantResourceUuid,\r
-            String invariantServiceUuid, String artifactName) throws GeneralSecurityException {\r
-        String baseUrl = refProp.getStringValue("sdc.serviceUrl");\r
-        String basicAuth = sdcReq.getSdcBasicAuth();\r
-        String postStatusData = "{ \n" + "\"event\" : \"" + "Created" + "\",\n" + "\"serviceUUID\" : \""\r
-                + invariantServiceUuid + "\",\n" + "\"resourceUUID\" :\"" + invariantResourceUuid + "\",\n"\r
-                + "\"artifactName\" : \"" + artifactName + "\",\n" + "} \n";\r
-        try {\r
-            String url = baseUrl;\r
-            if (invariantServiceUuid != null) {\r
-                url = dcaeUrl + "/closed-loops";\r
-            }\r
-            URL urlObj = new URL(url);\r
-            HttpURLConnection conn = (HttpURLConnection) urlObj.openConnection();\r
-            conn.setRequestProperty(refProp.getStringValue("sdc.InstanceID"), "CLAMP-Tool");\r
-            conn.setRequestProperty("Authorization", basicAuth);\r
-            conn.setRequestProperty("Content-Type", "application/json;charset=UTF-8");\r
-            conn.setRequestProperty("X-ECOMP-RequestID", LoggingUtils.getRequestId());\r
-            conn.setRequestMethod("POST");\r
-            byte[] postData = sdcReq.stringToByteArray(postStatusData);\r
-            try (DataOutputStream wr = new DataOutputStream(conn.getOutputStream())) {\r
-                wr.write(postData);\r
-            }\r
-            int responseCode = conn.getResponseCode();\r
-            logger.info("responseCode=" + responseCode);\r
-            String resp = getResponse(conn);\r
-            if (resp != null) {\r
-                return resp;\r
-            }\r
-        } catch (IOException e) {\r
-            logger.error("Not able to get any service information from sdc for uuid:" + invariantServiceUuid, e);\r
-        }\r
-        return "";\r
-    }\r
-\r
     /**\r
      * To get all sdc VF/VFC Resources basic info.\r
      * \r
@@ -1208,7 +1207,7 @@ public class SdcCatalogServices {
      */\r
     private List<CldsSdcResourceBasicInfo> getAllSdcVForVfcResourcesBasedOnResourceType(String resourceType)\r
             throws GeneralSecurityException {\r
-        String catalogUrl = refProp.getStringValue("sdc.catalog.url");\r
+        String catalogUrl = refProp.getStringValue(SDC_CATALOG_URL_PROPERTY_NAME);\r
         String resourceUrl = catalogUrl + "resources?resourceType=" + resourceType;\r
         String allSdcVfcResources = getCldsServicesOrResourcesBasedOnURL(resourceUrl, false);\r
         return removeDuplicateSdcResourceBasicInfo(getAllSdcResourcesListFromJson(allSdcVfcResources));\r
@@ -1264,11 +1263,13 @@ public class SdcCatalogServices {
      *            The location artifact name from where we can get the Artifact\r
      *            UUID\r
      * @throws GeneralSecurityException\r
-     *             In case of issues to decrypt the SDC password\r
+     *             In case of issues with the decryting the encrypted password\r
+     * @throws DecoderException\r
+     *             In case of issues with the decoding of the Hex String\r
      */\r
     public void uploadToSdc(ModelProperties prop, String userid, List<String> sdcReqUrlsList, String formattedSdcReq,\r
             String formattedSdcLocationReq, String artifactName, String locationArtifactName)\r
-            throws GeneralSecurityException {\r
+            throws GeneralSecurityException, DecoderException {\r
         logger.info("userid=" + userid);\r
         String serviceInvariantUuid = getServiceInvariantUuidFromProps(prop);\r
         if (sdcReqUrlsList != null && !sdcReqUrlsList.isEmpty()) {\r
@@ -21,7 +21,7 @@
  * ECOMP is a trademark and service mark of AT&T Intellectual Property.
  */
 
-package org.onap.clamp.clds.client.req;
+package org.onap.clamp.clds.client.req.sdc;
 
 import com.att.eelf.configuration.EELFLogger;
 import com.att.eelf.configuration.EELFManager;
@@ -41,24 +41,21 @@ import java.util.Iterator;
 import java.util.List;
 import java.util.Map.Entry;
 
-import org.apache.commons.codec.digest.DigestUtils;
+import org.apache.commons.codec.DecoderException;
 import org.camunda.bpm.engine.delegate.DelegateExecution;
-import org.onap.clamp.clds.client.SdcCatalogServices;
+import org.onap.clamp.clds.client.req.tca.TcaRequestFormatter;
 import org.onap.clamp.clds.model.CldsSdcResource;
 import org.onap.clamp.clds.model.CldsSdcServiceDetail;
 import org.onap.clamp.clds.model.prop.Global;
 import org.onap.clamp.clds.model.prop.ModelProperties;
 import org.onap.clamp.clds.model.prop.Tca;
 import org.onap.clamp.clds.model.refprop.RefProp;
-import org.onap.clamp.clds.util.CryptoUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 
 /**
  * Construct a Sdc request given CLDS objects.
  */
 public class SdcReq {
-    @Autowired
-    protected CryptoUtils             cryptoUtils;
     protected static final EELFLogger logger        = EELFManager.getInstance().getLogger(SdcReq.class);
     protected static final EELFLogger metricsLogger = EELFManager.getInstance().getMetricsLogger();
     @Autowired
@@ -136,39 +133,13 @@ public class SdcReq {
     public String formatSdcReq(String payloadData, String artifactName, String artifactLabel, String artifactType)
             throws IOException {
         logger.info("artifact=" + payloadData);
-        String base64Artifact = base64Encode(payloadData);
+        String base64Artifact = Base64.getEncoder().encodeToString(payloadData.getBytes(StandardCharsets.UTF_8));
         return "{ \n" + "\"payloadData\" : \"" + base64Artifact + "\",\n" + "\"artifactLabel\" : \"" + artifactLabel
                 + "\",\n" + "\"artifactName\" :\"" + artifactName + "\",\n" + "\"artifactType\" : \"" + artifactType
                 + "\",\n" + "\"artifactGroupType\" : \"DEPLOYMENT\",\n" + "\"description\" : \"from CLAMP Cockpit\"\n"
                 + "} \n";
     }
 
-    /**
-     * Get the SDC Request URL
-     *
-     * @param prop
-     *            The ModelProperties describing the clds model
-     * @param url
-     *            url
-     * @return SDC Request URL
-     */
-    public String getSdcReqUrl(ModelProperties prop, String url) {
-        Global globalProps = prop.getGlobal();
-        String serviceUUID = "";
-        String resourceInstanceName = "";
-        if (globalProps != null) {
-            List<String> resourceVf = globalProps.getResourceVf();
-            if (resourceVf != null && !resourceVf.isEmpty()) {
-                resourceInstanceName = resourceVf.get(0);
-            }
-            if (globalProps.getService() != null) {
-                serviceUUID = globalProps.getService();
-            }
-        }
-        String normalizedResourceInstanceName = normalizeResourceInstanceName(resourceInstanceName);
-        return url + "/" + serviceUUID + "/resourceInstances/" + normalizedResourceInstanceName + "/artifacts";
-    }
-
     /**
      * To get List of urls for all vfresources
      *
@@ -178,9 +149,12 @@ public class SdcReq {
      * @param execution
      * @return
      * @throws GeneralSecurityException
+     *             In case of issues when decrypting the password
+     * @throws DecoderException
+     *             In case of issues when decoding the Hex String
      */
     public List<String> getSdcReqUrlsList(ModelProperties prop, String baseUrl, SdcCatalogServices sdcCatalogServices,
-            DelegateExecution execution) throws GeneralSecurityException {
+            DelegateExecution execution) throws GeneralSecurityException, DecoderException {
         // TODO : refact and regroup with very similar code
         List<String> urlList = new ArrayList<>();
         Global globalProps = prop.getGlobal();
@@ -226,65 +200,6 @@ public class SdcReq {
         return inText.replace(" ", "").replace("-", "").replace(".", "").toLowerCase();
     }
 
-    /**
-     * from michael
-     *
-     * @param data
-     * @return
-     */
-    public String calculateMD5ByString(String data) {
-        String calculatedMd5 = DigestUtils.md5Hex(data);
-        // encode base-64 result
-        return base64Encode(calculatedMd5.getBytes());
-    }
-
-    /**
-     * Base 64 encode a String.
-     *
-     * @param inText
-     * @return
-     */
-    public String base64Encode(String inText) {
-        return base64Encode(stringToByteArray(inText));
-    }
-
-    /**
-     * Convert String to byte array.
-     *
-     * @param inText
-     * @return
-     */
-    public byte[] stringToByteArray(String inText) {
-        return inText.getBytes(StandardCharsets.UTF_8);
-    }
-
-    /**
-     * Base 64 encode a byte array.
-     *
-     * @param bytes
-     * @return
-     */
-    public String base64Encode(byte[] bytes) {
-        Base64.Encoder encoder = Base64.getEncoder();
-        return encoder.encodeToString(bytes);
-    }
-
-    /**
-     * Return SDC id and pw as a HTTP Basic Auth string (for example: Basic
-     * dGVzdDoxMjM0NTY=).
-     *
-     * @return The String with Basic Auth and password
-     * @throws GeneralSecurityException
-     *             In case of issue when decryting the SDC password
-     */
-    public String getSdcBasicAuth() throws GeneralSecurityException {
-        String sdcId = refProp.getStringValue("sdc.serviceUsername");
-        String sdcPw = refProp.getStringValue("sdc.servicePassword");
-        String password = cryptoUtils.decrypt(sdcPw);
-        String idPw = base64Encode(sdcId + ":" + password);
-        return "Basic " + idPw;
-    }
-
     /**
      * Method to get yaml/template properties value from json
      *
@@ -21,7 +21,7 @@
  * ECOMP is a trademark and service mark of AT&T Intellectual Property.
  */
 
-package org.onap.clamp.clds.client.req;
+package org.onap.clamp.clds.client.req.tca;
 
 import com.att.eelf.configuration.EELFLogger;
 import com.att.eelf.configuration.EELFManager;
@@ -30,6 +30,7 @@ import com.fasterxml.jackson.databind.node.ArrayNode;
 import com.fasterxml.jackson.databind.node.ObjectNode;
 import com.fasterxml.jackson.dataformat.yaml.snakeyaml.Yaml;
 
+import java.io.IOException;
 import java.util.Map;
 
 import org.onap.clamp.clds.exception.TcaRequestFormatterException;
@@ -77,7 +78,7 @@ public class TcaRequestFormatter {
             String tcaPolicyReq = rootNode.toString();
             logger.info("tcaPolicyReq=" + tcaPolicyReq);
             return tcaPolicyReq;
-        } catch (Exception e) {
+        } catch (IOException e) {
             throw new TcaRequestFormatterException("Exception caught when attempting to create the policy JSON", e);
         }
     }
@@ -90,31 +91,45 @@ public class TcaRequestFormatter {
      *            clds-references.properties file
      * @param modelProperties
      *            The Model Prop created from BPMN JSON and BPMN properties JSON
-     * @return The Json string containing that should be sent to policy
+     * @param service
+     *            The service ID, if not specified getGlobal.getService will be
+     *            used
+     * @param policyName
+     *            The policyName, if not specified the
+     *            modelProperties.getCurrentPolicyScopeAndPolicyName will be
+     *            used
+     * @param tca
+     *            The Tca object, if not specified the
+     *            modelProperties.setCurrentModelElementId will be used
+     * @return The Json node containing what should be sent to policy
      */
     public static JsonNode createPolicyContent(RefProp refProp, ModelProperties modelProperties, String service,
             String policyName, Tca tca) {
         try {
-            if (null == service) {
-                service = modelProperties.getGlobal().getService();
+            String serviceToUse = service;
+            String policyNameToUse = policyName;
+            Tca tcaToUse = tca;
+            if (serviceToUse == null) {
+                serviceToUse = modelProperties.getGlobal().getService();
             }
-            if (null == tca) {
-                tca = modelProperties.getType(Tca.class);
-                modelProperties.setCurrentModelElementId(tca.getId());
+            if (tcaToUse == null) {
+                tcaToUse = modelProperties.getType(Tca.class);
+                modelProperties.setCurrentModelElementId(tcaToUse.getId());
             }
-            if (null == policyName) {
-                policyName = modelProperties.getCurrentPolicyScopeAndPolicyName();
+            if (policyNameToUse == null) {
+                policyNameToUse = modelProperties.getCurrentPolicyScopeAndPolicyName();
             }
-            ObjectNode rootNode = (ObjectNode) refProp.getJsonTemplate("tca.template", service);
-            ((ObjectNode) rootNode.get("metricsPerEventName").get(0)).put("eventName", tca.getTcaItem().getEventName());
-            ((ObjectNode) rootNode.get("metricsPerEventName").get(0)).put("policyName", policyName);
+            ObjectNode rootNode = (ObjectNode) refProp.getJsonTemplate("tca.template", serviceToUse);
+            ((ObjectNode) rootNode.get("metricsPerEventName").get(0)).put("eventName",
+                    tcaToUse.getTcaItem().getEventName());
+            ((ObjectNode) rootNode.get("metricsPerEventName").get(0)).put("policyName", policyNameToUse);
             ((ObjectNode) rootNode.get("metricsPerEventName").get(0)).put("controlLoopSchemaType",
-                    tca.getTcaItem().getControlLoopSchemaType());
+                    tcaToUse.getTcaItem().getControlLoopSchemaType());
             ObjectNode thresholdsParent = ((ObjectNode) rootNode.get("metricsPerEventName").get(0));
-            addThresholds(refProp, service, thresholdsParent, tca.getTcaItem(), modelProperties);
+            addThresholds(refProp, serviceToUse, thresholdsParent, tcaToUse.getTcaItem(), modelProperties);
             logger.info("tcaPolicyContent=" + rootNode.toString());
             return rootNode;
-        } catch (Exception e) {
+        } catch (IOException e) {
             throw new TcaRequestFormatterException("Exception caught when attempting to create the policy content JSON",
                     e);
         }
@@ -140,9 +155,10 @@ public class TcaRequestFormatter {
      */
     private static void addThresholds(RefProp refProp, String service, ObjectNode appendToNode, TcaItem tcaItem,
             ModelProperties modelProperties) {
+        ArrayNode tcaNodes = appendToNode.withArray("thresholds");
+        ObjectNode tcaNode;
         try {
-            ArrayNode tcaNodes = appendToNode.withArray("thresholds");
-            ObjectNode tcaNode = (ObjectNode) refProp.getJsonTemplate("tca.thresholds.template", service);
+            tcaNode = (ObjectNode) refProp.getJsonTemplate("tca.thresholds.template", service);
             for (TcaThreshold tcaThreshold : tcaItem.getTcaThresholds()) {
                 tcaNode.put("closedLoopControlName", modelProperties.getControlNameAndPolicyUniqueId());
                 tcaNode.put("fieldPath", tcaThreshold.getFieldPath());
@@ -151,7 +167,7 @@ public class TcaRequestFormatter {
                 tcaNode.put("closedLoopEventStatus", tcaThreshold.getClosedLoopEventStatus());
                 tcaNodes.add(tcaNode);
             }
-        } catch (Exception e) {
+        } catch (IOException e) {
             throw new TcaRequestFormatterException("Exception caught when attempting to create the thresholds JSON", e);
         }
     }
@@ -171,34 +187,17 @@ public class TcaRequestFormatter {
      */
     public static String updatedBlueprintWithConfiguration(RefProp refProp, ModelProperties modelProperties,
             String yamlValue) {
-        try {
-            String jsonPolicy = ((ObjectNode) createPolicyContent(refProp, modelProperties, null, null, null))
-                    .toString();
-            logger.info("Yaml that will be updated:" + yamlValue);
-            Yaml yaml = new Yaml();
-            Map<String, Object> loadedYaml = (Map<String, Object>) yaml.load(yamlValue);
-            Map<String, Object> nodeTemplates = (Map<String, Object>) loadedYaml.get("node_templates");
-            // add policy_0 section in blueprint
-            /*
-             * Map<String, Object> policyObject = new HashMap<String, Object>
-             * (); Map<String, Object> policyIdObject = new HashMap<String,
-             * Object> (); String policyPrefix =
-             * refProp.getStringValue("tca.policyid.prefix");
-             * policyIdObject.put("policy_id", policyPrefix +
-             * modelProperties.getCurrentPolicyScopeAndPolicyName());
-             * policyObject.put("type", "dcae.nodes.policy");
-             * policyObject.put("properties", policyIdObject);
-             * nodeTemplates.put("policy_0", policyObject);
-             */
-            Map<String, Object> tcaObject = (Map<String, Object>) nodeTemplates.get("tca_tca");
-            Map<String, Object> propsObject = (Map<String, Object>) tcaObject.get("properties");
-            Map<String, Object> appPreferences = (Map<String, Object>) propsObject.get("app_preferences");
-            appPreferences.put("tca_policy", jsonPolicy);
-            String blueprint = yaml.dump(loadedYaml);
-            logger.info("Yaml updated:" + blueprint);
-            return blueprint;
-        } catch (Exception e) {
-            throw new TcaRequestFormatterException("Exception caught when attempting to update the blueprint", e);
-        }
+        String jsonPolicy = ((ObjectNode) createPolicyContent(refProp, modelProperties, null, null, null)).toString();
+        logger.info("Yaml that will be updated:" + yamlValue);
+        Yaml yaml = new Yaml();
+        Map<String, Object> loadedYaml = (Map<String, Object>) yaml.load(yamlValue);
+        Map<String, Object> nodeTemplates = (Map<String, Object>) loadedYaml.get("node_templates");
+        Map<String, Object> tcaObject = (Map<String, Object>) nodeTemplates.get("tca_tca");
+        Map<String, Object> propsObject = (Map<String, Object>) tcaObject.get("properties");
+        Map<String, Object> appPreferences = (Map<String, Object>) propsObject.get("app_preferences");
+        appPreferences.put("tca_policy", jsonPolicy);
+        String blueprint = yaml.dump(loadedYaml);
+        logger.info("Yaml updated:" + blueprint);
+        return blueprint;
     }
 }
\ No newline at end of file
index 0c73ac7..45d2786 100644 (file)
@@ -40,12 +40,12 @@ import org.onap.clamp.clds.client.HolmesPolicyDelegate;
 import org.onap.clamp.clds.client.HolmesPolicyDeleteDelegate;
 import org.onap.clamp.clds.client.OperationalPolicyDelegate;
 import org.onap.clamp.clds.client.OperationalPolicyDeleteDelegate;
-import org.onap.clamp.clds.client.PolicyClient;
-import org.onap.clamp.clds.client.SdcCatalogServices;
 import org.onap.clamp.clds.client.SdcSendReqDelegate;
 import org.onap.clamp.clds.client.TcaPolicyDelegate;
 import org.onap.clamp.clds.client.TcaPolicyDeleteDelegate;
-import org.onap.clamp.clds.client.req.SdcReq;
+import org.onap.clamp.clds.client.req.policy.PolicyClient;
+import org.onap.clamp.clds.client.req.sdc.SdcCatalogServices;
+import org.onap.clamp.clds.client.req.sdc.SdcReq;
 import org.onap.clamp.clds.dao.CldsDao;
 import org.onap.clamp.clds.model.refprop.RefProp;
 import org.onap.clamp.clds.transform.XslTransformer;
index c5332a6..2c052c1 100644 (file)
@@ -26,12 +26,7 @@ package org.onap.clamp.clds.dao;
 import com.att.eelf.configuration.EELFLogger;
 import com.att.eelf.configuration.EELFManager;
 
-import java.io.IOException;
 import java.io.InputStream;
-import java.io.ObjectInputStream;
-import java.sql.Blob;
-import java.sql.ResultSet;
-import java.sql.SQLException;
 import java.util.ArrayList;
 import java.util.HashMap;
 import java.util.List;
@@ -49,7 +44,6 @@ import org.onap.clamp.clds.model.CldsTemplate;
 import org.onap.clamp.clds.model.ValueItem;
 import org.springframework.dao.EmptyResultDataAccessException;
 import org.springframework.jdbc.core.JdbcTemplate;
-import org.springframework.jdbc.core.RowMapper;
 import org.springframework.jdbc.core.namedparam.MapSqlParameterSource;
 import org.springframework.jdbc.core.namedparam.SqlParameterSource;
 import org.springframework.jdbc.core.simple.SimpleJdbcCall;
@@ -60,10 +54,8 @@ import org.springframework.stereotype.Repository;
  */
 @Repository("cldsDao")
 public class CldsDao {
-
     protected static final EELFLogger logger        = EELFManager.getInstance().getLogger(CldsDao.class);
     protected static final EELFLogger metricsLogger = EELFManager.getInstance().getMetricsLogger();
-
     private JdbcTemplate              jdbcTemplateObject;
     private SimpleJdbcCall            procGetModel;
     private SimpleJdbcCall            procGetModelTemplate;
@@ -75,7 +67,6 @@ public class CldsDao {
     private SimpleJdbcCall            procDelAllModelInstances;
     private SimpleJdbcCall            procInsModelInstance;
     private SimpleJdbcCall            procDelModelInstance;
-
     private static final String       HEALTHCHECK   = "Select 1";
 
     /**
@@ -202,7 +193,6 @@ public class CldsDao {
         model.getEvent().setUserid((String) out.get("v_event_user_id"));
         model.setTypeId((String) out.get("v_service_type_id"));
         model.setDeploymentId((String) out.get("v_deployment_id"));
-
         Map<String, Object> modelResults = logSqlExecution(procGetModel, in);
         Object modelResultObject = modelResults.get("#result-set-1");
         if (modelResultObject != null && modelResultObject instanceof ArrayList) {
@@ -266,7 +256,6 @@ public class CldsDao {
         // Delete all existing model instances for given controlNameUUID
         logger.debug("deleting instances for: {}", model.getControlNameUuid());
         delAllModelInstances(model.getControlNameUuid());
-
         if (modelInstancesList == null) {
             logger.debug("modelInstancesList == null");
         } else {
@@ -358,41 +347,6 @@ public class CldsDao {
         logSqlExecution(procUpdEvent, in);
     }
 
-    /**
-     * Generic mapper for list of values
-     */
-    private static final class ValueItemMapper implements RowMapper<ValueItem> {
-        @Override
-        public ValueItem mapRow(ResultSet rs, int rowNum) throws SQLException {
-            ValueItem item = new ValueItem();
-            item.setValue(rs.getString(1));
-            return item;
-        }
-    }
-
-    /**
-     * Generic mapper for CldsDBServiceCache
-     */
-    private static final class CldsServiceDataMapper implements RowMapper<CldsServiceData> {
-        @Override
-        public CldsServiceData mapRow(ResultSet rs, int rowNum) throws SQLException {
-            CldsServiceData cldsServiceData = new CldsServiceData();
-            long age;
-            age = rs.getLong(5);
-            Blob blob = rs.getBlob(4);
-            InputStream is = blob.getBinaryStream();
-            ObjectInputStream oip;
-            try {
-                oip = new ObjectInputStream(is);
-                cldsServiceData = (CldsServiceData) oip.readObject();
-                cldsServiceData.setAgeOfRecord(age);
-            } catch (IOException | ClassNotFoundException e) {
-                logger.error("Error caught while retrieving cldsServiceData from database", e);
-            }
-            return cldsServiceData;
-        }
-    }
-
     /**
      * Return list of model names
      *
@@ -503,14 +457,14 @@ public class CldsDao {
     }
 
     /**
-     * Method to get all models with model properties.
+     * Method to get deployed/active models with model properties.
      * 
      * @return list of CldsModelProp
      */
-    public List<CldsModelProp> getAllModelProperties() {
+    public List<CldsModelProp> getDeployedModelProperties() {
         List<CldsModelProp> cldsModelPropList = new ArrayList<CldsModelProp>();
-        String modelsSql = "select m.model_id, m.model_name, mp.model_prop_id, mp.model_prop_text FROM model m, model_properties mp"
-                + " WHERE m.model_prop_id = mp.model_prop_id";
+        String modelsSql = "select m.model_id, m.model_name, mp.model_prop_id, mp.model_prop_text FROM model m, model_properties mp, event e "
+                + "WHERE m.model_prop_id = mp.model_prop_id and m.event_id = e.event_id and e.action_cd = 'DEPLOY'";
         List<Map<String, Object>> rows = jdbcTemplateObject.queryForList(modelsSql);
         CldsModelProp cldsModelProp = null;
         for (Map<String, Object> row : rows) {
@@ -523,5 +477,4 @@ public class CldsDao {
         }
         return cldsModelPropList;
     }
-
 }
diff --git a/src/main/java/org/onap/clamp/clds/dao/CldsServiceDataMapper.java b/src/main/java/org/onap/clamp/clds/dao/CldsServiceDataMapper.java
new file mode 100644 (file)
index 0000000..91d8950
--- /dev/null
@@ -0,0 +1,62 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP CLAMP
+ * ================================================================================
+ * Copyright (C) 2017 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============================================
+ * ===================================================================
+ * ECOMP is a trademark and service mark of AT&T Intellectual Property.
+ */
+
+package org.onap.clamp.clds.dao;
+
+import com.att.eelf.configuration.EELFLogger;
+import com.att.eelf.configuration.EELFManager;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.ObjectInputStream;
+import org.apache.commons.io.serialization.ValidatingObjectInputStream;
+import java.sql.Blob;
+import java.sql.ResultSet;
+import java.sql.SQLException;
+
+import org.onap.clamp.clds.model.CldsServiceData;
+import org.springframework.jdbc.core.RowMapper;
+
+/**
+ * Generic mapper for CldsDBServiceCache
+ */
+public final class CldsServiceDataMapper implements RowMapper<CldsServiceData> {
+    protected static final EELFLogger logger = EELFManager.getInstance().getLogger(CldsDao.class);
+
+    @Override
+    public CldsServiceData mapRow(ResultSet rs, int rowNum) throws SQLException {
+        CldsServiceData cldsServiceData = new CldsServiceData();
+        long age;
+        age = rs.getLong(5);
+        Blob blob = rs.getBlob(4);
+        InputStream is = blob.getBinaryStream();
+        try (ValidatingObjectInputStream oip = new ValidatingObjectInputStream(is)) {
+               oip.accept(CldsServiceData.class);
+            cldsServiceData = (CldsServiceData) oip.readObject();
+            cldsServiceData.setAgeOfRecord(age);
+        } catch (IOException | ClassNotFoundException e) {
+            logger.error("Error caught while retrieving cldsServiceData from database", e);
+        }
+        return cldsServiceData;
+    }
+}
diff --git a/src/main/java/org/onap/clamp/clds/dao/ValueItemMapper.java b/src/main/java/org/onap/clamp/clds/dao/ValueItemMapper.java
new file mode 100644 (file)
index 0000000..1236728
--- /dev/null
@@ -0,0 +1,42 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP CLAMP
+ * ================================================================================
+ * Copyright (C) 2017 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============================================
+ * ===================================================================
+ * ECOMP is a trademark and service mark of AT&T Intellectual Property.
+ */
+
+package org.onap.clamp.clds.dao;
+
+import java.sql.ResultSet;
+import java.sql.SQLException;
+
+import org.onap.clamp.clds.model.ValueItem;
+import org.springframework.jdbc.core.RowMapper;
+
+/**
+ * Generic mapper for list of values
+ */
+public final class ValueItemMapper implements RowMapper<ValueItem> {
+    @Override
+    public ValueItem mapRow(ResultSet rs, int rowNum) throws SQLException {
+        ValueItem item = new ValueItem();
+        item.setValue(rs.getString(1));
+        return item;
+    }
+}
diff --git a/src/main/java/org/onap/clamp/clds/exception/ModelPropertiesException.java b/src/main/java/org/onap/clamp/clds/exception/ModelPropertiesException.java
new file mode 100644 (file)
index 0000000..09fb5db
--- /dev/null
@@ -0,0 +1,61 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP CLAMP
+ * ================================================================================
+ * Copyright (C) 2017 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============================================
+ * ===================================================================
+ * ECOMP is a trademark and service mark of AT&T Intellectual Property.
+ */
+
+package org.onap.clamp.clds.exception;
+
+/**
+ * The exception used in case of issues when decoding the ModelProperties JSON
+ * generated by the Designer UI.
+ * 
+ *
+ */
+public class ModelPropertiesException extends RuntimeException {
+    /**
+     * Generated ID.
+     */
+    private static final long serialVersionUID = 8452294782552680344L;
+
+    /**
+     * This constructor can be used to create a new ModelPropertiesException.
+     * 
+     * @param message
+     *            A string message detailing the problem
+     * @param e
+     *            The exception sent by the code
+     */
+    public ModelPropertiesException(String message, Throwable e) {
+        super(message, e);
+    }
+
+    /**
+     * This constructor can be used to create a new ModelPropertiesException.
+     * Use this constructor only if you are creating a new exception stack, not
+     * if an exception was already raised by another code.
+     *
+     * @param message
+     *            A string message detailing the problem
+     */
+    public ModelPropertiesException(String message) {
+        super(message);
+    }
+}
index f3d344a..9738396 100644 (file)
@@ -25,8 +25,6 @@ package org.onap.clamp.clds.model.prop;
 
 import com.att.eelf.configuration.EELFLogger;
 import com.att.eelf.configuration.EELFManager;
-import com.fasterxml.jackson.core.JsonParseException;
-import com.fasterxml.jackson.databind.JsonMappingException;
 import com.fasterxml.jackson.databind.JsonNode;
 import com.fasterxml.jackson.databind.ObjectMapper;
 import com.fasterxml.jackson.databind.node.ArrayNode;
@@ -40,25 +38,22 @@ import java.util.List;
 import java.util.Map;
 import java.util.Map.Entry;
 
+import org.onap.clamp.clds.exception.ModelBpmnException;
 import org.onap.clamp.clds.service.CldsService;
 
 /**
  * Parse Model BPMN properties.
  * <p>
- * Example json: {"policy"
- * :[{"id":"Policy_0oxeocn", "from":"StartEvent_1"}]}
+ * Example json: {"policy" :[{"id":"Policy_0oxeocn", "from":"StartEvent_1"}]}
  */
 public class ModelBpmn {
     protected static final EELFLogger               logger        = EELFManager.getInstance()
             .getLogger(CldsService.class);
     protected static final EELFLogger               auditLogger   = EELFManager.getInstance().getAuditLogger();
-
     // for each type, an array of entries
     private final Map<String, List<ModelBpmnEntry>> entriesByType = new HashMap<>();
-
     // for each id, an array of entries
     private final Map<String, List<ModelBpmnEntry>> entriesById   = new HashMap<>();
-
     // List of all elementIds
     private List<String>                            bpmnElementIds;
 
@@ -67,36 +62,37 @@ public class ModelBpmn {
      *
      * @param modelBpmnPropText
      * @return
-     * @throws IOException
-     * @throws JsonMappingException
-     * @throws JsonParseException
      */
-    public static ModelBpmn create(String modelBpmnPropText) throws IOException {
-        ModelBpmn modelBpmn = new ModelBpmn();
-        ObjectMapper objectMapper = new ObjectMapper();
-        ObjectNode root = objectMapper.readValue(modelBpmnPropText, ObjectNode.class);
-        // iterate over each entry like:
-        // "Policy":[{"id":"Policy","from":"StartEvent_1"}]
-        Iterator<Entry<String, JsonNode>> entryItr = root.fields();
-        List<String> bpmnElementIdList = new ArrayList<>();
-        while (entryItr.hasNext()) {
-            // process the entry
-            Entry<String, JsonNode> entry = entryItr.next();
-            String type = entry.getKey();
-            ArrayNode arrayNode = (ArrayNode) entry.getValue();
-            // process each id/from object, like:
-            // {"id":"Policy","from":"StartEvent_1"}
-            for (JsonNode anArrayNode : arrayNode) {
-                ObjectNode node = (ObjectNode) anArrayNode;
-                String id = node.get("id").asText();
-                String fromId = node.get("from").asText();
-                ModelBpmnEntry modelBpmnEntry = new ModelBpmnEntry(type, id, fromId);
-                modelBpmn.addEntry(modelBpmnEntry);
-                bpmnElementIdList.add(id);
+    public static ModelBpmn create(String modelBpmnPropText) {
+        try {
+            ModelBpmn modelBpmn = new ModelBpmn();
+            ObjectMapper objectMapper = new ObjectMapper();
+            ObjectNode root = objectMapper.readValue(modelBpmnPropText, ObjectNode.class);
+            // iterate over each entry like:
+            // "Policy":[{"id":"Policy","from":"StartEvent_1"}]
+            Iterator<Entry<String, JsonNode>> entryItr = root.fields();
+            List<String> bpmnElementIdList = new ArrayList<>();
+            while (entryItr.hasNext()) {
+                // process the entry
+                Entry<String, JsonNode> entry = entryItr.next();
+                String type = entry.getKey();
+                ArrayNode arrayNode = (ArrayNode) entry.getValue();
+                // process each id/from object, like:
+                // {"id":"Policy","from":"StartEvent_1"}
+                for (JsonNode anArrayNode : arrayNode) {
+                    ObjectNode node = (ObjectNode) anArrayNode;
+                    String id = node.get("id").asText();
+                    String fromId = node.get("from").asText();
+                    ModelBpmnEntry modelBpmnEntry = new ModelBpmnEntry(type, id, fromId);
+                    modelBpmn.addEntry(modelBpmnEntry);
+                    bpmnElementIdList.add(id);
+                }
+                modelBpmn.setBpmnElementIds(bpmnElementIdList);
             }
-            modelBpmn.setBpmnElementIds(bpmnElementIdList);
+            return modelBpmn;
+        } catch (IOException e) {
+            throw new ModelBpmnException("Exception occurred during the decoding of the bpmn JSON", e);
         }
-        return modelBpmn;
     }
 
     /**
@@ -122,8 +118,8 @@ public class ModelBpmn {
     }
 
     /**
-     * This method verifies if the ModelElement Type (holmes, tca,
-     * ...) is in the list.
+     * This method verifies if the ModelElement Type (holmes, tca, ...) is in
+     * the list.
      *
      * @param type
      *            A model Element type (tca, ...)
index f9eeeb5..bbcfd5d 100644 (file)
@@ -56,13 +56,14 @@ import javax.ws.rs.QueryParam;
 import javax.ws.rs.core.MediaType;
 import javax.xml.transform.TransformerException;
 
+import org.apache.commons.codec.DecoderException;
 import org.apache.commons.lang3.StringUtils;
 import org.camunda.bpm.engine.RuntimeService;
 import org.camunda.bpm.engine.runtime.ProcessInstance;
 import org.json.simple.parser.ParseException;
 import org.onap.clamp.clds.client.DcaeDispatcherServices;
 import org.onap.clamp.clds.client.DcaeInventoryServices;
-import org.onap.clamp.clds.client.SdcCatalogServices;
+import org.onap.clamp.clds.client.req.sdc.SdcCatalogServices;
 import org.onap.clamp.clds.dao.CldsDao;
 import org.onap.clamp.clds.exception.CldsConfigException;
 import org.onap.clamp.clds.exception.SdcCommunicationException;
@@ -337,12 +338,6 @@ public class CldsService extends SecureServiceBase {
         logger.info("PUT propText={}", cldsModel.getPropText());
         logger.info("PUT imageText={}", cldsModel.getImageText());
         cldsModel.setName(modelName);
-        try {
-            duplicateCheckforServiceVf(modelName, cldsModel.getPropText());
-        } catch (IOException | BadRequestException e) {
-            logger.error("Exception occured during duplicate check for service and VF", e);
-            throw new CldsConfigException(e.getMessage(), e);
-        }
         if (cldsModel.getTemplateName() != null) {
             CldsTemplate template = cldsDao.getTemplate(cldsModel.getTemplateName());
             if (template != null) {
@@ -390,8 +385,13 @@ public class CldsService extends SecureServiceBase {
      * @param model
      * @return
      * @throws TransformerException
+     *             In case of issues when doing the XSLT of the BPMN flow
      * @throws ParseException
+     *             In case of issues when parsing the JSON
      * @throws GeneralSecurityException
+     *             In case of issues when decrypting the password
+     * @throws DecoderException
+     *             In case of issues with the Hex String decoding
      */
     @ApiOperation(value = "Saves and processes an action for a CLDS model by name", notes = "", response = String.class)
     @PUT
@@ -400,7 +400,7 @@ public class CldsService extends SecureServiceBase {
     @Produces(MediaType.APPLICATION_JSON)
     public CldsModel putModelAndProcessAction(@PathParam("action") String action,
             @PathParam("modelName") String modelName, @QueryParam("test") String test, CldsModel model)
-            throws TransformerException, ParseException, GeneralSecurityException {
+            throws TransformerException, ParseException, GeneralSecurityException, DecoderException {
         Date startTime = new Date();
         LoggingUtils.setRequestContext("CldsService: Process model action", getPrincipalName());
         String actionCd = action.toUpperCase();
@@ -558,13 +558,15 @@ public class CldsService extends SecureServiceBase {
      * 
      * @throws GeneralSecurityException
      *             In case of issue when decryting the SDC password
+     * @throws DecoderException
+     *             In case of issues with the decoding of the Hex String
      *
      */
     @ApiOperation(value = "Retrieves sdc services", notes = "", response = String.class)
     @GET
     @Path("/sdc/services")
     @Produces(MediaType.APPLICATION_JSON)
-    public String getSdcServices() throws GeneralSecurityException {
+    public String getSdcServices() throws GeneralSecurityException, DecoderException {
         Date startTime = new Date();
         LoggingUtils.setRequestContext("CldsService: GET sdc services", getPrincipalName());
         String retStr;
@@ -603,7 +605,9 @@ public class CldsService extends SecureServiceBase {
      * on refresh and non refresh
      * 
      * @throws GeneralSecurityException
-     *             In case of issue when decryting the SDC password
+     *             In case of issues with the decryting the encrypted password
+     * @throws DecoderException
+     *             In case of issues with the decoding of the Hex String
      * 
      */
     @ApiOperation(value = "Retrieves total properties by using invariantUUID based on refresh and non refresh", notes = "", response = String.class)
@@ -612,7 +616,8 @@ public class CldsService extends SecureServiceBase {
     @Produces(MediaType.APPLICATION_JSON)
     public String getSdcPropertiesByServiceUUIDForRefresh(
             @PathParam("serviceInvariantUUID") String serviceInvariantUUID,
-            @DefaultValue("false") @QueryParam("refresh") String refresh) throws GeneralSecurityException {
+            @DefaultValue("false") @QueryParam("refresh") String refresh)
+            throws GeneralSecurityException, DecoderException {
         Date startTime = new Date();
         LoggingUtils.setRequestContext("CldsService: GET sdc properties by uuid", getPrincipalName());
         CldsServiceData cldsServiceData = new CldsServiceData();
@@ -831,6 +836,12 @@ public class CldsService extends SecureServiceBase {
             @QueryParam("test") String test, CldsModel model) throws IOException {
         Date startTime = new Date();
         LoggingUtils.setRequestContext("CldsService: Deploy model", getPrincipalName());
+        try {
+            checkForDuplicateServiceVf(modelName, model.getPropText());
+        } catch (IOException | BadRequestException e) {
+            logger.error("Exception occured during duplicate check for service and VF", e);
+            throw new CldsConfigException(e.getMessage(), e);
+        }
         String deploymentId = "";
         // If model is already deployed then pass same deployment id
         if (model.getDeploymentId() != null && !model.getDeploymentId().isEmpty()) {
@@ -932,13 +943,13 @@ public class CldsService extends SecureServiceBase {
         }
     }
 
-    private void duplicateCheckforServiceVf(String modelName, String modelPropText) throws IOException {
+    private void checkForDuplicateServiceVf(String modelName, String modelPropText) throws IOException {
         JsonNode modelJson = new ObjectMapper().readTree(modelPropText);
         JsonNode globalNode = modelJson.get("global");
         String service = AbstractModelElement.getValueByName(globalNode, "service");
         List<String> resourceVf = AbstractModelElement.getValuesByName(globalNode, "vf");
         if (service != null && resourceVf != null && !resourceVf.isEmpty()) {
-            List<CldsModelProp> cldsModelPropList = cldsDao.getAllModelProperties();
+            List<CldsModelProp> cldsModelPropList = cldsDao.getDeployedModelProperties();
             for (CldsModelProp cldsModelProp : cldsModelPropList) {
                 JsonNode currentJson = new ObjectMapper().readTree(cldsModelProp.getPropText());
                 JsonNode currentNode = currentJson.get("global");
@@ -947,8 +958,9 @@ public class CldsService extends SecureServiceBase {
                 if (currentVf != null && !currentVf.isEmpty()) {
                     if (!modelName.equalsIgnoreCase(cldsModelProp.getName()) && service.equalsIgnoreCase(currentService)
                             && resourceVf.get(0).equalsIgnoreCase(currentVf.get(0))) {
-                        throw new BadRequestException("Same service/VF already exists in " + cldsModelProp.getName()
-                                + " model, please select different service/VF.");
+                        throw new BadRequestException("Same Service/VF already exists in " + cldsModelProp.getName()
+                                + " model, please select different Service/VF.");
+
                     }
                 }
             }
index c84f5ef..070c066 100644 (file)
@@ -44,7 +44,6 @@ import javax.xml.transform.TransformerException;
 import org.onap.clamp.clds.dao.CldsDao;
 import org.onap.clamp.clds.model.CldsTemplate;
 import org.onap.clamp.clds.model.ValueItem;
-import org.onap.clamp.clds.transform.XslTransformer;
 import org.onap.clamp.clds.util.LoggingUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.beans.factory.annotation.Value;
@@ -55,15 +54,11 @@ import org.springframework.beans.factory.annotation.Value;
 @AjscService
 @Path("/cldsTempate")
 public class CldsTemplateService extends SecureServiceBase {
-
     @Value("${CLDS_PERMISSION_TYPE_TEMPLATE:permission-type-template}")
     private String                  cldsPermissionTypeTemplate;
-
     @Value("${CLDS_PERMISSION_INSTANCE:dev}")
     private String                  cldsPermissionInstance;
-
     private SecureServicePermission permissionReadTemplate;
-
     private SecureServicePermission permissionUpdateTemplate;
 
     @PostConstruct
@@ -75,12 +70,7 @@ public class CldsTemplateService extends SecureServiceBase {
     }
 
     @Autowired
-    private CldsDao        cldsDao;
-
-    @Autowired
-    private XslTransformer cldsBpmnTransformer;
-
-    private static String  userid;
+    private CldsDao cldsDao;
 
     /**
      * REST service that retrieves BPMN for a CLDS template name from the
@@ -170,7 +160,6 @@ public class CldsTemplateService extends SecureServiceBase {
         Date startTime = new Date();
         LoggingUtils.setRequestContext("CldsTemplateService: PUT template", getPrincipalName());
         isAuthorized(permissionUpdateTemplate);
-
         logger.info("PUT Template for  templateName=" + templateName);
         logger.info("PUT bpmnText=" + cldsTemplate.getBpmnText());
         logger.info("PUT propText=" + cldsTemplate.getPropText());
@@ -185,13 +174,11 @@ public class CldsTemplateService extends SecureServiceBase {
         logger.info(" bpmnText : " + cldsTemplate.getBpmnText());
         logger.info(" Image Text : " + cldsTemplate.getImageText());
         logger.info(" Prop Text : " + cldsTemplate.getPropText());
-        cldsTemplate.save(cldsDao, userid);
-
+        cldsTemplate.save(cldsDao, null);
         // audit log
         LoggingUtils.setTimeContext(startTime, new Date());
         LoggingUtils.setResponseContext("0", "Put template success", this.getClass().getName());
         auditLogger.info("PUT template completed");
-
         return cldsTemplate;
     }
 
index 9be8a13..d3f6424 100644 (file)
@@ -24,7 +24,7 @@
 package org.onap.clamp.clds;
 
 import org.junit.BeforeClass;
-import org.onap.clamp.clds.client.PolicyClient;
+import org.onap.clamp.clds.client.req.policy.PolicyClient;
 import org.onap.clamp.clds.model.refprop.RefProp;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.test.context.ActiveProfiles;
index 734b605..9b8f4aa 100644 (file)
@@ -31,6 +31,7 @@ import java.util.ArrayList;
 import java.util.List;
 
 import org.junit.Test;
+import org.onap.clamp.clds.client.req.policy.OperationalPolicyReq;
 import org.onap.policy.controlloop.policy.PolicyResult;
 import org.onap.policy.sdc.Resource;
 import org.onap.policy.sdc.ResourceType;
index 1427c32..78b2401 100644 (file)
@@ -25,6 +25,8 @@ package org.onap.clamp.clds.it;
 
 import static org.junit.Assert.assertEquals;
 
+import com.att.aft.dme2.internal.apache.commons.lang.RandomStringUtils;
+
 import java.io.IOException;
 
 import javax.ws.rs.NotFoundException;
@@ -51,10 +53,8 @@ import org.springframework.test.context.junit4.SpringRunner;
 @SpringBootTest
 @TestPropertySource(locations = "classpath:application-no-camunda.properties")
 public class CldsDaoItCase extends AbstractItCase {
-
     @Autowired
     public CldsDao cldsDao;
-
     private String bpmnText;
     private String imageText;
     private String bpmnPropText;
@@ -74,40 +74,37 @@ public class CldsDaoItCase extends AbstractItCase {
 
     @Test
     public void testModelSave() throws IOException {
+        String randomNameTemplate = RandomStringUtils.randomAlphanumeric(5);
+        String randomNameModel = RandomStringUtils.randomAlphanumeric(5);
         // Add the template first
         CldsTemplate newTemplate = new CldsTemplate();
-        newTemplate.setName("test-template");
-
+        newTemplate.setName(randomNameTemplate);
         newTemplate.setBpmnText(bpmnText);
         newTemplate.setImageText(imageText);
-
         // Save the template in DB
         cldsDao.setTemplate(newTemplate, "user");
         // Test if it's well there
-        CldsTemplate newTemplateRead = cldsDao.getTemplate("test-template");
+        CldsTemplate newTemplateRead = cldsDao.getTemplate(randomNameTemplate);
         assertEquals(bpmnText, newTemplateRead.getBpmnText());
         assertEquals(imageText, newTemplateRead.getImageText());
-
         // Save the model
         CldsModel newModel = new CldsModel();
-        newModel.setName("test-model");
-
+        newModel.setName(randomNameModel);
         newModel.setBpmnText(bpmnText);
         newModel.setImageText(imageText);
         newModel.setPropText(bpmnPropText);
         newModel.setControlNamePrefix("ClosedLoop-");
-        newModel.setTemplateName("test-template");
+        newModel.setTemplateName(randomNameTemplate);
         newModel.setTemplateId(newTemplate.getId());
         newModel.setDocText(newTemplate.getPropText());
         newModel.setDocId(newTemplate.getPropId());
         // Save the model in DB
         cldsDao.setModel(newModel, "user");
         // Test if the model can be retrieved
-        CldsModel newCldsModel = cldsDao.getModelTemplate("test-model");
+        CldsModel newCldsModel = cldsDao.getModelTemplate(randomNameModel);
         assertEquals(bpmnText, newCldsModel.getBpmnText());
         assertEquals(imageText, newCldsModel.getImageText());
         assertEquals(bpmnPropText, newCldsModel.getPropText());
-
     }
 
     @Test(expected = NotFoundException.class)
@@ -125,21 +122,16 @@ public class CldsDaoItCase extends AbstractItCase {
         // Add the template first
         CldsTemplate newTemplate = new CldsTemplate();
         newTemplate.setName("test-template-for-event");
-
         newTemplate.setBpmnText(bpmnText);
         newTemplate.setImageText(imageText);
-
         newTemplate.save(cldsDao, "user");
-
         // Test if it's well there
         CldsTemplate newTemplateRead = CldsTemplate.retrieve(cldsDao, "test-template-for-event", false);
         assertEquals(bpmnText, newTemplateRead.getBpmnText());
         assertEquals(imageText, newTemplateRead.getImageText());
-
         // Save the model
         CldsModel newModel = new CldsModel();
         newModel.setName("test-model-for-event");
-
         newModel.setBpmnText(bpmnText);
         newModel.setImageText(imageText);
         newModel.setPropText(bpmnPropText);
@@ -148,7 +140,6 @@ public class CldsDaoItCase extends AbstractItCase {
         newModel.setTemplateId(newTemplate.getId());
         newModel.setDocText(newTemplate.getPropText());
         newModel.setDocId(newTemplate.getPropId());
-
         CldsEvent.insEvent(cldsDao, newModel, "user", CldsEvent.ACTION_RESTART, CldsEvent.ACTION_STATE_COMPLETED,
                 "process-instance-id");
     }
index a1882ea..f6e9abd 100644 (file)
@@ -25,20 +25,30 @@ package org.onap.clamp.clds.it;
 
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNotNull;
 import static org.junit.Assert.assertTrue;
 
+import com.att.aft.dme2.internal.apache.commons.lang.RandomStringUtils;
+
+import java.io.IOException;
 import java.io.InputStream;
 import java.security.Principal;
 import java.util.Properties;
 
 import javax.ws.rs.core.SecurityContext;
 
+import org.junit.Before;
 import org.junit.Test;
 import org.junit.runner.RunWith;
 import org.mockito.Mockito;
 import org.onap.clamp.clds.AbstractItCase;
+import org.onap.clamp.clds.dao.CldsDao;
+import org.onap.clamp.clds.model.CldsHealthCheck;
 import org.onap.clamp.clds.model.CldsInfo;
+import org.onap.clamp.clds.model.CldsModel;
+import org.onap.clamp.clds.model.CldsTemplate;
 import org.onap.clamp.clds.service.CldsService;
+import org.onap.clamp.clds.util.ResourceFileUtil;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.boot.test.context.SpringBootTest;
 import org.springframework.boot.test.context.SpringBootTest.WebEnvironment;
@@ -52,19 +62,34 @@ import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
 @SpringBootTest(webEnvironment = WebEnvironment.RANDOM_PORT)
 @TestPropertySource(locations = "classpath:application-no-camunda.properties")
 public class CldsServiceItCase extends AbstractItCase {
-
     @Autowired
-    CldsService cldsService;
+    CldsService    cldsService;
+    private String bpmnText;
+    private String imageText;
+    private String bpmnPropText;
+    @Autowired
+    public CldsDao cldsDao;
+
+    /**
+     * Setup the variable before the tests execution.
+     * 
+     * @throws IOException
+     *             In case of issues when opening the files
+     */
+    @Before
+    public void setupBefore() throws IOException {
+        bpmnText = ResourceFileUtil.getResourceAsString("example/dao/bpmn-template.xml");
+        imageText = ResourceFileUtil.getResourceAsString("example/dao/image-template.xml");
+        bpmnPropText = ResourceFileUtil.getResourceAsString("example/dao/bpmn-prop.json");
+    }
 
     @Test
     public void testCldsInfoNotAuthorized() throws Exception {
         SecurityContext securityContext = Mockito.mock(SecurityContext.class);
         Principal principal = Mockito.mock(Principal.class);
         Mockito.when(principal.getName()).thenReturn("admin");
-
         Mockito.when(securityContext.getUserPrincipal()).thenReturn(principal);
         cldsService.setSecurityContext(securityContext);
-
         CldsInfo cldsInfo = cldsService.getCldsInfo();
         assertFalse(cldsInfo.isPermissionReadCl());
         assertFalse(cldsInfo.isPermissionReadTemplate());
@@ -74,32 +99,75 @@ public class CldsServiceItCase extends AbstractItCase {
 
     @Test
     public void testCldsInfoAuthorized() throws Exception {
-
         SecurityContext securityContext = Mockito.mock(SecurityContext.class);
         Principal p = Mockito.mock(Principal.class);
         Mockito.when(p.getName()).thenReturn("admin");
-
         Mockito.when(securityContext.getUserPrincipal()).thenReturn(p);
         Mockito.when(securityContext.isUserInRole("permission-type-cl|dev|read")).thenReturn(true);
         Mockito.when(securityContext.isUserInRole("permission-type-cl|dev|update")).thenReturn(true);
         Mockito.when(securityContext.isUserInRole("permission-type-template|dev|read")).thenReturn(true);
         Mockito.when(securityContext.isUserInRole("permission-type-template|dev|update")).thenReturn(true);
-
         cldsService.setSecurityContext(securityContext);
-
         CldsInfo cldsInfo = cldsService.getCldsInfo();
         assertTrue(cldsInfo.isPermissionReadCl());
         assertTrue(cldsInfo.isPermissionReadTemplate());
         assertTrue(cldsInfo.isPermissionUpdateCl());
         assertTrue(cldsInfo.isPermissionUpdateTemplate());
-
         Properties prop = new Properties();
-
         InputStream in = Thread.currentThread().getContextClassLoader().getResourceAsStream("clds-version.properties");
         prop.load(in);
         in.close();
-
         assertEquals(cldsInfo.getCldsVersion(), prop.getProperty("clds.version"));
         assertEquals(cldsInfo.getUserName(), "admin");
     }
+
+    @Test
+    public void testGetHealthCheck() throws Exception {
+        CldsHealthCheck cldsHealthCheck = cldsService.gethealthcheck();
+        assertNotNull(cldsHealthCheck);
+        assertEquals("UP", cldsHealthCheck.getHealthCheckStatus());
+        assertEquals("CLDS-APP", cldsHealthCheck.getHealthCheckComponent());
+        assertEquals("OK", cldsHealthCheck.getDescription());
+    }
+
+    @Test
+    public void testPutModel() throws Exception {
+        String randomNameTemplate = RandomStringUtils.randomAlphanumeric(5);
+        String randomNameModel = RandomStringUtils.randomAlphanumeric(5);
+        SecurityContext securityContext = Mockito.mock(SecurityContext.class);
+        Principal p = Mockito.mock(Principal.class);
+        Mockito.when(p.getName()).thenReturn("admin");
+        Mockito.when(securityContext.getUserPrincipal()).thenReturn(p);
+        Mockito.when(securityContext.isUserInRole("permission-type-cl|dev|read")).thenReturn(true);
+        Mockito.when(securityContext.isUserInRole("permission-type-cl|dev|update")).thenReturn(true);
+        Mockito.when(securityContext.isUserInRole("permission-type-template|dev|read")).thenReturn(true);
+        Mockito.when(securityContext.isUserInRole("permission-type-template|dev|update")).thenReturn(true);
+        cldsService.setSecurityContext(securityContext);
+        // Add the template first
+        CldsTemplate newTemplate = new CldsTemplate();
+        newTemplate.setName(randomNameTemplate);
+        newTemplate.setBpmnText(bpmnText);
+        newTemplate.setImageText(imageText);
+        // Save the template in DB
+        cldsDao.setTemplate(newTemplate, "user");
+        // Test if it's well there
+        CldsTemplate newTemplateRead = cldsDao.getTemplate(randomNameTemplate);
+        assertEquals(bpmnText, newTemplateRead.getBpmnText());
+        assertEquals(imageText, newTemplateRead.getImageText());
+        // Save the model
+        CldsModel newModel = new CldsModel();
+        newModel.setName(randomNameTemplate);
+        newModel.setBpmnText(bpmnText);
+        newModel.setImageText(imageText);
+        newModel.setPropText(bpmnPropText);
+        newModel.setControlNamePrefix("ClosedLoop-");
+        newModel.setTemplateName("test-template");
+        newModel.setTemplateId(newTemplate.getId());
+        newModel.setDocText(newTemplate.getPropText());
+        newModel.setDocId(newTemplate.getPropId());
+        // Test the PutModel method
+        cldsService.putModel(randomNameModel, newModel);
+        // Verify whether it has been added properly or not
+        assertNotNull(cldsDao.getModel(randomNameModel));
+    }
 }
index c87bbf6..3009199 100644 (file)
@@ -36,7 +36,7 @@ import java.util.Map;
 import org.junit.Test;
 import org.junit.runner.RunWith;
 import org.onap.clamp.clds.AbstractItCase;
-import org.onap.clamp.clds.client.req.OperationalPolicyReq;
+import org.onap.clamp.clds.client.req.policy.OperationalPolicyReq;
 import org.onap.clamp.clds.model.CldsEvent;
 import org.onap.clamp.clds.model.prop.ModelProperties;
 import org.onap.clamp.clds.model.prop.Policy;
@@ -52,7 +52,6 @@ import org.springframework.test.context.junit4.SpringRunner;
 @SpringBootTest
 @TestPropertySource(locations = "classpath:application-no-camunda.properties")
 public class OperationPolicyReqItCase extends AbstractItCase {
-
     @Test
     public void formatAttributesTest() throws IOException, BuilderException {
         String modelProp = ResourceFileUtil.getResourceAsString("example/modelProp.json");
index c129800..2757377 100644 (file)
@@ -34,8 +34,8 @@ import org.junit.Before;
 import org.junit.Test;
 import org.junit.runner.RunWith;
 import org.onap.clamp.clds.AbstractItCase;
-import org.onap.clamp.clds.client.req.OperationalPolicyReq;
-import org.onap.clamp.clds.client.req.TcaRequestFormatter;
+import org.onap.clamp.clds.client.req.policy.OperationalPolicyReq;
+import org.onap.clamp.clds.client.req.tca.TcaRequestFormatter;
 import org.onap.clamp.clds.model.CldsEvent;
 import org.onap.clamp.clds.model.prop.ModelProperties;
 import org.onap.clamp.clds.model.prop.Policy;
@@ -77,7 +77,6 @@ public class PolicyClientItCase extends AbstractItCase {
         if (policy.isFound()) {
             for (PolicyChain policyChain : policy.getPolicyChains()) {
                 String operationalPolicyRequestUuid = UUID.randomUUID().toString();
-
                 Map<AttributeType, Map<String, String>> attributes = OperationalPolicyReq.formatAttributes(refProp,
                         prop, policy.getId(), policyChain);
                 policyClient.sendBrmsPolicy(attributes, prop, operationalPolicyRequestUuid);
@@ -91,7 +90,6 @@ public class PolicyClientItCase extends AbstractItCase {
         if (tca.isFound()) {
             String tcaPolicyRequestUuid = UUID.randomUUID().toString();
             String policyJson = TcaRequestFormatter.createPolicyJson(refProp, prop);
-
             try {
                 policyClient.sendMicroServiceInJson(policyJson, prop, tcaPolicyRequestUuid);
             } catch (Exception e) {
@@ -102,7 +100,6 @@ public class PolicyClientItCase extends AbstractItCase {
 
     private void deleteOperationalPolicy(String actionCd) throws Exception {
         ModelProperties prop = new ModelProperties(modelName, controlName, actionCd, false, modelBpmnProp, modelProp);
-
         Policy policy = prop.getType(Policy.class);
         if (policy.isFound()) {
             prop.setCurrentModelElementId(policy.getId());
@@ -115,11 +112,9 @@ public class PolicyClientItCase extends AbstractItCase {
 
     private void deleteTcaPolicy(String actionCd) throws Exception {
         ModelProperties prop = new ModelProperties(modelName, controlName, actionCd, false, modelBpmnProp, modelProp);
-
         Tca tca = prop.getType(Tca.class);
         if (tca.isFound()) {
             prop.setCurrentModelElementId(tca.getId());
-
             try {
                 policyClient.deleteMicrosService(prop);
             } catch (Exception e) {
@@ -133,21 +128,15 @@ public class PolicyClientItCase extends AbstractItCase {
      * Temporarily disabled Test.
      */
     public void testCreateUpdateDeleteOperationalPolicy() throws Exception {
-
         createUpdateOperationalPolicy(CldsEvent.ACTION_SUBMIT);
-
         TimeUnit.SECONDS.sleep(20);
-
         deleteOperationalPolicy(CldsEvent.ACTION_DELETE);
     }
 
     @Test
     public void testCreateUpdateDeleteTcaPolicy() throws Exception {
-
         createUpdateTcaPolicy(CldsEvent.ACTION_SUBMIT);
-
         TimeUnit.SECONDS.sleep(20);
-
         deleteTcaPolicy(CldsEvent.ACTION_DELETE);
     }
 }
index 478a7b3..7ccda5a 100644 (file)
@@ -23,6 +23,8 @@
 
 package org.onap.clamp.clds.it;
 
+import com.att.eelf.configuration.EELFLogger;
+import com.att.eelf.configuration.EELFManager;
 import com.fasterxml.jackson.databind.ObjectMapper;
 import com.fasterxml.jackson.databind.node.ObjectNode;
 
@@ -42,6 +44,7 @@ import org.springframework.test.context.junit4.SpringRunner;
 @SpringBootTest
 @TestPropertySource(locations = "classpath:application-no-camunda.properties")
 public class RefPropItCase extends AbstractItCase {
+    protected static final EELFLogger logger = EELFManager.getInstance().getLogger(RefPropItCase.class);
 
     /**
      * Test getting prop value as a JSON Node / template.
@@ -53,12 +56,9 @@ public class RefPropItCase extends AbstractItCase {
     public void testJsonTemplate() throws IOException {
         ObjectNode root = (ObjectNode) refProp.getJsonTemplate("tca.template");
         root.put("closedLoopControlName", "ClosedLoop-FRWL-SIG-1582f840-2881-11e6-b4ec-005056a9d756");
-
         ObjectMapper mapper = new ObjectMapper();
         String jsonText = mapper.writeValueAsString(root);
-        System.out.println("jsonText=" + jsonText);
-
+        logger.error("Exception caught IllegalArgumentException as expected");
         // assertEquals(topicsJson, ref.getTopicsToJson());
     }
-
 }
index b684a50..5d3b770 100644 (file)
@@ -33,7 +33,7 @@ import org.junit.Test;
 import org.junit.runner.RunWith;
 import org.mockito.Mockito;
 import org.onap.clamp.clds.AbstractItCase;
-import org.onap.clamp.clds.client.SdcCatalogServices;
+import org.onap.clamp.clds.client.req.sdc.SdcCatalogServices;
 import org.onap.clamp.clds.model.CldsAlarmCondition;
 import org.onap.clamp.clds.model.CldsSdcResource;
 import org.onap.clamp.clds.model.CldsSdcResourceBasicInfo;
index faff284..757d85b 100644 (file)
@@ -30,12 +30,13 @@ import java.security.GeneralSecurityException;
 import java.util.ArrayList;
 import java.util.List;
 
+import org.apache.commons.codec.DecoderException;
 import org.camunda.bpm.engine.delegate.DelegateExecution;
 import org.junit.Assert;
 import org.junit.Test;
 import org.junit.runner.RunWith;
-import org.onap.clamp.clds.client.SdcCatalogServices;
-import org.onap.clamp.clds.client.req.SdcReq;
+import org.onap.clamp.clds.client.req.sdc.SdcCatalogServices;
+import org.onap.clamp.clds.client.req.sdc.SdcReq;
 import org.onap.clamp.clds.model.CldsSdcResource;
 import org.onap.clamp.clds.model.CldsSdcServiceDetail;
 import org.onap.clamp.clds.model.prop.Global;
@@ -55,7 +56,7 @@ public class SdcReqItCase {
     private SdcReq sdcReq;
 
     @Test
-    public void getSdcReqUrlsListNoGlobalPropTest() throws GeneralSecurityException {
+    public void getSdcReqUrlsListNoGlobalPropTest() throws GeneralSecurityException, DecoderException {
         ModelProperties prop = mock(ModelProperties.class);
         SdcCatalogServices sdcCatalogServices = mock(SdcCatalogServices.class);
         DelegateExecution delegateExecution = mock(DelegateExecution.class);
index a32743a..ccbcb0e 100644 (file)
@@ -32,7 +32,7 @@ import org.junit.Before;
 import org.junit.Test;
 import org.junit.runner.RunWith;
 import org.onap.clamp.clds.AbstractItCase;
-import org.onap.clamp.clds.client.req.TcaRequestFormatter;
+import org.onap.clamp.clds.client.req.tca.TcaRequestFormatter;
 import org.onap.clamp.clds.model.CldsEvent;
 import org.onap.clamp.clds.model.prop.ModelProperties;
 import org.onap.clamp.clds.util.ResourceFileUtil;