Introduce tosca saving
[clamp.git] / src / main / java / org / onap / clamp / clds / service / CldsService.java
index c0ff83c..521f3ce 100644 (file)
@@ -34,21 +34,12 @@ import java.io.IOException;
 import java.security.GeneralSecurityException;
 import java.util.Date;
 import java.util.List;
+import java.util.Optional;
 import java.util.UUID;
 
+import javax.servlet.http.HttpServletRequest;
 import javax.ws.rs.BadRequestException;
-import javax.ws.rs.Consumes;
-import javax.ws.rs.DefaultValue;
-import javax.ws.rs.GET;
 import javax.ws.rs.NotAuthorizedException;
-import javax.ws.rs.POST;
-import javax.ws.rs.PUT;
-import javax.ws.rs.Path;
-import javax.ws.rs.PathParam;
-import javax.ws.rs.Produces;
-import javax.ws.rs.QueryParam;
-import javax.ws.rs.core.MediaType;
-import javax.ws.rs.core.Response;
 import javax.xml.transform.TransformerException;
 
 import org.apache.camel.Produce;
@@ -66,7 +57,6 @@ import org.onap.clamp.clds.exception.policy.PolicyClientException;
 import org.onap.clamp.clds.exception.sdc.SdcCommunicationException;
 import org.onap.clamp.clds.model.CldsDbServiceCache;
 import org.onap.clamp.clds.model.CldsEvent;
-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.CldsModelProp;
@@ -84,9 +74,12 @@ import org.onap.clamp.clds.sdc.controller.installer.CsarInstallerImpl;
 import org.onap.clamp.clds.transform.XslTransformer;
 import org.onap.clamp.clds.util.JacksonUtils;
 import org.onap.clamp.clds.util.LoggingUtils;
+import org.onap.clamp.clds.util.ONAPLogConstants;
+import org.slf4j.event.Level;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.beans.factory.annotation.Value;
 import org.springframework.http.HttpStatus;
+import org.springframework.http.ResponseEntity;
 import org.springframework.stereotype.Component;
 import org.springframework.web.client.HttpClientErrorException;
 
@@ -94,13 +87,13 @@ import org.springframework.web.client.HttpClientErrorException;
  * Service to save and retrieve the CLDS model attributes.
  */
 @Component
-@Path("/clds")
 public class CldsService extends SecureServiceBase {
 
     @Produce(uri = "direct:processSubmit")
     private CamelProxy camelProxy;
     protected static final EELFLogger securityLogger = EELFManager.getInstance().getSecurityLogger();
-    static final String RESOURCE_NAME = "clds-version.properties";
+    protected static final EELFLogger logger = EELFManager.getInstance().getLogger(CldsService.class);
+
     public static final String GLOBAL_PROPERTIES_KEY = "files.globalProperties";
     private final String cldsPersmissionTypeCl;
     private final String cldsPermissionTypeClManage;
@@ -112,6 +105,8 @@ public class CldsService extends SecureServiceBase {
     final SecureServicePermission permissionUpdateCl;
     final SecureServicePermission permissionReadTemplate;
     final SecureServicePermission permissionUpdateTemplate;
+    final SecureServicePermission permissionReadTosca;
+    final SecureServicePermission permissionUpdateTosca;
 
     private final CldsDao cldsDao;
     private final XslTransformer cldsBpmnTransformer;
@@ -119,7 +114,10 @@ public class CldsService extends SecureServiceBase {
     private final SdcCatalogServices sdcCatalogServices;
     private final DcaeDispatcherServices dcaeDispatcherServices;
     private final DcaeInventoryServices dcaeInventoryServices;
+    private LoggingUtils util = new LoggingUtils(logger);
 
+    @Autowired
+    private HttpServletRequest request;
     @Autowired
     public CldsService(CldsDao cldsDao, XslTransformer cldsBpmnTransformer, ClampProperties refProp,
         SdcCatalogServices sdcCatalogServices, DcaeDispatcherServices dcaeDispatcherServices,
@@ -129,6 +127,7 @@ public class CldsService extends SecureServiceBase {
         @Value("${clamp.config.security.permission.type.cl.event:permission-type-cl-event}") String cldsPermissionTypeClEvent,
         @Value("${clamp.config.security.permission.type.filter.vf:permission-type-filter-vf}") String cldsPermissionTypeFilterVf,
         @Value("${clamp.config.security.permission.type.template:permission-type-template}") String cldsPermissionTypeTemplate,
+            @Value("${clamp.config.security.permission.type.tosca:permission-type-tosca}") String cldsPermissionTypeTosca,
         @Value("${clamp.config.security.permission.instance:dev}") String cldsPermissionInstance) {
         this.cldsDao = cldsDao;
         this.cldsBpmnTransformer = cldsBpmnTransformer;
@@ -148,6 +147,9 @@ public class CldsService extends SecureServiceBase {
             "read");
         permissionUpdateTemplate = SecureServicePermission.create(cldsPermissionTypeTemplate, cldsPermissionInstance,
             "update");
+        permissionReadTosca = SecureServicePermission.create(cldsPermissionTypeTosca, cldsPermissionInstance, "read");
+        permissionUpdateTosca = SecureServicePermission.create(cldsPermissionTypeTosca, cldsPermissionInstance,
+                "update");
     }
 
     /*
@@ -160,17 +162,14 @@ public class CldsService extends SecureServiceBase {
      * used to generate the ClosedLoop model. ACTION_CD | Current state of the
      * ClosedLoop in CLDS application.
      */
-    @GET
-    @Path("/cldsDetails")
-    @Produces(MediaType.APPLICATION_JSON)
     public List<CldsMonitoringDetails> getCLDSDetails() {
+        util.entering(request, "CldsService: GET model details");
         Date startTime = new Date();
-        LoggingUtils.setRequestContext("CldsService: GET model details", getPrincipalName());
         List<CldsMonitoringDetails> cldsMonitoringDetailsList = cldsDao.getCLDSMonitoringDetails();
         // audit log
         LoggingUtils.setTimeContext(startTime, new Date());
-        LoggingUtils.setResponseContext("0", "Get cldsDetails success", this.getClass().getName());
         auditLogger.info("GET cldsDetails completed");
+        util.exiting("200", "Get cldsDetails success", Level.INFO, ONAPLogConstants.ResponseStatus.COMPLETED);
         return cldsMonitoringDetailsList;
     }
 
@@ -178,12 +177,9 @@ public class CldsService extends SecureServiceBase {
      * CLDS IFO service will return 3 things 1. User Name 2. CLDS code version that
      * is currently installed from pom.xml file 3. User permissions
      */
-    @GET
-    @Path("/cldsInfo")
-    @Produces(MediaType.APPLICATION_JSON)
     public CldsInfo getCldsInfo() {
+        util.entering(request, "CldsService: GET cldsInfo");
         Date startTime = new Date();
-        LoggingUtils.setRequestContext("CldsService: GET cldsInfo", getPrincipalName());
         LoggingUtils.setTimeContext(startTime, new Date());
 
         CldsInfoProvider cldsInfoProvider = new CldsInfoProvider(this);
@@ -191,49 +187,11 @@ public class CldsService extends SecureServiceBase {
 
         // audit log
         LoggingUtils.setTimeContext(startTime, new Date());
-        LoggingUtils.setResponseContext("0", "Get cldsInfo success", this.getClass().getName());
         securityLogger.info("GET cldsInfo completed");
+        util.exiting("200", "Get cldsInfo success", Level.INFO, ONAPLogConstants.ResponseStatus.COMPLETED);
         return cldsInfo;
     }
 
-    /**
-     * REST service that retrieves clds healthcheck information.
-     *
-     * @return CldsHealthCheck class containing healthcheck info
-     */
-    @GET
-    @Path("/healthcheck")
-    @Produces(MediaType.APPLICATION_JSON)
-    public Response gethealthcheck() {
-        CldsHealthCheck cldsHealthCheck = new CldsHealthCheck();
-        Date startTime = new Date();
-        LoggingUtils.setRequestContext("CldsService: GET healthcheck", "Clamp-Health-Check");
-        LoggingUtils.setTimeContext(startTime, new Date());
-        boolean healthcheckFailed = false;
-        try {
-            cldsDao.doHealthCheck();
-            cldsHealthCheck.setHealthCheckComponent("CLDS-APP");
-            cldsHealthCheck.setHealthCheckStatus("UP");
-            cldsHealthCheck.setDescription("OK");
-            LoggingUtils.setResponseContext("0", "Get healthcheck success", this.getClass().getName());
-        } catch (Exception e) {
-            healthcheckFailed = true;
-            logger.error("CLAMP application DB Error", e);
-            LoggingUtils.setResponseContext("999", "Get healthcheck failed", this.getClass().getName());
-            cldsHealthCheck.setHealthCheckComponent("CLDS-APP");
-            cldsHealthCheck.setHealthCheckStatus("DOWN");
-            cldsHealthCheck.setDescription("NOT-OK");
-        }
-        // audit log
-        LoggingUtils.setTimeContext(startTime, new Date());
-        logger.info("GET healthcheck completed");
-        if (healthcheckFailed) {
-            return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(cldsHealthCheck).build();
-        } else {
-            return Response.status(Response.Status.OK).entity(cldsHealthCheck).build();
-        }
-    }
-
     /**
      * REST service that retrieves BPMN for a CLDS model name from the database.
      * This is subset of the json getModel. This is only expected to be used for
@@ -242,19 +200,16 @@ public class CldsService extends SecureServiceBase {
      * @param modelName
      * @return bpmn xml text - content of bpmn given name
      */
-    @GET
-    @Path("/model/bpmn/{modelName}")
-    @Produces(MediaType.TEXT_XML)
-    public String getBpmnXml(@PathParam("modelName") String modelName) {
+    public String getBpmnXml(String modelName) {
+        util.entering(request, "CldsService: GET model bpmn");
         Date startTime = new Date();
-        LoggingUtils.setRequestContext("CldsService: GET model bpmn", getPrincipalName());
         isAuthorized(permissionReadCl);
         logger.info("GET bpmnText for modelName={}", modelName);
         CldsModel model = CldsModel.retrieve(cldsDao, modelName, false);
         // audit log
         LoggingUtils.setTimeContext(startTime, new Date());
-        LoggingUtils.setResponseContext("0", "Get model bpmn success", this.getClass().getName());
         auditLogger.info("GET model bpmn completed");
+        util.exiting("200", "Get model bpmn success", Level.INFO, ONAPLogConstants.ResponseStatus.COMPLETED);
         return model.getBpmnText();
     }
 
@@ -266,19 +221,16 @@ public class CldsService extends SecureServiceBase {
      * @param modelName
      * @return image xml text - content of image given name
      */
-    @GET
-    @Path("/model/image/{modelName}")
-    @Produces(MediaType.TEXT_XML)
-    public String getImageXml(@PathParam("modelName") String modelName) {
+    public String getImageXml(String modelName) {
+       util.entering(request, "CldsService: GET model image");
         Date startTime = new Date();
-        LoggingUtils.setRequestContext("CldsService: GET model image", getPrincipalName());
         isAuthorized(permissionReadCl);
         logger.info("GET imageText for modelName={}", modelName);
         CldsModel model = CldsModel.retrieve(cldsDao, modelName, false);
         // audit log
         LoggingUtils.setTimeContext(startTime, new Date());
-        LoggingUtils.setResponseContext("0", "Get model image success", this.getClass().getName());
         auditLogger.info("GET model image completed");
+        util.exiting("200", "Get model image success", Level.INFO, ONAPLogConstants.ResponseStatus.COMPLETED);
         return model.getImageText();
     }
 
@@ -288,12 +240,9 @@ public class CldsService extends SecureServiceBase {
      * @param modelName
      * @return clds model - clds model for the given model name
      */
-    @GET
-    @Path("/model/{modelName}")
-    @Produces(MediaType.APPLICATION_JSON)
-    public CldsModel getModel(@PathParam("modelName") String modelName) {
+    public CldsModel getModel(String modelName) {
+       util.entering(request, "CldsService: GET model");
         Date startTime = new Date();
-        LoggingUtils.setRequestContext("CldsService: GET model", getPrincipalName());
         isAuthorized(permissionReadCl);
         logger.debug("GET model for  modelName={}", modelName);
         CldsModel cldsModel = CldsModel.retrieve(cldsDao, modelName, false);
@@ -310,8 +259,8 @@ public class CldsService extends SecureServiceBase {
         }
         // audit log
         LoggingUtils.setTimeContext(startTime, new Date());
-        LoggingUtils.setResponseContext("0", "Get model success", this.getClass().getName());
         auditLogger.info("GET model completed");
+        util.exiting("200", "Get model success", Level.INFO, ONAPLogConstants.ResponseStatus.COMPLETED);
         return cldsModel;
     }
 
@@ -320,13 +269,9 @@ public class CldsService extends SecureServiceBase {
      *
      * @param modelName
      */
-    @PUT
-    @Path("/model/{modelName}")
-    @Consumes(MediaType.APPLICATION_JSON)
-    @Produces(MediaType.APPLICATION_JSON)
-    public CldsModel putModel(@PathParam("modelName") String modelName, CldsModel cldsModel) {
+    public CldsModel putModel(String modelName, CldsModel cldsModel) {
+       util.entering(request, "CldsService: PUT model");
         Date startTime = new Date();
-        LoggingUtils.setRequestContext("CldsService: PUT model", getPrincipalName());
         isAuthorized(permissionUpdateCl);
         isAuthorizedForVf(cldsModel);
         logger.info("PUT model for  modelName={}", modelName);
@@ -340,8 +285,8 @@ public class CldsService extends SecureServiceBase {
         cldsModel.save(cldsDao, getUserId());
         // audit log
         LoggingUtils.setTimeContext(startTime, new Date());
-        LoggingUtils.setResponseContext("0", "Put model success", this.getClass().getName());
         auditLogger.info("PUT model completed");
+        util.exiting("200", "Put model success", Level.INFO, ONAPLogConstants.ResponseStatus.COMPLETED);
         return cldsModel;
     }
 
@@ -350,19 +295,16 @@ public class CldsService extends SecureServiceBase {
      *
      * @return model names in JSON
      */
-    @GET
-    @Path("/model-names")
-    @Produces(MediaType.APPLICATION_JSON)
     public List<ValueItem> getModelNames() {
+        util.entering(request, "CldsService: GET model names");
         Date startTime = new Date();
-        LoggingUtils.setRequestContext("CldsService: GET model names", getPrincipalName());
         isAuthorized(permissionReadCl);
         logger.info("GET list of model names");
         List<ValueItem> names = cldsDao.getBpmnNames();
         // audit log
         LoggingUtils.setTimeContext(startTime, new Date());
-        LoggingUtils.setResponseContext("0", "Get model names success", this.getClass().getName());
         auditLogger.info("GET model names completed");
+        util.exiting("200", "Get model names success", Level.INFO, ONAPLogConstants.ResponseStatus.COMPLETED);
         return names;
     }
 
@@ -397,18 +339,14 @@ public class CldsService extends SecureServiceBase {
      * @throws DecoderException
      *         In case of issues with the Hex String decoding
      */
-    @PUT
-    @Path("/action/{action}/{modelName}")
-    @Consumes(MediaType.APPLICATION_JSON)
-    @Produces(MediaType.APPLICATION_JSON)
-    public Response putModelAndProcessAction(@PathParam("action") String action,
-        @PathParam("modelName") String modelName, @QueryParam("test") String validateFlag, CldsModel model)
+    public ResponseEntity<?> putModelAndProcessAction(String action,
+        String modelName,String test, CldsModel model)
             throws TransformerException, ParseException {
+        util.entering(request, "CldsService: Process model action");
         Date startTime = new Date();
         CldsModel retrievedModel = null;
         Boolean errorCase = false;
         try {
-            LoggingUtils.setRequestContext("CldsService: Process model action", getPrincipalName());
             String actionCd = action.toUpperCase();
             SecureServicePermission permisionManage = SecureServicePermission.create(cldsPermissionTypeClManage,
                 cldsPermissionInstance, actionCd);
@@ -417,7 +355,7 @@ public class CldsService extends SecureServiceBase {
             String userId = getUserId();
             logger.info("PUT actionCd={}", actionCd);
             logger.info("PUT modelName={}", modelName);
-            logger.info("PUT test={}", validateFlag);
+            logger.info("PUT test={}", test);
             logger.info("PUT bpmnText={}", model.getBpmnText());
             logger.info("PUT propText={}", model.getPropText());
             logger.info("PUT userId={}", userId);
@@ -438,7 +376,7 @@ public class CldsService extends SecureServiceBase {
             // Flag indicates whether it is triggered by Validation Test button
             // from
             // UI
-            boolean isTest = Boolean.valueOf(validateFlag);
+            boolean isTest = Boolean.valueOf(test);
             if (!isTest) {
                 String actionTestOverride = refProp.getStringValue("action.test.override");
                 if (Boolean.valueOf(actionTestOverride)) {
@@ -468,38 +406,45 @@ public class CldsService extends SecureServiceBase {
                 // refresh model info from db (get fresh event info)
                 retrievedModel = CldsModel.retrieve(cldsDao, modelName, false);
             }
-            if (!isTest && (actionCd.equalsIgnoreCase(CldsEvent.ACTION_SUBMIT)
-                || actionCd.equalsIgnoreCase(CldsEvent.ACTION_RESUBMIT)
-                || actionCd.equalsIgnoreCase(CldsEvent.ACTION_SUBMITDCAE))) {
-                if (retrievedModel.getTemplateName().startsWith(CsarInstallerImpl.TEMPLATE_NAME_PREFIX)) {
-                    // SDC artifact case
-                    logger.info("Skipping DCAE inventory call as closed loop has been created from SDC notification");
-                    DcaeEvent dcaeEvent = new DcaeEvent();
-                    dcaeEvent.setArtifactName(retrievedModel.getControlName() + ".yml");
-                    dcaeEvent.setEvent(DcaeEvent.EVENT_DISTRIBUTION);
-                    CldsEvent.insEvent(cldsDao, dcaeEvent.getControlName(), userId, dcaeEvent.getCldsActionCd(),
-                        CldsEvent.ACTION_STATE_RECEIVED, null);
-                } else {
-                    // This should be done only when the call to DCAE
-                    // has not yet been done. When CL comes from SDC
-                    // this is not required as the DCAE inventory call is done
-                    // during the CL deployment.
-                    dcaeInventoryServices.setEventInventory(retrievedModel, getUserId());
+            if (retrievedModel != null) {
+                if (!isTest && !errorCase && (actionCd.equalsIgnoreCase(CldsEvent.ACTION_SUBMIT)
+                    || actionCd.equalsIgnoreCase(CldsEvent.ACTION_RESUBMIT)
+                    || actionCd.equalsIgnoreCase(CldsEvent.ACTION_SUBMITDCAE))) {
+                    if (retrievedModel.getTemplateName().startsWith(CsarInstallerImpl.TEMPLATE_NAME_PREFIX)) {
+                        // SDC artifact case
+                        logger.info("Skipping DCAE inventory call as closed loop has been created from SDC notification");
+                        DcaeEvent dcaeEvent = new DcaeEvent();
+                        dcaeEvent.setArtifactName(retrievedModel.getControlName() + ".yml");
+                        dcaeEvent.setEvent(DcaeEvent.EVENT_DISTRIBUTION);
+                        CldsEvent.insEvent(cldsDao, dcaeEvent.getControlName(), userId, dcaeEvent.getCldsActionCd(),
+                            CldsEvent.ACTION_STATE_RECEIVED, null);
+                    } else {
+                        // This should be done only when the call to DCAE
+                        // has not yet been done. When CL comes from SDC
+                        // this is not required as the DCAE inventory call is done
+                        // during the CL deployment.
+                        dcaeInventoryServices.setEventInventory(retrievedModel, getUserId());
+                    }
+                    retrievedModel.save(cldsDao, getUserId());
                 }
-                retrievedModel.save(cldsDao, getUserId());
+                // audit log
+                LoggingUtils.setTimeContext(startTime, new Date());
+                auditLogger.info("Process model action completed");
+            } else {
+                logger.error("CldsModel not found in database with modelName: " + modelName);
+                util.exiting(HttpStatus.INTERNAL_SERVER_ERROR.toString(), "CldsModel not found in database with modelName " + "modelName", Level.INFO, ONAPLogConstants.ResponseStatus.ERROR);
+                return new ResponseEntity<String>("CldsModel not found in database with modelName: \" + modelName", HttpStatus.INTERNAL_SERVER_ERROR);
             }
-            // audit log
-            LoggingUtils.setTimeContext(startTime, new Date());
-            LoggingUtils.setResponseContext("0", "Process model action success", this.getClass().getName());
-            auditLogger.info("Process model action completed");
         } catch (Exception e) {
             errorCase = true;
             logger.error("Exception occured during putModelAndProcessAction", e);
         }
         if (errorCase) {
-            return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(retrievedModel).build();
+            util.exiting(HttpStatus.INTERNAL_SERVER_ERROR.toString(), "putModelAndProcessAction failed", Level.INFO, ONAPLogConstants.ResponseStatus.ERROR);
+            return new ResponseEntity<>(retrievedModel, HttpStatus.INTERNAL_SERVER_ERROR);
         }
-        return Response.status(Response.Status.OK).entity(retrievedModel).build();
+        util.exiting(HttpStatus.OK.toString(), "Successful", Level.INFO, ONAPLogConstants.ResponseStatus.COMPLETED);
+        return new ResponseEntity<>(retrievedModel, HttpStatus.OK);
     }
 
     /**
@@ -508,13 +453,9 @@ public class CldsService extends SecureServiceBase {
      * @param test
      * @param dcaeEvent
      */
-    @POST
-    @Path("/dcae/event")
-    @Consumes(MediaType.APPLICATION_JSON)
-    @Produces(MediaType.APPLICATION_JSON)
-    public String postDcaeEvent(@QueryParam("test") String test, DcaeEvent dcaeEvent) {
+    public String postDcaeEvent(String test, DcaeEvent dcaeEvent) {
+        util.entering(request, "CldsService: Post dcae event");
         Date startTime = new Date();
-        LoggingUtils.setRequestContext("CldsService: Post dcae event", getPrincipalName());
         String userid = null;
         // TODO: allow auth checking to be turned off by removing the permission
         // type property
@@ -547,8 +488,8 @@ public class CldsService extends SecureServiceBase {
         }
         // audit log
         LoggingUtils.setTimeContext(startTime, new Date());
-        LoggingUtils.setResponseContext("0", "Post dcae event success", this.getClass().getName());
         auditLogger.info("Post dcae event completed");
+        util.exiting("200", "Post dcae event success", Level.INFO, ONAPLogConstants.ResponseStatus.COMPLETED);
         return msgInfo;
     }
 
@@ -560,12 +501,9 @@ public class CldsService extends SecureServiceBase {
      * @throws DecoderException
      *         In case of issues with the decoding of the Hex String
      */
-    @GET
-    @Path("/sdc/services")
-    @Produces(MediaType.APPLICATION_JSON)
     public String getSdcServices() throws GeneralSecurityException, DecoderException {
+        util.entering(request, "CldsService: GET sdc services");
         Date startTime = new Date();
-        LoggingUtils.setRequestContext("CldsService: GET sdc services", getPrincipalName());
         String retStr;
         try {
             retStr = createUiServiceFormatJson(sdcCatalogServices.getSdcServicesInformation(null));
@@ -576,8 +514,8 @@ public class CldsService extends SecureServiceBase {
         logger.info("value of sdcServices : {}", retStr);
         // audit log
         LoggingUtils.setTimeContext(startTime, new Date());
-        LoggingUtils.setResponseContext("0", "Get sdc services success", this.getClass().getName());
         auditLogger.info("GET sdc services completed");
+        util.exiting("200", "Get sdc services success", Level.INFO, ONAPLogConstants.ResponseStatus.COMPLETED);
         return retStr;
     }
 
@@ -587,9 +525,6 @@ public class CldsService extends SecureServiceBase {
      * @throws IOException
      *         In case of issues
      */
-    @GET
-    @Path("/properties")
-    @Produces(MediaType.APPLICATION_JSON)
     public String getSdcProperties() throws IOException {
         return createPropertiesObjectByUUID("{}");
     }
@@ -605,18 +540,14 @@ public class CldsService extends SecureServiceBase {
      * @throws IOException
      *         In case of issue to convert CldsServiceCache to InputStream
      */
-    @GET
-    @Path("/properties/{serviceInvariantUUID}")
-    @Produces(MediaType.APPLICATION_JSON)
     public String getSdcPropertiesByServiceUUIDForRefresh(
-        @PathParam("serviceInvariantUUID") String serviceInvariantUUID,
-        @DefaultValue("false") @QueryParam("refresh") boolean refresh)
+        String serviceInvariantUUID, Boolean refresh)
             throws GeneralSecurityException, DecoderException, IOException {
+        util.entering(request, "CldsService: GET sdc properties by uuid");
         Date startTime = new Date();
-        LoggingUtils.setRequestContext("CldsService: GET sdc properties by uuid", getPrincipalName());
         CldsServiceData cldsServiceData = new CldsServiceData();
         cldsServiceData.setServiceInvariantUUID(serviceInvariantUUID);
-        if (!refresh) {
+        if (!Optional.ofNullable(refresh).orElse(false)) {
             cldsServiceData = cldsDao.getCldsServiceCache(serviceInvariantUUID);
         }
         if (sdcCatalogServices.isCldsSdcCacheDataExpired(cldsServiceData)) {
@@ -629,8 +560,8 @@ public class CldsService extends SecureServiceBase {
         String sdcProperties = sdcCatalogServices.createPropertiesObjectByUUID(cldsServiceData);
         // audit log
         LoggingUtils.setTimeContext(startTime, new Date());
-        LoggingUtils.setResponseContext("0", "Get sdc properties by uuid success", this.getClass().getName());
         auditLogger.info("GET sdc properties by uuid completed");
+        util.exiting("200", "Get sdc properties by uuid success", Level.INFO, ONAPLogConstants.ResponseStatus.COMPLETED);
         return sdcProperties;
     }
 
@@ -803,13 +734,9 @@ public class CldsService extends SecureServiceBase {
         return emptyvfcobjectNode;
     }
 
-    @PUT
-    @Path("/deploy/{modelName}")
-    @Consumes(MediaType.APPLICATION_JSON)
-    @Produces(MediaType.APPLICATION_JSON)
-    public Response deployModel(@PathParam("modelName") String modelName, CldsModel model) {
+    public ResponseEntity<CldsModel> deployModel(String modelName, CldsModel model) {
+        util.entering(request, "CldsService: Deploy model");
         Date startTime = new Date();
-        LoggingUtils.setRequestContext("CldsService: Deploy model", getPrincipalName());
         Boolean errorCase = false;
         try {
             fillInCldsModel(model);
@@ -847,31 +774,29 @@ public class CldsService extends SecureServiceBase {
                 model.save(cldsDao, getUserId());
             } else {
                 logger.info("Deploy model (" + modelName + ") failed...Operation Status is - " + operationStatus);
+                util.exiting(HttpStatus.INTERNAL_SERVER_ERROR.toString(), "DeployModel failed", Level.INFO, ONAPLogConstants.ResponseStatus.ERROR);
                 throw new HttpClientErrorException(HttpStatus.INTERNAL_SERVER_ERROR,
                     "Deploy model (" + modelName + ") failed...Operation Status is - " + operationStatus);
             }
             logger.info("Deploy model (" + modelName + ") succeeded...Deployment Id is - " + deploymentId);
             // audit log
             LoggingUtils.setTimeContext(startTime, new Date());
-            LoggingUtils.setResponseContext("0", "Deploy model success", this.getClass().getName());
             auditLogger.info("Deploy model completed");
         } catch (Exception e) {
             errorCase = true;
             logger.error("Exception occured during deployModel", e);
         }
         if (errorCase) {
-            return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(model).build();
+               util.exiting(HttpStatus.INTERNAL_SERVER_ERROR.toString(), "DeployModel failed", Level.INFO, ONAPLogConstants.ResponseStatus.ERROR);
+            return new ResponseEntity<>(model, HttpStatus.INTERNAL_SERVER_ERROR);
         }
-        return Response.status(Response.Status.OK).entity(model).build();
+        util.exiting(HttpStatus.OK.toString(), "Successful", Level.INFO, ONAPLogConstants.ResponseStatus.COMPLETED);
+        return new ResponseEntity<>(model, HttpStatus.OK);
     }
 
-    @PUT
-    @Path("/undeploy/{modelName}")
-    @Consumes(MediaType.APPLICATION_JSON)
-    @Produces(MediaType.APPLICATION_JSON)
-    public Response unDeployModel(@PathParam("modelName") String modelName, CldsModel model) {
+    public ResponseEntity<CldsModel> unDeployModel(String modelName, CldsModel model) {
+        util.entering(request, "CldsService: Undeploy model");
         Date startTime = new Date();
-        LoggingUtils.setRequestContext("CldsService: Undeploy model", getPrincipalName());
         Boolean errorCase = false;
         try {
             SecureServicePermission permisionManage = SecureServicePermission.create(cldsPermissionTypeClManage,
@@ -896,22 +821,24 @@ public class CldsService extends SecureServiceBase {
                 model.save(cldsDao, getUserId());
             } else {
                 logger.info("Undeploy model (" + modelName + ") failed...Operation Status is - " + operationStatus);
+                util.exiting(HttpStatus.INTERNAL_SERVER_ERROR.toString(), "UndeployModel failed", Level.INFO, ONAPLogConstants.ResponseStatus.ERROR);
                 throw new HttpClientErrorException(HttpStatus.INTERNAL_SERVER_ERROR,
                     "Undeploy model (" + modelName + ") failed...Operation Status is - " + operationStatus);
             }
             logger.info("Undeploy model (" + modelName + ") succeeded.");
             // audit log
             LoggingUtils.setTimeContext(startTime, new Date());
-            LoggingUtils.setResponseContext("0", "Undeploy model success", this.getClass().getName());
             auditLogger.info("Undeploy model completed");
         } catch (Exception e) {
             errorCase = true;
             logger.error("Exception occured during unDeployModel", e);
         }
         if (errorCase) {
-            return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(model).build();
+            util.exiting(HttpStatus.INTERNAL_SERVER_ERROR.toString(), "UndeployModel failed", Level.INFO, ONAPLogConstants.ResponseStatus.ERROR);
+            return new ResponseEntity<>(model, HttpStatus.INTERNAL_SERVER_ERROR);
         }
-        return Response.status(Response.Status.OK).entity(model).build();
+        util.exiting(HttpStatus.OK.toString(), "Successful", Level.INFO, ONAPLogConstants.ResponseStatus.COMPLETED);
+        return new ResponseEntity<>(model, HttpStatus.OK);
     }
 
     private void checkForDuplicateServiceVf(String modelName, String modelPropText) throws IOException {
@@ -950,4 +877,9 @@ public class CldsService extends SecureServiceBase {
             cldsDao.insEvent(cldsModelName, cldsControlNamePrfx, null, newEvent);
         }
     }
+
+    // Created for the integration test
+    public void setLoggingUtil (LoggingUtils utilP) {
+        util =  utilP;
+    }
 }
\ No newline at end of file