Remove dead code 29/95329/1
authorsebdet <sebastien.determe@intl.att.com>
Tue, 10 Sep 2019 10:25:47 +0000 (12:25 +0200)
committersebdet <sebastien.determe@intl.att.com>
Tue, 10 Sep 2019 10:25:47 +0000 (12:25 +0200)
Removal of deprecated v1 interface code, sql cleaned up as well, old
model removed from database

Issue-ID: CLAMP-487
Change-Id: I4a9f14de9ea1c1b76c522581d75cf4b011c2aa01
Signed-off-by: sebdet <sebastien.determe@intl.att.com>
95 files changed:
extra/sql/bulkload/clds-create-db-objects.sql [deleted file]
extra/sql/bulkload/clds-stored-procedures.sql [deleted file]
extra/sql/bulkload/create-db.sql [new file with mode: 0644]
extra/sql/drop/clds-drop-db-objects.sql [deleted file]
extra/sql/load-sql-files-tests-automation.sh
src/main/java/org/onap/clamp/clds/Application.java
src/main/java/org/onap/clamp/clds/client/CldsEventDelegate.java [deleted file]
src/main/java/org/onap/clamp/clds/client/DcaeDispatcherServices.java [deleted file]
src/main/java/org/onap/clamp/clds/client/DcaeInventoryServices.java
src/main/java/org/onap/clamp/clds/client/GuardPolicyDelegate.java [deleted file]
src/main/java/org/onap/clamp/clds/client/GuardPolicyDeleteDelegate.java [deleted file]
src/main/java/org/onap/clamp/clds/client/HolmesPolicyDelegate.java [deleted file]
src/main/java/org/onap/clamp/clds/client/HolmesPolicyDeleteDelegate.java [deleted file]
src/main/java/org/onap/clamp/clds/client/ModelDeleteDelegate.java [deleted file]
src/main/java/org/onap/clamp/clds/client/OperationalPolicyDelegate.java [deleted file]
src/main/java/org/onap/clamp/clds/client/OperationalPolicyDeleteDelegate.java [deleted file]
src/main/java/org/onap/clamp/clds/client/TcaPolicyDelegate.java [deleted file]
src/main/java/org/onap/clamp/clds/client/TcaPolicyDeleteDelegate.java [deleted file]
src/main/java/org/onap/clamp/clds/client/req/policy/GuardPolicyAttributesConstructor.java [deleted file]
src/main/java/org/onap/clamp/clds/client/req/policy/OperationalPolicyAttributesConstructor.java [deleted file]
src/main/java/org/onap/clamp/clds/client/req/policy/OperationalPolicyYamlFormatter.java [deleted file]
src/main/java/org/onap/clamp/clds/client/req/policy/PolicyClient.java [deleted file]
src/main/java/org/onap/clamp/clds/client/req/tca/TcaRequestFormatter.java [deleted file]
src/main/java/org/onap/clamp/clds/config/spring/CldsConfiguration.java
src/main/java/org/onap/clamp/clds/dao/CldsDao.java [deleted file]
src/main/java/org/onap/clamp/clds/dao/ValueItemMapper.java [deleted file]
src/main/java/org/onap/clamp/clds/model/CldsAlarmCondition.java [deleted file]
src/main/java/org/onap/clamp/clds/model/CldsDbServiceCache.java [deleted file]
src/main/java/org/onap/clamp/clds/model/CldsDictionary.java
src/main/java/org/onap/clamp/clds/model/CldsDictionaryItem.java
src/main/java/org/onap/clamp/clds/model/CldsEvent.java [deleted file]
src/main/java/org/onap/clamp/clds/model/CldsHealthCheck.java
src/main/java/org/onap/clamp/clds/model/CldsModel.java [deleted file]
src/main/java/org/onap/clamp/clds/model/CldsModelInstance.java [deleted file]
src/main/java/org/onap/clamp/clds/model/CldsModelProp.java [deleted file]
src/main/java/org/onap/clamp/clds/model/CldsServiceData.java [deleted file]
src/main/java/org/onap/clamp/clds/model/CldsTemplate.java [deleted file]
src/main/java/org/onap/clamp/clds/model/CldsToscaModel.java [deleted file]
src/main/java/org/onap/clamp/clds/model/CldsToscaModelDetails.java [deleted file]
src/main/java/org/onap/clamp/clds/model/CldsToscaModelRevision.java [deleted file]
src/main/java/org/onap/clamp/clds/model/CldsVfData.java [deleted file]
src/main/java/org/onap/clamp/clds/model/CldsVfKPIData.java [deleted file]
src/main/java/org/onap/clamp/clds/model/CldsVfcData.java [deleted file]
src/main/java/org/onap/clamp/clds/model/DcaeEvent.java [deleted file]
src/main/java/org/onap/clamp/clds/model/ValueItem.java [deleted file]
src/main/java/org/onap/clamp/clds/model/actions/ActionsHandler.java [deleted file]
src/main/java/org/onap/clamp/clds/model/actions/ActionsHandlerImpl.java [deleted file]
src/main/java/org/onap/clamp/clds/model/properties/AbstractModelElement.java [deleted file]
src/main/java/org/onap/clamp/clds/model/properties/Global.java [deleted file]
src/main/java/org/onap/clamp/clds/model/properties/Holmes.java [deleted file]
src/main/java/org/onap/clamp/clds/model/properties/ModelBpmn.java [deleted file]
src/main/java/org/onap/clamp/clds/model/properties/ModelBpmnEntry.java [deleted file]
src/main/java/org/onap/clamp/clds/model/properties/ModelProperties.java [deleted file]
src/main/java/org/onap/clamp/clds/model/properties/Policy.java [deleted file]
src/main/java/org/onap/clamp/clds/model/properties/PolicyChain.java [deleted file]
src/main/java/org/onap/clamp/clds/model/properties/PolicyItem.java [deleted file]
src/main/java/org/onap/clamp/clds/model/properties/Tca.java [deleted file]
src/main/java/org/onap/clamp/clds/model/properties/TcaItem.java [deleted file]
src/main/java/org/onap/clamp/clds/model/properties/TcaThreshold.java [deleted file]
src/main/java/org/onap/clamp/clds/model/status/StatusHandler.java [deleted file]
src/main/java/org/onap/clamp/clds/model/status/StatusHandlerImpl.java [deleted file]
src/main/java/org/onap/clamp/clds/service/CldsHealthcheckService.java
src/main/java/org/onap/clamp/clds/tosca/ToscaYamlToJsonConvertor.java
src/main/java/org/onap/clamp/clds/transform/XslTransformer.java [deleted file]
src/main/java/org/onap/clamp/clds/util/JsonUtils.java
src/main/java/org/onap/clamp/policy/microservice/MicroServicePolicy.java
src/test/java/org/onap/clamp/clds/client/CldsEventDelegateTest.java [deleted file]
src/test/java/org/onap/clamp/clds/client/DcaeDispatcherServicesTest.java [deleted file]
src/test/java/org/onap/clamp/clds/client/GuardPolicyDelegateTest.java [deleted file]
src/test/java/org/onap/clamp/clds/client/GuardPolicyDeleteDelegateTest.java [deleted file]
src/test/java/org/onap/clamp/clds/client/HolmesPolicyDelegateTest.java [deleted file]
src/test/java/org/onap/clamp/clds/client/HolmesPolicyDeleteDelegateTest.java [deleted file]
src/test/java/org/onap/clamp/clds/client/ModelDeleteDelegateTest.java [deleted file]
src/test/java/org/onap/clamp/clds/client/OperationalPolicyDelegateTest.java [deleted file]
src/test/java/org/onap/clamp/clds/client/OperationalPolicyDeleteDelegateTest.java [deleted file]
src/test/java/org/onap/clamp/clds/client/TcaPolicyDelegateTest.java [deleted file]
src/test/java/org/onap/clamp/clds/client/TcaPolicyDeleteDelegateTest.java [deleted file]
src/test/java/org/onap/clamp/clds/client/req/policy/GuardPolicyAttributesConstructorTest.java [deleted file]
src/test/java/org/onap/clamp/clds/client/req/policy/OperationalPolicyAttributesConstructorTest.java [deleted file]
src/test/java/org/onap/clamp/clds/client/req/policy/OperationalPolicyYamlFormatterTest.java [deleted file]
src/test/java/org/onap/clamp/clds/client/req/tca/TcaRequestFormatterTest.java [deleted file]
src/test/java/org/onap/clamp/clds/it/CldsDaoItCase.java [deleted file]
src/test/java/org/onap/clamp/clds/it/CldsServiceItCase.java
src/test/java/org/onap/clamp/clds/it/HolmesPolicyDelegateItCase.java [deleted file]
src/test/java/org/onap/clamp/clds/it/OperationPolicyReqItCase.java [deleted file]
src/test/java/org/onap/clamp/clds/it/PolicyClientItCase.java [deleted file]
src/test/java/org/onap/clamp/clds/it/TcaRequestFormatterItCase.java [deleted file]
src/test/java/org/onap/clamp/clds/model/CldsDbServiceCacheTest.java [deleted file]
src/test/java/org/onap/clamp/clds/model/CldsModelTest.java [deleted file]
src/test/java/org/onap/clamp/clds/model/DcaeEventTest.java [deleted file]
src/test/java/org/onap/clamp/clds/model/prop/CustomModelElement.java [deleted file]
src/test/java/org/onap/clamp/clds/model/prop/CustomModelElementTest.java [deleted file]
src/test/java/org/onap/clamp/clds/model/prop/ModelPropertiesTest.java [deleted file]
src/test/java/org/onap/clamp/clds/tosca/ToscaYamlToJsonConvertorTest.java
src/test/java/org/onap/clamp/clds/transform/XslTransformerTest.java [deleted file]

diff --git a/extra/sql/bulkload/clds-create-db-objects.sql b/extra/sql/bulkload/clds-create-db-objects.sql
deleted file mode 100644 (file)
index aa3aa65..0000000
+++ /dev/null
@@ -1,225 +0,0 @@
-#
-# Create CLDS database objects (tables, etc.)
-#
-#
-CREATE DATABASE `cldsdb4`;
-USE `cldsdb4`;
-DROP USER 'clds';
-CREATE USER 'clds';
-GRANT ALL on cldsdb4.* to 'clds' identified by 'sidnnd83K' with GRANT OPTION;
-GRANT SELECT on mysql.proc TO 'clds';
-FLUSH PRIVILEGES;
-
-
-CREATE TABLE template (
-  template_id VARCHAR(36) NOT NULL,
-  template_name VARCHAR(80) NOT NULL,
-  template_bpmn_id VARCHAR(36) NULL,
-  template_image_id VARCHAR(36) NULL,
-  template_doc_id VARCHAR(36) NULL,
-  PRIMARY KEY (template_id),
-  UNIQUE (template_name)
-) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE utf8_bin;
-
-CREATE TABLE template_bpmn (
-  template_bpmn_id VARCHAR(36) NOT NULL,
-  template_id VARCHAR(36) NOT NULL,
-  template_bpmn_text MEDIUMTEXT NOT NULL,
-  user_id VARCHAR(80),
-  timestamp TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
-  PRIMARY KEY (template_bpmn_id)
-) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE utf8_bin;
-
-CREATE TABLE template_image (
-  template_image_id VARCHAR(36) NOT NULL,
-  template_id VARCHAR(36) NOT NULL,
-  template_image_text MEDIUMTEXT NULL,
-  user_id VARCHAR(80),
-  timestamp TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
-  PRIMARY KEY (template_image_id)
-) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE utf8_bin;
-
-CREATE TABLE template_doc (
-  template_doc_id VARCHAR(36) NOT NULL,
-  template_id VARCHAR(36) NOT NULL,
-  template_doc_text MEDIUMTEXT NULL,
-  user_id VARCHAR(80),
-  timestamp TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
-  PRIMARY KEY (template_doc_id)
-) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE utf8_bin;
-
-CREATE TABLE model (
-  model_id VARCHAR(36) NOT NULL,
-  model_name VARCHAR(80) NOT NULL,
-  template_id VARCHAR(36) NULL,
-  model_prop_id VARCHAR(36) NULL,
-  model_blueprint_id VARCHAR(36) NULL,
-  event_id VARCHAR(36) NULL,
-  control_name_prefix VARCHAR(80) NULL,
-  control_name_uuid VARCHAR(36) NOT NULL,
-  service_type_id VARCHAR(80) NULL,
-  deployment_id VARCHAR(80) NULL,
-  deployment_status_url VARCHAR(300) NULL,
-  PRIMARY KEY (model_id),
-  UNIQUE (model_name),
-  UNIQUE (control_name_uuid),
-  UNIQUE (service_type_id),
-  UNIQUE (deployment_id)
-) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE utf8_bin;
-
-CREATE TABLE model_properties (
-  model_prop_id VARCHAR(36) NOT NULL,
-  model_id VARCHAR(36) NOT NULL,
-  model_prop_text MEDIUMTEXT NULL,
-  user_id VARCHAR(80),
-  timestamp TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
-  PRIMARY KEY (model_prop_id)
-) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE utf8_bin;
-
-CREATE TABLE model_blueprint (
-  model_blueprint_id VARCHAR(36) NOT NULL,
-  model_id VARCHAR(36) NOT NULL,
-  model_blueprint_text MEDIUMTEXT NULL,
-  user_id VARCHAR(80),
-  timestamp TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
-  PRIMARY KEY (model_blueprint_id)
-) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE utf8_bin;
-
-CREATE TABLE model_instance (
-  model_instance_id VARCHAR(36) NOT NULL,
-  model_id VARCHAR(36) NOT NULL,
-  vm_name VARCHAR(250) NOT NULL,
-  location VARCHAR(250) NULL,
-  timestamp TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
-  PRIMARY KEY (model_instance_id),
-  UNIQUE (model_id, vm_name)
-) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE utf8_bin;
-
-CREATE TABLE event (
-  event_id VARCHAR(36) NOT NULL,
-  model_id VARCHAR(36) NULL,
-  action_cd VARCHAR(80) NOT NULL,
-  action_state_cd VARCHAR(80) NULL,
-  prev_event_id VARCHAR(36) NULL,
-  process_instance_id VARCHAR(80) NULL,
-  user_id VARCHAR(80) NULL,
-  timestamp TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
-  PRIMARY KEY (event_id)
-) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE utf8_bin;
-
-CREATE TABLE IF NOT EXISTS tosca_model (
-  tosca_model_id VARCHAR(36) NOT NULL,
-  tosca_model_name VARCHAR(80) NOT NULL,
-  policy_type VARCHAR(80) NULL,
-  user_id VARCHAR(80),
-  timestamp TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
-  PRIMARY KEY (tosca_model_id)
-) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE utf8_bin;
-
-CREATE TABLE IF NOT EXISTS tosca_model_revision (
-  tosca_model_revision_id VARCHAR(36) NOT NULL,
-  tosca_model_id VARCHAR(36) NOT NULL,
-  version DOUBLE NOT NULL DEFAULT 1,
-  tosca_model_yaml MEDIUMTEXT NULL,
-  tosca_model_json MEDIUMTEXT NULL,
-  user_id VARCHAR(80),
-  createdTimestamp TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
-  lastUpdatedTimestamp TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
-  PRIMARY KEY (tosca_model_revision_id),
-  CONSTRAINT tosca_model_revision_ukey UNIQUE KEY (tosca_model_id, version),
-  CONSTRAINT tosca_model_revision_fkey01 FOREIGN KEY (tosca_model_id) REFERENCES tosca_model (tosca_model_id)
-) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE utf8_bin;
-
-CREATE TABLE IF NOT EXISTS dictionary (
-  dictionary_id VARCHAR(36) NOT NULL,
-  dictionary_name VARCHAR(80) NOT NULL,
-  created_by VARCHAR(80),
-  modified_by VARCHAR(80),
-  timestamp TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
-  PRIMARY KEY (dictionary_id)
-) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE utf8_bin;
-
-CREATE TABLE IF NOT EXISTS dictionary_elements (
-  dict_element_id VARCHAR(36) NOT NULL,
-  dictionary_id VARCHAR(36) NOT NULL,
-  dict_element_name VARCHAR(250) NOT NULL,
-  dict_element_short_name VARCHAR(80) NOT NULL,
-  dict_element_description VARCHAR(250),
-  dict_element_type VARCHAR(80) NOT NULL,
-  created_by VARCHAR(80),
-  modified_by VARCHAR(80),
-  timestamp TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
-  PRIMARY KEY (dict_element_id),
-  CONSTRAINT dictionary_elements_ukey UNIQUE KEY (dict_element_name, dict_element_short_name),
-  CONSTRAINT dictionary_elements_ukey_fkey01 FOREIGN KEY (dictionary_id) REFERENCES dictionary (dictionary_id)
-) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE utf8_bin;
-
-ALTER TABLE template
-    ADD CONSTRAINT template_bpmn_id_fkey01
-    FOREIGN KEY (template_bpmn_id)
-    REFERENCES template_bpmn (template_bpmn_id);
-
-ALTER TABLE template
-    ADD CONSTRAINT template_image_id_fkey01
-    FOREIGN KEY (template_image_id)
-    REFERENCES template_image (template_image_id);
-
-ALTER TABLE template
-    ADD CONSTRAINT template_doc_id_fkey01
-    FOREIGN KEY (template_doc_id)
-    REFERENCES template_doc (template_doc_id);
-
-ALTER TABLE template_bpmn
-    ADD CONSTRAINT template_id_fkey02
-    FOREIGN KEY (template_id)
-    REFERENCES template (template_id);
-
-ALTER TABLE template_image
-    ADD CONSTRAINT template_id_fkey03
-    FOREIGN KEY (template_id)
-    REFERENCES template (template_id);
-
-ALTER TABLE template_doc
-    ADD CONSTRAINT template_id_fkey04
-    FOREIGN KEY (template_id)
-    REFERENCES template (template_id);
-
-ALTER TABLE model
-    ADD CONSTRAINT template_id_fkey01
-    FOREIGN KEY (template_id)
-    REFERENCES template (template_id);
-
-ALTER TABLE model
-    ADD CONSTRAINT model_prop_id_fkey01
-    FOREIGN KEY (model_prop_id)
-    REFERENCES model_properties (model_prop_id);
-
-ALTER TABLE model
-    ADD CONSTRAINT model_blueprint_id_fkey01
-    FOREIGN KEY (model_blueprint_id)
-    REFERENCES model_blueprint (model_blueprint_id);
-
-ALTER TABLE model
-    ADD CONSTRAINT event_id_fkey01
-    FOREIGN KEY (event_id)
-    REFERENCES event (event_id);
-
-ALTER TABLE model_properties
-    ADD CONSTRAINT model_id_fkey01
-    FOREIGN KEY (model_id)
-    REFERENCES model (model_id);
-
-ALTER TABLE model_blueprint
-    ADD CONSTRAINT model_id_fkey02
-    FOREIGN KEY (model_id)
-    REFERENCES model (model_id);
-
-ALTER TABLE model_instance
-    ADD CONSTRAINT model_id_fkey04
-    FOREIGN KEY (model_id)
-    REFERENCES model (model_id);
-
-ALTER TABLE event
-    ADD CONSTRAINT model_id_fkey03
-    FOREIGN KEY (model_id)
-    REFERENCES model (model_id);
diff --git a/extra/sql/bulkload/clds-stored-procedures.sql b/extra/sql/bulkload/clds-stored-procedures.sql
deleted file mode 100644 (file)
index b48e86a..0000000
+++ /dev/null
@@ -1,534 +0,0 @@
-#
-# CLDS stored procedures
-#
-
-USE cldsdb4;
-
-DROP PROCEDURE IF EXISTS upd_event;
-DROP PROCEDURE IF EXISTS ins_event;
-DROP PROCEDURE IF EXISTS del_all_model_instances;
-DROP PROCEDURE IF EXISTS del_model_instance;
-DROP PROCEDURE IF EXISTS ins_model_instance;
-DROP PROCEDURE IF EXISTS set_model;
-DROP PROCEDURE IF EXISTS get_model;
-DROP PROCEDURE IF EXISTS get_model_template;
-DROP PROCEDURE IF EXISTS set_template;
-DROP PROCEDURE IF EXISTS get_template;
-DROP PROCEDURE IF EXISTS del_model;
-DROP PROCEDURE IF EXISTS set_new_tosca_model_version;
-DROP PROCEDURE IF EXISTS set_tosca_model;
-DROP PROCEDURE IF EXISTS set_dictionary;
-DROP PROCEDURE IF EXISTS set_dictionary_elements;
-DELIMITER //
-CREATE PROCEDURE get_template
-  (IN v_template_name VARCHAR(80),
-   OUT v_template_id VARCHAR(36),
-   OUT v_template_bpmn_id VARCHAR(36),
-   OUT v_template_bpmn_user_id VARCHAR(80),
-   OUT v_template_bpmn_text MEDIUMTEXT,
-   OUT v_template_image_id VARCHAR(36),
-   OUT v_template_image_user_id VARCHAR(80),
-   OUT v_template_image_text MEDIUMTEXT,
-   OUT v_template_doc_id VARCHAR(36),
-   OUT v_template_doc_user_id VARCHAR(80),
-   OUT v_template_doc_text MEDIUMTEXT)
-BEGIN
-  SELECT t.template_id,
-                tb.template_bpmn_id,
-                tb.user_id,
-                tb.template_bpmn_text,
-                ti.template_image_id,
-                ti.user_id,
-                ti.template_image_text,
-                td.template_doc_id,
-                td.user_id,
-                td.template_doc_text
-    INTO v_template_id,
-         v_template_bpmn_id,
-         v_template_bpmn_user_id,
-         v_template_bpmn_text,
-         v_template_image_id,
-         v_template_image_user_id,
-         v_template_image_text,
-         v_template_doc_id,
-         v_template_doc_user_id,
-         v_template_doc_text
-    FROM template t,
-         template_bpmn tb,
-                template_image ti,
-                template_doc td
-    WHERE t.template_bpmn_id = tb.template_bpmn_id
-         AND t.template_image_id = ti.template_image_id
-         AND t.template_doc_id = td.template_doc_id
-      AND t.template_name = v_template_name;
-END;
-CREATE PROCEDURE set_template
-  (IN v_template_name VARCHAR(80),
-   IN v_user_id VARCHAR(80),
-   IN v_template_bpmn_text MEDIUMTEXT,
-   IN v_template_image_text MEDIUMTEXT,
-   IN v_template_doc_text MEDIUMTEXT,
-   OUT v_template_id VARCHAR(36),
-   OUT v_template_bpmn_id VARCHAR(36),
-   OUT v_template_bpmn_user_id VARCHAR(80),
-   OUT v_template_image_id VARCHAR(36),
-   OUT v_template_image_user_id VARCHAR(80),
-   OUT v_template_doc_id VARCHAR(36),
-   OUT v_template_doc_user_id VARCHAR(80))
-BEGIN
-  DECLARE v_old_template_bpmn_text MEDIUMTEXT;
-  DECLARE v_old_template_image_text MEDIUMTEXT;
-  DECLARE v_old_template_doc_text MEDIUMTEXT;
-  SET v_template_id = NULL;
-  CALL get_template(
-    v_template_name,
-    v_template_id,
-    v_template_bpmn_id,
-    v_template_bpmn_user_id,
-    v_old_template_bpmn_text,
-    v_template_image_id,
-    v_template_image_user_id,
-    v_old_template_image_text,
-    v_template_doc_id,
-    v_template_doc_user_id,
-    v_old_template_doc_text);
-  IF v_template_id IS NULL THEN
-    BEGIN
-         SET v_template_id = UUID();
-      INSERT INTO template
-           (template_id, template_name)
-           VALUES (v_template_id, v_template_name);
-       END;
-  END IF;
-  IF v_template_bpmn_id IS NULL OR v_template_bpmn_text <> v_old_template_bpmn_text THEN
-       SET v_template_bpmn_id = UUID();
-    INSERT INTO template_bpmn
-         (template_bpmn_id, template_id, template_bpmn_text, user_id)
-         VALUES (v_template_bpmn_id, v_template_id, v_template_bpmn_text, v_user_id);
-       SET v_template_bpmn_user_id = v_user_id;
-  END IF;
-  IF v_template_image_id IS NULL OR v_template_image_text <> v_old_template_image_text THEN
-       SET v_template_image_id = UUID();
-    INSERT INTO template_image
-         (template_image_id, template_id, template_image_text, user_id)
-         VALUES (v_template_image_id, v_template_id, v_template_image_text, v_user_id);
-       SET v_template_image_user_id = v_user_id;
-  END IF;
-  IF v_template_doc_id IS NULL OR v_template_doc_text <> v_old_template_doc_text THEN
-       SET v_template_doc_id = UUID();
-    INSERT INTO template_doc
-         (template_doc_id, template_id, template_doc_text, user_id)
-         VALUES (v_template_doc_id, v_template_id, v_template_doc_text, v_user_id);
-       SET v_template_doc_user_id = v_user_id;
-  END IF;
-  UPDATE template
-    SET template_bpmn_id = v_template_bpmn_id,
-           template_image_id = v_template_image_id,
-           template_doc_id = v_template_doc_id
-    WHERE template_id = v_template_id;
-END;
-CREATE PROCEDURE get_model
-  (IN v_model_name VARCHAR(80),
-   OUT v_control_name_prefix VARCHAR(80),
-   INOUT v_control_name_uuid VARCHAR(36),
-   OUT v_model_id VARCHAR(36),
-   OUT v_service_type_id VARCHAR(80),
-   OUT v_deployment_id VARCHAR(80),
-   OUT v_deployment_status_url VARCHAR(300),
-   OUT v_template_name VARCHAR(80),
-   OUT v_template_id VARCHAR(36),
-   OUT v_model_prop_id VARCHAR(36),
-   OUT v_model_prop_user_id VARCHAR(80),
-   OUT v_model_prop_text MEDIUMTEXT,
-   OUT v_model_blueprint_id VARCHAR(36),
-   OUT v_model_blueprint_user_id VARCHAR(80),
-   OUT v_model_blueprint_text MEDIUMTEXT,
-   OUT v_event_id VARCHAR(36),
-   OUT v_action_cd VARCHAR(80),
-   OUT v_action_state_cd VARCHAR(80),
-   OUT v_event_process_instance_id VARCHAR(80),
-   OUT v_event_user_id VARCHAR(80))
-BEGIN
-  SELECT m.control_name_prefix,
-                m.control_name_uuid,
-                m.model_id,
-                m.service_type_id,
-                m.deployment_id,
-                m.deployment_status_url,
-                t.template_name,
-                m.template_id,
-                mp.model_prop_id,
-                mp.user_id,
-                mp.model_prop_text,
-                mb.model_blueprint_id,
-                mb.user_id,
-                mb.model_blueprint_text,
-                e.event_id,
-                e.action_cd,
-                e.action_state_cd,
-                e.process_instance_id,
-                e.user_id
-    INTO v_control_name_prefix,
-         v_control_name_uuid,
-                v_model_id,
-                v_service_type_id,
-                v_deployment_id,
-                v_deployment_status_url,
-                v_template_name,
-         v_template_id,
-         v_model_prop_id,
-         v_model_prop_user_id,
-         v_model_prop_text,
-         v_model_blueprint_id,
-         v_model_blueprint_user_id,
-         v_model_blueprint_text,
-         v_event_id,
-         v_action_cd,
-                v_action_state_cd,
-         v_event_process_instance_id,
-         v_event_user_id
-    FROM model m,
-                template t,
-                model_properties mp,
-                model_blueprint mb,
-                event e
-    WHERE m.template_id = t.template_id
-         AND m.model_prop_id = mp.model_prop_id
-         AND m.model_blueprint_id = mb.model_blueprint_id
-         AND m.event_id = e.event_id
-      AND (m.model_name = v_model_name
-      OR  m.control_name_uuid = v_control_name_uuid);
-    SELECT model_instance_id,
-           vm_name,
-           location,
-           timestamp
-    FROM model_instance
-    WHERE model_id = v_model_id
-    ORDER BY 2;
-END;
-CREATE PROCEDURE get_model_template
-  (IN v_model_name VARCHAR(80),
-   OUT v_control_name_prefix VARCHAR(80),
-   INOUT v_control_name_uuid VARCHAR(36),
-   OUT v_model_id VARCHAR(36),
-   OUT v_service_type_id VARCHAR(80),
-   OUT v_deployment_id VARCHAR(80),
-   OUT v_deployment_status_url VARCHAR(300),
-   OUT v_template_name VARCHAR(80),
-   OUT v_template_id VARCHAR(36),
-   OUT v_model_prop_id VARCHAR(36),
-   OUT v_model_prop_user_id VARCHAR(80),
-   OUT v_model_prop_text MEDIUMTEXT,
-   OUT v_model_blueprint_id VARCHAR(36),
-   OUT v_model_blueprint_user_id VARCHAR(80),
-   OUT v_model_blueprint_text MEDIUMTEXT,
-   OUT v_template_bpmn_id VARCHAR(36),
-   OUT v_template_bpmn_user_id VARCHAR(80),
-   OUT v_template_bpmn_text MEDIUMTEXT,
-   OUT v_template_image_id VARCHAR(36),
-   OUT v_template_image_user_id VARCHAR(80),
-   OUT v_template_image_text MEDIUMTEXT,
-   OUT v_template_doc_id VARCHAR(36),
-   OUT v_template_doc_user_id VARCHAR(80),
-   OUT v_template_doc_text MEDIUMTEXT,
-   OUT v_event_id VARCHAR(36),
-   OUT v_action_cd VARCHAR(80),
-   OUT v_action_state_cd VARCHAR(80),
-   OUT v_event_process_instance_id VARCHAR(80),
-   OUT v_event_user_id VARCHAR(80))
-BEGIN
-  CALL get_model(
-    v_model_name,
-    v_control_name_prefix,
-    v_control_name_uuid,
-    v_model_id,
-       v_service_type_id,
-       v_deployment_id,
-       v_deployment_status_url,
-    v_template_name,
-    v_template_id,
-    v_model_prop_id,
-    v_model_prop_user_id,
-    v_model_prop_text,
-    v_model_blueprint_id,
-    v_model_blueprint_user_id,
-    v_model_blueprint_text,
-       v_event_id,
-       v_action_cd,
-       v_action_state_cd,
-       v_event_process_instance_id,
-       v_event_user_id);
-  CALL get_template(
-    v_template_name,
-    v_template_id,
-    v_template_bpmn_id,
-    v_template_bpmn_user_id,
-    v_template_bpmn_text,
-    v_template_image_id,
-    v_template_image_user_id,
-    v_template_image_text,
-    v_template_doc_id,
-    v_template_doc_user_id,
-    v_template_doc_text);
-  END;
-CREATE PROCEDURE set_model
-  (IN v_model_name VARCHAR(80),
-   IN v_template_id VARCHAR(36),
-   IN v_user_id VARCHAR(80),
-   IN v_model_prop_text MEDIUMTEXT,
-   IN v_model_blueprint_text MEDIUMTEXT,
-   IN v_service_type_id VARCHAR(80),
-   IN v_deployment_id VARCHAR(80),
-   IN v_deployment_status_url VARCHAR(300),
-   INOUT v_control_name_prefix VARCHAR(80),
-   INOUT v_control_name_uuid VARCHAR(36),
-   OUT v_model_id VARCHAR(36),
-   OUT v_model_prop_id VARCHAR(36),
-   OUT v_model_prop_user_id VARCHAR(80),
-   OUT v_model_blueprint_id VARCHAR(36),
-   OUT v_model_blueprint_user_id VARCHAR(80),
-   OUT v_event_id VARCHAR(36),
-   OUT v_action_cd VARCHAR(80),
-   OUT v_action_state_cd VARCHAR(80),
-   OUT v_event_process_instance_id VARCHAR(80),
-   OUT v_event_user_id VARCHAR(80))
-BEGIN
-  DECLARE v_old_template_name VARCHAR(80);
-  DECLARE v_old_template_id VARCHAR(36);
-  DECLARE v_old_control_name_prefix VARCHAR(80);
-  DECLARE v_old_control_name_uuid VARCHAR(36);
-  DECLARE v_old_model_prop_text MEDIUMTEXT;
-  DECLARE v_old_model_blueprint_text MEDIUMTEXT;
-  DECLARE v_old_service_type_id VARCHAR(80);
-  DECLARE v_old_deployment_id VARCHAR(80);
-  DECLARE v_old_deployment_status_url VARCHAR(300);
-  SET v_model_id = NULL;
-  CALL get_model(
-    v_model_name,
-    v_old_control_name_prefix,
-    v_old_control_name_uuid,
-    v_model_id,
-       v_old_service_type_id,
-       v_old_deployment_id,
-       v_old_deployment_status_url,
-    v_old_template_name,
-    v_old_template_id,
-    v_model_prop_id,
-    v_model_prop_user_id,
-    v_old_model_prop_text,
-    v_model_blueprint_id,
-    v_model_blueprint_user_id,
-    v_old_model_blueprint_text,
-       v_event_id,
-       v_action_cd,
-       v_action_state_cd,
-       v_event_process_instance_id,
-       v_event_user_id);
-  IF v_model_id IS NULL THEN
-    BEGIN
-      # UUID can be provided initially but cannot be updated
-         # if not provided (this is expected) then it will be set here
-      IF v_control_name_uuid IS NULL THEN
-           SET v_control_name_uuid = UUID();
-         END IF;
-      SET v_model_id = v_control_name_uuid;
-      INSERT INTO model
-           (model_id, model_name, template_id, control_name_prefix, control_name_uuid, service_type_id, deployment_id, deployment_status_url)
-           VALUES (v_model_id, v_model_name, v_template_id, v_control_name_prefix, v_control_name_uuid, v_service_type_id, v_deployment_id,v_deployment_status_url);
-         # since just created model, insert CREATED event as initial default event
-         SET v_action_cd = 'CREATE';
-         SET v_action_state_cd = 'COMPLETED';
-         SET v_event_user_id = v_user_id;
-      SET v_event_id = UUID();
-      INSERT INTO event
-           (event_id, model_id, action_cd, action_state_cd, user_id)
-           VALUES (v_event_id, v_model_id, v_action_cd, v_action_state_cd, v_event_user_id);
-         UPDATE model
-               SET event_id = v_event_id
-               WHERE model_id = v_model_id;
-       END;
-  ELSE
-    BEGIN
-         # use old control_name_prefix if null value is provided
-      IF v_control_name_prefix IS NULL THEN
-            SET v_control_name_prefix = v_old_control_name_prefix;
-         END IF;
-         # UUID can not be updated after initial insert
-         SET v_control_name_uuid = v_old_control_name_uuid;
-       END;
-  END IF;
-  IF v_model_prop_id IS NULL OR v_model_prop_text <> v_old_model_prop_text THEN
-       SET v_model_prop_id = UUID();
-    INSERT INTO model_properties
-         (model_prop_id, model_id, model_prop_text, user_id)
-         VALUES (v_model_prop_id, v_model_id, v_model_prop_text, v_user_id);
-       SET v_model_prop_user_id = v_user_id;
-  END IF;
-  IF v_model_blueprint_id IS NULL OR v_model_blueprint_text <> v_old_model_blueprint_text THEN
-       SET v_model_blueprint_id = UUID();
-    INSERT INTO model_blueprint
-         (model_blueprint_id, model_id, model_blueprint_text, user_id)
-         VALUES (v_model_blueprint_id, v_model_id, v_model_blueprint_text, v_user_id);
-       SET v_model_blueprint_user_id = v_user_id;
-  END IF;
-  UPDATE model
-    SET control_name_prefix = v_control_name_prefix,
-           model_prop_id = v_model_prop_id,
-           model_blueprint_id = v_model_blueprint_id,
-           service_type_id = v_service_type_id,
-           deployment_id = v_deployment_id,
-           deployment_status_url = v_deployment_status_url
-    WHERE model_id = v_model_id;
-END;
-CREATE PROCEDURE ins_model_instance
-  (IN v_control_name_uuid VARCHAR(36),
-   IN v_vm_name VARCHAR(250),
-   IN v_location VARCHAR(250),
-   OUT v_model_id VARCHAR(36),
-   OUT v_model_instance_id VARCHAR(36))
-BEGIN
-   SELECT m.model_id
-    INTO v_model_id
-    FROM model m
-    WHERE m.control_name_uuid = v_control_name_uuid;
-  SET v_model_instance_id = UUID();
-  INSERT INTO model_instance
-       (model_instance_id, model_id, vm_name, location)
-       VALUES (v_model_instance_id, v_model_id, v_vm_name, v_location);
-END;
-CREATE PROCEDURE del_model_instance
-  (IN v_control_name_uuid VARCHAR(36),
-   IN v_vm_name VARCHAR(250),
-   OUT v_model_id VARCHAR(36),
-   OUT v_model_instance_id VARCHAR(36))
-BEGIN
-   SELECT m.model_id, i.model_instance_id
-    INTO v_model_id,
-         v_model_instance_id
-    FROM model m,
-         model_instance i
-    WHERE m.model_id = i.model_id
-     AND  m.control_name_uuid = v_control_name_uuid
-     AND  i.vm_name = v_vm_name;
-  DELETE FROM model_instance
-  WHERE model_instance_id = v_model_instance_id;
-END;
-CREATE PROCEDURE del_all_model_instances
-  (IN v_control_name_uuid VARCHAR(36),
-   OUT v_model_id VARCHAR(36))
-BEGIN
-  SELECT m.model_id
-    INTO v_model_id
-    FROM model m
-    WHERE m.control_name_uuid = v_control_name_uuid;
-  DELETE FROM model_instance
-  WHERE model_id = v_model_id;
-END;
-CREATE PROCEDURE ins_event
-  (IN v_model_name VARCHAR(80),
-   IN v_control_name_prefix VARCHAR(80),
-   IN v_control_name_uuid VARCHAR(36),
-   IN v_user_id VARCHAR(80),
-   IN v_action_cd VARCHAR(80),
-   IN v_action_state_cd VARCHAR(80),
-   IN v_process_instance_id VARCHAR(80),
-   OUT v_model_id VARCHAR(36),
-   OUT v_event_id VARCHAR(36))
-BEGIN
-  DECLARE v_prev_event_id VARCHAR(36);
-  SELECT m.model_id,
-                m.event_id
-    INTO v_model_id,
-         v_prev_event_id
-    FROM model m
-    WHERE m.model_name = v_model_name
-         OR  m.control_name_uuid = v_control_name_uuid;
-  SET v_event_id = UUID();
-  INSERT INTO event
-       (event_id, model_id, action_cd, action_state_cd, prev_event_id, process_instance_id, user_id)
-       VALUES (v_event_id, v_model_id, v_action_cd, v_action_state_cd, v_prev_event_id, v_process_instance_id, v_user_id);
-  UPDATE model
-       SET event_id = v_event_id
-       WHERE model_id = v_model_id;
-END;
-CREATE PROCEDURE upd_event
-  (IN v_event_id VARCHAR(36),
-   IN v_process_instance_id VARCHAR(80))
-BEGIN
-  UPDATE event
-       SET process_instance_id = v_process_instance_id
-       WHERE event_id = v_event_id;
-END;
-CREATE PROCEDURE del_model
-(IN v_model_name VARCHAR(80))
-BEGIN
-    DECLARE v_model_id VARCHAR(36);
-    SELECT model_id INTO v_model_id from model where model_name = v_model_name;
-    UPDATE model set event_id = null, model_blueprint_id = null, model_prop_id = null where model_id = v_model_id;
-       DELETE from event where model_id = v_model_id;
-       DELETE from model_blueprint where model_id = v_model_id;
-       DELETE from model_properties where model_id = v_model_id;
-    DELETE from model where model_id = v_model_id;
-END;
-
-CREATE PROCEDURE set_new_tosca_model_version
-  (IN v_tosca_model_id VARCHAR(36),
-   IN v_version DOUBLE,
-   IN v_tosca_model_yaml MEDIUMTEXT,
-   IN v_tosca_model_json MEDIUMTEXT,
-   IN v_user_id VARCHAR(80),
-   OUT v_revision_id VARCHAR(36))
-BEGIN
-  SET v_revision_id = UUID();
-  INSERT INTO tosca_model_revision
-    (tosca_model_revision_id, tosca_model_id, version, tosca_model_yaml, tosca_model_json, user_id)
-    VALUES (v_revision_id, v_tosca_model_id, v_version, v_tosca_model_yaml, v_tosca_model_json, v_user_id);
-END;
-
-CREATE PROCEDURE set_tosca_model
-  (IN v_tosca_model_name VARCHAR(80),
-   IN v_policy_type VARCHAR(80),
-   IN v_user_id VARCHAR(80),
-   IN v_tosca_model_yaml MEDIUMTEXT,
-   IN v_tosca_model_json MEDIUMTEXT,
-   IN v_version DOUBLE,
-   OUT v_tosca_model_id VARCHAR(36),
-   OUT v_revision_id VARCHAR(36))
-BEGIN
-  SET v_tosca_model_id = UUID();
-  INSERT INTO tosca_model
-    (tosca_model_id, tosca_model_name, policy_type, user_id)
-    VALUES (v_tosca_model_id, v_tosca_model_name, v_policy_type, v_user_id);
-  SET v_revision_id = UUID();
-  INSERT INTO tosca_model_revision
-    (tosca_model_revision_id, tosca_model_id, version, tosca_model_yaml, tosca_model_json, user_id)
-    VALUES (v_revision_id, v_tosca_model_id, v_version, v_tosca_model_yaml, v_tosca_model_json, v_user_id);
-END;
-
-CREATE PROCEDURE set_dictionary
-  (IN v_dictionary_name VARCHAR(80),
-   IN v_user_id VARCHAR(80),
-   OUT v_dictionary_id VARCHAR(36))
-BEGIN
-  SET v_dictionary_id = UUID();
-  INSERT INTO dictionary
-    (dictionary_id, dictionary_name, created_by, modified_by)
-    VALUES (v_dictionary_id, v_dictionary_name, v_user_id, v_user_id);
-END;
-
-CREATE PROCEDURE set_dictionary_elements
-  (IN v_dictionary_id VARCHAR(36),
-   IN v_dict_element_name VARCHAR(250),
-   IN v_dict_element_short_name VARCHAR(80),
-   IN v_dict_element_description VARCHAR(250),
-   IN v_dict_element_type VARCHAR(80),
-   IN v_user_id VARCHAR(80),
-   OUT v_dict_element_id VARCHAR(36))
-BEGIN
-  SET v_dict_element_id = UUID();
-  INSERT INTO dictionary_elements
-    (dict_element_id, dictionary_id, dict_element_name, dict_element_short_name, dict_element_description, dict_element_type, created_by, modified_by)
-    VALUES (v_dict_element_id, v_dictionary_id, v_dict_element_name, v_dict_element_short_name, v_dict_element_description, v_dict_element_type, v_user_id, v_user_id);
-END;
-//
-DELIMITER ;
diff --git a/extra/sql/bulkload/create-db.sql b/extra/sql/bulkload/create-db.sql
new file mode 100644 (file)
index 0000000..ea4d97c
--- /dev/null
@@ -0,0 +1,11 @@
+#
+# Create CLDS database objects (tables, etc.)
+#
+#
+CREATE DATABASE `cldsdb4`;
+USE `cldsdb4`;
+DROP USER 'clds';
+CREATE USER 'clds';
+GRANT ALL on cldsdb4.* to 'clds' identified by 'sidnnd83K' with GRANT OPTION;
+FLUSH PRIVILEGES;
+
diff --git a/extra/sql/drop/clds-drop-db-objects.sql b/extra/sql/drop/clds-drop-db-objects.sql
deleted file mode 100644 (file)
index 1c173a4..0000000
+++ /dev/null
@@ -1,39 +0,0 @@
-#
-# Drop CLDS database objects (tables, etc.)
-#
-
-
-ALTER TABLE template
-    DROP FOREIGN KEY template_image_id_fkey01;
-ALTER TABLE template
-    DROP FOREIGN KEY template_bpmn_id_fkey01;
-ALTER TABLE template
-    DROP FOREIGN KEY template_doc_id_fkey01;
-
-ALTER TABLE model
-    DROP FOREIGN KEY template_id_fkey01;
-ALTER TABLE model
-    DROP FOREIGN KEY model_prop_id_fkey01;
-ALTER TABLE model
-    DROP FOREIGN KEY model_blueprint_id_fkey01;
-ALTER TABLE model
-    DROP FOREIGN KEY event_id_fkey01;
-
-DROP TABLE clds_service_cache;
-
-DROP TABLE model_instance;
-DROP TABLE model_blueprint;
-DROP TABLE model_properties;
-DROP TABLE event;
-DROP TABLE model;
-
-DROP TABLE template_doc;
-DROP TABLE template_image;
-DROP TABLE template_bpmn;
-DROP TABLE template;
-
-DROP TABLE dictionary_elements;
-DROP TABLE dictionary;
-DROP TABLE tosca_model_revision;
-DROP TABLE tosca_model;
-
index 19cd516..564b99f 100755 (executable)
@@ -24,8 +24,6 @@
 ###
 
 cd /docker-entrypoint-initdb.d/bulkload
-### Keep previous DB for now (SOON DEPRECATED)
-mysql -uroot -p$MYSQL_ROOT_PASSWORD -f < clds-create-db-objects.sql
-mysql -uroot -p$MYSQL_ROOT_PASSWORD -f < clds-stored-procedures.sql
+mysql -uroot -p$MYSQL_ROOT_PASSWORD -f < create-db.sql
 ## New model creation 
 mysql -uroot -p$MYSQL_ROOT_PASSWORD -f cldsdb4 < create-tables.sql
index bac328d..efc4b12 100644 (file)
@@ -37,8 +37,6 @@ import java.security.cert.X509Certificate;
 import java.util.Enumeration;
 
 import org.apache.catalina.connector.Connector;
-import org.onap.clamp.clds.model.properties.Holmes;
-import org.onap.clamp.clds.model.properties.ModelProperties;
 import org.onap.clamp.clds.util.ClampVersioning;
 import org.onap.clamp.clds.util.ResourceFileUtil;
 import org.springframework.beans.factory.annotation.Autowired;
@@ -65,7 +63,7 @@ import org.springframework.transaction.annotation.EnableTransactionManagement;
 
 @ComponentScan(basePackages = { "org.onap.clamp" })
 @SpringBootApplication(exclude = { DataSourceAutoConfiguration.class, SecurityAutoConfiguration.class,
-    UserDetailsServiceAutoConfiguration.class })
+        UserDetailsServiceAutoConfiguration.class })
 @EnableJpaRepositories(basePackages = { "org.onap.clamp" })
 @EntityScan(basePackages = { "org.onap.clamp" })
 @EnableTransactionManagement
@@ -98,28 +96,21 @@ public class Application extends SpringBootServletInitializer {
     }
 
     public static void main(String[] args) {
-        // This is to initialize some Onap Clamp components
-        initializeComponents();
         // Start the Spring application
         SpringApplication.run(Application.class, args);
     }
 
-    private static void initializeComponents() {
-        ModelProperties.registerModelElement(Holmes.class, Holmes.getType());
-    }
-
     /**
      * This method is used to declare the camel servlet.
      *
      * @return A servlet bean
-     * @throws IOException
-     *         IO Exception
+     * @throws IOException IO Exception
      */
     @Bean
     public ServletRegistrationBean camelServletRegistrationBean() throws IOException {
-        eelfLogger.info(
-            ResourceFileUtil.getResourceAsString("boot-message.txt") + "(v" + ClampVersioning.getCldsVersionFromProps()
-                + ")" + System.getProperty("line.separator") + getSslExpirationDate());
+        eelfLogger.info(ResourceFileUtil.getResourceAsString("boot-message.txt") + "(v"
+                + ClampVersioning.getCldsVersionFromProps() + ")" + System.getProperty("line.separator")
+                + getSslExpirationDate());
         ServletRegistrationBean registration = new ServletRegistrationBean(new ClampServlet(), "/restservices/clds/*");
         registration.setName("CamelServlet");
         return registration;
@@ -147,7 +138,7 @@ public class Application extends SpringBootServletInitializer {
     private Connector createRedirectConnector(int redirectSecuredPort) {
         if (redirectSecuredPort <= 0) {
             eelfLogger.warn("HTTP port redirection to HTTPS is disabled because the HTTPS port is 0 (random port) or -1"
-                + " (Connector disabled)");
+                    + " (Connector disabled)");
             return null;
         }
         Connector connector = new Connector("org.apache.coyote.http11.Http11NioProtocol");
@@ -165,16 +156,16 @@ public class Application extends SpringBootServletInitializer {
 
                 KeyStore keystore = KeyStore.getInstance(env.getProperty("server.ssl.key-store-type"));
                 keystore.load(
-                    ResourceFileUtil
-                        .getResourceAsStream(env.getProperty("server.ssl.key-store").replaceAll("classpath:", "")),
-                    env.getProperty("server.ssl.key-store-password").toCharArray());
+                        ResourceFileUtil.getResourceAsStream(
+                                env.getProperty("server.ssl.key-store").replaceAll("classpath:", "")),
+                        env.getProperty("server.ssl.key-store-password").toCharArray());
                 Enumeration<String> aliases = keystore.aliases();
                 while (aliases.hasMoreElements()) {
                     String alias = aliases.nextElement();
                     if ("X.509".equals(keystore.getCertificate(alias).getType())) {
                         result.append("* " + alias + " expires "
-                            + ((X509Certificate) keystore.getCertificate(alias)).getNotAfter()
-                            + System.getProperty("line.separator"));
+                                + ((X509Certificate) keystore.getCertificate(alias)).getNotAfter()
+                                + System.getProperty("line.separator"));
                     }
                 }
             } else {
diff --git a/src/main/java/org/onap/clamp/clds/client/CldsEventDelegate.java b/src/main/java/org/onap/clamp/clds/client/CldsEventDelegate.java
deleted file mode 100644 (file)
index 8ae10b2..0000000
+++ /dev/null
@@ -1,73 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * ONAP CLAMP
- * ================================================================================
- * Copyright (C) 2017-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.client;
-
-import com.att.eelf.configuration.EELFLogger;
-import com.att.eelf.configuration.EELFManager;
-
-import org.apache.camel.Exchange;
-import org.onap.clamp.clds.dao.CldsDao;
-import org.onap.clamp.clds.model.CldsEvent;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.stereotype.Component;
-
-/**
- * Create CLDS Event.
- */
-@Component
-public class CldsEventDelegate {
-
-    protected static final EELFLogger logger = EELFManager.getInstance().getLogger(CldsEventDelegate.class);
-    protected static final EELFLogger metricsLogger = EELFManager.getInstance().getMetricsLogger();
-    @Autowired
-    private CldsDao cldsDao;
-
-    /**
-     * Insert event using process variables.
-     *
-     * @param camelExchange
-     *        The Camel Exchange object containing the properties
-     * @param actionState
-     *        The action state that is used instead of the one in exchange property
-     */
-
-    public void addEvent(Exchange camelExchange, String actionState) {
-        String controlName = (String) camelExchange.getProperty("controlName");
-        String actionCd = (String) camelExchange.getProperty("actionCd");
-        String actionStateCd = (actionState != null) ? actionState : CldsEvent.ACTION_STATE_COMPLETED;
-        actionStateCd = ((String) camelExchange.getProperty("actionStateCd")) != null
-            ? ((String) camelExchange.getProperty("actionStateCd"))
-            : actionStateCd;
-        // Flag indicate whether it is triggered by Validation Test button from
-        // UI
-        boolean isTest = (boolean) camelExchange.getProperty("isTest");
-        boolean isInsertTestEvent = (boolean) camelExchange.getProperty("isInsertTestEvent");
-        String userid = (String) camelExchange.getProperty("userid");
-        // do not insert events for test actions unless flag set to insert them
-        if (!isTest || isInsertTestEvent) {
-            // won't really have userid here...
-            CldsEvent.insEvent(cldsDao, controlName, userid, actionCd, actionStateCd, camelExchange.getExchangeId());
-        }
-    }
-}
diff --git a/src/main/java/org/onap/clamp/clds/client/DcaeDispatcherServices.java b/src/main/java/org/onap/clamp/clds/client/DcaeDispatcherServices.java
deleted file mode 100644 (file)
index 83401a3..0000000
+++ /dev/null
@@ -1,216 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * ONAP CLAMP
- * ================================================================================
- * Copyright (C) 2017-2018 AT&T Intellectual Property. All rights
- *                             reserved.
- * ================================================================================
- * Modifications Copyright (c) 2019 Samsung
- * ================================================================================
- * 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.client;
-
-import com.att.eelf.configuration.EELFLogger;
-import com.att.eelf.configuration.EELFManager;
-
-import com.google.gson.JsonObject;
-import java.io.IOException;
-import java.util.Date;
-
-import org.json.simple.JSONObject;
-import org.json.simple.parser.JSONParser;
-import org.json.simple.parser.ParseException;
-import org.onap.clamp.clds.config.ClampProperties;
-import org.onap.clamp.clds.exception.dcae.DcaeDeploymentException;
-import org.onap.clamp.clds.util.LoggingUtils;
-import org.onap.clamp.util.HttpConnectionManager;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.stereotype.Component;
-
-/**
- * This class implements the communication with DCAE for the service
- * deployments.
- */
-@Component
-public class DcaeDispatcherServices {
-
-    protected static final EELFLogger logger = EELFManager.getInstance().getLogger(DcaeDispatcherServices.class);
-    protected static final EELFLogger metricsLogger = EELFManager.getInstance().getMetricsLogger();
-    private final ClampProperties refProp;
-    private final HttpConnectionManager dcaeHttpConnectionManager;
-    private static final String STATUS_URL_LOG = "Status URL extracted: ";
-    private static final String DCAE_URL_PREFIX = "/dcae-deployments/";
-    private static final String DCAE_URL_PROPERTY_NAME = "dcae.dispatcher.url";
-    private static final String DCAE_LINK_FIELD = "links";
-    private static final String DCAE_STATUS_FIELD = "status";
-
-    @Autowired
-    public DcaeDispatcherServices(ClampProperties refProp, HttpConnectionManager dcaeHttpConnectionManager) {
-        this.refProp = refProp;
-        this.dcaeHttpConnectionManager = dcaeHttpConnectionManager;
-    }
-
-    /**
-     * Get the Operation Status from a specified URL with retry.
-     * @param operationStatusUrl
-     *        The URL of the DCAE
-     * @return The status
-     * @throws InterruptedException Exception during the retry
-     */
-    public String getOperationStatusWithRetry(String operationStatusUrl) throws InterruptedException {
-        String operationStatus = "";
-        for (int i = 0; i < Integer.valueOf(refProp.getStringValue("dcae.dispatcher.retry.limit")); i++) {
-            logger.info("Trying to get Operation status on DCAE for url:" + operationStatusUrl);
-            operationStatus = getOperationStatus(operationStatusUrl);
-            logger.info("Current Status is:" + operationStatus);
-            if (!"processing".equalsIgnoreCase(operationStatus)) {
-                return operationStatus;
-            } else {
-                Thread.sleep(Integer.valueOf(refProp.getStringValue("dcae.dispatcher.retry.interval")));
-            }
-        }
-        logger.warn("Number of attempts on DCAE is over, stopping the getOperationStatus method");
-        return operationStatus;
-    }
-
-    /**
-     * Get the Operation Status from a specified URL.
-     * @param statusUrl
-     *        The URL provided by a previous DCAE Query
-     * @return The status
-     */
-    public String getOperationStatus(String statusUrl) {
-        // Assigning processing status to monitor operation status further
-        String opStatus = "processing";
-        Date startTime = new Date();
-        LoggingUtils.setTargetContext("DCAE", "getOperationStatus");
-        try {
-            String responseStr = dcaeHttpConnectionManager.doHttpRequest(statusUrl, "GET", null,
-                                                                         null, "DCAE", null,
-                                                                         null);
-            JSONObject jsonObj = parseResponse(responseStr);
-            String operationType = (String) jsonObj.get("operationType");
-            String status = (String) jsonObj.get(DCAE_STATUS_FIELD);
-            logger.info("Operation Type - " + operationType + ", Status " + status);
-            LoggingUtils.setResponseContext("0", "Get operation status success", this.getClass().getName());
-            opStatus = status;
-        } catch (Exception e) {
-            LoggingUtils.setResponseContext("900", "Get operation status failed", this.getClass().getName());
-            LoggingUtils.setErrorContext("900", "Get operation status error");
-            logger.error("Exception occurred during getOperationStatus Operation with DCAE", e);
-        } finally {
-            LoggingUtils.setTimeContext(startTime, new Date());
-            metricsLogger.info("getOperationStatus complete");
-        }
-        return opStatus;
-    }
-
-    /**
-     * Returns status URL for createNewDeployment operation.
-     * @param deploymentId
-     *        The deployment ID
-     * @param serviceTypeId
-     *        Service type ID
-     * @param blueprintInputJson
-     *        The value for each blueprint parameters in a flat JSON
-     * @return The status URL
-     */
-    public String createNewDeployment(String deploymentId, String serviceTypeId, JsonObject blueprintInputJson) {
-        Date startTime = new Date();
-        LoggingUtils.setTargetContext("DCAE", "createNewDeployment");
-        try {
-            JsonObject rootObject = refProp.getJsonTemplate("dcae.deployment.template").getAsJsonObject();
-            rootObject.addProperty("serviceTypeId", serviceTypeId);
-            if (blueprintInputJson != null) {
-                rootObject.add("inputs", blueprintInputJson);
-            }
-            String apiBodyString = rootObject.toString();
-            logger.info("Dcae api Body String - " + apiBodyString);
-            String url = refProp.getStringValue(DCAE_URL_PROPERTY_NAME) + DCAE_URL_PREFIX + deploymentId;
-            String statusUrl = getDcaeResponse(url, "PUT", apiBodyString, "application/json", DCAE_LINK_FIELD,
-                DCAE_STATUS_FIELD);
-            LoggingUtils.setResponseContext("0", "Create new deployment failed", this.getClass().getName());
-            return statusUrl;
-        } catch (Exception e) {
-            LoggingUtils.setResponseContext("900", "Create new deployment failed", this.getClass().getName());
-            LoggingUtils.setErrorContext("900", "Create new deployment error");
-            logger.error("Exception occurred during createNewDeployment Operation with DCAE", e);
-            throw new DcaeDeploymentException("Exception occurred during createNewDeployment Operation with DCAE", e);
-        } finally {
-            LoggingUtils.setTimeContext(startTime, new Date());
-            metricsLogger.info("createNewDeployment complete");
-        }
-    }
-
-    /***
-     * Returns status URL for deleteExistingDeployment operation.
-     *
-     * @param deploymentId
-     *        The deployment ID
-     * @param serviceTypeId
-     *        The service Type ID
-     * @return The status URL
-     */
-    public String deleteExistingDeployment(String deploymentId, String serviceTypeId) {
-        Date startTime = new Date();
-        LoggingUtils.setTargetContext("DCAE", "deleteExistingDeployment");
-        try {
-            String apiBodyString = "{\"serviceTypeId\": \"" + serviceTypeId + "\"}";
-            logger.info("Dcae api Body String - " + apiBodyString);
-            String url = refProp.getStringValue(DCAE_URL_PROPERTY_NAME) + DCAE_URL_PREFIX + deploymentId;
-            String statusUrl = getDcaeResponse(url, "DELETE", apiBodyString, "application/json", DCAE_LINK_FIELD,
-                DCAE_STATUS_FIELD);
-            LoggingUtils.setResponseContext("0", "Delete existing deployment success", this.getClass().getName());
-            return statusUrl;
-
-        } catch (Exception e) {
-            LoggingUtils.setResponseContext("900", "Delete existing deployment failed", this.getClass().getName());
-            LoggingUtils.setErrorContext("900", "Delete existing deployment error");
-            logger.error("Exception occurred during deleteExistingDeployment Operation with DCAE", e);
-            throw new DcaeDeploymentException("Exception occurred during deleteExistingDeployment Operation with DCAE",
-                e);
-        } finally {
-            LoggingUtils.setTimeContext(startTime, new Date());
-            metricsLogger.info("deleteExistingDeployment complete");
-        }
-    }
-
-    private String getDcaeResponse(String url, String requestMethod, String payload, String contentType, String node,
-        String nodeAttr) throws IOException, ParseException {
-        Date startTime = new Date();
-        try {
-            String responseStr = dcaeHttpConnectionManager.doHttpRequest(url, requestMethod, payload, contentType, "DCAE", null, null);
-            JSONObject jsonObj = parseResponse(responseStr);
-            JSONObject linksObj = (JSONObject) jsonObj.get(node);
-            String statusUrl = (String) linksObj.get(nodeAttr);
-            logger.info(STATUS_URL_LOG + statusUrl);
-            return statusUrl;
-        } catch (IOException | ParseException e) {
-            logger.error("Exception occurred getting response from DCAE", e);
-            throw e;
-        } finally {
-            LoggingUtils.setTimeContext(startTime, new Date());
-            metricsLogger.info("getDcaeResponse complete");
-        }
-    }
-
-    private JSONObject parseResponse(String responseStr) throws ParseException {
-        JSONParser parser = new JSONParser();
-        return (JSONObject) parser.parse(responseStr);
-    }
-}
\ No newline at end of file
index 7f20919..0ebaab5 100644 (file)
@@ -29,20 +29,13 @@ import com.att.eelf.configuration.EELFManager;
 \r
 import java.io.IOException;\r
 import java.util.Date;\r
-import java.util.List;\r
 \r
 import org.json.simple.JSONArray;\r
 import org.json.simple.JSONObject;\r
 import org.json.simple.parser.JSONParser;\r
 import org.json.simple.parser.ParseException;\r
 import org.onap.clamp.clds.config.ClampProperties;\r
-import org.onap.clamp.clds.dao.CldsDao;\r
-import org.onap.clamp.clds.model.CldsEvent;\r
-import org.onap.clamp.clds.model.CldsModel;\r
-import org.onap.clamp.clds.model.DcaeEvent;\r
 import org.onap.clamp.clds.model.dcae.DcaeInventoryResponse;\r
-import org.onap.clamp.clds.model.properties.Global;\r
-import org.onap.clamp.clds.model.properties.ModelProperties;\r
 import org.onap.clamp.clds.util.JsonUtils;\r
 import org.onap.clamp.clds.util.LoggingUtils;\r
 import org.onap.clamp.util.HttpConnectionManager;\r
@@ -62,93 +55,17 @@ public class DcaeInventoryServices {
     public static final String DCAE_INVENTORY_RETRY_INTERVAL = "dcae.intentory.retry.interval";\r
     public static final String DCAE_INVENTORY_RETRY_LIMIT = "dcae.intentory.retry.limit";\r
     private final ClampProperties refProp;\r
-    private final CldsDao cldsDao;\r
     private final HttpConnectionManager httpConnectionManager;\r
 \r
     /**\r
      * Constructor.\r
      */\r
     @Autowired\r
-    public DcaeInventoryServices(ClampProperties refProp, CldsDao cldsDao,\r
-                                 HttpConnectionManager httpConnectionManager) {\r
+    public DcaeInventoryServices(ClampProperties refProp, HttpConnectionManager httpConnectionManager) {\r
         this.refProp = refProp;\r
-        this.cldsDao = cldsDao;\r
         this.httpConnectionManager = httpConnectionManager;\r
     }\r
 \r
-    /**\r
-     * Set the event inventory.\r
-     *\r
-     * @param cldsModel\r
-     *        The CldsModel\r
-     * @param userId\r
-     *        The user ID\r
-     * @throws ParseException\r
-     *         In case of DCAE Json parse exception\r
-     */\r
-    public void setEventInventory(CldsModel cldsModel, String userId) throws InterruptedException {\r
-        String artifactName = cldsModel.getControlName();\r
-        DcaeEvent dcaeEvent = new DcaeEvent();\r
-        DcaeInventoryResponse dcaeResponse = null;\r
-        Date startTime = new Date();\r
-        LoggingUtils.setTargetContext("DCAE", "setEventInventory");\r
-        if (artifactName != null) {\r
-            artifactName = artifactName + ".yml";\r
-        }\r
-        try {\r
-            // Below are the properties required for calling the dcae inventory\r
-            ModelProperties prop = new ModelProperties(cldsModel.getName(), cldsModel.getControlName(), null,\r
-                                                       false, "{}", cldsModel.getPropText());\r
-            Global global = prop.getGlobal();\r
-            String invariantServiceUuid = global.getService();\r
-            List<String> resourceUuidList = global.getResourceVf();\r
-            String resourceUuid = "";\r
-            if (resourceUuidList != null && !resourceUuidList.isEmpty()) {\r
-                resourceUuid = resourceUuidList.get(0);\r
-            }\r
-            /* Inventory service url is called in this method */\r
-            dcaeResponse = getDcaeInformation(artifactName, invariantServiceUuid, resourceUuid);\r
-            /* set dcae events */\r
-            dcaeEvent.setArtifactName(artifactName);\r
-            dcaeEvent.setEvent(DcaeEvent.EVENT_DISTRIBUTION);\r
-            LoggingUtils.setResponseContext("0", "Set inventory success", this.getClass().getName());\r
-        } catch (ParseException e) {\r
-            LoggingUtils.setResponseContext("900", "Set inventory failed", this.getClass().getName());\r
-            LoggingUtils.setErrorContext("900", "Set inventory error");\r
-            logger.error("Error during JSON decoding", e);\r
-        } catch (IOException ex) {\r
-            LoggingUtils.setResponseContext("900", "Set inventory failed", this.getClass().getName());\r
-            LoggingUtils.setErrorContext("900", "Set inventory error");\r
-            logger.error("Error during DCAE communication", ex);\r
-        } finally {\r
-            LoggingUtils.setTimeContext(startTime, new Date());\r
-            metricsLogger.info("setEventInventory complete");\r
-        }\r
-        this.analyzeAndSaveDcaeResponse(dcaeResponse, cldsModel, dcaeEvent, userId);\r
-    }\r
-\r
-    private void analyzeAndSaveDcaeResponse(DcaeInventoryResponse dcaeResponse, CldsModel cldsModel,\r
-        DcaeEvent dcaeEvent, String userId) {\r
-        if (dcaeResponse != null) {\r
-            logger.info("Dcae Response for query on inventory: " + dcaeResponse);\r
-            String oldTypeId = cldsModel.getTypeId();\r
-            if (dcaeResponse.getTypeId() != null) {\r
-                cldsModel.setTypeId(dcaeResponse.getTypeId());\r
-            }\r
-            if (dcaeResponse.getTypeName() != null) {\r
-                cldsModel.setTypeName(dcaeResponse.getTypeName());\r
-            }\r
-            if (oldTypeId == null || !cldsModel.getEvent().getActionCd().equalsIgnoreCase(CldsEvent.ACTION_DISTRIBUTE)\r
-                || cldsModel.getEvent().getActionCd().equalsIgnoreCase(CldsEvent.ACTION_SUBMITDCAE)) {\r
-                CldsEvent.insEvent(cldsDao, dcaeEvent.getControlName(), userId, dcaeEvent.getCldsActionCd(),\r
-                    CldsEvent.ACTION_STATE_RECEIVED, null);\r
-            }\r
-            cldsModel.save(cldsDao, userId);\r
-        } else {\r
-            logger.info(cldsModel.getName() + " Model is not present in Dcae Inventory Service.");\r
-        }\r
-    }\r
-\r
     private int getTotalCountFromDcaeInventoryResponse(String responseStr) throws ParseException {\r
         JSONParser parser = new JSONParser();\r
         Object obj0 = parser.parse(responseStr);\r
@@ -169,23 +86,18 @@ public class DcaeInventoryServices {
     /**\r
      * DO a query to DCAE to get some Information.\r
      *\r
-     * @param artifactName\r
-     *        The artifact Name\r
-     * @param serviceUuid\r
-     *        The service UUID\r
-     * @param resourceUuid\r
-     *        The resource UUID\r
+     * @param artifactName The artifact Name\r
+     * @param serviceUuid  The service UUID\r
+     * @param resourceUuid The resource UUID\r
      * @return The DCAE inventory for the artifact in DcaeInventoryResponse\r
-     * @throws IOException\r
-     *         In case of issues with the stream\r
-     * @throws ParseException\r
-     *         In case of issues with the Json parsing\r
+     * @throws IOException    In case of issues with the stream\r
+     * @throws ParseException In case of issues with the Json parsing\r
      */\r
     public DcaeInventoryResponse getDcaeInformation(String artifactName, String serviceUuid, String resourceUuid)\r
-        throws IOException, ParseException, InterruptedException {\r
+            throws IOException, ParseException, InterruptedException {\r
         LoggingUtils.setTargetContext("DCAE", "getDcaeInformation");\r
         String queryString = "?asdcResourceId=" + resourceUuid + "&asdcServiceId=" + serviceUuid + "&typeName="\r
-            + artifactName;\r
+                + artifactName;\r
         String fullUrl = refProp.getStringValue(DCAE_INVENTORY_URL) + "/dcae-service-types" + queryString;\r
         logger.info("Dcae Inventory Service full url - " + fullUrl);\r
         DcaeInventoryResponse response = queryDcaeInventory(fullUrl);\r
@@ -196,7 +108,7 @@ public class DcaeInventoryServices {
     }\r
 \r
     private DcaeInventoryResponse queryDcaeInventory(String fullUrl)\r
-        throws IOException, InterruptedException, ParseException {\r
+            throws IOException, InterruptedException, ParseException {\r
         int retryInterval = 0;\r
         int retryLimit = 1;\r
         if (refProp.getStringValue(DCAE_INVENTORY_RETRY_LIMIT) != null) {\r
@@ -215,7 +127,7 @@ public class DcaeInventoryServices {
                 return getItemsFromDcaeInventoryResponse(response);\r
             }\r
             logger.info(\r
-                "Dcae inventory totalCount returned is 0, so waiting " + retryInterval + "ms before retrying ...");\r
+                    "Dcae inventory totalCount returned is 0, so waiting " + retryInterval + "ms before retrying ...");\r
             // wait for a while and try to connect to DCAE again\r
             Thread.sleep(retryInterval);\r
         }\r
diff --git a/src/main/java/org/onap/clamp/clds/client/GuardPolicyDelegate.java b/src/main/java/org/onap/clamp/clds/client/GuardPolicyDelegate.java
deleted file mode 100644 (file)
index 3229337..0000000
+++ /dev/null
@@ -1,81 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * ONAP CLAMP
- * ================================================================================
- * Copyright (C) 2017-2018 AT&T Intellectual Property. All rights
- *                             reserved.
- * ================================================================================
- * Modifications Copyright (c) 2019 Samsung
- * ================================================================================
- * 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.client;
-
-import com.att.eelf.configuration.EELFLogger;
-import com.att.eelf.configuration.EELFManager;
-
-import org.apache.camel.Exchange;
-import org.apache.camel.Handler;
-import org.onap.clamp.clds.client.req.policy.GuardPolicyAttributesConstructor;
-import org.onap.clamp.clds.client.req.policy.PolicyClient;
-import org.onap.clamp.clds.model.properties.ModelProperties;
-import org.onap.clamp.clds.model.properties.Policy;
-import org.onap.clamp.clds.model.properties.PolicyChain;
-import org.onap.clamp.clds.model.properties.PolicyItem;
-import org.onap.clamp.clds.util.LoggingUtils;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.stereotype.Component;
-
-/**
- * Send Guard Policy info to policy API. It uses the policy code to define the
- * model and communicate with it. See also the PolicyClient class.
- */
-@Component
-public class GuardPolicyDelegate {
-
-    protected static final EELFLogger logger = EELFManager.getInstance().getLogger(GuardPolicyDelegate.class);
-    protected static final EELFLogger metricsLogger = EELFManager.getInstance().getMetricsLogger();
-    private final PolicyClient policyClient;
-
-    @Autowired
-    public GuardPolicyDelegate(PolicyClient policyClient) {
-        this.policyClient = policyClient;
-    }
-
-    /**
-     * Perform activity. Send Guard Policies info to policy api.
-     *
-     * @param camelExchange The Camel Exchange object containing the properties
-     */
-    @Handler
-    public void execute(Exchange camelExchange) {
-        ModelProperties prop = ModelProperties.create(camelExchange);
-        Policy policy = prop.getType(Policy.class);
-        if (policy.isFound()) {
-            for (PolicyChain policyChain : prop.getType(Policy.class).getPolicyChains()) {
-                for (PolicyItem policyItem : GuardPolicyAttributesConstructor
-                        .getAllPolicyGuardsFromPolicyChain(policyChain)) {
-                    prop.setCurrentModelElementId(policy.getId());
-                    prop.setPolicyUniqueId(policyChain.getPolicyId());
-                    prop.setGuardUniqueId(policyItem.getId());
-                    policyClient.sendGuardPolicy(GuardPolicyAttributesConstructor
-                            .formatAttributes(prop, policyItem), prop, LoggingUtils.getRequestId(), policyItem);
-                }
-            }
-        }
-    }
-}
diff --git a/src/main/java/org/onap/clamp/clds/client/GuardPolicyDeleteDelegate.java b/src/main/java/org/onap/clamp/clds/client/GuardPolicyDeleteDelegate.java
deleted file mode 100644 (file)
index ae962a0..0000000
+++ /dev/null
@@ -1,82 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * ONAP CLAMP
- * ================================================================================
- * Copyright (C) 2017-2018 AT&T Intellectual Property. All rights
- *                             reserved.
- * ================================================================================
- * Modifications Copyright (c) 2019 Samsung
- * ================================================================================
- * 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.client;
-
-import com.att.eelf.configuration.EELFLogger;
-import com.att.eelf.configuration.EELFManager;
-
-import org.apache.camel.Exchange;
-import org.apache.camel.Handler;
-import org.onap.clamp.clds.client.req.policy.GuardPolicyAttributesConstructor;
-import org.onap.clamp.clds.client.req.policy.PolicyClient;
-import org.onap.clamp.clds.model.CldsEvent;
-import org.onap.clamp.clds.model.properties.ModelProperties;
-import org.onap.clamp.clds.model.properties.Policy;
-import org.onap.clamp.clds.model.properties.PolicyChain;
-import org.onap.clamp.clds.model.properties.PolicyItem;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.stereotype.Component;
-
-/**
- * Delete Operational Policy via policy api.
- */
-@Component
-public class GuardPolicyDeleteDelegate {
-
-    protected static final EELFLogger logger = EELFManager.getInstance()
-            .getLogger(GuardPolicyDeleteDelegate.class);
-    protected static final EELFLogger metricsLogger = EELFManager.getInstance().getMetricsLogger();
-    private final PolicyClient policyClient;
-
-    @Autowired
-    public GuardPolicyDeleteDelegate(PolicyClient policyClient) {
-        this.policyClient = policyClient;
-    }
-
-    /**
-     * Perform activity. Delete Operational Policy via policy api.
-     *
-     * @param camelExchange The Camel Exchange object containing the properties
-     */
-    @Handler
-    public void execute(Exchange camelExchange) {
-        ModelProperties prop = ModelProperties.create(camelExchange);
-        Policy policy = prop.getType(Policy.class);
-
-        String eventAction = (String) camelExchange.getProperty("eventAction");
-        if (!eventAction.equalsIgnoreCase(CldsEvent.ACTION_CREATE) && policy.isFound()) {
-            for (PolicyChain policyChain : prop.getType(Policy.class).getPolicyChains()) {
-                for (PolicyItem policyItem : GuardPolicyAttributesConstructor
-                        .getAllPolicyGuardsFromPolicyChain(policyChain)) {
-                    prop.setCurrentModelElementId(policy.getId());
-                    prop.setPolicyUniqueId(policyChain.getPolicyId());
-                    prop.setGuardUniqueId(policyItem.getId());
-                    policyClient.deleteGuard(prop);
-                }
-            }
-        }
-    }
-}
diff --git a/src/main/java/org/onap/clamp/clds/client/HolmesPolicyDelegate.java b/src/main/java/org/onap/clamp/clds/client/HolmesPolicyDelegate.java
deleted file mode 100644 (file)
index e178ec7..0000000
+++ /dev/null
@@ -1,94 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * ONAP CLAMP
- * ================================================================================
- * Copyright (C) 2017-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.client;
-
-import com.att.eelf.configuration.EELFLogger;
-import com.att.eelf.configuration.EELFManager;
-
-import java.util.UUID;
-
-import org.apache.camel.Exchange;
-import org.apache.camel.Handler;
-import org.onap.clamp.clds.client.req.policy.PolicyClient;
-import org.onap.clamp.clds.config.ClampProperties;
-import org.onap.clamp.clds.dao.CldsDao;
-import org.onap.clamp.clds.model.CldsModel;
-import org.onap.clamp.clds.model.properties.Holmes;
-import org.onap.clamp.clds.model.properties.ModelProperties;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.stereotype.Component;
-
-/**
- * Send Holmes info to policy api.
- */
-@Component
-public class HolmesPolicyDelegate {
-
-    protected static final EELFLogger logger = EELFManager.getInstance().getLogger(HolmesPolicyDelegate.class);
-    protected static final EELFLogger metricsLogger = EELFManager.getInstance().getMetricsLogger();
-    @Autowired
-    private PolicyClient policyClient;
-    @Autowired
-    private ClampProperties refProp;
-    @Autowired
-    private CldsDao cldsDao;
-
-    /**
-     * Perform activity. Send Holmes info to policy api.
-     *
-     * @param camelExchange
-     *            The Camel Exchange object containing the properties
-     */
-    @Handler
-    public void execute(Exchange camelExchange) {
-        String holmesPolicyRequestUuid = UUID.randomUUID().toString();
-        camelExchange.setProperty("holmesPolicyRequestUuid", holmesPolicyRequestUuid);
-        ModelProperties prop = ModelProperties.create(camelExchange);
-        Holmes holmes = prop.getType(Holmes.class);
-        if (holmes.isFound()) {
-            String responseMessage = policyClient.sendBasePolicyInOther(formatHolmesConfigBody(prop, holmes),
-                    holmes.getConfigPolicyName(), prop, holmesPolicyRequestUuid);
-            if (responseMessage != null) {
-                camelExchange.setProperty("holmesPolicyResponseMessage", responseMessage.getBytes());
-            }
-            CldsModel cldsModel = CldsModel.retrieve(cldsDao, (String) camelExchange.getProperty("modelName"), false);
-            cldsModel.setPropText(cldsModel.getPropText().replaceAll("AUTO_GENERATED_POLICY_ID_AT_SUBMIT",
-                    prop.getPolicyNameForDcaeDeploy(refProp)));
-            cldsModel.save(cldsDao, (String) camelExchange.getProperty("userid"));
-        }
-    }
-
-    /**
-     * This method is used to create the Payload that must be sent to Holmes.
-     * 
-     * @param prop
-     *            The ModelProperties containing all the closed loop props
-     * @param holmes
-     *            The holmes object extracted from the closed loop
-     * @return The String that must be sent to policy for holmes
-     */
-    public static String formatHolmesConfigBody(ModelProperties prop, Holmes holmes) {
-        return prop.getControlName() + "$$$" + holmes.getCorrelationLogic();
-    }
-}
diff --git a/src/main/java/org/onap/clamp/clds/client/HolmesPolicyDeleteDelegate.java b/src/main/java/org/onap/clamp/clds/client/HolmesPolicyDeleteDelegate.java
deleted file mode 100644 (file)
index 965698d..0000000
+++ /dev/null
@@ -1,63 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * ONAP CLAMP
- * ================================================================================
- * Copyright (C) 2017-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.client;
-
-import com.att.eelf.configuration.EELFLogger;
-import com.att.eelf.configuration.EELFManager;
-
-import org.apache.camel.Exchange;
-import org.apache.camel.Handler;
-import org.onap.clamp.clds.client.req.policy.PolicyClient;
-import org.onap.clamp.clds.model.properties.Holmes;
-import org.onap.clamp.clds.model.properties.ModelProperties;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.stereotype.Component;
-
-/**
- * Delete Holmes Policy via policy api.
- */
-@Component
-public class HolmesPolicyDeleteDelegate {
-
-    protected static final EELFLogger logger = EELFManager.getInstance().getLogger(HolmesPolicyDeleteDelegate.class);
-    protected static final EELFLogger metricsLogger = EELFManager.getInstance().getMetricsLogger();
-    @Autowired
-    private PolicyClient policyClient;
-
-    /**
-     * Perform activity. Delete Holmes Policy via policy api.
-     *
-     * @param camelExchange
-     *            The Camel Exchange object containing the properties
-     */
-    @Handler
-    public void execute(Exchange camelExchange) {
-        ModelProperties prop = ModelProperties.create(camelExchange);
-        Holmes holmes = prop.getType(Holmes.class);
-        if (holmes.isFound()) {
-            prop.setCurrentModelElementId(holmes.getId());
-            policyClient.deleteBasePolicy(prop);
-        }
-    }
-}
diff --git a/src/main/java/org/onap/clamp/clds/client/ModelDeleteDelegate.java b/src/main/java/org/onap/clamp/clds/client/ModelDeleteDelegate.java
deleted file mode 100644 (file)
index 6a369db..0000000
+++ /dev/null
@@ -1,57 +0,0 @@
-/*-
- * ============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.client;
-
-import com.att.eelf.configuration.EELFLogger;
-import com.att.eelf.configuration.EELFManager;
-
-import org.apache.camel.Exchange;
-import org.apache.camel.Handler;
-import org.onap.clamp.clds.dao.CldsDao;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.stereotype.Component;
-
-/**
- * Delete model.
- */
-@Component
-public class ModelDeleteDelegate {
-
-    protected static final EELFLogger logger = EELFManager.getInstance().getLogger(ModelDeleteDelegate.class);
-    protected static final EELFLogger metricsLogger = EELFManager.getInstance().getMetricsLogger();
-    @Autowired
-    private CldsDao cldsDao;
-
-    /**
-     * Insert event using process variables.
-     *
-     * @param camelExchange
-     *            The Camel Exchange object containing the properties
-     */
-    @Handler
-    public void execute(Exchange camelExchange) {
-        String modelName = (String) camelExchange.getProperty("modelName");
-        cldsDao.deleteModel(modelName);
-    }
-}
diff --git a/src/main/java/org/onap/clamp/clds/client/OperationalPolicyDelegate.java b/src/main/java/org/onap/clamp/clds/client/OperationalPolicyDelegate.java
deleted file mode 100644 (file)
index 307c8e5..0000000
+++ /dev/null
@@ -1,91 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * ONAP CLAMP
- * ================================================================================
- * Copyright (C) 2017-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============================================
- * Modifications copyright (c) 2018 Nokia
- * ===================================================================
- *
- */
-
-package org.onap.clamp.clds.client;
-
-import com.att.eelf.configuration.EELFLogger;
-import com.att.eelf.configuration.EELFManager;
-
-import java.io.UnsupportedEncodingException;
-import java.util.Map;
-
-import org.apache.camel.Exchange;
-import org.apache.camel.Handler;
-import org.onap.clamp.clds.client.req.policy.OperationalPolicyAttributesConstructor;
-import org.onap.clamp.clds.client.req.policy.PolicyClient;
-import org.onap.clamp.clds.config.ClampProperties;
-import org.onap.clamp.clds.model.properties.ModelProperties;
-import org.onap.clamp.clds.model.properties.Policy;
-import org.onap.clamp.clds.model.properties.PolicyChain;
-import org.onap.clamp.clds.util.LoggingUtils;
-import org.onap.policy.api.AttributeType;
-import org.onap.policy.controlloop.policy.builder.BuilderException;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.stereotype.Component;
-
-/**
- * Send Operational Policy info to policy api. It uses the policy code to define
- * the model and communicate with it. See also the PolicyClient class.
- */
-@Component
-public class OperationalPolicyDelegate {
-
-    protected static final EELFLogger logger = EELFManager.getInstance().getLogger(OperationalPolicyDelegate.class);
-    protected static final EELFLogger metricsLogger = EELFManager.getInstance().getMetricsLogger();
-    private final PolicyClient policyClient;
-    private final ClampProperties refProp;
-
-    @Autowired
-    public OperationalPolicyDelegate(PolicyClient policyClient, ClampProperties refProp) {
-        this.policyClient = policyClient;
-        this.refProp = refProp;
-    }
-
-    /**
-     * Perform activity. Send Operational Policy info to policy api.
-     *
-     * @param camelExchange
-     *            The Camel Exchange object containing the properties
-     * @throws BuilderException
-     *             In case of issues with OperationalPolicyRequestAttributesConstructor
-     * @throws UnsupportedEncodingException
-     *             In case of issues with the Charset encoding
-     */
-    @Handler
-    public void execute(Exchange camelExchange) throws BuilderException, UnsupportedEncodingException {
-        String responseMessage = null;
-        ModelProperties prop = ModelProperties.create(camelExchange);
-        Policy policy = prop.getType(Policy.class);
-        if (policy.isFound()) {
-            for (PolicyChain policyChain : prop.getType(Policy.class).getPolicyChains()) {
-                Map<AttributeType, Map<String, String>> attributes = OperationalPolicyAttributesConstructor
-                    .formatAttributes(refProp,prop, prop.getType(Policy.class).getId(), policyChain);
-                responseMessage = policyClient.sendBrmsPolicy(attributes, prop, LoggingUtils.getRequestId());
-            }
-            if (responseMessage != null) {
-                camelExchange.setProperty("operationalPolicyResponseMessage", responseMessage.getBytes());
-            }
-        }
-    }
-}
diff --git a/src/main/java/org/onap/clamp/clds/client/OperationalPolicyDeleteDelegate.java b/src/main/java/org/onap/clamp/clds/client/OperationalPolicyDeleteDelegate.java
deleted file mode 100644 (file)
index adec94f..0000000
+++ /dev/null
@@ -1,71 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * ONAP CLAMP
- * ================================================================================
- * Copyright (C) 2017-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.client;
-
-import com.att.eelf.configuration.EELFLogger;
-import com.att.eelf.configuration.EELFManager;
-
-import org.apache.camel.Exchange;
-import org.apache.camel.Handler;
-import org.onap.clamp.clds.client.req.policy.PolicyClient;
-import org.onap.clamp.clds.model.CldsEvent;
-import org.onap.clamp.clds.model.properties.ModelProperties;
-import org.onap.clamp.clds.model.properties.Policy;
-import org.onap.clamp.clds.model.properties.PolicyChain;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.stereotype.Component;
-
-/**
- * Delete Operational Policy via policy api.
- */
-@Component
-public class OperationalPolicyDeleteDelegate {
-
-    protected static final EELFLogger logger = EELFManager.getInstance()
-        .getLogger(OperationalPolicyDeleteDelegate.class);
-    protected static final EELFLogger metricsLogger = EELFManager.getInstance().getMetricsLogger();
-    @Autowired
-    private PolicyClient policyClient;
-
-    /**
-     * Perform activity. Delete Operational Policy via policy api.
-     *
-     * @param camelExchange
-     *        The Camel Exchange object containing the properties
-     */
-    @Handler
-    public void execute(Exchange camelExchange) {
-        ModelProperties prop = ModelProperties.create(camelExchange);
-        Policy policy = prop.getType(Policy.class);
-        prop.setCurrentModelElementId(policy.getId());
-        String eventAction = (String) camelExchange.getProperty("eventAction");
-        if (policy.getPolicyChains() != null && !policy.getPolicyChains().isEmpty()
-            && !eventAction.equalsIgnoreCase(CldsEvent.ACTION_CREATE) && policy.isFound()) {
-            for (PolicyChain policyChain : policy.getPolicyChains()) {
-                prop.setPolicyUniqueId(policyChain.getPolicyId());
-                logger.info("Policy Delete response: " + policyClient.deleteBrms(prop));
-            }
-        }
-    }
-}
diff --git a/src/main/java/org/onap/clamp/clds/client/TcaPolicyDelegate.java b/src/main/java/org/onap/clamp/clds/client/TcaPolicyDelegate.java
deleted file mode 100644 (file)
index cb31b5f..0000000
+++ /dev/null
@@ -1,82 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * ONAP CLAMP
- * ================================================================================
- * Copyright (C) 2017-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.client;
-
-import com.att.eelf.configuration.EELFLogger;
-import com.att.eelf.configuration.EELFManager;
-
-import java.util.UUID;
-
-import org.apache.camel.Exchange;
-import org.apache.camel.Handler;
-import org.onap.clamp.clds.client.req.policy.PolicyClient;
-import org.onap.clamp.clds.client.req.tca.TcaRequestFormatter;
-import org.onap.clamp.clds.config.ClampProperties;
-import org.onap.clamp.clds.dao.CldsDao;
-import org.onap.clamp.clds.model.CldsModel;
-import org.onap.clamp.clds.model.properties.ModelProperties;
-import org.onap.clamp.clds.model.properties.Tca;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.stereotype.Component;
-
-/**
- * Send Tca info to policy api.
- */
-@Component
-public class TcaPolicyDelegate {
-
-    protected static final EELFLogger logger = EELFManager.getInstance().getLogger(TcaPolicyDelegate.class);
-    protected static final EELFLogger metricsLogger = EELFManager.getInstance().getMetricsLogger();
-    @Autowired
-    private ClampProperties refProp;
-    @Autowired
-    private PolicyClient policyClient;
-    @Autowired
-    private CldsDao cldsDao;
-
-    /**
-     * Perform activity. Send Tca info to policy api.
-     *
-     * @param camelExchange
-     *            The Camel Exchange object containing the properties
-     */
-    @Handler
-    public void execute(Exchange camelExchange) {
-        String tcaPolicyRequestUuid = UUID.randomUUID().toString();
-        camelExchange.setProperty("tcaPolicyRequestUuid", tcaPolicyRequestUuid);
-        ModelProperties prop = ModelProperties.create(camelExchange);
-        Tca tca = prop.getType(Tca.class);
-        if (tca.isFound()) {
-            String policyJson = TcaRequestFormatter.createPolicyJson(refProp, prop);
-            String responseMessage = policyClient.sendMicroServiceInOther(policyJson, prop);
-            if (responseMessage != null) {
-                camelExchange.setProperty("tcaPolicyResponseMessage", responseMessage.getBytes());
-            }
-            CldsModel cldsModel = CldsModel.retrieve(cldsDao, (String) camelExchange.getProperty("modelName"), false);
-            cldsModel.setPropText(cldsModel.getPropText().replaceAll("AUTO_GENERATED_POLICY_ID_AT_SUBMIT",
-                    prop.getPolicyNameForDcaeDeploy(refProp)));
-            cldsModel.save(cldsDao, (String) camelExchange.getProperty("userid"));
-        }
-    }
-}
diff --git a/src/main/java/org/onap/clamp/clds/client/TcaPolicyDeleteDelegate.java b/src/main/java/org/onap/clamp/clds/client/TcaPolicyDeleteDelegate.java
deleted file mode 100644 (file)
index a3fcc53..0000000
+++ /dev/null
@@ -1,66 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * ONAP CLAMP
- * ================================================================================
- * Copyright (C) 2017-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.client;
-
-import com.att.eelf.configuration.EELFLogger;
-import com.att.eelf.configuration.EELFManager;
-
-import org.apache.camel.Exchange;
-import org.apache.camel.Handler;
-import org.onap.clamp.clds.client.req.policy.PolicyClient;
-import org.onap.clamp.clds.model.properties.ModelProperties;
-import org.onap.clamp.clds.model.properties.Tca;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.stereotype.Component;
-
-/**
- * Delete Tca Policy via policy api.
- */
-@Component
-public class TcaPolicyDeleteDelegate {
-
-    protected static final EELFLogger logger = EELFManager.getInstance().getLogger(TcaPolicyDeleteDelegate.class);
-    protected static final EELFLogger metricsLogger = EELFManager.getInstance().getMetricsLogger();
-    @Autowired
-    private PolicyClient policyClient;
-
-    /**
-     * Perform activity. Delete Tca Policy via policy api.
-     *
-     * @param camelExchange
-     *            The Camel Exchange object containing the properties
-     */
-    @Handler
-    public void execute(Exchange camelExchange) {
-        ModelProperties prop = ModelProperties.create(camelExchange);
-        Tca tca = prop.getType(Tca.class);
-        if (tca.isFound()) {
-            prop.setCurrentModelElementId(tca.getId());
-            String responseMessage = policyClient.deleteMicrosService(prop);
-            if (responseMessage != null) {
-                camelExchange.setProperty("tcaPolicyDeleteResponseMessage", responseMessage.getBytes());
-            }
-        }
-    }
-}
diff --git a/src/main/java/org/onap/clamp/clds/client/req/policy/GuardPolicyAttributesConstructor.java b/src/main/java/org/onap/clamp/clds/client/req/policy/GuardPolicyAttributesConstructor.java
deleted file mode 100644 (file)
index e996ae8..0000000
+++ /dev/null
@@ -1,109 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * ONAP CLAMP
- * ================================================================================
- * Copyright (C) 2017-2018 AT&T Intellectual Property. All rights
- *                             reserved.
- * ================================================================================
- * Modifications Copyright (c) 2019 Samsung
- * ================================================================================
- * 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.client.req.policy;
-
-import com.att.eelf.configuration.EELFLogger;
-import com.att.eelf.configuration.EELFManager;
-
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.EnumMap;
-
-import org.onap.clamp.clds.model.properties.ModelProperties;
-import org.onap.clamp.clds.model.properties.PolicyChain;
-import org.onap.clamp.clds.model.properties.PolicyItem;
-import org.onap.policy.api.AttributeType;
-
-public class GuardPolicyAttributesConstructor {
-    public static final String ACTOR = "actor";
-    public static final String RECIPE = "recipe";
-    public static final String TARGETS = "targets";
-    public static final String CLNAME = "clname";
-    public static final String MIN = "min";
-    public static final String MAX = "max";
-    public static final String LIMIT = "limit";
-    public static final String TIME_WINDOW = "timeWindow";
-    public static final String TIME_UNITS = "timeUnits";
-    public static final String GUARD_ACTIVE_START = "guardActiveStart";
-    public static final String GUARD_ACTIVE_END = "guardActiveEnd";
-
-    private static final EELFLogger logger = EELFManager.getInstance()
-        .getLogger(GuardPolicyAttributesConstructor.class);
-
-    private GuardPolicyAttributesConstructor() {
-    }
-
-    public static Map<AttributeType, Map<String, String>> formatAttributes(ModelProperties modelProperties,
-        PolicyItem policyItem) {
-        Map<String, String> matchingAttributes = prepareMatchingAttributes(policyItem, modelProperties);
-        return createAttributesMap(matchingAttributes);
-    }
-
-    /**
-     * Get all the Guard policies from the policy chain.
-     * @param policyChain The policy chain
-     * @return The list of guard policies
-     */
-    public static List<PolicyItem> getAllPolicyGuardsFromPolicyChain(PolicyChain policyChain) {
-        List<PolicyItem> listItem = new ArrayList<>();
-        for (PolicyItem policyItem : policyChain.getPolicyItems()) {
-            if ("on".equals(policyItem.getEnableGuardPolicy())) {
-                listItem.add(policyItem);
-            }
-        }
-        return listItem;
-    }
-
-    private static Map<String, String> prepareMatchingAttributes(PolicyItem policyItem, ModelProperties modelProp) {
-        logger.info("Preparing matching attributes for guard...");
-        Map<String, String> matchingAttributes = new HashMap<>();
-        matchingAttributes.put(ACTOR, policyItem.getActor());
-        matchingAttributes.put(RECIPE, policyItem.getRecipe());
-        matchingAttributes.put(TARGETS, policyItem.getGuardTargets());
-        matchingAttributes.put(CLNAME, modelProp.getControlNameAndPolicyUniqueId());
-        if ("GUARD_MIN_MAX".equals(policyItem.getGuardPolicyType())) {
-            matchingAttributes.put(MIN, policyItem.getMinGuard());
-            matchingAttributes.put(MAX, policyItem.getMaxGuard());
-        } else if ("GUARD_YAML".equals(policyItem.getGuardPolicyType())) {
-            matchingAttributes.put(LIMIT, policyItem.getLimitGuard());
-            matchingAttributes.put(TIME_WINDOW, policyItem.getTimeWindowGuard());
-            matchingAttributes.put(TIME_UNITS, policyItem.getTimeUnitsGuard());
-        }
-        matchingAttributes.put(GUARD_ACTIVE_START, policyItem.getGuardActiveStart());
-        matchingAttributes.put(GUARD_ACTIVE_END, policyItem.getGuardActiveEnd());
-
-        logger.info("Prepared: " + matchingAttributes);
-        return matchingAttributes;
-    }
-
-    private static Map<AttributeType, Map<String, String>> createAttributesMap(Map<String, String> matchingAttributes) {
-        Map<AttributeType, Map<String, String>> attributes = new EnumMap<>(AttributeType.class);
-        attributes.put(AttributeType.MATCHING, matchingAttributes);
-        return attributes;
-    }
-}
diff --git a/src/main/java/org/onap/clamp/clds/client/req/policy/OperationalPolicyAttributesConstructor.java b/src/main/java/org/onap/clamp/clds/client/req/policy/OperationalPolicyAttributesConstructor.java
deleted file mode 100644 (file)
index af23626..0000000
+++ /dev/null
@@ -1,166 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * ONAP CLAMP
- * ================================================================================
- * Copyright (C) 2017-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============================================
- * Modifications copyright (c) 2018 Nokia
- * ===================================================================
- *
- */
-
-package org.onap.clamp.clds.client.req.policy;
-
-import com.att.eelf.configuration.EELFLogger;
-import com.att.eelf.configuration.EELFManager;
-import com.google.common.base.Strings;
-import com.google.common.collect.ImmutableMap;
-
-import java.io.UnsupportedEncodingException;
-import java.util.HashMap;
-import java.util.Map;
-
-import org.onap.clamp.clds.config.ClampProperties;
-import org.onap.clamp.clds.model.properties.ModelProperties;
-import org.onap.clamp.clds.model.properties.PolicyChain;
-import org.onap.clamp.clds.model.properties.PolicyItem;
-import org.onap.policy.api.AttributeType;
-import org.onap.policy.controlloop.policy.builder.BuilderException;
-
-public class OperationalPolicyAttributesConstructor {
-
-    private static final EELFLogger logger = EELFManager.getInstance()
-        .getLogger(OperationalPolicyAttributesConstructor.class);
-    public static final String TEMPLATE_NAME = "templateName";
-    public static final String CLOSED_LOOP_CONTROL_NAME = "closedLoopControlName";
-    public static final String NOTIFICATION_TOPIC = "notificationTopic";
-    public static final String OPERATION_TOPIC = "operationTopic";
-    public static final String CONTROL_LOOP_YAML = "controlLoopYaml";
-    public static final String CONTROLLER = "controller";
-    public static final String RECIPE = "Recipe";
-    public static final String MAX_RETRIES = "MaxRetries";
-    public static final String RETRY_TIME_LIMIT = "RetryTimeLimit";
-    public static final String RESOURCE_ID = "ResourceId";
-    public static final String RECIPE_TOPIC = "RecipeTopic";
-
-    private OperationalPolicyAttributesConstructor() {
-    }
-
-    /**
-     * Format the attributes.
-     * @param refProp The Clamp properties
-     * @param modelProperties The model properties
-     * @param modelElementId The model element ID
-     * @param policyChain The policy chain
-     * @return The attributes map
-     * @throws BuilderException Exception while building up the attributes map
-     * @throws UnsupportedEncodingException Unsupported encoding exception
-     */
-    public static Map<AttributeType, Map<String, String>> formatAttributes(ClampProperties refProp,
-        ModelProperties modelProperties,
-        String modelElementId, PolicyChain policyChain)
-            throws BuilderException, UnsupportedEncodingException {
-        modelProperties.setCurrentModelElementId(modelElementId);
-        modelProperties.setPolicyUniqueId(policyChain.getPolicyId());
-
-        String globalService = modelProperties.getGlobal().getService();
-
-        Map<String, String> ruleAttributes = prepareRuleAttributes(refProp, modelProperties, modelElementId,
-            policyChain, globalService);
-        Map<String, String> matchingAttributes = prepareMatchingAttributes(refProp, globalService);
-
-        return createAttributesMap(matchingAttributes, ruleAttributes);
-    }
-
-    private static Map<String, String> prepareRuleAttributes(ClampProperties clampProperties, 
-        ModelProperties modelProperties,
-        String modelElementId, PolicyChain policyChain, String globalService)
-            throws BuilderException, UnsupportedEncodingException {
-        logger.info("Preparing rule attributes...");
-        String templateName = clampProperties.getStringValue("op.templateName", globalService);
-        String operationTopic = clampProperties.getStringValue("op.operationTopic", globalService);
-        String notificationTopic = clampProperties.getStringValue("op.notificationTopic", globalService);
-
-        Map<String, String> ruleAttributes = new HashMap<>();
-        ruleAttributes.put(TEMPLATE_NAME, templateName);
-        ruleAttributes.put(CLOSED_LOOP_CONTROL_NAME, modelProperties.getControlNameAndPolicyUniqueId());
-        ruleAttributes.put(NOTIFICATION_TOPIC, notificationTopic);
-
-        ImmutableMap<String, String> attributes = createRuleAttributesFromPolicy(clampProperties, modelProperties,
-            modelElementId, policyChain, globalService, operationTopic);
-        ruleAttributes.putAll(attributes);
-        logger.info("Prepared: " + ruleAttributes);
-        return ruleAttributes;
-    }
-
-    private static Map<String, String> prepareMatchingAttributes(ClampProperties refProp, String globalService) {
-        logger.info("Preparing matching attributes...");
-        String controller = refProp.getStringValue("op.controller", globalService);
-        Map<String, String> matchingAttributes = new HashMap<>();
-        matchingAttributes.put(CONTROLLER, controller);
-        logger.info("Prepared: " + matchingAttributes);
-        return matchingAttributes;
-    }
-
-    private static Map<AttributeType, Map<String, String>> createAttributesMap(Map<String, String> matchingAttributes,
-        Map<String, String> ruleAttributes) {
-        Map<AttributeType, Map<String, String>> attributes = new HashMap<>();
-        attributes.put(AttributeType.RULE, ruleAttributes);
-        attributes.put(AttributeType.MATCHING, matchingAttributes);
-        return attributes;
-    }
-
-    private static ImmutableMap<String, String> createRuleAttributesFromPolicy(ClampProperties refProp, 
-        ModelProperties modelProperties,
-        String modelElementId, PolicyChain policyChain,
-        String globalService, String operationTopic)
-            throws BuilderException, UnsupportedEncodingException {
-        if (Strings.isNullOrEmpty(operationTopic)) {
-            // if no operationTopic, then don't format yaml - use first policy
-            String recipeTopic = refProp.getStringValue("op.recipeTopic", globalService);
-            return createRuleAttributesFromPolicyItem(
-                policyChain.getPolicyItems().get(0), recipeTopic);
-        } else {
-            return createRuleAttributesFromPolicyChain(policyChain, modelProperties,
-                modelElementId, operationTopic);
-        }
-    }
-
-    private static ImmutableMap<String, String> createRuleAttributesFromPolicyItem(PolicyItem policyItem, 
-        String recipeTopic) {
-        logger.info("recipeTopic=" + recipeTopic);
-        return ImmutableMap.<String, String>builder()
-            .put(RECIPE_TOPIC, recipeTopic)
-            .put(RECIPE, policyItem.getRecipe())
-            .put(MAX_RETRIES, String.valueOf(policyItem.getMaxRetries()))
-            .put(RETRY_TIME_LIMIT, String.valueOf(policyItem.getRetryTimeLimit()))
-            .put(RESOURCE_ID, String.valueOf(policyItem.getTargetResourceId()))
-            .build();
-    }
-
-    private static ImmutableMap<String, String> createRuleAttributesFromPolicyChain(PolicyChain policyChain,
-        ModelProperties modelProperties,
-        String modelElementId,
-        String operationTopic)
-            throws BuilderException, UnsupportedEncodingException {
-        logger.info("operationTopic=" + operationTopic);
-        String yaml = OperationalPolicyYamlFormatter.formatYaml(modelProperties, modelElementId, policyChain);
-        return ImmutableMap.<String, String>builder()
-            .put(OPERATION_TOPIC, operationTopic)
-            .put(CONTROL_LOOP_YAML, yaml)
-            .build();
-    }
-}
\ No newline at end of file
diff --git a/src/main/java/org/onap/clamp/clds/client/req/policy/OperationalPolicyYamlFormatter.java b/src/main/java/org/onap/clamp/clds/client/req/policy/OperationalPolicyYamlFormatter.java
deleted file mode 100644 (file)
index f2536b1..0000000
+++ /dev/null
@@ -1,219 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * ONAP CLAMP
- * ================================================================================
- * Copyright (C) 2017-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============================================
- * Modifications copyright (c) 2018 Nokia
- * ===================================================================
- *
- */
-
-package org.onap.clamp.clds.client.req.policy;
-
-import com.att.eelf.configuration.EELFLogger;
-import com.att.eelf.configuration.EELFManager;
-
-import java.io.UnsupportedEncodingException;
-import java.net.URLEncoder;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-
-import javax.ws.rs.BadRequestException;
-
-import org.onap.clamp.clds.model.properties.Global;
-import org.onap.clamp.clds.model.properties.ModelProperties;
-import org.onap.clamp.clds.model.properties.PolicyChain;
-import org.onap.clamp.clds.model.properties.PolicyItem;
-import org.onap.policy.controlloop.policy.Policy;
-import org.onap.policy.controlloop.policy.PolicyResult;
-import org.onap.policy.controlloop.policy.Target;
-import org.onap.policy.controlloop.policy.TargetType;
-import org.onap.policy.controlloop.policy.builder.BuilderException;
-import org.onap.policy.controlloop.policy.builder.ControlLoopPolicyBuilder;
-import org.onap.policy.controlloop.policy.builder.Message;
-import org.onap.policy.controlloop.policy.builder.Results;
-import org.onap.policy.sdc.Resource;
-import org.onap.policy.sdc.ResourceType;
-import org.onap.policy.sdc.Service;
-
-public class OperationalPolicyYamlFormatter {
-    private static final EELFLogger logger = EELFManager.getInstance().getLogger(OperationalPolicyYamlFormatter.class);
-
-    protected OperationalPolicyYamlFormatter() {
-    }
-
-    /**
-     * Format Operational OpenLoop Policy yaml.
-     *
-     * @param prop The model properties
-     * @param modelElementId The model element ID
-     * @param policyChain The policy chain
-     * @return The operational openloop policy in yaml format
-     * @throws BuilderException The builder exception
-     * @throws UnsupportedEncodingException The unsupported encoding exception
-     */
-    public static String formatOpenLoopYaml(ModelProperties prop, String modelElementId, PolicyChain policyChain)
-        throws BuilderException, UnsupportedEncodingException {
-        // get property objects
-        Global global = prop.getGlobal();
-        prop.setCurrentModelElementId(modelElementId);
-        prop.setPolicyUniqueId(policyChain.getPolicyId());
-        // convert values to SDC objects
-        Service service = new Service(global.getService());
-        Resource[] vfResources = convertToResources(global.getResourceVf(), ResourceType.VF);
-        // create builder
-        ControlLoopPolicyBuilder builder = ControlLoopPolicyBuilder.Factory.buildControlLoop(prop.getControlName(),
-            policyChain.getTimeout(), service, vfResources);
-        // builder.setTriggerPolicy(refProp.getStringValue("op.openloop.policy"));
-        // Build the specification
-        Results results = builder.buildSpecification();
-        validate(results);
-        return URLEncoder.encode(results.getSpecification(), "UTF-8");
-    }
-
-    /**
-     * Format Operational Policy yaml.
-     * @param prop The model properties
-     * @param modelElementId The model element ID
-     * @param policyChain The policy chain
-     * @return The operational policy properties in yaml format
-     * @throws BuilderException The builder exception
-     * @throws UnsupportedEncodingException The unsupported encoding exception
-     */
-    public static String formatYaml(ModelProperties prop, String modelElementId, PolicyChain policyChain)
-        throws BuilderException, UnsupportedEncodingException {
-        // get property objects
-        prop.setCurrentModelElementId(modelElementId);
-        prop.setPolicyUniqueId(policyChain.getPolicyId());
-
-        // create builder
-        ControlLoopPolicyBuilder builder = ControlLoopPolicyBuilder.Factory.buildControlLoop(prop.getControlName(),
-            policyChain.getTimeout());
-        // process each policy
-        Map<String, Policy> policyObjMap = new HashMap<>();
-        List<PolicyItem> policyItemList = orderParentFirst(policyChain.getPolicyItems());
-        for (PolicyItem policyItem : policyItemList) {
-            String policyName = policyItem.getRecipe() + " Policy";
-            Target target = new Target();
-            target.setType(TargetType.VM);
-            // We can send target type as VM/VNF for most of recipes
-            if (policyItem.getRecipeLevel() != null && !policyItem.getRecipeLevel().isEmpty()) {
-                target.setType(TargetType.valueOf(policyItem.getRecipeLevel()));
-            }
-            target.setResourceID(policyItem.getTargetResourceId());
-            String actor = policyItem.getActor();
-            Map<String, String> payloadMap = policyItem.getRecipePayload();
-            Policy policyObj;
-            if (policyItemList.indexOf(policyItem) == 0) {
-                String policyDescription = policyItem.getRecipe()
-                    + " Policy - the trigger (no parent) policy - created by CLDS";
-                policyObj = builder.setTriggerPolicy(policyName, policyDescription, actor, target,
-                    policyItem.getRecipe(), payloadMap, policyItem.getMaxRetries(), policyItem.getRetryTimeLimit());
-            } else {
-                Policy parentPolicyObj = policyObjMap.get(policyItem.getParentPolicy());
-                String policyDescription = policyItem.getRecipe() + " Policy - triggered conditionally by "
-                    + parentPolicyObj.getName() + " - created by CLDS";
-                policyObj = builder.setPolicyForPolicyResult(policyName, policyDescription, actor, target,
-                    policyItem.getRecipe(), payloadMap, policyItem.getMaxRetries(), policyItem.getRetryTimeLimit(),
-                    parentPolicyObj.getId(), convertToPolicyResults(policyItem.getParentPolicyConditions()));
-                logger.info("policyObj.id=" + policyObj.getId() + "; parentPolicyObj.id=" + parentPolicyObj.getId());
-            }
-            policyObjMap.put(policyItem.getId(), policyObj);
-        }
-        // Build the specification
-        Results results = builder.buildSpecification();
-        validate(results);
-        return URLEncoder.encode(results.getSpecification(), "UTF-8");
-    }
-
-    protected static List<PolicyItem> orderParentFirst(List<PolicyItem> inOrigList) {
-        List<PolicyItem> inList = new ArrayList<>();
-        inList.addAll(inOrigList);
-        List<PolicyItem> outList = new ArrayList<>();
-        int prevSize = 0;
-        while (!inList.isEmpty()) {
-            // check if there's a loop in the policy chain (the inList should
-            // have been reduced by at least one)
-            if (inList.size() == prevSize) {
-                throw new BadRequestException("Operation Policy validation problem: loop in Operation Policy chain");
-            }
-            prevSize = inList.size();
-            // the following loop should remove at least one PolicyItem from the
-            // inList
-            Iterator<PolicyItem> inListItr = inList.iterator();
-            while (inListItr.hasNext()) {
-                PolicyItem inItem = inListItr.next();
-                // check for trigger policy (no parent)
-                String parent = inItem.getParentPolicy();
-                if (parent == null || parent.length() == 0) {
-                    if (!outList.isEmpty()) {
-                        throw new BadRequestException(
-                            "Operation Policy validation problem: more than one trigger policy");
-                    } else {
-                        outList.add(inItem);
-                        inListItr.remove();
-                    }
-                } else {
-                    // check if this PolicyItem's parent has been processed
-                    for (PolicyItem outItem : outList) {
-                        if (outItem.getId().equals(parent)) {
-                            // if the inItem parent is already in the outList,
-                            // then add inItem to outList and remove from inList
-                            outList.add(inItem);
-                            inListItr.remove();
-                            break;
-                        }
-                    }
-                }
-            }
-        }
-        return outList;
-    }
-
-    protected static void validate(Results results) {
-        if (results.isValid()) {
-            logger.info("results.getSpecification()=" + results.getSpecification());
-        } else {
-            // throw exception with error info
-            StringBuilder sb = new StringBuilder();
-            sb.append("Operation Policy validation problem: ControlLoopPolicyBuilder failed with following messages: ");
-            for (Message message : results.getMessages()) {
-                sb.append(message.getMessage());
-                sb.append("; ");
-            }
-            throw new BadRequestException(sb.toString());
-        }
-    }
-
-    protected static Resource[] convertToResources(List<String> stringList, ResourceType resourceType) {
-        if (stringList == null || stringList.isEmpty()) {
-            return new Resource[0];
-        }
-        return stringList.stream().map(stringElem -> new Resource(stringElem, resourceType)).toArray(Resource[]::new);
-    }
-
-    protected static PolicyResult[] convertToPolicyResults(List<String> prList) {
-        if (prList == null || prList.isEmpty()) {
-            return new PolicyResult[0];
-        }
-        return prList.stream().map(PolicyResult::toResult).toArray(PolicyResult[]::new);
-    }
-
-}
\ No newline at end of file
diff --git a/src/main/java/org/onap/clamp/clds/client/req/policy/PolicyClient.java b/src/main/java/org/onap/clamp/clds/client/req/policy/PolicyClient.java
deleted file mode 100644 (file)
index 68d8529..0000000
+++ /dev/null
@@ -1,681 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * ONAP CLAMP
- * ================================================================================
- * Copyright (C) 2017-2018 AT&T Intellectual Property. All rights
- *                             reserved.
- * ================================================================================
- * Modifications Copyright (c) 2019 Samsung
- * ================================================================================
- * 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.client.req.policy;
-
-import com.att.eelf.configuration.EELFLogger;
-import com.att.eelf.configuration.EELFManager;
-
-import java.io.IOException;
-import java.io.OutputStream;
-import java.nio.file.Files;
-import java.nio.file.Path;
-import java.nio.file.Paths;
-import java.util.Collection;
-import java.util.Date;
-import java.util.Map;
-import java.util.UUID;
-
-import javax.ws.rs.BadRequestException;
-
-import org.onap.clamp.clds.config.ClampProperties;
-import org.onap.clamp.clds.config.PolicyConfiguration;
-import org.onap.clamp.clds.exception.policy.PolicyClientException;
-import org.onap.clamp.clds.model.CldsToscaModel;
-import org.onap.clamp.clds.model.properties.ModelProperties;
-import org.onap.clamp.clds.model.properties.PolicyItem;
-import org.onap.clamp.clds.util.LoggingUtils;
-import org.onap.policy.api.AttributeType;
-import org.onap.policy.api.ConfigRequestParameters;
-import org.onap.policy.api.DeletePolicyCondition;
-import org.onap.policy.api.DeletePolicyParameters;
-import org.onap.policy.api.DictionaryType;
-import org.onap.policy.api.ImportParameters;
-import org.onap.policy.api.ImportParameters.IMPORT_TYPE;
-import org.onap.policy.api.PolicyChangeResponse;
-import org.onap.policy.api.PolicyClass;
-import org.onap.policy.api.PolicyConfigException;
-import org.onap.policy.api.PolicyConfigType;
-import org.onap.policy.api.PolicyEngine;
-import org.onap.policy.api.PolicyEngineException;
-import org.onap.policy.api.PolicyParameters;
-import org.onap.policy.api.PolicyType;
-import org.onap.policy.api.PushPolicyParameters;
-import org.onap.policy.api.RuleProvider;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.context.annotation.Primary;
-import org.springframework.stereotype.Component;
-
-/**
- * Policy utility methods - specifically, send the policy.
- */
-@Component
-@Primary
-public class PolicyClient {
-
-    private PolicyEngine policyEngine;
-    private static final String LOG_POLICY_PREFIX = "Response is ";
-    private static final EELFLogger logger = EELFManager.getInstance().getLogger(PolicyClient.class);
-    private static final EELFLogger metricsLogger = EELFManager.getInstance().getMetricsLogger();
-    private static final String POLICY_MSTYPE_PROPERTY_NAME = "policy.ms.type";
-    private static final String POLICY_ONAPNAME_PROPERTY_NAME = "policy.onap.name";
-    private static final String POLICY_BASENAME_PREFIX_PROPERTY_NAME = "policy.base.policyNamePrefix";
-    private static final String POLICY_OP_NAME_PREFIX_PROPERTY_NAME = "policy.op.policyNamePrefix";
-    public static final String POLICY_MS_NAME_PREFIX_PROPERTY_NAME = "policy.ms.policyNamePrefix";
-    private static final String POLICY_OP_TYPE_PROPERTY_NAME = "policy.op.type";
-    private static final String TOSCA_FILE_TEMP_PATH = "tosca.filePath";
-    private static final String POLICY_COMMUNICATION_LOG_MESSAGE = "Exception occurred during policy communication";
-    private static final String POLICY_COMMUNICATION_EXC_MESSAGE = "Exception while communicating with Policy";
-    private static final String POLICY = "Policy";
-
-    @Autowired
-    private ClampProperties refProp;
-    @Autowired
-    private PolicyConfiguration policyConfiguration;
-
-    /**
-     * Perform Guard policy type.
-     *
-     * @param attributes
-     *        A map of attributes
-     * @param prop
-     *        The ModelProperties
-     * @param policyRequestUuid
-     *        PolicyRequest UUID
-     * @return The response message of policy
-     */
-    public String sendGuardPolicy(Map<AttributeType, Map<String, String>> attributes, ModelProperties prop,
-        String policyRequestUuid, PolicyItem policyItem) {
-        PolicyParameters policyParameters = new PolicyParameters();
-        // Set Policy Type(Mandatory)
-        policyParameters.setPolicyClass(PolicyClass.Decision);
-        // Set Policy Name(Mandatory)
-        policyParameters.setPolicyName(prop.getPolicyScopeAndNameWithUniqueGuardId());
-        // documentation says this is options, but when tested, got the
-        // following failure: java.lang.Exception: Policy send failed: PE300 -
-        // Data Issue: No policyDescription given.
-        policyParameters.setPolicyDescription(refProp.getStringValue("op.policyDescription"));
-        policyParameters.setOnapName("PDPD");
-        policyParameters.setRuleProvider(RuleProvider.valueOf(policyItem.getGuardPolicyType()));
-        policyParameters.setAttributes(attributes);
-        // Set a random UUID(Mandatory)
-        policyParameters.setRequestID(UUID.fromString(policyRequestUuid));
-
-        String rtnMsg = send(policyParameters, prop, null, null);
-        push(DictionaryType.Decision.toString(), prop, null);
-        return rtnMsg;
-    }
-
-    /**
-     * Perform BRMS policy type.
-     *
-     * @param attributes
-     *        A map of attributes
-     * @param prop
-     *        The ModelProperties
-     * @param policyRequestUuid
-     *        PolicyRequest UUID
-     * @return The response message of policy
-     */
-    public String sendBrmsPolicy(Map<AttributeType, Map<String, String>> attributes, ModelProperties prop,
-        String policyRequestUuid) {
-        PolicyParameters policyParameters = new PolicyParameters();
-        // Set Policy Type(Mandatory)
-        policyParameters.setPolicyConfigType(PolicyConfigType.BRMS_PARAM);
-        // Set Policy Name(Mandatory)
-        policyParameters.setPolicyName(prop.getPolicyScopeAndNameWithUniqueId());
-        // documentation says this is options, but when tested, got the
-        // following failure: java.lang.Exception: Policy send failed: PE300 -
-        // Data Issue: No policyDescription given.
-        policyParameters.setPolicyDescription(refProp.getStringValue("op.policyDescription"));
-        policyParameters.setAttributes(attributes);
-        // Set a random UUID(Mandatory)
-        policyParameters.setRequestID(UUID.fromString(policyRequestUuid));
-        String policyNamePrefix = refProp.getStringValue(POLICY_OP_NAME_PREFIX_PROPERTY_NAME);
-        String rtnMsg = send(policyParameters, prop, policyNamePrefix, null);
-        String policyType = refProp.getStringValue(POLICY_OP_TYPE_PROPERTY_NAME);
-        push(policyType, prop, null);
-        return rtnMsg;
-    }
-
-    /**
-     * Perform send of microservice policy in JSON.
-     *
-     * @param policyJson
-     *        The policy JSON
-     * @param prop
-     *        The ModelProperties
-     * @param policyRequestUuid
-     *        The policy Request UUID
-     * @return The response message of policy
-     */
-    public String sendMicroServiceInJson(String policyJson, ModelProperties prop, String policyRequestUuid) {
-        PolicyParameters policyParameters = new PolicyParameters();
-        // Set Policy Type
-        policyParameters.setPolicyConfigType(PolicyConfigType.MicroService);
-        policyParameters.setOnapName(refProp.getStringValue(POLICY_ONAPNAME_PROPERTY_NAME));
-        policyParameters.setPolicyName(prop.getCurrentPolicyScopeAndPolicyName());
-        policyParameters.setConfigBody(policyJson);
-        policyParameters.setConfigBodyType(PolicyType.JSON);
-        policyParameters.setRequestID(UUID.fromString(policyRequestUuid));
-        String policyNamePrefix = refProp.getStringValue(POLICY_MS_NAME_PREFIX_PROPERTY_NAME);
-        // Adding this line to clear the policy id from policy name while
-        // pushing to policy engine
-        prop.setPolicyUniqueId("");
-        String rtnMsg = send(policyParameters, prop, policyNamePrefix, null);
-        String policyType = refProp.getStringValue(POLICY_MSTYPE_PROPERTY_NAME);
-        push(policyType, prop, null);
-        return rtnMsg;
-    }
-
-    /**
-     * Perform send of base policy in OTHER type.
-     *
-     * @param configBody
-     *        The config policy string body
-     * @param configPolicyName
-     *        The config policy name of the component that has been pre-deployed in
-     *        DCAE
-     * @param prop
-     *        The ModelProperties
-     * @param policyRequestUuid
-     *        The policy request UUID
-     * @return The answer from policy call
-     */
-    public String sendBasePolicyInOther(String configBody, String configPolicyName, ModelProperties prop,
-        String policyRequestUuid) {
-        PolicyParameters policyParameters = new PolicyParameters();
-        // Set Policy Type
-        policyParameters.setPolicyConfigType(PolicyConfigType.Base);
-        policyParameters.setOnapName(refProp.getStringValue(POLICY_ONAPNAME_PROPERTY_NAME));
-        policyParameters.setPolicyName(prop.getCurrentPolicyScopeAndPolicyName());
-        policyParameters.setConfigBody(configBody);
-        policyParameters.setConfigBodyType(PolicyType.OTHER);
-        policyParameters.setConfigName("HolmesPolicy");
-        policyParameters.setPolicyName(configPolicyName);
-        policyParameters.setRequestID(UUID.fromString(policyRequestUuid));
-        // Adding this line to clear the policy id from policy name while
-        // pushing to policy engine
-        prop.setPolicyUniqueId("");
-        String rtnMsg = send(policyParameters, prop, refProp.getStringValue(POLICY_BASENAME_PREFIX_PROPERTY_NAME),
-            null);
-        push(PolicyConfigType.Base.toString(), prop, null);
-        return rtnMsg;
-    }
-
-    /**
-     * Perform send of Microservice policy in OTHER type.
-     *
-     * @param configBody
-     *        The config policy string body
-     * @param prop
-     *        The ModelProperties
-     * @return The answer from policy call
-     */
-    public String sendMicroServiceInOther(String configBody, ModelProperties prop) {
-        PolicyParameters policyParameters = new PolicyParameters();
-        // Set Policy Type
-        policyParameters.setPolicyConfigType(PolicyConfigType.MicroService);
-        policyParameters.setOnapName(refProp.getStringValue(POLICY_ONAPNAME_PROPERTY_NAME));
-        policyParameters.setPolicyName(prop.getCurrentPolicyScopeAndPolicyName());
-        policyParameters.setConfigBody(configBody);
-        String policyNamePrefix = refProp.getStringValue(POLICY_MS_NAME_PREFIX_PROPERTY_NAME);
-        // Adding this line to clear the policy id from policy name while
-        // pushing to policy engine
-        prop.setPolicyUniqueId("");
-        String rtnMsg = send(policyParameters, prop, policyNamePrefix, null);
-        String policyType = refProp.getStringValue(POLICY_MSTYPE_PROPERTY_NAME);
-        push(policyType, prop, null);
-        return rtnMsg;
-    }
-
-    /**
-     * Perform send of Configuration or Decision policies.
-     *
-     * @param policyParameters
-     *        The PolicyParameters
-     * @param prop
-     *        The ModelProperties
-     * @return The response message of Policy
-     */
-    protected String send(PolicyParameters policyParameters, ModelProperties prop, String policyPrefix,
-        String policyNameWithPrefix) {
-        // Verify whether it is triggered by Validation Test button from UI
-        if (prop.isTestOnly()) {
-            return "send not executed for test action";
-        }
-        // API method to create or update Policy.
-        PolicyChangeResponse response = null;
-        String responseMessage = "";
-        Date startTime = new Date();
-        try {
-            if ((PolicyClass.Decision.equals(policyParameters.getPolicyClass()) && !checkDecisionPolicyExists(prop))
-                || (PolicyClass.Config.equals(policyParameters.getPolicyClass())
-                    && !checkPolicyExists(prop, policyPrefix, policyNameWithPrefix))) {
-                LoggingUtils.setTargetContext(POLICY, "createPolicy");
-                logger.info("Attempting to create policy for action=" + prop.getActionCd());
-                response = getPolicyEngine().createPolicy(policyParameters);
-                responseMessage = response.getResponseMessage();
-            } else {
-                LoggingUtils.setTargetContext(POLICY, "updatePolicy");
-                logger.info("Attempting to update policy for action=" + prop.getActionCd());
-                response = getPolicyEngine().updatePolicy(policyParameters);
-                responseMessage = response.getResponseMessage();
-            }
-        } catch (Exception e) {
-            LoggingUtils.setResponseContext("900", "Policy send failed", this.getClass().getName());
-            LoggingUtils.setErrorContext("900", "Policy send error");
-            logger.error(POLICY_COMMUNICATION_LOG_MESSAGE, e);
-            throw new PolicyClientException(POLICY_COMMUNICATION_EXC_MESSAGE, e);
-        }
-        logger.info(LOG_POLICY_PREFIX + responseMessage);
-        LoggingUtils.setTimeContext(startTime, new Date());
-        if (response.getResponseCode() == 200) {
-            LoggingUtils.setResponseContext("0", "Policy send success", this.getClass().getName());
-            logger.info("Policy send successful");
-            metricsLogger.info("Policy send success");
-        } else {
-            LoggingUtils.setResponseContext("900", "Policy send failed", this.getClass().getName());
-            logger.warn("Policy send failed: " + responseMessage);
-            metricsLogger.info("Policy send failure");
-            throw new BadRequestException("Policy send failed: " + responseMessage);
-        }
-        return responseMessage;
-    }
-
-    /**
-     * Format and send push of policy.
-     *
-     * @param policyType
-     *        The policy Type
-     * @param prop
-     *        The ModelProperties
-     * @return The response message of policy
-     */
-    protected String push(String policyType, ModelProperties prop, String policyName) {
-        // Verify whether it is triggered by Validation Test button from UI
-        if (prop.isTestOnly()) {
-            return "push not executed for test action";
-        }
-        PushPolicyParameters pushPolicyParameters = new PushPolicyParameters();
-        pushPolicyParameters.setPolicyName(selectRightPolicyName(prop, policyType, policyName));
-        logger.info("Policy Name in Push policy method - " + pushPolicyParameters.getPolicyName());
-        pushPolicyParameters.setPolicyType(policyType);
-        pushPolicyParameters.setPdpGroup(refProp.getStringValue("policy.pdp.group"));
-        pushPolicyParameters.setRequestID(null);
-        // API method to create or update Policy.
-        PolicyChangeResponse response;
-        String responseMessage = "";
-        try {
-            LoggingUtils.setTargetContext(POLICY, "pushPolicy");
-            logger.info("Attempting to push policy...");
-            response = getPolicyEngine().pushPolicy(pushPolicyParameters);
-            if (response != null) {
-                responseMessage = response.getResponseMessage();
-            }
-        } catch (Exception e) {
-            LoggingUtils.setResponseContext("900", "Policy push failed", this.getClass().getName());
-            LoggingUtils.setErrorContext("900", "Policy push error");
-            logger.error(POLICY_COMMUNICATION_LOG_MESSAGE, e);
-            throw new PolicyClientException(POLICY_COMMUNICATION_EXC_MESSAGE, e);
-        }
-        logger.info(LOG_POLICY_PREFIX + responseMessage);
-        if (response != null && (response.getResponseCode() == 200 || response.getResponseCode() == 204)) {
-            LoggingUtils.setResponseContext("0", "Policy push success", this.getClass().getName());
-            logger.info("Policy push successful");
-            metricsLogger.info("Policy push success");
-        } else {
-            LoggingUtils.setResponseContext("900", "Policy push failed", this.getClass().getName());
-            logger.warn("Policy push failed: " + responseMessage);
-            metricsLogger.info("Policy push failure");
-            throw new BadRequestException("Policy push failed: " + responseMessage);
-        }
-        return responseMessage;
-    }
-
-    /**
-     * Use list Decision policy to know if the decision policy exists.
-     *
-     * @param prop
-     *        The model properties
-     * @return true if it exists, false otherwise
-     */
-    protected boolean checkDecisionPolicyExists(ModelProperties prop) {
-        boolean policyexists = false;
-
-        logger.info("Search in Policy Engine for DecisionpolicyName=" + prop.getPolicyScopeAndNameWithUniqueGuardId());
-        try {
-            // No other choice than pushing to see if it exists or not
-            String response = push(DictionaryType.Decision.toString(), prop, null);
-            if (response != null) {
-                policyexists = true;
-            }
-        } catch (BadRequestException e) {
-            // just print warning - if no policy version found
-            logger.warn("Policy not found...policy name - " + prop.getPolicyScopeAndNameWithUniqueGuardId(), e);
-        }
-        return policyexists;
-    }
-
-    /**
-     * Use list Policy API to retrieve the policy. Return true if policy exists
-     * otherwise return false.
-     *
-     * @param prop
-     *        The ModelProperties
-     * @param policyPrefix
-     *        The Policy Name Prefix
-     * @param policyNameWithPrefix
-     *        The Policy Full Name
-     * @return The response message from policy
-     * @throws PolicyConfigException
-     *         In case of issues with policy engine
-     */
-    protected boolean checkPolicyExists(ModelProperties prop, String policyPrefix, String policyNameWithPrefix) {
-        boolean policyexists = false;
-        String policyName = "";
-        try {
-            policyName = selectRightPolicyNameWithPrefix(prop, policyPrefix, policyNameWithPrefix);
-            logger.info("Search in Policy Engine for policyName=" + policyName);
-
-            ConfigRequestParameters configRequestParameters = new ConfigRequestParameters();
-            configRequestParameters.setPolicyName(policyName);
-            Collection<String> response = getPolicyEngine().listConfig(configRequestParameters);
-            if (response != null && !response.isEmpty() && !response.contains("Policy Name: null")) {
-                policyexists = true;
-            }
-        } catch (PolicyConfigException e1) {
-            // just print warning - if no policy version found
-            logger.warn("Policy not found...policy name - " + policyName, e1);
-        }
-        return policyexists;
-    }
-
-    /**
-     * This method create a new policy engine.
-     *
-     * @return A new policy engine
-     */
-    private synchronized PolicyEngine getPolicyEngine() {
-        try {
-            if (policyEngine == null) {
-                policyEngine = new PolicyEngine(policyConfiguration.getProperties());
-            }
-        } catch (PolicyEngineException e) {
-            throw new PolicyClientException("Exception when creating a new policy engine", e);
-        }
-        return policyEngine;
-    }
-
-    /**
-     * Format and send delete Micro Service requests to Policy.
-     *
-     * @param prop
-     *        The ModelProperties
-     * @return The response message from Policy
-     */
-    public String deleteMicrosService(ModelProperties prop) {
-        return findAndDelete(prop, POLICY_MS_NAME_PREFIX_PROPERTY_NAME, POLICY_MSTYPE_PROPERTY_NAME);
-    }
-
-    /**
-     * This method delete the Base policy.
-     *
-     * @param prop
-     *        The model Properties
-     * @return A string with the answer from policy
-     */
-    public String deleteBasePolicy(ModelProperties prop) {
-        return deletePolicy(prop, PolicyConfigType.Base.toString(), null);
-    }
-
-    /**
-     * Format and send delete Guard requests to Policy.
-     *
-     * @param prop
-     *        The ModelProperties
-     * @return The response message from policy
-     */
-    public String deleteGuard(ModelProperties prop) {
-        String deletePolicyResponse = "";
-        try {
-
-            if (checkDecisionPolicyExists(prop)) {
-                deletePolicyResponse = deletePolicy(prop, DictionaryType.Decision.toString(), null);
-            }
-        } catch (Exception e) {
-            logger.error(POLICY_COMMUNICATION_LOG_MESSAGE, e);
-            throw new PolicyClientException(POLICY_COMMUNICATION_EXC_MESSAGE, e);
-        }
-        return deletePolicyResponse;
-    }
-
-    /**
-     * Format and send delete BRMS requests to Policy.
-     *
-     * @param prop
-     *        The ModelProperties
-     * @return The response message from policy
-     */
-    public String deleteBrms(ModelProperties prop) {
-        return findAndDelete(prop, POLICY_OP_NAME_PREFIX_PROPERTY_NAME, POLICY_OP_TYPE_PROPERTY_NAME);
-    }
-
-    private String findAndDelete(ModelProperties prop, String policyPrefixProperty, String policyTypeProperty) {
-        String deletePolicyResponse = "";
-        try {
-            String policyNamePrefix = refProp.getStringValue(policyPrefixProperty);
-            if (checkPolicyExists(prop, policyNamePrefix, null)) {
-                String policyType = refProp.getStringValue(policyTypeProperty);
-                deletePolicyResponse = deletePolicy(prop, policyType, null);
-            }
-        } catch (Exception e) {
-            logger.error(POLICY_COMMUNICATION_LOG_MESSAGE, e);
-            throw new PolicyClientException(POLICY_COMMUNICATION_EXC_MESSAGE, e);
-        }
-        return deletePolicyResponse;
-    }
-
-    protected String selectRightPolicyName(ModelProperties prop, String policyType, String policyName) {
-        if (policyName == null) {
-            if (prop.getPolicyUniqueId() != null && !prop.getPolicyUniqueId().isEmpty()) {
-                if (DictionaryType.Decision.toString().equals(policyType)) {
-                    return prop.getPolicyScopeAndNameWithUniqueGuardId();
-                } else {
-                    return prop.getPolicyScopeAndNameWithUniqueId();
-                }
-            } else {
-                return prop.getCurrentPolicyScopeAndPolicyName();
-            }
-        } else {
-            return policyName;
-        }
-    }
-
-    /**
-     * Method to return correct policy name with prefix.
-     *
-     * @param prop
-     *        The ModelProperties
-     * @param policyPrefix
-     *        Policy Prefix
-     * @param policyNameWithPrefix
-     *        Policy Name With Prefix
-     * @return The policy name with the prefix
-     */
-    protected String selectRightPolicyNameWithPrefix(ModelProperties prop, String policyPrefix,
-        String policyNameWithPrefix) {
-        if (policyNameWithPrefix == null) {
-            if (prop.getPolicyUniqueId() != null && !prop.getPolicyUniqueId().isEmpty()) {
-                return prop.getCurrentPolicyScopeAndFullPolicyName(policyPrefix) + "_" + prop.getPolicyUniqueId();
-            } else {
-                return prop.getCurrentPolicyScopeAndFullPolicyName(policyPrefix);
-            }
-        } else {
-            return policyNameWithPrefix;
-        }
-    }
-
-    /**
-     * Format and send delete PAP and PDP requests to Policy.
-     *
-     * @param prop
-     *        The ModelProperties
-     * @param policyType
-     *        The policyType "Decision" or
-     * @return The response message from policy
-     */
-    protected String deletePolicy(ModelProperties prop, String policyType, String policyName) {
-        DeletePolicyParameters deletePolicyParameters = new DeletePolicyParameters();
-        deletePolicyParameters.setPolicyName(selectRightPolicyName(prop, policyType, policyName));
-        logger.info("Policy Name in delete policy method - " + deletePolicyParameters.getPolicyName());
-        logger.info("Deleting policy from PDP...");
-        deletePolicyParameters.setPolicyComponent("PDP");
-        deletePolicyParameters.setDeleteCondition(DeletePolicyCondition.ALL);
-        deletePolicyParameters.setPdpGroup(refProp.getStringValue("policy.pdp.group"));
-        deletePolicyParameters.setPolicyType(policyType);
-        // send delete request
-        logger.info("Deleting policy from PAP...");
-        StringBuilder responseMessage = new StringBuilder(sendDeletePolicy(deletePolicyParameters, prop));
-        deletePolicyParameters.setPolicyComponent("PAP");
-        deletePolicyParameters.setDeleteCondition(DeletePolicyCondition.ALL);
-        // send delete request
-        responseMessage.append(sendDeletePolicy(deletePolicyParameters, prop));
-        return responseMessage.toString();
-    }
-
-    /**
-     * Send delete request to Policy.
-     *
-     * @param deletePolicyParameters
-     *        The DeletePolicyParameters
-     * @param prop
-     *        The ModelProperties
-     * @return The response message from policy
-     */
-    protected String sendDeletePolicy(DeletePolicyParameters deletePolicyParameters, ModelProperties prop) {
-        // Verify whether it is triggered by Validation Test button from UI
-        if (prop.isTestOnly()) {
-            return "delete not executed for test action";
-        }
-        // API method to create or update Policy.
-        PolicyChangeResponse response = null;
-        String responseMessage = "";
-        try {
-            logger.info("Attempting to delete policy...");
-            response = getPolicyEngine().deletePolicy(deletePolicyParameters);
-            responseMessage = response.getResponseMessage();
-        } catch (Exception e) {
-            logger.error("Exception occurred during policy communnication", e);
-        }
-        logger.info(LOG_POLICY_PREFIX + responseMessage);
-        if (response != null && response.getResponseCode() == 200) {
-            logger.info("Policy delete successful");
-        } else {
-            logger.warn("Policy delete failed: " + responseMessage);
-            throw new BadRequestException("Policy delete failed: " + responseMessage);
-        }
-        return responseMessage;
-    }
-
-    /**
-     * Create a temp Tosca model file and perform import model to Policy Engine.
-     *
-     * @param cldsToscaModel
-     *        Policy model details
-     * @return The response message from policy
-     */
-    public String importToscaModel(CldsToscaModel cldsToscaModel) {
-        String filePath = "";
-        try {
-            String clampToscaPath = refProp.getStringValue(TOSCA_FILE_TEMP_PATH);
-            filePath = buildFilePathForToscaFile(clampToscaPath, cldsToscaModel.getToscaModelName());
-            logger.info("Writing Tosca model : " + filePath);
-            Path path = Paths.get(filePath);
-            Files.createDirectories(path.getParent());
-            // Create or Ovewrite an existing the file
-            try (OutputStream out = Files.newOutputStream(path)) {
-                out.write(cldsToscaModel.getToscaModelYaml().getBytes(), 0,
-                    cldsToscaModel.getToscaModelYaml().getBytes().length);
-            }
-        } catch (IOException e) {
-            logger.error("Exception caught when attempting to write Tosca files to disk", e);
-            throw new PolicyClientException("Exception caught when attempting to write Tosca files to disk", e);
-        }
-
-        ImportParameters importParameters = new ImportParameters();
-        importParameters.setImportParameters(cldsToscaModel.getToscaModelName(), cldsToscaModel.getToscaModelName(),
-            null, filePath, IMPORT_TYPE.MICROSERVICE, String.valueOf(cldsToscaModel.getVersion()));
-        return importModel(importParameters);
-    }
-
-    /**
-     * Import the model.
-     * @param importParameters
-     *        The ImportParameters
-     * @return The response message from policy
-     */
-    private String importModel(ImportParameters importParameters) {
-        PolicyChangeResponse response = null;
-        String responseMessage = "";
-
-        try {
-            logger.info("Attempting to import tosca policy model for action=" + importParameters.getFilePath());
-            response = getPolicyEngine().policyEngineImport(importParameters);
-            if (response != null) {
-                responseMessage = response.getResponseMessage();
-            }
-        } catch (Exception e) {
-            LoggingUtils.setResponseContext("900", "Policy Model import failed", this.getClass().getName());
-            LoggingUtils.setErrorContext("900", "Policy Model import error");
-            logger.error(POLICY_COMMUNICATION_LOG_MESSAGE, e);
-            throw new PolicyClientException(POLICY_COMMUNICATION_EXC_MESSAGE, e);
-        }
-        logger.info(LOG_POLICY_PREFIX + responseMessage);
-        if (response != null && (response.getResponseCode() == 200 || response.getResponseCode() == 204)) {
-            LoggingUtils.setResponseContext("0", "Policy Model import success", this.getClass().getName());
-            logger.info("Policy import model successful");
-            metricsLogger.info("Policy import model success");
-        } else {
-            LoggingUtils.setResponseContext("900", "Policy import model failed", this.getClass().getName());
-            logger.warn("Policy import model failed: " + responseMessage);
-            metricsLogger.info("Policy import model failure");
-            throw new BadRequestException("Policy import model failed: " + responseMessage);
-        }
-        return responseMessage;
-    }
-
-    /**
-     * Build file path for tosca file.
-     * @param clampToscaPath
-     *        Temp directory path for writing tosca files
-     * @param toscaModelName
-     *        Tosca Model Name
-     * @return File Path on the system
-     */
-    private String buildFilePathForToscaFile(String clampToscaPath, String toscaModelName) {
-        return clampToscaPath + "/" + toscaModelName + ".yml";
-    }
-}
\ No newline at end of file
diff --git a/src/main/java/org/onap/clamp/clds/client/req/tca/TcaRequestFormatter.java b/src/main/java/org/onap/clamp/clds/client/req/tca/TcaRequestFormatter.java
deleted file mode 100644 (file)
index ae0de07..0000000
+++ /dev/null
@@ -1,203 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * ONAP CLAMP
- * ================================================================================
- * Copyright (C) 2017-2018 AT&T Intellectual Property. All rights
- *                             reserved.
- * ================================================================================
- * Modifications Copyright (c) 2019 Samsung
- * ================================================================================
- * 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.client.req.tca;
-
-import com.att.eelf.configuration.EELFLogger;
-import com.att.eelf.configuration.EELFManager;
-
-import com.google.gson.JsonArray;
-import com.google.gson.JsonObject;
-import java.io.IOException;
-import java.util.Map;
-
-import org.onap.clamp.clds.config.ClampProperties;
-import org.onap.clamp.clds.exception.TcaRequestFormatterException;
-import org.onap.clamp.clds.model.properties.ModelProperties;
-import org.onap.clamp.clds.model.properties.Tca;
-import org.onap.clamp.clds.model.properties.TcaItem;
-import org.onap.clamp.clds.model.properties.TcaThreshold;
-import org.onap.clamp.clds.util.JsonUtils;
-import org.yaml.snakeyaml.Yaml;
-
-/**
- * Construct the requests for TCA policy and SDC.
- */
-public class TcaRequestFormatter {
-
-    protected static final EELFLogger logger = EELFManager.getInstance().getLogger(TcaRequestFormatter.class);
-    protected static final EELFLogger metricsLogger = EELFManager.getInstance().getMetricsLogger();
-
-    /**
-     * Hide the default constructor.
-     */
-    private TcaRequestFormatter() {
-    }
-
-    /**
-     * Format Tca Policy JSON request.
-     *
-     * @param refProp
-     *            The refProp generally created by Spring, it's an access on the
-     *            clds-references.properties file
-     * @param modelProperties
-     *            The Model Prop created from BPMN JSON and BPMN properties JSON
-     * @return The Json string containing that should be sent to policy
-     */
-    public static String createPolicyJson(ClampProperties refProp, ModelProperties modelProperties) {
-        try {
-            String service = modelProperties.getGlobal().getService();
-            Tca tca = modelProperties.getType(Tca.class);
-            modelProperties.setCurrentModelElementId(tca.getId());
-            // Always one tcaItem so must be set to id 0
-            modelProperties.setPolicyUniqueId("0");
-            JsonObject rootNode = refProp.getJsonTemplate("tca.policy.template", service ).getAsJsonObject();
-            String policyName = modelProperties.getCurrentPolicyScopeAndPolicyName();
-            rootNode.addProperty("policyName", policyName);
-            rootNode.get("content").getAsJsonObject().add("tca_policy",
-                    createPolicyContent(refProp, modelProperties, service, policyName, tca));
-            String tcaPolicyReq = rootNode.toString();
-            logger.info("tcaPolicyReq=" + tcaPolicyReq);
-            return tcaPolicyReq;
-        } catch (IOException e) {
-            throw new TcaRequestFormatterException("Exception caught when attempting to create the policy JSON", e);
-        }
-    }
-
-    /**
-     * Format Tca Policy Content JSON
-     *
-     * @param refProp
-     *            The refProp generally created by Spring, it's an access on the
-     *            clds-references.properties file
-     * @param modelProperties
-     *            The Model Prop created from BPMN JSON and BPMN properties JSON
-     * @param service
-     *            The service ID, if not specified getGlobal.getService will be
-     *            used
-     * @param policyName
-     *            The policyName, if not specified the
-     *            modelProperties.getCurrentPolicyScopeAndPolicyName will be
-     *            used
-     * @param tca
-     *            The Tca object, if not specified the
-     *            modelProperties.setCurrentModelElementId will be used
-     * @return The Json node containing what should be sent to policy
-     */
-    public static JsonObject createPolicyContent(ClampProperties refProp, ModelProperties modelProperties, String service,
-            String policyName, Tca tca) {
-        try {
-            String serviceToUse = service;
-            String policyNameToUse = policyName;
-            Tca tcaToUse = tca;
-            if (serviceToUse == null) {
-                serviceToUse = modelProperties.getGlobal().getService();
-            }
-            if (tcaToUse == null) {
-                tcaToUse = modelProperties.getType(Tca.class);
-                modelProperties.setCurrentModelElementId(tcaToUse.getId());
-            }
-            if (policyNameToUse == null) {
-                policyNameToUse = modelProperties.getCurrentPolicyScopeAndPolicyName();
-            }
-            JsonObject rootNode = refProp.getJsonTemplate("tca.template", serviceToUse).getAsJsonObject();
-            JsonObject metricsPerEventName = rootNode.get("metricsPerEventName").getAsJsonArray().get(0).getAsJsonObject();
-            metricsPerEventName.addProperty("eventName", tcaToUse.getTcaItem().getEventName());
-            metricsPerEventName.addProperty("policyName", policyNameToUse);
-            metricsPerEventName.addProperty("controlLoopSchemaType",tcaToUse.getTcaItem().getControlLoopSchemaType());
-            addThresholds(refProp, serviceToUse, metricsPerEventName, tcaToUse.getTcaItem(), modelProperties);
-            logger.info("tcaPolicyContent=" + rootNode.toString());
-            return rootNode;
-        } catch (IOException e) {
-            throw new TcaRequestFormatterException("Exception caught when attempting to create the policy content JSON",
-                    e);
-        }
-    }
-
-    /**
-     * Add threshold values to the existing policy JSON.
-     *
-     * @param refProp
-     *            The refProp generally created by Spring, it's an access on the
-     *            clds-references.properties file
-     * @param service
-     *            The Service value extracted from Global section of the Bpmn
-     *            Properties JSON
-     * @param appendToNode
-     *            The JSON structure from where the thresholds section must be
-     *            added
-     * @param tcaItem
-     *            The TCA item contained in the Tca object
-     * @param modelProperties
-     *            The Model Properties created from BPMN JSON and BPMN
-     *            properties JSON
-     */
-    private static void addThresholds(ClampProperties refProp, String service, JsonObject appendToNode, TcaItem tcaItem,
-            ModelProperties modelProperties) {
-        JsonArray tcaNodes = appendToNode.get("thresholds").getAsJsonArray();
-        try {
-            for (TcaThreshold tcaThreshold : tcaItem.getTcaThresholds()) {
-                JsonObject tcaNode = refProp.getJsonTemplate("tca.thresholds.template", service).getAsJsonObject();
-                tcaNode.addProperty("closedLoopControlName", modelProperties.getControlNameAndPolicyUniqueId());
-                tcaNode.addProperty("fieldPath", tcaThreshold.getFieldPath());
-                tcaNode.addProperty("thresholdValue", tcaThreshold.getThreshold());
-                tcaNode.addProperty("direction", tcaThreshold.getOperator());
-                tcaNode.addProperty("closedLoopEventStatus", tcaThreshold.getClosedLoopEventStatus());
-                tcaNodes.add(tcaNode);
-            }
-        } catch (IOException e) {
-            throw new TcaRequestFormatterException("Exception caught when attempting to create the thresholds JSON", e);
-        }
-    }
-
-    /**
-     * This method updates the blueprint that is received in the UI with the TCA
-     * Json.
-     *
-     * @param refProp
-     *            * The refProp generally created by Spring, it's an access on
-     *            the clds-references.properties file
-     * @param modelProperties
-     *            The Model Prop created from BPMN JSON and BPMN properties JSON
-     * @param yamlValue
-     *            The yaml string received from the UI
-     * @return The updated YAML as a string
-     */
-    public static String updatedBlueprintWithConfiguration(ClampProperties refProp, ModelProperties modelProperties,
-            String yamlValue) {
-        String jsonPolicy = JsonUtils.GSON.toJson(createPolicyContent(refProp, modelProperties, null, null, null));
-        logger.info("Yaml that will be updated:" + yamlValue);
-        Yaml yaml = new Yaml();
-        Map<String, Map> loadedYaml = yaml.load(yamlValue);
-        Map<String, Map> nodeTemplates = loadedYaml.get("node_templates");
-        Map<String, Map> tcaObject = nodeTemplates.get("tca_tca");
-        Map<String, Map> propsObject = tcaObject.get("properties");
-        Map<String, String> appPreferences = propsObject.get("app_preferences");
-        appPreferences.put("tca_policy", jsonPolicy);
-        String blueprint = yaml.dump(loadedYaml);
-        logger.info("Yaml updated:" + blueprint);
-        return blueprint;
-    }
-}
\ No newline at end of file
index 1fdc898..cb60894 100644 (file)
 package org.onap.clamp.clds.config.spring;
 
 import javax.sql.DataSource;
-import javax.xml.transform.TransformerConfigurationException;
 
 import org.onap.clamp.clds.config.ClampProperties;
 import org.onap.clamp.clds.config.EncodedPasswordBasicDataSource;
-import org.onap.clamp.clds.transform.XslTransformer;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.beans.factory.config.PropertiesFactoryBean;
 import org.springframework.boot.context.properties.ConfigurationProperties;
@@ -63,11 +61,4 @@ public class CldsConfiguration {
         bean.setLocation(appContext.getResource(refProp.getStringValue("files.systemProperties")));
         return bean;
     }
-
-    @Bean(name = "cldsBpmnTransformer")
-    public XslTransformer getCldsBpmnXslTransformer() throws TransformerConfigurationException {
-        XslTransformer xslTransformer = new XslTransformer();
-        xslTransformer.setXslResourceName("xsl/clds-bpmn-transformer.xsl");
-        return xslTransformer;
-    }
 }
\ No newline at end of file
diff --git a/src/main/java/org/onap/clamp/clds/dao/CldsDao.java b/src/main/java/org/onap/clamp/clds/dao/CldsDao.java
deleted file mode 100644 (file)
index 91ddfc4..0000000
+++ /dev/null
@@ -1,715 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * ONAP CLAMP
- * ================================================================================
- * Copyright (C) 2017-2019 AT&T Intellectual Property. All rights
- *                             reserved.
- * ================================================================================
- * Modifications Copyright (c) 2019 Samsung
- * ================================================================================
- * 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.dao;
-
-import com.att.eelf.configuration.EELFLogger;
-import com.att.eelf.configuration.EELFManager;
-
-import java.text.SimpleDateFormat;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
-import javax.sql.DataSource;
-
-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;
-import org.onap.clamp.clds.model.CldsModelProp;
-import org.onap.clamp.clds.model.CldsTemplate;
-import org.onap.clamp.clds.model.CldsToscaModel;
-import org.onap.clamp.clds.model.ValueItem;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.beans.factory.annotation.Qualifier;
-import org.springframework.jdbc.core.JdbcTemplate;
-import org.springframework.jdbc.core.namedparam.MapSqlParameterSource;
-import org.springframework.jdbc.core.namedparam.SqlParameterSource;
-import org.springframework.jdbc.core.simple.SimpleJdbcCall;
-import org.springframework.stereotype.Repository;
-
-/**
- * Data Access for CLDS Model tables.
- */
-@Repository("cldsDao")
-public class CldsDao {
-
-    private static final EELFLogger logger = EELFManager.getInstance().getLogger(CldsDao.class);
-    private JdbcTemplate jdbcTemplateObject;
-    private SimpleJdbcCall procGetModel;
-    private SimpleJdbcCall procGetModelTemplate;
-    private SimpleJdbcCall procSetModel;
-    private SimpleJdbcCall procInsEvent;
-    private SimpleJdbcCall procUpdEvent;
-    private SimpleJdbcCall procSetTemplate;
-    private SimpleJdbcCall procGetTemplate;
-    private SimpleJdbcCall procDelAllModelInstances;
-    private SimpleJdbcCall procInsModelInstance;
-    private SimpleJdbcCall procDeleteModel;
-    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;
-
-    private static final String DATE_FORMAT = "MM-dd-yyyy HH:mm:ss";
-
-    /**
-     * Log message when instantiating.
-     */
-    @Autowired
-    public CldsDao(@Qualifier("cldsDataSource") DataSource dataSource) {
-        logger.info("CldsDao instantiating...");
-        setDataSource(dataSource);
-    }
-
-    /**
-     * When dataSource is provided, instantiate spring jdbc objects.
-     *
-     * @param dataSource the data source
-     */
-    public void setDataSource(DataSource dataSource) {
-        this.jdbcTemplateObject = new JdbcTemplate(dataSource);
-        this.procGetModel = new SimpleJdbcCall(dataSource).withProcedureName("get_model");
-        this.procGetModelTemplate = new SimpleJdbcCall(dataSource).withProcedureName("get_model_template");
-        this.procSetModel = new SimpleJdbcCall(dataSource).withProcedureName("set_model");
-        this.procInsEvent = new SimpleJdbcCall(dataSource).withProcedureName("ins_event");
-        this.procUpdEvent = new SimpleJdbcCall(dataSource).withProcedureName("upd_event");
-        this.procGetTemplate = new SimpleJdbcCall(dataSource).withProcedureName("get_template");
-        this.procSetTemplate = new SimpleJdbcCall(dataSource).withProcedureName("set_template");
-        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");
-    }
-
-    /**
-     * Get a model from the database given the model name.
-     *
-     * @param modelName the model name
-     * @return the model
-     */
-    public CldsModel getModel(String modelName) {
-        return getModel(modelName, null);
-    }
-
-    // Get a model from the database given the model name or a controlNameUuid.
-    private CldsModel getModel(String modelName, String controlNameUuid) {
-        CldsModel model = new CldsModel();
-        model.setName(modelName);
-        SqlParameterSource in = new MapSqlParameterSource().addValue("v_model_name", modelName)
-                .addValue(V_CONTROL_NAME_UUID, controlNameUuid);
-        Map<String, Object> out = logSqlExecution(procGetModel, in);
-        populateModelProperties(model, out);
-        return model;
-    }
-
-    /**
-     * Get a model from the database given the controlNameUuid.
-     *
-     * @param controlNameUuid the control name uuid
-     * @return the model by uuid
-     */
-    public CldsModel getModelByUuid(String controlNameUuid) {
-        return getModel(null, controlNameUuid);
-    }
-
-    /**
-     * Get a model and template information from the database given the model name.
-     *
-     * @param modelName the model name
-     * @return model model template
-     */
-
-    public CldsModel getModelTemplate(String modelName) {
-        CldsModel model = new CldsModel();
-        model.setName(modelName);
-        SqlParameterSource in = new MapSqlParameterSource().addValue("v_model_name", modelName);
-        Map<String, Object> out = logSqlExecution(procGetModelTemplate, in);
-        populateModelProperties(model, out);
-        Map<String, Object> modelResults = logSqlExecution(procGetModel, in);
-        Object modelResultObject = modelResults.get("#result-set-1");
-        if (modelResultObject instanceof ArrayList) {
-            for (Object currModelInstance : (List<Object>) modelResultObject) {
-                if (currModelInstance instanceof HashMap) {
-                    HashMap<String, String> modelInstanceMap = (HashMap<String, String>) currModelInstance;
-                    CldsModelInstance modelInstance = new CldsModelInstance();
-                    modelInstance.setModelInstanceId(modelInstanceMap.get("model_instance_id"));
-                    modelInstance.setVmName(modelInstanceMap.get("vm_name"));
-                    modelInstance.setLocation(modelInstanceMap.get("location"));
-                    model.getCldsModelInstanceList().add(modelInstance);
-                    logger.info("value of currModel: {}", currModelInstance);
-                }
-            }
-        }
-        return model;
-    }
-
-    /**
-     * Update model in the database using parameter values and return updated model
-     * object.
-     *
-     * @param model  the model
-     * @param userid the userid
-     * @return model
-     */
-    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_deployment_status_url", model.getDeploymentStatusUrl())
-                .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));
-        model.setId((String) (out.get("v_model_id")));
-        setEventProp(model.getEvent(), out);
-        return model;
-    }
-
-    /**
-     * Inserts new modelInstance in the database using parameter values and return
-     * updated model object.
-     *
-     * @param model              the model
-     * @param modelInstancesList the model instances list
-     */
-    public void insModelInstance(CldsModel model, List<CldsModelInstance> modelInstancesList) {
-        // Delete all existing model instances for given controlNameUUID
-        logger.debug("deleting instances for: {}", model.getControlNameUuid());
-        delAllModelInstances(model.getControlNameUuid());
-        if (modelInstancesList == null) {
-            logger.debug("modelInstancesList == null");
-        } else {
-            for (CldsModelInstance currModelInstance : modelInstancesList) {
-                logger.debug("v_control_name_uuid={}", model.getControlNameUuid());
-                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());
-                Map<String, Object> out = logSqlExecution(procInsModelInstance, in);
-                model.setId((String) (out.get("v_model_id")));
-                CldsModelInstance modelInstance = new CldsModelInstance();
-                modelInstance.setLocation(currModelInstance.getLocation());
-                modelInstance.setVmName(currModelInstance.getVmName());
-                modelInstance.setModelInstanceId((String) (out.get("v_model_instance_id")));
-                model.getCldsModelInstanceList().add(modelInstance);
-            }
-        }
-    }
-
-    /**
-     * Insert an event in the database - require either modelName or
-     * controlNamePrefix/controlNameUuid.
-     *
-     * @param modelName         the model name
-     * @param controlNamePrefix the control name prefix
-     * @param controlNameUuid   the control name uuid
-     * @param cldsEvent         the clds event
-     * @return clds event
-     */
-    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());
-        Map<String, Object> out = logSqlExecution(procInsEvent, in);
-        event.setId((String) (out.get("v_event_id")));
-        return event;
-    }
-
-    private String delAllModelInstances(String controlNameUUid) {
-        SqlParameterSource in = new MapSqlParameterSource().addValue(V_CONTROL_NAME_UUID, controlNameUUid);
-        Map<String, Object> out = logSqlExecution(procDelAllModelInstances, in);
-        return (String) (out.get("v_model_id"));
-    }
-
-    /**
-     * Update event with process instance id.
-     *
-     * @param eventId           the event id
-     * @param processInstanceId the process instance id
-     */
-    public void updEvent(String eventId, String processInstanceId) {
-        SqlParameterSource in = new MapSqlParameterSource().addValue("v_event_id", eventId)
-                .addValue("v_process_instance_id", processInstanceId);
-        logSqlExecution(procUpdEvent, in);
-    }
-
-    /**
-     * Return list of model names.
-     *
-     * @return model names
-     */
-    public List<ValueItem> getModelNames() {
-        String sql = "SELECT model_name FROM model ORDER BY 1;";
-        return jdbcTemplateObject.query(sql, new ValueItemMapper());
-    }
-
-    /**
-     * Update template in the database using parameter values and return updated
-     * template object.
-     *
-     * @param template the template
-     * @param userid   the userid
-     */
-    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());
-
-        // properties to setup the template is return from the logSqlExecution method
-        setTemplateBaseProp(template, logSqlExecution(procSetTemplate, in));
-    }
-
-    /**
-     * Return list of template names.
-     *
-     * @return template names
-     */
-    public List<ValueItem> getTemplateNames() {
-        String sql = "SELECT template_name FROM template ORDER BY 1;";
-        return jdbcTemplateObject.query(sql, new ValueItemMapper());
-    }
-
-    /**
-     * Get a template from the database given the model name.
-     *
-     * @param templateName the template name
-     * @return model template
-     */
-    public CldsTemplate getTemplate(String templateName) {
-        CldsTemplate template = new CldsTemplate();
-        template.setName(templateName);
-        SqlParameterSource in = new MapSqlParameterSource().addValue("v_template_name", templateName);
-
-        Map<String, Object> out = logSqlExecution(procGetTemplate, in);
-        setTemplateBaseProp(template, out);
-
-        // additional template setting's
-        template.setPropText((String) out.get("v_template_doc_text"));
-        template.setBpmnText((String) out.get("v_template_bpmn_text"));
-        template.setImageText((String) out.get("v_template_image_text"));
-        return template;
-    }
-
-    /**
-     * Helper method to setup the base template properties.
-     *
-     * @param template the template
-     * @param prop     collection with the properties
-     */
-    private void setTemplateBaseProp(CldsTemplate template, Map prop) {
-        template.setId((String) prop.get("v_template_id"));
-        template.setBpmnUserid((String) prop.get("v_template_bpmn_user_id"));
-        template.setBpmnId((String) prop.get("v_template_bpmn_id"));
-        template.setImageId((String) prop.get("v_template_image_id"));
-        template.setImageUserid((String) prop.get("v_template_image_user_id"));
-        template.setPropId((String) prop.get("v_template_doc_id"));
-        template.setPropUserid((String) prop.get("v_template_doc_user_id"));
-    }
-
-    private static Map<String, Object> logSqlExecution(SimpleJdbcCall call, SqlParameterSource source) {
-        try {
-            return call.execute(source);
-        } catch (Exception e) {
-            logger.error("Exception occured in " + source.getClass().getCanonicalName() + ": " + e);
-            throw e;
-        }
-    }
-
-    /**
-     * Do health check.
-     */
-    public void doHealthCheck() {
-        jdbcTemplateObject.execute(HEALTHCHECK);
-    }
-
-    /**
-     * 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'";
-        List<Map<String, Object>> rows = jdbcTemplateObject.queryForList(modelsSql);
-        CldsModelProp cldsModelProp = null;
-        for (Map<String, Object> row : rows) {
-            cldsModelProp = new CldsModelProp();
-            cldsModelProp.setId((String) row.get("model_id"));
-            cldsModelProp.setName((String) row.get("model_name"));
-            cldsModelProp.setPropId((String) row.get("model_prop_id"));
-            cldsModelProp.setPropText((String) row.get("model_prop_text"));
-            cldsModelPropList.add(cldsModelProp);
-        }
-        return cldsModelPropList;
-    }
-
-    /**
-     * Method to delete model from database.
-     *
-     * @param modelName the model name
-     */
-    public void deleteModel(String modelName) {
-        SqlParameterSource in = new MapSqlParameterSource().addValue("v_model_name", modelName);
-        logSqlExecution(procDeleteModel, in);
-    }
-
-    private void populateModelProperties(CldsModel model, Map out) {
-        model.setControlNamePrefix((String) out.get(V_CONTROL_NAME_PREFIX));
-        model.setControlNameUuid((String) out.get(V_CONTROL_NAME_UUID));
-        model.setId((String) out.get("v_model_id"));
-        model.setTemplateId((String) out.get("v_template_id"));
-        model.setTemplateName((String) (out.get("v_template_name")));
-        model.setBpmnText((String) out.get("v_template_bpmn_text"));
-        model.setPropText((String) out.get("v_model_prop_text"));
-        model.setImageText((String) out.get("v_template_image_text"));
-        model.setDocText((String) out.get("v_template_doc_text"));
-        model.setBlueprintText((String) out.get("v_model_blueprint_text"));
-        model.setTypeId((String) out.get("v_service_type_id"));
-        model.setDeploymentId((String) out.get("v_deployment_id"));
-        model.setDeploymentStatusUrl((String) out.get("v_deployment_status_url"));
-
-        setEventProp(model.getEvent(), out);
-    }
-
-    /**
-     * Helper method to setup the event prop to the CldsEvent class.
-     *
-     * @param event the clds event
-     * @param prop  collection with the configuration
-     */
-    private void setEventProp(CldsEvent event, Map prop) {
-        event.setId((String) prop.get("v_event_id"));
-        event.setActionCd((String) prop.get("v_action_cd"));
-        event.setActionStateCd((String) prop.get("v_action_state_cd"));
-        event.setProcessInstanceId((String) prop.get("v_event_process_instance_id"));
-        event.setUserid((String) prop.get("v_event_user_id"));
-    }
-
-    /**
-     * Method to retrieve a tosca models by Policy Type from database.
-     *
-     * @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 the policy type
-     * @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 toscaModelName the tosca model name
-     * @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(DATE_FORMAT);
-        List<CldsToscaModel> cldsToscaModels = new ArrayList<>();
-
-        String toscaModelSql = new StringBuilder("SELECT tm.tosca_model_name, tm.tosca_model_id, tm.policy_type, "
-                + "tmr.tosca_model_revision_id, tmr.tosca_model_json, tmr.version, tmr.user_id, tmr.createdTimestamp,"
-                + "tmr.lastUpdatedTimestamp").append(toscaModelName != null ? (", tmr.tosca_model_yaml") : "").append(
-                        " FROM tosca_model tm, tosca_model_revision tmr WHERE tm.tosca_model_id = tmr.tosca_model_id")
-                        .append(toscaModelName != null ? (" AND tm.tosca_model_name = '" + toscaModelName + "'") : "")
-                        .append(policyType != null ? (" AND tm.policy_type = '" + policyType + "'") : "")
-                        .append(" AND tmr.version = (select max(version) from tosca_model_revision st where tmr.tosca_model_id"
-                                + "=st.tosca_model_id)")
-                        .toString();
-
-        List<Map<String, Object>> rows = jdbcTemplateObject.queryForList(toscaModelSql);
-
-        if (rows != null) {
-            rows.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.setToscaModelJson((String) row.get("tosca_model_json"));
-                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;
-    }
-
-    /**
-     * Method to upload a new version of Tosca Model Yaml in Database.
-     *
-     * @param cldsToscaModel the clds tosca model
-     * @param userId         the user id
-     * @return CldsToscaModel clds tosca model
-     */
-    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 the clds tosca model
-     * @param userId         the user id
-     * @return CldsToscaModel clds tosca model
-     */
-    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 the clds dictionary
-     */
-    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   the dictionary id
-     * @param cldsDictionary the clds dictionary
-     * @param userId         the user id
-     */
-    public void updateDictionary(String dictionaryId, CldsDictionary cldsDictionary, String userId) {
-
-        String dictionarySql = new StringBuilder("UPDATE dictionary SET dictionary_name = '")
-                .append(cldsDictionary.getDictionaryName()).append("', modified_by = '").append(userId)
-                .append("'WHERE dictionary_id = '").append(dictionaryId).append("'").toString();
-        jdbcTemplateObject.update(dictionarySql);
-        cldsDictionary.setUpdatedBy(userId);
-    }
-
-    /**
-     * Method to get list of Dictionaries from the Database.
-     *
-     * @param dictionaryId   the dictionary id
-     * @param dictionaryName the dictionary name
-     * @return dictionary
-     */
-    public List<CldsDictionary> getDictionary(String dictionaryId, String dictionaryName) {
-        SimpleDateFormat sdf = new SimpleDateFormat(DATE_FORMAT);
-        List<CldsDictionary> dictionaries = new ArrayList<>();
-
-        String whereFilter = " WHERE ";
-        if (dictionaryName != null) {
-            whereFilter += "dictionary_name = '" + dictionaryName + "'";
-            if (dictionaryId != null) {
-                whereFilter += " AND dictionary_id = '" + dictionaryId + "'";
-            }
-        } else if (dictionaryId != null) {
-            whereFilter += "dictionary_id = '" + dictionaryId + "'";
-        } else {
-            whereFilter = "";
-        }
-        String dictionarySql = new StringBuilder(
-                "SELECT dictionary_id, dictionary_name, created_by, " + "modified_by, timestamp FROM dictionary")
-                        .append(whereFilter).toString();
-
-        List<Map<String, Object>> rows = jdbcTemplateObject.queryForList(dictionarySql);
-
-        if (rows != null) {
-            rows.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 the clds dictionary item
-     * @param userId             the user id
-     */
-    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 the dictionary element id
-     * @param cldsDictionaryItem  the clds dictionary item
-     * @param userId              the user id
-     */
-    public void updateDictionaryElements(String dictionaryElementId, CldsDictionaryItem cldsDictionaryItem,
-            String userId) {
-
-        String dictionarySql = new StringBuilder().append("UPDATE dictionary_elements SET dict_element_name = '")
-                .append(cldsDictionaryItem.getDictElementName()).append("', dict_element_short_name = '")
-                .append(cldsDictionaryItem.getDictElementShortName()).append("', dict_element_description= '")
-                .append(cldsDictionaryItem.getDictElementDesc()).append("', dict_element_type = '")
-                .append(cldsDictionaryItem.getDictElementType()).append("', modified_by = '").append(userId).append("'")
-                .append(" WHERE dict_element_id = '").append(dictionaryElementId).append("'").toString();
-        jdbcTemplateObject.update(dictionarySql);
-        cldsDictionaryItem.setUpdatedBy(userId);
-    }
-
-    /**
-     * Method to get list of all dictionary elements for a given dictionary in the
-     * Database.
-     *
-     * @param dictionaryName       the dictionary name
-     * @param dictionaryId         the dictionary id
-     * @param dictElementShortName the dict element short name
-     * @return dictionary elements
-     */
-    public List<CldsDictionaryItem> getDictionaryElements(String dictionaryName, String dictionaryId,
-            String dictElementShortName) {
-        SimpleDateFormat sdf = new SimpleDateFormat(DATE_FORMAT);
-        List<CldsDictionaryItem> dictionaryItems = new ArrayList<>();
-        String dictionarySql = new StringBuilder("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")
-                        .append((dictionaryId != null) ? (" AND d.dictionary_id = '" + dictionaryId + "'") : "")
-                        .append((dictElementShortName != null)
-                                ? (" AND de.dict_element_short_name = '" + dictElementShortName + "'")
-                                : "")
-                        .append((dictionaryName != null) ? (" AND dictionary_name = '" + dictionaryName + "'") : "")
-                        .toString();
-
-        List<Map<String, Object>> rows = jdbcTemplateObject.queryForList(dictionarySql);
-
-        if (rows != null) {
-            rows.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 get Map of all dictionary elements with key as dictionary short
-     * name and value as the full name.
-     *
-     * @param dictionaryElementType the dictionary element type
-     * @return Map of dictionary elements as key value pair
-     */
-    public Map<String, String> getDictionaryElementsByType(String dictionaryElementType) {
-        Map<String, String> dictionaryItems = new HashMap<>();
-        String dictionarySql = new StringBuilder("SELECT dict_element_name, dict_element_short_name "
-                + "FROM dictionary_elements WHERE dict_element_type = '").append(dictionaryElementType).append("'")
-                        .toString();
-
-        List<Map<String, Object>> rows = jdbcTemplateObject.queryForList(dictionarySql);
-
-        if (rows != null) {
-            rows.forEach(row -> {
-                dictionaryItems.put(((String) row.get("dict_element_short_name")),
-                        ((String) row.get("dict_element_name")));
-            });
-        }
-        return dictionaryItems;
-    }
-}
diff --git a/src/main/java/org/onap/clamp/clds/dao/ValueItemMapper.java b/src/main/java/org/onap/clamp/clds/dao/ValueItemMapper.java
deleted file mode 100644 (file)
index 599bef7..0000000
+++ /dev/null
@@ -1,42 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * ONAP CLAMP
- * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights
- *                             reserved.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END============================================
- * ===================================================================
- * 
- */
-
-package org.onap.clamp.clds.dao;
-
-import java.sql.ResultSet;
-import java.sql.SQLException;
-
-import org.onap.clamp.clds.model.ValueItem;
-import org.springframework.jdbc.core.RowMapper;
-
-/**
- * Generic mapper for list of values.
- */
-public final class ValueItemMapper implements RowMapper<ValueItem> {
-    @Override
-    public ValueItem mapRow(ResultSet rs, int rowNum) throws SQLException {
-        ValueItem item = new ValueItem();
-        item.setValue(rs.getString(1));
-        return item;
-    }
-}
diff --git a/src/main/java/org/onap/clamp/clds/model/CldsAlarmCondition.java b/src/main/java/org/onap/clamp/clds/model/CldsAlarmCondition.java
deleted file mode 100644 (file)
index 114d785..0000000
+++ /dev/null
@@ -1,68 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * ONAP CLAMP
- * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights
- *                             reserved.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License"); 
- * you may not use this file except in compliance with the License. 
- * You may obtain a copy of the License at
- * 
- * http://www.apache.org/licenses/LICENSE-2.0
- * 
- * Unless required by applicable law or agreed to in writing, software 
- * distributed under the License is distributed on an "AS IS" BASIS, 
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
- * See the License for the specific language governing permissions and 
- * limitations under the License.
- * ============LICENSE_END============================================
- * ===================================================================
- * 
- */
-
-package org.onap.clamp.clds.model;
-
-import java.io.Serializable;
-
-public class CldsAlarmCondition implements Serializable {
-
-    private static final long serialVersionUID = 4271364536747705555L;
-    private String            eventSourceType;
-    private String            alarmConditionKey;
-    private String            severity;
-    private String            eventName;
-
-    public String getEventSourceType() {
-        return eventSourceType;
-    }
-
-    public void setEventSourceType(String eventSourceType) {
-        this.eventSourceType = eventSourceType;
-    }
-
-    public String getSeverity() {
-        return severity;
-    }
-
-    public void setSeverity(String severity) {
-        this.severity = severity;
-    }
-
-    public String getAlarmConditionKey() {
-        return alarmConditionKey;
-    }
-
-    public void setAlarmConditionKey(String alarmConditionKey) {
-        this.alarmConditionKey = alarmConditionKey;
-    }
-
-    public String getEventName() {
-        return eventName;
-    }
-
-    public void setEventName(String eventName) {
-        this.eventName = eventName;
-    }
-
-}
diff --git a/src/main/java/org/onap/clamp/clds/model/CldsDbServiceCache.java b/src/main/java/org/onap/clamp/clds/model/CldsDbServiceCache.java
deleted file mode 100644 (file)
index 140d6e8..0000000
+++ /dev/null
@@ -1,85 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * ONAP CLAMP
- * ================================================================================
- * Copyright (C) 2017-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.io.ByteArrayInputStream;
-import java.io.ByteArrayOutputStream;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.ObjectOutputStream;
-
-public class CldsDbServiceCache {
-
-    private String invariantId;
-    private String serviceId;
-    private InputStream cldsDataInstream;
-
-    /**
-     * Constructor.
-     * @param cldsServiceData The cles service data
-     * @throws IOException IO Exception
-     */
-    public CldsDbServiceCache(CldsServiceData cldsServiceData) throws IOException {
-        setCldsDataInstream(cldsServiceData);
-        setInvariantId(cldsServiceData.getServiceInvariantUUID());
-        setServiceId(cldsServiceData.getServiceUUID());
-    }
-
-    public String getInvariantId() {
-        return invariantId;
-    }
-
-    public void setInvariantId(String invariantId) {
-        this.invariantId = invariantId;
-    }
-
-    public String getServiceId() {
-        return serviceId;
-    }
-
-    public void setServiceId(String serviceId) {
-        this.serviceId = serviceId;
-    }
-
-    public InputStream getCldsDataInstream() {
-        return cldsDataInstream;
-    }
-
-    public void setCldsDataInstream(InputStream cldsDataInputstream) {
-        this.cldsDataInstream = cldsDataInputstream;
-    }
-
-    public void setCldsDataInstream(CldsServiceData cldsServiceData) throws IOException {
-        this.cldsDataInstream = getInstreamFromObject(cldsServiceData);
-    }
-
-    private InputStream getInstreamFromObject(CldsServiceData cldsServiceData) throws IOException {
-        ByteArrayOutputStream baos = new ByteArrayOutputStream();
-        ObjectOutputStream oos = new ObjectOutputStream(baos);
-        oos.writeObject(cldsServiceData);
-        oos.flush();
-        oos.close();
-        return new ByteArrayInputStream(baos.toByteArray());
-    }
-}
index 27a430c..35fbcec 100644 (file)
 
 package org.onap.clamp.clds.model;
 
+import com.google.gson.annotations.Expose;
+
 import java.util.ArrayList;
 import java.util.List;
 
-import org.onap.clamp.clds.dao.CldsDao;
-
-import com.google.gson.annotations.Expose;
-
 /**
  * Represents a CLDS Dictionary.
  */
@@ -50,33 +48,6 @@ public class CldsDictionary {
     @Expose
     private List<CldsDictionaryItem> cldsDictionaryItems = new ArrayList<>();
 
-    /**
-     * Creates or updates dictionary item for a dictionary in DB.
-     *
-     * @param dictionaryName The dictionary name
-     * @param cldsDao        The CldsDao
-     * @param userId         The user ID
-     */
-    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);
-        }
-    }
-
     /**
      * Get the dictionary ID.
      * 
index 14a6850..1b79bdf 100644 (file)
@@ -25,10 +25,6 @@ package org.onap.clamp.clds.model;
 
 import com.google.gson.annotations.Expose;
 
-import java.util.List;
-
-import org.onap.clamp.clds.dao.CldsDao;
-
 /**
  * Represents a CLDS Dictionary Item.
  */
@@ -53,34 +49,6 @@ public class CldsDictionaryItem {
     @Expose
     private String lastUpdatedDate;
 
-    /**
-     * Save the dictionary item.
-     *
-     * @param dictionaryName The name of the dictionary
-     * @param cldsDao        The cldsDao
-     * @param userId         The user id
-     */
-    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);
-            }
-        }
-    }
-
     /**
      * Get the dictionary element id.
      *
diff --git a/src/main/java/org/onap/clamp/clds/model/CldsEvent.java b/src/main/java/org/onap/clamp/clds/model/CldsEvent.java
deleted file mode 100644 (file)
index cc57f9e..0000000
+++ /dev/null
@@ -1,300 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * ONAP CLAMP
- * ================================================================================
- * Copyright (C) 2017-2019 AT&T Intellectual Property. All rights
- *                             reserved.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END============================================
- * ===================================================================
- *
- */
-
-package org.onap.clamp.clds.model;
-
-import org.onap.clamp.clds.dao.CldsDao;
-
-/**
- * Represent a CLDS Event.
- */
-public class CldsEvent {
-    /**
-     * The constant ACTION_TEST.
-     */
-    public static final String ACTION_TEST = "TEST";
-    /**
-     * The constant ACTION_CREATE.
-     */
-    public static final String ACTION_CREATE = "CREATE";
-    /**
-     * The constant ACTION_MODIFY.
-     */
-    public static final String ACTION_MODIFY = "MODIFY";
-    /**
-     * The constant ACTION_SUBMIT.
-     */
-    public static final String ACTION_SUBMIT = "SUBMIT";
-    /**
-     * The constant ACTION_RESUBMIT.
-     */
-    // an update before model is active
-    public static final String ACTION_RESUBMIT = "RESUBMIT";
-    /**
-     * The constant ACTION_SUBMITDCAE.
-     */
-    // For simplified models
-    public static final String ACTION_SUBMITDCAE = "SUBMITDCAE";
-    /**
-     * The constant ACTION_SUBMITPOLICY.
-     */
-    public static final String ACTION_SUBMITPOLICY = "SUBMITPOLICY";
-    /**
-     * The constant ACTION_DISTRIBUTE.
-     */
-    // only from dcae
-    public static final String ACTION_DISTRIBUTE = "DISTRIBUTE";
-    /**
-     * The constant ACTION_DEPLOY.
-     */
-    // only from dcae
-    public static final String ACTION_DEPLOY = "DEPLOY";
-    /**
-     * The constant ACTION_UNDEPLOY.
-     */
-    // only from dcae
-    public static final String ACTION_UNDEPLOY = "UNDEPLOY";
-    /**
-     * The constant ACTION_UPDATE.
-     */
-    public static final String ACTION_UPDATE = "UPDATE";
-    /**
-     * The constant ACTION_DELETE.
-     */
-    public static final String ACTION_DELETE = "DELETE";
-    /**
-     * The constant ACTION_STOP.
-     */
-    public static final String ACTION_STOP = "STOP";
-    /**
-     * The constant ACTION_RESTART.
-     */
-    public static final String ACTION_RESTART = "RESTART";
-
-    /**
-     * The constant ACTION_STATE_INITIATED.
-     */
-    public static final String ACTION_STATE_INITIATED = "INITIATED";
-    /**
-     * The constant ACTION_STATE_SENT.
-     */
-    public static final String ACTION_STATE_SENT = "SENT";
-    /**
-     * The constant ACTION_STATE_COMPLETED.
-     */
-    public static final String ACTION_STATE_COMPLETED = "COMPLETED";
-    /**
-     * The constant ACTION_STATE_RECEIVED.
-     */
-    public static final String ACTION_STATE_RECEIVED = "RECEIVED";
-    /**
-     * The constant ACTION_STATE_ERROR.
-     */
-    public static final String ACTION_STATE_ERROR = "ERROR";
-    /**
-     * The constant ACTION_STATE_ANY.
-     */
-    public static final String ACTION_STATE_ANY = null;
-
-    private String id;
-    private String actionCd;
-    private String actionStateCd;
-    private String processInstanceId;
-    private String userid;
-
-    /**
-     * Gets id.
-     *
-     * @return the id
-     */
-    public String getId() {
-        return id;
-    }
-
-    /**
-     * Sets id.
-     *
-     * @param id the id
-     */
-    public void setId(String id) {
-        this.id = id;
-    }
-
-    /**
-     * Ins event clds event.
-     *
-     * @param cldsDao           the clds dao
-     * @param controlName       the control name
-     * @param userid            the userid
-     * @param actionCd          the action cd
-     * @param actionStateCd     the action state cd
-     * @param processInstanceId the process instance id
-     * @return clds event
-     */
-    public static CldsEvent insEvent(CldsDao cldsDao, String controlName, String userid, String actionCd,
-        String actionStateCd, String processInstanceId) {
-        CldsModel model = CldsModel.createUsingControlName(controlName);
-        return insEvent(cldsDao, model, userid, actionCd, actionStateCd, processInstanceId);
-    }
-
-    /**
-     * Insert event using controlNameUuid to find the model. This method meant for
-     * processing events from dcae.
-     *
-     * @param cldsDao           the clds dao
-     * @param model             the model
-     * @param userId            the user id
-     * @param actionCd          the action cd
-     * @param actionStateCd     the action state cd
-     * @param processInstanceId the process instance id
-     * @return clds event
-     */
-    public static CldsEvent insEvent(CldsDao cldsDao, CldsModel model, String userId, String actionCd,
-        String actionStateCd, String processInstanceId) {
-        CldsEvent event = new CldsEvent();
-        event.setUserid(userId);
-        event.setActionCd(actionCd);
-        event.setActionStateCd(actionStateCd);
-        event.setProcessInstanceId(processInstanceId);
-        cldsDao.insEvent(null, model.getControlNamePrefix(), model.getControlNameUuid(), event);
-        return event;
-    }
-
-    /**
-     * Check if actionCd is equal to the supplied checkActionCd checkActionCd should
-     * not be null.
-     *
-     * @param checkActionCd the check action cd
-     * @return boolean
-     */
-    public boolean isActionCd(String checkActionCd) {
-        if (actionCd == null) {
-            return false;
-        }
-        return actionCd.equals(checkActionCd);
-    }
-
-    /**
-     * Check if actionCd and actionStateCd are equal to the supplied checkActionCd
-     * and checkActionStateCd. Treat checkActionStateCd == null as a wildcard
-     * checkActionCd should not be null.
-     *
-     * @param checkActionCd      the check action cd
-     * @param checkActionStateCd the check action state cd
-     * @return boolean
-     */
-    public boolean isActionAndStateCd(String checkActionCd, String checkActionStateCd) {
-        if (actionCd == null) {
-            return false;
-        }
-        // treat checkActionStateCd == null as a wildcard (same for
-        // actionStateCd, although it shouln't be null...)
-        if (checkActionStateCd == null || actionStateCd == null) {
-            return actionCd.equals(checkActionCd);
-        }
-        return actionCd.equals(checkActionCd) && actionStateCd.equals(checkActionStateCd);
-    }
-
-    /**
-     * Check if actionStateCd is equal to the supplied checkActionStateCd.
-     * checkActionCd should not be null.
-     *
-     * @param checkActionStateCd the check action state cd
-     * @return boolean
-     */
-    public boolean isActionStateCd(String checkActionStateCd) {
-        return !(checkActionStateCd == null || actionStateCd == null) && actionStateCd.equals(checkActionStateCd);
-    }
-
-    /**
-     * Gets action cd.
-     *
-     * @return the actionCd
-     */
-    public String getActionCd() {
-        return actionCd;
-    }
-
-    /**
-     * Sets action cd.
-     *
-     * @param actionCd the actionCd to set
-     */
-    public void setActionCd(String actionCd) {
-        this.actionCd = actionCd;
-    }
-
-    /**
-     * Gets action state cd.
-     *
-     * @return the actionStateCd
-     */
-    public String getActionStateCd() {
-        return actionStateCd;
-    }
-
-    /**
-     * Sets action state cd.
-     *
-     * @param actionStateCd the actionStateCd to set
-     */
-    public void setActionStateCd(String actionStateCd) {
-        this.actionStateCd = actionStateCd;
-    }
-
-    /**
-     * Gets process instance id.
-     *
-     * @return the processInstanceId
-     */
-    public String getProcessInstanceId() {
-        return processInstanceId;
-    }
-
-    /**
-     * Sets process instance id.
-     *
-     * @param processInstanceId the processInstanceId to set
-     */
-    public void setProcessInstanceId(String processInstanceId) {
-        this.processInstanceId = processInstanceId;
-    }
-
-    /**
-     * Gets userid.
-     *
-     * @return the userid
-     */
-    public String getUserid() {
-        return userid;
-    }
-
-    /**
-     * Sets userid.
-     *
-     * @param userid the userid to set
-     */
-    public void setUserid(String userid) {
-        this.userid = userid;
-    }
-}
index f66a631..651997c 100644 (file)
 
 package org.onap.clamp.clds.model;
 
-public class CldsHealthCheck {
+import com.google.gson.annotations.Expose;
 
+public class CldsHealthCheck {
+    @Expose
     private String healthCheckComponent;
+    @Expose
+    private String healthCheckStatus;
+    @Expose
+    private String description;
 
     public String getHealthCheckComponent() {
         return healthCheckComponent;
@@ -35,9 +41,6 @@ public class CldsHealthCheck {
         this.healthCheckComponent = healthCheckComponent;
     }
 
-    private String healthCheckStatus;
-    private String description;
-
     public String getDescription() {
         return description;
     }
diff --git a/src/main/java/org/onap/clamp/clds/model/CldsModel.java b/src/main/java/org/onap/clamp/clds/model/CldsModel.java
deleted file mode 100644 (file)
index 4d2ca89..0000000
+++ /dev/null
@@ -1,627 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * ONAP CLAMP
- * ================================================================================
- * Copyright (C) 2017-2019 AT&T Intellectual Property. All rights
- *                             reserved.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END============================================
- * ===================================================================
- *
- */
-
-package org.onap.clamp.clds.model;
-
-import com.google.gson.annotations.Expose;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import javax.ws.rs.BadRequestException;
-import javax.ws.rs.NotFoundException;
-
-import org.onap.clamp.clds.dao.CldsDao;
-import org.onap.clamp.clds.model.actions.ActionsHandler;
-import org.onap.clamp.clds.model.actions.ActionsHandlerImpl;
-import org.onap.clamp.clds.model.status.StatusHandler;
-import org.onap.clamp.clds.model.status.StatusHandlerImpl;
-
-/**
- * Represent a CLDS Model.
- */
-public class CldsModel {
-
-    private static final int UUID_LENGTH = 36;
-    /**
-     * The constant STATUS_DESIGN.
-     */
-    public static final String STATUS_DESIGN = "DESIGN";
-    /**
-     * The constant STATUS_DISTRIBUTED.
-     */
-    public static final String STATUS_DISTRIBUTED = "DISTRIBUTED";
-    /**
-     * The constant STATUS_ACTIVE.
-     */
-    public static final String STATUS_ACTIVE = "ACTIVE";
-    /**
-     * The constant STATUS_STOPPED.
-     */
-    public static final String STATUS_STOPPED = "STOPPED";
-    /**
-     * The constant STATUS_DELETING.
-     */
-    public static final String STATUS_DELETING = "DELETING";
-    /**
-     * The constant STATUS_ERROR.
-     */
-    public static final String STATUS_ERROR = "ERROR";
-    /**
-     * The constant STATUS_UNKNOWN.
-     */
-    public static final String STATUS_UNKNOWN = "UNKNOWN";
-
-    @Expose
-    private String id;
-    @Expose
-    private String templateId;
-    @Expose
-    private String templateName;
-    @Expose
-    private String name;
-    @Expose
-    private String controlNamePrefix;
-    @Expose
-    private String controlNameUuid;
-    @Expose
-    private String bpmnText;
-    @Expose
-    private String propText;
-    @Expose
-    private String imageText;
-    @Expose
-    private String docText;
-    @Expose
-    private String blueprintText;
-    @Expose
-    private CldsEvent event;
-    @Expose
-    private String status;
-    @Expose
-    private List<String> permittedActionCd;
-    @Expose
-    private List<CldsModelInstance> cldsModelInstanceList;
-    // This is a transient value used to return the failure message to UI
-    @Expose
-    private String errorMessageForUi;
-    /**
-     * The service type Id received from DCAE by querying it.
-     */
-    @Expose
-    private String typeId;
-    @Expose
-    private String typeName;
-    @Expose
-    private String deploymentId;
-    @Expose
-    private String deploymentStatusUrl;
-
-    // Set default handlers but this can be changed if needed.
-    private static StatusHandler statusHandler = new StatusHandlerImpl();
-    private static ActionsHandler actionsHandler = new ActionsHandlerImpl();
-
-    /**
-     * Sets status handler.
-     *
-     * @param statHandler the stat handler
-     */
-    public static synchronized void setStatusHandler(StatusHandler statHandler) {
-        statusHandler = statHandler;
-    }
-
-    /**
-     * Sets actions handler.
-     *
-     * @param cdHandler the cd handler
-     */
-    public static synchronized void setActionsHandler(ActionsHandler cdHandler) {
-        actionsHandler = cdHandler;
-    }
-
-    /**
-     * Construct empty model.
-     */
-    public CldsModel() {
-        event = new CldsEvent();
-    }
-
-    /**
-     * Retrieve from DB.
-     *
-     * @param cldsDao      the clds dao
-     * @param name         the name
-     * @param okIfNotFound the ok if not found
-     * @return the clds model
-     */
-    public static CldsModel retrieve(CldsDao cldsDao, String name, boolean okIfNotFound) {
-        // get from db
-        CldsModel model = cldsDao.getModelTemplate(name);
-        if (model.getId() == null && !okIfNotFound) {
-            throw new NotFoundException();
-        }
-        model.determineStatus();
-        model.determinePermittedActionCd();
-        return model;
-    }
-
-    /**
-     * Can dcae inventory call boolean.
-     *
-     * @return the boolean
-     */
-    public boolean canDcaeInventoryCall() {
-        boolean canCall = false;
-        /* Below checks the clds event is submit/resubmit/distribute */
-        if (event.isActionCd(CldsEvent.ACTION_SUBMIT) || event.isActionCd(CldsEvent.ACTION_RESUBMIT)
-                || event.isActionCd(CldsEvent.ACTION_DISTRIBUTE) || event.isActionCd(CldsEvent.ACTION_SUBMITDCAE)) {
-            canCall = true;
-        }
-        return canCall;
-    }
-
-    /**
-     * Save model to DB.
-     *
-     * @param cldsDao the clds dao
-     * @param userid  the userid
-     * @return the clds model
-     */
-    public CldsModel save(CldsDao cldsDao, String userid) {
-        CldsModel cldsModel = cldsDao.setModel(this, userid);
-        determineStatus();
-        determinePermittedActionCd();
-        return cldsModel;
-    }
-
-    /**
-     * set the status in the model.
-     */
-    public void determineStatus() {
-        status = statusHandler.determineStatusOnLastEvent(event);
-    }
-
-    /**
-     * Determine permittedActionCd list using the actionCd from the current event.
-     * It's a states graph, given the next action that can be executed from the one
-     * that has been executed (described in the event object). ACTION_CREATE being
-     * the first one.
-     */
-    public void determinePermittedActionCd() {
-        permittedActionCd = actionsHandler.determinePermittedActionsOnLastEvent(event, propText);
-    }
-
-    /**
-     * Validate requestedActionCd - determine permittedActionCd and then check if
-     * contained in permittedActionCd Throw IllegalArgumentException if requested
-     * actionCd is not permitted.
-     *
-     * @param requestedActionCd the requested action cd
-     */
-    public void validateAction(String requestedActionCd) {
-        determinePermittedActionCd();
-        if (!permittedActionCd.contains(requestedActionCd)) {
-            throw new IllegalArgumentException("Invalid requestedActionCd: " + requestedActionCd
-                    + ".  Given current actionCd: " + actionsHandler.getCurrentActionCd(event)
-                    + ", the permittedActionCd: " + permittedActionCd);
-        }
-    }
-
-    /**
-     * Extract the UUID portion of a given full control name (controlNamePrefix +
-     * controlNameUuid). No fields are populated other than controlNamePrefix and
-     * controlNameUuid. Throws BadRequestException if length of given control name
-     * is less than UUID_LENGTH.
-     *
-     * @param fullControlName the full control name
-     * @return the clds model
-     */
-    public static CldsModel createUsingControlName(String fullControlName) {
-        if (fullControlName == null || fullControlName.length() < UUID_LENGTH) {
-            throw new BadRequestException(
-                    "closed loop id / control name length, " + (fullControlName != null ? fullControlName.length() : 0)
-                            + ", less than the minimum of: " + UUID_LENGTH);
-        }
-        CldsModel model = new CldsModel();
-        model.setControlNamePrefix(fullControlName.substring(0, fullControlName.length() - UUID_LENGTH));
-        model.setControlNameUuid(fullControlName.substring(fullControlName.length() - UUID_LENGTH));
-        return model;
-    }
-
-    /**
-     * Gets control name.
-     *
-     * @return the controlName (controlNamePrefix + controlNameUuid)
-     */
-    public String getControlName() {
-        return controlNamePrefix + controlNameUuid;
-    }
-
-    /**
-     * To insert modelInstance to the database.
-     *
-     * @param cldsDao   the clds dao
-     * @param dcaeEvent the dcae event
-     * @param userid    the userid
-     * @return the clds model
-     */
-    public static CldsModel insertModelInstance(CldsDao cldsDao, DcaeEvent dcaeEvent, String userid) {
-        String controlName = dcaeEvent.getControlName();
-        CldsModel cldsModel = createUsingControlName(controlName);
-        cldsModel = cldsDao.getModelByUuid(cldsModel.getControlNameUuid());
-        cldsModel.determineStatus();
-        if (dcaeEvent.getCldsActionCd().equals(CldsEvent.ACTION_UNDEPLOY) || (dcaeEvent.getCldsActionCd()
-                .equals(CldsEvent.ACTION_DEPLOY)
-                && (cldsModel.getStatus().equals(STATUS_DISTRIBUTED) || cldsModel.getStatus().equals(STATUS_DESIGN)))) {
-            CldsEvent.insEvent(cldsDao, dcaeEvent.getControlName(), userid, dcaeEvent.getCldsActionCd(),
-                    CldsEvent.ACTION_STATE_RECEIVED, null);
-        }
-        cldsDao.insModelInstance(cldsModel, dcaeEvent.getInstances());
-        return cldsModel;
-    }
-
-    /**
-     * Gets name.
-     *
-     * @return the name
-     */
-    public String getName() {
-        return name;
-    }
-
-    /**
-     * Sets name.
-     *
-     * @param name the name to set
-     */
-    public void setName(String name) {
-        this.name = name;
-    }
-
-    /**
-     * Gets type name.
-     *
-     * @return the typeName
-     */
-    public String getTypeName() {
-        return typeName;
-    }
-
-    /**
-     * Sets type name.
-     *
-     * @param typeName the type name
-     */
-    public void setTypeName(String typeName) {
-        this.typeName = typeName;
-    }
-
-    /**
-     * Gets template id.
-     *
-     * @return the template id
-     */
-    public String getTemplateId() {
-        return templateId;
-    }
-
-    /**
-     * Sets template id.
-     *
-     * @param templateId the template id
-     */
-    public void setTemplateId(String templateId) {
-        this.templateId = templateId;
-    }
-
-    /**
-     * Gets control name prefix.
-     *
-     * @return the controlNamePrefix
-     */
-    public String getControlNamePrefix() {
-        return controlNamePrefix;
-    }
-
-    /**
-     * Sets control name prefix.
-     *
-     * @param controlNamePrefix the controlNamePrefix to set
-     */
-    public void setControlNamePrefix(String controlNamePrefix) {
-        this.controlNamePrefix = controlNamePrefix;
-    }
-
-    /**
-     * Gets control name uuid.
-     *
-     * @return the controlNameUuid
-     */
-    public String getControlNameUuid() {
-        return controlNameUuid;
-    }
-
-    /**
-     * Sets control name uuid.
-     *
-     * @param controlNameUuid the controlNameUuid to set
-     */
-    public void setControlNameUuid(String controlNameUuid) {
-        this.controlNameUuid = controlNameUuid;
-    }
-
-    /**
-     * Gets prop text.
-     *
-     * @return the propText
-     */
-    public String getPropText() {
-        return propText;
-    }
-
-    /**
-     * Sets prop text.
-     *
-     * @param propText the propText to set
-     */
-    public void setPropText(String propText) {
-        this.propText = propText;
-    }
-
-    /**
-     * Gets event.
-     *
-     * @return the event
-     */
-    public CldsEvent getEvent() {
-        return event;
-    }
-
-    /**
-     * Gets id.
-     *
-     * @return the id
-     */
-    public String getId() {
-        return id;
-    }
-
-    /**
-     * Sets id.
-     *
-     * @param id the id
-     */
-    public void setId(String id) {
-        this.id = id;
-    }
-
-    /**
-     * Gets template name.
-     *
-     * @return the template name
-     */
-    public String getTemplateName() {
-        return templateName;
-    }
-
-    /**
-     * Sets template name.
-     *
-     * @param templateName the template name
-     */
-    public void setTemplateName(String templateName) {
-        this.templateName = templateName;
-    }
-
-    /**
-     * Sets event.
-     *
-     * @param event the event to set
-     */
-    public void setEvent(CldsEvent event) {
-        this.event = event;
-    }
-
-    /**
-     * Gets status.
-     *
-     * @return the status
-     */
-    public String getStatus() {
-        return status;
-    }
-
-    /**
-     * Sets status.
-     *
-     * @param status the status to set
-     */
-    public void setStatus(String status) {
-        this.status = status;
-    }
-
-    /**
-     * Gets blueprint text.
-     *
-     * @return the blueprint text
-     */
-    public String getBlueprintText() {
-        return blueprintText;
-    }
-
-    /**
-     * Sets blueprint text.
-     *
-     * @param blueprintText the blueprint text
-     */
-    public void setBlueprintText(String blueprintText) {
-        this.blueprintText = blueprintText;
-    }
-
-    /**
-     * Gets bpmn text.
-     *
-     * @return the bpmn text
-     */
-    public String getBpmnText() {
-        return bpmnText;
-    }
-
-    /**
-     * Sets bpmn text.
-     *
-     * @param bpmnText the bpmn text
-     */
-    public void setBpmnText(String bpmnText) {
-        this.bpmnText = bpmnText;
-    }
-
-    /**
-     * Gets image text.
-     *
-     * @return the image text
-     */
-    public String getImageText() {
-        return imageText;
-    }
-
-    /**
-     * Sets image text.
-     *
-     * @param imageText the image text
-     */
-    public void setImageText(String imageText) {
-        this.imageText = imageText;
-    }
-
-    /**
-     * Gets doc text.
-     *
-     * @return the doc text
-     */
-    public String getDocText() {
-        return docText;
-    }
-
-    /**
-     * Sets doc text.
-     *
-     * @param docText the doc text
-     */
-    public void setDocText(String docText) {
-        this.docText = docText;
-    }
-
-    /**
-     * Gets type id.
-     *
-     * @return the type id
-     */
-    public String getTypeId() {
-        return typeId;
-    }
-
-    /**
-     * Sets type id.
-     *
-     * @param typeId the type id
-     */
-    public void setTypeId(String typeId) {
-        this.typeId = typeId;
-    }
-
-    /**
-     * Gets clds model instance list.
-     *
-     * @return the clds model instance list
-     */
-    public List<CldsModelInstance> getCldsModelInstanceList() {
-        if (cldsModelInstanceList == null) {
-            cldsModelInstanceList = new ArrayList<>();
-        }
-        return cldsModelInstanceList;
-    }
-
-    /**
-     * Gets deployment id.
-     *
-     * @return the deployment id
-     */
-    public String getDeploymentId() {
-        return deploymentId;
-    }
-
-    /**
-     * Sets deployment id.
-     *
-     * @param deploymentId the deployment id
-     */
-    public void setDeploymentId(String deploymentId) {
-        this.deploymentId = deploymentId;
-    }
-
-    /**
-     * Gets permitted action cd.
-     *
-     * @return the permitted action cd
-     */
-    public List<String> getPermittedActionCd() {
-        return permittedActionCd;
-    }
-
-    /**
-     * Gets error message for ui.
-     *
-     * @return the error message for ui
-     */
-    public String getErrorMessageForUi() {
-        return errorMessageForUi;
-    }
-
-    /**
-     * Sets error message for ui.
-     *
-     * @param errorMessageForUi the error message for ui
-     */
-    public void setErrorMessageForUi(String errorMessageForUi) {
-        this.errorMessageForUi = errorMessageForUi;
-    }
-
-    /**
-     * Gets deployment status url.
-     *
-     * @return the deployment status url
-     */
-    public String getDeploymentStatusUrl() {
-        return deploymentStatusUrl;
-    }
-
-    /**
-     * Sets deployment status url.
-     *
-     * @param deploymentStatusUrl the deployment status url
-     */
-    public void setDeploymentStatusUrl(String deploymentStatusUrl) {
-        this.deploymentStatusUrl = deploymentStatusUrl;
-    }
-}
diff --git a/src/main/java/org/onap/clamp/clds/model/CldsModelInstance.java b/src/main/java/org/onap/clamp/clds/model/CldsModelInstance.java
deleted file mode 100644 (file)
index 082bfe3..0000000
+++ /dev/null
@@ -1,56 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * ONAP CLAMP
- * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights
- *                             reserved.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License"); 
- * you may not use this file except in compliance with the License. 
- * You may obtain a copy of the License at
- * 
- * http://www.apache.org/licenses/LICENSE-2.0
- * 
- * Unless required by applicable law or agreed to in writing, software 
- * distributed under the License is distributed on an "AS IS" BASIS, 
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
- * See the License for the specific language governing permissions and 
- * limitations under the License.
- * ============LICENSE_END============================================
- * ===================================================================
- * 
- */
-
-package org.onap.clamp.clds.model;
-
-public class CldsModelInstance {
-
-    private String modelInstanceId;
-    private String location;
-    private String vmName;
-
-    public String getVmName() {
-        return vmName;
-    }
-
-    public void setVmName(String vmName) {
-        this.vmName = vmName;
-    }
-
-    public String getLocation() {
-        return location;
-    }
-
-    public void setLocation(String location) {
-        this.location = location;
-    }
-
-    public String getModelInstanceId() {
-        return modelInstanceId;
-    }
-
-    public void setModelInstanceId(String modelInstanceId) {
-        this.modelInstanceId = modelInstanceId;
-    }
-
-}
diff --git a/src/main/java/org/onap/clamp/clds/model/CldsModelProp.java b/src/main/java/org/onap/clamp/clds/model/CldsModelProp.java
deleted file mode 100644 (file)
index 1a486e1..0000000
+++ /dev/null
@@ -1,68 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * ONAP CLAMP
- * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights
- *                             reserved.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END============================================
- * ===================================================================
- * 
- */
-
-package org.onap.clamp.clds.model;
-
-/**
- * Maintain model name and property text data.
- */
-public class CldsModelProp {
-
-    private String id;
-    private String name;
-    private String propId;
-    private String propText;
-
-    public String getId() {
-        return id;
-    }
-
-    public void setId(String id) {
-        this.id = id;
-    }
-
-    public String getName() {
-        return name;
-    }
-
-    public void setName(String name) {
-        this.name = name;
-    }
-
-    public String getPropId() {
-        return propId;
-    }
-
-    public void setPropId(String propId) {
-        this.propId = propId;
-    }
-
-    public String getPropText() {
-        return propText;
-    }
-
-    public void setPropText(String propText) {
-        this.propText = propText;
-    }
-
-}
diff --git a/src/main/java/org/onap/clamp/clds/model/CldsServiceData.java b/src/main/java/org/onap/clamp/clds/model/CldsServiceData.java
deleted file mode 100644 (file)
index 8777ab5..0000000
+++ /dev/null
@@ -1,107 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * ONAP CLAMP
- * ================================================================================
- * Copyright (C) 2017-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.att.eelf.configuration.EELFLogger;
-import com.att.eelf.configuration.EELFManager;
-
-import java.io.Serializable;
-import java.util.ArrayList;
-import java.util.List;
-
-import javax.ws.rs.NotAuthorizedException;
-
-import org.onap.clamp.clds.service.CldsService;
-
-public class CldsServiceData implements Serializable {
-
-    private static final long serialVersionUID = -9153372664377279423L;
-    protected static final EELFLogger logger = EELFManager.getInstance().getLogger(CldsServiceData.class);
-    protected static final EELFLogger auditLogger = EELFManager.getInstance().getAuditLogger();
-    private String serviceInvariantUuid;
-    private String serviceUiod;
-    private Long ageOfRecord;
-    private List<CldsVfData> cldsVfs;
-
-    public String getServiceInvariantUUID() {
-        return serviceInvariantUuid;
-    }
-
-    public void setServiceInvariantUUID(String serviceInvariantUuid) {
-        this.serviceInvariantUuid = serviceInvariantUuid;
-    }
-
-    public List<CldsVfData> getCldsVfs() {
-        return cldsVfs;
-    }
-
-    public void setCldsVfs(List<CldsVfData> cldsVfs) {
-        this.cldsVfs = cldsVfs;
-    }
-
-    public String getServiceUUID() {
-        return serviceUiod;
-    }
-
-    public void setServiceUUID(String serviceUuid) {
-        this.serviceUiod = serviceUuid;
-    }
-
-    public Long getAgeOfRecord() {
-        return ageOfRecord;
-    }
-
-    public void setAgeOfRecord(Long ageOfRecord) {
-        this.ageOfRecord = ageOfRecord;
-    }
-
-    /**
-     * Filter out any VFs that the user is not authorized for. Use the CldsService
-     * to determine if the user is authorized for a VF.
-     *
-     * @param svc The clds service
-     */
-    public void filterVfs(CldsService svc) {
-        List<CldsVfData> filteredCldsVfs = new ArrayList<>();
-        if (cldsVfs == null) {
-            logger.debug("cldsVfs == null");
-        } else {
-            for (CldsVfData vf : cldsVfs) {
-                // if user is authorized for the VF then add it to the filtered
-                // list
-                try {
-                    if (svc.isAuthorizedForVf(vf.getVfInvariantResourceUUID())) {
-                        filteredCldsVfs.add(vf);
-                    }
-                } catch (NotAuthorizedException e) {
-                    logger.error("user not authorized for {}" + vf.getVfInvariantResourceUUID(), e);
-                    // when not NotAuthorizedException - don't add to
-                    // filteredCldsVfs list
-                }
-            }
-        }
-        // new filtered list replaces the list of VFs for the user
-        cldsVfs = filteredCldsVfs;
-    }
-}
diff --git a/src/main/java/org/onap/clamp/clds/model/CldsTemplate.java b/src/main/java/org/onap/clamp/clds/model/CldsTemplate.java
deleted file mode 100644 (file)
index b124780..0000000
+++ /dev/null
@@ -1,213 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * ONAP CLAMP
- * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights
- *                             reserved.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END============================================
- * ===================================================================
- *
- */
-
-package org.onap.clamp.clds.model;
-
-import com.google.gson.annotations.Expose;
-
-import javax.ws.rs.NotFoundException;
-
-import org.onap.clamp.clds.dao.CldsDao;
-
-/**
- * Represent a CLDS Model.
- */
-public class CldsTemplate {
-
-    public static final String STATUS_DESIGN = "DESIGN";
-    public static final String STATUS_ACTIVE = "ACTIVE";
-    public static final String STATUS_STOPPED = "STOPPED";
-    public static final String STATUS_DELETING = "DELETING";
-    // manual intervention required
-    public static final String STATUS_ERROR = "ERROR";
-    public static final String STATUS_UNKNOWN = "UNKNOWN";
-
-    @Expose
-    private String id;
-    @Expose
-    private String name;
-    @Expose
-    private String controlNamePrefix;
-    @Expose
-    private String controlNameUuid;
-    @Expose
-    private String bpmnId;
-    @Expose
-    private String bpmnUserid;
-    @Expose
-    private String bpmnText;
-    @Expose
-    private String imageId;
-    @Expose
-    private String imageUserid;
-    @Expose
-    private String imageText;
-    @Expose
-    private String propId;
-    @Expose
-    private String propUserid;
-    @Expose
-    private String propText;
-    @Expose
-    private boolean userAuthorizedToUpdate;
-
-    /**
-     * Save template to DB.
-     *
-     * @param cldsDao The cldsDao
-     * @param userid  The user Id
-     */
-    public void save(CldsDao cldsDao, String userid) {
-        cldsDao.setTemplate(this, userid);
-    }
-
-    /**
-     * Retrieve from DB.
-     *
-     * @param cldsDao      The cldsDao
-     * @param name         The template name to retrieve
-     * @param okIfNotFound The flag indicating whether exception will be returned in
-     *                     case nothing is found
-     * @return Clds template from DB
-     */
-    public static CldsTemplate retrieve(CldsDao cldsDao, String name, boolean okIfNotFound) {
-        // get from db
-        CldsTemplate template = cldsDao.getTemplate(name);
-        if (template.getId() == null && !okIfNotFound) {
-            throw new NotFoundException();
-        }
-        return template;
-    }
-
-    public String getBpmnUserid() {
-        return bpmnUserid;
-    }
-
-    public void setBpmnUserid(String bpmnUserid) {
-        this.bpmnUserid = bpmnUserid;
-    }
-
-    public String getBpmnText() {
-        return bpmnText;
-    }
-
-    public void setBpmnText(String bpmnText) {
-        this.bpmnText = bpmnText;
-    }
-
-    public String getImageUserid() {
-        return imageUserid;
-    }
-
-    public void setImageUserid(String imageUserid) {
-        this.imageUserid = imageUserid;
-    }
-
-    public String getImageText() {
-        return imageText;
-    }
-
-    public void setImageText(String imageText) {
-        this.imageText = imageText;
-    }
-
-    public String getName() {
-        return name;
-    }
-
-    public void setName(String name) {
-        this.name = name;
-    }
-
-    public String getControlNamePrefix() {
-        return controlNamePrefix;
-    }
-
-    public void setControlNamePrefix(String controlNamePrefix) {
-        this.controlNamePrefix = controlNamePrefix;
-    }
-
-    public String getControlNameUuid() {
-        return controlNameUuid;
-    }
-
-    public void setControlNameUuid(String controlNameUuid) {
-        this.controlNameUuid = controlNameUuid;
-    }
-
-    public String getPropId() {
-        return propId;
-    }
-
-    public void setPropId(String propId) {
-        this.propId = propId;
-    }
-
-    public String getPropUserid() {
-        return propUserid;
-    }
-
-    public void setPropUserid(String propUserid) {
-        this.propUserid = propUserid;
-    }
-
-    public String getPropText() {
-        return propText;
-    }
-
-    public void setPropText(String propText) {
-        this.propText = propText;
-    }
-
-    public String getId() {
-        return id;
-    }
-
-    public void setId(String id) {
-        this.id = id;
-    }
-
-    public String getBpmnId() {
-        return bpmnId;
-    }
-
-    public void setBpmnId(String bpmnId) {
-        this.bpmnId = bpmnId;
-    }
-
-    public String getImageId() {
-        return imageId;
-    }
-
-    public void setImageId(String imageId) {
-        this.imageId = imageId;
-    }
-
-    public boolean isUserAuthorizedToUpdate() {
-        return userAuthorizedToUpdate;
-    }
-
-    public void setUserAuthorizedToUpdate(boolean userAuthorizedToUpdate) {
-        this.userAuthorizedToUpdate = userAuthorizedToUpdate;
-    }
-}
diff --git a/src/main/java/org/onap/clamp/clds/model/CldsToscaModel.java b/src/main/java/org/onap/clamp/clds/model/CldsToscaModel.java
deleted file mode 100644 (file)
index 5ae13d2..0000000
+++ /dev/null
@@ -1,145 +0,0 @@
-/*-
- * ============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.google.gson.annotations.Expose;
-
-import java.util.List;
-
-import org.apache.commons.lang3.StringUtils;
-import org.onap.clamp.clds.client.req.policy.PolicyClient;
-import org.onap.clamp.clds.config.ClampProperties;
-import org.onap.clamp.clds.dao.CldsDao;
-import org.onap.clamp.clds.tosca.ToscaYamlToJsonConvertor;
-
-public class CldsToscaModel extends CldsToscaModelRevision {
-
-    @Expose
-    private String id;
-    @Expose
-    private String policyType;
-    @Expose
-    private String toscaModelName;
-
-    /**
-     * Construct.
-     */
-    public CldsToscaModel() {
-    }
-
-    /**
-     * Creates or updates Tosca Model to DB.
-     *
-     * @param cldsDao The cldsDao
-     * @param userId  The user Id
-     */
-    public CldsToscaModel save(CldsDao cldsDao, ClampProperties refProp, PolicyClient policyClient, String userId) {
-        CldsToscaModel cldsToscaModel = null;
-        refProp.getStringList("tosca.policyTypes", ",").stream().forEach(policyType -> {
-            if (StringUtils.containsIgnoreCase(this.getToscaModelName(), policyType)) {
-                this.setPolicyType(policyType);
-            }
-        });
-
-        ToscaYamlToJsonConvertor convertor = new ToscaYamlToJsonConvertor(cldsDao);
-        this.setToscaModelJson(convertor.parseToscaYaml(this.getToscaModelYaml()));
-        List<CldsToscaModel> toscaModels = cldsDao.getToscaModelByName(this.getToscaModelName());
-        if (toscaModels != null && !toscaModels.isEmpty()) {
-            CldsToscaModel toscaModel = toscaModels.stream().findFirst().get();
-            this.setVersion(incrementVersion(toscaModel.getVersion()));
-            this.setId(toscaModel.getId());
-            this.setUserId(userId);
-            if (refProp.getStringValue("import.tosca.model").equalsIgnoreCase("true")) {
-                policyClient.importToscaModel(this);
-            }
-            cldsToscaModel = cldsDao.updateToscaModelWithNewVersion(this, userId);
-        } else {
-            this.setVersion(1);
-            if (refProp.getStringValue("import.tosca.model").equalsIgnoreCase("true")) {
-                policyClient.importToscaModel(this);
-            }
-            cldsToscaModel = cldsDao.insToscaModel(this, userId);
-        }
-        return cldsToscaModel;
-    }
-
-    private double incrementVersion(double curVersion) {
-        return curVersion + 1;
-    }
-
-    /**
-     * Get the Id.
-     *
-     * @return the id
-     */
-    public String getId() {
-        return id;
-    }
-
-    /**
-     * Set the id.
-     *
-     * @param id the id to set
-     */
-    public void setId(String id) {
-        this.id = id;
-    }
-
-    /**
-     * Get the policy type.
-     *
-     * @return the policyType
-     */
-    public String getPolicyType() {
-        return policyType;
-    }
-
-    /**
-     * Set the policy type.
-     *
-     * @param policyType the policyType to set
-     */
-    public void setPolicyType(String policyType) {
-        this.policyType = policyType;
-    }
-
-    /**
-     * Get the tosca model name.
-     *
-     * @return the toscaModelName
-     */
-    public String getToscaModelName() {
-        return toscaModelName;
-    }
-
-    /**
-     * Set the tosca model name.
-     *
-     * @param toscaModelName the toscaModelName to set
-     */
-    public void setToscaModelName(String toscaModelName) {
-        this.toscaModelName = toscaModelName;
-    }
-
-}
diff --git a/src/main/java/org/onap/clamp/clds/model/CldsToscaModelDetails.java b/src/main/java/org/onap/clamp/clds/model/CldsToscaModelDetails.java
deleted file mode 100644 (file)
index 4ee1deb..0000000
+++ /dev/null
@@ -1,143 +0,0 @@
-/*-
- * ============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;
-
-    /**
-     * Get the id.
-     * @return the id
-     */
-    public String getId() {
-        return id;
-    }
-
-    /**
-     * Set the id.
-     * @param id
-     *        the id to set
-     */
-    public void setId(String id) {
-        this.id = id;
-    }
-
-    /**
-     * Get the tosca model name.
-     * @return the toscaModelName
-     */
-    public String getToscaModelName() {
-        return toscaModelName;
-    }
-
-    /**
-     * Set the tosca model name.
-     * @param toscaModelName
-     *        the toscaModelName to set
-     */
-    public void setToscaModelName(String toscaModelName) {
-        this.toscaModelName = toscaModelName;
-    }
-
-    /**
-     * Get the policy type.
-     * @return the policyType
-     */
-    public String getPolicyType() {
-        return policyType;
-    }
-
-    /**
-     * Set the policy type.
-     * @param policyType
-     *        the policyType to set
-     */
-    public void setPolicyType(String policyType) {
-        this.policyType = policyType;
-    }
-
-    /**
-     * Get the list of tosca model revisions.
-     * @return the toscaModelRevisions
-     */
-    public List<CldsToscaModelRevision> getToscaModelRevisions() {
-        return toscaModelRevisions;
-    }
-
-    /**
-     * Set the list of tosca model revisions.
-     * @param toscaModelRevisions
-     *        the toscaModelRevisions to set
-     */
-    public void setToscaModelRevisions(List<CldsToscaModelRevision> toscaModelRevisions) {
-        this.toscaModelRevisions = toscaModelRevisions;
-    }
-
-    /**
-     * Get the user id.
-     * @return the userId
-     */
-    public String getUserId() {
-        return userId;
-    }
-
-    /**
-     * Set the user id.
-     * @param userId
-     *        the userId to set
-     */
-    public void setUserId(String userId) {
-        this.userId = userId;
-    }
-
-    /**
-     * Get the last updated date.
-     * @return the lastUpdatedDate
-     */
-    public String getLastUpdatedDate() {
-        return lastUpdatedDate;
-    }
-
-    /**
-     * Set the last updated date.
-     * @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
deleted file mode 100644 (file)
index b9a7e0d..0000000
+++ /dev/null
@@ -1,158 +0,0 @@
-/*-
- * ============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;
-
-    /**
-     * Get the revision id.
-     * @return the revisionId
-     */
-    public String getRevisionId() {
-        return revisionId;
-    }
-
-    /**
-     * Set the revision id.
-     * @param revisionId
-     *        the revisionId to set
-     */
-    public void setRevisionId(String revisionId) {
-        this.revisionId = revisionId;
-    }
-
-    /**
-     * Get the tosca model yaml.
-     * @return the toscaModelYaml
-     */
-    public String getToscaModelYaml() {
-        return toscaModelYaml;
-    }
-
-    /**
-     * Set the tosca model yaml.
-     * @param toscaModelYaml
-     *        the toscaModelYaml to set
-     */
-    public void setToscaModelYaml(String toscaModelYaml) {
-        this.toscaModelYaml = toscaModelYaml;
-    }
-
-    /**
-     * Get the version.
-     * @return the version
-     */
-    public double getVersion() {
-        return version;
-    }
-
-    /**
-     * Set the version.
-     * @param version
-     *        the version to set
-     */
-    public void setVersion(double version) {
-        this.version = version;
-    }
-
-    /**
-     * Get the tosca model json.
-     * @return the toscaModelJson
-     */
-    public String getToscaModelJson() {
-        return toscaModelJson;
-    }
-
-    /**
-     * Set the tosca model json.
-     * @param toscaModelJson
-     *        the toscaModelJson to set
-     */
-    public void setToscaModelJson(String toscaModelJson) {
-        this.toscaModelJson = toscaModelJson;
-    }
-
-    /**
-     * Get the user id.
-     * @return the userId
-     */
-    public String getUserId() {
-        return userId;
-    }
-
-    /**
-     * Set the user id.
-     * @param userId
-     *        the userId to set
-     */
-    public void setUserId(String userId) {
-        this.userId = userId;
-    }
-
-    /**
-     * Get the created date.
-     * @return the createdDate
-     */
-    public String getCreatedDate() {
-        return createdDate;
-    }
-
-    /**
-     * Set the created date.
-     * @param createdDate
-     *        the createdDate to set
-     */
-    public void setCreatedDate(String createdDate) {
-        this.createdDate = createdDate;
-    }
-
-    /**
-     * Get the last updated date.
-     * @return the lastUpdatedDate
-     */
-    public String getLastUpdatedDate() {
-        return lastUpdatedDate;
-    }
-
-    /**
-     * Set the last updated date.
-     * @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/CldsVfData.java b/src/main/java/org/onap/clamp/clds/model/CldsVfData.java
deleted file mode 100644 (file)
index a31388e..0000000
+++ /dev/null
@@ -1,70 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * ONAP CLAMP
- * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights
- *                             reserved.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END============================================
- * ===================================================================
- * 
- */
-
-package org.onap.clamp.clds.model;
-
-import java.io.Serializable;
-import java.util.List;
-
-public class CldsVfData implements Serializable {
-
-    private static final long   serialVersionUID = -5069670140274203606L;
-    private String              vfName;
-    private String              vfInvariantResourceUuid;
-    private List<CldsVfcData>   cldsVfcs;
-
-    private List<CldsVfKPIData> cldsKpiList;
-
-    public List<CldsVfKPIData> getCldsKPIList() {
-        return cldsKpiList;
-    }
-
-    public void setCldsKPIList(List<CldsVfKPIData> cldsKpiList) {
-        this.cldsKpiList = cldsKpiList;
-    }
-
-    public String getVfName() {
-        return vfName;
-    }
-
-    public void setVfName(String vfName) {
-        this.vfName = vfName;
-    }
-
-    public List<CldsVfcData> getCldsVfcs() {
-        return cldsVfcs;
-    }
-
-    public void setCldsVfcs(List<CldsVfcData> cldsVfcs) {
-        this.cldsVfcs = cldsVfcs;
-    }
-
-    public String getVfInvariantResourceUUID() {
-        return vfInvariantResourceUuid;
-    }
-
-    public void setVfInvariantResourceUUID(String vfInvariantResourceUuid) {
-        this.vfInvariantResourceUuid = vfInvariantResourceUuid;
-    }
-
-}
diff --git a/src/main/java/org/onap/clamp/clds/model/CldsVfKPIData.java b/src/main/java/org/onap/clamp/clds/model/CldsVfKPIData.java
deleted file mode 100644 (file)
index 8aab1ff..0000000
+++ /dev/null
@@ -1,89 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * ONAP CLAMP
- * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights
- *                             reserved.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END============================================
- * ===================================================================
- * 
- */
-
-package org.onap.clamp.clds.model;
-
-import java.io.Serializable;
-
-public class CldsVfKPIData implements Serializable {
-
-    private static final long serialVersionUID = 9067755871527776380L;
-
-    private String            nfNamingCode;
-    private String            nfNamingValue;
-
-    private String            fieldPath;
-    private String            fieldPathValue;
-
-    private String            thresholdName;
-    private String            thresholdValue;
-
-    public String getNfNamingCode() {
-        return nfNamingCode;
-    }
-
-    public void setNfNamingCode(String nfNamingCode) {
-        this.nfNamingCode = nfNamingCode;
-    }
-
-    public String getNfNamingValue() {
-        return nfNamingValue;
-    }
-
-    public void setNfNamingValue(String nfNamingValue) {
-        this.nfNamingValue = nfNamingValue;
-    }
-
-    public String getFieldPath() {
-        return fieldPath;
-    }
-
-    public void setFieldPath(String fieldPath) {
-        this.fieldPath = fieldPath;
-    }
-
-    public String getFieldPathValue() {
-        return fieldPathValue;
-    }
-
-    public void setFieldPathValue(String fieldPathValue) {
-        this.fieldPathValue = fieldPathValue;
-    }
-
-    public String getThresholdName() {
-        return thresholdName;
-    }
-
-    public void setThresholdName(String thresholdName) {
-        this.thresholdName = thresholdName;
-    }
-
-    public String getThresholdValue() {
-        return thresholdValue;
-    }
-
-    public void setThresholdValue(String thresholdValue) {
-        this.thresholdValue = thresholdValue;
-    }
-
-}
diff --git a/src/main/java/org/onap/clamp/clds/model/CldsVfcData.java b/src/main/java/org/onap/clamp/clds/model/CldsVfcData.java
deleted file mode 100644 (file)
index 034fc28..0000000
+++ /dev/null
@@ -1,60 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * ONAP CLAMP
- * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights
- *                             reserved.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END============================================
- * ===================================================================
- *
- */
-
-package org.onap.clamp.clds.model;
-
-import java.io.Serializable;
-import java.util.List;
-
-public class CldsVfcData implements Serializable {
-
-    private static final long serialVersionUID = 406993878174183557L;
-    private String vfcName;
-    private String vfcInvariantResourceUuid;
-    private List<CldsAlarmCondition> cldsAlarmConditions;
-
-    public String getVfcName() {
-        return vfcName;
-    }
-
-    public void setVfcName(String vfcName) {
-        this.vfcName = vfcName;
-    }
-
-    public List<CldsAlarmCondition> getCldsAlarmConditions() {
-        return cldsAlarmConditions;
-    }
-
-    public void setCldsAlarmConditions(List<CldsAlarmCondition> cldsAlarmConditions) {
-        this.cldsAlarmConditions = cldsAlarmConditions;
-    }
-
-    public String getVfcInvariantResourceUUID() {
-        return vfcInvariantResourceUuid;
-    }
-
-    public void setVfcInvariantResourceUUID(String vfcInvariantResourceUuid) {
-        this.vfcInvariantResourceUuid = vfcInvariantResourceUuid;
-    }
-
-}
diff --git a/src/main/java/org/onap/clamp/clds/model/DcaeEvent.java b/src/main/java/org/onap/clamp/clds/model/DcaeEvent.java
deleted file mode 100644 (file)
index 9126f9a..0000000
+++ /dev/null
@@ -1,186 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * ONAP CLAMP
- * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights
- *                             reserved.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END============================================
- * ===================================================================
- *
- */
-
-package org.onap.clamp.clds.model;
-
-import com.google.gson.annotations.Expose;
-
-import java.util.List;
-
-import javax.ws.rs.BadRequestException;
-
-/**
- * Represent a DCAE Event.
- */
-public class DcaeEvent {
-    // this is an event we (clds) sends to dcae
-    public static final String EVENT_CREATED = "created";
-    public static final String EVENT_DISTRIBUTION = "distribute";
-    public static final String EVENT_DEPLOYMENT = "deployment";
-    public static final String EVENT_UNDEPLOYMENT = "undeployment";
-    public static final String ARTIFACT_NAME_SUFFIX = ".yml";
-
-    @Expose
-    private String event;
-    @Expose
-    private String serviceUuid;
-    @Expose
-    private String resourceUuid;
-    @Expose
-    private String artifactName; // controlName.yml
-    @Expose
-    private List<CldsModelInstance> instances;
-
-    /**
-     * Transform a DCAE Event Action to a CldsEvent.actionCd.
-     *
-     * @return The clds action.
-     */
-    public String getCldsActionCd() {
-        if (event == null || event.length() == 0) {
-            throw new BadRequestException("action null or empty");
-        } else if (event.equalsIgnoreCase(EVENT_CREATED)) {
-            return CldsEvent.ACTION_CREATE;
-        } else if (event.equalsIgnoreCase(EVENT_DISTRIBUTION)) {
-            return CldsEvent.ACTION_DISTRIBUTE;
-        } else if (event.equalsIgnoreCase(EVENT_DEPLOYMENT) && (instances == null || instances.isEmpty())) {
-            return CldsEvent.ACTION_DEPLOY;
-        } else if (event.equalsIgnoreCase(EVENT_DEPLOYMENT)) {
-            return CldsEvent.ACTION_DEPLOY;
-            // EVENT_UNDEPLOYMENT is defunct - DCAE Proxy will not undeploy
-            // individual instances. It will send an empty list of
-            // deployed instances to indicate all have been removed. Or it will
-            // send an updated list to indicate those that
-            // are still deployed with any not on the list considered
-            // undeployed.
-        } else if (event.equals(EVENT_UNDEPLOYMENT)) {
-            return CldsEvent.ACTION_UNDEPLOY;
-        }
-
-        throw new BadRequestException("event value not valid: " + event);
-    }
-
-    /**
-     * Derive the controlName from the artifactName.
-     *
-     * @return the controlName
-     */
-    public String getControlName() {
-        if (artifactName != null && artifactName.endsWith(ARTIFACT_NAME_SUFFIX)) {
-            return artifactName.substring(0, artifactName.length() - ARTIFACT_NAME_SUFFIX.length());
-        } else {
-            throw new BadRequestException("artifactName value not valid (expecting it to end with "
-                    + ARTIFACT_NAME_SUFFIX + "): " + artifactName);
-        }
-    }
-
-    /**
-     * Get the event.
-     *
-     * @return the event
-     */
-    public String getEvent() {
-        return event;
-    }
-
-    /**
-     * Set the event.
-     *
-     * @param event the event to set
-     */
-    public void setEvent(String event) {
-        this.event = event;
-    }
-
-    /**
-     * Get the serviceUUID.
-     *
-     * @return the serviceUUID
-     */
-    public String getServiceUUID() {
-        return serviceUuid;
-    }
-
-    /**
-     * Set the serviceUUID.
-     *
-     * @param serviceUUID the serviceUUID to set
-     */
-    public void setServiceUUID(String serviceUuid) {
-        this.serviceUuid = serviceUuid;
-    }
-
-    /**
-     * Get the resourceUUID.
-     *
-     * @return the resourceUUID
-     */
-    public String getResourceUUID() {
-        return resourceUuid;
-    }
-
-    /**
-     * Set the resourceUUID.
-     *
-     * @param resourceUUID the resourceUUID to set
-     */
-    public void setResourceUUID(String resourceUuid) {
-        this.resourceUuid = resourceUuid;
-    }
-
-    /**
-     * Get the artifact name.
-     *
-     * @return the artifactName
-     */
-    public String getArtifactName() {
-        return artifactName;
-    }
-
-    /**
-     * Set the artifact name.
-     *
-     * @param artifactName the artifactName to set
-     */
-    public void setArtifactName(String artifactName) {
-        this.artifactName = artifactName;
-    }
-
-    /**
-     * Get the list of instances.
-     *
-     * @return The list of model instances
-     */
-    public List<CldsModelInstance> getInstances() {
-        return instances;
-    }
-
-    /**
-     * Set the list of model instances.
-     *
-     * @param instances The list of model instances to set
-     */
-    public void setInstances(List<CldsModelInstance> instances) {
-        this.instances = instances;
-    }
-}
diff --git a/src/main/java/org/onap/clamp/clds/model/ValueItem.java b/src/main/java/org/onap/clamp/clds/model/ValueItem.java
deleted file mode 100644 (file)
index 4232390..0000000
+++ /dev/null
@@ -1,65 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * ONAP CLAMP
- * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights
- *                             reserved.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END============================================
- * ===================================================================
- *
- */
-
-package org.onap.clamp.clds.model;
-
-import com.google.gson.annotations.Expose;
-
-/**
- * ValueItem used for value lists.
- */
-public class ValueItem {
-    @Expose
-    private String value;
-
-    /**
-     * Instantiate using value.
-     *
-     * @param value The value
-     */
-    public ValueItem(String value) {
-        this.value = value;
-    }
-
-    public ValueItem() {
-    }
-
-    /**
-     * Get the value.
-     *
-     * @return the value
-     */
-    public String getValue() {
-        return value;
-    }
-
-    /**
-     * Set the value.
-     *
-     * @param value the value to set
-     */
-    public void setValue(String value) {
-        this.value = value;
-    }
-
-}
diff --git a/src/main/java/org/onap/clamp/clds/model/actions/ActionsHandler.java b/src/main/java/org/onap/clamp/clds/model/actions/ActionsHandler.java
deleted file mode 100644 (file)
index 9aed447..0000000
+++ /dev/null
@@ -1,171 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * ONAP CLAMP
- * ================================================================================
- * Copyright (C) 2018-2019 AT&T Intellectual Property. All rights
- *                             reserved.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END============================================
- * ===================================================================
- *
- */
-
-package org.onap.clamp.clds.model.actions;
-
-import com.att.eelf.configuration.EELFLogger;
-import com.google.gson.JsonElement;
-import com.google.gson.JsonObject;
-import com.google.gson.JsonParseException;
-import java.util.Arrays;
-import java.util.List;
-import org.onap.clamp.clds.model.CldsEvent;
-import org.onap.clamp.clds.util.JsonUtils;
-
-/**
- * Interface for actions that the user can do according to the last event.
- *
- *
- */
-public interface ActionsHandler {
-
-    enum ModelType {
-        SIMPLE_MODEL("simpleModel"), POLICY_MODEL("policyModel");
-        private final String type;
-
-        ModelType(String type) {
-            this.type = type;
-        }
-
-        public final String getType() {
-            return this.type;
-        }
-    }
-
-    EELFLogger getLogger();
-
-    /**
-     * This method determines a list of actions that the user can do according to
-     * the last event.
-     *
-     * @param event
-     *        The last event
-     * @param propText
-     *        The Json properties string
-     * @return A list of actions
-     */
-    default List<String> determinePermittedActionsOnLastEvent(CldsEvent event, String propText) {
-        List<String> permittedActions;
-        String actionCd = getCurrentActionCd(event);
-        switch (actionCd) {
-            case CldsEvent.ACTION_CREATE:
-                permittedActions = Arrays.asList(CldsEvent.ACTION_SUBMIT, CldsEvent.ACTION_TEST,
-                        CldsEvent.ACTION_DELETE);
-                if (isTypeModel(propText, ModelType.SIMPLE_MODEL)) {
-                    permittedActions = Arrays.asList(CldsEvent.ACTION_SUBMITDCAE, CldsEvent.ACTION_SUBMITPOLICY,
-                            CldsEvent.ACTION_TEST, CldsEvent.ACTION_DELETE);
-                }
-                break;
-            case CldsEvent.ACTION_SUBMIT:
-            case CldsEvent.ACTION_RESUBMIT:
-            case CldsEvent.ACTION_DISTRIBUTE:
-                permittedActions = Arrays.asList(CldsEvent.ACTION_DEPLOY, CldsEvent.ACTION_RESUBMIT,
-                        CldsEvent.ACTION_DELETE);
-                if (isTypeModel(propText, ModelType.SIMPLE_MODEL)) {
-                    permittedActions = Arrays.asList(CldsEvent.ACTION_DEPLOY, CldsEvent.ACTION_SUBMITDCAE,
-                            CldsEvent.ACTION_DELETE);
-                }
-                break;
-            case CldsEvent.ACTION_SUBMITDCAE:
-                permittedActions = Arrays.asList(CldsEvent.ACTION_SUBMITDCAE, CldsEvent.ACTION_DELETE);
-                break;
-            case CldsEvent.ACTION_SUBMITPOLICY:
-                permittedActions = Arrays.asList(CldsEvent.ACTION_UPDATE, CldsEvent.ACTION_STOP);
-                break;
-            case CldsEvent.ACTION_UNDEPLOY:
-                permittedActions = Arrays.asList(CldsEvent.ACTION_UPDATE, CldsEvent.ACTION_DEPLOY,
-                        CldsEvent.ACTION_RESUBMIT, CldsEvent.ACTION_DELETE);
-                if (isTypeModel(propText, ModelType.SIMPLE_MODEL)) {
-                    permittedActions = Arrays.asList(CldsEvent.ACTION_UPDATE, CldsEvent.ACTION_DEPLOY,
-                            CldsEvent.ACTION_SUBMITDCAE, CldsEvent.ACTION_DELETE);
-                }
-                break;
-            case CldsEvent.ACTION_DEPLOY:
-                permittedActions = Arrays.asList(CldsEvent.ACTION_UNDEPLOY, CldsEvent.ACTION_UPDATE,
-                        CldsEvent.ACTION_STOP);
-                break;
-            case CldsEvent.ACTION_RESTART:
-            case CldsEvent.ACTION_UPDATE:
-                permittedActions = Arrays.asList(CldsEvent.ACTION_DEPLOY, CldsEvent.ACTION_UPDATE,
-                        CldsEvent.ACTION_STOP, CldsEvent.ACTION_UNDEPLOY);
-                if (isTypeModel(propText, ModelType.POLICY_MODEL)) {
-                    permittedActions = Arrays.asList(CldsEvent.ACTION_UPDATE, CldsEvent.ACTION_STOP);
-                }
-                break;
-            case CldsEvent.ACTION_STOP:
-                permittedActions = Arrays.asList(CldsEvent.ACTION_UPDATE, CldsEvent.ACTION_RESTART,
-                        CldsEvent.ACTION_UNDEPLOY);
-                if (isTypeModel(propText, ModelType.POLICY_MODEL)) {
-                    permittedActions = Arrays.asList(CldsEvent.ACTION_UPDATE, CldsEvent.ACTION_RESTART,
-                            CldsEvent.ACTION_DELETE);
-                }
-                break;
-            default:
-                getLogger().warn("Invalid current actionCd: " + actionCd);
-                permittedActions = Arrays.asList();
-        }
-        return permittedActions;
-    }
-
-    /**
-     * This returns the action of the event or a default one if not found.
-     *
-     * @param event The last event
-     * @return The action
-     */
-    default String getCurrentActionCd(CldsEvent event) {
-        // current default actionCd is CREATE
-        String actionCd = CldsEvent.ACTION_CREATE;
-        if (event != null && event.getActionCd() != null) {
-            actionCd = event.getActionCd();
-        }
-        return actionCd;
-    }
-
-    /**
-     * Check whether the text properties is of specified type ModelType.
-     *
-     * @param propText
-     *        The Clamp Json properties
-     * @param key
-     *        The model type
-     * @return True if matches the right type specified
-     */
-    default boolean isTypeModel(String propText, ModelType key) {
-        boolean result = false;
-        try {
-            if (propText != null) {
-                JsonObject modelJson = JsonUtils.GSON.fromJson(propText, JsonObject.class);
-                JsonElement modelJsonOfType = modelJson.get(key.getType());
-                if (modelJsonOfType != null
-                        && modelJsonOfType.isJsonPrimitive()
-                        && modelJsonOfType.getAsJsonPrimitive().getAsBoolean()) {
-                    result = true;
-                }
-            }
-        } catch (JsonParseException e) {
-            getLogger().error("Error while parsing propText json", e);
-        }
-        return result;
-    }
-}
diff --git a/src/main/java/org/onap/clamp/clds/model/actions/ActionsHandlerImpl.java b/src/main/java/org/onap/clamp/clds/model/actions/ActionsHandlerImpl.java
deleted file mode 100644 (file)
index 8d7d240..0000000
+++ /dev/null
@@ -1,38 +0,0 @@
-/*-
- * ============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.actions;
-
-import com.att.eelf.configuration.EELFLogger;
-import com.att.eelf.configuration.EELFManager;
-
-public class ActionsHandlerImpl implements ActionsHandler {
-
-    private static final EELFLogger logger = EELFManager.getInstance().getLogger(ActionsHandlerImpl.class);
-
-    @Override
-    public EELFLogger getLogger() {
-        return logger;
-    }
-
-}
diff --git a/src/main/java/org/onap/clamp/clds/model/properties/AbstractModelElement.java b/src/main/java/org/onap/clamp/clds/model/properties/AbstractModelElement.java
deleted file mode 100644 (file)
index 9c15524..0000000
+++ /dev/null
@@ -1,81 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * ONAP CLAMP
- * ================================================================================
- * Copyright (C) 2017-2018 AT&T Intellectual Property. All rights
- *                             reserved.
- * ================================================================================
- * Modifications Copyright (c) 2019 Samsung
- * ================================================================================
- * 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.properties;
-
-import com.att.eelf.configuration.EELFLogger;
-import com.att.eelf.configuration.EELFManager;
-import com.google.gson.JsonElement;
-import com.google.gson.JsonObject;
-
-/**
- * Provide base ModelElement functionality. Perform base parsing of properties for a ModelElement (such as,
- * VesCollector, Policy, Tca, Holmes, ...)
- */
-public abstract class AbstractModelElement {
-
-    protected static final EELFLogger logger = EELFManager.getInstance().getLogger(AbstractModelElement.class);
-    protected static final EELFLogger auditLogger = EELFManager.getInstance().getAuditLogger();
-    private final String id;
-    protected String topicPublishes;
-    protected final JsonElement modelElementJsonNode;
-    private final boolean isFound;
-
-    /**
-     * Perform base parsing of properties for a ModelElement (such as, VesCollector, Policy and Tca).
-     */
-    protected AbstractModelElement(String type, ModelBpmn modelBpmn, JsonObject modelJson) {
-        this.id = modelBpmn.getId(type);
-        this.modelElementJsonNode = modelJson.get(id);
-        this.isFound = modelBpmn.isModelElementTypeInList(type);
-    }
-
-    /**
-     * Get the topic publishes.
-     *
-     * @return the topicPublishes
-     */
-    public String getTopicPublishes() {
-        return topicPublishes;
-    }
-
-    /**
-     * Get the id.
-     *
-     * @return the id
-     */
-    public String getId() {
-        return id;
-    }
-
-    /**
-     * Get the isFound flag.
-     *
-     * @return the isFound
-     */
-    public boolean isFound() {
-        return isFound;
-    }
-}
diff --git a/src/main/java/org/onap/clamp/clds/model/properties/Global.java b/src/main/java/org/onap/clamp/clds/model/properties/Global.java
deleted file mode 100644 (file)
index 0eed6ab..0000000
+++ /dev/null
@@ -1,179 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * ONAP CLAMP
- * ================================================================================
- * Copyright (C) 2017-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.properties;
-
-import com.att.eelf.configuration.EELFLogger;
-import com.att.eelf.configuration.EELFManager;
-
-import com.google.gson.JsonElement;
-import com.google.gson.JsonObject;
-import java.util.List;
-import org.onap.clamp.clds.util.JsonUtils;
-
-/**
- * Parse global json properties.
- * Example json:
- * "global":[{"name":"service","value":["vUSP"]},{"name":"vnf","value":["vCTS",
- * "v3CDB"]},{"name":"location","value":["san_diego","san_antonio","kansas_city"
- * ,"kings_mountain","Secaucus","lisle","concord","houston","akron"]}]
- */
-public class Global {
-
-    protected static final EELFLogger logger = EELFManager.getInstance().getLogger(Global.class);
-    protected static final EELFLogger auditLogger = EELFManager.getInstance().getAuditLogger();
-    private String service;
-    private String actionSet;
-    private List<String> resourceVf;
-    private List<String> resourceVfc;
-    private JsonObject deployParameters;
-    private List<String> location;
-    private String vnfScope;
-
-    /**
-     * Parse global given json node.
-     *
-     * @param modelJson The model in json format.
-     */
-    public Global(JsonObject modelJson) {
-        JsonElement globalNode = modelJson.get("global");
-        service = JsonUtils.getStringValueByName(globalNode, "service");
-        actionSet = JsonUtils.getStringValueByName(globalNode, "actionSet");
-        resourceVf = JsonUtils.getStringValuesByName(globalNode, "vf");
-        resourceVfc = JsonUtils.getStringValuesByName(globalNode, "vfc");
-        deployParameters = JsonUtils.getJsonObjectByName(globalNode, "deployParameters");
-        location = JsonUtils.getStringValuesByName(globalNode, "location");
-        vnfScope = JsonUtils.getStringValueByName(globalNode, "vnf");
-    }
-
-    /**
-     * Get the service.
-     * @return the service
-     */
-    public String getService() {
-        return service;
-    }
-
-    /**
-     * Set the service.
-     * @param service
-     *            the service to set
-     */
-    public void setService(String service) {
-        this.service = service;
-    }
-
-    /**
-     * Get the action set.
-     * @return the actionSet
-     */
-    public String getActionSet() {
-        return actionSet;
-    }
-
-    /**
-     * Set tje actionSet.
-     * @param actionSet
-     *             The actionSet to set
-     */
-    public void setActionSet(String actionSet) {
-        this.actionSet = actionSet;
-    }
-
-    /**
-     * Get the resource vf.
-     * @return the resourceVf
-     */
-    public List<String> getResourceVf() {
-        return resourceVf;
-    }
-
-    /**
-     * Set the resourceVf.
-     * @param resourceVf
-     *            the resourceVf to set
-     */
-    public void setResourceVf(List<String> resourceVf) {
-        this.resourceVf = resourceVf;
-    }
-
-    /**
-     * Get the resource Vfc.
-     * @return the resourceVfc
-     */
-    public List<String> getResourceVfc() {
-        return resourceVfc;
-    }
-
-    /**
-     * Set tje respirce Vfc.
-     * @param resourceVfc
-     *            the resourceVfc to set
-     */
-    public void setResourceVfc(List<String> resourceVfc) {
-        this.resourceVfc = resourceVfc;
-    }
-
-    /**
-     * Get the list of locations.
-     * @return the location
-     */
-    public List<String> getLocation() {
-        return location;
-    }
-
-    /**
-     * Set the list of locations.
-     * @param location
-     *            the location to set
-     */
-    public void setLocation(List<String> location) {
-        this.location = location;
-    }
-
-    /**
-     * Get the deploy parameters.
-     * @return The deploy parameters
-     */
-    public JsonObject getDeployParameters() {
-        return deployParameters;
-    }
-
-    /**
-     * Set the deploy parameters.
-     * @param deployParameters
-     *         the deploy parameters to set
-     */
-    public void setDeployParameters(JsonObject deployParameters) {
-        this.deployParameters = deployParameters;
-    }
-
-    /**
-     * Get the vnf scope.
-     * @return The vnf scope
-     */
-    public String getVnfScope() {
-        return vnfScope;
-    }
-
-}
diff --git a/src/main/java/org/onap/clamp/clds/model/properties/Holmes.java b/src/main/java/org/onap/clamp/clds/model/properties/Holmes.java
deleted file mode 100644 (file)
index a56c57d..0000000
+++ /dev/null
@@ -1,71 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * ONAP CLAMP
- * ================================================================================
- * Copyright (C) 2017-2018 AT&T Intellectual Property. All rights
- *                             reserved.
- * ================================================================================
- * Modifications Copyright (c) 2019 Samsung
- * ================================================================================
- * 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.properties;
-
-import com.google.gson.JsonObject;
-
-import org.onap.clamp.clds.util.JsonUtils;
-
-/**
- * Parse Holmes bpmn parameters json properties. Example json:
- * [{"name":"correlationalLogic","value":"vcwx"},{"name":"configPolicyName","value":"cccc"}]
- */
-public class Holmes extends AbstractModelElement {
-
-    private static final String TYPE_HOLMES = "holmes";
-
-    private String correlationLogic;
-    private String configPolicyName;
-
-    /**
-     * Default constructor for Holmes Element.
-     *
-     * @param modelBpmn
-     *        The model bpmn
-     * @param modelJson
-     *        The model json
-     */
-    public Holmes(ModelBpmn modelBpmn, JsonObject modelJson) {
-        super(TYPE_HOLMES, modelBpmn, modelJson);
-
-        if (modelElementJsonNode != null) {
-            correlationLogic = JsonUtils.getStringValueByName(modelElementJsonNode, "correlationalLogic");
-            configPolicyName = JsonUtils.getStringValueByName(modelElementJsonNode, "configPolicyName");
-        }
-    }
-
-    public static final String getType() {
-        return TYPE_HOLMES;
-    }
-
-    public String getCorrelationLogic() {
-        return correlationLogic;
-    }
-
-    public String getConfigPolicyName() {
-        return configPolicyName;
-    }
-}
diff --git a/src/main/java/org/onap/clamp/clds/model/properties/ModelBpmn.java b/src/main/java/org/onap/clamp/clds/model/properties/ModelBpmn.java
deleted file mode 100644 (file)
index d35eea8..0000000
+++ /dev/null
@@ -1,173 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * ONAP CLAMP
- * ================================================================================
- * Copyright (C) 2017-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.properties;
-
-import com.att.eelf.configuration.EELFLogger;
-import com.att.eelf.configuration.EELFManager;
-
-import com.google.gson.JsonArray;
-import com.google.gson.JsonElement;
-import com.google.gson.JsonObject;
-import com.google.gson.JsonParseException;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-import java.util.Map.Entry;
-
-import org.onap.clamp.clds.exception.ModelBpmnException;
-import org.onap.clamp.clds.service.CldsService;
-import org.onap.clamp.clds.util.JsonUtils;
-
-/**
- * Parse Model BPMN properties.
- * Example json: {"policy" :[{"id":"Policy_0oxeocn", "from":"StartEvent_1"}]}
- */
-public class ModelBpmn {
-
-    protected static final EELFLogger logger = EELFManager.getInstance().getLogger(CldsService.class);
-    protected static final EELFLogger auditLogger = EELFManager.getInstance().getAuditLogger();
-    // for each type, an array of entries
-    private final Map<String, List<ModelBpmnEntry>> entriesByType = new HashMap<>();
-    // for each id, an array of entries
-    private final Map<String, List<ModelBpmnEntry>> entriesById = new HashMap<>();
-    // List of all elementIds
-    private List<String> bpmnElementIds;
-
-    /**
-     * Create ModelBpmn and populate maps from json.
-     *
-     * @param modelBpmnPropText The model bpmn properties text
-     * @return The model bpmn
-     */
-    public static ModelBpmn create(String modelBpmnPropText) {
-        try {
-            ModelBpmn modelBpmn = new ModelBpmn();
-            JsonObject root = JsonUtils.GSON.fromJson(modelBpmnPropText, JsonObject.class);
-            // iterate over each entry like:
-            // "Policy":[{"id":"Policy","from":"StartEvent_1"}]
-            Iterator<Entry<String, JsonElement>> entryItr = root.entrySet().iterator();
-            List<String> bpmnElementIdList = new ArrayList<>();
-            while (entryItr.hasNext()) {
-                // process the entry
-                Entry<String, JsonElement> entry = entryItr.next();
-                String type = entry.getKey();
-                JsonArray arrayNode = entry.getValue().getAsJsonArray();
-                // process each id/from object, like:
-                // {"id":"Policy","from":"StartEvent_1"}
-                for (JsonElement anArrayNode : arrayNode) {
-                    JsonObject node = anArrayNode.getAsJsonObject();
-                    String id = node.get("id").getAsString();
-                    String fromId = node.get("from").getAsString();
-                    ModelBpmnEntry modelBpmnEntry = new ModelBpmnEntry(type, id, fromId);
-                    modelBpmn.addEntry(modelBpmnEntry);
-                    bpmnElementIdList.add(id);
-                }
-                modelBpmn.setBpmnElementIds(bpmnElementIdList);
-            }
-            return modelBpmn;
-        } catch (JsonParseException e) {
-            throw new ModelBpmnException("Exception occurred during the decoding of the bpmn JSON", e);
-        }
-    }
-
-    /**
-     * Add entry to both maps.
-     *
-     * @param entry The model bpmn entry.
-     */
-    private void addEntry(ModelBpmnEntry entry) {
-        addEntry(entriesByType, entry, entry.getType());
-        addEntry(entriesById, entry, entry.getId());
-    }
-
-    /**
-     * Add an entry to provided map with provided key.
-     *
-     * @param map The map to add the model bpmn entry
-     * @param entry The model bmpn entry
-     * @param key The key
-     */
-    private static void addEntry(Map<String, List<ModelBpmnEntry>> map, ModelBpmnEntry entry, String key) {
-        List<ModelBpmnEntry> list = map.computeIfAbsent(key, k -> new ArrayList<>());
-        list.add(entry);
-    }
-
-    /**
-     * This method verifies if the ModelElement Type (holmes, tca, ...) is in
-     * the list.
-     *
-     * @param type
-     *            A model Element type (tca, ...)
-     * @return true if the element is found or false otherwise
-     */
-    public boolean isModelElementTypeInList(String type) {
-        return entriesByType.get(type) != null;
-    }
-
-    /**
-     * Get the id.
-     * @return the id field given the ModelElement type
-     */
-    public String getId(String type) {
-        String modelElementId = "";
-        if (entriesByType.get(type) != null) {
-            modelElementId = entriesByType.get(type).get(0).getId();
-        }
-        return modelElementId;
-    }
-
-    /**
-     * Get the form id.
-     * @return the fromId field given the ModelElement type
-     */
-    public String getFromId(String type) {
-        String modelElementFromIdId = "";
-        if (entriesByType.get(type) != null) {
-            modelElementFromIdId = entriesByType.get(type).get(0).getFromId();
-        }
-        return modelElementFromIdId;
-    }
-
-    /**
-     * Get the type.
-     * @return the ModelElement type given the ModelElement id
-     */
-    public String getType(String id) {
-        return entriesById.get(id).get(0).getType();
-    }
-
-    /**
-     * Get the bpmn element ids.
-     * @return list of elementIds from bpmn
-     */
-    public List<String> getBpmnElementIds() {
-        return bpmnElementIds;
-    }
-
-    public void setBpmnElementIds(List<String> bpmnElementIds) {
-        this.bpmnElementIds = bpmnElementIds;
-    }
-}
diff --git a/src/main/java/org/onap/clamp/clds/model/properties/ModelBpmnEntry.java b/src/main/java/org/onap/clamp/clds/model/properties/ModelBpmnEntry.java
deleted file mode 100644 (file)
index 741b9de..0000000
+++ /dev/null
@@ -1,107 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * ONAP CLAMP
- * ================================================================================
- * Copyright (C) 2017-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.properties;
-
-import com.att.eelf.configuration.EELFLogger;
-import com.att.eelf.configuration.EELFManager;
-
-/**
- * Model BPMN property entry.
- * Example json: {"policy":
- * [{"id":"Policy_0oxeocn", "from":"StartEvent_1"}]}
- */
-public class ModelBpmnEntry {
-    protected static final EELFLogger       logger      = EELFManager.getInstance().getLogger(ModelBpmnEntry.class);
-    protected static final EELFLogger auditLogger = EELFManager.getInstance().getAuditLogger();
-
-    private String                  type;
-    private String                  id;
-    private String                  fromId;
-
-    /**
-     * Parse the json so that the "id" and "from" fields can be retrieved on
-     * demand.
-     *
-     * @param type The type
-     * @param id The id
-     * @param fromId The form id
-     */
-    public ModelBpmnEntry(String type, String id, String fromId) {
-        this.type = type;
-        this.id = id;
-        this.fromId = fromId;
-    }
-
-    /**
-     * Get the type.
-     * @return the type
-     */
-    public String getType() {
-        return type;
-    }
-
-    /**
-     * Set the type.
-     * @param type
-     *            the type to set
-     */
-    public void setType(String type) {
-        this.type = type;
-    }
-
-    /**
-     * Get the id.
-     * @return the id
-     */
-    public String getId() {
-        return id;
-    }
-
-    /**
-     * Set the id.
-     * @param id
-     *            the id to set
-     */
-    public void setId(String id) {
-        this.id = id;
-    }
-
-    /**
-     * Get the form id.
-     * @return the fromId
-     */
-    public String getFromId() {
-        return fromId;
-    }
-
-    /**
-     * Set the form id.
-     * @param fromId
-     *            the fromId to set
-     */
-    public void setFromId(String fromId) {
-        this.fromId = fromId;
-    }
-
-}
diff --git a/src/main/java/org/onap/clamp/clds/model/properties/ModelProperties.java b/src/main/java/org/onap/clamp/clds/model/properties/ModelProperties.java
deleted file mode 100644 (file)
index 9b7f85d..0000000
+++ /dev/null
@@ -1,380 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * ONAP CLAMP
- * ================================================================================
- * Copyright (C) 2017-2018 AT&T Intellectual Property. All rights
- *                             reserved.
- * ================================================================================
- * Modifications Copyright (c) 2019 Samsung
- * ================================================================================
- * 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.properties;
-
-import com.att.eelf.configuration.EELFLogger;
-import com.att.eelf.configuration.EELFManager;
-import com.google.gson.JsonObject;
-import com.google.gson.JsonParseException;
-import java.lang.reflect.InvocationTargetException;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-import java.util.concurrent.ConcurrentHashMap;
-import org.apache.camel.Exchange;
-import org.onap.clamp.clds.client.req.policy.PolicyClient;
-import org.onap.clamp.clds.config.ClampProperties;
-import org.onap.clamp.clds.exception.ModelBpmnException;
-import org.onap.clamp.clds.model.CldsModel;
-import org.onap.clamp.clds.service.CldsService;
-import org.onap.clamp.clds.util.JsonUtils;
-
-/**
- * Parse model properties.
- */
-public class ModelProperties {
-
-    protected static final EELFLogger logger = EELFManager.getInstance().getLogger(CldsService.class);
-    protected static final EELFLogger auditLogger = EELFManager.getInstance().getAuditLogger();
-    private ModelBpmn modelBpmn;
-    private JsonObject modelJson;
-    private final String modelName;
-    private final String controlName;
-    private final String actionCd;
-    // Flag indicate whether it is triggered by Validation Test button from UI
-    private final boolean testOnly;
-    private Global global;
-    private final Map<String, AbstractModelElement> modelElements = new ConcurrentHashMap<>();
-    private String currentModelElementId;
-    private String policyUniqueId;
-    private String guardUniqueId;
-    public static final String POLICY_GUARD_SUFFIX = "_Guard_";
-    private static final Object lock = new Object();
-    private static Map<Class<? extends AbstractModelElement>, String> modelElementClasses = new ConcurrentHashMap<>();
-
-    static {
-        synchronized (lock) {
-            modelElementClasses.put(Policy.class, Policy.getType());
-            modelElementClasses.put(Tca.class, Tca.getType());
-            modelElementClasses.put(Holmes.class, Holmes.getType());
-        }
-    }
-
-    /**
-     * Retain data required to parse the ModelElement objects. (Rather than parse
-     * them all - parse them on demand if requested.)
-     *
-     * @param modelName
-     *        The model name coming form the UI
-     * @param controlName
-     *        The closed loop name coming from the UI
-     * @param actionCd
-     *        Type of operation PUT,UPDATE,DELETE
-     * @param isATest
-     *        The test flag coming from the UI (for validation only, no query are
-     *        physically executed)
-     * @param modelBpmnText
-     *        The BPMN flow in JSON from the UI
-     * @param modelPropText
-     *        The BPMN parameters for all boxes defined in modelBpmnTest
-     */
-    public ModelProperties(String modelName, String controlName, String actionCd, boolean isATest, String modelBpmnText,
-        String modelPropText) {
-        try {
-            this.modelName = modelName;
-            this.controlName = controlName;
-            this.actionCd = actionCd;
-            this.testOnly = isATest;
-            modelBpmn = ModelBpmn.create(modelBpmnText);
-            modelJson = JsonUtils.GSON.fromJson(modelPropText, JsonObject.class);
-            instantiateMissingModelElements();
-        } catch (JsonParseException e) {
-            throw new ModelBpmnException("Exception occurred when trying to decode the BPMN Properties JSON", e);
-        }
-    }
-
-    /**
-     * This method is meant to ensure that one ModelElement instance exists for each
-     * ModelElement class. As new ModelElement classes could have been registered
-     * after instantiation of this ModelProperties, we need to build the missing
-     * ModelElement instances.
-     */
-    private void instantiateMissingModelElements() {
-        if (modelElementClasses.size() != modelElements.size()) {
-            Set<String> missingTypes = new HashSet<>(modelElementClasses.values());
-            missingTypes.removeAll(modelElements.keySet());
-            // Parse the list of base Model Elements and build up the
-            // ModelElements
-            modelElementClasses.entrySet().stream().parallel()
-                    .filter(entry -> (AbstractModelElement.class.isAssignableFrom(entry.getKey())
-                            && missingTypes.contains(entry.getValue())))
-                    .forEach(entry -> {
-                        try {
-                            modelElements.put(entry.getValue(),
-                                    (entry.getKey().getConstructor(ModelBpmn.class, JsonObject.class)
-                                            .newInstance(modelBpmn, modelJson)));
-                        } catch (InstantiationException | NoSuchMethodException | IllegalAccessException
-                                | InvocationTargetException e) {
-                            logger.warn("Unable to instantiate a ModelElement " + entry.getValue()
-                                    + ", exception follows: ", e);
-                        }
-                    });
-        }
-    }
-
-    /**
-     * Get the VF for a model. If return null if there is no VF.
-     *
-     * @param model The clds model
-     * @return The vf of the model
-     */
-    public static String getVf(CldsModel model) {
-        List<String> vfs = null;
-        try {
-            JsonObject modelJson = JsonUtils.GSON.fromJson(model.getPropText(), JsonObject.class);
-            Global global = new Global(modelJson);
-            vfs = global.getResourceVf();
-        } catch (JsonParseException e) {
-            logger.warn("no VF found", e);
-        }
-        String vf = null;
-        if (vfs != null && !vfs.isEmpty()) {
-            vf = vfs.get(0);
-        }
-        return vf;
-    }
-
-    /**
-     * Create ModelProperties extracted from a CamelExchange.
-     *
-     * @param camelExchange
-     *        The camel Exchange object that contains all info provided to the flow
-     * @return A model Properties created from the parameters found in camelExchange
-     *         object
-     */
-    public static ModelProperties create(Exchange camelExchange) {
-        String modelProp = (String) camelExchange.getProperty("modelProp");
-        String modelBpmnProp = (String) camelExchange.getProperty("modelBpmnProp");
-        String modelName = (String) camelExchange.getProperty("modelName");
-        String controlName = (String) camelExchange.getProperty("controlName");
-        String actionCd = (String) camelExchange.getProperty("actionCd");
-        boolean isTest = (boolean) camelExchange.getProperty("isTest");
-        return new ModelProperties(modelName, controlName, actionCd, isTest, modelBpmnProp, modelProp);
-    }
-
-    /**
-     * Get the model name.
-     * @return the modelName
-     */
-    public String getModelName() {
-        return modelName;
-    }
-
-    /**
-     * Get the control name.
-     * @return the controlName
-     */
-    public String getControlName() {
-        return controlName;
-    }
-
-    /**
-     * Get the control name qnd policy uniqueId.
-     * @return the controlNameAndPolicyUniqueId
-     */
-    public String getControlNameAndPolicyUniqueId() {
-        return controlName + "_" + policyUniqueId;
-    }
-
-    /**
-     * Get the current policy name.
-     * @return the currentPolicyName
-     */
-    private String getCurrentPolicyName() {
-        return normalizePolicyScopeName(controlName + "_" + currentModelElementId);
-    }
-
-    private String createScopeSeparator(String policyScope) {
-        return policyScope.contains(".") ? "" : ".";
-    }
-
-    /**
-     * Get the current policy scope and policy name.
-     * @return the currentPolicyScopeAndPolicyName
-     */
-    public String getCurrentPolicyScopeAndPolicyName() {
-        return normalizePolicyScopeName(modelName + createScopeSeparator(modelName) + getCurrentPolicyName());
-    }
-
-    /**
-     * Get policy name for dcae deploy.
-     * @return The policyName that wil be used in input parameters of DCAE deploy
-     */
-    public String getPolicyNameForDcaeDeploy(ClampProperties refProp) {
-        return normalizePolicyScopeName(modelName + createScopeSeparator(modelName)
-            + refProp.getStringValue(PolicyClient.POLICY_MS_NAME_PREFIX_PROPERTY_NAME) + getCurrentPolicyName());
-    }
-
-    /**
-     * Get policy scope and name with uniqueid.
-     * @return the policyScopeAndNameWithUniqueId
-     */
-    public String getPolicyScopeAndNameWithUniqueId() {
-        return normalizePolicyScopeName(
-            modelName + createScopeSeparator(modelName) + getCurrentPolicyName() + "_" + policyUniqueId);
-    }
-
-    /**
-     * Get policy scope and name with unique guardid.
-     * @return the policyScopeAndNameWithUniqueId
-     */
-    public String getPolicyScopeAndNameWithUniqueGuardId() {
-        return normalizePolicyScopeName(modelName + createScopeSeparator(modelName) + getCurrentPolicyName() + "_"
-            + policyUniqueId + POLICY_GUARD_SUFFIX + guardUniqueId);
-    }
-
-    /**
-     * Get current policy scope and full policy name.
-     * @return the currentPolicyScopeAndFullPolicyName
-     */
-    public String getCurrentPolicyScopeAndFullPolicyName(String policyNamePrefix) {
-        return normalizePolicyScopeName(
-            modelName + createScopeSeparator(modelName) + policyNamePrefix + getCurrentPolicyName());
-    }
-
-    /**
-     * Get policy name with scope context.
-     * @return the PolicyNameWithScopeContext
-     */
-    public String getPolicyNameWithScopeContext(String policyScope, String policyType, String vnfScope, String context,
-        String userDefinedName) {
-        return normalizePolicyScopeName(policyScope + createScopeSeparator(policyScope) + policyType + "_" + vnfScope
-            + "_" + context + "_" + modelName + "_" + userDefinedName);
-    }
-
-    /**
-     * Get policy name with prefix scope context.
-     * @return the PolicyNameWithPrefixScopeContext
-     */
-    public String getPolicyNameWithPrefixScopeContext(String policyScope, String policyType, String vnfScope,
-        String context, String userDefinedName, String policyPrefix) {
-        return normalizePolicyScopeName(policyScope + createScopeSeparator(policyScope) + policyPrefix + policyType
-            + "_" + vnfScope + "_" + context + "_" + modelName + "_" + userDefinedName);
-    }
-
-    /**
-     * Replace all '-' with '_' within policy scope and name.
-     *
-     * @param inName policy scope and name
-     * @return policy scope and name with "-" replaced with "_"
-     */
-    private String normalizePolicyScopeName(String inName) {
-        return inName.replaceAll("-", "_");
-    }
-
-    /**
-     * Get current model element id.
-     * @return the currentModelElementId
-     */
-    public String getCurrentModelElementId() {
-        return currentModelElementId;
-    }
-
-    /**
-     * When generating a policy request for a model element, must set the id of that
-     * model element using this method. Used to generate the policy name.
-     *
-     * @param currentModelElementId
-     *        the currentModelElementId to set
-     */
-    public void setCurrentModelElementId(String currentModelElementId) {
-        this.currentModelElementId = currentModelElementId;
-    }
-
-    /**
-     * Get policy uniqueId.
-     * @return the policyUniqueId
-     */
-    public String getPolicyUniqueId() {
-        return policyUniqueId;
-    }
-
-    public String getGuardUniqueId() {
-        return guardUniqueId;
-    }
-
-    public void setGuardUniqueId(String guardUniqueId) {
-        this.guardUniqueId = guardUniqueId;
-    }
-
-    /**
-     * When generating a policy request for a model element, must set the unique id
-     * of that policy using this method. Used to generate the policy name.
-     *
-     * @param policyUniqueId
-     *        the policyUniqueId to set
-     */
-    public void setPolicyUniqueId(String policyUniqueId) {
-        this.policyUniqueId = policyUniqueId;
-    }
-
-    /**
-     * Get actioncd.
-     * @return the actionCd
-     */
-    public String getActionCd() {
-        return actionCd;
-    }
-
-    /**
-     * Get the testOnly flag value.
-     * @return the testOnly
-     */
-    public boolean isTestOnly() {
-        return testOnly;
-    }
-
-    /**
-     * Get the global value.
-     * @return the global
-     */
-    public Global getGlobal() {
-        if (global == null) {
-            global = new Global(modelJson);
-        }
-        return global;
-    }
-
-    /**
-     * Registers model element.
-     *
-     * @param modelElementClass model element class
-     * @param type model element type
-     */
-    public static final synchronized void registerModelElement(Class<? extends AbstractModelElement> modelElementClass,
-        String type) {
-        if (!modelElementClasses.containsKey(modelElementClass.getClass())) {
-            modelElementClasses.put(modelElementClass, type);
-        }
-    }
-
-    public <T extends AbstractModelElement> T getType(Class<T> clazz) {
-        instantiateMissingModelElements();
-        String type = modelElementClasses.get(clazz);
-        return (type != null ? (T) modelElements.get(type) : null);
-    }
-}
diff --git a/src/main/java/org/onap/clamp/clds/model/properties/Policy.java b/src/main/java/org/onap/clamp/clds/model/properties/Policy.java
deleted file mode 100644 (file)
index 9537cb9..0000000
+++ /dev/null
@@ -1,95 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * ONAP CLAMP
- * ================================================================================
- * Copyright (C) 2017-2018 AT&T Intellectual Property. All rights
- *                             reserved.
- * ================================================================================
- * Modifications Copyright (c) 2019 Samsung
- * ================================================================================
- * 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.properties;
-
-import com.att.eelf.configuration.EELFLogger;
-import com.att.eelf.configuration.EELFManager;
-import com.google.gson.JsonElement;
-import com.google.gson.JsonObject;
-
-import java.io.IOException;
-import java.util.ArrayList;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map.Entry;
-
-/**
- * Parse Policy json properties.
- * Example json:
- * "Policy_005sny1":[[{"name":"timeout","value":"5"}],{"policyConfigurations":[[
- * {"name":"recipe","value":["restart"]},{"name":"maxRetries","value":["3"]},{
- * "name":"retryTimeLimit","value":["180"]},{"name":"_id","value":["vf3RtPi"]},{
- * "name":"location","value":["san_diego"]},{"name":"resource","value":["vCTS"]}
- * ,{"name":"onMaxRetriesLimit","value":[""]},{"name":"onTimeLimit","value":[""]
- * },{"name":"onOtherFailure","value":[""]},{"name":"policy_parent","value":[""]
- * }],[{"name":"recipe","value":["rebuild"]},{"name":"maxRetries","value":["3"]}
- * ,{"name":"retryTimeLimit","value":["180"]},{"name":"_id","value":["89z8Ncl"]}
- * ,{"name":"location","value":["san_diego"]},{"name":"resource","value":["vCTS"
- * ]},{"name":"onMaxRetriesLimit","value":[""]},{"name":"onTimeLimit","value":[
- * ""]},{"name":"onOtherFailure","value":[""]},{"name":"policy_parent","value":[
- * "vf3RtPi"]}]]}]
- */
-public class Policy extends AbstractModelElement {
-    protected static final EELFLogger logger = EELFManager.getInstance().getLogger(Policy.class);
-    protected static final EELFLogger auditLogger = EELFManager.getInstance().getAuditLogger();
-
-    private List<PolicyChain> policyChains;
-
-    private static final String TYPE_POLICY = "policy";
-
-    /**
-     * Parse Policy given json node.
-     *
-     * @param modelBpmn The model bpmn
-     * @param modelJson The model json
-     * @throws IOException The IO Exception
-     */
-    public Policy(ModelBpmn modelBpmn, JsonObject modelJson) throws IOException {
-        super(TYPE_POLICY, modelBpmn, modelJson);
-
-        // process policies
-        if (modelElementJsonNode != null) {
-            Iterator<Entry<String, JsonElement>> itr = modelElementJsonNode.getAsJsonObject().entrySet().iterator();
-            policyChains = new ArrayList<>();
-            while (itr.hasNext()) {
-                policyChains.add(new PolicyChain(itr.next().getValue()));
-            }
-        }
-    }
-
-    /**
-     * Get the policy chains.
-     *
-     * @return the policyChains
-     */
-    public List<PolicyChain> getPolicyChains() {
-        return policyChains;
-    }
-
-    public static final String getType() {
-        return TYPE_POLICY;
-    }
-}
diff --git a/src/main/java/org/onap/clamp/clds/model/properties/PolicyChain.java b/src/main/java/org/onap/clamp/clds/model/properties/PolicyChain.java
deleted file mode 100644 (file)
index ba6abd8..0000000
+++ /dev/null
@@ -1,125 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * ONAP CLAMP
- * ================================================================================
- * Copyright (C) 2017-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.properties;
-
-import com.att.eelf.configuration.EELFLogger;
-import com.att.eelf.configuration.EELFManager;
-import com.google.gson.JsonArray;
-import com.google.gson.JsonElement;
-import java.io.IOException;
-import java.util.ArrayList;
-import java.util.Iterator;
-import java.util.List;
-import org.onap.clamp.clds.util.JsonUtils;
-
-/**
- * Parse Policy json properties.
- * Example json:
- * {"Policy_1e33tn8":{"PolicyTest1":[{"name":"pname","value":"PolicyTest1"},{
- * "name":"pid","value":"1"},{"name":"timeout","value":"345"},{
- * "policyConfigurations":[[{"name":"recipe","value":["restart"]},{"name":
- * "maxRetries","value":["3"]},{"name":"retryTimeLimit","value":["180"]},{"name"
- * :"_id","value":["q2JmHD5"]},{"name":"parentPolicy","value":[""]}],[{"name":
- * "recipe","value":["rebuild"]},{"name":"maxRetries","value":["3"]},{"name":
- * "retryTimeLimit","value":["180"]},{"name":"_id","value":["0ZqHdrR"]},{"name":
- * "parentPolicy","value":[""]},{"name":
- * "targetResourceId","value":["Eace933104d443b496b8.nodes.heat.vpg"]}]]}],
- * "PolicyTest2":[{"name":"pname","value":
- * "PolicyTest2"},{"name":"pid","value":"2"},{"name":"timeout","value":"345"},{
- * "policyConfigurations":[[{"name":"recipe","value":["restart"]},{"name":
- * "maxRetries","value":["3"]},{"name":"retryTimeLimit","value":["180"]},{"name"
- * :"_id","value":["q2JmHD5"]},{"name":"parentPolicy","value":[""]}],[{"name":
- * "recipe","value":["rebuild"]},{"name":"maxRetries","value":["3"]},{"name":
- * "retryTimeLimit","value":["180"]},{"name":"_id","value":["0ZqHdrR"]},{"name":
- * "parentPolicy","value":[""]},{"name":
- * "targetResourceId","value":["Eace933104d443b496b8.nodes.heat.vpg"]}]]}]}} f
- *
- */
-public class PolicyChain {
-
-    protected static final EELFLogger logger      = EELFManager.getInstance().getLogger(PolicyChain.class);
-    protected static final EELFLogger auditLogger = EELFManager.getInstance().getAuditLogger();
-
-    private String                    policyId;
-    private Integer                   timeout;
-    private List<PolicyItem>          policyItems;
-    private String                    policyType;
-
-    /**
-     * Constructor.
-     * @param node The policy element in JsonElement format
-     * @throws IOException The IO Exception
-     */
-    public PolicyChain(JsonElement node) throws IOException {
-        if (node != null && node.isJsonArray() && node.getAsJsonArray().size() > 0) {
-            policyId = JsonUtils.getStringValueByName(node, "pid");
-            timeout = JsonUtils.getIntValueByName(node, "timeout");
-            policyType = JsonUtils.getStringValueByName(node, "policyType");
-            JsonArray operationalPolicyParameters = node.getAsJsonArray();
-
-            JsonArray policyConfigurations = operationalPolicyParameters.get(operationalPolicyParameters.size() - 1)
-                .getAsJsonObject()
-                .get("policyConfigurations")
-                .getAsJsonArray();
-            Iterator<JsonElement> itr = policyConfigurations.iterator();
-            policyItems = new ArrayList<>();
-            while (itr.hasNext()) {
-                policyItems.add(new PolicyItem(itr.next()));
-
-            }
-        }
-    }
-    /**
-     * Get the policy Id.
-     * @return the policyId
-     */
-    public String getPolicyId() {
-        return policyId;
-    }
-
-    /**
-     * Get the time out.
-     * @return the timeout
-     */
-    public Integer getTimeout() {
-        return timeout;
-    }
-
-    /**
-     * Get the policy items.
-     * @return the policyItems
-     */
-    public List<PolicyItem> getPolicyItems() {
-        return policyItems;
-    }
-
-    /**
-     * Get the policy type.
-     * @return the policyType
-     */
-    public String getPolicyType() {
-        return policyType;
-    }
-
-}
diff --git a/src/main/java/org/onap/clamp/clds/model/properties/PolicyItem.java b/src/main/java/org/onap/clamp/clds/model/properties/PolicyItem.java
deleted file mode 100644 (file)
index 1855468..0000000
+++ /dev/null
@@ -1,330 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * ONAP CLAMP
- * ================================================================================
- * Copyright (C) 2017-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.properties;
-
-import com.att.eelf.configuration.EELFLogger;
-import com.att.eelf.configuration.EELFManager;
-
-import com.google.gson.JsonElement;
-import com.google.gson.reflect.TypeToken;
-import java.io.IOException;
-import java.util.List;
-import java.util.Map;
-
-import org.onap.clamp.clds.util.JsonUtils;
-import org.yaml.snakeyaml.Yaml;
-
-/**
- * Parse policyConfigurations from Policy json properties.
- * Example json:
- * "Policy_005sny1":[[{"name":"timeout","value":"5"}],{"policyConfigurations":[[
- * {"name":"recipe","value":["restart"]},{"name":"maxRetries","value":["3"]},{
- * "name":"retryTimeLimit","value":["180"]},{"name":"_id","value":["vf3RtPi"]},{
- * "name":"location","value":["san_diego"]},{"name":"resource","value":["vCTS"]}
- * ,{"name":"onMaxRetriesLimit","value":[""]},{"name":"onTimeLimit","value":[""]
- * },{"name":"onOtherFailure","value":[""]},{"name":"policy_parent","value":[""]
- * }],[{"name":"recipe","value":["rebuild"]},{"name":"maxRetries","value":["3"]}
- * ,{"name":"retryTimeLimit","value":["180"]},{"name":"_id","value":["89z8Ncl"]}
- * ,{"name":"location","value":["san_diego"]},{"name":"resource","value":["vCTS"
- * ]},{"name":"onMaxRetriesLimit","value":[""]},{"name":"onTimeLimit","value":[
- * ""]},{"name":"onOtherFailure","value":[""]},{"name":"policy_parent","value":[
- * "vf3RtPi"]},{"name":
- * "targetResourceId","value":["Eace933104d443b496b8.nodes.heat.vpg"]}]]}]
- */
-public class PolicyItem implements Cloneable {
-    protected static final EELFLogger logger = EELFManager.getInstance().getLogger(PolicyItem.class);
-    protected static final EELFLogger auditLogger = EELFManager.getInstance().getAuditLogger();
-
-    private String id;
-    private String recipe;
-    private int maxRetries;
-    private int retryTimeLimit;
-    private String parentPolicy;
-    private List<String> parentPolicyConditions;
-    private String actor;
-    private String targetResourceId;
-    private String recipeInfo;
-    private String recipeLevel;
-    private String recipeInput;
-    private Map<String, String> recipePayload;
-    private String oapRop;
-    private String oapLimit;
-
-    private String enableGuardPolicy;
-    private String guardPolicyType;
-    private String guardTargets;
-    private String minGuard;
-    private String maxGuard;
-    private String limitGuard;
-    private String timeUnitsGuard;
-    private String timeWindowGuard;
-    private String guardActiveStart;
-    private String guardActiveEnd;
-
-    /**
-     * Parse Policy given JSON node.
-     *
-     * @param item policy in JSON format
-     * @throws IOException IO exception
-     */
-    public PolicyItem(JsonElement item) throws IOException {
-        id = JsonUtils.getStringValueByName(item, "_id");
-        recipe = JsonUtils.getStringValueByName(item, "recipe");
-        maxRetries = JsonUtils.getIntValueByName(item, "maxRetries");
-        retryTimeLimit = JsonUtils.getIntValueByName(item, "retryTimeLimit");
-        parentPolicy = JsonUtils.getStringValueByName(item, "parentPolicy");
-        parentPolicyConditions = JsonUtils.getStringValuesByName(item, "parentPolicyConditions");
-        targetResourceId = JsonUtils.getStringValueByName(item, "targetResourceId");
-        if (targetResourceId != null && targetResourceId.isEmpty()) {
-            this.setTargetResourceId(null);
-        }
-        recipeInfo = JsonUtils.getStringValueByName(item, "recipeInfo");
-        recipeLevel = JsonUtils.getStringValueByName(item, "recipeLevel");
-        recipeInput = JsonUtils.getStringValueByName(item, "recipeInput");
-        String payload = JsonUtils.getStringValueByName(item, "recipePayload");
-
-        if (payload != null && !payload.isEmpty()) {
-            if (payload.trim().startsWith("{") && payload.trim().endsWith("}")) {
-                // Seems to be a JSON
-                recipePayload = JsonUtils.GSON.fromJson(payload, new TypeToken<Map<String, String>>() {}.getType());
-            } else {
-                // SHould be a YAML then
-                recipePayload = new Yaml().load(payload);
-            }
-        }
-        oapRop = JsonUtils.getStringValueByName(item, "oapRop");
-        oapLimit = JsonUtils.getStringValueByName(item, "oapLimit");
-        actor = JsonUtils.getStringValueByName(item, "actor");
-
-        enableGuardPolicy = JsonUtils.getStringValueByName(item, "enableGuardPolicy");
-        guardPolicyType = JsonUtils.getStringValueByName(item, "guardPolicyType");
-        guardTargets = JsonUtils.getStringValueByName(item, "guardTargets");
-        minGuard = JsonUtils.getStringValueByName(item, "minGuard");
-        maxGuard = JsonUtils.getStringValueByName(item, "maxGuard");
-        limitGuard = JsonUtils.getStringValueByName(item, "limitGuard");
-        timeUnitsGuard = JsonUtils.getStringValueByName(item, "timeUnitsGuard");
-        timeWindowGuard = JsonUtils.getStringValueByName(item, "timeWindowGuard");
-        guardActiveStart = JsonUtils.getStringValueByName(item, "guardActiveStart");
-        guardActiveEnd = JsonUtils.getStringValueByName(item, "guardActiveEnd");
-    }
-
-    /**
-     * Get the id.
-     * @return the id
-     */
-    public String getId() {
-        return id;
-    }
-
-    /**
-     * Get the recipe.
-     * @return the recipe
-     */
-    public String getRecipe() {
-        return recipe;
-    }
-
-    /**
-     * Set the id.
-     * @param the id
-     */
-    public void setId(String id) {
-        this.id = id;
-    }
-
-    /**
-     * Set the recipe.
-     * @param the recipe
-     */
-    public void setRecipe(String recipe) {
-        this.recipe = recipe;
-    }
-
-    /**
-     * Set the parent policy.
-     * @param the parentPolicy
-     */
-    public void setParentPolicy(String parentPolicy) {
-        this.parentPolicy = parentPolicy;
-    }
-
-    /**
-     * Set the max retries.
-     * @param the maxRetries
-     */
-    public void setMaxRetries(int maxRetries) {
-        this.maxRetries = maxRetries;
-    }
-
-    /**
-     * Set the retry time limit.
-     * @param the retryTimeLimit
-     */
-    public void setRetryTimeLimit(int retryTimeLimit) {
-        this.retryTimeLimit = retryTimeLimit;
-    }
-
-    /**
-     * Set the parent policy conditions.
-     * @param the parentPolicyConditions
-     */
-    public void setParentPolicyConditions(List<String> parentPolicyConditions) {
-        this.parentPolicyConditions = parentPolicyConditions;
-    }
-
-    /**
-     * Get the max retires.
-     * @return the maxRetries
-     */
-    public int getMaxRetries() {
-        return maxRetries;
-    }
-
-    /**
-     * Get the retry time limit.
-     * @return the retryTimeLimit
-     */
-    public int getRetryTimeLimit() {
-        return retryTimeLimit;
-    }
-
-    /**
-     * Get the parent policy.
-     * @return the parentPolicy
-     */
-    public String getParentPolicy() {
-        return parentPolicy;
-    }
-
-    /**
-     * Get the list of parent policy conditions.
-     * @return the parentPolicyConditions
-     */
-    public List<String> getParentPolicyConditions() {
-        return parentPolicyConditions;
-    }
-
-    /**
-     * Get the actor.
-     * @return the actor
-     */
-    public String getActor() {
-        return actor;
-    }
-
-    /**
-     * Set the actor.
-     * @param the actor
-     */
-    public void setActor(String actor) {
-        this.actor = actor;
-    }
-
-    public String getTargetResourceId() {
-        return targetResourceId;
-    }
-
-    public void setTargetResourceId(String targetResourceId) {
-        this.targetResourceId = targetResourceId;
-    }
-
-    public String getRecipeInfo() {
-        return recipeInfo;
-    }
-
-    public String getRecipeLevel() {
-        return recipeLevel;
-    }
-
-    public String getRecipeInput() {
-        return recipeInput;
-    }
-
-    public Map<String, String> getRecipePayload() {
-        return recipePayload;
-    }
-
-    /**
-     * Get oap rop.
-     * @return The oap rop?
-     */
-    public String getOapRop() {
-        if (oapRop == null) {
-            oapRop = "0m";
-        }
-        return oapRop;
-    }
-
-    /**
-     * Get oap limit.
-     * @return the oap limit
-     */
-    public String getOapLimit() {
-        if (oapLimit == null) {
-            oapLimit = "0";
-        }
-        return oapLimit;
-    }
-
-    public String getEnableGuardPolicy() {
-        return enableGuardPolicy;
-    }
-
-    public String getGuardPolicyType() {
-        return guardPolicyType;
-    }
-
-    public String getGuardTargets() {
-        return guardTargets;
-    }
-
-    public String getMinGuard() {
-        return minGuard;
-    }
-
-    public String getMaxGuard() {
-        return maxGuard;
-    }
-
-    public String getLimitGuard() {
-        return limitGuard;
-    }
-
-    public String getTimeUnitsGuard() {
-        return timeUnitsGuard;
-    }
-
-    public String getTimeWindowGuard() {
-        return timeWindowGuard;
-    }
-
-    public String getGuardActiveStart() {
-        return guardActiveStart;
-    }
-
-    public String getGuardActiveEnd() {
-        return guardActiveEnd;
-    }
-
-}
diff --git a/src/main/java/org/onap/clamp/clds/model/properties/Tca.java b/src/main/java/org/onap/clamp/clds/model/properties/Tca.java
deleted file mode 100644 (file)
index efa0188..0000000
+++ /dev/null
@@ -1,72 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * ONAP CLAMP
- * ================================================================================
- * Copyright (C) 2017-2018 AT&T Intellectual Property. All rights
- *                             reserved.
- * ================================================================================
- * Modifications Copyright (c) 2019 Samsung
- * ================================================================================
- * 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.properties;
-
-import com.att.eelf.configuration.EELFLogger;
-import com.att.eelf.configuration.EELFManager;
-import com.google.gson.JsonElement;
-import com.google.gson.JsonObject;
-
-import java.util.Map.Entry;
-import java.util.Set;
-
-/**
- * Parse ONAP Tca json properties.
- */
-public class Tca extends AbstractModelElement {
-
-    protected static final EELFLogger logger = EELFManager.getInstance().getLogger(Tca.class);
-    protected static final EELFLogger auditLogger = EELFManager.getInstance().getAuditLogger();
-
-    private TcaItem tcaItem;
-
-    private static final String TYPE_TCA = "tca";
-
-    /**
-     * Parse Tca given json node.
-     *
-     * @param modelBpmn The model bpmn
-     * @param modelJson The model json
-     */
-    public Tca(ModelBpmn modelBpmn, JsonObject modelJson) {
-        super(TYPE_TCA, modelBpmn, modelJson);
-
-        // process Server_Configurations
-        if (modelElementJsonNode != null) {
-            //this is wrong assumption that there is only one property object
-            Set<Entry<String, JsonElement>> entries = modelElementJsonNode.getAsJsonObject().entrySet();
-            tcaItem = new TcaItem(entries.iterator().next().getValue());
-        }
-    }
-
-    public TcaItem getTcaItem() {
-        return tcaItem;
-    }
-
-    public static final String getType() {
-        return TYPE_TCA;
-    }
-}
diff --git a/src/main/java/org/onap/clamp/clds/model/properties/TcaItem.java b/src/main/java/org/onap/clamp/clds/model/properties/TcaItem.java
deleted file mode 100644 (file)
index 94361c7..0000000
+++ /dev/null
@@ -1,119 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * ONAP CLAMP
- * ================================================================================
- * Copyright (C) 2017-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.properties;
-
-import com.att.eelf.configuration.EELFLogger;
-import com.att.eelf.configuration.EELFManager;
-
-import com.google.gson.JsonArray;
-import com.google.gson.JsonElement;
-import java.util.ArrayList;
-import java.util.Iterator;
-import java.util.List;
-import org.onap.clamp.clds.util.JsonUtils;
-
-/**
- * Parse ONAP Tca Item json properties.
- *
- */
-public class TcaItem {
-
-    protected static final EELFLogger logger      = EELFManager.getInstance().getLogger(TcaItem.class);
-    protected static final EELFLogger auditLogger = EELFManager.getInstance().getAuditLogger();
-
-    private String                    tcaName;
-    private String                    tcaUuId;
-    private String                    policyId;
-    private String                    eventName;
-    private String                    controlLoopSchemaType;
-    private List<TcaThreshold>        tcaThresholds;
-
-    /**
-     * Parse Tca Item given json node.
-     *
-     * @param tcaJson The tac json
-     */
-    public TcaItem(JsonElement tcaJson) {
-
-        tcaName = JsonUtils.getStringValueByName(tcaJson, "tname");
-        tcaUuId = JsonUtils.getStringValueByName(tcaJson, "tuuid");
-        policyId = JsonUtils.getStringValueByName(tcaJson, "tcaPolId");
-        eventName = JsonUtils.getStringValueByName(tcaJson, "eventName");
-        controlLoopSchemaType = JsonUtils.getStringValueByName(tcaJson, "controlLoopSchemaType");
-        // process service Configurations
-        JsonArray tcaConfigurationArray = tcaJson.getAsJsonArray();
-        JsonArray serviceConfigurationsNode = tcaConfigurationArray.get(tcaConfigurationArray.size() - 1)
-            .getAsJsonObject().get("serviceConfigurations").getAsJsonArray();
-        Iterator<JsonElement> itr = serviceConfigurationsNode.iterator();
-        tcaThresholds = new ArrayList<>();
-        while (itr.hasNext()) {
-            tcaThresholds.add(new TcaThreshold(itr.next().getAsJsonArray()));
-        }
-    }
-
-    public String getControlLoopSchemaType() {
-        return controlLoopSchemaType;
-    }
-
-    public void setControlLoopSchemaType(String controlLoopSchemaType) {
-        this.controlLoopSchemaType = controlLoopSchemaType;
-    }
-
-    public String getTcaName() {
-        return tcaName;
-    }
-
-    public void setTcaName(String tcaName) {
-        this.tcaName = tcaName;
-    }
-
-    public String getTcaUuId() {
-        return tcaUuId;
-    }
-
-    public void setTcaUuId(String tcaUuId) {
-        this.tcaUuId = tcaUuId;
-    }
-
-    public String getPolicyId() {
-        return policyId;
-    }
-
-    public void setPolicyId(String policyId) {
-        this.policyId = policyId;
-    }
-
-    public List<TcaThreshold> getTcaThresholds() {
-        return tcaThresholds;
-    }
-
-    public String getEventName() {
-        return eventName;
-    }
-
-    public void setEventName(String eventName) {
-        this.eventName = eventName;
-    }
-
-}
diff --git a/src/main/java/org/onap/clamp/clds/model/properties/TcaThreshold.java b/src/main/java/org/onap/clamp/clds/model/properties/TcaThreshold.java
deleted file mode 100644 (file)
index 8c69f48..0000000
+++ /dev/null
@@ -1,96 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * ONAP CLAMP
- * ================================================================================
- * Copyright (C) 2017-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.properties;
-
-import com.att.eelf.configuration.EELFLogger;
-import com.att.eelf.configuration.EELFManager;
-import com.google.gson.JsonArray;
-
-/**
- * Parse ONAP Tca Threshold json properties.
- *
- */
-public class TcaThreshold {
-
-    protected static final EELFLogger logger      = EELFManager.getInstance().getLogger(TcaThreshold.class);
-    protected static final EELFLogger auditLogger = EELFManager.getInstance().getAuditLogger();
-
-    private String                    fieldPath;
-    private String                    operator;
-    private Integer                   threshold;
-    private String                    closedLoopEventStatus;
-
-    /**
-     * Parse Tca Threshhold given json node.
-     *
-     * @param tcaTresholdConfiguration The tca threshold in JsonArray format
-     */
-    public TcaThreshold(JsonArray tcaTresholdConfiguration) {
-
-        if (tcaTresholdConfiguration.get(0) != null) {
-            fieldPath = tcaTresholdConfiguration.get(0).getAsString();
-        }
-        if (tcaTresholdConfiguration.get(1) != null) {
-            operator = tcaTresholdConfiguration.get(1).getAsString();
-        }
-        if (tcaTresholdConfiguration.get(2) != null) {
-            threshold = Integer.valueOf(tcaTresholdConfiguration.get(2).getAsString());
-        }
-        if (tcaTresholdConfiguration.get(3) != null) {
-            closedLoopEventStatus = tcaTresholdConfiguration.get(3).getAsString();
-        }
-    }
-
-    public String getFieldPath() {
-        return fieldPath;
-    }
-
-    public void setFieldPath(String fieldPath) {
-        this.fieldPath = fieldPath;
-    }
-
-    public String getOperator() {
-        return operator;
-    }
-
-    public void setOperator(String operator) {
-        this.operator = operator;
-    }
-
-    public Integer getThreshold() {
-        return threshold;
-    }
-
-    public void setThreshold(Integer threshold) {
-        this.threshold = threshold;
-    }
-
-    public String getClosedLoopEventStatus() {
-        return closedLoopEventStatus;
-    }
-
-    public void setClosedLoopEventStatus(String closedLoopEventStatus) {
-        this.closedLoopEventStatus = closedLoopEventStatus;
-    }
-}
diff --git a/src/main/java/org/onap/clamp/clds/model/status/StatusHandler.java b/src/main/java/org/onap/clamp/clds/model/status/StatusHandler.java
deleted file mode 100644 (file)
index 300c8b1..0000000
+++ /dev/null
@@ -1,68 +0,0 @@
-/*-
- * ============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.status;
-
-import org.onap.clamp.clds.model.CldsEvent;
-import org.onap.clamp.clds.model.CldsModel;
-
-/**
- * This interface describe the handler of the status in CldsModel, it's normally
- * based on the last event stored in db.
- *
- */
-public interface StatusHandler {
-
-    /**
-     * This method determines the status of the closed loop based on the last event.
-     * 
-     * @param event
-     *        The last event
-     * @return The status
-     */
-    default String determineStatusOnLastEvent(CldsEvent event) {
-        String status = CldsModel.STATUS_UNKNOWN;
-        if (event == null || event.getActionCd() == null) {
-            status = CldsModel.STATUS_DESIGN;
-        } else if (event.isActionStateCd(CldsEvent.ACTION_STATE_ERROR)) {
-            status = CldsModel.STATUS_ERROR;
-        } else if (event.isActionAndStateCd(CldsEvent.ACTION_CREATE, CldsEvent.ACTION_STATE_ANY)) {
-            status = CldsModel.STATUS_DESIGN;
-        } else if (event.isActionAndStateCd(CldsEvent.ACTION_DISTRIBUTE, CldsEvent.ACTION_STATE_RECEIVED)
-            || event.isActionAndStateCd(CldsEvent.ACTION_UNDEPLOY, CldsEvent.ACTION_STATE_COMPLETED)
-            || event.isActionAndStateCd(CldsEvent.ACTION_SUBMIT, CldsEvent.ACTION_STATE_COMPLETED)
-            || event.isActionAndStateCd(CldsEvent.ACTION_RESUBMIT, CldsEvent.ACTION_STATE_COMPLETED)) {
-            status = CldsModel.STATUS_DISTRIBUTED;
-        } else if (event.isActionAndStateCd(CldsEvent.ACTION_DELETE, CldsEvent.ACTION_STATE_SENT)) {
-            status = CldsModel.STATUS_DELETING;
-        } else if (event.isActionAndStateCd(CldsEvent.ACTION_DEPLOY, CldsEvent.ACTION_STATE_COMPLETED)
-            || event.isActionAndStateCd(CldsEvent.ACTION_RESTART, CldsEvent.ACTION_STATE_COMPLETED)
-            || event.isActionAndStateCd(CldsEvent.ACTION_UPDATE, CldsEvent.ACTION_STATE_COMPLETED)
-            || event.isActionAndStateCd(CldsEvent.ACTION_SUBMITPOLICY, CldsEvent.ACTION_STATE_ANY)) {
-            status = CldsModel.STATUS_ACTIVE;
-        } else if (event.isActionAndStateCd(CldsEvent.ACTION_STOP, CldsEvent.ACTION_STATE_COMPLETED)) {
-            status = CldsModel.STATUS_STOPPED;
-        }
-        return status;
-    }
-}
diff --git a/src/main/java/org/onap/clamp/clds/model/status/StatusHandlerImpl.java b/src/main/java/org/onap/clamp/clds/model/status/StatusHandlerImpl.java
deleted file mode 100644 (file)
index b539e90..0000000
+++ /dev/null
@@ -1,27 +0,0 @@
-/*-
- * ============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.status;
-
-public class StatusHandlerImpl implements StatusHandler {
-}
index 1b0cca6..f167916 100644 (file)
@@ -27,10 +27,10 @@ import com.att.eelf.configuration.EELFManager;
 
 import java.util.Date;
 
-import org.onap.clamp.clds.dao.CldsDao;
 import org.onap.clamp.clds.model.CldsHealthCheck;
 import org.onap.clamp.clds.util.LoggingUtils;
 import org.onap.clamp.clds.util.ONAPLogConstants;
+import org.onap.clamp.loop.LoopController;
 import org.slf4j.event.Level;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.http.HttpStatus;
@@ -45,7 +45,7 @@ import org.springframework.stereotype.Component;
 public class CldsHealthcheckService {
 
     @Autowired
-    private CldsDao cldsDao;
+    private LoopController loopController;
 
     protected static final EELFLogger logger = EELFManager.getInstance().getLogger(CldsHealthcheckService.class);
 
@@ -62,7 +62,7 @@ public class CldsHealthcheckService {
         LoggingUtils.setTimeContext(startTime, new Date());
         boolean healthcheckFailed = false;
         try {
-            cldsDao.doHealthCheck();
+            loopController.getLoopNames();
             cldsHealthCheck.setHealthCheckComponent("CLDS-APP");
             cldsHealthCheck.setHealthCheckStatus("UP");
             cldsHealthCheck.setDescription("OK");
@@ -79,11 +79,10 @@ public class CldsHealthcheckService {
         LoggingUtils.setTimeContext(startTime, new Date());
         if (healthcheckFailed) {
             util.exiting(HttpStatus.INTERNAL_SERVER_ERROR.toString(), "Healthcheck failed", Level.INFO,
-                         ONAPLogConstants.ResponseStatus.ERROR);
+                    ONAPLogConstants.ResponseStatus.ERROR);
             return new ResponseEntity<>(cldsHealthCheck, HttpStatus.INTERNAL_SERVER_ERROR);
         } else {
-            util.exiting("200", "Healthcheck failed", Level.INFO,
-                         ONAPLogConstants.ResponseStatus.COMPLETED);
+            util.exiting("200", "Healthcheck failed", Level.INFO, ONAPLogConstants.ResponseStatus.COMPLETED);
             return new ResponseEntity<>(cldsHealthCheck, HttpStatus.OK);
         }
     }
index ea4e097..f5c21c1 100644 (file)
@@ -29,13 +29,9 @@ import java.util.Iterator;
 import java.util.LinkedHashMap;
 import java.util.List;
 import java.util.Map;
-import java.util.Optional;
-import java.util.stream.Collectors;
 
 import org.json.JSONArray;
 import org.json.JSONObject;
-import org.onap.clamp.clds.dao.CldsDao;
-import org.onap.clamp.clds.model.CldsDictionaryItem;
 import org.yaml.snakeyaml.Yaml;
 
 /**
@@ -45,15 +41,10 @@ import org.yaml.snakeyaml.Yaml;
  */
 public class ToscaYamlToJsonConvertor {
 
-    private CldsDao cldsDao;
     private int simpleTypeOrder = 1000;
     private int complexTypeOrder = 10000;
     private int complexSimpleTypeOrder = 1;
 
-    public ToscaYamlToJsonConvertor(CldsDao cldsDao) {
-        this.cldsDao = cldsDao;
-    }
-
     private int incrementSimpleTypeOrder() {
         return simpleTypeOrder++;
     }
@@ -67,24 +58,6 @@ public class ToscaYamlToJsonConvertor {
         return complexTypeOrder + complexSimpleTypeOrder;
     }
 
-    /**
-     * Returns the CldsDao.
-     *
-     * @return the cldsDao
-     */
-    public CldsDao getCldsDao() {
-        return cldsDao;
-    }
-
-    /**
-     * Sets the CldsDao.
-     *
-     * @param cldsDao the cldsDao to set
-     */
-    public void setCldsDao(CldsDao cldsDao) {
-        this.cldsDao = cldsDao;
-    }
-
     /**
      * Parses Tosca YAML string.
      *
@@ -115,7 +88,7 @@ public class ToscaYamlToJsonConvertor {
     // Parse node_type and data_type
     @SuppressWarnings("unchecked")
     private void parseNodeAndDataType(LinkedHashMap<String, Object> map, LinkedHashMap<String, Object> nodeTypes,
-        LinkedHashMap<String, Object> dataNodes) {
+            LinkedHashMap<String, Object> dataNodes) {
         map.entrySet().stream().forEach(n -> {
             if (n.getKey().contains(ToscaSchemaConstants.NODE_TYPES) && n.getValue() instanceof Map) {
                 parseNodeAndDataType((LinkedHashMap<String, Object>) n.getValue(), nodeTypes, dataNodes);
@@ -132,7 +105,7 @@ public class ToscaYamlToJsonConvertor {
 
     @SuppressWarnings("unchecked")
     private void populateJsonEditorObject(LinkedHashMap<String, Object> map, LinkedHashMap<String, Object> nodeTypes,
-        LinkedHashMap<String, Object> dataNodes, JSONObject jsonParentObject, JSONObject jsonTempObject) {
+            LinkedHashMap<String, Object> dataNodes, JSONObject jsonParentObject, JSONObject jsonTempObject) {
 
         Map<String, JSONObject> jsonEntrySchema = new HashMap();
         jsonParentObject.put(JsonEditorSchemaConstants.TYPE, JsonEditorSchemaConstants.TYPE_OBJECT);
@@ -143,49 +116,53 @@ public class ToscaYamlToJsonConvertor {
                         JSONArray rootNodeArray = new JSONArray();
                         if (ntElement.getValue() instanceof Map) {
                             ((LinkedHashMap<String, Object>) ntElement.getValue()).entrySet()
-                                .forEach((ntPropertiesElement) -> {
-                                    boolean isListNode = false;
-                                    parseDescription((LinkedHashMap<String, Object>) ntPropertiesElement.getValue(),
-                                        jsonParentObject);
-                                    LinkedHashMap<String, Object> parentPropertiesMap =
-                                            (LinkedHashMap<String, Object>) ntPropertiesElement.getValue();
-                                    if (parentPropertiesMap.containsKey(ToscaSchemaConstants.TYPE)
-                                        && ((String) parentPropertiesMap.get(ToscaSchemaConstants.TYPE))
-                                            .contains(ToscaSchemaConstants.TYPE_MAP)
-                                        && parentPropertiesMap.containsKey(ToscaSchemaConstants.ENTRY_SCHEMA)) {
-                                        parentPropertiesMap = (LinkedHashMap<String, Object>) parentPropertiesMap
-                                            .get(ToscaSchemaConstants.ENTRY_SCHEMA);
-                                        isListNode = true;
-                                    }
-                                    if (parentPropertiesMap.containsKey(ToscaSchemaConstants.TYPE)
-                                        && ((String) parentPropertiesMap.get(ToscaSchemaConstants.TYPE))
-                                            .contains(ToscaSchemaConstants.POLICY_DATA)) {
-                                        ((LinkedHashMap<String, Object>) dataNodes
-                                            .get(parentPropertiesMap.get(ToscaSchemaConstants.TYPE))).entrySet()
-                                                .stream().forEach(pmap -> {
-                                                    if (pmap.getKey()
-                                                        .equalsIgnoreCase(ToscaSchemaConstants.PROPERTIES)) {
-                                                        parseToscaProperties(ToscaSchemaConstants.POLICY_NODE,
-                                                            (LinkedHashMap<String, Object>) pmap.getValue(),
-                                                            jsonParentObject, rootNodeArray, jsonEntrySchema, dataNodes,
-                                                            incrementSimpleTypeOrder());
-                                                    }
-
-                                                });
-
-                                    }
-                                    if (isListNode) {
-                                        jsonTempObject.put(JsonEditorSchemaConstants.TYPE,
-                                            JsonEditorSchemaConstants.TYPE_ARRAY);
+                                    .forEach((ntPropertiesElement) -> {
+                                        boolean isListNode = false;
                                         parseDescription((LinkedHashMap<String, Object>) ntPropertiesElement.getValue(),
-                                            jsonTempObject);
-                                        jsonTempObject.put(JsonEditorSchemaConstants.ITEMS, jsonParentObject);
-                                        jsonTempObject.put(JsonEditorSchemaConstants.FORMAT,
-                                            JsonEditorSchemaConstants.CUSTOM_KEY_FORMAT_TABS_TOP);
-                                        jsonTempObject.put(JsonEditorSchemaConstants.UNIQUE_ITEMS,
-                                            JsonEditorSchemaConstants.TRUE);
-                                    }
-                                });
+                                                jsonParentObject);
+                                        LinkedHashMap<String, Object> parentPropertiesMap = (LinkedHashMap<String, Object>) ntPropertiesElement
+                                                .getValue();
+                                        if (parentPropertiesMap.containsKey(ToscaSchemaConstants.TYPE)
+                                                && ((String) parentPropertiesMap.get(ToscaSchemaConstants.TYPE))
+                                                        .contains(ToscaSchemaConstants.TYPE_MAP)
+                                                && parentPropertiesMap.containsKey(ToscaSchemaConstants.ENTRY_SCHEMA)) {
+                                            parentPropertiesMap = (LinkedHashMap<String, Object>) parentPropertiesMap
+                                                    .get(ToscaSchemaConstants.ENTRY_SCHEMA);
+                                            isListNode = true;
+                                        }
+                                        if (parentPropertiesMap.containsKey(ToscaSchemaConstants.TYPE)
+                                                && ((String) parentPropertiesMap.get(ToscaSchemaConstants.TYPE))
+                                                        .contains(ToscaSchemaConstants.POLICY_DATA)) {
+                                            ((LinkedHashMap<String, Object>) dataNodes
+                                                    .get(parentPropertiesMap.get(ToscaSchemaConstants.TYPE))).entrySet()
+                                                            .stream().forEach(pmap -> {
+                                                                if (pmap.getKey().equalsIgnoreCase(
+                                                                        ToscaSchemaConstants.PROPERTIES)) {
+                                                                    parseToscaProperties(
+                                                                            ToscaSchemaConstants.POLICY_NODE,
+                                                                            (LinkedHashMap<String, Object>) pmap
+                                                                                    .getValue(),
+                                                                            jsonParentObject, rootNodeArray,
+                                                                            jsonEntrySchema, dataNodes,
+                                                                            incrementSimpleTypeOrder());
+                                                                }
+
+                                                            });
+
+                                        }
+                                        if (isListNode) {
+                                            jsonTempObject.put(JsonEditorSchemaConstants.TYPE,
+                                                    JsonEditorSchemaConstants.TYPE_ARRAY);
+                                            parseDescription(
+                                                    (LinkedHashMap<String, Object>) ntPropertiesElement.getValue(),
+                                                    jsonTempObject);
+                                            jsonTempObject.put(JsonEditorSchemaConstants.ITEMS, jsonParentObject);
+                                            jsonTempObject.put(JsonEditorSchemaConstants.FORMAT,
+                                                    JsonEditorSchemaConstants.CUSTOM_KEY_FORMAT_TABS_TOP);
+                                            jsonTempObject.put(JsonEditorSchemaConstants.UNIQUE_ITEMS,
+                                                    JsonEditorSchemaConstants.TRUE);
+                                        }
+                                    });
                         }
                     }
                 });
@@ -195,8 +172,8 @@ public class ToscaYamlToJsonConvertor {
 
     @SuppressWarnings("unchecked")
     private void parseToscaProperties(String parentKey, LinkedHashMap<String, Object> propertiesMap,
-        JSONObject jsonDataNode, JSONArray array, Map<String, JSONObject> jsonEntrySchema,
-        LinkedHashMap<String, Object> dataNodes, final int order) {
+            JSONObject jsonDataNode, JSONArray array, Map<String, JSONObject> jsonEntrySchema,
+            LinkedHashMap<String, Object> dataNodes, final int order) {
         JSONObject jsonPropertyNode = new JSONObject();
         propertiesMap.entrySet().stream().forEach(p -> {
             // Populate JSON Array for "required" key
@@ -204,12 +181,12 @@ public class ToscaYamlToJsonConvertor {
             if (p.getValue() instanceof Map) {
                 LinkedHashMap<String, Object> nodeMap = (LinkedHashMap<String, Object>) p.getValue();
                 if (nodeMap.containsKey(ToscaSchemaConstants.REQUIRED)
-                    && ((boolean) nodeMap.get(ToscaSchemaConstants.REQUIRED))) {
+                        && ((boolean) nodeMap.get(ToscaSchemaConstants.REQUIRED))) {
                     array.put(p.getKey());
                 }
                 // if(nodeMap.containsKey(ToscaSchemaConstants.CONSTRAINTS))
                 parseToscaChildNodeMap(p.getKey(), nodeMap, jsonPropertyNode, jsonEntrySchema, dataNodes, array,
-                    incrementSimpleTypeOrder());
+                        incrementSimpleTypeOrder());
             }
         });
         jsonDataNode.put(JsonEditorSchemaConstants.REQUIRED, array);
@@ -218,8 +195,8 @@ public class ToscaYamlToJsonConvertor {
 
     @SuppressWarnings("unchecked")
     private void parseToscaPropertiesForType(String parentKey, LinkedHashMap<String, Object> propertiesMap,
-        JSONObject jsonDataNode, JSONArray array, Map<String, JSONObject> jsonEntrySchema,
-        LinkedHashMap<String, Object> dataNodes, boolean isType, int order) {
+            JSONObject jsonDataNode, JSONArray array, Map<String, JSONObject> jsonEntrySchema,
+            LinkedHashMap<String, Object> dataNodes, boolean isType, int order) {
         JSONObject jsonPropertyNode = new JSONObject();
 
         propertiesMap.entrySet().stream().forEach(p -> {
@@ -228,13 +205,14 @@ public class ToscaYamlToJsonConvertor {
             if (p.getValue() instanceof Map) {
                 LinkedHashMap<String, Object> nodeMap = (LinkedHashMap<String, Object>) p.getValue();
                 if (!(parentKey.contains(ToscaSchemaConstants.ENTRY_SCHEMA)
-                    || parentKey.contains(ToscaSchemaConstants.POLICY_NODE))
-                    && nodeMap.containsKey(ToscaSchemaConstants.TYPE)
-                    && (((String) nodeMap.get(ToscaSchemaConstants.TYPE)).contains(ToscaSchemaConstants.POLICY_DATA))) {
+                        || parentKey.contains(ToscaSchemaConstants.POLICY_NODE))
+                        && nodeMap.containsKey(ToscaSchemaConstants.TYPE)
+                        && (((String) nodeMap.get(ToscaSchemaConstants.TYPE))
+                                .contains(ToscaSchemaConstants.POLICY_DATA))) {
                     overWriteArray = true;
                 }
                 if (nodeMap.containsKey(ToscaSchemaConstants.REQUIRED)
-                    && ((boolean) nodeMap.get(ToscaSchemaConstants.REQUIRED))) {
+                        && ((boolean) nodeMap.get(ToscaSchemaConstants.REQUIRED))) {
                     array.put(p.getKey());
                 }
                 parseToscaChildNodeMap(p.getKey(), nodeMap, jsonPropertyNode, jsonEntrySchema, dataNodes, array, order);
@@ -245,8 +223,8 @@ public class ToscaYamlToJsonConvertor {
     }
 
     private void parseToscaChildNodeMap(String childObjectKey, LinkedHashMap<String, Object> childNodeMap,
-        JSONObject jsonPropertyNode, Map<String, JSONObject> jsonEntrySchema, LinkedHashMap<String, Object> dataNodes,
-        JSONArray array, int order) {
+            JSONObject jsonPropertyNode, Map<String, JSONObject> jsonEntrySchema,
+            LinkedHashMap<String, Object> dataNodes, JSONArray array, int order) {
         JSONObject childObject = new JSONObject();
         // JSONArray childArray = new JSONArray();
         parseDescription(childNodeMap, childObject);
@@ -260,11 +238,12 @@ public class ToscaYamlToJsonConvertor {
     }
 
     private void parseEntrySchema(LinkedHashMap<String, Object> childNodeMap, JSONObject childObject,
-        JSONObject jsonPropertyNode, Map<String, JSONObject> jsonEntrySchema, LinkedHashMap<String, Object> dataNodes) {
+            JSONObject jsonPropertyNode, Map<String, JSONObject> jsonEntrySchema,
+            LinkedHashMap<String, Object> dataNodes) {
         if (childNodeMap.get(ToscaSchemaConstants.ENTRY_SCHEMA) != null) {
             if (childNodeMap.get(ToscaSchemaConstants.ENTRY_SCHEMA) instanceof Map) {
                 LinkedHashMap<String, Object> entrySchemaMap = (LinkedHashMap<String, Object>) childNodeMap
-                    .get(ToscaSchemaConstants.ENTRY_SCHEMA);
+                        .get(ToscaSchemaConstants.ENTRY_SCHEMA);
                 entrySchemaMap.entrySet().stream().forEach(entry -> {
                     if (entry.getKey().equalsIgnoreCase(ToscaSchemaConstants.TYPE) && entry.getValue() != null) {
                         String entrySchemaType = (String) entry.getValue();
@@ -274,33 +253,34 @@ public class ToscaYamlToJsonConvertor {
                                 // Already traversed
                                 JSONObject entrySchemaObject = jsonEntrySchema.get(entrySchemaType);
                                 attachEntrySchemaJsonObject(childObject, entrySchemaObject,
-                                    JsonEditorSchemaConstants.TYPE_OBJECT);
+                                        JsonEditorSchemaConstants.TYPE_OBJECT);
                             } else if (dataNodes.containsKey(entrySchemaType)) {
 
                                 JSONObject entrySchemaObject = new JSONObject();
                                 // Need to traverse
                                 ((LinkedHashMap<String, Object>) dataNodes.get(entrySchemaType)).entrySet().stream()
-                                    .forEach(pmap -> {
-                                        if (pmap.getKey().equalsIgnoreCase(ToscaSchemaConstants.PROPERTIES)) {
-                                            parseToscaProperties(ToscaSchemaConstants.ENTRY_SCHEMA,
-                                                (LinkedHashMap<String, Object>) pmap.getValue(), entrySchemaObject,
-                                                array, jsonEntrySchema, dataNodes, incrementComplexTypeOrder());
-                                            jsonEntrySchema.put(entrySchemaType, entrySchemaObject);
-                                            dataNodes.remove(entrySchemaType);
-                                            attachEntrySchemaJsonObject(childObject, entrySchemaObject,
-                                                JsonEditorSchemaConstants.TYPE_OBJECT);
-                                        }
-
-                                    });
+                                        .forEach(pmap -> {
+                                            if (pmap.getKey().equalsIgnoreCase(ToscaSchemaConstants.PROPERTIES)) {
+                                                parseToscaProperties(ToscaSchemaConstants.ENTRY_SCHEMA,
+                                                        (LinkedHashMap<String, Object>) pmap.getValue(),
+                                                        entrySchemaObject, array, jsonEntrySchema, dataNodes,
+                                                        incrementComplexTypeOrder());
+                                                jsonEntrySchema.put(entrySchemaType, entrySchemaObject);
+                                                dataNodes.remove(entrySchemaType);
+                                                attachEntrySchemaJsonObject(childObject, entrySchemaObject,
+                                                        JsonEditorSchemaConstants.TYPE_OBJECT);
+                                            }
+
+                                        });
                             }
                         } else if (entrySchemaType.equalsIgnoreCase(ToscaSchemaConstants.TYPE_STRING)
-                            || entrySchemaType.equalsIgnoreCase(ToscaSchemaConstants.TYPE_INTEGER)
-                            || entrySchemaType.equalsIgnoreCase(ToscaSchemaConstants.TYPE_FLOAT)) {
+                                || entrySchemaType.equalsIgnoreCase(ToscaSchemaConstants.TYPE_INTEGER)
+                                || entrySchemaType.equalsIgnoreCase(ToscaSchemaConstants.TYPE_FLOAT)) {
                             JSONObject entrySchemaObject = new JSONObject();
                             parseConstraints(entrySchemaMap, entrySchemaObject);
                             String jsontype = JsonEditorSchemaConstants.TYPE_STRING;
                             if (entrySchemaType.equalsIgnoreCase(ToscaSchemaConstants.TYPE_INTEGER)
-                                || entrySchemaType.equalsIgnoreCase(ToscaSchemaConstants.TYPE_FLOAT)) {
+                                    || entrySchemaType.equalsIgnoreCase(ToscaSchemaConstants.TYPE_FLOAT)) {
                                 jsontype = JsonEditorSchemaConstants.TYPE_INTEGER;
                             }
                             if (childNodeMap.get(ToscaSchemaConstants.TYPE) != null) {
@@ -310,7 +290,7 @@ public class ToscaYamlToJsonConvertor {
                                     if (typeValue.equalsIgnoreCase(ToscaSchemaConstants.TYPE_LIST)) {
                                         // Custom key for JSON Editor and UI rendering
                                         childObject.put(JsonEditorSchemaConstants.CUSTOM_KEY_FORMAT,
-                                            JsonEditorSchemaConstants.FORMAT_SELECT);
+                                                JsonEditorSchemaConstants.FORMAT_SELECT);
                                         // childObject.put(JsonEditorSchemaConstants.UNIQUE_ITEMS,
                                         // JsonEditorSchemaConstants.TRUE);
                                     }
@@ -352,7 +332,8 @@ public class ToscaYamlToJsonConvertor {
     }
 
     private void parseTypes(String childObjectKey, LinkedHashMap<String, Object> childNodeMap, JSONObject childObject,
-        Map<String, JSONObject> jsonEntrySchema, LinkedHashMap<String, Object> dataNodes, JSONArray array, int order) {
+            Map<String, JSONObject> jsonEntrySchema, LinkedHashMap<String, Object> dataNodes, JSONArray array,
+            int order) {
         if (childNodeMap.get(ToscaSchemaConstants.TYPE) != null) {
             // Only known value of type is String for now
             if (childNodeMap.get(ToscaSchemaConstants.TYPE) instanceof String) {
@@ -367,7 +348,7 @@ public class ToscaYamlToJsonConvertor {
                     childObject.put(JsonEditorSchemaConstants.TYPE, JsonEditorSchemaConstants.TYPE_ARRAY);
                     // Custom key for JSON Editor and UI rendering
                     childObject.put(JsonEditorSchemaConstants.CUSTOM_KEY_FORMAT,
-                        JsonEditorSchemaConstants.CUSTOM_KEY_FORMAT_TABS_TOP);
+                            JsonEditorSchemaConstants.CUSTOM_KEY_FORMAT_TABS_TOP);
                     childObject.put(JsonEditorSchemaConstants.UNIQUE_ITEMS, JsonEditorSchemaConstants.TRUE);
                 } else if (typeValue.equalsIgnoreCase(ToscaSchemaConstants.TYPE_MAP)) {
                     childObject.put(JsonEditorSchemaConstants.TYPE, JsonEditorSchemaConstants.TYPE_OBJECT);
@@ -388,10 +369,10 @@ public class ToscaYamlToJsonConvertor {
                                 ((LinkedHashMap<String, Object>) pmap.getValue()).entrySet().stream().forEach(p -> {
                                     if (p.getValue() instanceof Map) {
                                         LinkedHashMap<String, Object> childNodeMap2 = (LinkedHashMap<String, Object>) p
-                                            .getValue();
+                                                .getValue();
                                         if (childNodeMap2.containsKey(ToscaSchemaConstants.TYPE)
-                                            && (((String) childNodeMap2.get(ToscaSchemaConstants.TYPE))
-                                                .contains(ToscaSchemaConstants.POLICY_DATA))) {
+                                                && (((String) childNodeMap2.get(ToscaSchemaConstants.TYPE))
+                                                        .contains(ToscaSchemaConstants.POLICY_DATA))) {
                                         }
                                     }
                                 });
@@ -400,8 +381,8 @@ public class ToscaYamlToJsonConvertor {
                         ((LinkedHashMap<String, Object>) dataNodes.get(typeValue)).entrySet().stream().forEach(pmap -> {
                             if (pmap.getKey().equalsIgnoreCase(ToscaSchemaConstants.PROPERTIES)) {
                                 parseToscaPropertiesForType(childObjectKey,
-                                    (LinkedHashMap<String, Object>) pmap.getValue(), entrySchemaObject, childArray,
-                                    jsonEntrySchema, dataNodes, true, incrementComplexSimpleTypeOrder());
+                                        (LinkedHashMap<String, Object>) pmap.getValue(), entrySchemaObject, childArray,
+                                        jsonEntrySchema, dataNodes, true, incrementComplexSimpleTypeOrder());
                                 jsonEntrySchema.put(typeValue, entrySchemaObject);
                                 dataNodes.remove(typeValue);
                                 attachTypeJsonObject(childObject, entrySchemaObject);
@@ -420,32 +401,32 @@ public class ToscaYamlToJsonConvertor {
 
     private void parseConstraints(LinkedHashMap<String, Object> childNodeMap, JSONObject childObject) {
         if (childNodeMap.containsKey(ToscaSchemaConstants.CONSTRAINTS)
-            && childNodeMap.get(ToscaSchemaConstants.CONSTRAINTS) != null) {
+                && childNodeMap.get(ToscaSchemaConstants.CONSTRAINTS) != null) {
             List<LinkedHashMap<String, Object>> constraintsList = (List<LinkedHashMap<String, Object>>) childNodeMap
-                .get(ToscaSchemaConstants.CONSTRAINTS);
+                    .get(ToscaSchemaConstants.CONSTRAINTS);
             constraintsList.stream().forEach(c -> {
                 if (c instanceof Map) {
                     c.entrySet().stream().forEach(constraint -> {
                         if (constraint.getKey().equalsIgnoreCase(ToscaSchemaConstants.MIN_LENGTH)
-                            || constraint.getKey().equalsIgnoreCase(ToscaSchemaConstants.GREATER_OR_EQUAL)) {
+                                || constraint.getKey().equalsIgnoreCase(ToscaSchemaConstants.GREATER_OR_EQUAL)) {
                             // For String min_lenghth is minimum length whereas for number, it will be
                             // minimum or greater than to the defined value
                             if (childNodeMap.containsKey(ToscaSchemaConstants.TYPE)
-                                && (childNodeMap.get(ToscaSchemaConstants.TYPE) instanceof String)
-                                && ((String) childNodeMap.get(ToscaSchemaConstants.TYPE))
-                                    .equalsIgnoreCase(ToscaSchemaConstants.TYPE_STRING)) {
+                                    && (childNodeMap.get(ToscaSchemaConstants.TYPE) instanceof String)
+                                    && ((String) childNodeMap.get(ToscaSchemaConstants.TYPE))
+                                            .equalsIgnoreCase(ToscaSchemaConstants.TYPE_STRING)) {
                                 childObject.put(JsonEditorSchemaConstants.MIN_LENGTH, constraint.getValue());
                             } else {
                                 childObject.put(JsonEditorSchemaConstants.MINIMUM, constraint.getValue());
                             }
                         } else if (constraint.getKey().equalsIgnoreCase(ToscaSchemaConstants.MAX_LENGTH)
-                            || constraint.getKey().equalsIgnoreCase(ToscaSchemaConstants.LESS_OR_EQUAL)) {
+                                || constraint.getKey().equalsIgnoreCase(ToscaSchemaConstants.LESS_OR_EQUAL)) {
                             // For String max_lenghth is maximum length whereas for number, it will be
                             // maximum or less than the defined value
                             if (childNodeMap.containsKey(ToscaSchemaConstants.TYPE)
-                                && (childNodeMap.get(ToscaSchemaConstants.TYPE) instanceof String)
-                                && ((String) childNodeMap.get(ToscaSchemaConstants.TYPE))
-                                    .equalsIgnoreCase(ToscaSchemaConstants.TYPE_STRING)) {
+                                    && (childNodeMap.get(ToscaSchemaConstants.TYPE) instanceof String)
+                                    && ((String) childNodeMap.get(ToscaSchemaConstants.TYPE))
+                                            .equalsIgnoreCase(ToscaSchemaConstants.TYPE_STRING)) {
                                 childObject.put(JsonEditorSchemaConstants.MAX_LENGTH, constraint.getValue());
                             } else {
                                 childObject.put(JsonEditorSchemaConstants.MAXIMUM, constraint.getValue());
@@ -457,18 +438,18 @@ public class ToscaYamlToJsonConvertor {
                         } else if (constraint.getKey().equalsIgnoreCase(ToscaSchemaConstants.IN_RANGE)) {
                             if (constraint.getValue() instanceof ArrayList<?>) {
                                 if (childNodeMap.containsKey(ToscaSchemaConstants.TYPE)
-                                    && (childNodeMap.get(ToscaSchemaConstants.TYPE) instanceof String)
-                                    && ((String) childNodeMap.get(ToscaSchemaConstants.TYPE))
-                                        .equalsIgnoreCase(ToscaSchemaConstants.TYPE_STRING)) {
+                                        && (childNodeMap.get(ToscaSchemaConstants.TYPE) instanceof String)
+                                        && ((String) childNodeMap.get(ToscaSchemaConstants.TYPE))
+                                                .equalsIgnoreCase(ToscaSchemaConstants.TYPE_STRING)) {
                                     childObject.put(JsonEditorSchemaConstants.MIN_LENGTH,
-                                        ((ArrayList) constraint.getValue()).get(0));
+                                            ((ArrayList) constraint.getValue()).get(0));
                                     childObject.put(JsonEditorSchemaConstants.MAX_LENGTH,
-                                        ((ArrayList) constraint.getValue()).get(1));
+                                            ((ArrayList) constraint.getValue()).get(1));
                                 } else {
                                     childObject.put(JsonEditorSchemaConstants.MINIMUM,
-                                        ((ArrayList) constraint.getValue()).get(0));
+                                            ((ArrayList) constraint.getValue()).get(0));
                                     childObject.put(JsonEditorSchemaConstants.MAXIMUM,
-                                        ((ArrayList) constraint.getValue()).get(1));
+                                            ((ArrayList) constraint.getValue()).get(1));
                                 }
 
                             }
@@ -477,8 +458,8 @@ public class ToscaYamlToJsonConvertor {
 
                             if (constraint.getValue() instanceof ArrayList<?>) {
                                 boolean processDictionary = ((ArrayList<?>) constraint.getValue()).stream()
-                                    .anyMatch(value -> (value instanceof String
-                                        && ((String) value).contains(ToscaSchemaConstants.DICTIONARY)));
+                                        .anyMatch(value -> (value instanceof String
+                                                && ((String) value).contains(ToscaSchemaConstants.DICTIONARY)));
                                 if (!processDictionary) {
                                     ((ArrayList<?>) constraint.getValue()).stream().forEach(value -> {
                                         validValuesArray.put(value);
@@ -487,7 +468,7 @@ public class ToscaYamlToJsonConvertor {
                                 } else {
                                     ((ArrayList<?>) constraint.getValue()).stream().forEach(value -> {
                                         if ((value instanceof String
-                                            && ((String) value).contains(ToscaSchemaConstants.DICTIONARY))) {
+                                                && ((String) value).contains(ToscaSchemaConstants.DICTIONARY))) {
                                             processDictionaryElements(childObject, (String) value);
                                         }
 
@@ -505,77 +486,63 @@ public class ToscaYamlToJsonConvertor {
 
     private void processDictionaryElements(JSONObject childObject, String dictionaryReference) {
 
-        if (dictionaryReference.contains("#")) {
-            String[] dictionaryKeyArray = dictionaryReference
-                .substring(dictionaryReference.indexOf(ToscaSchemaConstants.DICTIONARY) + 11,
-                    dictionaryReference.length())
-                .split("#");
-            // We support only one # as of now.
-            List<CldsDictionaryItem> cldsDictionaryElements = null;
-            List<CldsDictionaryItem> subDictionaryElements = null;
-            if (dictionaryKeyArray != null && dictionaryKeyArray.length == 2) {
-                cldsDictionaryElements = getCldsDao().getDictionaryElements(dictionaryKeyArray[0], null, null);
-                subDictionaryElements = getCldsDao().getDictionaryElements(dictionaryKeyArray[1], null, null);
-
-                if (cldsDictionaryElements != null) {
-                    List<String> subCldsDictionaryNames = subDictionaryElements.stream()
-                        .map(CldsDictionaryItem::getDictElementShortName).collect(Collectors.toList());
-                    JSONArray jsonArray = new JSONArray();
-
-                    Optional.ofNullable(cldsDictionaryElements).get().stream().forEach(c -> {
-                        JSONObject jsonObject = new JSONObject();
-                        jsonObject.put(JsonEditorSchemaConstants.TYPE, getJsonType(c.getDictElementType()));
-                        if (c.getDictElementType() != null
-                            && c.getDictElementType().equalsIgnoreCase(ToscaSchemaConstants.TYPE_STRING)) {
-                            jsonObject.put(JsonEditorSchemaConstants.MIN_LENGTH, 1);
-                        }
-                        jsonObject.put(JsonEditorSchemaConstants.ID, c.getDictElementName());
-                        jsonObject.put(JsonEditorSchemaConstants.LABEL, c.getDictElementShortName());
-                        jsonObject.put(JsonEditorSchemaConstants.OPERATORS, subCldsDictionaryNames);
-                        jsonArray.put(jsonObject);
-                    });
-                    ;
-                    JSONObject filterObject = new JSONObject();
-                    filterObject.put(JsonEditorSchemaConstants.FILTERS, jsonArray);
-
-                    childObject.put(JsonEditorSchemaConstants.TYPE, JsonEditorSchemaConstants.TYPE_QBLDR);
-                    // TO invoke validation on such parameters
-                    childObject.put(JsonEditorSchemaConstants.MIN_LENGTH, 1);
-                    childObject.put(JsonEditorSchemaConstants.QSSCHEMA, filterObject);
-
-                }
-            }
-        } else {
-            String dictionaryKey = dictionaryReference.substring(
-                dictionaryReference.indexOf(ToscaSchemaConstants.DICTIONARY) + 11, dictionaryReference.length());
-            if (dictionaryKey != null) {
-                List<CldsDictionaryItem> cldsDictionaryElements = getCldsDao().getDictionaryElements(dictionaryKey,
-                    null, null);
-                if (cldsDictionaryElements != null) {
-                    List<String> cldsDictionaryNames = new ArrayList<>();
-                    List<String> cldsDictionaryFullNames = new ArrayList<>();
-                    cldsDictionaryElements.stream().forEach(c -> {
-                        // Json type will be translated before Policy creation
-                        if (c.getDictElementType() != null && !c.getDictElementType().equalsIgnoreCase("json")) {
-                            cldsDictionaryFullNames.add(c.getDictElementName());
-                        }
-                        cldsDictionaryNames.add(c.getDictElementShortName());
-                    });
-
-                    if (cldsDictionaryFullNames.size() > 0) {
-                        childObject.put(JsonEditorSchemaConstants.ENUM, cldsDictionaryFullNames);
-                        // Add Enum titles for generated translated values during JSON instance
-                        // generation
-                        JSONObject enumTitles = new JSONObject();
-                        enumTitles.put(JsonEditorSchemaConstants.ENUM_TITLES, cldsDictionaryNames);
-                        childObject.put(JsonEditorSchemaConstants.OPTIONS, enumTitles);
-                    } else {
-                        childObject.put(JsonEditorSchemaConstants.ENUM, cldsDictionaryNames);
-                    }
-
-                }
-            }
-        }
+        /*
+         * if (dictionaryReference.contains("#")) { String[] dictionaryKeyArray =
+         * dictionaryReference
+         * .substring(dictionaryReference.indexOf(ToscaSchemaConstants.DICTIONARY) + 11,
+         * dictionaryReference.length()) .split("#"); // We support only one # as of
+         * now. List<CldsDictionaryItem> cldsDictionaryElements = null;
+         * List<CldsDictionaryItem> subDictionaryElements = null; if (dictionaryKeyArray
+         * != null && dictionaryKeyArray.length == 2) { cldsDictionaryElements =
+         * getCldsDao().getDictionaryElements(dictionaryKeyArray[0], null, null);
+         * subDictionaryElements =
+         * getCldsDao().getDictionaryElements(dictionaryKeyArray[1], null, null);
+         * 
+         * if (cldsDictionaryElements != null) { List<String> subCldsDictionaryNames =
+         * subDictionaryElements.stream()
+         * .map(CldsDictionaryItem::getDictElementShortName).collect(Collectors.toList()
+         * ); JSONArray jsonArray = new JSONArray();
+         * 
+         * Optional.ofNullable(cldsDictionaryElements).get().stream().forEach(c -> {
+         * JSONObject jsonObject = new JSONObject();
+         * jsonObject.put(JsonEditorSchemaConstants.TYPE,
+         * getJsonType(c.getDictElementType())); if (c.getDictElementType() != null &&
+         * c.getDictElementType().equalsIgnoreCase(ToscaSchemaConstants.TYPE_STRING)) {
+         * jsonObject.put(JsonEditorSchemaConstants.MIN_LENGTH, 1); }
+         * jsonObject.put(JsonEditorSchemaConstants.ID, c.getDictElementName());
+         * jsonObject.put(JsonEditorSchemaConstants.LABEL, c.getDictElementShortName());
+         * jsonObject.put(JsonEditorSchemaConstants.OPERATORS, subCldsDictionaryNames);
+         * jsonArray.put(jsonObject); }); ; JSONObject filterObject = new JSONObject();
+         * filterObject.put(JsonEditorSchemaConstants.FILTERS, jsonArray);
+         * 
+         * childObject.put(JsonEditorSchemaConstants.TYPE,
+         * JsonEditorSchemaConstants.TYPE_QBLDR); // TO invoke validation on such
+         * parameters childObject.put(JsonEditorSchemaConstants.MIN_LENGTH, 1);
+         * childObject.put(JsonEditorSchemaConstants.QSSCHEMA, filterObject);
+         * 
+         * } } } else { String dictionaryKey = dictionaryReference.substring(
+         * dictionaryReference.indexOf(ToscaSchemaConstants.DICTIONARY) + 11,
+         * dictionaryReference.length()); if (dictionaryKey != null) {
+         * List<CldsDictionaryItem> cldsDictionaryElements =
+         * getCldsDao().getDictionaryElements(dictionaryKey, null, null); if
+         * (cldsDictionaryElements != null) { List<String> cldsDictionaryNames = new
+         * ArrayList<>(); List<String> cldsDictionaryFullNames = new ArrayList<>();
+         * cldsDictionaryElements.stream().forEach(c -> { // Json type will be
+         * translated before Policy creation if (c.getDictElementType() != null &&
+         * !c.getDictElementType().equalsIgnoreCase("json")) {
+         * cldsDictionaryFullNames.add(c.getDictElementName()); }
+         * cldsDictionaryNames.add(c.getDictElementShortName()); });
+         * 
+         * if (cldsDictionaryFullNames.size() > 0) {
+         * childObject.put(JsonEditorSchemaConstants.ENUM, cldsDictionaryFullNames); //
+         * Add Enum titles for generated translated values during JSON instance //
+         * generation JSONObject enumTitles = new JSONObject();
+         * enumTitles.put(JsonEditorSchemaConstants.ENUM_TITLES, cldsDictionaryNames);
+         * childObject.put(JsonEditorSchemaConstants.OPTIONS, enumTitles); } else {
+         * childObject.put(JsonEditorSchemaConstants.ENUM, cldsDictionaryNames); }
+         * 
+         * } } }
+         */
     }
 
     private String getJsonType(String toscaType) {
diff --git a/src/main/java/org/onap/clamp/clds/transform/XslTransformer.java b/src/main/java/org/onap/clamp/clds/transform/XslTransformer.java
deleted file mode 100644 (file)
index 85b3f5c..0000000
+++ /dev/null
@@ -1,75 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * ONAP CLAMP
- * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights
- *                             reserved.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License"); 
- * you may not use this file except in compliance with the License. 
- * You may obtain a copy of the License at
- * 
- * http://www.apache.org/licenses/LICENSE-2.0
- * 
- * Unless required by applicable law or agreed to in writing, software 
- * distributed under the License is distributed on an "AS IS" BASIS, 
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
- * See the License for the specific language governing permissions and 
- * limitations under the License.
- * ============LICENSE_END============================================
- * ===================================================================
- * 
- */
-
-package org.onap.clamp.clds.transform;
-
-import com.sun.org.apache.xalan.internal.xsltc.trax.TransformerFactoryImpl;
-import java.io.StringReader;
-import java.io.StringWriter;
-
-import javax.xml.XMLConstants;
-import javax.xml.transform.Templates;
-import javax.xml.transform.Transformer;
-import javax.xml.transform.TransformerConfigurationException;
-import javax.xml.transform.TransformerException;
-import javax.xml.transform.TransformerFactory;
-import javax.xml.transform.stream.StreamResult;
-import javax.xml.transform.stream.StreamSource;
-
-import org.onap.clamp.clds.util.ResourceFileUtil;
-
-/**
- * XSL Transformer.
- */
-public class XslTransformer {
-
-    private Templates templates;
-
-    /**
-     * Sets Xsl Resource name.
-     *
-     * @param xslResourceName xsl resource name
-     * @throws TransformerConfigurationException exception if there is configuration error
-     */
-    public void setXslResourceName(String xslResourceName) throws TransformerConfigurationException {
-        TransformerFactory tfactory = new TransformerFactoryImpl();
-        tfactory.setAttribute(XMLConstants.ACCESS_EXTERNAL_DTD, "");
-        tfactory.setFeature(XMLConstants.FEATURE_SECURE_PROCESSING, true);
-        templates = tfactory.newTemplates(new StreamSource(ResourceFileUtil.getResourceAsStream(xslResourceName)));
-    }
-
-    /**
-     * Given xml input, return the transformed result.
-     *
-     * @param xml xml string
-     * @throws TransformerException exception during transformation
-     */
-    public String doXslTransformToString(String xml) throws TransformerException {
-        StringWriter output = new StringWriter(4096);
-
-        Transformer transformer = templates.newTransformer();
-        transformer.transform(new StreamSource(new StringReader(xml)), new StreamResult(output));
-        return output.toString();
-    }
-
-}
index 6182598..cc875d6 100644 (file)
@@ -41,7 +41,6 @@ import java.util.Spliterators;
 import java.util.stream.Collectors;
 import java.util.stream.StreamSupport;
 
-import org.onap.clamp.clds.model.properties.AbstractModelElement;
 import org.onap.clamp.clds.service.SecureServicePermission;
 import org.onap.clamp.clds.service.SecureServicePermissionDeserializer;
 import org.onap.clamp.dao.model.gson.converter.InstantDeserializer;
@@ -52,17 +51,17 @@ import org.onap.clamp.dao.model.gson.converter.InstantSerializer;
  */
 public class JsonUtils {
 
-    protected static final EELFLogger logger = EELFManager.getInstance().getLogger(AbstractModelElement.class);
+    protected static final EELFLogger logger = EELFManager.getInstance().getLogger(JsonUtils.class);
     private static final String LOG_ELEMENT_NOT_FOUND = "Value '{}' for key 'name' not found in JSON";
     private static final String LOG_ELEMENT_NOT_FOUND_IN_JSON = "Value '{}' for key 'name' not found in JSON {}";
 
     public static final Gson GSON = new GsonBuilder()
-        .registerTypeAdapter(SecureServicePermission.class, new SecureServicePermissionDeserializer()).create();
+            .registerTypeAdapter(SecureServicePermission.class, new SecureServicePermissionDeserializer()).create();
 
     public static final Gson GSON_JPA_MODEL = new GsonBuilder()
-        .registerTypeAdapter(Instant.class, new InstantSerializer())
-        .registerTypeAdapter(Instant.class, new InstantDeserializer()).setPrettyPrinting()
-        .excludeFieldsWithoutExposeAnnotation().create();
+            .registerTypeAdapter(Instant.class, new InstantSerializer())
+            .registerTypeAdapter(Instant.class, new InstantDeserializer()).setPrettyPrinting()
+            .excludeFieldsWithoutExposeAnnotation().create();
 
     private JsonUtils() {
     }
@@ -73,7 +72,7 @@ public class JsonUtils {
      */
     public static String getStringValueByName(JsonElement jsonElement, String name) {
         String value = extractJsonValueFromElement(jsonElement, name).map(JsonUtils::extractStringValueFromElement)
-            .orElse(null);
+                .orElse(null);
         if (value == null) {
             if (logger.isDebugEnabled()) {
                 logger.debug(LOG_ELEMENT_NOT_FOUND_IN_JSON, name, jsonElement.toString());
@@ -90,7 +89,7 @@ public class JsonUtils {
      */
     public static List<String> getStringValuesByName(JsonElement jsonElement, String name) {
         List<String> values = extractJsonValueFromElement(jsonElement, name)
-            .map(JsonUtils::extractStringValuesFromElement).orElse(new ArrayList<>());
+                .map(JsonUtils::extractStringValuesFromElement).orElse(new ArrayList<>());
         if (values.isEmpty()) {
             if (logger.isDebugEnabled()) {
                 logger.debug(LOG_ELEMENT_NOT_FOUND_IN_JSON, name, jsonElement.toString());
@@ -116,7 +115,7 @@ public class JsonUtils {
      */
     public static JsonObject getJsonObjectByName(JsonElement jsonElement, String name) {
         JsonObject jsonObject = extractJsonValueFromElement(jsonElement, name).map(JsonElement::getAsJsonObject)
-            .orElse(null);
+                .orElse(null);
         if (jsonObject == null) {
             logger.warn(LOG_ELEMENT_NOT_FOUND, name);
         } else {
@@ -147,7 +146,7 @@ public class JsonUtils {
 
     private static boolean hasMatchingParameterName(String name, JsonElement element) {
         return element.isJsonObject() && element.getAsJsonObject().has("name")
-            && name.equals(element.getAsJsonObject().get("name").getAsString());
+                && name.equals(element.getAsJsonObject().get("name").getAsString());
     }
 
     private static String extractStringValueFromElement(JsonElement element) {
@@ -163,10 +162,10 @@ public class JsonUtils {
     private static List<String> extractStringValuesFromElement(JsonElement element) {
         if (element.isJsonArray()) {
             return StreamSupport
-                .stream(Spliterators.spliteratorUnknownSize(element.getAsJsonArray().iterator(), Spliterator.ORDERED),
-                    false)
-                .filter(JsonElement::isJsonPrimitive).map(JsonElement::getAsJsonPrimitive)
-                .filter(JsonPrimitive::isString).map(JsonPrimitive::getAsString).collect(Collectors.toList());
+                    .stream(Spliterators.spliteratorUnknownSize(element.getAsJsonArray().iterator(),
+                            Spliterator.ORDERED), false)
+                    .filter(JsonElement::isJsonPrimitive).map(JsonElement::getAsJsonPrimitive)
+                    .filter(JsonPrimitive::isString).map(JsonPrimitive::getAsString).collect(Collectors.toList());
         } else {
             String value = extractStringValueFromElement(element);
             return Lists.newArrayList(value);
index d8d15a5..b1cea34 100644 (file)
@@ -104,25 +104,20 @@ public class MicroServicePolicy implements Serializable, Policy {
      * The constructor that create the json representation from the policyTosca
      * using the ToscaYamlToJsonConvertor.
      *
-     * @param name
-     *        The name of the MicroService
-     * @param modelType
-     *        The model type of the MicroService
-     * @param policyTosca
-     *        The policy Tosca of the MicroService
-     * @param shared
-     *        The flag indicate whether the MicroService is shared
-     * @param usedByLoops
-     *        The list of loops that uses this MicroService
+     * @param name        The name of the MicroService
+     * @param modelType   The model type of the MicroService
+     * @param policyTosca The policy Tosca of the MicroService
+     * @param shared      The flag indicate whether the MicroService is shared
+     * @param usedByLoops The list of loops that uses this MicroService
      */
     public MicroServicePolicy(String name, String modelType, String policyTosca, Boolean shared,
-        Set<Loop> usedByLoops) {
+            Set<Loop> usedByLoops) {
         this.name = name;
         this.modelType = modelType;
         this.policyTosca = policyTosca;
         this.shared = shared;
         this.jsonRepresentation = JsonUtils.GSON_JPA_MODEL
-            .fromJson(new ToscaYamlToJsonConvertor(null).parseToscaYaml(policyTosca), JsonObject.class);
+                .fromJson(new ToscaYamlToJsonConvertor().parseToscaYaml(policyTosca), JsonObject.class);
         this.usedByLoops = usedByLoops;
     }
 
@@ -136,21 +131,16 @@ public class MicroServicePolicy implements Serializable, Policy {
      * The constructor that does not make use of ToscaYamlToJsonConvertor but take
      * the jsonRepresentation instead.
      *
-     * @param name
-     *        The name of the MicroService
-     * @param modelType
-     *        The model type of the MicroService
-     * @param policyTosca
-     *        The policy Tosca of the MicroService
-     * @param shared
-     *        The flag indicate whether the MicroService is shared
-     * @param jsonRepresentation
-     *        The UI representation in json format
-     * @param usedByLoops
-     *        The list of loops that uses this MicroService
+     * @param name               The name of the MicroService
+     * @param modelType          The model type of the MicroService
+     * @param policyTosca        The policy Tosca of the MicroService
+     * @param shared             The flag indicate whether the MicroService is
+     *                           shared
+     * @param jsonRepresentation The UI representation in json format
+     * @param usedByLoops        The list of loops that uses this MicroService
      */
     public MicroServicePolicy(String name, String modelType, String policyTosca, Boolean shared,
-        JsonObject jsonRepresentation, Set<Loop> usedByLoops) {
+            JsonObject jsonRepresentation, Set<Loop> usedByLoops) {
         this.name = name;
         this.modelType = modelType;
         this.policyTosca = policyTosca;
@@ -245,7 +235,7 @@ public class MicroServicePolicy implements Serializable, Policy {
 
     private String getMicroServicePropertyNameFromTosca(JsonObject object) {
         return object.getAsJsonObject("policy_types").getAsJsonObject(this.modelType).getAsJsonObject("properties")
-            .keySet().toArray(new String[1])[0];
+                .keySet().toArray(new String[1])[0];
     }
 
     @Override
diff --git a/src/test/java/org/onap/clamp/clds/client/CldsEventDelegateTest.java b/src/test/java/org/onap/clamp/clds/client/CldsEventDelegateTest.java
deleted file mode 100644 (file)
index 3b5a9ee..0000000
+++ /dev/null
@@ -1,83 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * ONAP CLAMP
- * ================================================================================
- * Copyright (C) 2019 Samsung. 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.client;
-
-import static org.mockito.Matchers.any;
-import static org.mockito.Matchers.eq;
-import static org.mockito.Mockito.never;
-import static org.mockito.Mockito.verify;
-import static org.mockito.Mockito.when;
-
-import org.apache.camel.Exchange;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.mockito.InjectMocks;
-import org.mockito.Mock;
-import org.mockito.runners.MockitoJUnitRunner;
-import org.onap.clamp.clds.dao.CldsDao;
-
-@RunWith(MockitoJUnitRunner.class)
-public class CldsEventDelegateTest {
-
-    private static final String CONTROL_NAME_KEY = "controlName";
-    private static final String TEST_KEY = "isTest";
-    private static final String INSERT_TEST_EVENT_KEY = "isInsertTestEvent";
-    private static final String PREFIX = "abcdef-";
-    private static final String UUID = "ABCDEFGHIJKLMNOPQRSTUVWXYZ-123456789";
-
-    @Mock
-    private Exchange exchange;
-
-    @Mock
-    private CldsDao cldsDao;
-
-    @InjectMocks
-    private CldsEventDelegate cldsEventDelegate;
-
-    @Test
-    public void shouldExecuteSuccessfully() {
-        // given
-        when(exchange.getProperty(eq(CONTROL_NAME_KEY))).thenReturn(PREFIX + UUID);
-        when(exchange.getProperty(eq(TEST_KEY))).thenReturn(false);
-        when(exchange.getProperty(eq(INSERT_TEST_EVENT_KEY))).thenReturn(false);
-
-        // when
-        cldsEventDelegate.addEvent(exchange, null);
-
-        // then
-        verify(cldsDao).insEvent(eq(null), eq(PREFIX), eq(UUID), any());
-    }
-
-    @Test
-    public void shouldExecuteWithoutInsertingEventIntoDatabase() {
-        // given
-        when(exchange.getProperty(eq(TEST_KEY))).thenReturn(true);
-        when(exchange.getProperty(eq(INSERT_TEST_EVENT_KEY))).thenReturn(false);
-
-        // when
-        cldsEventDelegate.addEvent(exchange, null);
-
-        // then
-        verify(cldsDao, never()).insEvent(any(), any(), any(), any());
-    }
-}
\ No newline at end of file
diff --git a/src/test/java/org/onap/clamp/clds/client/DcaeDispatcherServicesTest.java b/src/test/java/org/onap/clamp/clds/client/DcaeDispatcherServicesTest.java
deleted file mode 100644 (file)
index e6c634c..0000000
+++ /dev/null
@@ -1,157 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * ONAP CLAMP
- * ================================================================================
- * Copyright (C) 2018 Nokia Intellectual Property. All rights
- *                             reserved.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END============================================
- * ===================================================================
- *
- */
-
-package org.onap.clamp.clds.client;
-
-import com.google.common.collect.ImmutableMap;
-import com.google.gson.JsonObject;
-import java.io.IOException;
-import org.assertj.core.api.Assertions;
-import org.junit.Before;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.mockito.InjectMocks;
-import org.mockito.Matchers;
-import org.mockito.Mock;
-import org.mockito.Mockito;
-import org.mockito.runners.MockitoJUnitRunner;
-import org.onap.clamp.clds.config.ClampProperties;
-import org.onap.clamp.util.HttpConnectionManager;
-
-
-
-@RunWith(MockitoJUnitRunner.class)
-public class DcaeDispatcherServicesTest {
-
-    private static final String DEPLOYMENT_STATUS_URL = "http://portal.api.simpledemo.onap.org:30297/dcae-deployments/"
-            + "closedLoop_c9c8b281-6fbd-4702-ba13-affa90411152_deploymentId/"
-            + "operation/a97b46f6-d77c-42a1-9449-d5ae71e8f688";
-    private static final String DCAE_URL = "dcae_url";
-    private static final String DEPLOY_RESPONSE_STRING = "{\"links\":"
-            + "{\"status\":\"http://deployment-handler.onap:8443/dcae-deployments/"
-            + "closedLoop_152367c8-b172-47b3-9e58-c53add75d869_deploymentId/"
-            + "operation/366eb098-7977-4966-ae82-abd2087edb10\"}}";
-
-    @Mock
-    private ClampProperties clampProperties;
-
-    @Mock
-    HttpConnectionManager httpConnectionManager;
-
-    @InjectMocks
-    DcaeDispatcherServices dcaeDispatcherServices;
-
-    private static final String STATUS_RESPONSE_PROCESSING = "{\"operationType\": \"deploy\","
-        + "\"status\": \"processing\"}";
-    private static final String STATUS_RESPONSE_ACTIVE = "{\"operationType\": \"deploy\",\"status\": \"succeeded\"}";
-
-    /**
-     * Setup method.
-     */
-    @Before
-    public void setUp() {
-        ImmutableMap.<String, String>builder()
-                .put("dcae.dispatcher.retry.limit", "3")
-                .put("dcae.dispatcher.retry.interval", "0")
-                .put("dcae.dispatcher.url", DCAE_URL)
-                .build()
-                .forEach((property, value) -> {
-                    Mockito.when(clampProperties.getStringValue(Matchers.matches(property), Matchers.any()))
-                            .thenReturn(value);
-                    Mockito.when(clampProperties.getStringValue(Matchers.matches(property))).thenReturn(value);
-                });
-    }
-
-    @Test
-    public void shouldReturnDcaeOperationSataus() throws IOException {
-        //given
-        Mockito.when(httpConnectionManager.doHttpRequest(DEPLOYMENT_STATUS_URL, "GET", null, null, "DCAE", null, null))
-                .thenReturn(STATUS_RESPONSE_PROCESSING);
-        //when
-        String operationStatus = dcaeDispatcherServices.getOperationStatus(DEPLOYMENT_STATUS_URL);
-
-        //then
-        Assertions.assertThat(operationStatus).isEqualTo("processing");
-    }
-
-    @Test
-    public void shouldTryMultipleTimesWhenProcessing() throws IOException, InterruptedException {
-        //given
-        Mockito.when(httpConnectionManager.doHttpRequest(DEPLOYMENT_STATUS_URL, "GET",
-                null, null, "DCAE", null, null))
-                .thenReturn(STATUS_RESPONSE_PROCESSING, STATUS_RESPONSE_PROCESSING, STATUS_RESPONSE_ACTIVE);
-        //when
-        String operationStatus = dcaeDispatcherServices.getOperationStatusWithRetry(DEPLOYMENT_STATUS_URL);
-
-        //then
-        Assertions.assertThat(operationStatus).isEqualTo("succeeded");
-        Mockito.verify(httpConnectionManager, Mockito.times(3))
-                .doHttpRequest(DEPLOYMENT_STATUS_URL, "GET", null, null, "DCAE", null, null);
-
-    }
-
-    @Test
-    public void shouldTryOnlyAsManyTimesAsConfigured() throws IOException, InterruptedException {
-        //given
-        Mockito.when(httpConnectionManager
-                .doHttpRequest(DEPLOYMENT_STATUS_URL, "GET", null, null, "DCAE", null, null))
-                .thenReturn(STATUS_RESPONSE_PROCESSING, STATUS_RESPONSE_PROCESSING, STATUS_RESPONSE_PROCESSING,
-                        STATUS_RESPONSE_PROCESSING, STATUS_RESPONSE_PROCESSING);
-        //when
-        String operationStatus = dcaeDispatcherServices.getOperationStatusWithRetry(DEPLOYMENT_STATUS_URL);
-
-        //then
-        Assertions.assertThat(operationStatus).isEqualTo("processing");
-        Mockito.verify(httpConnectionManager, Mockito.times(3))
-                .doHttpRequest(DEPLOYMENT_STATUS_URL, "GET", null, null, "DCAE", null, null);
-
-    }
-
-    @Test
-    public void shouldTriggerDeploymentCreation() throws IOException {
-        //given
-        String deploymentId = "closedLoop_152367c8-b172-47b3-9e58-c53add75d869_deploymentId";
-        String serviceTypeId = "e2ba40f7-bf42-41e7-acd7-48fd07586d90";
-        Mockito.when(clampProperties.getJsonTemplate("dcae.deployment.template"))
-                .thenReturn(new JsonObject());
-
-        Mockito.when(httpConnectionManager
-                .doHttpRequest(DCAE_URL
-                                + "/dcae-deployments/closedLoop_152367c8-b172-47b3-9e58-c53add75d869_deploymentId",
-                        "PUT",
-                        "{\"serviceTypeId\":\"e2ba40f7-bf42-41e7-acd7-48fd07586d90\",\"inputs\":{}}",
-                        "application/json", "DCAE", null, null))
-                .thenReturn(DEPLOY_RESPONSE_STRING);
-        JsonObject blueprintInputJson = new JsonObject();
-
-        //when
-        String operationStatus = dcaeDispatcherServices
-                .createNewDeployment(deploymentId, serviceTypeId, blueprintInputJson);
-
-        //then
-        Assertions.assertThat(operationStatus).isEqualTo("http://deployment-handler.onap:8443/"
-                + "dcae-deployments/closedLoop_152367c8-b172-47b3-9e58-c53add75d869_deploymentId/"
-                + "operation/366eb098-7977-4966-ae82-abd2087edb10");
-
-    }
-}
\ No newline at end of file
diff --git a/src/test/java/org/onap/clamp/clds/client/GuardPolicyDelegateTest.java b/src/test/java/org/onap/clamp/clds/client/GuardPolicyDelegateTest.java
deleted file mode 100644 (file)
index 4b21d6f..0000000
+++ /dev/null
@@ -1,108 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * ONAP CLAMP
- * ================================================================================
- * Copyright (C) 2019 Samsung. 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.client;
-
-import static org.mockito.Matchers.any;
-import static org.mockito.Matchers.eq;
-import static org.mockito.Mockito.never;
-import static org.mockito.Mockito.verify;
-import static org.mockito.Mockito.when;
-
-import org.apache.camel.Exchange;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.mockito.InjectMocks;
-import org.mockito.Mock;
-import org.mockito.runners.MockitoJUnitRunner;
-import org.onap.clamp.clds.client.req.policy.PolicyClient;
-import org.onap.clamp.clds.exception.ModelBpmnException;
-
-@RunWith(MockitoJUnitRunner.class)
-public class GuardPolicyDelegateTest {
-
-    private static final String TEST_KEY = "isTest";
-    private static final String MODEL_BPMN_KEY = "modelBpmnProp";
-    private static final String MODEL_PROP_KEY = "modelProp";
-    private static final String POLICY_ID_FROM_JSON = "{policy:[{id:guard,from:''}]}";
-    private static final String ID_WITH_CHAIN_JSON = "{guard:{q:["
-            + "{name:timeout,value:200},"
-            + "{policyConfigurations:["
-            + "[{name:maxRetries,value:3},"
-            + "{name:retryTimeLimit,value:800},"
-            + "{name:enableGuardPolicy,value:on}]]}]}}";
-    private static final String SIMPLE_JSON = "{}";
-    private static final String NOT_JSON = "not json";
-
-    @Mock
-    private Exchange exchange;
-
-    @Mock
-    private PolicyClient policyClient;
-
-    @InjectMocks
-    private GuardPolicyDelegate guardPolicyDelegate;
-
-    @Test
-    public void shouldExecuteSuccessfully() {
-        // given
-        when(exchange.getProperty(eq(TEST_KEY))).thenReturn(false);
-        when(exchange.getProperty(eq(MODEL_BPMN_KEY))).thenReturn(POLICY_ID_FROM_JSON);
-        when(exchange.getProperty(eq(MODEL_PROP_KEY))).thenReturn(ID_WITH_CHAIN_JSON);
-
-        // when
-        guardPolicyDelegate.execute(exchange);
-
-        // then
-        verify(policyClient).sendGuardPolicy(any(), any(), any(), any());
-    }
-
-    @Test
-    public void shouldExecutePolicyNotFound() {
-        // given
-        when(exchange.getProperty(eq(TEST_KEY))).thenReturn(false);
-        when(exchange.getProperty(eq(MODEL_BPMN_KEY))).thenReturn(SIMPLE_JSON);
-        when(exchange.getProperty(eq(MODEL_PROP_KEY))).thenReturn(SIMPLE_JSON);
-
-        // when
-        guardPolicyDelegate.execute(exchange);
-
-        // then
-        verify(policyClient, never()).sendGuardPolicy(any(), any(), any(), any());
-    }
-
-    @Test(expected = ModelBpmnException.class)
-    public void shouldThrowModelBpmnException() {
-        // given
-        when(exchange.getProperty(eq(TEST_KEY))).thenReturn(true);
-        when(exchange.getProperty(eq(MODEL_BPMN_KEY))).thenReturn(NOT_JSON);
-
-        // when
-        guardPolicyDelegate.execute(exchange);
-    }
-
-    @Test(expected = NullPointerException.class)
-    public void shouldThrowNullPointerException() {
-        // when
-        guardPolicyDelegate.execute(exchange);
-    }
-}
diff --git a/src/test/java/org/onap/clamp/clds/client/GuardPolicyDeleteDelegateTest.java b/src/test/java/org/onap/clamp/clds/client/GuardPolicyDeleteDelegateTest.java
deleted file mode 100644 (file)
index 2ff8166..0000000
+++ /dev/null
@@ -1,117 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * ONAP CLAMP
- * ================================================================================
- * Copyright (C) 2019 Samsung. 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.client;
-
-import static org.mockito.Mockito.any;
-import static org.mockito.Mockito.eq;
-import static org.mockito.Mockito.never;
-import static org.mockito.Mockito.verify;
-import static org.mockito.Mockito.when;
-
-import org.apache.camel.Exchange;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.mockito.InjectMocks;
-import org.mockito.Mock;
-import org.mockito.runners.MockitoJUnitRunner;
-import org.onap.clamp.clds.client.req.policy.PolicyClient;
-import org.onap.clamp.clds.exception.ModelBpmnException;
-
-@RunWith(MockitoJUnitRunner.class)
-public class GuardPolicyDeleteDelegateTest {
-
-    private static final String MODEL_BPMN_KEY = "modelBpmnProp";
-    private static final String MODEL_PROP_KEY = "modelProp";
-    private static final String TEST_KEY = "isTest";
-    private static final String EVENT_ACTION_KEY = "eventAction";
-
-    private static final String POLICY_ID_FROM_JSON = "{policy:[{id:Policy_7,from:''}]}";
-    private static final String TCA_ID_FROM_JSON = "{tca:[{id:'',from:''}]}";
-    private static final String ID_JSON = "{Policy_7:{r:["
-            + "{name:pid,value:pid334},"
-            + "{name:timeout,value:50},"
-            + "{name:policyType,value:pt},"
-            + "{policyConfigurations:[["
-            + "{name:_id,value:ret345},"
-            + "{name:recipe,value:make},"
-            + "{name:maxRetries,value:5},"
-            + "{name:retryTimeLimit,value:100},"
-            + "{name:enableGuardPolicy,value:on}]]}]}}";
-    private static final String NOT_JSON = "not json";
-    private static final String EVENT_ACTION_VALUE = "action";
-
-    @Mock
-    private Exchange exchange;
-
-    @Mock
-    private PolicyClient policyClient;
-
-    @InjectMocks
-    private GuardPolicyDeleteDelegate guardPolicyDeleteDelegate;
-
-    @Test
-    public void shouldExecuteSuccessfully() {
-        // given
-        when(exchange.getProperty(eq(MODEL_BPMN_KEY))).thenReturn(POLICY_ID_FROM_JSON);
-        when(exchange.getProperty(eq(MODEL_PROP_KEY))).thenReturn(ID_JSON);
-        when(exchange.getProperty(eq(TEST_KEY))).thenReturn(false);
-        when(exchange.getProperty(eq(EVENT_ACTION_KEY))).thenReturn(EVENT_ACTION_VALUE);
-
-        // when
-        guardPolicyDeleteDelegate.execute(exchange);
-
-        // then
-        verify(policyClient).deleteGuard(any());
-    }
-
-    @Test
-    public void shouldExecutePolicyNotFound() {
-        // given
-        when(exchange.getProperty(eq(MODEL_BPMN_KEY))).thenReturn(TCA_ID_FROM_JSON);
-        when(exchange.getProperty(eq(MODEL_PROP_KEY))).thenReturn(ID_JSON);
-        when(exchange.getProperty(eq(TEST_KEY))).thenReturn(false);
-        when(exchange.getProperty(eq(EVENT_ACTION_KEY))).thenReturn(EVENT_ACTION_VALUE);
-
-        // when
-        guardPolicyDeleteDelegate.execute(exchange);
-
-        // then
-        verify(policyClient, never()).deleteGuard(any());
-    }
-
-    @Test(expected = ModelBpmnException.class)
-    public void shouldThrowModelBpmnException() {
-        // given
-        when(exchange.getProperty(eq(MODEL_BPMN_KEY))).thenReturn(NOT_JSON);
-        when(exchange.getProperty(eq(TEST_KEY))).thenReturn(false);
-
-        // when
-        guardPolicyDeleteDelegate.execute(exchange);
-    }
-
-    @Test(expected = NullPointerException.class)
-    public void shouldThrowNullPointerException() {
-        // when
-        guardPolicyDeleteDelegate.execute(exchange);
-    }
-}
diff --git a/src/test/java/org/onap/clamp/clds/client/HolmesPolicyDelegateTest.java b/src/test/java/org/onap/clamp/clds/client/HolmesPolicyDelegateTest.java
deleted file mode 100644 (file)
index 1d3f1ce..0000000
+++ /dev/null
@@ -1,183 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * ONAP CLAMP
- * ================================================================================
- * Copyright (C) 2019 Samsung. 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.client;
-
-import static org.junit.Assert.assertEquals;
-import static org.mockito.Mockito.any;
-import static org.mockito.Mockito.anyString;
-import static org.mockito.Mockito.eq;
-import static org.mockito.Mockito.mock;
-import static org.mockito.Mockito.never;
-import static org.mockito.Mockito.verify;
-import static org.mockito.Mockito.when;
-
-import com.google.gson.JsonElement;
-import com.google.gson.JsonObject;
-
-import java.io.IOException;
-
-import org.apache.camel.Exchange;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.mockito.InjectMocks;
-import org.mockito.Mock;
-import org.mockito.runners.MockitoJUnitRunner;
-import org.onap.clamp.clds.client.req.policy.PolicyClient;
-import org.onap.clamp.clds.config.ClampProperties;
-import org.onap.clamp.clds.dao.CldsDao;
-import org.onap.clamp.clds.exception.ModelBpmnException;
-import org.onap.clamp.clds.model.CldsModel;
-import org.onap.clamp.clds.model.properties.Holmes;
-import org.onap.clamp.clds.model.properties.ModelProperties;
-import org.onap.clamp.clds.util.JsonUtils;
-
-@RunWith(MockitoJUnitRunner.class)
-public class HolmesPolicyDelegateTest {
-
-    private static final String ID_JSON = "{\"id\":{\"r\":[{},{\"serviceConfigurations\":"
-            + "[[\"x\",\"+\",\"2\",\"y\"]]}]}}";
-    private static final String METRICS_JSON = "{\"metricsPerEventName\":[{\"thresholds\":[]}]}";
-    private static final String CONTENT_JSON = "{\"content\":{}}";
-    private static final String NULL_JSON = "{}";
-    private static final String HOLMES_ID_FROM_JSON = "{\"holmes\":[{\"id\":\"id\",\"from\":\"\"}]}";
-    private static final String TCA_ID_FROM_JSON = "{\"tca\":[{\"id\":\"\",\"from\":\"\"}]}";
-    private static final String CORRELATION_LOGIC_JSON = "{\"name\":\"correlationalLogic\"}";
-    private static final String NOT_JSON = "not json";
-    private static final String MODEL_BPMN_KEY = "modelBpmnProp";
-    private static final String MODEL_PROP_KEY = "modelProp";
-    private static final String MODEL_NAME_KEY = "modelName";
-    private static final String TEST_KEY = "isTest";
-    private static final String USERID_KEY = "userid";
-    private static final String TCA_TEMPLATE_KEY = "tca.template";
-    private static final String TCA_POLICY_TEMPLATE_KEY = "tca.policy.template";
-    private static final String TCA_THRESHOLDS_TEMPLATE_KEY = "tca.thresholds.template";
-    private static final String HOLMES_POLICY_RESPONSE_MESSAGE_KEY = "holmesPolicyResponseMessage";
-    private static final String RESPONSE_MESSAGE_VALUE = "responseMessage";
-    private static final String MODEL_NAME_VALUE = "model.name";
-    private static final String CONTROL_NAME_VALUE = "control.name";
-    private static final String USERID_VALUE = "user";
-    private static final String CLDS_MODEL_ID = "id";
-    private static final String CLDS_MODEL_PROP_TEXT = "propText";
-
-    @Mock
-    private Exchange exchange;
-
-    @Mock
-    private PolicyClient policyClient;
-
-    @Mock
-    private ClampProperties clampProperties;
-
-    @Mock
-    private CldsDao cldsDao;
-
-    @InjectMocks
-    private HolmesPolicyDelegate holmesPolicyDelegateTest;
-
-    @Test
-    public void shouldExecuteSuccessfully() throws IOException {
-        // given
-        when(exchange.getProperty(eq(MODEL_BPMN_KEY))).thenReturn(HOLMES_ID_FROM_JSON);
-        when(exchange.getProperty(eq(MODEL_PROP_KEY))).thenReturn(ID_JSON);
-        when(exchange.getProperty(eq(MODEL_NAME_KEY))).thenReturn(MODEL_NAME_VALUE);
-        when(exchange.getProperty(eq(TEST_KEY))).thenReturn(false);
-        when(exchange.getProperty(eq(USERID_KEY))).thenReturn(USERID_VALUE);
-
-        JsonElement jsonTemplateA = mock(JsonElement.class);
-        when(clampProperties.getJsonTemplate(eq(TCA_TEMPLATE_KEY), anyString())).thenReturn(jsonTemplateA);
-        when(jsonTemplateA.getAsJsonObject()).thenReturn(getJsonObject(METRICS_JSON));
-
-        JsonElement jsonTemplateB = mock(JsonElement.class);
-        when(clampProperties.getJsonTemplate(eq(TCA_POLICY_TEMPLATE_KEY), anyString())).thenReturn(jsonTemplateB);
-        when(jsonTemplateB.getAsJsonObject()).thenReturn(getJsonObject(CONTENT_JSON));
-
-        JsonElement jsonTemplateC = mock(JsonElement.class);
-        when(clampProperties.getJsonTemplate(eq(TCA_THRESHOLDS_TEMPLATE_KEY), anyString())).thenReturn(jsonTemplateC);
-        when(jsonTemplateC.getAsJsonObject()).thenReturn(getJsonObject(NULL_JSON));
-
-        when(policyClient.sendBasePolicyInOther(anyString(), anyString(), any(), anyString()))
-                .thenReturn(RESPONSE_MESSAGE_VALUE);
-
-        CldsModel cldsModel = new CldsModel();
-        cldsModel.setId(CLDS_MODEL_ID);
-        cldsModel.setPropText(CLDS_MODEL_PROP_TEXT);
-        when(cldsDao.getModelTemplate(eq(MODEL_NAME_VALUE))).thenReturn(cldsModel);
-
-        // when
-        holmesPolicyDelegateTest.execute(exchange);
-
-        // then
-        verify(exchange).setProperty(eq(HOLMES_POLICY_RESPONSE_MESSAGE_KEY), eq(RESPONSE_MESSAGE_VALUE.getBytes()));
-        verify(cldsDao).setModel(eq(cldsModel), eq(USERID_VALUE));
-    }
-
-    @Test
-    public void shouldExecuteHolmesNotFound() {
-        // given
-        when(exchange.getProperty(eq(MODEL_BPMN_KEY))).thenReturn(TCA_ID_FROM_JSON);
-        when(exchange.getProperty(eq(MODEL_PROP_KEY))).thenReturn(ID_JSON);
-        when(exchange.getProperty(eq(TEST_KEY))).thenReturn(false);
-
-        // when
-        holmesPolicyDelegateTest.execute(exchange);
-
-        // then
-        verify(policyClient, never()).sendBasePolicyInOther(anyString(), anyString(), any(), anyString());
-        verify(exchange, never()).setProperty(eq(HOLMES_POLICY_RESPONSE_MESSAGE_KEY), any());
-        verify(cldsDao, never()).setModel(any(), anyString());
-    }
-
-    @Test(expected = ModelBpmnException.class)
-    public void shouldThrowModelBpmnException() {
-        // given
-        when(exchange.getProperty(eq(MODEL_BPMN_KEY))).thenReturn(NOT_JSON);
-        when(exchange.getProperty(eq(TEST_KEY))).thenReturn(false);
-
-        // when
-        holmesPolicyDelegateTest.execute(exchange);
-    }
-
-    @Test(expected = NullPointerException.class)
-    public void shouldThrowNullPointerException() {
-        // when
-        holmesPolicyDelegateTest.execute(exchange);
-    }
-
-    @Test
-    public void shouldDoFormatHolmesConfigBodySuccessfully() {
-        // given
-        ModelProperties prop = new ModelProperties(null, CONTROL_NAME_VALUE, null, false,
-                HOLMES_ID_FROM_JSON, "{\"id\":" + CORRELATION_LOGIC_JSON + "}");
-        Holmes holmes = prop.getType(Holmes.class);
-
-        // when
-        String result = HolmesPolicyDelegate.formatHolmesConfigBody(prop, holmes);
-
-        // then
-        assertEquals(CONTROL_NAME_VALUE + "$$$" + CORRELATION_LOGIC_JSON, result);
-    }
-
-    private static JsonObject getJsonObject(String jsonText) {
-        return JsonUtils.GSON.fromJson(jsonText, JsonObject.class);
-    }
-}
diff --git a/src/test/java/org/onap/clamp/clds/client/HolmesPolicyDeleteDelegateTest.java b/src/test/java/org/onap/clamp/clds/client/HolmesPolicyDeleteDelegateTest.java
deleted file mode 100644 (file)
index ccebbfb..0000000
+++ /dev/null
@@ -1,104 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * ONAP CLAMP
- * ================================================================================
- * Copyright (C) 2019 Samsung. 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.client;
-
-import static org.mockito.Mockito.any;
-import static org.mockito.Mockito.eq;
-import static org.mockito.Mockito.never;
-import static org.mockito.Mockito.verify;
-import static org.mockito.Mockito.when;
-
-import org.apache.camel.Exchange;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.mockito.InjectMocks;
-import org.mockito.Mock;
-import org.mockito.runners.MockitoJUnitRunner;
-import org.onap.clamp.clds.client.req.policy.PolicyClient;
-import org.onap.clamp.clds.exception.ModelBpmnException;
-
-@RunWith(MockitoJUnitRunner.class)
-public class HolmesPolicyDeleteDelegateTest {
-
-    private static final String MODEL_BPMN_KEY = "modelBpmnProp";
-    private static final String MODEL_PROP_KEY = "modelProp";
-    private static final String TEST_KEY = "isTest";
-
-    private static final String HOLMES_ID_FROM_JSON = "{\"holmes\":[{\"id\":\"\",\"from\":\"\"}]}";
-    private static final String TCA_ID_FROM_JSON = "{\"tca\":[{\"id\":\"\",\"from\":\"\"}]}";
-    private static final String ID_JSON = "{\"id\":\"\"}";
-    private static final String NOT_JSON = "not json";
-
-    @Mock
-    private Exchange exchange;
-
-    @Mock
-    private PolicyClient policyClient;
-
-    @InjectMocks
-    private HolmesPolicyDeleteDelegate holmesPolicyDeleteDelegate;
-
-    @Test
-    public void shouldExecuteSuccessfully() {
-        // given
-        when(exchange.getProperty(eq(MODEL_BPMN_KEY))).thenReturn(HOLMES_ID_FROM_JSON);
-        when(exchange.getProperty(eq(MODEL_PROP_KEY))).thenReturn(ID_JSON);
-        when(exchange.getProperty(eq(TEST_KEY))).thenReturn(false);
-
-        // when
-        holmesPolicyDeleteDelegate.execute(exchange);
-
-        // then
-        verify(policyClient).deleteBasePolicy(any());
-    }
-
-    @Test
-    public void shouldExecuteHolmesNotFound() {
-        // given
-        when(exchange.getProperty(eq(MODEL_BPMN_KEY))).thenReturn(TCA_ID_FROM_JSON);
-        when(exchange.getProperty(eq(MODEL_PROP_KEY))).thenReturn(ID_JSON);
-        when(exchange.getProperty(eq(TEST_KEY))).thenReturn(false);
-
-        // when
-        holmesPolicyDeleteDelegate.execute(exchange);
-
-        // then
-        verify(policyClient, never()).deleteBasePolicy(any());
-    }
-
-    @Test(expected = ModelBpmnException.class)
-    public void shouldThrowModelBpmnException() {
-        // given
-        when(exchange.getProperty(eq(MODEL_BPMN_KEY))).thenReturn(NOT_JSON);
-        when(exchange.getProperty(eq(TEST_KEY))).thenReturn(false);
-
-        // when
-        holmesPolicyDeleteDelegate.execute(exchange);
-    }
-
-    @Test(expected = NullPointerException.class)
-    public void shouldThrowNullPointerException() {
-        // when
-        holmesPolicyDeleteDelegate.execute(exchange);
-    }
-}
diff --git a/src/test/java/org/onap/clamp/clds/client/ModelDeleteDelegateTest.java b/src/test/java/org/onap/clamp/clds/client/ModelDeleteDelegateTest.java
deleted file mode 100644 (file)
index 06b9422..0000000
+++ /dev/null
@@ -1,63 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * ONAP CLAMP
- * ================================================================================
- * Copyright (C) 2019 Samsung. 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.client;
-
-import static org.mockito.Mockito.eq;
-import static org.mockito.Mockito.verify;
-import static org.mockito.Mockito.when;
-
-import org.apache.camel.Exchange;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.mockito.InjectMocks;
-import org.mockito.Mock;
-import org.mockito.runners.MockitoJUnitRunner;
-import org.onap.clamp.clds.dao.CldsDao;
-
-@RunWith(MockitoJUnitRunner.class)
-public class ModelDeleteDelegateTest {
-
-    private static final String NAME_KEY = "modelName";
-    private static final String NAME_VALUE = "model.name";
-
-    @Mock
-    private Exchange exchange;
-
-    @Mock
-    private CldsDao cldsDao;
-
-    @InjectMocks
-    private ModelDeleteDelegate modelDeleteDelegate;
-
-    @Test
-    public void shouldExecuteSuccessfully() {
-        // given
-        when(exchange.getProperty(eq(NAME_KEY))).thenReturn(NAME_VALUE);
-
-        // when
-        modelDeleteDelegate.execute(exchange);
-
-        // then
-        verify(cldsDao).deleteModel(eq(NAME_VALUE));
-    }
-}
diff --git a/src/test/java/org/onap/clamp/clds/client/OperationalPolicyDelegateTest.java b/src/test/java/org/onap/clamp/clds/client/OperationalPolicyDelegateTest.java
deleted file mode 100644 (file)
index 75be799..0000000
+++ /dev/null
@@ -1,125 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * ONAP CLAMP
- * ================================================================================
- * Copyright (C) 2019 Samsung. 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.client;
-
-import static org.mockito.Matchers.any;
-import static org.mockito.Matchers.eq;
-import static org.mockito.Mockito.never;
-import static org.mockito.Mockito.verify;
-import static org.mockito.Mockito.when;
-
-import java.io.UnsupportedEncodingException;
-
-import org.apache.camel.Exchange;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.mockito.InjectMocks;
-import org.mockito.Mock;
-import org.mockito.runners.MockitoJUnitRunner;
-import org.onap.clamp.clds.client.req.policy.PolicyClient;
-import org.onap.clamp.clds.config.ClampProperties;
-import org.onap.clamp.clds.exception.ModelBpmnException;
-import org.onap.policy.controlloop.policy.builder.BuilderException;
-
-@RunWith(MockitoJUnitRunner.class)
-public class OperationalPolicyDelegateTest {
-
-    private static final String TEST_KEY = "isTest";
-    private static final String MODEL_BPMN_KEY = "modelBpmnProp";
-    private static final String MODEL_PROP_KEY = "modelProp";
-    private static final String RECIPE_TOPIC_KEY = "op.recipeTopic";
-    private static final String MESSAGE_KEY = "operationalPolicyResponseMessage";
-    private static final String SERVICE_NAME = "service.name";
-    private static final String POLICY_ID_FROM_JSON = "{policy:[{id:Oper12,from:''}]}";
-    private static final String ID_WITH_CHAIN_JSON = "{Oper12:{ab:["
-            + "{name:timeout,value:500},"
-            + "{policyConfigurations:["
-            + "[{name:maxRetries,value:5},"
-            + "{name:retryTimeLimit,value:1000},"
-            + "{name:recipe,value:go},"
-            + "{name:targetResourceId,"
-            + "value:resid234}]]}]},"
-            + "global:[{name:service,value:" + SERVICE_NAME + "}]}";
-    private static final String SIMPLE_JSON = "{}";
-    private static final String NOT_JSON = "not json";
-    private static final String MESSAGE_VALUE = "message";
-    private static final String RECIPE_TOPIC_VALUE = "recipe.topic";
-
-    @Mock
-    private Exchange exchange;
-
-    @Mock
-    private PolicyClient policyClient;
-
-    @Mock
-    private ClampProperties refProp;
-
-    @InjectMocks
-    private OperationalPolicyDelegate operationalPolicyDelegate;
-
-    @Test
-    public void shouldExecuteSuccessfully() throws BuilderException, UnsupportedEncodingException {
-        // given
-        when(exchange.getProperty(eq(TEST_KEY))).thenReturn(true);
-        when(exchange.getProperty(eq(MODEL_BPMN_KEY))).thenReturn(POLICY_ID_FROM_JSON);
-        when(exchange.getProperty(eq(MODEL_PROP_KEY))).thenReturn(ID_WITH_CHAIN_JSON);
-        when(policyClient.sendBrmsPolicy(any(), any(), any())).thenReturn(MESSAGE_VALUE);
-        when(refProp.getStringValue(eq(RECIPE_TOPIC_KEY), eq(SERVICE_NAME))).thenReturn(RECIPE_TOPIC_VALUE);
-
-        // when
-        operationalPolicyDelegate.execute(exchange);
-
-        // then
-        verify(exchange).setProperty(eq(MESSAGE_KEY), eq(MESSAGE_VALUE.getBytes()));
-    }
-
-    @Test
-    public void shouldExecutePolicyNotFound() throws BuilderException, UnsupportedEncodingException {
-        // given
-        when(exchange.getProperty(eq(TEST_KEY))).thenReturn(false);
-        when(exchange.getProperty(eq(MODEL_BPMN_KEY))).thenReturn(SIMPLE_JSON);
-        when(exchange.getProperty(eq(MODEL_PROP_KEY))).thenReturn(SIMPLE_JSON);
-
-        // when
-        operationalPolicyDelegate.execute(exchange);
-
-        // then
-        verify(policyClient, never()).sendBrmsPolicy(any(), any(), any());
-    }
-
-    @Test(expected = ModelBpmnException.class)
-    public void shouldThrowModelBpmnException() throws BuilderException, UnsupportedEncodingException {
-        // given
-        when(exchange.getProperty(eq(TEST_KEY))).thenReturn(true);
-        when(exchange.getProperty(eq(MODEL_BPMN_KEY))).thenReturn(NOT_JSON);
-
-        // when
-        operationalPolicyDelegate.execute(exchange);
-    }
-
-    @Test(expected = NullPointerException.class)
-    public void shouldThrowNullPointerException() throws BuilderException, UnsupportedEncodingException {
-        // when
-        operationalPolicyDelegate.execute(exchange);
-    }
-}
diff --git a/src/test/java/org/onap/clamp/clds/client/OperationalPolicyDeleteDelegateTest.java b/src/test/java/org/onap/clamp/clds/client/OperationalPolicyDeleteDelegateTest.java
deleted file mode 100644 (file)
index 9d87e7e..0000000
+++ /dev/null
@@ -1,108 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * ONAP CLAMP
- * ================================================================================
- * Copyright (C) 2019 Samsung. 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.client;
-
-import static org.mockito.Matchers.any;
-import static org.mockito.Matchers.eq;
-import static org.mockito.Mockito.never;
-import static org.mockito.Mockito.times;
-import static org.mockito.Mockito.verify;
-import static org.mockito.Mockito.when;
-
-import org.apache.camel.Exchange;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.mockito.InjectMocks;
-import org.mockito.Mock;
-import org.mockito.runners.MockitoJUnitRunner;
-import org.onap.clamp.clds.client.req.policy.PolicyClient;
-import org.onap.clamp.clds.exception.ModelBpmnException;
-import org.onap.clamp.clds.model.properties.ModelProperties;
-
-@RunWith(MockitoJUnitRunner.class)
-public class OperationalPolicyDeleteDelegateTest {
-
-    private static final String TEST_KEY = "isTest";
-    private static final String MODEL_BPMN_KEY = "modelBpmnProp";
-    private static final String MODEL_PROP_KEY = "modelProp";
-    private static final String EVENT_ACTION_KEY = "eventAction";
-    private static final String POLICY_ID_FROM_JSON = "{policy:[{id:Poli2,from:''}]}";
-    private static final String ID_WITH_CHAIN_JSON = "{Poli2:{ab:c,xy:z}}";
-    private static final String ID_NO_CHAIN_JSON = "{Poli2:{}}";
-    private static final String EVENT_ACTION_VALUE = "still";
-    private static final String NOT_JSON = "23e";
-
-    @Mock
-    private Exchange exchange;
-
-    @Mock
-    private PolicyClient policyClient;
-
-    @InjectMocks
-    private OperationalPolicyDeleteDelegate operationalPolicyDeleteDelegate;
-
-    @Test
-    public void shouldExecuteSuccessfully() {
-        // given
-        when(exchange.getProperty(eq(TEST_KEY))).thenReturn(false);
-        when(exchange.getProperty(eq(MODEL_BPMN_KEY))).thenReturn(POLICY_ID_FROM_JSON);
-        when(exchange.getProperty(eq(MODEL_PROP_KEY))).thenReturn(ID_WITH_CHAIN_JSON);
-        when(exchange.getProperty(eq(EVENT_ACTION_KEY))).thenReturn(EVENT_ACTION_VALUE);
-
-        // when
-        operationalPolicyDeleteDelegate.execute(exchange);
-
-        // then
-        verify(policyClient, times(2)).deleteBrms(any(ModelProperties.class));
-    }
-
-    @Test
-    public void shouldExecuteTcaNotFound() {
-        // given
-        when(exchange.getProperty(eq(TEST_KEY))).thenReturn(true);
-        when(exchange.getProperty(eq(MODEL_BPMN_KEY))).thenReturn(POLICY_ID_FROM_JSON);
-        when(exchange.getProperty(eq(MODEL_PROP_KEY))).thenReturn(ID_NO_CHAIN_JSON);
-
-        // when
-        operationalPolicyDeleteDelegate.execute(exchange);
-
-        // then
-        verify(policyClient, never()).deleteBrms(any(ModelProperties.class));
-    }
-
-    @Test(expected = ModelBpmnException.class)
-    public void shouldThrowModelBpmnException() {
-        // given
-        when(exchange.getProperty(eq(TEST_KEY))).thenReturn(false);
-        when(exchange.getProperty(eq(MODEL_BPMN_KEY))).thenReturn(NOT_JSON);
-
-        // when
-        operationalPolicyDeleteDelegate.execute(exchange);
-    }
-
-    @Test(expected = NullPointerException.class)
-    public void shouldThrowNullPointerException() {
-        // when
-        operationalPolicyDeleteDelegate.execute(exchange);
-    }
-}
diff --git a/src/test/java/org/onap/clamp/clds/client/TcaPolicyDelegateTest.java b/src/test/java/org/onap/clamp/clds/client/TcaPolicyDelegateTest.java
deleted file mode 100644 (file)
index a885199..0000000
+++ /dev/null
@@ -1,166 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * ONAP CLAMP
- * ================================================================================
- * Copyright (C) 2019 Samsung. 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.client;
-
-import static org.mockito.Mockito.any;
-import static org.mockito.Mockito.anyString;
-import static org.mockito.Mockito.eq;
-import static org.mockito.Mockito.mock;
-import static org.mockito.Mockito.never;
-import static org.mockito.Mockito.verify;
-import static org.mockito.Mockito.when;
-
-import com.google.gson.JsonElement;
-import com.google.gson.JsonObject;
-
-import java.io.IOException;
-
-import org.apache.camel.Exchange;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.mockito.InjectMocks;
-import org.mockito.Mock;
-import org.mockito.runners.MockitoJUnitRunner;
-import org.onap.clamp.clds.client.req.policy.PolicyClient;
-import org.onap.clamp.clds.config.ClampProperties;
-import org.onap.clamp.clds.dao.CldsDao;
-import org.onap.clamp.clds.exception.ModelBpmnException;
-import org.onap.clamp.clds.model.CldsModel;
-import org.onap.clamp.clds.util.JsonUtils;
-
-@RunWith(MockitoJUnitRunner.class)
-public class TcaPolicyDelegateTest {
-
-    private static final String MODEL_BPMN_KEY = "modelBpmnProp";
-    private static final String MODEL_PROP_KEY = "modelProp";
-    private static final String MODEL_NAME_KEY = "modelName";
-    private static final String TEST_KEY = "isTest";
-    private static final String USERID_KEY = "userid";
-    private static final String TCA_TEMPLATE_KEY = "tca.template";
-    private static final String TCA_POLICY_TEMPLATE_KEY = "tca.policy.template";
-    private static final String TCA_THRESHOLDS_TEMPLATE_KEY = "tca.thresholds.template";
-    private static final String TCA_POLICY_RESPONSE_MESSAGE_KEY = "tcaPolicyResponseMessage";
-
-    private static final String TCA_ID_FROM_JSON = "{\"tca\":[{\"id\":\"id\",\"from\":\"\"}]}";
-    private static final String ID_JSON = "{\"id\":{\"r\":[{},{\"serviceConfigurations\":"
-            + "[[\"x\",\"+\",\"2\",\"y\"]]}]}}";
-    private static final String TCA_TEMPLATE_JSON = "{\"metricsPerEventName\":[{\"thresholds\":[]}]}";
-    private static final String TCA_POLICY_TEMPLATE_JSON = "{\"content\":{}}";
-    private static final String TCA_THRESHOLDS_TEMPLATE_JSON = "{}";
-    private static final String HOLMES_ID_FROM_JSON = "{\"holmes\":[{\"id\":\"\",\"from\":\"\"}]}";
-    private static final String NOT_JSON = "not json";
-
-    private static final String RESPONSE_MESSAGE_VALUE = "responseMessage";
-    private static final String MODEL_NAME_VALUE = "ModelName";
-    private static final String USERID_VALUE = "user";
-
-    private static final String CLDS_MODEL_ID = "id";
-    private static final String CLDS_MODEL_PROP_TEXT = "propText";
-
-    @Mock
-    private Exchange camelExchange;
-
-    @Mock
-    private ClampProperties refProp;
-
-    @Mock
-    private PolicyClient policyClient;
-
-    @Mock
-    private CldsDao cldsDao;
-
-    @InjectMocks
-    private TcaPolicyDelegate tcaPolicyDelegate;
-
-    @Test
-    public void shouldExecuteSuccessfully() throws IOException {
-        //given
-        when(camelExchange.getProperty(eq(MODEL_BPMN_KEY))).thenReturn(TCA_ID_FROM_JSON);
-        when(camelExchange.getProperty(eq(MODEL_PROP_KEY))).thenReturn(ID_JSON);
-        when(camelExchange.getProperty(eq(MODEL_NAME_KEY))).thenReturn(MODEL_NAME_VALUE);
-        when(camelExchange.getProperty(eq(TEST_KEY))).thenReturn(false);
-        when(camelExchange.getProperty(eq(USERID_KEY))).thenReturn(USERID_VALUE);
-
-        JsonElement jsonTemplate;
-        JsonObject jsonObject;
-
-        jsonTemplate = mock(JsonElement.class);
-        when(refProp.getJsonTemplate(eq(TCA_TEMPLATE_KEY), anyString())).thenReturn(jsonTemplate);
-        jsonObject = JsonUtils.GSON.fromJson(TCA_TEMPLATE_JSON, JsonObject.class);
-        when(jsonTemplate.getAsJsonObject()).thenReturn(jsonObject);
-
-        jsonTemplate = mock(JsonElement.class);
-        when(refProp.getJsonTemplate(eq(TCA_POLICY_TEMPLATE_KEY), anyString())).thenReturn(jsonTemplate);
-        jsonObject = JsonUtils.GSON.fromJson(TCA_POLICY_TEMPLATE_JSON, JsonObject.class);
-        when(jsonTemplate.getAsJsonObject()).thenReturn(jsonObject);
-
-        jsonTemplate = mock(JsonElement.class);
-        when(refProp.getJsonTemplate(eq(TCA_THRESHOLDS_TEMPLATE_KEY), anyString())).thenReturn(jsonTemplate);
-        jsonObject = JsonUtils.GSON.fromJson(TCA_THRESHOLDS_TEMPLATE_JSON, JsonObject.class);
-        when(jsonTemplate.getAsJsonObject()).thenReturn(jsonObject);
-
-        when(policyClient.sendMicroServiceInOther(anyString(), any())).thenReturn(RESPONSE_MESSAGE_VALUE);
-
-        CldsModel cldsModel = new CldsModel();
-        cldsModel.setId(CLDS_MODEL_ID);
-        cldsModel.setPropText(CLDS_MODEL_PROP_TEXT);
-        when(cldsDao.getModelTemplate(eq(MODEL_NAME_VALUE))).thenReturn(cldsModel);
-
-        //when
-        tcaPolicyDelegate.execute(camelExchange);
-
-        //then
-        verify(camelExchange).setProperty(eq(TCA_POLICY_RESPONSE_MESSAGE_KEY), eq(RESPONSE_MESSAGE_VALUE.getBytes()));
-        verify(cldsDao).setModel(eq(cldsModel), eq(USERID_VALUE));
-    }
-
-    @Test
-    public void shouldExecuteTcaNotFound() {
-        //given
-        when(camelExchange.getProperty(eq(MODEL_BPMN_KEY))).thenReturn(HOLMES_ID_FROM_JSON);
-        when(camelExchange.getProperty(eq(MODEL_PROP_KEY))).thenReturn(ID_JSON);
-        when(camelExchange.getProperty(eq(TEST_KEY))).thenReturn(false);
-
-        //when
-        tcaPolicyDelegate.execute(camelExchange);
-
-        //then
-        verify(policyClient, never()).sendMicroServiceInOther(any(), any());
-    }
-
-    @Test(expected = ModelBpmnException.class)
-    public void shouldThrowModelBpmnException() {
-        //given
-        when(camelExchange.getProperty(eq(MODEL_BPMN_KEY))).thenReturn(NOT_JSON);
-        when(camelExchange.getProperty(eq(TEST_KEY))).thenReturn(false);
-
-        //when
-        tcaPolicyDelegate.execute(camelExchange);
-    }
-
-    @Test(expected = NullPointerException.class)
-    public void shouldThrowNullPointerException() {
-        //when
-        tcaPolicyDelegate.execute(camelExchange);
-    }
-}
diff --git a/src/test/java/org/onap/clamp/clds/client/TcaPolicyDeleteDelegateTest.java b/src/test/java/org/onap/clamp/clds/client/TcaPolicyDeleteDelegateTest.java
deleted file mode 100644 (file)
index 70edabe..0000000
+++ /dev/null
@@ -1,103 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * ONAP CLAMP
- * ================================================================================
- * Copyright (C) 2019 Samsung. 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.client;
-
-import org.apache.camel.Exchange;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.mockito.InjectMocks;
-import org.mockito.Mock;
-import org.mockito.Mockito;
-import org.mockito.runners.MockitoJUnitRunner;
-import org.onap.clamp.clds.client.req.policy.PolicyClient;
-import org.onap.clamp.clds.exception.ModelBpmnException;
-
-@RunWith(MockitoJUnitRunner.class)
-public class TcaPolicyDeleteDelegateTest {
-
-    private static final String TCA_ID_FROM_JSON = "{\"tca\":[{\"id\":\"\",\"from\":\"\"}]}";
-    private static final String HOLMES_ID_FROM_JSON = "{\"holmes\":[{\"id\":\"\",\"from\":\"\"}]}";
-    private static final String ID_JSON = "{\"id\":\"\"}";
-    private static final String NOT_JSON = "not json";
-    private static final String MODEL_BPMN_KEY = "modelBpmnProp";
-    private static final String MODEL_PROP_KEY = "modelProp";
-    private static final String TEST_KEY = "isTest";
-    private static final String PROPERTY_NAME = "tcaPolicyDeleteResponseMessage";
-    private static final String MESSAGE = "message";
-
-    @Mock
-    private Exchange camelExchange;
-
-    @Mock
-    private PolicyClient policyClient;
-
-    @InjectMocks
-    private TcaPolicyDeleteDelegate tcaPolicyDeleteDelegate;
-
-    @Test
-    public void shouldExecuteSuccessfully() {
-        //given
-        Mockito.when(camelExchange.getProperty(MODEL_BPMN_KEY)).thenReturn(TCA_ID_FROM_JSON);
-        Mockito.when(camelExchange.getProperty(MODEL_PROP_KEY)).thenReturn(ID_JSON);
-        Mockito.when(camelExchange.getProperty(TEST_KEY)).thenReturn(false);
-
-        Mockito.when(policyClient.deleteMicrosService(Mockito.any())).thenReturn(MESSAGE);
-
-        //when
-        tcaPolicyDeleteDelegate.execute(camelExchange);
-
-        //then
-        Mockito.verify(camelExchange).setProperty(PROPERTY_NAME, MESSAGE.getBytes());
-    }
-
-    @Test
-    public void shouldExecuteTcaNotFound() {
-        //given
-        Mockito.when(camelExchange.getProperty(MODEL_BPMN_KEY)).thenReturn(HOLMES_ID_FROM_JSON);
-        Mockito.when(camelExchange.getProperty(MODEL_PROP_KEY)).thenReturn(ID_JSON);
-        Mockito.when(camelExchange.getProperty(TEST_KEY)).thenReturn(false);
-
-        //when
-        tcaPolicyDeleteDelegate.execute(camelExchange);
-
-        //then
-        Mockito.verify(policyClient, Mockito.never()).deleteMicrosService(Mockito.any());
-        Mockito.verify(camelExchange, Mockito.never()).setProperty(Mockito.any(), Mockito.any());
-    }
-
-    @Test(expected = ModelBpmnException.class)
-    public void shouldThrowModelBpmnException() {
-        //given
-        Mockito.when(camelExchange.getProperty(MODEL_BPMN_KEY)).thenReturn(NOT_JSON);
-        Mockito.when(camelExchange.getProperty(TEST_KEY)).thenReturn(false);
-
-        //when
-        tcaPolicyDeleteDelegate.execute(camelExchange);
-    }
-
-    @Test(expected = NullPointerException.class)
-    public void shouldThrowNullPointerException() {
-        //when
-        tcaPolicyDeleteDelegate.execute(camelExchange);
-    }
-}
diff --git a/src/test/java/org/onap/clamp/clds/client/req/policy/GuardPolicyAttributesConstructorTest.java b/src/test/java/org/onap/clamp/clds/client/req/policy/GuardPolicyAttributesConstructorTest.java
deleted file mode 100644 (file)
index 3178580..0000000
+++ /dev/null
@@ -1,85 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * ONAP CLAMP
- * ================================================================================
- * Copyright (C) 2018 Nokia Intellectual Property. All rights
- *                             reserved.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END============================================
- * ===================================================================
- *
- */
-
-package org.onap.clamp.clds.client.req.policy;
-
-import java.io.IOException;
-import java.util.List;
-import java.util.Map;
-
-import org.assertj.core.api.Assertions;
-import org.junit.Before;
-import org.junit.Test;
-import org.onap.clamp.clds.model.properties.ModelProperties;
-import org.onap.clamp.clds.model.properties.Policy;
-import org.onap.clamp.clds.model.properties.PolicyChain;
-import org.onap.clamp.clds.model.properties.PolicyItem;
-import org.onap.clamp.clds.util.ResourceFileUtil;
-import org.onap.policy.api.AttributeType;
-import org.onap.policy.controlloop.policy.builder.BuilderException;
-
-public class GuardPolicyAttributesConstructorTest {
-
-    private static final String CONTROL_NAME = "ClosedLoop-d4629aee-970f-11e8-86c9-02552dda865e";
-    private ModelProperties modelProperties;
-    private List<PolicyChain> policyChains;
-
-    /**
-     * @throws Exception thrown if resources not found.
-     */
-    @Before
-    public void setUp() throws Exception {
-        String modelProp = ResourceFileUtil
-            .getResourceAsString("example/model-properties/tca_new/model-properties.json");
-        String modelBpmnJson = ResourceFileUtil.getResourceAsString("example/model-properties/tca_new/model-bpmn.json");
-        modelProperties = new ModelProperties("CLAMPDemoVFW_v1_0_3af8daec-6f10-4027-a3540", CONTROL_NAME, "PUT", false,
-            modelBpmnJson, modelProp);
-
-        policyChains = modelProperties.getType(Policy.class).getPolicyChains();
-    }
-
-    @Test
-    public void testRequestAttributes() throws IOException, BuilderException {
-        List<PolicyItem> policyItemsList = GuardPolicyAttributesConstructor
-            .getAllPolicyGuardsFromPolicyChain(policyChains.get(0));
-
-        Assertions.assertThat(policyItemsList.size()).isEqualTo(1);
-
-        // Test first entry
-        Map<AttributeType, Map<String, String>> requestAttributes = GuardPolicyAttributesConstructor
-            .formatAttributes(modelProperties, policyItemsList.get(0));
-
-        Assertions.assertThat(requestAttributes).containsKeys(AttributeType.MATCHING);
-        Map<String, String> ruleParameters = requestAttributes.get(AttributeType.MATCHING);
-        Assertions.assertThat(ruleParameters).contains(Assertions.entry(GuardPolicyAttributesConstructor.ACTOR, "APPC"),
-            Assertions.entry(GuardPolicyAttributesConstructor.RECIPE, "restart"),
-            Assertions.entry(GuardPolicyAttributesConstructor.TARGETS, ".*"),
-            Assertions.entry(GuardPolicyAttributesConstructor.CLNAME,
-                modelProperties.getControlNameAndPolicyUniqueId()),
-            Assertions.entry(GuardPolicyAttributesConstructor.LIMIT, "1"),
-            Assertions.entry(GuardPolicyAttributesConstructor.TIME_WINDOW, "10"),
-            Assertions.entry(GuardPolicyAttributesConstructor.TIME_UNITS, "minute"),
-            Assertions.entry(GuardPolicyAttributesConstructor.GUARD_ACTIVE_START, "00:00:01-05:00"),
-            Assertions.entry(GuardPolicyAttributesConstructor.GUARD_ACTIVE_END, "00:00:00-05:00"));
-    }
-}
diff --git a/src/test/java/org/onap/clamp/clds/client/req/policy/OperationalPolicyAttributesConstructorTest.java b/src/test/java/org/onap/clamp/clds/client/req/policy/OperationalPolicyAttributesConstructorTest.java
deleted file mode 100644 (file)
index 4d78cf8..0000000
+++ /dev/null
@@ -1,147 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * ONAP CLAMP
- * ================================================================================
- * Copyright (C) 2018 Nokia Intellectual Property. All rights
- *                             reserved.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END============================================
- * ===================================================================
- *
- */
-
-package org.onap.clamp.clds.client.req.policy;
-
-import com.google.common.collect.ImmutableMap;
-import com.google.gson.JsonElement;
-import java.io.IOException;
-import java.net.URLDecoder;
-import java.util.Map;
-import org.assertj.core.api.Assertions;
-import org.junit.Before;
-import org.junit.Test;
-import org.mockito.Matchers;
-import org.mockito.Mockito;
-import org.onap.clamp.clds.config.ClampProperties;
-import org.onap.clamp.clds.model.properties.ModelProperties;
-import org.onap.clamp.clds.model.properties.PolicyChain;
-import org.onap.clamp.clds.util.JsonUtils;
-import org.onap.clamp.clds.util.ResourceFileUtil;
-import org.onap.policy.api.AttributeType;
-import org.onap.policy.controlloop.policy.ControlLoopPolicy;
-import org.onap.policy.controlloop.policy.Policy;
-import org.onap.policy.controlloop.policy.Target;
-import org.onap.policy.controlloop.policy.TargetType;
-import org.onap.policy.controlloop.policy.builder.BuilderException;
-import org.yaml.snakeyaml.Yaml;
-
-public class OperationalPolicyAttributesConstructorTest {
-
-    private static final String CONTROL_NAME = "ClosedLoop-d4629aee-970f-11e8-86c9-02552dda865e";
-    private ModelProperties modelProperties;
-    private PolicyChain policyChain;
-
-    /**
-     * @throws Exception thrown if resource not found.
-     */
-    @Before
-    public void setUp() throws Exception {
-        String modelProp = ResourceFileUtil
-            .getResourceAsString("example/model-properties/policy/modelBpmnProperties.json");
-        modelProperties = new ModelProperties("CLAMPDemoVFW_v1_0_3af8daec-6f10-4027-a3540", CONTROL_NAME, "PUT", false,
-            "{}", modelProp);
-        policyChain = readPolicyChainFromResources();
-    }
-
-    @Test
-    public void shouldFormatRequestAttributes() throws IOException, BuilderException {
-        // given
-        ClampProperties mockClampProperties = createMockClampProperties(ImmutableMap.<String, String>builder()
-            .put("op.templateName", "ClosedLoopControlName").put("op.notificationTopic", "POLICY-CL-MGT")
-            .put("op.controller", "amsterdam").put("op.recipeTopic", "APPC").build());
-
-        // when
-        Map<AttributeType, Map<String, String>> requestAttributes = OperationalPolicyAttributesConstructor
-            .formatAttributes(mockClampProperties, modelProperties, "789875c1-e788-432f-9a76-eac8ed889734",
-                policyChain);
-        // then
-        Assertions.assertThat(requestAttributes).containsKeys(AttributeType.MATCHING, AttributeType.RULE);
-        Assertions.assertThat(requestAttributes.get(AttributeType.MATCHING))
-            .contains(Assertions.entry(OperationalPolicyAttributesConstructor.CONTROLLER, "amsterdam"));
-
-        Map<String, String> ruleParameters = requestAttributes.get(AttributeType.RULE);
-        Assertions.assertThat(ruleParameters).containsExactly(
-            Assertions.entry(OperationalPolicyAttributesConstructor.MAX_RETRIES, "3"),
-            Assertions.entry(OperationalPolicyAttributesConstructor.TEMPLATE_NAME, "ClosedLoopControlName"),
-            Assertions.entry(OperationalPolicyAttributesConstructor.NOTIFICATION_TOPIC, "POLICY-CL-MGT"),
-            Assertions.entry(OperationalPolicyAttributesConstructor.RECIPE_TOPIC, "APPC"),
-            Assertions.entry(OperationalPolicyAttributesConstructor.RECIPE, "healthCheck"),
-            Assertions.entry(OperationalPolicyAttributesConstructor.RESOURCE_ID,
-                "cdb69724-57d5-4a22-b96c-4c345150fd0e"),
-            Assertions.entry(OperationalPolicyAttributesConstructor.RETRY_TIME_LIMIT, "180"),
-            Assertions.entry(OperationalPolicyAttributesConstructor.CLOSED_LOOP_CONTROL_NAME, CONTROL_NAME + "_1"));
-    }
-
-    @Test
-    public void shouldFormatRequestAttributesWithProperControlLoopYaml() throws IOException, BuilderException {
-        // given
-        ClampProperties mockClampProperties = createMockClampProperties(
-            ImmutableMap.<String, String>builder().put("op.templateName", "ClosedLoopControlName")
-                .put("op.operationTopic", "APPP-CL").put("op.notificationTopic", "POLICY-CL-MGT")
-                .put("op.controller", "amsterdam").put("op.recipeTopic", "APPC").build());
-
-        Policy expectedPolicy = new Policy("6f76ad0b-ea9d-4a92-8d7d-6a6367ce2c77", "healthCheck Policy",
-            "healthCheck Policy - the trigger (no parent) policy - created by CLDS", "APPC", null,
-            new Target(TargetType.VM, "cdb69724-57d5-4a22-b96c-4c345150fd0e"), "healthCheck", 3, 180);
-
-        // when
-        Map<AttributeType, Map<String, String>> requestAttributes = OperationalPolicyAttributesConstructor
-            .formatAttributes(mockClampProperties, modelProperties, "789875c1-e788-432f-9a76-eac8ed889734",
-                policyChain);
-
-        // then
-        Assertions.assertThat(requestAttributes).containsKeys(AttributeType.MATCHING, AttributeType.RULE);
-        Assertions.assertThat(requestAttributes.get(AttributeType.MATCHING))
-            .contains(Assertions.entry("controller", "amsterdam"));
-
-        Map<String, String> ruleParameters = requestAttributes.get(AttributeType.RULE);
-        Assertions.assertThat(ruleParameters).contains(
-            Assertions.entry(OperationalPolicyAttributesConstructor.OPERATION_TOPIC, "APPP-CL"),
-            Assertions.entry(OperationalPolicyAttributesConstructor.TEMPLATE_NAME, "ClosedLoopControlName"),
-            Assertions.entry(OperationalPolicyAttributesConstructor.NOTIFICATION_TOPIC, "POLICY-CL-MGT"),
-            Assertions.entry(OperationalPolicyAttributesConstructor.CLOSED_LOOP_CONTROL_NAME, CONTROL_NAME + "_1"));
-
-        String controlLoopYaml = URLDecoder
-            .decode(ruleParameters.get(OperationalPolicyAttributesConstructor.CONTROL_LOOP_YAML), "UTF-8");
-        ControlLoopPolicy controlLoopPolicy = new Yaml().load(controlLoopYaml);
-
-        Assertions.assertThat(controlLoopPolicy.getControlLoop().getControlLoopName()).isEqualTo(CONTROL_NAME);
-        Assertions.assertThat(controlLoopPolicy.getPolicies()).usingElementComparatorIgnoringFields("id")
-            .containsExactly(expectedPolicy);
-    }
-
-    private ClampProperties createMockClampProperties(ImmutableMap<String, String> propertiesMap) {
-        ClampProperties props = Mockito.mock(ClampProperties.class);
-        propertiesMap.forEach((property, value) -> Mockito
-            .when(props.getStringValue(Matchers.matches(property), Matchers.any())).thenReturn(value));
-        return props;
-    }
-
-    private PolicyChain readPolicyChainFromResources() throws IOException {
-        String policyChainText = ResourceFileUtil
-            .getResourceAsString("example/operational-policy/json-policy-chain.json");
-        JsonElement policyChainNode = JsonUtils.GSON.fromJson(policyChainText, JsonElement.class);
-        return new PolicyChain(policyChainNode);
-    }
-}
diff --git a/src/test/java/org/onap/clamp/clds/client/req/policy/OperationalPolicyYamlFormatterTest.java b/src/test/java/org/onap/clamp/clds/client/req/policy/OperationalPolicyYamlFormatterTest.java
deleted file mode 100644 (file)
index 662beb2..0000000
+++ /dev/null
@@ -1,64 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * ONAP CLAMP
- * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights
- *                             reserved.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END============================================
- * Modifications copyright (c) 2018 Nokia
- * ===================================================================
- *
- */
-
-package org.onap.clamp.clds.client.req.policy;
-
-import java.util.Arrays;
-import java.util.List;
-
-import org.assertj.core.api.Assertions;
-import org.junit.Test;
-import org.onap.policy.controlloop.policy.PolicyResult;
-import org.onap.policy.sdc.Resource;
-import org.onap.policy.sdc.ResourceType;
-
-public class OperationalPolicyYamlFormatterTest {
-
-    @Test
-    public void shouldConvertGivenStringsToResourceObjects() throws SecurityException, IllegalArgumentException {
-
-        // given
-        List<String> stringList = Arrays.asList("test1", "test2", "test3", "test4");
-
-        // when
-        Resource[] resources = OperationalPolicyYamlFormatter.convertToResources(stringList, ResourceType.VF);
-
-        // then
-        Assertions.assertThat(resources).extracting(Resource::getResourceName).containsExactly("test1", "test2",
-            "test3", "test4");
-    }
-
-    @Test
-    public void shouldConvertGivenStringsToPolicyResults() throws SecurityException, IllegalArgumentException {
-        // given
-        List<String> stringList = Arrays.asList("FAILURE", "SUCCESS", "FAILURE_GUARD", "FAILURE_TIMEOUT");
-
-        // when
-        PolicyResult[] policyResults = OperationalPolicyYamlFormatter.convertToPolicyResults(stringList);
-
-        // then
-        Assertions.assertThat(policyResults).containsExactly(PolicyResult.FAILURE, PolicyResult.SUCCESS,
-            PolicyResult.FAILURE_GUARD, PolicyResult.FAILURE_TIMEOUT);
-    }
-}
\ No newline at end of file
diff --git a/src/test/java/org/onap/clamp/clds/client/req/tca/TcaRequestFormatterTest.java b/src/test/java/org/onap/clamp/clds/client/req/tca/TcaRequestFormatterTest.java
deleted file mode 100644 (file)
index 429611c..0000000
+++ /dev/null
@@ -1,116 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * ONAP CLAMP
- * ================================================================================
- * Copyright (C) 2019 Nokia Intellectual Property. All rights
- *                             reserved.
- * ================================================================================
- * Modifications Copyright (c) 2019 Samsung
- * ================================================================================
- * 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.client.req.tca;
-
-import static org.assertj.core.api.Assertions.assertThat;
-import static org.mockito.Matchers.any;
-import static org.mockito.Mockito.mock;
-import static org.mockito.Mockito.when;
-
-import com.google.gson.JsonObject;
-import java.io.IOException;
-import org.junit.Test;
-import org.mockito.Mockito;
-import org.onap.clamp.clds.config.ClampProperties;
-import org.onap.clamp.clds.exception.TcaRequestFormatterException;
-import org.onap.clamp.clds.model.properties.ModelProperties;
-import org.onap.clamp.clds.model.properties.Tca;
-import org.onap.clamp.clds.model.properties.TcaItem;
-import org.onap.clamp.clds.util.JsonUtils;
-
-public class TcaRequestFormatterTest {
-
-    private static final String TCA_POLICY_PROPERTIES_TEMPLATE = "{"
-        + " \"domain\": \"measurementsForVfScaling\","
-        + " \"metricsPerEventName\": ["
-        + "  {"
-        + "   \"eventName\": \"???\","
-        + "   \"controlLoopSchemaType\": \"VNF\","
-        + "   \"policyScope\": \"DCAE\","
-        + "   \"policyName\": \"???\","
-        + "   \"policyVersion\": \"v0.0.1\","
-        + "   \"thresholds\": ["
-        + "   ]"
-        + "  }"
-        + " ]"
-        + "}";
-
-    @Test
-    public void shouldReturnFormattedTcaPolicyRequest() throws IOException {
-        //given
-        String service = "TestService";
-        String policy = "TestService_scope.PolicyName";
-        ClampProperties clampProperties = mock(ClampProperties.class);
-        String expectedRequestText = 
-            "{ "
-            + " \"domain\": \"measurementsForVfScaling\", "
-            + " \"metricsPerEventName\": [ "
-            + "  { "
-            + "   \"eventName\": \"vLoadBalancer\", "
-            + "   \"controlLoopSchemaType\": \"VNF\", "
-            + "   \"policyScope\": \"DCAE\", "
-            + "   \"policyName\": \"TestService_scope.PolicyName\", "
-            + "   \"policyVersion\": \"v0.0.1\", "
-            + "   \"thresholds\": [] "
-            + "  } "
-            + " ] "
-            + "}";
-    
-        JsonObject tcaPolicyPropertiesTemplate = JsonUtils.GSON
-            .fromJson(TCA_POLICY_PROPERTIES_TEMPLATE, JsonObject.class);
-
-        JsonObject expectedRequest = JsonUtils.GSON.fromJson(expectedRequestText, JsonObject.class);
-
-        ModelProperties modelProperties = mock(ModelProperties.class);
-        Tca tca = mock(Tca.class);
-        TcaItem tcaItem = mock(TcaItem.class);
-        when(clampProperties.getJsonTemplate(any(), any())).thenReturn(tcaPolicyPropertiesTemplate);
-        when(tca.getTcaItem()).thenReturn(tcaItem);
-        when(tcaItem.getEventName()).thenReturn("vLoadBalancer");
-        when(tcaItem.getControlLoopSchemaType()).thenReturn("VNF");
-
-        //when
-        JsonObject policyContent = TcaRequestFormatter
-            .createPolicyContent(clampProperties, modelProperties, service, policy, tca);
-
-        //then
-        assertThat(expectedRequest).isEqualTo(policyContent);
-    }
-
-    @Test(expected = TcaRequestFormatterException.class)
-    public void shouldThrowTcaRequestFormatterException() throws IOException {
-        //given
-        String service = "TestService";
-        String policy = "TestService_scope.PolicyName";
-        ClampProperties clampProperties =  mock(ClampProperties.class);
-        ModelProperties modelProperties = mock(ModelProperties.class);
-        Tca tca = mock(Tca.class);
-        //when
-        Mockito.when(clampProperties.getJsonTemplate(any(), any())).thenThrow(IOException.class);
-        //then
-        TcaRequestFormatter.createPolicyContent(clampProperties, modelProperties, service, policy, tca);
-    }
-}
diff --git a/src/test/java/org/onap/clamp/clds/it/CldsDaoItCase.java b/src/test/java/org/onap/clamp/clds/it/CldsDaoItCase.java
deleted file mode 100644 (file)
index 65ab4c5..0000000
+++ /dev/null
@@ -1,145 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * ONAP CLAMP
- * ================================================================================
- * Copyright (C) 2017-2019 AT&T Intellectual Property. All rights
- *                             reserved.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END============================================
- * ===================================================================
- *
- */
-
-package org.onap.clamp.clds.it;
-
-import static org.junit.Assert.assertEquals;
-
-import com.att.eelf.configuration.EELFLogger;
-import com.att.eelf.configuration.EELFManager;
-
-import java.io.IOException;
-
-import javax.ws.rs.NotFoundException;
-
-import org.apache.commons.lang3.RandomStringUtils;
-import org.junit.Before;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.onap.clamp.clds.dao.CldsDao;
-import org.onap.clamp.clds.model.CldsEvent;
-import org.onap.clamp.clds.model.CldsModel;
-import org.onap.clamp.clds.model.CldsTemplate;
-import org.onap.clamp.clds.util.ResourceFileUtil;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.boot.test.context.SpringBootTest;
-import org.springframework.test.context.junit4.SpringRunner;
-
-/**
- * Test CldsDAO calls through CldsModel and CldsEvent. This really test the DB
- * and stored procedures.
- */
-@RunWith(SpringRunner.class)
-@SpringBootTest
-public class CldsDaoItCase {
-
-    protected static final EELFLogger logger = EELFManager.getInstance().getLogger(CldsDaoItCase.class);
-    @Autowired
-    public CldsDao cldsDao;
-    private String bpmnText;
-    private String imageText;
-    private String bpmnPropText;
-
-    /**
-     * Setup the variable before the tests execution.
-     *
-     * @throws IOException In case of issues when opening the files
-     */
-    @Before
-    public void setupBefore() throws IOException {
-        bpmnText = ResourceFileUtil.getResourceAsString("example/dao/bpmn-template.xml");
-        imageText = ResourceFileUtil.getResourceAsString("example/dao/image-template.xml");
-        bpmnPropText = ResourceFileUtil.getResourceAsString("example/dao/bpmn-prop.json");
-    }
-
-    @Test
-    public void testModelSave() {
-        String randomNameTemplate = RandomStringUtils.randomAlphanumeric(5);
-        // Add the template first
-        CldsTemplate newTemplate = new CldsTemplate();
-        newTemplate.setName(randomNameTemplate);
-        newTemplate.setBpmnText(bpmnText);
-        newTemplate.setImageText(imageText);
-        // Save the template in DB
-        cldsDao.setTemplate(newTemplate, "user");
-        // Test if it's well there
-        CldsTemplate newTemplateRead = cldsDao.getTemplate(randomNameTemplate);
-        assertEquals(bpmnText, newTemplateRead.getBpmnText());
-        assertEquals(imageText, newTemplateRead.getImageText());
-        // Save the model
-        CldsModel newModel = new CldsModel();
-        String randomNameModel = RandomStringUtils.randomAlphanumeric(5);
-        newModel.setName(randomNameModel);
-        newModel.setBpmnText(bpmnText);
-        newModel.setImageText(imageText);
-        newModel.setPropText(bpmnPropText);
-        newModel.setControlNamePrefix("ClosedLoop-");
-        newModel.setTemplateName(randomNameTemplate);
-        newModel.setTemplateId(newTemplate.getId());
-        newModel.setDocText(newTemplate.getPropText());
-        // Save the model in DB
-        cldsDao.setModel(newModel, "user");
-        // Test if the model can be retrieved
-        CldsModel newCldsModel = cldsDao.getModelTemplate(randomNameModel);
-        assertEquals(bpmnText, newCldsModel.getBpmnText());
-        assertEquals(imageText, newCldsModel.getImageText());
-        assertEquals(bpmnPropText, newCldsModel.getPropText());
-    }
-
-    @Test(expected = NotFoundException.class)
-    public void testGetModelNotFound() {
-        CldsModel.retrieve(cldsDao, "test-model-not-found", false);
-    }
-
-    @Test(expected = NotFoundException.class)
-    public void testGetTemplateNotFound() {
-        CldsTemplate.retrieve(cldsDao, "test-template-not-found", false);
-    }
-
-    @Test
-    public void testInsEvent() {
-        // Add the template first
-        CldsTemplate newTemplate = new CldsTemplate();
-        newTemplate.setName("test-template-for-event");
-        newTemplate.setBpmnText(bpmnText);
-        newTemplate.setImageText(imageText);
-        newTemplate.save(cldsDao, "user");
-        // Test if it's well there
-        CldsTemplate newTemplateRead = CldsTemplate.retrieve(cldsDao, "test-template-for-event", false);
-        assertEquals(bpmnText, newTemplateRead.getBpmnText());
-        assertEquals(imageText, newTemplateRead.getImageText());
-        // Save the model
-        CldsModel newModel = new CldsModel();
-        newModel.setName("test-model-for-event");
-        newModel.setBpmnText(bpmnText);
-        newModel.setImageText(imageText);
-        newModel.setPropText(bpmnPropText);
-        newModel.setControlNamePrefix("ClosedLoop-");
-        newModel.setTemplateName("test-template-for-event");
-        newModel.setTemplateId(newTemplate.getId());
-        newModel.setDocText(newTemplate.getPropText());
-        CldsEvent.insEvent(cldsDao, newModel, "user", CldsEvent.ACTION_RESTART, CldsEvent.ACTION_STATE_COMPLETED,
-                "process-instance-id");
-    }
-
-}
index 963f45b..8745cc5 100644 (file)
@@ -41,7 +41,6 @@ import org.junit.Test;
 import org.junit.runner.RunWith;
 import org.mockito.Matchers;
 import org.mockito.Mockito;
-import org.onap.clamp.clds.dao.CldsDao;
 import org.onap.clamp.clds.model.CldsInfo;
 import org.onap.clamp.clds.service.CldsService;
 import org.onap.clamp.clds.util.LoggingUtils;
@@ -72,8 +71,6 @@ public class CldsServiceItCase {
     private String bpmnPropText;
     private String docText;
 
-    @Autowired
-    private CldsDao cldsDao;
     private Authentication authentication;
     private List<GrantedAuthority> authList = new LinkedList<GrantedAuthority>();
     private LoggingUtils util;
diff --git a/src/test/java/org/onap/clamp/clds/it/HolmesPolicyDelegateItCase.java b/src/test/java/org/onap/clamp/clds/it/HolmesPolicyDelegateItCase.java
deleted file mode 100644 (file)
index 439ec7f..0000000
+++ /dev/null
@@ -1,57 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * ONAP CLAMP
- * ================================================================================
- * Copyright (C) 2017-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.it;
-
-import static org.junit.Assert.assertTrue;
-
-import java.io.IOException;
-
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.onap.clamp.clds.client.HolmesPolicyDelegate;
-import org.onap.clamp.clds.model.properties.Holmes;
-import org.onap.clamp.clds.model.properties.ModelProperties;
-import org.onap.clamp.clds.util.ResourceFileUtil;
-import org.springframework.boot.test.context.SpringBootTest;
-import org.springframework.test.context.junit4.SpringRunner;
-
-/**
- * Test Onap HolmesPolicyDelegate features.
- */
-@RunWith(SpringRunner.class)
-@SpringBootTest
-public class HolmesPolicyDelegateItCase {
-
-    @Test
-    public void testCreatePolicyJson() throws IOException {
-        String modelBpmnProp = ResourceFileUtil
-                .getResourceAsString("example/model-properties/holmes/modelBpmnProperties.json");
-        String modelBpmn = ResourceFileUtil.getResourceAsString("example/model-properties/holmes/modelBpmn.json");
-        ModelProperties prop = new ModelProperties("example-model-name",
-                "ClosedLoop_FRWL_SIG_fad4dcae_e498_11e6_852e_0050568c4ccf", null, true, modelBpmn, modelBpmnProp);
-        Holmes holmes = prop.getType(Holmes.class);
-        String result = HolmesPolicyDelegate.formatHolmesConfigBody(prop, holmes);
-        assertTrue("ClosedLoop_FRWL_SIG_fad4dcae_e498_11e6_852e_0050568c4ccf$$$blabla".equals(result));
-    }
-}
diff --git a/src/test/java/org/onap/clamp/clds/it/OperationPolicyReqItCase.java b/src/test/java/org/onap/clamp/clds/it/OperationPolicyReqItCase.java
deleted file mode 100644 (file)
index 344641a..0000000
+++ /dev/null
@@ -1,99 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * ONAP CLAMP
- * ================================================================================
- * Copyright (C) 2017-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============================================
- * Modifications copyright (c) 2018 Nokia
- * ===================================================================
- *
- */
-
-package org.onap.clamp.clds.it;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertTrue;
-
-import java.io.IOException;
-import java.net.URLDecoder;
-import java.util.ArrayList;
-import java.util.List;
-import java.util.Map;
-
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.onap.clamp.clds.client.req.policy.OperationalPolicyAttributesConstructor;
-import org.onap.clamp.clds.config.ClampProperties;
-import org.onap.clamp.clds.model.CldsEvent;
-import org.onap.clamp.clds.model.properties.ModelProperties;
-import org.onap.clamp.clds.model.properties.Policy;
-import org.onap.clamp.clds.model.properties.PolicyChain;
-import org.onap.clamp.clds.util.ResourceFileUtil;
-import org.onap.policy.api.AttributeType;
-import org.onap.policy.controlloop.policy.builder.BuilderException;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.boot.test.context.SpringBootTest;
-import org.springframework.test.context.junit4.SpringRunner;
-
-@RunWith(SpringRunner.class)
-@SpringBootTest
-public class OperationPolicyReqItCase {
-
-    @Autowired
-    private ClampProperties refProp;
-
-    @Test
-    public void formatAttributesTest() throws IOException, BuilderException {
-        String modelBpmnProp = ResourceFileUtil
-            .getResourceAsString("example/model-properties/policy/modelBpmnProperties.json");
-        String modelBpmn = ResourceFileUtil.getResourceAsString("example/model-properties/policy/modelBpmn.json");
-        ModelProperties modelProperties = new ModelProperties("testModel", "controlNameTest", CldsEvent.ACTION_SUBMIT,
-            true, modelBpmn, modelBpmnProp);
-        List<Map<AttributeType, Map<String, String>>> attributes = new ArrayList<>();
-        if (modelProperties.getType(Policy.class).isFound()) {
-            for (PolicyChain policyChain : modelProperties.getType(Policy.class).getPolicyChains()) {
-                attributes.add(OperationalPolicyAttributesConstructor.formatAttributes(refProp, modelProperties,
-                    modelProperties.getType(Policy.class).getId(), policyChain));
-            }
-        }
-        assertFalse(attributes.isEmpty());
-        assertTrue(attributes.size() == 2);
-        // now validate the Yaml, to do so we replace the dynamic ID by a known
-        // key so that we can compare it
-        String yaml = URLDecoder.decode(attributes.get(0).get(AttributeType.RULE).get("controlLoopYaml"), "UTF-8");
-        yaml = replaceGeneratedValues(yaml);
-        assertEquals(ResourceFileUtil.getResourceAsString("example/operational-policy/yaml-policy-chain-1.yaml"), yaml);
-        yaml = URLDecoder.decode(attributes.get(1).get(AttributeType.RULE).get("controlLoopYaml"), "UTF-8");
-        yaml = replaceGeneratedValues(yaml);
-        assertEquals(ResourceFileUtil.getResourceAsString("example/operational-policy/yaml-policy-chain-2.yaml"), yaml);
-    }
-
-    private String replaceGeneratedValues(String yaml) {
-        yaml = yaml.replaceAll("Policy - created" + System.lineSeparator() + "    by CLDS", "Policy - created by CLDS");
-        yaml = yaml.replaceAll("trigger_policy: (.*)", "trigger_policy: <generatedId>");
-        yaml = yaml.replaceAll("id: (.*)", "id: <generatedId>");
-        yaml = yaml.replaceAll("success: (.*)", "success: <generatedId>");
-        // Remove this field as not always present (depends of policy api)
-        yaml = yaml.replaceAll("  pnf: null" + System.lineSeparator(), "");
-        yaml = yaml.replaceAll("failure: (.*)", "failure: <generatedId>");
-        yaml = yaml.replaceAll("failure_exception: (.*)", "failure_exception: <generatedId>");
-        yaml = yaml.replaceAll("failure_retries: (.*)", "failure_retries: <generatedId>");
-        yaml = yaml.replaceAll("failure_timeout: (.*)", "failure_timeout: <generatedId>");
-        yaml = yaml.substring(yaml.indexOf("controlLoop:"), yaml.length());
-        return yaml;
-    }
-}
diff --git a/src/test/java/org/onap/clamp/clds/it/PolicyClientItCase.java b/src/test/java/org/onap/clamp/clds/it/PolicyClientItCase.java
deleted file mode 100644 (file)
index 3acc439..0000000
+++ /dev/null
@@ -1,284 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * ONAP CLAMP
- * ================================================================================
- * Copyright (C) 2017-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============================================
- * Modifications copyright (c) 2018 Nokia
- * ===================================================================
- *
- */
-
-package org.onap.clamp.clds.it;
-
-import com.google.gson.reflect.TypeToken;
-import java.io.IOException;
-import java.lang.reflect.Type;
-import java.util.List;
-import java.util.Map;
-
-import javax.xml.transform.TransformerException;
-
-import org.assertj.core.api.Assertions;
-import org.junit.Before;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.onap.clamp.clds.client.req.policy.GuardPolicyAttributesConstructor;
-import org.onap.clamp.clds.client.req.policy.OperationalPolicyAttributesConstructor;
-import org.onap.clamp.clds.client.req.policy.PolicyClient;
-import org.onap.clamp.clds.client.req.tca.TcaRequestFormatter;
-import org.onap.clamp.clds.config.ClampProperties;
-import org.onap.clamp.clds.dao.CldsDao;
-import org.onap.clamp.clds.model.CldsEvent;
-import org.onap.clamp.clds.model.CldsToscaModel;
-import org.onap.clamp.clds.model.properties.ModelProperties;
-import org.onap.clamp.clds.model.properties.Policy;
-import org.onap.clamp.clds.model.properties.PolicyItem;
-import org.onap.clamp.clds.model.properties.Tca;
-import org.onap.clamp.clds.transform.XslTransformer;
-import org.onap.clamp.clds.util.JsonUtils;
-import org.onap.clamp.clds.util.LoggingUtils;
-import org.onap.clamp.clds.util.ResourceFileUtil;
-import org.onap.policy.api.AttributeType;
-import org.onap.policy.api.PolicyConfigType;
-import org.onap.policy.api.PolicyType;
-import org.onap.policy.controlloop.policy.builder.BuilderException;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.boot.test.context.SpringBootTest;
-import org.springframework.test.context.junit4.SpringRunner;
-
-/**
- * Test Policy API, this uses the emulator written in python that is started
- * during the tests, It returns the payload sent in the policy queries so that
- * it can be validated here.
- */
-@RunWith(SpringRunner.class)
-@SpringBootTest
-public class PolicyClientItCase {
-
-    private static final Type MAP_OF_STRING_TO_OBJECT_TYPE = new TypeToken<Map<String, Object>>() {}.getType();
-
-    @Autowired
-    private CldsDao cldsDao;
-    @Autowired
-    private ClampProperties refProp;
-    @Autowired
-    private PolicyClient policyClient;
-    @Autowired
-    XslTransformer cldsBpmnTransformer;
-
-    String modelProp;
-    String modelName;
-    String controlName;
-    String modelBpmnPropJson;
-    ModelProperties prop;
-
-    /**
-     * Setup method.
-     * @throws IOException thrown if resources not found
-     * @throws TransformerException thrown if invalid xml given to transformation
-     */
-    @Before
-    public void setUp() throws IOException, TransformerException {
-        modelProp = ResourceFileUtil.getResourceAsString("example/model-properties/tca_new/model-properties.json");
-        modelName = "example-model06";
-        controlName = "ClosedLoop_FRWL_SIG_fad4dcae_e498_11e6_852e_0050568c4ccf";
-        modelBpmnPropJson = cldsBpmnTransformer.doXslTransformToString(
-            ResourceFileUtil.getResourceAsString("example/model-properties/tca_new/tca-template.xml"));
-        prop = new ModelProperties(modelName, controlName, CldsEvent.ACTION_SUBMIT, false, modelBpmnPropJson,
-            modelProp);
-    }
-
-    @Test
-    public void testSendGuardPolicy() {
-        // Normally there is only one Guard
-        List<PolicyItem> policyItems = GuardPolicyAttributesConstructor
-            .getAllPolicyGuardsFromPolicyChain(prop.getType(Policy.class).getPolicyChains().get(0));
-        PolicyItem policyItem = policyItems.get(0);
-        prop.setCurrentModelElementId(prop.getType(Policy.class).getId());
-        prop.setPolicyUniqueId(prop.getType(Policy.class).getPolicyChains().get(0).getPolicyId());
-        prop.setGuardUniqueId(policyItem.getId());
-        String response = policyClient.sendGuardPolicy(
-            GuardPolicyAttributesConstructor.formatAttributes(prop, policyItem), prop, LoggingUtils.getRequestId(),
-            policyItem);
-        Map<String, Object> mapNodes = JsonUtils.GSON.fromJson(response, MAP_OF_STRING_TO_OBJECT_TYPE);
-        Assertions.assertThat(mapNodes).contains(Assertions.entry("policyClass", "Decision"),
-            Assertions.entry("policyName",
-                modelName.replace("-", "_") + "." + controlName + "_Policy_12lup3h_0_Guard_6TtHGPq"),
-            Assertions.entry("policyDescription", "from clds"), Assertions.entry("onapName", "PDPD"),
-            Assertions.entry("requestID", LoggingUtils.getRequestId()), Assertions.entry("ruleProvider", "GUARD_YAML"));
-
-        // Check Guard attributes
-        Assertions.assertThat((Map<String, Object>) mapNodes.get("attributes"))
-            .containsKey(AttributeType.MATCHING.name());
-        Assertions.assertThat(
-            (Map<String, Object>) ((Map<String, Object>) mapNodes.get("attributes")).get(AttributeType.MATCHING.name()))
-            .contains(Assertions.entry(GuardPolicyAttributesConstructor.ACTOR, "APPC"),
-                Assertions.entry(GuardPolicyAttributesConstructor.CLNAME, controlName + "_0"),
-                Assertions.entry(GuardPolicyAttributesConstructor.TIME_WINDOW, "10"));
-    }
-
-    @Test
-    public void testSendBrmsPolicy() throws BuilderException, IllegalArgumentException, IOException {
-        Map<AttributeType, Map<String, String>> attributes = OperationalPolicyAttributesConstructor.formatAttributes(
-            refProp, prop, prop.getType(Policy.class).getId(), prop.getType(Policy.class).getPolicyChains().get(0));
-        String response = policyClient.sendBrmsPolicy(attributes, prop, LoggingUtils.getRequestId());
-
-        Map<String, Object> mapNodes = JsonUtils.GSON.fromJson(response, MAP_OF_STRING_TO_OBJECT_TYPE);
-
-        Assertions.assertThat(mapNodes).contains(Assertions.entry("policyClass", "Config"),
-            Assertions.entry("policyName", modelName.replace("-", "_") + "." + controlName + "_Policy_12lup3h_0"),
-            Assertions.entry("policyConfigType", PolicyConfigType.BRMS_PARAM.name()),
-            Assertions.entry("requestID", LoggingUtils.getRequestId()));
-
-        // Check BRMS attributes present
-        Assertions.assertThat((Map<String, Object>) mapNodes.get("attributes"))
-            .containsKeys(AttributeType.MATCHING.name(), AttributeType.RULE.name());
-
-    }
-
-    @Test
-    public void testSendMicroServiceInJson() throws IllegalArgumentException {
-        prop.setCurrentModelElementId(prop.getType(Policy.class).getId());
-        String jsonToSend = "{\"test\":\"test\"}";
-        String response = policyClient.sendMicroServiceInJson(jsonToSend, prop, LoggingUtils.getRequestId());
-
-        Map<String, Object> mapNodes = JsonUtils.GSON.fromJson(response, MAP_OF_STRING_TO_OBJECT_TYPE);
-
-        Assertions.assertThat(mapNodes).contains(Assertions.entry("policyClass", "Config"),
-            Assertions.entry("policyName", modelName.replace("-", "_") + "." + controlName + "_Policy_12lup3h"),
-            Assertions.entry("policyConfigType", PolicyConfigType.MicroService.name()),
-            Assertions.entry("requestID", LoggingUtils.getRequestId()),
-            Assertions.entry("configBodyType", PolicyType.JSON.name()), Assertions.entry("onapName", "DCAE"),
-            Assertions.entry("configBody", jsonToSend));
-
-    }
-
-    @Test
-    public void testSendBasePolicyInOther() throws IllegalArgumentException, IOException {
-        String body = "test";
-        String response = policyClient.sendBasePolicyInOther(body, "myPolicy", prop, LoggingUtils.getRequestId());
-        Map<String, Object> mapNodes = JsonUtils.GSON.fromJson(response, MAP_OF_STRING_TO_OBJECT_TYPE);
-
-        Assertions.assertThat(mapNodes).contains(Assertions.entry("policyClass", "Config"),
-            Assertions.entry("policyName", "myPolicy"),
-            Assertions.entry("policyConfigType", PolicyConfigType.Base.name()),
-            Assertions.entry("requestID", LoggingUtils.getRequestId()),
-            Assertions.entry("configBodyType", PolicyType.OTHER.name()), Assertions.entry("onapName", "DCAE"),
-            Assertions.entry("configBody", body));
-    }
-
-    @Test
-    public void testSendMicroServiceInOther() throws IllegalArgumentException, IOException {
-        Tca tca = prop.getType(Tca.class);
-        String tcaJson = TcaRequestFormatter.createPolicyJson(refProp, prop);
-        String response = policyClient.sendMicroServiceInOther(tcaJson, prop);
-
-        Map<String, Object> mapNodes = JsonUtils.GSON.fromJson(response, MAP_OF_STRING_TO_OBJECT_TYPE);
-
-        Assertions.assertThat(mapNodes).contains(Assertions.entry("policyClass", "Config"),
-            Assertions.entry("policyName", modelName.replace("-", "_") + "." + controlName + "_TCA_1d13unw"),
-            Assertions.entry("policyConfigType", PolicyConfigType.MicroService.name()),
-            Assertions.entry("configBody", tcaJson), Assertions.entry("onapName", "DCAE"));
-    }
-
-    @Test
-    public void testDeleteMicrosService() throws IllegalArgumentException, IOException {
-        Tca tca = prop.getType(Tca.class);
-        prop.setCurrentModelElementId(tca.getId());
-        String[] responses = policyClient.deleteMicrosService(prop).split("\\}\\{");
-
-        // There are 2 responses appended to the result, one for PDP one for PAP !
-        Map<String, Object> mapNodesPdp = JsonUtils.GSON.fromJson(responses[0] + "}",
-            MAP_OF_STRING_TO_OBJECT_TYPE);
-        Map<String, Object> mapNodesPap = JsonUtils.GSON.fromJson("{" + responses[1],
-            MAP_OF_STRING_TO_OBJECT_TYPE);
-
-        Assertions.assertThat(mapNodesPdp).contains(
-            Assertions.entry("policyName", modelName.replace("-", "_") + "." + controlName + "_TCA_1d13unw"),
-            Assertions.entry("policyType", PolicyConfigType.MicroService.name()),
-            Assertions.entry("policyComponent", "PDP"), Assertions.entry("deleteCondition", "ALL"));
-
-        Assertions.assertThat(mapNodesPap).contains(
-            Assertions.entry("policyName", modelName.replace("-", "_") + "." + controlName + "_TCA_1d13unw"),
-            Assertions.entry("policyType", PolicyConfigType.MicroService.name()),
-            Assertions.entry("policyComponent", "PAP"), Assertions.entry("deleteCondition", "ALL"));
-    }
-
-    @Test
-    public void testDeleteGuard() throws IllegalArgumentException, IOException {
-        List<PolicyItem> policyItems = GuardPolicyAttributesConstructor
-            .getAllPolicyGuardsFromPolicyChain(prop.getType(Policy.class).getPolicyChains().get(0));
-        prop.setCurrentModelElementId(prop.getType(Policy.class).getId());
-        prop.setPolicyUniqueId(prop.getType(Policy.class).getPolicyChains().get(0).getPolicyId());
-        prop.setGuardUniqueId(policyItems.get(0).getId());
-        String[] responses = policyClient.deleteGuard(prop).split("\\}\\{");
-
-        Map<String, Object> mapNodesPdp = JsonUtils.GSON.fromJson(responses[0] + "}",
-            MAP_OF_STRING_TO_OBJECT_TYPE);
-        Map<String, Object> mapNodesPap = JsonUtils.GSON.fromJson("{" + responses[1],
-            MAP_OF_STRING_TO_OBJECT_TYPE);
-
-        Assertions.assertThat(mapNodesPdp).contains(
-            Assertions.entry("policyName",
-                modelName.replace("-", "_") + "." + controlName + "_Policy_12lup3h_0_Guard_6TtHGPq"),
-            Assertions.entry("policyType", "Decision"), Assertions.entry("policyComponent", "PDP"),
-            Assertions.entry("deleteCondition", "ALL"));
-        Assertions.assertThat(mapNodesPap).contains(
-            Assertions.entry("policyName",
-                modelName.replace("-", "_") + "." + controlName + "_Policy_12lup3h_0_Guard_6TtHGPq"),
-            Assertions.entry("policyType", "Decision"), Assertions.entry("policyComponent", "PAP"),
-            Assertions.entry("deleteCondition", "ALL"));
-    }
-
-    @Test
-    public void testDeleteBrms() throws IllegalArgumentException, IOException {
-        prop.setPolicyUniqueId(prop.getType(Policy.class).getPolicyChains().get(0).getPolicyId());
-        prop.setCurrentModelElementId(prop.getType(Policy.class).getId());
-        String[] responses = policyClient.deleteBrms(prop).split("\\}\\{");
-
-        Map<String, Object> mapNodesPdp = JsonUtils.GSON.fromJson(responses[0] + "}",
-            MAP_OF_STRING_TO_OBJECT_TYPE);
-        Map<String, Object> mapNodesPap = JsonUtils.GSON.fromJson("{" + responses[1],
-            MAP_OF_STRING_TO_OBJECT_TYPE);
-
-        Assertions.assertThat(mapNodesPdp).contains(
-            Assertions.entry("policyName", modelName.replace("-", "_") + "." + controlName + "_Policy_12lup3h_0"),
-            Assertions.entry("policyType", "BRMS_Param"), Assertions.entry("policyComponent", "PDP"),
-            Assertions.entry("deleteCondition", "ALL"));
-        Assertions.assertThat(mapNodesPap).contains(
-            Assertions.entry("policyName", modelName.replace("-", "_") + "." + controlName + "_Policy_12lup3h_0"),
-            Assertions.entry("policyType", "BRMS_Param"), Assertions.entry("policyComponent", "PAP"),
-            Assertions.entry("deleteCondition", "ALL"));
-    }
-
-    @Test
-    public void testImportToscaModel() throws IOException {
-        String toscaModelYaml = ResourceFileUtil.getResourceAsString("tosca/tca-policy-test.yaml");
-        CldsToscaModel cldsToscaModel = new CldsToscaModel();
-        cldsToscaModel.setToscaModelName("tca-policy-test");
-        cldsToscaModel.setToscaModelYaml(toscaModelYaml);
-        cldsToscaModel.setUserId("admin");
-        cldsToscaModel.setPolicyType("tca");
-        cldsToscaModel = cldsToscaModel.save(cldsDao, refProp, policyClient, "test");
-        String tosca = policyClient.importToscaModel(cldsToscaModel);
-
-        Assertions.assertThat(tosca).contains(
-            "{\"serviceName\":\"tca-policy-test\",\"description\":\"tca-policy-test\","
-                + "\"requestID\":null,\"filePath\":\"/tmp/tosca-models/tca-policy-test.yml\",");
-        Assertions.assertThat(tosca).contains(toscaModelYaml);
-    }
-}
diff --git a/src/test/java/org/onap/clamp/clds/it/TcaRequestFormatterItCase.java b/src/test/java/org/onap/clamp/clds/it/TcaRequestFormatterItCase.java
deleted file mode 100644 (file)
index abc744e..0000000
+++ /dev/null
@@ -1,89 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * ONAP CLAMP
- * ================================================================================
- * Copyright (C) 2017-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.it;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-
-import java.io.IOException;
-
-import org.json.JSONException;
-import org.junit.Before;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.onap.clamp.clds.client.req.tca.TcaRequestFormatter;
-import org.onap.clamp.clds.config.ClampProperties;
-import org.onap.clamp.clds.model.CldsEvent;
-import org.onap.clamp.clds.model.properties.ModelProperties;
-import org.onap.clamp.clds.util.ResourceFileUtil;
-import org.skyscreamer.jsonassert.JSONAssert;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.boot.test.context.SpringBootTest;
-import org.springframework.test.context.junit4.SpringRunner;
-
-/**
- * Test Onap TcaRequestFormatter features.
- */
-@RunWith(SpringRunner.class)
-@SpringBootTest
-public class TcaRequestFormatterItCase {
-
-    @Autowired
-    private ClampProperties refProp;
-    private String modelProp;
-    private String modelBpmn;
-    private String modelName;
-    private String controlName;
-    private String yamlInput;
-    private ModelProperties modelProperties;
-
-    /**
-     * Initialize Test.
-     */
-    @Before
-    public void setUp() throws IOException {
-        modelProp = ResourceFileUtil.getResourceAsString("example/model-properties/tca/modelBpmnProperties.json");
-        modelBpmn = ResourceFileUtil.getResourceAsString("example/model-properties/tca/modelBpmn.json");
-        yamlInput = ResourceFileUtil.getResourceAsString("example/tca-policy-req/blueprint-input.yaml");
-        modelName = "example-model01";
-        controlName = "ClosedLoop_FRWL_SIG_fad4dcae_e498_11e6_852e_0050568c4ccf";
-        modelProperties = new ModelProperties(modelName, controlName, CldsEvent.ACTION_SUBMIT, false, modelBpmn,
-                modelProp);
-    }
-
-    @Test
-    public void testCreatePolicyJson() throws IOException, JSONException {
-        String result = TcaRequestFormatter.createPolicyJson(refProp, modelProperties);
-        assertNotNull(result);
-        JSONAssert.assertEquals(ResourceFileUtil.getResourceAsString("example/tca-policy-req/tca-policy-expected.json"),
-                result, true);
-    }
-
-    @Test
-    public void testUpdatedBlueprintWithConfiguration() throws IOException {
-        String result = TcaRequestFormatter.updatedBlueprintWithConfiguration(refProp, modelProperties, yamlInput);
-        assertNotNull(result);
-        assertEquals(ResourceFileUtil.getResourceAsString("example/tca-policy-req/blueprint-expected.yaml"), result);
-    }
-}
diff --git a/src/test/java/org/onap/clamp/clds/model/CldsDbServiceCacheTest.java b/src/test/java/org/onap/clamp/clds/model/CldsDbServiceCacheTest.java
deleted file mode 100644 (file)
index 3fe29dc..0000000
+++ /dev/null
@@ -1,77 +0,0 @@
-/*-
- * ============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============================================
- * Modifications copyright (c) 2018 Nokia
- * ===================================================================
- * 
- */
-
-package org.onap.clamp.clds.model;
-
-import static org.assertj.core.api.Assertions.assertThat;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-
-import java.io.IOException;
-import java.io.ObjectInputStream;
-import java.util.ArrayList;
-import java.util.List;
-import org.junit.Test;
-
-public class CldsDbServiceCacheTest {
-
-    @Test
-    public void testConstructor() throws IOException, ClassNotFoundException {
-        // given
-        CldsServiceData cldsServiceData = new CldsServiceData();
-        cldsServiceData.setServiceUUID("testUUID");
-        cldsServiceData.setAgeOfRecord(100L);
-        cldsServiceData.setServiceInvariantUUID("testInvariantUUID");
-
-        CldsVfData cldsVfData = new CldsVfData();
-        cldsVfData.setVfName("vf");
-
-        CldsVfKPIData cldsVfKpiData = new CldsVfKPIData();
-        cldsVfKpiData.setFieldPath("fieldPath");
-        cldsVfKpiData.setFieldPathValue("fieldValue");
-
-        List<CldsVfKPIData> cldsKpiList = new ArrayList<>();
-        cldsKpiList.add(cldsVfKpiData);
-        cldsVfData.setCldsKPIList(cldsKpiList);
-
-        List<CldsVfData> cldsVfs = new ArrayList<>();
-        cldsVfs.add(cldsVfData);
-        cldsServiceData.setCldsVfs(cldsVfs);
-
-        CldsDbServiceCache cldsDbServiceCache = new CldsDbServiceCache(cldsServiceData);
-
-        // when
-        ObjectInputStream reader = new ObjectInputStream(cldsDbServiceCache.getCldsDataInstream());
-        CldsServiceData cldsServiceDataResult = (CldsServiceData) reader.readObject();
-
-        // then
-        assertThat(cldsServiceDataResult).isNotNull();
-        assertThat(cldsServiceDataResult.getCldsVfs()).hasSize(1);
-        assertThat(cldsServiceDataResult.getCldsVfs().get(0).getCldsKPIList()).hasSize(1);
-
-        assertThat(cldsServiceDataResult.getServiceInvariantUUID()).isEqualTo("testInvariantUUID");
-        assertThat(cldsServiceDataResult.getServiceUUID()).isEqualTo("testUUID");
-        assertThat(cldsServiceDataResult.getAgeOfRecord()).isEqualTo(100L);
-    }
-}
diff --git a/src/test/java/org/onap/clamp/clds/model/CldsModelTest.java b/src/test/java/org/onap/clamp/clds/model/CldsModelTest.java
deleted file mode 100644 (file)
index 0a60185..0000000
+++ /dev/null
@@ -1,167 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * ONAP CLAMP
- * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights
- *                             reserved.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END============================================
- * ===================================================================
- *
- */
-
-package org.onap.clamp.clds.model;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.fail;
-
-import com.att.eelf.configuration.EELFLogger;
-import com.att.eelf.configuration.EELFManager;
-
-import javax.ws.rs.BadRequestException;
-
-import org.junit.Test;
-
-/**
- * Test org.onap.clamp.ClampDesigner.model.Model
- */
-public class CldsModelTest {
-    protected static final EELFLogger logger = EELFManager.getInstance().getLogger(CldsModelTest.class);
-
-    @Test
-    public void testCreateUsingControlName() {
-        utilCreateUsingControlName("abc-", "7c42aceb-2350-11e6-8131-fa163ea8d2da");
-        utilCreateUsingControlName("", "7c42aceb-2350-11e6-8131-fa163ea8d2da");
-    }
-
-    @Test(expected = BadRequestException.class)
-    public void testExceptionCreateUsingControlName() {
-        utilCreateUsingControlName("", "c42aceb-2350-11e6-8131-fa163ea8d2da");
-    }
-
-    @Test(expected = IllegalArgumentException.class)
-    public void testValidateActionEmptyEvent() {
-        CldsModel cldsModel = new CldsModel();
-        cldsModel.validateAction(CldsEvent.ACTION_CREATE);
-    }
-
-    @Test(expected = IllegalArgumentException.class)
-    public void testValidateActionNotExist() {
-        CldsModel cldsModel = new CldsModel();
-        cldsModel.validateAction("unknown");
-    }
-
-    @Test(expected = IllegalArgumentException.class)
-    public void testValidateActionFromCreate() {
-        CldsModel cldsModel = new CldsModel();
-        cldsModel.getEvent().setActionCd(CldsEvent.ACTION_CREATE);
-        cldsModel.validateAction(CldsEvent.ACTION_SUBMIT);
-        cldsModel.validateAction(CldsEvent.ACTION_TEST);
-        cldsModel.validateAction(CldsEvent.ACTION_DEPLOY);
-        fail("Exception should have been sent");
-    }
-
-    @Test(expected = IllegalArgumentException.class)
-    public void testValidateActionFromSubmitOrReSubmit() {
-        CldsModel cldsModel = new CldsModel();
-        cldsModel.getEvent().setActionCd(CldsEvent.ACTION_SUBMIT);
-        cldsModel.validateAction(CldsEvent.ACTION_RESUBMIT);
-        try {
-            cldsModel.validateAction(CldsEvent.ACTION_RESTART);
-            fail("Exception should have been sent");
-        } catch (IllegalArgumentException e) {
-            logger.error("Exception caught IllegalArgumentException as expected", e);
-        }
-        cldsModel.getEvent().setActionCd(CldsEvent.ACTION_RESUBMIT);
-        cldsModel.validateAction(CldsEvent.ACTION_RESUBMIT);
-        cldsModel.validateAction(CldsEvent.ACTION_RESTART);
-        fail("Exception should have been sent");
-    }
-
-    @Test(expected = IllegalArgumentException.class)
-    public void testValidateActionFromDistribute() {
-        CldsModel cldsModel = new CldsModel();
-        cldsModel.getEvent().setActionCd(CldsEvent.ACTION_DISTRIBUTE);
-        cldsModel.validateAction(CldsEvent.ACTION_RESUBMIT);
-        cldsModel.validateAction(CldsEvent.ACTION_DEPLOY);
-        cldsModel.validateAction(CldsEvent.ACTION_CREATE);
-        fail("Exception should have been sent");
-    }
-
-    @Test(expected = IllegalArgumentException.class)
-    public void testValidateActionFromUndeploy() {
-        CldsModel cldsModel = new CldsModel();
-        cldsModel.getEvent().setActionCd(CldsEvent.ACTION_UNDEPLOY);
-        cldsModel.validateAction(CldsEvent.ACTION_UPDATE);
-        cldsModel.validateAction(CldsEvent.ACTION_DEPLOY);
-        cldsModel.validateAction(CldsEvent.ACTION_RESUBMIT);
-        cldsModel.validateAction(CldsEvent.ACTION_CREATE);
-        fail("Exception should have been sent");
-    }
-
-    @Test(expected = IllegalArgumentException.class)
-    public void testValidateActionFromDeploy() {
-        CldsModel cldsModel = new CldsModel();
-        cldsModel.getEvent().setActionCd(CldsEvent.ACTION_DEPLOY);
-        cldsModel.validateAction(CldsEvent.ACTION_DEPLOY);
-        cldsModel.validateAction(CldsEvent.ACTION_UNDEPLOY);
-        cldsModel.validateAction(CldsEvent.ACTION_UPDATE);
-        cldsModel.validateAction(CldsEvent.ACTION_STOP);
-        cldsModel.validateAction(CldsEvent.ACTION_CREATE);
-        fail("Exception should have been sent");
-    }
-
-    @Test(expected = IllegalArgumentException.class)
-    public void testValidateActionFromRestartOrUpdate() {
-        CldsModel cldsModel = new CldsModel();
-        cldsModel.getEvent().setActionCd(CldsEvent.ACTION_RESTART);
-        cldsModel.validateAction(CldsEvent.ACTION_DEPLOY);
-        cldsModel.validateAction(CldsEvent.ACTION_UPDATE);
-        cldsModel.validateAction(CldsEvent.ACTION_STOP);
-        cldsModel.validateAction(CldsEvent.ACTION_UNDEPLOY);
-        try {
-            cldsModel.validateAction(CldsEvent.ACTION_CREATE);
-            fail("Exception should have been sent");
-        } catch (IllegalArgumentException e) {
-            System.out.println("Exception caught IllegalArgumentException as expected");
-        }
-        cldsModel.getEvent().setActionCd(CldsEvent.ACTION_UPDATE);
-        cldsModel.validateAction(CldsEvent.ACTION_DEPLOY);
-        cldsModel.validateAction(CldsEvent.ACTION_UPDATE);
-        cldsModel.validateAction(CldsEvent.ACTION_STOP);
-        cldsModel.validateAction(CldsEvent.ACTION_UNDEPLOY);
-        cldsModel.validateAction(CldsEvent.ACTION_CREATE);
-        fail("Exception should have been sent");
-    }
-
-    @Test(expected = IllegalArgumentException.class)
-    public void testValidateActionFromStop() {
-        CldsModel cldsModel = new CldsModel();
-        cldsModel.getEvent().setActionCd(CldsEvent.ACTION_STOP);
-        cldsModel.validateAction(CldsEvent.ACTION_UPDATE);
-        cldsModel.validateAction(CldsEvent.ACTION_RESTART);
-        cldsModel.validateAction(CldsEvent.ACTION_UNDEPLOY);
-        cldsModel.validateAction(CldsEvent.ACTION_CREATE);
-        fail("Exception should have been sent");
-    }
-
-    /**
-     * Utility Method to create model from controlname and uuid.
-     */
-    public void utilCreateUsingControlName(String controlNamePrefix, String controlNameUuid) {
-        CldsModel model = CldsModel.createUsingControlName(controlNamePrefix + controlNameUuid);
-        assertEquals(controlNamePrefix, model.getControlNamePrefix());
-        assertEquals(controlNameUuid, model.getControlNameUuid());
-    }
-}
diff --git a/src/test/java/org/onap/clamp/clds/model/DcaeEventTest.java b/src/test/java/org/onap/clamp/clds/model/DcaeEventTest.java
deleted file mode 100644 (file)
index 315e656..0000000
+++ /dev/null
@@ -1,74 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * ONAP CLAMP
- * ================================================================================
- * Copyright (C) 2019 Samsung. 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 static org.junit.Assert.assertEquals;
-import org.junit.Test;
-import javax.ws.rs.BadRequestException;
-import java.util.Arrays;
-
-public class DcaeEventTest {
-
-    @Test
-    public void testGetCldsActionId() {
-        //given
-        DcaeEvent dcaeEvent = new DcaeEvent();
-        dcaeEvent.setEvent(DcaeEvent.EVENT_CREATED);
-        dcaeEvent.setResourceUUID("1");
-        dcaeEvent.setServiceUUID("2");
-
-        //when
-        String cldsAction = dcaeEvent.getCldsActionCd();
-        dcaeEvent.setInstances(Arrays.asList(new CldsModelInstance()));
-        //then
-        assertEquals(CldsEvent.ACTION_CREATE, cldsAction);
-
-        //when
-        dcaeEvent.setEvent(DcaeEvent.EVENT_DEPLOYMENT);
-        //then
-        assertEquals(CldsEvent.ACTION_DEPLOY, dcaeEvent.getCldsActionCd());
-
-        //when
-        dcaeEvent.setInstances(null);
-        //then
-        assertEquals(CldsEvent.ACTION_DEPLOY, dcaeEvent.getCldsActionCd());
-
-        //when
-        dcaeEvent.setEvent(DcaeEvent.EVENT_UNDEPLOYMENT);
-        //then
-        assertEquals(CldsEvent.ACTION_UNDEPLOY, dcaeEvent.getCldsActionCd());
-
-    }
-
-    @Test(expected = BadRequestException.class)
-    public void shouldReturnBadRequestException() {
-        //given
-        DcaeEvent dcaeEvent = new DcaeEvent();
-        dcaeEvent.setResourceUUID("1");
-        dcaeEvent.setServiceUUID("2");
-        //when
-        dcaeEvent.setEvent("BadEvent");
-        //then
-        dcaeEvent.getCldsActionCd();
-    }
-}
diff --git a/src/test/java/org/onap/clamp/clds/model/prop/CustomModelElement.java b/src/test/java/org/onap/clamp/clds/model/prop/CustomModelElement.java
deleted file mode 100644 (file)
index 31d0be8..0000000
+++ /dev/null
@@ -1,61 +0,0 @@
-/*-\r
- * ============LICENSE_START=======================================================\r
- * ONAP CLAMP\r
- * ================================================================================\r
- * Copyright (C) 2017-2018 AT&T Intellectual Property. All rights\r
- *                             reserved.\r
- * ================================================================================\r
- * Modifications Copyright (c) 2019 Samsung\r
- * ================================================================================\r
- * Licensed under the Apache License, Version 2.0 (the "License");\r
- * you may not use this file except in compliance with the License.\r
- * You may obtain a copy of the License at\r
- *\r
- * http://www.apache.org/licenses/LICENSE-2.0\r
- *\r
- * Unless required by applicable law or agreed to in writing, software\r
- * distributed under the License is distributed on an "AS IS" BASIS,\r
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
- * See the License for the specific language governing permissions and\r
- * limitations under the License.\r
- * ============LICENSE_END============================================\r
- * ===================================================================\r
- *\r
- */\r
-\r
-package org.onap.clamp.clds.model.prop;\r
-\r
-import com.google.gson.JsonObject;\r
-import org.onap.clamp.clds.model.properties.AbstractModelElement;\r
-import org.onap.clamp.clds.model.properties.ModelBpmn;\r
-import org.onap.clamp.clds.util.JsonUtils;\r
-\r
-/**\r
- * A CustomModelElement to test the capability to add new elements on the fly.\r
- */\r
-public class CustomModelElement extends AbstractModelElement {\r
-\r
-    private String test;\r
-    private static final String CUSTOM_TYPE = "customType";\r
-\r
-    /**\r
-     * Main Constructor.\r
-     */\r
-    public CustomModelElement(ModelBpmn modelBpmn, JsonObject modelJson) {\r
-        super(CUSTOM_TYPE, modelBpmn, modelJson);\r
-        topicPublishes = JsonUtils.getStringValueByName(modelElementJsonNode, "topicPublishes");\r
-        test = JsonUtils.getStringValueByName(modelElementJsonNode, "test");\r
-    }\r
-\r
-    public static final String getType() {\r
-        return CUSTOM_TYPE;\r
-    }\r
-\r
-    public String getTest() {\r
-        return test;\r
-    }\r
-\r
-    public void setTest(String test) {\r
-        this.test = test;\r
-    }\r
-}\r
diff --git a/src/test/java/org/onap/clamp/clds/model/prop/CustomModelElementTest.java b/src/test/java/org/onap/clamp/clds/model/prop/CustomModelElementTest.java
deleted file mode 100644 (file)
index de3126a..0000000
+++ /dev/null
@@ -1,56 +0,0 @@
-/*-\r
- * ============LICENSE_START=======================================================\r
- * ONAP CLAMP\r
- * ================================================================================\r
- * Copyright (C) 2017-2018 AT&T Intellectual Property. All rights\r
- *                             reserved.\r
- * ================================================================================\r
- * Licensed under the Apache License, Version 2.0 (the "License");\r
- * you may not use this file except in compliance with the License.\r
- * You may obtain a copy of the License at\r
- *\r
- * http://www.apache.org/licenses/LICENSE-2.0\r
- *\r
- * Unless required by applicable law or agreed to in writing, software\r
- * distributed under the License is distributed on an "AS IS" BASIS,\r
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
- * See the License for the specific language governing permissions and\r
- * limitations under the License.\r
- * ============LICENSE_END============================================\r
- * ===================================================================\r
- * \r
- */\r
-\r
-package org.onap.clamp.clds.model.prop;\r
-\r
-import java.io.IOException;\r
-\r
-import org.junit.Assert;\r
-import org.junit.Test;\r
-import org.onap.clamp.clds.model.properties.ModelProperties;\r
-import org.onap.clamp.clds.util.ResourceFileUtil;\r
-\r
-public class CustomModelElementTest {\r
-\r
-    public CustomModelElementTest() {\r
-    }\r
-\r
-    @Test\r
-    public void testCustomElement() throws IOException {\r
-        String modelBpmnProp = ResourceFileUtil.getResourceAsString("example/model-properties/custom/modelBpmn.json");\r
-        String modelProp = ResourceFileUtil\r
-                .getResourceAsString("example/model-properties/custom/modelBpmnProperties.json");\r
-        String modName = "example-model-name";\r
-        String controlName = "example-control-name";\r
-        CustomModelElement customModelElement = null;\r
-        // Instantiate first, we should not have our CustomModelElement yet\r
-        ModelProperties prop = new ModelProperties(modName, controlName, null, true, modelBpmnProp, modelProp);\r
-        Assert.assertNotNull(prop);\r
-        customModelElement = prop.getType(CustomModelElement.class);\r
-        Assert.assertNull(customModelElement);\r
-        ModelProperties.registerModelElement(CustomModelElement.class, CustomModelElement.getType());\r
-        customModelElement = prop.getType(CustomModelElement.class);\r
-        Assert.assertNotNull(customModelElement);\r
-        Assert.assertEquals("This is a test", customModelElement.getTest());\r
-    }\r
-}\r
diff --git a/src/test/java/org/onap/clamp/clds/model/prop/ModelPropertiesTest.java b/src/test/java/org/onap/clamp/clds/model/prop/ModelPropertiesTest.java
deleted file mode 100644 (file)
index 4195f90..0000000
+++ /dev/null
@@ -1,142 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * ONAP CLAMP
- * ================================================================================
- * Copyright (C) 2017-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.prop;
-
-import static org.assertj.core.api.Assertions.assertThat;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertTrue;
-
-import java.io.IOException;
-import java.util.Arrays;
-
-import org.junit.Before;
-import org.junit.Test;
-import org.onap.clamp.clds.model.CldsModel;
-import org.onap.clamp.clds.model.properties.Holmes;
-import org.onap.clamp.clds.model.properties.ModelProperties;
-import org.onap.clamp.clds.model.properties.Policy;
-import org.onap.clamp.clds.model.properties.PolicyItem;
-import org.onap.clamp.clds.model.properties.Tca;
-import org.onap.clamp.clds.util.ResourceFileUtil;
-
-/**
- * Test org.onap.clamp.ClampDesigner.model.prop package using ModelProperties.
- */
-public class ModelPropertiesTest {
-
-    @Before
-    public void registerNewClasses() {
-        ModelProperties.registerModelElement(Holmes.class, Holmes.getType());
-    }
-
-    @Test
-    public void testTcaModelDecoding() throws IOException {
-        String modelBpmnProp = ResourceFileUtil
-            .getResourceAsString("example/model-properties/tca/modelBpmnProperties.json");
-        String modelBpmn = ResourceFileUtil.getResourceAsString("example/model-properties/tca/modelBpmn.json");
-        ModelProperties prop = new ModelProperties("example-model-name", "example-control-name", null, true, modelBpmn,
-            modelBpmnProp);
-        Policy policy = prop.getType(Policy.class);
-        assertTrue(policy.isFound());
-        assertEquals(1, policy.getPolicyChains().size());
-        assertEquals("0", policy.getPolicyChains().get(0).getPolicyId());
-        assertEquals(1, policy.getPolicyChains().get(0).getPolicyItems().size());
-        PolicyItem firstPolicyItem = policy.getPolicyChains().get(0).getPolicyItems().get(0);
-        assertEquals("resourceid", firstPolicyItem.getTargetResourceId());
-        assertEquals(180, firstPolicyItem.getRetryTimeLimit());
-        assertEquals(3, firstPolicyItem.getMaxRetries());
-        assertEquals("", firstPolicyItem.getParentPolicy());
-        assertThat(firstPolicyItem.getParentPolicyConditions()).isEmpty();
-        Tca tca = prop.getType(Tca.class);
-        assertNotNull(tca);
-        assertTrue(tca.isFound());
-        assertEquals("vFirewallBroadcastPackets", tca.getTcaItem().getEventName());
-        assertEquals("VNF", tca.getTcaItem().getControlLoopSchemaType());
-        assertEquals("policy1", tca.getTcaItem().getPolicyId());
-        assertEquals("f734f031-10aa-t8fb-330f-04dde2886325", tca.getTcaItem().getTcaUuId());
-        assertEquals(2, tca.getTcaItem().getTcaThresholds().size());
-        assertEquals("ABATED", tca.getTcaItem().getTcaThresholds().get(0).getClosedLoopEventStatus());
-        assertEquals("$.event.measurementsForVfScalingFields.additionalMeasurements[*].arrayOfFields[0].value",
-            tca.getTcaItem().getTcaThresholds().get(0).getFieldPath());
-        assertEquals("LESS_OR_EQUAL", tca.getTcaItem().getTcaThresholds().get(0).getOperator());
-        assertEquals(Integer.valueOf(123), tca.getTcaItem().getTcaThresholds().get(0).getThreshold());
-        assertEquals("ONSET", tca.getTcaItem().getTcaThresholds().get(1).getClosedLoopEventStatus());
-        assertEquals("$.event.measurementsForVfScalingFields.additionalMeasurements[*].arrayOfFields[0].value",
-            tca.getTcaItem().getTcaThresholds().get(1).getFieldPath());
-        assertEquals("GREATER_OR_EQUAL", tca.getTcaItem().getTcaThresholds().get(1).getOperator());
-        assertEquals(Integer.valueOf(123), tca.getTcaItem().getTcaThresholds().get(1).getThreshold());
-        // Test global prop
-        assertEquals("vnfRecipe", prop.getGlobal().getActionSet());
-        assertEquals("4cc5b45a-1f63-4194-8100-cd8e14248c92", prop.getGlobal().getService());
-        assertTrue(Arrays.equals(new String[] { "023a3f0d-1161-45ff-b4cf-8918a8ccf3ad" },
-            prop.getGlobal().getResourceVf().toArray()));
-        assertTrue(Arrays.equals(new String[] { "SNDGCA64", "ALPRGAED", "LSLEILAA", "MDTWNJC1" },
-            prop.getGlobal().getLocation().toArray()));
-        assertEquals("value1", prop.getGlobal().getDeployParameters().get("input1").getAsString());
-        assertEquals("value2", prop.getGlobal().getDeployParameters().get("input2").getAsString());
-    }
-
-    @Test
-    public void testHolmesModelDecoding() throws IOException {
-        String modelBpmnProp = ResourceFileUtil
-            .getResourceAsString("example/model-properties/holmes/modelBpmnProperties.json");
-        String modelBpmn = ResourceFileUtil.getResourceAsString("example/model-properties/holmes/modelBpmn.json");
-        ModelProperties prop = new ModelProperties("example-model-name", "example-control-name", null, true, modelBpmn,
-            modelBpmnProp);
-        Policy policy = prop.getType(Policy.class);
-        assertTrue(policy.isFound());
-        assertEquals(1, policy.getPolicyChains().size());
-        assertEquals("0", policy.getPolicyChains().get(0).getPolicyId());
-        assertEquals(1, policy.getPolicyChains().get(0).getPolicyItems().size());
-        PolicyItem firstPolicyItem = policy.getPolicyChains().get(0).getPolicyItems().get(0);
-        assertEquals("resourceid", firstPolicyItem.getTargetResourceId());
-        assertEquals(180, firstPolicyItem.getRetryTimeLimit());
-        assertEquals(3, firstPolicyItem.getMaxRetries());
-        assertEquals("", firstPolicyItem.getParentPolicy());
-        assertThat(firstPolicyItem.getParentPolicyConditions()).isEmpty();
-        Holmes holmes = prop.getType(Holmes.class);
-        assertNotNull(holmes);
-        assertTrue(holmes.isFound());
-        assertEquals("configPolicy1", holmes.getConfigPolicyName());
-        assertEquals("blabla", holmes.getCorrelationLogic());
-        // Test global prop
-        assertEquals("vnfRecipe", prop.getGlobal().getActionSet());
-        assertEquals("4cc5b45a-1f63-4194-8100-cd8e14248c92", prop.getGlobal().getService());
-        assertTrue(Arrays.equals(new String[] { "f5213e3a-9191-4362-93b5-b67f8d770e44" },
-            prop.getGlobal().getResourceVf().toArray()));
-        assertTrue(Arrays.equals(new String[] { "SNDGCA64", "ALPRGAED", "LSLEILAA", "MDTWNJC1" },
-            prop.getGlobal().getLocation().toArray()));
-        assertEquals("value1", prop.getGlobal().getDeployParameters().get("input1").getAsString());
-        assertEquals("value2", prop.getGlobal().getDeployParameters().get("input2").getAsString());
-    }
-
-    @Test
-    public void testGetVf() throws IOException {
-        CldsModel cldsModel = new CldsModel();
-        cldsModel
-        .setPropText(ResourceFileUtil.getResourceAsString("example/model-properties/tca/modelBpmnProperties.json"));
-        assertEquals("023a3f0d-1161-45ff-b4cf-8918a8ccf3ad", ModelProperties.getVf(cldsModel));
-    }
-}
\ No newline at end of file
index 199d053..65b95a1 100644 (file)
@@ -43,11 +43,11 @@ public class ToscaYamlToJsonConvertorTest {
     @Test
     public final void testParseToscaYaml() throws IOException {
         String toscaModelYaml = ResourceFileUtil.getResourceAsString("tosca/tosca_example.yaml");
-        ToscaYamlToJsonConvertor convertor = new ToscaYamlToJsonConvertor(null);
+        ToscaYamlToJsonConvertor convertor = new ToscaYamlToJsonConvertor();
 
         String parsedJsonSchema = convertor.parseToscaYaml(toscaModelYaml);
         assertNotNull(parsedJsonSchema);
         JSONAssert.assertEquals(ResourceFileUtil.getResourceAsString("tosca/policy-yaml-to-json.json"),
-            parsedJsonSchema, true);
+                parsedJsonSchema, true);
     }
 }
diff --git a/src/test/java/org/onap/clamp/clds/transform/XslTransformerTest.java b/src/test/java/org/onap/clamp/clds/transform/XslTransformerTest.java
deleted file mode 100644 (file)
index 5cfa4fa..0000000
+++ /dev/null
@@ -1,59 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * ONAP CLAMP
- * ================================================================================
- * Copyright (C) 2017-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.transform;
-
-import static org.junit.Assert.assertNotNull;
-
-import java.io.IOException;
-
-import javax.xml.transform.TransformerException;
-
-import org.json.JSONException;
-import org.junit.Test;
-import org.onap.clamp.clds.util.ResourceFileUtil;
-import org.skyscreamer.jsonassert.JSONAssert;
-
-public class XslTransformerTest {
-
-    /**
-     * This test validates the XSLT to convert BPMN xml to BPMN JSON.
-     * 
-     * @throws TransformerException
-     *             In case of issues
-     * @throws IOException
-     *             In case of issues
-     * @throws JSONException
-     *             In case of issues to decode Json
-     */
-    @Test
-    public void xslTransformTest() throws TransformerException, IOException, JSONException {
-        XslTransformer xslTransformer = new XslTransformer();
-        xslTransformer.setXslResourceName("xsl/clds-bpmn-transformer.xsl");
-        String bpmnJson = xslTransformer
-                .doXslTransformToString(ResourceFileUtil.getResourceAsString("example/xsl-validation/modelBpmn.xml"));
-        assertNotNull(bpmnJson);
-        JSONAssert.assertEquals(ResourceFileUtil.getResourceAsString("example/xsl-validation/modelBpmnForVerif.json"),
-                bpmnJson, true);
-    }
-}