Introduce tosca saving

Introduce tosca saving for generic Config policy + rest apis

Issue-ID: CLAMP-214
Signed-off-by: sebdet <sd378r@intl.att.com>
Change-Id: I34431d256b195071ea6f7581fc20aff9a6b9aaf7
diff --git a/src/main/java/org/onap/clamp/clds/dao/CldsDao.java b/src/main/java/org/onap/clamp/clds/dao/CldsDao.java
index a3771aa..bdb8e4b 100644
--- a/src/main/java/org/onap/clamp/clds/dao/CldsDao.java
+++ b/src/main/java/org/onap/clamp/clds/dao/CldsDao.java
@@ -18,7 +18,7 @@
  * limitations under the License.
  * ============LICENSE_END============================================
  * ===================================================================
- * 
+ *
  */
 
 package org.onap.clamp.clds.dao;
@@ -32,10 +32,13 @@
 import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
+import java.util.stream.Collectors;
 
 import javax.sql.DataSource;
 
 import org.onap.clamp.clds.model.CldsDbServiceCache;
+import org.onap.clamp.clds.model.CldsDictionary;
+import org.onap.clamp.clds.model.CldsDictionaryItem;
 import org.onap.clamp.clds.model.CldsEvent;
 import org.onap.clamp.clds.model.CldsModel;
 import org.onap.clamp.clds.model.CldsModelInstance;
@@ -43,6 +46,9 @@
 import org.onap.clamp.clds.model.CldsMonitoringDetails;
 import org.onap.clamp.clds.model.CldsServiceData;
 import org.onap.clamp.clds.model.CldsTemplate;
+import org.onap.clamp.clds.model.CldsToscaModel;
+import org.onap.clamp.clds.model.CldsToscaModelDetails;
+import org.onap.clamp.clds.model.CldsToscaModelRevision;
 import org.onap.clamp.clds.model.ValueItem;
 import org.springframework.dao.EmptyResultDataAccessException;
 import org.springframework.jdbc.core.JdbcTemplate;
@@ -72,7 +78,13 @@
     private static final String HEALTHCHECK = "Select 1";
     private static final String V_CONTROL_NAME_PREFIX = "v_control_name_prefix";
     private static final String V_CONTROL_NAME_UUID = "v_control_name_uuid";
-   
+
+    private SimpleJdbcCall procInsertToscaModel;
+    private SimpleJdbcCall procInsertNewToscaModelVersion;
+    private SimpleJdbcCall procInsertDictionary;
+    private SimpleJdbcCall procInsertDictionaryElement;
+
+
     /**
      * Log message when instantiating
      */
@@ -95,6 +107,10 @@
         this.procInsModelInstance = new SimpleJdbcCall(dataSource).withProcedureName("ins_model_instance");
         this.procDelAllModelInstances = new SimpleJdbcCall(dataSource).withProcedureName("del_all_model_instances");
         this.procDeleteModel = new SimpleJdbcCall(dataSource).withProcedureName("del_model");
+        this.procInsertToscaModel = new SimpleJdbcCall(dataSource).withProcedureName("set_tosca_model");
+        this.procInsertNewToscaModelVersion = new SimpleJdbcCall(dataSource).withProcedureName("set_new_tosca_model_version");
+        this.procInsertDictionary = new SimpleJdbcCall(dataSource).withProcedureName("set_dictionary");
+        this.procInsertDictionaryElement = new SimpleJdbcCall(dataSource).withProcedureName("set_dictionary_elements");
     }
 
     /**
@@ -116,7 +132,7 @@
         CldsModel model = new CldsModel();
         model.setName(modelName);
         SqlParameterSource in = new MapSqlParameterSource().addValue("v_model_name", modelName)
-                .addValue(V_CONTROL_NAME_UUID, controlNameUuid);
+            .addValue(V_CONTROL_NAME_UUID, controlNameUuid);
         Map<String, Object> out = logSqlExecution(procGetModel, in);
         populateModelProperties(model, out);
         return model;
@@ -165,12 +181,12 @@
      */
     public CldsModel setModel(CldsModel model, String userid) {
         SqlParameterSource in = new MapSqlParameterSource().addValue("v_model_name", model.getName())
-                .addValue("v_template_id", model.getTemplateId()).addValue("v_user_id", userid)
-                .addValue("v_model_prop_text", model.getPropText())
-                .addValue("v_model_blueprint_text", model.getBlueprintText())
-                .addValue("v_service_type_id", model.getTypeId()).addValue("v_deployment_id", model.getDeploymentId())
-                .addValue("v_control_name_prefix", model.getControlNamePrefix())
-                .addValue(V_CONTROL_NAME_UUID, model.getControlNameUuid());
+            .addValue("v_template_id", model.getTemplateId()).addValue("v_user_id", userid)
+            .addValue("v_model_prop_text", model.getPropText())
+            .addValue("v_model_blueprint_text", model.getBlueprintText())
+            .addValue("v_service_type_id", model.getTypeId()).addValue("v_deployment_id", model.getDeploymentId())
+            .addValue("v_control_name_prefix", model.getControlNamePrefix())
+            .addValue(V_CONTROL_NAME_UUID, model.getControlNameUuid());
         Map<String, Object> out = logSqlExecution(procSetModel, in);
         model.setControlNamePrefix((String) out.get(V_CONTROL_NAME_PREFIX));
         model.setControlNameUuid((String) out.get(V_CONTROL_NAME_UUID));
@@ -203,9 +219,9 @@
                 logger.debug("v_vm_name={}", currModelInstance.getVmName());
                 logger.debug("v_location={}", currModelInstance.getLocation());
                 SqlParameterSource in = new MapSqlParameterSource()
-                        .addValue(V_CONTROL_NAME_UUID, model.getControlNameUuid())
-                        .addValue("v_vm_name", currModelInstance.getVmName())
-                        .addValue("v_location", currModelInstance.getLocation());
+                    .addValue(V_CONTROL_NAME_UUID, model.getControlNameUuid())
+                    .addValue("v_vm_name", currModelInstance.getVmName())
+                    .addValue("v_location", currModelInstance.getLocation());
                 Map<String, Object> out = logSqlExecution(procInsModelInstance, in);
                 model.setId((String) (out.get("v_model_id")));
                 CldsModelInstance modelInstance = new CldsModelInstance();
@@ -230,10 +246,10 @@
     public CldsEvent insEvent(String modelName, String controlNamePrefix, String controlNameUuid, CldsEvent cldsEvent) {
         CldsEvent event = new CldsEvent();
         SqlParameterSource in = new MapSqlParameterSource().addValue("v_model_name", modelName)
-                .addValue(V_CONTROL_NAME_PREFIX, controlNamePrefix).addValue(V_CONTROL_NAME_UUID, controlNameUuid)
-                .addValue("v_user_id", cldsEvent.getUserid()).addValue("v_action_cd", cldsEvent.getActionCd())
-                .addValue("v_action_state_cd", cldsEvent.getActionStateCd())
-                .addValue("v_process_instance_id", cldsEvent.getProcessInstanceId());
+            .addValue(V_CONTROL_NAME_PREFIX, controlNamePrefix).addValue(V_CONTROL_NAME_UUID, controlNameUuid)
+            .addValue("v_user_id", cldsEvent.getUserid()).addValue("v_action_cd", cldsEvent.getActionCd())
+            .addValue("v_action_state_cd", cldsEvent.getActionStateCd())
+            .addValue("v_process_instance_id", cldsEvent.getProcessInstanceId());
         Map<String, Object> out = logSqlExecution(procInsEvent, in);
         event.setId((String) (out.get("v_event_id")));
         return event;
@@ -253,7 +269,7 @@
      */
     public void updEvent(String eventId, String processInstanceId) {
         SqlParameterSource in = new MapSqlParameterSource().addValue("v_event_id", eventId)
-                .addValue("v_process_instance_id", processInstanceId);
+            .addValue("v_process_instance_id", processInstanceId);
         logSqlExecution(procUpdEvent, in);
     }
 
@@ -276,9 +292,9 @@
      */
     public void setTemplate(CldsTemplate template, String userid) {
         SqlParameterSource in = new MapSqlParameterSource().addValue("v_template_name", template.getName())
-                .addValue("v_user_id", userid).addValue("v_template_bpmn_text", template.getBpmnText())
-                .addValue("v_template_image_text", template.getImageText())
-                .addValue("v_template_doc_text", template.getPropText());
+            .addValue("v_user_id", userid).addValue("v_template_bpmn_text", template.getBpmnText())
+            .addValue("v_template_image_text", template.getImageText())
+            .addValue("v_template_doc_text", template.getPropText());
         Map<String, Object> out = logSqlExecution(procSetTemplate, in);
         template.setId((String) (out.get("v_template_id")));
         template.setBpmnUserid((String) (out.get("v_template_bpmn_user_id")));
@@ -333,10 +349,10 @@
         try {
             String getCldsServiceSQL = "SELECT * , TIMESTAMPDIFF(SECOND, timestamp, CURRENT_TIMESTAMP()) FROM clds_service_cache where invariant_service_id  = ? ";
             cldsServiceData = jdbcTemplateObject.queryForObject(getCldsServiceSQL, new Object[] { invariantUUID },
-                    new CldsServiceDataMapper());
+                new CldsServiceDataMapper());
             if (cldsServiceData != null) {
                 logger.info("CldsServiceData found in cache for Service Invariant ID:"
-                        + cldsServiceData.getServiceInvariantUUID());
+                    + cldsServiceData.getServiceInvariantUUID());
                 return cldsServiceData;
             } else {
                 logger.warn("CldsServiceData not found in cache for Service Invariant ID:" + invariantUUID);
@@ -351,13 +367,13 @@
 
     public void setCldsServiceCache(CldsDbServiceCache cldsDBServiceCache) {
         if (cldsDBServiceCache != null && cldsDBServiceCache.getInvariantId() != null
-                && cldsDBServiceCache.getServiceId() != null) {
+            && cldsDBServiceCache.getServiceId() != null) {
             String invariantUuid = cldsDBServiceCache.getInvariantId();
             String serviceUuid = cldsDBServiceCache.getServiceId();
             InputStream is = cldsDBServiceCache.getCldsDataInstream();
             String insertCldsServiceCacheSql = "INSERT INTO clds_service_cache"
-                    + "(invariant_service_id,service_id,timestamp,object_data) VALUES"
-                    + "(?,?,CURRENT_TIMESTAMP,?) ON DUPLICATE KEY UPDATE invariant_service_id = VALUES(invariant_service_id) , timestamp = CURRENT_TIMESTAMP , object_data = VALUES(object_data) ";
+                + "(invariant_service_id,service_id,timestamp,object_data) VALUES"
+                + "(?,?,CURRENT_TIMESTAMP,?) ON DUPLICATE KEY UPDATE invariant_service_id = VALUES(invariant_service_id) , timestamp = CURRENT_TIMESTAMP , object_data = VALUES(object_data) ";
             jdbcTemplateObject.update(insertCldsServiceCacheSql, invariantUuid, serviceUuid, is);
         }
     }
@@ -377,13 +393,13 @@
 
     /**
      * Method to get deployed/active models with model properties.
-     * 
+     *
      * @return list of CldsModelProp
      */
     public List<CldsModelProp> getDeployedModelProperties() {
         List<CldsModelProp> cldsModelPropList = new ArrayList<>();
         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'";
+            + "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) {
@@ -399,7 +415,7 @@
 
     /**
      * Method to get deployed/active models with model properties.
-     * 
+     *
      * @return list of CLDS-Monitoring-Details: CLOSELOOP_NAME | Close loop name
      *         used in the CLDS application (prefix: ClosedLoop- + unique
      *         ClosedLoop ID) MODEL_NAME | Model Name in CLDS application
@@ -414,8 +430,8 @@
         SimpleDateFormat sdf = new SimpleDateFormat("MM-dd-yyyy HH:mm:ss");
         List<CldsMonitoringDetails> cldsMonitoringDetailsList = new ArrayList<CldsMonitoringDetails>();
         String modelsSql = "SELECT CONCAT(M.CONTROL_NAME_PREFIX, M.CONTROL_NAME_UUID) AS CLOSELOOP_NAME , M.MODEL_NAME, M.SERVICE_TYPE_ID, M.DEPLOYMENT_ID, T.TEMPLATE_NAME, E.ACTION_CD, E.USER_ID, E.TIMESTAMP "
-                + "FROM MODEL M, TEMPLATE T, EVENT E "
-                + "WHERE M.TEMPLATE_ID = T.TEMPLATE_ID AND M.EVENT_ID = E.EVENT_ID " + "ORDER BY ACTION_CD";
+            + "FROM MODEL M, TEMPLATE T, EVENT E "
+            + "WHERE M.TEMPLATE_ID = T.TEMPLATE_ID AND M.EVENT_ID = E.EVENT_ID " + "ORDER BY ACTION_CD";
         List<Map<String, Object>> rows = jdbcTemplateObject.queryForList(modelsSql);
         CldsMonitoringDetails cldsMonitoringDetails = null;
         for (Map<String, Object> row : rows) {
@@ -435,14 +451,14 @@
 
     /**
      * Method to delete model from database.
-     * 
+     *
      * @param modelName
      */
     public void deleteModel(String modelName) {
         SqlParameterSource in = new MapSqlParameterSource().addValue("v_model_name", modelName);
         logSqlExecution(procDeleteModel, in);
     }
-    
+
     private void populateModelProperties(CldsModel model, Map out) {
         // todo : rationalize
         model.setControlNamePrefix((String) out.get(V_CONTROL_NAME_PREFIX));
@@ -461,6 +477,317 @@
         model.getEvent().setProcessInstanceId((String) out.get("v_event_process_instance_id"));
         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"));        	
-    }    
+        model.setDeploymentId((String) out.get("v_deployment_id"));
+    }
+
+
+    /**
+     * Method to retrieve a tosca models by Policy Type from database.
+
+     * @param policyType
+     * @return  List of CldsToscaModel
+     */
+    public List<CldsToscaModel> getAllToscaModels() {
+        return getToscaModel(null, null);
+    }
+
+    /**
+     * Method to retrieve a tosca models by Policy Type from database.
+
+     * @param policyType
+     * @return  List of CldsToscaModel
+     */
+    public List<CldsToscaModel> getToscaModelByPolicyType(String policyType) {
+        return getToscaModel(null, policyType);
+    }
+
+    /**
+     * Method to retrieve a tosca models by toscaModelName, version from database.
+     *
+     * @param policyType
+     * @return List of CldsToscaModel
+     */
+    public List<CldsToscaModel> getToscaModelByName(String toscaModelName) {
+        return getToscaModel(toscaModelName, null);
+    }
+
+    // Retrieve the latest tosca model for a policy type or by tosca model name
+
+    private List<CldsToscaModel> getToscaModel(String toscaModelName, String policyType) {
+        SimpleDateFormat sdf = new SimpleDateFormat("MM-dd-yyyy HH:mm:ss");
+        List<CldsToscaModel> cldsToscaModels = new ArrayList<>();
+
+        String toscaModelSql = "SELECT tm.tosca_model_name, tm.tosca_model_id, tm.policy_type, tmr.tosca_model_revision_id, tmr.version, tmr.user_id, tmr.createdTimestamp, tmr.lastUpdatedTimestamp "
+            + ((toscaModelName != null) ? (", tmr.tosca_model_yaml ") : " ")
+            + "FROM tosca_model tm, tosca_model_revision tmr WHERE tm.tosca_model_id = tmr.tosca_model_id "
+            + ((toscaModelName != null) ? (" AND tm.tosca_model_name = '" + toscaModelName + "'") : " ")
+            + ((policyType != null) ? (" AND tm.policy_type = '" + policyType + "'") : " ")
+            + "AND tmr.version = (select max(version) from tosca_model_revision st where tmr.tosca_model_id=st.tosca_model_id)";
+
+        List<Map<String, Object>> rows = jdbcTemplateObject.queryForList(toscaModelSql);
+
+        if (rows != null && rows.size() > 0) {
+
+            rows.stream().forEach(row -> {
+                CldsToscaModel cldsToscaModel = new CldsToscaModel();
+                cldsToscaModel.setId((String) row.get("tosca_model_id"));
+                cldsToscaModel.setPolicyType((String) row.get("policy_type"));
+                cldsToscaModel.setToscaModelName((String) row.get("tosca_model_name"));
+                cldsToscaModel.setUserId((String) row.get("user_id"));
+                cldsToscaModel.setRevisionId((String) row.get("tosca_model_revision_id"));
+                cldsToscaModel.setVersion(((Double) row.get("version")));
+                cldsToscaModel.setCreatedDate(sdf.format(row.get("createdTimestamp")));
+                cldsToscaModel.setLastUpdatedDate(sdf.format(row.get("lastUpdatedTimestamp")));
+                if (toscaModelName != null) {
+                    cldsToscaModel.setToscaModelYaml((String) row.get("tosca_model_yaml"));
+                }
+                cldsToscaModels.add(cldsToscaModel);
+            });
+
+        }
+        return cldsToscaModels;
+    }
+
+    // Retrieve Tosca Models & its revisions by policy Type.
+    private List<CldsToscaModelDetails> getAllToscaModelVersion(String toscaModelName, String policyType,
+        String version) {
+        SimpleDateFormat sdf = new SimpleDateFormat("MM-dd-yyyy HH:mm:ss");
+        List<CldsToscaModelDetails> cldsToscaModelDetailsList = new ArrayList<>();
+        String toscaModelSql = "SELECT tm.tosca_model_name, tm.tosca_model_id, tm.policy_type, tmr.tosca_model_revision_id, tmr.version, tmr.user_id, tmr.createdTimestamp, tmr.lastUpdatedTimestamp "
+            + "FROM tosca_model tm, tosca_model_revision tmr " + "WHERE tmr.tosca_model_id = tm.tosca_model_id "
+            + ((policyType != null) ? (" AND tm.policy_type = '" + policyType + "'") : " ")
+            + ((toscaModelName != null) ? (" AND tm.tosca_model_name = '" + toscaModelName + "'") : " ")
+            + ((version != null) ? (" AND tmr.version = '" + version + "'") : "");
+
+        List<Map<String, Object>> rows = jdbcTemplateObject.queryForList(toscaModelSql);
+
+        if (rows != null && rows.size() > 0) {
+            // Get list of all available modelIds
+            List<String> listofModelIds = new ArrayList<>();
+            for (Map<String, Object> r : rows) {
+                if (r != null) {
+                    listofModelIds.add((String) r.get("tosca_model_id"));
+                }
+            }
+            // Filter Distinct elements using streams
+            listofModelIds = listofModelIds.stream().distinct().collect(Collectors.toList());
+
+            // TODO change logic using java8
+            for (String modelId : listofModelIds) {
+                CldsToscaModelDetails cldsToscaModelDetails = new CldsToscaModelDetails();
+                List<CldsToscaModelRevision> revisions = new ArrayList<>();
+                for (Map<String, Object> row : rows) {
+                    String id = (String) row.get("tosca_model_id");
+                    if (modelId.equalsIgnoreCase(id)) {
+                        cldsToscaModelDetails.setId(id);
+                        cldsToscaModelDetails.setPolicyType((String) row.get("policy_type"));
+                        cldsToscaModelDetails.setToscaModelName((String) row.get("tosca_model_name"));
+                        cldsToscaModelDetails.setUserId((String) row.get("user_id"));
+
+                        CldsToscaModelRevision modelRevision = new CldsToscaModelRevision();
+                        modelRevision.setRevisionId((String) row.get("tosca_model_revision_id"));
+                        modelRevision.setVersion(((Double) row.get("version")));
+                        modelRevision.setUserId((String) row.get("user_id"));
+                        modelRevision.setCreatedDate(sdf.format(row.get("createdTimestamp")));
+                        modelRevision.setLastUpdatedDate(sdf.format(row.get("lastUpdatedTimestamp")));
+                        revisions.add(modelRevision);
+                    }
+                }
+                cldsToscaModelDetails.setToscaModelRevisions(revisions);
+                cldsToscaModelDetailsList.add(cldsToscaModelDetails);
+            }
+        }
+        return cldsToscaModelDetailsList;
+    }
+
+
+    /**
+     *  Method to upload a new version of Tosca Model Yaml in Database
+     *
+     * @param cldsToscaModel
+     * @param userId
+     * @return CldsToscaModel
+     *
+     */
+    public CldsToscaModel updateToscaModelWithNewVersion(CldsToscaModel cldsToscaModel, String userId) {
+        SqlParameterSource in = new MapSqlParameterSource().addValue("v_tosca_model_id", cldsToscaModel.getId())
+            .addValue("v_version", cldsToscaModel.getVersion())
+            .addValue("v_tosca_model_yaml", cldsToscaModel.getToscaModelYaml())
+            .addValue("v_tosca_model_json", cldsToscaModel.getToscaModelJson()).addValue("v_user_id", userId);
+        Map<String, Object> out = logSqlExecution(procInsertNewToscaModelVersion, in);
+        cldsToscaModel.setRevisionId((String) (out.get("v_revision_id")));
+        return cldsToscaModel;
+    }
+
+
+    /**
+     *  Method to upload a new Tosca model Yaml in DB. Default version is 1.0
+     *
+     * @param cldsToscaModel
+     * @param userId
+     * @return CldsToscaModel
+     */
+    public CldsToscaModel insToscaModel(CldsToscaModel cldsToscaModel, String userId) {
+        SqlParameterSource in = new MapSqlParameterSource()
+            .addValue("v_tosca_model_name", cldsToscaModel.getToscaModelName())
+            .addValue("v_policy_type", cldsToscaModel.getPolicyType())
+            .addValue("v_tosca_model_yaml", cldsToscaModel.getToscaModelYaml())
+            .addValue("v_tosca_model_json", cldsToscaModel.getToscaModelJson())
+            .addValue("v_version", cldsToscaModel.getVersion()).addValue("v_user_id", userId);
+        Map<String, Object> out = logSqlExecution(procInsertToscaModel, in);
+        cldsToscaModel.setId((String) (out.get("v_tosca_model_id")));
+        cldsToscaModel.setRevisionId((String) (out.get("v_revision_id")));
+        cldsToscaModel.setUserId((String) out.get("v_user_id"));
+        return cldsToscaModel;
+    }
+
+    /**
+     * Method to insert a new Dictionary in Database
+     *
+     * @param cldsDictionary
+     */
+    public void insDictionary(CldsDictionary cldsDictionary) {
+        SqlParameterSource in = new MapSqlParameterSource()
+            .addValue("v_dictionary_name", cldsDictionary.getDictionaryName())
+            .addValue("v_user_id", cldsDictionary.getCreatedBy());
+        Map<String, Object> out = logSqlExecution(procInsertDictionary, in);
+        cldsDictionary.setDictionaryId((String) (out.get("v_dictionary_id")));
+    }
+
+
+    /**
+     * Method to update Dictionary with new info in Database
+     *
+     * @param dictionaryId
+     * @param cldsDictionary
+     * @param userId
+     */
+    public void updateDictionary(String dictionaryId, CldsDictionary cldsDictionary, String userId) {
+
+        String dictionarySql = "UPDATE dictionary " + "SET dictionary_name = '" + cldsDictionary.getDictionaryName()
+        + "', modified_by = '" + userId + "'" + "WHERE dictionary_id = '" + dictionaryId + "'";
+        jdbcTemplateObject.update(dictionarySql);
+        cldsDictionary.setUpdatedBy(userId);
+    }
+
+
+    /**
+     * Method to get list of Dictionaries from the Database
+     *
+     * @param dictionaryId
+     * @param dictionaryName
+     * @return
+     */
+    public List<CldsDictionary> getDictionary(String dictionaryId, String dictionaryName) {
+        SimpleDateFormat sdf = new SimpleDateFormat("MM-dd-yyyy HH:mm:ss");
+        List<CldsDictionary> dictionaries = new ArrayList<>();
+        String dictionarySql = "SELECT dictionary_id, dictionary_name, created_by, modified_by, timestamp FROM dictionary"
+            + ((dictionaryId != null || dictionaryName != null)
+                ? (" WHERE " + ((dictionaryName != null) ? ("dictionary_name = '" + dictionaryName + "'") : "")
+                    + ((dictionaryId != null && dictionaryName != null) ? (" AND ") : "")
+                    + ((dictionaryId != null) ? ("dictionary_id = '" + dictionaryId + "'") : "")): "");
+
+        List<Map<String, Object>> rows = jdbcTemplateObject.queryForList(dictionarySql);
+
+        if (rows != null && rows.size() > 0) {
+            rows.stream().forEach(row -> {
+                CldsDictionary cldsDictionary = new CldsDictionary();
+                cldsDictionary.setDictionaryId((String) row.get("dictionary_id"));
+                cldsDictionary.setDictionaryName((String) row.get("dictionary_name"));
+                cldsDictionary.setCreatedBy((String) row.get("created_by"));
+                cldsDictionary.setUpdatedBy((String) row.get("modified_by"));
+                cldsDictionary.setLastUpdatedDate(sdf.format(row.get("timestamp")));
+                dictionaries.add(cldsDictionary);
+            });
+        }
+        return dictionaries;
+    }
+
+    /**
+     * Method to insert a new Dictionary Element for given dictionary in Database
+     *
+     * @param cldsDictionaryItem
+     * @param userId
+     */
+    public void insDictionarElements(CldsDictionaryItem cldsDictionaryItem, String userId) {
+        SqlParameterSource in = new MapSqlParameterSource()
+            .addValue("v_dictionary_id", cldsDictionaryItem.getDictionaryId())
+            .addValue("v_dict_element_name", cldsDictionaryItem.getDictElementName())
+            .addValue("v_dict_element_short_name", cldsDictionaryItem.getDictElementShortName())
+            .addValue("v_dict_element_description", cldsDictionaryItem.getDictElementDesc())
+            .addValue("v_dict_element_type", cldsDictionaryItem.getDictElementType())
+            .addValue("v_user_id", userId);
+        Map<String, Object> out = logSqlExecution(procInsertDictionaryElement, in);
+        cldsDictionaryItem.setDictElementId((String) (out.get("v_dict_element_id")));
+    }
+
+
+    /**
+     * Method to update Dictionary Elements with new info for a given dictionary in Database
+     *
+     * @param dictionaryElementId
+     * @param cldsDictionaryItem
+     * @param userId
+     */
+    public void updateDictionaryElements(String dictionaryElementId, CldsDictionaryItem cldsDictionaryItem, String userId) {
+
+        String dictionarySql = "UPDATE dictionary_elements SET dict_element_name = '"
+            + cldsDictionaryItem.getDictElementName() + "', dict_element_short_name = '"
+            + cldsDictionaryItem.getDictElementShortName() + "', dict_element_description= '"
+            + cldsDictionaryItem.getDictElementDesc() + "', dict_element_type = '"
+            + cldsDictionaryItem.getDictElementType() + "', modified_by = '" + userId + "' "
+            + "WHERE dict_element_id = '" + dictionaryElementId + "'";
+        jdbcTemplateObject.update(dictionarySql);
+        cldsDictionaryItem.setUpdatedBy(userId);
+    }
+
+    /**
+     * Method to get list of all dictionary elements for a given dictionary in the Database
+     *
+     * @param dictionaryName
+     * @param dictionaryId
+     * @param dictElementShortName
+     * @return
+     */
+    public List<CldsDictionaryItem> getDictionaryElements(String dictionaryName, String dictionaryId,
+        String dictElementShortName) {
+        SimpleDateFormat sdf = new SimpleDateFormat("MM-dd-yyyy HH:mm:ss");
+        List<CldsDictionaryItem> dictionaryItems = new ArrayList<>();
+        String dictionarySql = "SELECT de.dict_element_id, de.dictionary_id, de.dict_element_name, de.dict_element_short_name, de.dict_element_description, de.dict_element_type, de.created_by, de.modified_by, de.timestamp  "
+            + "FROM dictionary_elements de, dictionary d WHERE de.dictionary_id = d.dictionary_id "
+            + ((dictionaryId != null) ? (" AND d.dictionary_id = '" + dictionaryId + "'") : "")
+            + ((dictElementShortName != null) ? (" AND de.dict_element_short_name = '" + dictElementShortName + "'"): "")
+            + ((dictionaryName != null) ? (" AND dictionary_name = '" + dictionaryName + "'") : "");
+
+        List<Map<String, Object>> rows = jdbcTemplateObject.queryForList(dictionarySql);
+
+        if (rows != null && rows.size() > 0) {
+            rows.stream().forEach(row -> {
+                CldsDictionaryItem dictionaryItem = new CldsDictionaryItem();
+                dictionaryItem.setDictElementId((String) row.get("dict_element_id"));
+                dictionaryItem.setDictionaryId((String) row.get("dictionary_id"));
+                dictionaryItem.setDictElementName((String) row.get("dict_element_name"));
+                dictionaryItem.setDictElementShortName((String) row.get("dict_element_short_name"));
+                dictionaryItem.setDictElementDesc((String) row.get("dict_element_description"));
+                dictionaryItem.setDictElementType((String) row.get("dict_element_type"));
+                dictionaryItem.setCreatedBy((String) row.get("created_by"));
+                dictionaryItem.setUpdatedBy((String) row.get("modified_by"));
+                dictionaryItem.setLastUpdatedDate(sdf.format(row.get("timestamp")));
+                dictionaryItems.add(dictionaryItem);
+            });
+        }
+        return dictionaryItems;
+    }
+
+    /**
+     * Method to delete a tosca model from database.
+     *
+     * @param toscaModelId
+     * @param revisionId
+     */
+    /*public void deleteModel(String toscaModelId, String revisionId) {
+        SqlParameterSource in = new MapSqlParameterSource().addValue("v_tosca_model_id", toscaModelId)
+        		.addValue("v_revision_id", revisionId);
+        logSqlExecution(procDelToscaModel, in);
+    }*/
 }
diff --git a/src/main/java/org/onap/clamp/clds/model/CldsDictionary.java b/src/main/java/org/onap/clamp/clds/model/CldsDictionary.java
new file mode 100644
index 0000000..a9b003d
--- /dev/null
+++ b/src/main/java/org/onap/clamp/clds/model/CldsDictionary.java
@@ -0,0 +1,164 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP CLAMP
+ * ================================================================================
+ * Copyright (C) 2018 AT&T Intellectual Property. All rights
+ *                             reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END============================================
+ * ===================================================================
+ *
+ */
+
+package org.onap.clamp.clds.model;
+
+import com.fasterxml.jackson.annotation.JsonInclude;
+import com.fasterxml.jackson.annotation.JsonInclude.Include;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.onap.clamp.clds.dao.CldsDao;
+
+/**
+ * Represents a CLDS Dictionary.
+ */
+@JsonInclude(Include.NON_NULL)
+public class CldsDictionary {
+
+    private String dictionaryId;
+    private String dictionaryName;
+    private String createdBy;
+    private String updatedBy;
+    private String lastUpdatedDate;
+    private List<CldsDictionaryItem> cldsDictionaryItems = new ArrayList<>();
+
+    /**
+     * Creates or updates dictionary item for a dictionary in DB
+     *
+     * @param dictionaryName
+     * @param cldsDao
+     * @param userId
+     */
+    public void save(String dictionaryName, CldsDao cldsDao, String userId) {
+        List<CldsDictionary> list = cldsDao.getDictionary(this.getDictionaryId(), dictionaryName);
+        if (list != null && !list.isEmpty()) {
+            CldsDictionary cldsDictionary = list.stream().findFirst().get();
+            if (!cldsDictionary.getDictionaryName().equalsIgnoreCase(this.getDictionaryName())) {
+                cldsDao.updateDictionary(cldsDictionary.getDictionaryId(), this, userId);
+                this.setCreatedBy(cldsDictionary.getCreatedBy());
+            } else {
+                this.setDictionaryId(cldsDictionary.getDictionaryId());
+                this.setCreatedBy(cldsDictionary.getCreatedBy());
+                this.setUpdatedBy(cldsDictionary.getUpdatedBy());
+                this.setLastUpdatedDate(cldsDictionary.getLastUpdatedDate());
+            }
+        } else {
+            this.setCreatedBy(userId);
+            this.setUpdatedBy(userId);
+            cldsDao.insDictionary(this);
+        }
+    }
+
+    /**
+     * @return the dictionaryId
+     */
+    public String getDictionaryId() {
+        return dictionaryId;
+    }
+
+    /**
+     * @param dictionaryId
+     *        the dictionaryId to set
+     */
+    public void setDictionaryId(String dictionaryId) {
+        this.dictionaryId = dictionaryId;
+    }
+
+    /**
+     * @return the dictionaryName
+     */
+    public String getDictionaryName() {
+        return dictionaryName;
+    }
+
+    /**
+     * @param dictionaryName
+     *        the dictionaryName to set
+     */
+    public void setDictionaryName(String dictionaryName) {
+        this.dictionaryName = dictionaryName;
+    }
+
+    /**
+     * @return the createdBy
+     */
+    public String getCreatedBy() {
+        return createdBy;
+    }
+
+    /**
+     * @param createdBy
+     *        the createdBy to set
+     */
+    public void setCreatedBy(String createdBy) {
+        this.createdBy = createdBy;
+    }
+
+    /**
+     * @return the updatedBy
+     */
+    public String getUpdatedBy() {
+        return updatedBy;
+    }
+
+    /**
+     * @param updatedby
+     *        the updatedBy to set
+     */
+    public void setUpdatedBy(String updatedby) {
+        updatedBy = updatedby;
+    }
+
+    /**
+     * @return the lastUpdatedDate
+     */
+    public String getLastUpdatedDate() {
+        return lastUpdatedDate;
+    }
+
+    /**
+     * @param lastUpdatedDate
+     *        the lastUpdatedDate to set
+     */
+    public void setLastUpdatedDate(String lastUpdatedDate) {
+        this.lastUpdatedDate = lastUpdatedDate;
+    }
+
+    /**
+     * @return the cldsDictionaryItems
+     */
+    public List<CldsDictionaryItem> getCldsDictionaryItems() {
+        return cldsDictionaryItems;
+    }
+
+    /**
+     * @param cldsDictionaryItems
+     *        the cldsDictionaryItems to set
+     */
+    public void setCldsDictionaryItems(List<CldsDictionaryItem> cldsDictionaryItems) {
+        this.cldsDictionaryItems = cldsDictionaryItems;
+    }
+
+}
diff --git a/src/main/java/org/onap/clamp/clds/model/CldsDictionaryItem.java b/src/main/java/org/onap/clamp/clds/model/CldsDictionaryItem.java
new file mode 100644
index 0000000..87ba9fe
--- /dev/null
+++ b/src/main/java/org/onap/clamp/clds/model/CldsDictionaryItem.java
@@ -0,0 +1,205 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP CLAMP
+ * ================================================================================
+ * Copyright (C) 2018 AT&T Intellectual Property. All rights
+ *                             reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END============================================
+ * ===================================================================
+ *
+ */
+
+package org.onap.clamp.clds.model;
+
+import com.fasterxml.jackson.annotation.JsonInclude;
+import com.fasterxml.jackson.annotation.JsonInclude.Include;
+
+import java.util.List;
+
+import org.onap.clamp.clds.dao.CldsDao;
+
+/**
+ * Represents a CLDS Dictionary Item.
+ */
+@JsonInclude(Include.NON_NULL)
+public class CldsDictionaryItem {
+
+    private String dictElementId;
+    private String dictionaryId;
+    private String dictElementName;
+    private String dictElementShortName;
+    private String dictElementDesc;
+    private String dictElementType;
+    private String createdBy;
+    private String updatedBy;
+    private String lastUpdatedDate;
+
+    public void save(String dictionaryName, CldsDao cldsDao, String userId) {
+        // Check if dictionary exists.
+        List<CldsDictionary> list = cldsDao.getDictionary(this.getDictionaryId(), dictionaryName);
+        if (list != null && !list.isEmpty()) {
+            // Dictionary found. We can add or update the dictionary element
+            CldsDictionary cldsDictionary = list.stream().findFirst().get();
+            List<CldsDictionaryItem> dictionaryItems = cldsDao.getDictionaryElements(dictionaryName,
+                cldsDictionary.getDictionaryId(), this.getDictElementShortName());
+            if (dictionaryItems != null && !dictionaryItems.isEmpty()) {
+                CldsDictionaryItem item = dictionaryItems.stream().findFirst().get();
+                cldsDao.updateDictionaryElements(item.getDictElementId(), this, userId);
+                this.setCreatedBy(item.getCreatedBy());
+
+            } else {
+                this.setCreatedBy(userId);
+                this.setUpdatedBy(userId);
+                cldsDao.insDictionarElements(this, userId);
+            }
+        }
+    }
+
+    /**
+     * @return the dictElementId
+     */
+    public String getDictElementId() {
+        return dictElementId;
+    }
+
+    /**
+     * @param dictElementId
+     *        the dictElementId to set
+     */
+    public void setDictElementId(String dictElementId) {
+        this.dictElementId = dictElementId;
+    }
+
+    /**
+     * @return the dictionaryId
+     */
+    public String getDictionaryId() {
+        return dictionaryId;
+    }
+
+    /**
+     * @param dictionaryId
+     *        the dictionaryId to set
+     */
+    public void setDictionaryId(String dictionaryId) {
+        this.dictionaryId = dictionaryId;
+    }
+
+    /**
+     * @return the dictElementName
+     */
+    public String getDictElementName() {
+        return dictElementName;
+    }
+
+    /**
+     * @param dictElementName
+     *        the dictElementName to set
+     */
+    public void setDictElementName(String dictElementName) {
+        this.dictElementName = dictElementName;
+    }
+
+    /**
+     * @return the dictElementShortName
+     */
+    public String getDictElementShortName() {
+        return dictElementShortName;
+    }
+
+    /**
+     * @param dictElementShortName
+     *        the dictElementShortName to set
+     */
+    public void setDictElementShortName(String dictElementShortName) {
+        this.dictElementShortName = dictElementShortName;
+    }
+
+    /**
+     * @return the dictElementDesc
+     */
+    public String getDictElementDesc() {
+        return dictElementDesc;
+    }
+
+    /**
+     * @param dictElementDesc
+     *        the dictElementDesc to set
+     */
+    public void setDictElementDesc(String dictElementDesc) {
+        this.dictElementDesc = dictElementDesc;
+    }
+
+    /**
+     * @return the dictElementType
+     */
+    public String getDictElementType() {
+        return dictElementType;
+    }
+
+    /**
+     * @param dictElementType
+     *        the dictElementType to set
+     */
+    public void setDictElementType(String dictElementType) {
+        this.dictElementType = dictElementType;
+    }
+
+    /**
+     * @return the createdBy
+     */
+    public String getCreatedBy() {
+        return createdBy;
+    }
+
+    /**
+     * @param createdBy
+     *        the createdBy to set
+     */
+    public void setCreatedBy(String createdBy) {
+        this.createdBy = createdBy;
+    }
+
+    /**
+     * @return the updatedBy
+     */
+    public String getUpdatedBy() {
+        return updatedBy;
+    }
+
+    /**
+     * @param updatedby
+     *        the updatedBy to set
+     */
+    public void setUpdatedBy(String updatedby) {
+        updatedBy = updatedby;
+    }
+
+    /**
+     * @return the lastUpdatedDate
+     */
+    public String getLastUpdatedDate() {
+        return lastUpdatedDate;
+    }
+
+    /**
+     * @param lastUpdatedDate
+     *        the lastUpdatedDate to set
+     */
+    public void setLastUpdatedDate(String lastUpdatedDate) {
+        this.lastUpdatedDate = lastUpdatedDate;
+    }
+
+}
diff --git a/src/main/java/org/onap/clamp/clds/model/CldsEvent.java b/src/main/java/org/onap/clamp/clds/model/CldsEvent.java
index 0867b96..8d3807b 100644
--- a/src/main/java/org/onap/clamp/clds/model/CldsEvent.java
+++ b/src/main/java/org/onap/clamp/clds/model/CldsEvent.java
@@ -29,37 +29,38 @@
  * Represent a CLDS Event.
  */
 public class CldsEvent {
-    public static final String ACTION_TEST            = "TEST";
-    public static final String ACTION_CREATE          = "CREATE";
-    public static final String ACTION_MODIFY          = "MODIFY";
-    public static final String ACTION_SUBMIT          = "SUBMIT";
+    public static final String ACTION_TEST = "TEST";
+    public static final String ACTION_CREATE = "CREATE";
+    public static final String ACTION_MODIFY = "MODIFY";
+    public static final String ACTION_SUBMIT = "SUBMIT";
     // an update before model is active
-    public static final String ACTION_RESUBMIT        = "RESUBMIT";
+    public static final String ACTION_RESUBMIT = "RESUBMIT";
     // For simplified models
-    public static final String ACTION_SUBMITDCAE      = "SUBMITDCAE";
+    public static final String ACTION_SUBMITDCAE = "SUBMITDCAE";
+    public static final String ACTION_SUBMITPOLICY = "SUBMITPOLICY";
     // only from dcae
-    public static final String ACTION_DISTRIBUTE      = "DISTRIBUTE";
+    public static final String ACTION_DISTRIBUTE = "DISTRIBUTE";
     // only from dcae
-    public static final String ACTION_DEPLOY          = "DEPLOY";
+    public static final String ACTION_DEPLOY = "DEPLOY";
     // only from dcae
-    public static final String ACTION_UNDEPLOY        = "UNDEPLOY";
-    public static final String ACTION_UPDATE          = "UPDATE";
-    public static final String ACTION_DELETE          = "DELETE";
-    public static final String ACTION_STOP            = "STOP";
-    public static final String ACTION_RESTART         = "RESTART";
+    public static final String ACTION_UNDEPLOY = "UNDEPLOY";
+    public static final String ACTION_UPDATE = "UPDATE";
+    public static final String ACTION_DELETE = "DELETE";
+    public static final String ACTION_STOP = "STOP";
+    public static final String ACTION_RESTART = "RESTART";
 
     public static final String ACTION_STATE_INITIATED = "INITIATED";
-    public static final String ACTION_STATE_SENT      = "SENT";
+    public static final String ACTION_STATE_SENT = "SENT";
     public static final String ACTION_STATE_COMPLETED = "COMPLETED";
-    public static final String ACTION_STATE_RECEIVED  = "RECEIVED";
-    public static final String ACTION_STATE_ERROR     = "ERROR";
-    public static final String ACTION_STATE_ANY       = null;
+    public static final String ACTION_STATE_RECEIVED = "RECEIVED";
+    public static final String ACTION_STATE_ERROR = "ERROR";
+    public static final String ACTION_STATE_ANY = null;
 
-    private String             id;
-    private String             actionCd;
-    private String             actionStateCd;
-    private String             processInstanceId;
-    private String             userid;
+    private String id;
+    private String actionCd;
+    private String actionStateCd;
+    private String processInstanceId;
+    private String userid;
 
     public String getId() {
         return id;
diff --git a/src/main/java/org/onap/clamp/clds/model/CldsInfo.java b/src/main/java/org/onap/clamp/clds/model/CldsInfo.java
index 382d4e8..a24885f 100644
--- a/src/main/java/org/onap/clamp/clds/model/CldsInfo.java
+++ b/src/main/java/org/onap/clamp/clds/model/CldsInfo.java
@@ -25,12 +25,14 @@
 
 public class CldsInfo {
 
-    private String  userName;
-    private String  cldsVersion;
+    private String userName;
+    private String cldsVersion;
     private boolean permissionReadCl;
     private boolean permissionUpdateCl;
     private boolean permissionReadTemplate;
     private boolean permissionUpdateTemplate;
+    private boolean permissionReadTosca;
+    private boolean permissionUpdateTosca;
 
     public String getUserName() {
         return userName;
@@ -80,4 +82,20 @@
         this.permissionUpdateTemplate = permissionUpdateTemplate;
     }
 
+    public boolean isPermissionReadTosca() {
+        return permissionReadTosca;
+    }
+
+    public void setPermissionReadTosca(boolean permissionReadTosca) {
+        this.permissionReadTosca = permissionReadTosca;
+    }
+
+    public boolean isPermissionUpdateTosca() {
+        return permissionUpdateTosca;
+    }
+
+    public void setPermissionUpdateTosca(boolean permissionUpdateTosca) {
+        this.permissionUpdateTosca = permissionUpdateTosca;
+    }
+
 }
diff --git a/src/main/java/org/onap/clamp/clds/model/CldsModel.java b/src/main/java/org/onap/clamp/clds/model/CldsModel.java
index 8b23995..55f4dfd 100644
--- a/src/main/java/org/onap/clamp/clds/model/CldsModel.java
+++ b/src/main/java/org/onap/clamp/clds/model/CldsModel.java
@@ -139,7 +139,8 @@
         } else if (event.isActionAndStateCd(CldsEvent.ACTION_DEPLOY, CldsEvent.ACTION_STATE_RECEIVED)
                 || event.isActionAndStateCd(CldsEvent.ACTION_RESTART, CldsEvent.ACTION_STATE_ANY)
                 || event.isActionAndStateCd(CldsEvent.ACTION_UPDATE, CldsEvent.ACTION_STATE_ANY)
-                || event.isActionAndStateCd(CldsEvent.ACTION_DEPLOY, CldsEvent.ACTION_STATE_ANY)) {
+                || event.isActionAndStateCd(CldsEvent.ACTION_DEPLOY, CldsEvent.ACTION_STATE_ANY)
+                || event.isActionAndStateCd(CldsEvent.ACTION_SUBMITPOLICY, CldsEvent.ACTION_STATE_ANY)) {
             status = STATUS_ACTIVE;
         } else if (event.isActionAndStateCd(CldsEvent.ACTION_STOP, CldsEvent.ACTION_STATE_ANY)) {
             status = STATUS_STOPPED;
@@ -185,14 +186,15 @@
                 permittedActionCd = Arrays.asList(CldsEvent.ACTION_SUBMIT, CldsEvent.ACTION_TEST,
                         CldsEvent.ACTION_DELETE);
                 if (isSimplifiedModel()) {
-                    permittedActionCd = Arrays.asList(CldsEvent.ACTION_SUBMITDCAE, CldsEvent.ACTION_TEST,
-                            CldsEvent.ACTION_DELETE);
+                    permittedActionCd = Arrays.asList(CldsEvent.ACTION_SUBMITDCAE, CldsEvent.ACTION_SUBMITPOLICY,
+                            CldsEvent.ACTION_TEST, CldsEvent.ACTION_DELETE);
                 }
                 break;
             case CldsEvent.ACTION_MODIFY:
                 permittedActionCd = Arrays.asList(CldsEvent.ACTION_RESUBMIT, CldsEvent.ACTION_DELETE);
                 if (isSimplifiedModel()) {
-                    permittedActionCd = Arrays.asList(CldsEvent.ACTION_SUBMITDCAE, CldsEvent.ACTION_DELETE);
+                    permittedActionCd = Arrays.asList(CldsEvent.ACTION_SUBMITDCAE, CldsEvent.ACTION_SUBMITPOLICY,
+                            CldsEvent.ACTION_DELETE);
                 }
                 break;
             case CldsEvent.ACTION_SUBMIT:
@@ -202,6 +204,9 @@
             case CldsEvent.ACTION_SUBMITDCAE:
                 permittedActionCd = Arrays.asList(CldsEvent.ACTION_SUBMITDCAE, CldsEvent.ACTION_DELETE);
                 break;
+            case CldsEvent.ACTION_SUBMITPOLICY:
+                permittedActionCd = Arrays.asList(CldsEvent.ACTION_UPDATE, CldsEvent.ACTION_STOP);
+                break;
             case CldsEvent.ACTION_DISTRIBUTE:
                 permittedActionCd = Arrays.asList(CldsEvent.ACTION_DEPLOY, CldsEvent.ACTION_RESUBMIT,
                         CldsEvent.ACTION_DELETE);
@@ -226,10 +231,17 @@
             case CldsEvent.ACTION_UPDATE:
                 permittedActionCd = Arrays.asList(CldsEvent.ACTION_DEPLOY, CldsEvent.ACTION_UPDATE,
                         CldsEvent.ACTION_STOP, CldsEvent.ACTION_UNDEPLOY);
+                if (isPolicyOnly()) {
+                    permittedActionCd = Arrays.asList(CldsEvent.ACTION_UPDATE, CldsEvent.ACTION_STOP);
+                }
                 break;
             case CldsEvent.ACTION_STOP:
                 permittedActionCd = Arrays.asList(CldsEvent.ACTION_UPDATE, CldsEvent.ACTION_RESTART,
                         CldsEvent.ACTION_UNDEPLOY);
+                if (isPolicyOnly()) {
+                    permittedActionCd = Arrays.asList(CldsEvent.ACTION_UPDATE, CldsEvent.ACTION_RESTART,
+                            CldsEvent.ACTION_DELETE);
+                }
                 break;
             default:
                 logger.warn("Invalid current actionCd: " + actionCd);
@@ -252,6 +264,22 @@
         return result;
     }
 
+    private boolean isPolicyOnly() {
+        boolean result = false;
+        try {
+            if (propText != null) {
+                JsonNode modelJson = JacksonUtils.getObjectMapperInstance().readTree(propText);
+                JsonNode policyOnlyJson = modelJson.get("policyOnly");
+                if (policyOnlyJson != null && policyOnlyJson.asBoolean()) {
+                    result = true;
+                }
+            }
+        } catch (IOException e) {
+            logger.error("Error while parsing propText json", e);
+        }
+        return result;
+    }
+
     /**
      * Validate requestedActionCd - determine permittedActionCd and then check
      * if contained in permittedActionCd Throw IllegalArgumentException if
diff --git a/src/main/java/org/onap/clamp/clds/model/CldsToscaModel.java b/src/main/java/org/onap/clamp/clds/model/CldsToscaModel.java
new file mode 100644
index 0000000..4a23525
--- /dev/null
+++ b/src/main/java/org/onap/clamp/clds/model/CldsToscaModel.java
@@ -0,0 +1,130 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP CLAMP
+ * ================================================================================
+ * Copyright (C) 2018 AT&T Intellectual Property. All rights
+ *                             reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END============================================
+ * ===================================================================
+ *
+ */
+
+package org.onap.clamp.clds.model;
+
+import java.util.List;
+
+import org.onap.clamp.clds.dao.CldsDao;
+
+public class CldsToscaModel extends CldsToscaModelRevision {
+
+    private String id;
+    private String policyType;
+    private String toscaModelName;
+    private String toscaModelYaml;
+
+    /**
+     * Creates or updates Tosca Model to DB
+     *
+     * @param cldsDao
+     * @param userId
+     */
+    public CldsToscaModel save(CldsDao cldsDao, String userId) {
+        CldsToscaModel cldsToscaModel = null;
+        // TODO tosca parsing logic
+        this.setToscaModelJson("{}");
+        this.setPolicyType("Aging");// TODO update with subString or node_type from the model name
+        List<CldsToscaModel> toscaModels = cldsDao.getToscaModelByName(this.getToscaModelName());
+        if (toscaModels != null && !toscaModels.isEmpty()) {
+            CldsToscaModel toscaModel = toscaModels.stream().findFirst().get();
+            // CldsToscaModelRevision modelRevision =
+            // revisions.stream().max(Comparator.comparingDouble(CldsToscaModelRevision::getVersion)).get();
+            this.setVersion(incrementVersion(toscaModel.getVersion()));
+            this.setId(toscaModel.getId());
+            this.setUserId(userId);
+            cldsToscaModel = cldsDao.updateToscaModelWithNewVersion(this, userId);
+        } else {
+            this.setVersion(1);
+            cldsToscaModel = cldsDao.insToscaModel(this, userId);
+        }
+        return cldsToscaModel;
+    }
+
+    private double incrementVersion(double curVersion) {
+        return curVersion + 1;
+    }
+
+    /**
+     * @return the id
+     */
+    public String getId() {
+        return id;
+    }
+
+    /**
+     * @param id
+     *        the id to set
+     */
+    public void setId(String id) {
+        this.id = id;
+    }
+
+    /**
+     * @return the policyType
+     */
+    public String getPolicyType() {
+        return policyType;
+    }
+
+    /**
+     * @param policyType
+     *        the policyType to set
+     */
+    public void setPolicyType(String policyType) {
+        this.policyType = policyType;
+    }
+
+    /**
+     * @return the toscaModelName
+     */
+    public String getToscaModelName() {
+        return toscaModelName;
+    }
+
+    /**
+     * @param toscaModelName
+     *        the toscaModelName to set
+     */
+    public void setToscaModelName(String toscaModelName) {
+        this.toscaModelName = toscaModelName;
+    }
+
+    /**
+     * @return the toscaModelYaml
+     */
+    @Override
+    public String getToscaModelYaml() {
+        return toscaModelYaml;
+    }
+
+    /**
+     * @param toscaModelYaml
+     *        the toscaModelYaml to set
+     */
+    @Override
+    public void setToscaModelYaml(String toscaModelYaml) {
+        this.toscaModelYaml = toscaModelYaml;
+    }
+
+}
diff --git a/src/main/java/org/onap/clamp/clds/model/CldsToscaModelDetails.java b/src/main/java/org/onap/clamp/clds/model/CldsToscaModelDetails.java
new file mode 100644
index 0000000..5c6f4aa
--- /dev/null
+++ b/src/main/java/org/onap/clamp/clds/model/CldsToscaModelDetails.java
@@ -0,0 +1,132 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP CLAMP
+ * ================================================================================
+ * Copyright (C) 2018 AT&T Intellectual Property. All rights
+ *                             reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END============================================
+ * ===================================================================
+ *
+ */
+
+package org.onap.clamp.clds.model;
+
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * Represents a CLDS Tosca model
+ *
+ */
+public class CldsToscaModelDetails {
+
+    private String id;
+    private String toscaModelName;
+    private String policyType;
+    private List<CldsToscaModelRevision> toscaModelRevisions = new ArrayList<>();
+    private String userId;
+    private String lastUpdatedDate;
+
+    /**
+     * @return the id
+     */
+    public String getId() {
+        return id;
+    }
+
+    /**
+     * @param id
+     *        the id to set
+     */
+    public void setId(String id) {
+        this.id = id;
+    }
+
+    /**
+     * @return the toscaModelName
+     */
+    public String getToscaModelName() {
+        return toscaModelName;
+    }
+
+    /**
+     * @param toscaModelName
+     *        the toscaModelName to set
+     */
+    public void setToscaModelName(String toscaModelName) {
+        this.toscaModelName = toscaModelName;
+    }
+
+    /**
+     * @return the policyType
+     */
+    public String getPolicyType() {
+        return policyType;
+    }
+
+    /**
+     * @param policyType
+     *        the policyType to set
+     */
+    public void setPolicyType(String policyType) {
+        this.policyType = policyType;
+    }
+
+    /**
+     * @return the toscaModelRevisions
+     */
+    public List<CldsToscaModelRevision> getToscaModelRevisions() {
+        return toscaModelRevisions;
+    }
+
+    /**
+     * @param toscaModelRevisions
+     *        the toscaModelRevisions to set
+     */
+    public void setToscaModelRevisions(List<CldsToscaModelRevision> toscaModelRevisions) {
+        this.toscaModelRevisions = toscaModelRevisions;
+    }
+
+    /**
+     * @return the userId
+     */
+    public String getUserId() {
+        return userId;
+    }
+
+    /**
+     * @param userId
+     *        the userId to set
+     */
+    public void setUserId(String userId) {
+        this.userId = userId;
+    }
+
+    /**
+     * @return the lastUpdatedDate
+     */
+    public String getLastUpdatedDate() {
+        return lastUpdatedDate;
+    }
+
+    /**
+     * @param lastUpdatedDate
+     *        the lastUpdatedDate to set
+     */
+    public void setLastUpdatedDate(String lastUpdatedDate) {
+        this.lastUpdatedDate = lastUpdatedDate;
+    }
+
+}
diff --git a/src/main/java/org/onap/clamp/clds/model/CldsToscaModelRevision.java b/src/main/java/org/onap/clamp/clds/model/CldsToscaModelRevision.java
new file mode 100644
index 0000000..bfb0536
--- /dev/null
+++ b/src/main/java/org/onap/clamp/clds/model/CldsToscaModelRevision.java
@@ -0,0 +1,144 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP CLAMP
+ * ================================================================================
+ * Copyright (C) 2018 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============================================
+ * ===================================================================
+ *
+ */
+
+/**
+ * Represents a CLDS Tosca model revision
+ *
+ */
+package org.onap.clamp.clds.model;
+
+public class CldsToscaModelRevision {
+
+    private String revisionId;
+    private String toscaModelYaml;
+    private double version;
+    private String toscaModelJson;
+    private String userId;
+    private String createdDate;
+    private String lastUpdatedDate;
+
+    /**
+     * @return the revisionId
+     */
+    public String getRevisionId() {
+        return revisionId;
+    }
+
+    /**
+     * @param revisionId
+     *        the revisionId to set
+     */
+    public void setRevisionId(String revisionId) {
+        this.revisionId = revisionId;
+    }
+
+    /**
+     * @return the toscaModelYaml
+     */
+    public String getToscaModelYaml() {
+        return toscaModelYaml;
+    }
+
+    /**
+     * @param toscaModelYaml
+     *        the toscaModelYaml to set
+     */
+    public void setToscaModelYaml(String toscaModelYaml) {
+        this.toscaModelYaml = toscaModelYaml;
+    }
+
+    /**
+     * @return the version
+     */
+    public double getVersion() {
+        return version;
+    }
+
+    /**
+     * @param version
+     *        the version to set
+     */
+    public void setVersion(double version) {
+        this.version = version;
+    }
+
+    /**
+     * @return the toscaModelJson
+     */
+    public String getToscaModelJson() {
+        return toscaModelJson;
+    }
+
+    /**
+     * @param toscaModelJson
+     *        the toscaModelJson to set
+     */
+    public void setToscaModelJson(String toscaModelJson) {
+        this.toscaModelJson = toscaModelJson;
+    }
+
+    /**
+     * @return the userId
+     */
+    public String getUserId() {
+        return userId;
+    }
+
+    /**
+     * @param userId
+     *        the userId to set
+     */
+    public void setUserId(String userId) {
+        this.userId = userId;
+    }
+
+    /**
+     * @return the createdDate
+     */
+    public String getCreatedDate() {
+        return createdDate;
+    }
+
+    /**
+     * @param createdDate
+     *        the createdDate to set
+     */
+    public void setCreatedDate(String createdDate) {
+        this.createdDate = createdDate;
+    }
+
+    /**
+     * @return the lastUpdatedDate
+     */
+    public String getLastUpdatedDate() {
+        return lastUpdatedDate;
+    }
+
+    /**
+     * @param lastUpdatedDate
+     *        the lastUpdatedDate to set
+     */
+    public void setLastUpdatedDate(String lastUpdatedDate) {
+        this.lastUpdatedDate = lastUpdatedDate;
+    }
+}
diff --git a/src/main/java/org/onap/clamp/clds/service/CldsDictionaryService.java b/src/main/java/org/onap/clamp/clds/service/CldsDictionaryService.java
new file mode 100644
index 0000000..5d5e218
--- /dev/null
+++ b/src/main/java/org/onap/clamp/clds/service/CldsDictionaryService.java
@@ -0,0 +1,149 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP CLAMP
+ * ================================================================================
+ * Copyright (C) 2018 AT&T Intellectual Property. All rights
+ *                             reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END============================================
+ * ===================================================================
+ *
+ */
+
+package org.onap.clamp.clds.service;
+
+import java.util.Date;
+import java.util.List;
+
+import javax.annotation.PostConstruct;
+
+import org.onap.clamp.clds.dao.CldsDao;
+import org.onap.clamp.clds.model.CldsDictionary;
+import org.onap.clamp.clds.model.CldsDictionaryItem;
+import org.onap.clamp.clds.util.LoggingUtils;
+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;
+
+/**
+ * REST services to manage dictionary and dictionary items for Tosca Model
+ */
+@Component
+public class CldsDictionaryService extends SecureServiceBase {
+
+	@Value("${clamp.config.security.permission.type.tosca:permission-type-tosca}")
+	private String cldsPermissionTypeTosca;
+	@Value("${clamp.config.security.permission.instance:dev}")
+	private String cldsPermissionInstance;
+	private SecureServicePermission permissionReadTosca;
+	private SecureServicePermission permissionUpdateTosca;
+
+	@Autowired
+	private CldsDao cldsDao;
+
+	@PostConstruct
+	private final void initConstruct() {
+		permissionReadTosca = SecureServicePermission.create(cldsPermissionTypeTosca, cldsPermissionInstance, "read");
+        permissionUpdateTosca = SecureServicePermission.create(cldsPermissionTypeTosca, cldsPermissionInstance, "update");
+	}
+
+	/**
+	 *  REST Service that creates or Updates a Dictionary
+	 *  
+	 * @param dictionaryName
+	 * @param cldsDictionary
+	 * @return CldsDictionary that was created in DB.
+	 */
+	public ResponseEntity<CldsDictionary> createOrUpdateDictionary(String dictionaryName,
+			CldsDictionary cldsDictionary) {
+		Date startTime = new Date();
+		LoggingUtils.setRequestContext("CldsDictionaryService: createOrUpdateDictionary", getPrincipalName());
+		// TODO revisit based on new permissions
+		isAuthorized(permissionUpdateTosca);
+		if (cldsDictionary == null) {
+			cldsDictionary = new CldsDictionary();
+			cldsDictionary.setDictionaryName(dictionaryName);
+		}
+		cldsDictionary.save(dictionaryName, cldsDao, getUserId());
+		LoggingUtils.setTimeContext(startTime, new Date());
+		LoggingUtils.setResponseContext("0", "createOrUpdateDictionary success", this.getClass().getName());
+		auditLogger.info("createOrUpdateDictionary completed");
+		return new ResponseEntity<>(cldsDictionary, HttpStatus.OK);
+	}
+
+	/**
+	 * REST Service that creates or Updates a Dictionary Elements for dictionary in DB
+	 * 
+	 * @param dictionaryName
+	 * @param dictionaryItem
+	 * @return CldsDictionaryItem
+	 * 			A dictionary items that was created or updated in DB
+	 */
+	public ResponseEntity<CldsDictionaryItem> createOrUpdateDictionaryElements(String dictionaryName,
+			CldsDictionaryItem dictionaryItem) {
+		Date startTime = new Date();
+		LoggingUtils.setRequestContext("CldsDictionaryService: createOrUpdateDictionaryElements", getPrincipalName());
+		// TODO revisit based on new permissions
+		isAuthorized(permissionUpdateTosca);
+		dictionaryItem.save(dictionaryName, cldsDao, getUserId());
+		LoggingUtils.setTimeContext(startTime, new Date());
+		LoggingUtils.setResponseContext("0", "createOrUpdateDictionaryElements success", this.getClass().getName());
+		auditLogger.info("createOrUpdateDictionaryElements completed");
+		return new ResponseEntity<>(dictionaryItem, HttpStatus.OK);
+	}
+
+	/**
+	 * Rest Service that retrieves all CLDS dictionary in DB
+	 * 
+	 * @return CldsDictionary List
+	 * 			List of CldsDictionary available in DB
+	 */
+	public ResponseEntity<List<CldsDictionary>> getAllDictionaryNames() {
+		Date startTime = new Date();
+		LoggingUtils.setRequestContext("CldsDictionaryService: getAllDictionaryNames", getPrincipalName());
+		// TODO revisit based on new permissions
+		isAuthorized(permissionReadTosca);
+		List<CldsDictionary> dictionaries = cldsDao.getDictionary(null, null);
+		LoggingUtils.setTimeContext(startTime, new Date());
+		LoggingUtils.setResponseContext("0", "getAllDictionaryNames success", this.getClass().getName());
+		auditLogger.info("getAllDictionaryNames completed");
+		return new ResponseEntity<>(dictionaries, HttpStatus.OK);
+	}
+
+	/**
+	 * Rest Service that retrieves all CLDS dictionary items in DB for a give dictionary name
+	 * 
+	 * @param dictionaryName
+	 * @return CldsDictionaryItem list
+	 * 			List of CLDS Dictionary items for a given dictionary name
+	 */
+	public ResponseEntity<List<CldsDictionaryItem>> getDictionaryElementsByName(String dictionaryName) {
+		Date startTime = new Date();
+		LoggingUtils.setRequestContext("CldsDictionaryService: getDictionaryElementsByName", getPrincipalName());
+		// TODO revisit based on new permissions
+		isAuthorized(permissionReadTosca);
+		List<CldsDictionaryItem> dictionaryItems = cldsDao.getDictionaryElements(dictionaryName, null, null);
+		LoggingUtils.setTimeContext(startTime, new Date());
+		LoggingUtils.setResponseContext("0", "getAllDictionaryNames success", this.getClass().getName());
+		auditLogger.info("getAllDictionaryNames completed");
+		return new ResponseEntity<>(dictionaryItems, HttpStatus.OK);
+	}
+
+	public ResponseEntity<?> deleteDictionary() {
+		return null;
+	}
+
+}
diff --git a/src/main/java/org/onap/clamp/clds/service/CldsInfoProvider.java b/src/main/java/org/onap/clamp/clds/service/CldsInfoProvider.java
index 6bebde9..7027cf1 100644
--- a/src/main/java/org/onap/clamp/clds/service/CldsInfoProvider.java
+++ b/src/main/java/org/onap/clamp/clds/service/CldsInfoProvider.java
@@ -45,6 +45,8 @@
         cldsInfo.setPermissionUpdateCl(cldsService.isAuthorizedNoException(cldsService.permissionUpdateCl));
         cldsInfo.setPermissionReadTemplate(cldsService.isAuthorizedNoException(cldsService.permissionReadTemplate));
         cldsInfo.setPermissionUpdateTemplate(cldsService.isAuthorizedNoException(cldsService.permissionUpdateTemplate));
+        cldsInfo.setPermissionReadTosca(cldsService.isAuthorizedNoException(cldsService.permissionReadTosca));
+        cldsInfo.setPermissionUpdateTosca(cldsService.isAuthorizedNoException(cldsService.permissionUpdateTosca));
         return cldsInfo;
     }
 }
diff --git a/src/main/java/org/onap/clamp/clds/service/CldsService.java b/src/main/java/org/onap/clamp/clds/service/CldsService.java
index bc58ee6..521f3ce 100644
--- a/src/main/java/org/onap/clamp/clds/service/CldsService.java
+++ b/src/main/java/org/onap/clamp/clds/service/CldsService.java
@@ -105,6 +105,8 @@
     final SecureServicePermission permissionUpdateCl;
     final SecureServicePermission permissionReadTemplate;
     final SecureServicePermission permissionUpdateTemplate;
+    final SecureServicePermission permissionReadTosca;
+    final SecureServicePermission permissionUpdateTosca;
 
     private final CldsDao cldsDao;
     private final XslTransformer cldsBpmnTransformer;
@@ -125,6 +127,7 @@
         @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;
@@ -144,6 +147,9 @@
             "read");
         permissionUpdateTemplate = SecureServicePermission.create(cldsPermissionTypeTemplate, cldsPermissionInstance,
             "update");
+        permissionReadTosca = SecureServicePermission.create(cldsPermissionTypeTosca, cldsPermissionInstance, "read");
+        permissionUpdateTosca = SecureServicePermission.create(cldsPermissionTypeTosca, cldsPermissionInstance,
+                "update");
     }
 
     /*
@@ -401,7 +407,7 @@
                 retrievedModel = CldsModel.retrieve(cldsDao, modelName, false);
             }
             if (retrievedModel != null) {
-                if (!isTest && (actionCd.equalsIgnoreCase(CldsEvent.ACTION_SUBMIT)
+                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)) {
diff --git a/src/main/java/org/onap/clamp/clds/service/CldsToscaService.java b/src/main/java/org/onap/clamp/clds/service/CldsToscaService.java
new file mode 100644
index 0000000..f33039f
--- /dev/null
+++ b/src/main/java/org/onap/clamp/clds/service/CldsToscaService.java
@@ -0,0 +1,149 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP CLAMP
+ * ================================================================================
+ * Copyright (C) 2018 AT&T Intellectual Property. All rights
+ *                             reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END============================================
+ * ===================================================================
+ *
+ */
+
+package org.onap.clamp.clds.service;
+
+import java.util.Date;
+import java.util.List;
+import java.util.Optional;
+
+import javax.annotation.PostConstruct;
+
+import org.onap.clamp.clds.dao.CldsDao;
+import org.onap.clamp.clds.model.CldsToscaModel;
+import org.onap.clamp.clds.util.LoggingUtils;
+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;
+
+/**
+ * REST services to manage Tosca Model
+ */
+@Component
+public class CldsToscaService extends SecureServiceBase {
+
+	@Value("${clamp.config.security.permission.type.tosca:permission-type-tosca}")
+	private String cldsPermissionTypeTosca;
+	@Value("${clamp.config.security.permission.instance:dev}")
+	private String cldsPermissionInstance;
+	private SecureServicePermission permissionReadTosca;
+	private SecureServicePermission permissionUpdateTosca;
+
+	@Autowired
+	private CldsDao cldsDao;
+
+	@PostConstruct
+	private final void initConstruct() {
+		permissionReadTosca = SecureServicePermission.create(cldsPermissionTypeTosca, cldsPermissionInstance, "read");
+        permissionUpdateTosca = SecureServicePermission.create(cldsPermissionTypeTosca, cldsPermissionInstance, "update");
+	}
+	
+	/**
+	 * REST service to upload a new Tosca Model or update an existing Tosca model with new version.
+	 * This API will parse the Tosca model yaml and generates a JSON schema out of it.
+	 * 
+	 * @param toscaModelName
+	 * 			Tosca model name to be used as a key
+	 * @param cldsToscaModel
+	 *          Object containing the tosca model yaml
+	 * 
+	 * @return clds tosca models - list of CLDS tosca models for a given policy type 
+	 */
+	public ResponseEntity<?> parseToscaModelAndSave(String toscaModelName, CldsToscaModel cldsToscaModel ) {
+        Date startTime = new Date();
+        LoggingUtils.setRequestContext("CldsToscaService: Parse Tosca model and save", getPrincipalName());
+        //TODO revisit based on new permissions
+        isAuthorized(permissionUpdateTosca);
+        cldsToscaModel.setToscaModelName(toscaModelName);
+        cldsToscaModel = cldsToscaModel.save(cldsDao, getUserId());
+        LoggingUtils.setTimeContext(startTime, new Date());
+        LoggingUtils.setResponseContext("0", "Parse Tosca model and save success", this.getClass().getName());
+        auditLogger.info("Parse Tosca model and save completed");
+        return new ResponseEntity<>(cldsToscaModel, HttpStatus.CREATED);
+	}
+	
+	/**
+	 * REST service to retrieve all Tosca models from the CLDS database.
+	 * 
+	 * @return clds tosca models - list of CLDS tosca models 
+	 */
+	public ResponseEntity<List<CldsToscaModel>> getAllToscaModels() {
+		
+		Date startTime = new Date();
+        LoggingUtils.setRequestContext("CldsToscaService: Get All tosca models", getPrincipalName());
+        //TODO revisit based on new permissions
+        isAuthorized(permissionReadTosca);
+        List<CldsToscaModel> cldsToscaModels = Optional.ofNullable(cldsDao.getAllToscaModels()).get();
+        LoggingUtils.setTimeContext(startTime, new Date());
+        LoggingUtils.setResponseContext("0", "Get All tosca models success", this.getClass().getName());
+        auditLogger.info("Get All tosca models");
+        return new ResponseEntity<>(cldsToscaModels, HttpStatus.OK);
+	}
+	
+	/**
+	 * REST service that retrieves a CLDS Tosca model by model name from the database.
+	 * 
+	 * @param toscaModelName
+	 * 			Path param with tosca model name
+	 * 
+	 * @return clds tosca model -  CLDS tosca model for a given tosca model name 
+	 */
+	public ResponseEntity<CldsToscaModel> getToscaModel(String toscaModelName) {
+		Date startTime = new Date();
+        LoggingUtils.setRequestContext("CldsToscaService: Get tosca models by model name", getPrincipalName());
+        //TODO revisit based on new permissions
+        isAuthorized(permissionReadTosca);
+        List<CldsToscaModel> cldsToscaModels = Optional.ofNullable(cldsDao.getToscaModelByName(toscaModelName)).get();
+        LoggingUtils.setTimeContext(startTime, new Date());
+        LoggingUtils.setResponseContext("0", "Get tosca models by model name success", this.getClass().getName());
+        auditLogger.info("GET tosca models by model name completed");
+        return new ResponseEntity<>(Optional.ofNullable(cldsToscaModels).get().stream().findFirst().get(), HttpStatus.OK);
+	}
+
+	
+	/**
+	 * REST service that retrieves a CLDS Tosca model lists for a policy type from the database.
+	 * 
+	 * @param policyType
+	 * @return clds tosca model -  CLDS tosca model for a given policy type 
+	 */
+	public ResponseEntity<CldsToscaModel> getToscaModelsByPolicyType(String policyType) {
+		Date startTime = new Date();
+        LoggingUtils.setRequestContext("CldsToscaService: Get tosca models by policyType", getPrincipalName());
+        //TODO revisit based on new permissions
+        isAuthorized(permissionReadTosca);
+        List<CldsToscaModel> cldsToscaModels = Optional.ofNullable(cldsDao.getToscaModelByPolicyType(policyType)).get();
+        LoggingUtils.setTimeContext(startTime, new Date());
+        LoggingUtils.setResponseContext("0", "Get tosca models by policyType success", this.getClass().getName());
+        auditLogger.info("GET tosca models by policyType completed");
+        return new ResponseEntity<>(Optional.ofNullable(cldsToscaModels).get().stream().findFirst().get(), HttpStatus.OK);
+	}
+	
+	public ResponseEntity<?> deleteToscaModelById(String toscaModeId) {
+		//TODO
+		return null;
+	}
+	
+}
diff --git a/src/main/resources/clds/camel/rest/clds-services.xml b/src/main/resources/clds/camel/rest/clds-services.xml
index 1ea8213..b63591f 100644
--- a/src/main/resources/clds/camel/rest/clds-services.xml
+++ b/src/main/resources/clds/camel/rest/clds-services.xml
@@ -64,7 +64,7 @@
 				
 				
 				
-				<get uri="/cldsTempate/template/bpmn/{templateName}" produces="text/xml">
+				<get uri="/cldsTempate/template/bpmn/{templateName}" produces="text/xml" >
 						<to
 								uri="bean:org.onap.clamp.clds.service.CldsTemplateService?method=getBpmnTemplate(${header.templateName})" />
 				</get>
@@ -86,6 +86,43 @@
 				</get>
 				
 				
+				<put uri="/tosca/models/{toscaModelName}" type="org.onap.clamp.clds.model.CldsToscaModel" consumes="application/json" produces="application/json">
+						<to
+								uri="bean:org.onap.clamp.clds.service.CldsToscaService?method=parseToscaModelAndSave(${header.toscaModelName},${body})" />
+				</put>
+				<get uri="/tosca/models/policyType/{policyType}" produces="application/json">
+						<to
+								uri="bean:org.onap.clamp.clds.service.CldsToscaService?method=getToscaModelsByPolicyType(${header.policyType})" />
+				</get>
+				<get uri="/tosca/models" outType="org.onap.clamp.clds.model.CldsToscaModel" produces="application/json">
+						<to
+								uri="bean:org.onap.clamp.clds.service.CldsToscaService?method=getAllToscaModels()" />
+				</get>	
+				<get uri="/tosca/models/{toscaModelName}" outType="org.onap.clamp.clds.model.CldsToscaModel" produces="application/json">
+						<to
+								uri="bean:org.onap.clamp.clds.service.CldsToscaService?method=getToscaModel(${header.toscaModelName})" />
+				</get>
+				
+				
+				<put uri="/dictionary/{dictionaryName}" type="org.onap.clamp.clds.model.CldsDictionary" outType="org.onap.clamp.clds.model.CldsDictionary" consumes="application/json" produces="application/json">
+						<to
+								uri="bean:org.onap.clamp.clds.service.CldsDictionaryService?method=createOrUpdateDictionary(${header.dictionaryName},${body})" />
+				</put>
+				
+				<get uri="/dictionary" outType="org.onap.clamp.clds.model.CldsDictionary" produces="application/json">
+						<to
+								uri="bean:org.onap.clamp.clds.service.CldsDictionaryService?method=getAllDictionaryNames()" />
+				</get>
+				
+				<put uri="/dictionary/{dictionaryName}/items" type="org.onap.clamp.clds.model.CldsDictionaryItem" outType="org.onap.clamp.clds.model.CldsDictionaryItem" consumes="application/json" produces="application/json">
+						<to
+								uri="bean:org.onap.clamp.clds.service.CldsDictionaryService?method=createOrUpdateDictionaryElements(${header.dictionaryName},${body})" />
+				</put>
+				
+				<get uri="/dictionary/{dictionaryName}/items" outType="org.onap.clamp.clds.model.CldsDictionary" produces="application/json">
+						<to
+								uri="bean:org.onap.clamp.clds.service.CldsDictionaryService?method=getDictionaryElementsByName(${header.dictionaryName})" />
+				</get>
 				
 				<get uri="/user/getUser" produces="text/plain">
 						<to